1 ;;; gnus-sum.el --- summary mode commands for Gnus
2 ;; Copyright (C) 1996,97,98,99 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
28 (eval-when-compile (require 'cl))
38 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
40 (defcustom gnus-kill-summary-on-exit t
41 "*If non-nil, kill the summary buffer when you exit from it.
42 If nil, the summary will become a \"*Dead Summary*\" buffer, and
43 it will be killed sometime later."
44 :group 'gnus-summary-exit
47 (defcustom gnus-fetch-old-headers nil
48 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
49 If an unread article in the group refers to an older, already read (or
50 just marked as read) article, the old article will not normally be
51 displayed in the Summary buffer. If this variable is non-nil, Gnus
52 will attempt to grab the headers to the old articles, and thereby
53 build complete threads. If it has the value `some', only enough
54 headers to connect otherwise loose threads will be displayed. This
55 variable can also be a number. In that case, no more than that number
56 of old headers will be fetched. If it has the value `invisible', all
57 old headers will be fetched, but none will be displayed.
59 The server has to support NOV for any of this to work."
61 :type '(choice (const :tag "off" nil)
64 (sexp :menu-tag "other" t)))
66 (defcustom gnus-refer-thread-limit 200
67 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
68 If t, fetch all the available old headers."
71 (sexp :menu-tag "other" t)))
73 (defcustom gnus-summary-make-false-root 'adopt
74 "*nil means that Gnus won't gather loose threads.
75 If the root of a thread has expired or been read in a previous
76 session, the information necessary to build a complete thread has been
77 lost. Instead of having many small sub-threads from this original thread
78 scattered all over the summary buffer, Gnus can gather them.
80 If non-nil, Gnus will try to gather all loose sub-threads from an
81 original thread into one large thread.
83 If this variable is non-nil, it should be one of `none', `adopt',
86 If this variable is `none', Gnus will not make a false root, but just
87 present the sub-threads after another.
88 If this variable is `dummy', Gnus will create a dummy root that will
89 have all the sub-threads as children.
90 If this variable is `adopt', Gnus will make one of the \"children\"
91 the parent and mark all the step-children as such.
92 If this variable is `empty', the \"children\" are printed with empty
93 subject fields. (Or rather, they will be printed with a string
94 given by the `gnus-summary-same-subject' variable.)"
96 :type '(choice (const :tag "off" nil)
102 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
103 "*A regexp to match subjects to be excluded from loose thread gathering.
104 As loose thread gathering is done on subjects only, that means that
105 there can be many false gatherings performed. By rooting out certain
106 common subjects, gathering might become saner."
110 (defcustom gnus-summary-gather-subject-limit nil
111 "*Maximum length of subject comparisons when gathering loose threads.
112 Use nil to compare full subjects. Setting this variable to a low
113 number will help gather threads that have been corrupted by
114 newsreaders chopping off subject lines, but it might also mean that
115 unrelated articles that have subject that happen to begin with the
116 same few characters will be incorrectly gathered.
118 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
121 :type '(choice (const :tag "off" nil)
123 (sexp :menu-tag "on" t)))
125 (defcustom gnus-simplify-subject-functions nil
126 "List of functions taking a string argument that simplify subjects.
127 The functions are applied recursively.
129 Useful functions to put in this list include: `gnus-simplify-subject-re',
130 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
132 :type '(repeat function))
134 (defcustom gnus-simplify-ignored-prefixes nil
135 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
137 :type '(choice (const :tag "off" nil)
140 (defcustom gnus-build-sparse-threads nil
141 "*If non-nil, fill in the gaps in threads.
142 If `some', only fill in the gaps that are needed to tie loose threads
143 together. If `more', fill in all leaf nodes that Gnus can find. If
144 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
146 :type '(choice (const :tag "off" nil)
149 (sexp :menu-tag "all" t)))
151 (defcustom gnus-summary-thread-gathering-function
152 'gnus-gather-threads-by-subject
153 "*Function used for gathering loose threads.
154 There are two pre-defined functions: `gnus-gather-threads-by-subject',
155 which only takes Subjects into consideration; and
156 `gnus-gather-threads-by-references', which compared the References
157 headers of the articles to find matches."
159 :type '(radio (function-item gnus-gather-threads-by-subject)
160 (function-item gnus-gather-threads-by-references)
161 (function :tag "other")))
163 (defcustom gnus-summary-same-subject ""
164 "*String indicating that the current article has the same subject as the previous.
165 This variable will only be used if the value of
166 `gnus-summary-make-false-root' is `empty'."
167 :group 'gnus-summary-format
170 (defcustom gnus-summary-goto-unread t
171 "*If t, many commands will go to the next unread article.
172 This applies to marking commands as well as other commands that
173 \"naturally\" select the next article, like, for instance, `SPC' at
174 the end of an article.
175 If nil, only the marking commands will go to the next (un)read article.
176 If `never', commands that usually go to the next unread article, will
177 go to the next article, whether it is read or not."
178 :group 'gnus-summary-marks
179 :link '(custom-manual "(gnus)Setting Marks")
180 :type '(choice (const :tag "off" nil)
182 (sexp :menu-tag "on" t)))
184 (defcustom gnus-summary-default-score 0
185 "*Default article score level.
186 All scores generated by the score files will be added to this score.
187 If this variable is nil, scoring will be disabled."
188 :group 'gnus-score-default
189 :type '(choice (const :tag "disable")
192 (defcustom gnus-summary-zcore-fuzz 0
193 "*Fuzziness factor for the zcore in the summary buffer.
194 Articles with scores closer than this to `gnus-summary-default-score'
196 :group 'gnus-summary-format
199 (defcustom gnus-simplify-subject-fuzzy-regexp nil
200 "*Strings to be removed when doing fuzzy matches.
201 This can either be a regular expression or list of regular expressions
202 that will be removed from subject strings if fuzzy subject
203 simplification is selected."
205 :type '(repeat regexp))
207 (defcustom gnus-show-threads t
208 "*If non-nil, display threads in summary mode."
212 (defcustom gnus-thread-hide-subtree nil
213 "*If non-nil, hide all threads initially.
214 If threads are hidden, you have to run the command
215 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
216 to expose hidden threads."
220 (defcustom gnus-thread-hide-killed t
221 "*If non-nil, hide killed threads automatically."
225 (defcustom gnus-thread-ignore-subject t
226 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
227 If nil, articles that have different subjects from their parents will
228 start separate threads."
232 (defcustom gnus-thread-operation-ignore-subject t
233 "*If non-nil, subjects will be ignored when doing thread commands.
234 This affects commands like `gnus-summary-kill-thread' and
235 `gnus-summary-lower-thread'.
237 If this variable is nil, articles in the same thread with different
238 subjects will not be included in the operation in question. If this
239 variable is `fuzzy', only articles that have subjects that are fuzzily
240 equal will be included."
242 :type '(choice (const :tag "off" nil)
246 (defcustom gnus-thread-indent-level 4
247 "*Number that says how much each sub-thread should be indented."
251 (defcustom gnus-auto-extend-newsgroup t
252 "*If non-nil, extend newsgroup forward and backward when requested."
253 :group 'gnus-summary-choose
256 (defcustom gnus-auto-select-first t
257 "*If nil, don't select the first unread article when entering a group.
258 If this variable is `best', select the highest-scored unread article
259 in the group. If t, select the first unread article.
261 This variable can also be a function to place point on a likely
262 subject line. Useful values include `gnus-summary-first-unread-subject',
263 `gnus-summary-first-unread-article' and
264 `gnus-summary-best-unread-article'.
266 If you want to prevent automatic selection of the first unread article
267 in some newsgroups, set the variable to nil in
268 `gnus-select-group-hook'."
269 :group 'gnus-group-select
270 :type '(choice (const :tag "none" nil)
272 (sexp :menu-tag "first" t)
273 (function-item gnus-summary-first-unread-subject)
274 (function-item gnus-summary-first-unread-article)
275 (function-item gnus-summary-best-unread-article)))
277 (defcustom gnus-auto-select-next t
278 "*If non-nil, offer to go to the next group from the end of the previous.
279 If the value is t and the next newsgroup is empty, Gnus will exit
280 summary mode and go back to group mode. If the value is neither nil
281 nor t, Gnus will select the following unread newsgroup. In
282 particular, if the value is the symbol `quietly', the next unread
283 newsgroup will be selected without any confirmation, and if it is
284 `almost-quietly', the next group will be selected without any
285 confirmation if you are located on the last article in the group.
286 Finally, if this variable is `slightly-quietly', the `Z n' command
287 will go to the next group without confirmation."
288 :group 'gnus-summary-maneuvering
289 :type '(choice (const :tag "off" nil)
291 (const almost-quietly)
292 (const slightly-quietly)
293 (sexp :menu-tag "on" t)))
295 (defcustom gnus-auto-select-same nil
296 "*If non-nil, select the next article with the same subject.
297 If there are no more articles with the same subject, go to
298 the first unread article."
299 :group 'gnus-summary-maneuvering
302 (defcustom gnus-summary-check-current nil
303 "*If non-nil, consider the current article when moving.
304 The \"unread\" movement commands will stay on the same line if the
305 current article is unread."
306 :group 'gnus-summary-maneuvering
309 (defcustom gnus-auto-center-summary t
310 "*If non-nil, always center the current summary buffer.
311 In particular, if `vertical' do only vertical recentering. If non-nil
312 and non-`vertical', do both horizontal and vertical recentering."
313 :group 'gnus-summary-maneuvering
314 :type '(choice (const :tag "none" nil)
316 (integer :tag "height")
317 (sexp :menu-tag "both" t)))
319 (defcustom gnus-show-all-headers nil
320 "*If non-nil, don't hide any headers."
321 :group 'gnus-article-hiding
322 :group 'gnus-article-headers
325 (defcustom gnus-summary-ignore-duplicates nil
326 "*If non-nil, ignore articles with identical Message-ID headers."
330 (defcustom gnus-single-article-buffer t
331 "*If non-nil, display all articles in the same buffer.
332 If nil, each group will get its own article buffer."
333 :group 'gnus-article-various
336 (defcustom gnus-break-pages t
337 "*If non-nil, do page breaking on articles.
338 The page delimiter is specified by the `gnus-page-delimiter'
340 :group 'gnus-article-various
343 (defcustom gnus-move-split-methods nil
344 "*Variable used to suggest where articles are to be moved to.
345 It uses the same syntax as the `gnus-split-methods' variable."
346 :group 'gnus-summary-mail
347 :type '(repeat (choice (list :value (fun) function)
348 (cons :value ("" "") regexp (repeat string))
351 (defcustom gnus-unread-mark ? ;Whitespace
352 "*Mark used for unread articles."
353 :group 'gnus-summary-marks
356 (defcustom gnus-ticked-mark ?!
357 "*Mark used for ticked articles."
358 :group 'gnus-summary-marks
361 (defcustom gnus-dormant-mark ??
362 "*Mark used for dormant articles."
363 :group 'gnus-summary-marks
366 (defcustom gnus-del-mark ?r
367 "*Mark used for del'd articles."
368 :group 'gnus-summary-marks
371 (defcustom gnus-read-mark ?R
372 "*Mark used for read articles."
373 :group 'gnus-summary-marks
376 (defcustom gnus-expirable-mark ?E
377 "*Mark used for expirable articles."
378 :group 'gnus-summary-marks
381 (defcustom gnus-killed-mark ?K
382 "*Mark used for killed articles."
383 :group 'gnus-summary-marks
386 (defcustom gnus-souped-mark ?F
387 "*Mark used for killed articles."
388 :group 'gnus-summary-marks
391 (defcustom gnus-kill-file-mark ?X
392 "*Mark used for articles killed by kill files."
393 :group 'gnus-summary-marks
396 (defcustom gnus-low-score-mark ?Y
397 "*Mark used for articles with a low score."
398 :group 'gnus-summary-marks
401 (defcustom gnus-catchup-mark ?C
402 "*Mark used for articles that are caught up."
403 :group 'gnus-summary-marks
406 (defcustom gnus-replied-mark ?A
407 "*Mark used for articles that have been replied to."
408 :group 'gnus-summary-marks
411 (defcustom gnus-cached-mark ?*
412 "*Mark used for articles that are in the cache."
413 :group 'gnus-summary-marks
416 (defcustom gnus-saved-mark ?S
417 "*Mark used for articles that have been saved to."
418 :group 'gnus-summary-marks
421 (defcustom gnus-ancient-mark ?O
422 "*Mark used for ancient articles."
423 :group 'gnus-summary-marks
426 (defcustom gnus-sparse-mark ?Q
427 "*Mark used for sparsely reffed articles."
428 :group 'gnus-summary-marks
431 (defcustom gnus-canceled-mark ?G
432 "*Mark used for canceled articles."
433 :group 'gnus-summary-marks
436 (defcustom gnus-duplicate-mark ?M
437 "*Mark used for duplicate articles."
438 :group 'gnus-summary-marks
441 (defcustom gnus-undownloaded-mark ?@
442 "*Mark used for articles that weren't downloaded."
443 :group 'gnus-summary-marks
446 (defcustom gnus-downloadable-mark ?%
447 "*Mark used for articles that are to be downloaded."
448 :group 'gnus-summary-marks
451 (defcustom gnus-unsendable-mark ?=
452 "*Mark used for articles that won't be sent."
453 :group 'gnus-summary-marks
456 (defcustom gnus-score-over-mark ?+
457 "*Score mark used for articles with high scores."
458 :group 'gnus-summary-marks
461 (defcustom gnus-score-below-mark ?-
462 "*Score mark used for articles with low scores."
463 :group 'gnus-summary-marks
466 (defcustom gnus-empty-thread-mark ? ;Whitespace
467 "*There is no thread under the article."
468 :group 'gnus-summary-marks
471 (defcustom gnus-not-empty-thread-mark ?=
472 "*There is a thread under the article."
473 :group 'gnus-summary-marks
476 (defcustom gnus-view-pseudo-asynchronously nil
477 "*If non-nil, Gnus will view pseudo-articles asynchronously."
478 :group 'gnus-extract-view
481 (defcustom gnus-auto-expirable-marks
482 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
483 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
484 gnus-souped-mark gnus-duplicate-mark)
485 "*The list of marks converted into expiration if a group is auto-expirable."
487 :type '(repeat character))
489 (defcustom gnus-inhibit-user-auto-expire t
490 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
494 (defcustom gnus-view-pseudos nil
495 "*If `automatic', pseudo-articles will be viewed automatically.
496 If `not-confirm', pseudos will be viewed automatically, and the user
497 will not be asked to confirm the command."
498 :group 'gnus-extract-view
499 :type '(choice (const :tag "off" nil)
501 (const not-confirm)))
503 (defcustom gnus-view-pseudos-separately t
504 "*If non-nil, one pseudo-article will be created for each file to be viewed.
505 If nil, all files that use the same viewing command will be given as a
506 list of parameters to that command."
507 :group 'gnus-extract-view
510 (defcustom gnus-insert-pseudo-articles t
511 "*If non-nil, insert pseudo-articles when decoding articles."
512 :group 'gnus-extract-view
515 (defcustom gnus-summary-dummy-line-format
517 "*The format specification for the dummy roots in the summary buffer.
518 It works along the same lines as a normal formatting string,
519 with some simple extensions.
522 :group 'gnus-threading
525 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
526 "*The format specification for the summary mode line.
527 It works along the same lines as a normal formatting string,
528 with some simple extensions:
531 %p Unprefixed group name
532 %A Current article number
533 %z Current article score
535 %U Number of unread articles in the group
536 %e Number of unselected articles in the group
537 %Z A string with unread/unselected article counts
538 %g Shortish group name
539 %S Subject of the current article
541 %s Current score file name
542 %d Number of dormant articles
543 %r Number of articles that have been marked as read in this session
544 %E Number of articles expunged by the score files"
545 :group 'gnus-summary-format
548 (defcustom gnus-list-identifiers nil
549 "Regexp that matches list identifiers to be removed from subject.
550 This can also be a list of regexps."
551 :group 'gnus-summary-format
552 :group 'gnus-article-hiding
553 :type '(choice (const :tag "none" nil)
555 (repeat :value (".*") regexp)))
557 (defcustom gnus-summary-mark-below 0
558 "*Mark all articles with a score below this variable as read.
559 This variable is local to each summary buffer and usually set by the
561 :group 'gnus-score-default
564 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
565 "*List of functions used for sorting articles in the summary buffer.
566 This variable is only used when not using a threaded display."
567 :group 'gnus-summary-sort
568 :type '(repeat (choice (function-item gnus-article-sort-by-number)
569 (function-item gnus-article-sort-by-author)
570 (function-item gnus-article-sort-by-subject)
571 (function-item gnus-article-sort-by-date)
572 (function-item gnus-article-sort-by-score)
573 (function :tag "other"))))
575 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
576 "*List of functions used for sorting threads in the summary buffer.
577 By default, threads are sorted by article number.
579 Each function takes two threads and return non-nil if the first thread
580 should be sorted before the other. If you use more than one function,
581 the primary sort function should be the last. You should probably
582 always include `gnus-thread-sort-by-number' in the list of sorting
583 functions -- preferably first.
585 Ready-made functions include `gnus-thread-sort-by-number',
586 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
587 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
588 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
589 :group 'gnus-summary-sort
590 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
591 (function-item gnus-thread-sort-by-author)
592 (function-item gnus-thread-sort-by-subject)
593 (function-item gnus-thread-sort-by-date)
594 (function-item gnus-thread-sort-by-score)
595 (function-item gnus-thread-sort-by-total-score)
596 (function :tag "other"))))
598 (defcustom gnus-thread-score-function '+
599 "*Function used for calculating the total score of a thread.
601 The function is called with the scores of the article and each
602 subthread and should then return the score of the thread.
604 Some functions you can use are `+', `max', or `min'."
605 :group 'gnus-summary-sort
608 (defcustom gnus-summary-expunge-below nil
609 "All articles that have a score less than this variable will be expunged.
610 This variable is local to the summary buffers."
611 :group 'gnus-score-default
612 :type '(choice (const :tag "off" nil)
615 (defcustom gnus-thread-expunge-below nil
616 "All threads that have a total score less than this variable will be expunged.
617 See `gnus-thread-score-function' for en explanation of what a
620 This variable is local to the summary buffers."
621 :group 'gnus-threading
622 :group 'gnus-score-default
623 :type '(choice (const :tag "off" nil)
626 (defcustom gnus-summary-mode-hook nil
627 "*A hook for Gnus summary mode.
628 This hook is run before any variables are set in the summary buffer."
629 :group 'gnus-summary-various
632 (defcustom gnus-summary-menu-hook nil
633 "*Hook run after the creation of the summary mode menu."
634 :group 'gnus-summary-visual
637 (defcustom gnus-summary-exit-hook nil
638 "*A hook called on exit from the summary buffer.
639 It will be called with point in the group buffer."
640 :group 'gnus-summary-exit
643 (defcustom gnus-summary-prepare-hook nil
644 "*A hook called after the summary buffer has been generated.
645 If you want to modify the summary buffer, you can use this hook."
646 :group 'gnus-summary-various
649 (defcustom gnus-summary-prepared-hook nil
650 "*A hook called as the last thing after the summary buffer has been generated."
651 :group 'gnus-summary-various
654 (defcustom gnus-summary-generate-hook nil
655 "*A hook run just before generating the summary buffer.
656 This hook is commonly used to customize threading variables and the
658 :group 'gnus-summary-various
661 (defcustom gnus-select-group-hook nil
662 "*A hook called when a newsgroup is selected.
664 If you'd like to simplify subjects like the
665 `gnus-summary-next-same-subject' command does, you can use the
668 (setq gnus-select-group-hook
671 (mapcar (lambda (header)
672 (mail-header-set-subject
674 (gnus-simplify-subject
675 (mail-header-subject header) 're-only)))
676 gnus-newsgroup-headers))))"
677 :group 'gnus-group-select
680 (defcustom gnus-select-article-hook nil
681 "*A hook called when an article is selected."
682 :group 'gnus-summary-choose
685 (defcustom gnus-visual-mark-article-hook
686 (list 'gnus-highlight-selected-summary)
687 "*Hook run after selecting an article in the summary buffer.
688 It is meant to be used for highlighting the article in some way. It
689 is not run if `gnus-visual' is nil."
690 :group 'gnus-summary-visual
693 (defcustom gnus-parse-headers-hook nil
694 "*A hook called before parsing the headers."
698 (defcustom gnus-exit-group-hook nil
699 "*A hook called when exiting (not quitting) summary mode."
703 (defcustom gnus-summary-update-hook
704 (list 'gnus-summary-highlight-line)
705 "*A hook called when a summary line is changed.
706 The hook will not be called if `gnus-visual' is nil.
708 The default function `gnus-summary-highlight-line' will
709 highlight the line according to the `gnus-summary-highlight'
711 :group 'gnus-summary-visual
714 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
715 "*A hook called when an article is selected for the first time.
716 The hook is intended to mark an article as read (or unread)
717 automatically when it is selected."
718 :group 'gnus-summary-choose
721 (defcustom gnus-group-no-more-groups-hook nil
722 "*A hook run when returning to group mode having no more (unread) groups."
723 :group 'gnus-group-select
726 (defcustom gnus-ps-print-hook nil
727 "*A hook run before ps-printing something from Gnus."
731 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
732 "Face used for highlighting the current article in the summary buffer."
733 :group 'gnus-summary-visual
736 (defcustom gnus-summary-highlight
737 '(((= mark gnus-canceled-mark)
738 . gnus-summary-cancelled-face)
739 ((and (> score default)
740 (or (= mark gnus-dormant-mark)
741 (= mark gnus-ticked-mark)))
742 . gnus-summary-high-ticked-face)
743 ((and (< score default)
744 (or (= mark gnus-dormant-mark)
745 (= mark gnus-ticked-mark)))
746 . gnus-summary-low-ticked-face)
747 ((or (= mark gnus-dormant-mark)
748 (= mark gnus-ticked-mark))
749 . gnus-summary-normal-ticked-face)
750 ((and (> score default) (= mark gnus-ancient-mark))
751 . gnus-summary-high-ancient-face)
752 ((and (< score default) (= mark gnus-ancient-mark))
753 . gnus-summary-low-ancient-face)
754 ((= mark gnus-ancient-mark)
755 . gnus-summary-normal-ancient-face)
756 ((and (> score default) (= mark gnus-unread-mark))
757 . gnus-summary-high-unread-face)
758 ((and (< score default) (= mark gnus-unread-mark))
759 . gnus-summary-low-unread-face)
760 ((= mark gnus-unread-mark)
761 . gnus-summary-normal-unread-face)
762 ((and (> score default) (memq mark (list gnus-downloadable-mark
763 gnus-undownloaded-mark)))
764 . gnus-summary-high-unread-face)
765 ((and (< score default) (memq mark (list gnus-downloadable-mark
766 gnus-undownloaded-mark)))
767 . gnus-summary-low-unread-face)
768 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
769 . gnus-summary-normal-unread-face)
771 . gnus-summary-high-read-face)
773 . gnus-summary-low-read-face)
775 . gnus-summary-normal-read-face))
776 "*Controls the highlighting of summary buffer lines.
778 A list of (FORM . FACE) pairs. When deciding how a a particular
779 summary line should be displayed, each form is evaluated. The content
780 of the face field after the first true form is used. You can change
781 how those summary lines are displayed, by editing the face field.
783 You can use the following variables in the FORM field.
785 score: The articles score
786 default: The default article score.
787 below: The score below which articles are automatically marked as read.
788 mark: The articles mark."
789 :group 'gnus-summary-visual
790 :type '(repeat (cons (sexp :tag "Form" nil)
793 (defcustom gnus-alter-header-function nil
794 "Function called to allow alteration of article header structures.
795 The function is called with one parameter, the article header vector,
796 which it may alter in any way.")
798 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
799 "Variable that says which function should be used to decode a string with encoded words.")
801 (defcustom gnus-extra-headers nil
802 "*Extra headers to parse."
804 :type '(repeat symbol))
806 (defcustom gnus-ignored-from-addresses
807 (and user-mail-address (regexp-quote user-mail-address))
808 "*Regexp of From headers that may be suppressed in favor of To headers."
812 (defcustom gnus-group-charset-alist
813 '(("^hk\\>\\|^tw\\>\\|\\<big5\\>" cn-big5)
814 ("^cn\\>\\|\\<chinese\\>" cn-gb-2312)
815 ("^fj\\>\\|^japan\\>" iso-2022-jp-2)
816 ("^tnn\\>\\|^pin\\>\\|^sci.lang.japan" iso-2022-7bit)
817 ("^relcom\\>" koi8-r)
819 ("^\\(cz\\|hun\\|pl\\|sk\\|hr\\)\\>" iso-8859-2)
820 ("^israel\\>" iso-8859-1)
822 ("^alt.chinese.text.big5\\>" chinese-big5)
823 ("^soc.culture.vietnamese\\>" vietnamese-viqr)
824 ("^\\(comp\\|rec\\|alt\\|sci\\|soc\\|news\\|gnu\\|bofh\\)\\>" iso-8859-1)
826 "Alist of regexps (to match group names) and default charsets to be used when reading."
827 :type '(repeat (list (regexp :tag "Group")
828 (symbol :tag "Charset")))
829 :group 'gnus-charset)
831 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
832 "List of charsets that should be ignored.
833 When these charsets are used in the \"charset\" parameter, the
834 default charset will be used instead."
835 :type '(repeat symbol)
836 :group 'gnus-charset)
838 (defcustom gnus-group-ignored-charsets-alist
839 '(("alt\\.chinese\\.text" iso-8859-1))
840 "Alist of regexps (to match group names) and charsets that should be ignored.
841 When these charsets are used in the \"charset\" parameter, the
842 default charset will be used instead."
843 :type '(repeat (cons (regexp :tag "Group")
845 :group 'gnus-charset)
847 (defcustom gnus-group-highlight-words-alist nil
848 "Alist of group regexps and highlight regexps.
849 This variable uses the same syntax as `gnus-emphasis-alist'."
850 :type '(repeat (cons (regexp :tag "Group")
851 (repeat (list (regexp :tag "Highlight regexp")
852 (number :tag "Group for entire word" 0)
853 (number :tag "Group for displayed part" 0)
855 gnus-emphasis-highlight-words)))))
856 :group 'gnus-summary-visual)
858 (defcustom gnus-summary-show-article-charset-alist
860 "Alist of number and charset.
861 The article will be shown with the charset corresponding to the
863 For example: ((1 . cn-gb-2312) (2 . big5))."
864 :type '(repeat (cons (number :tag "Argument" 1)
865 (symbol :tag "Charset")))
866 :group 'gnus-charset)
868 (defcustom gnus-preserve-marks t
869 "Whether marks are preserved when moving, copying and respooling messages."
871 :group 'gnus-summary-marks)
873 ;;; Internal variables
875 (defvar gnus-article-mime-handles nil)
876 (defvar gnus-article-decoded-p nil)
877 (defvar gnus-scores-exclude-files nil)
878 (defvar gnus-page-broken nil)
879 (defvar gnus-inhibit-mime-unbuttonizing nil)
881 (defvar gnus-original-article nil)
882 (defvar gnus-article-internal-prepare-hook nil)
883 (defvar gnus-newsgroup-process-stack nil)
885 (defvar gnus-thread-indent-array nil)
886 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
887 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
888 "Function called to sort the articles within a thread after it has been gathered together.")
890 ;; Avoid highlighting in kill files.
891 (defvar gnus-summary-inhibit-highlight nil)
892 (defvar gnus-newsgroup-selected-overlay nil)
893 (defvar gnus-inhibit-limiting nil)
894 (defvar gnus-newsgroup-adaptive-score-file nil)
895 (defvar gnus-current-score-file nil)
896 (defvar gnus-current-move-group nil)
897 (defvar gnus-current-copy-group nil)
898 (defvar gnus-current-crosspost-group nil)
900 (defvar gnus-newsgroup-dependencies nil)
901 (defvar gnus-newsgroup-adaptive nil)
902 (defvar gnus-summary-display-article-function nil)
903 (defvar gnus-summary-highlight-line-function nil
904 "Function called after highlighting a summary line.")
906 (defvar gnus-summary-line-format-alist
907 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
908 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
909 (?s gnus-tmp-subject-or-nil ?s)
910 (?n gnus-tmp-name ?s)
911 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
913 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
915 (?F gnus-tmp-from ?s)
916 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
917 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
918 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
919 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
920 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
921 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
922 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
923 (?L gnus-tmp-lines ?d)
924 (?I gnus-tmp-indentation ?s)
925 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
926 (?R gnus-tmp-replied ?c)
927 (?\[ gnus-tmp-opening-bracket ?c)
928 (?\] gnus-tmp-closing-bracket ?c)
929 (?\> (make-string gnus-tmp-level ? ) ?s)
930 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
931 (?i gnus-tmp-score ?d)
932 (?z gnus-tmp-score-char ?c)
933 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
934 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
935 (?U gnus-tmp-unread ?c)
936 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header) ?s)
937 (?t (gnus-summary-number-of-articles-in-thread
938 (and (boundp 'thread) (car thread)) gnus-tmp-level)
940 (?e (gnus-summary-number-of-articles-in-thread
941 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
943 (?u gnus-tmp-user-defined ?s)
944 (?P (gnus-pick-line-number) ?d))
945 "An alist of format specifications that can appear in summary lines,
946 and what variables they correspond with, along with the type of the
947 variable (string, integer, character, etc).")
949 (defvar gnus-summary-dummy-line-format-alist
950 `((?S gnus-tmp-subject ?s)
951 (?N gnus-tmp-number ?d)
952 (?u gnus-tmp-user-defined ?s)))
954 (defvar gnus-summary-mode-line-format-alist
955 `((?G gnus-tmp-group-name ?s)
956 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
957 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
958 (?A gnus-tmp-article-number ?d)
959 (?Z gnus-tmp-unread-and-unselected ?s)
961 (?U gnus-tmp-unread-and-unticked ?d)
962 (?S gnus-tmp-subject ?s)
963 (?e gnus-tmp-unselected ?d)
964 (?u gnus-tmp-user-defined ?s)
965 (?d (length gnus-newsgroup-dormant) ?d)
966 (?t (length gnus-newsgroup-marked) ?d)
967 (?r (length gnus-newsgroup-reads) ?d)
968 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
969 (?E gnus-newsgroup-expunged-tally ?d)
970 (?s (gnus-current-score-file-nondirectory) ?s)))
972 (defvar gnus-last-search-regexp nil
973 "Default regexp for article search command.")
975 (defvar gnus-last-shell-command nil
976 "Default shell command on article.")
978 (defvar gnus-newsgroup-begin nil)
979 (defvar gnus-newsgroup-end nil)
980 (defvar gnus-newsgroup-last-rmail nil)
981 (defvar gnus-newsgroup-last-mail nil)
982 (defvar gnus-newsgroup-last-folder nil)
983 (defvar gnus-newsgroup-last-file nil)
984 (defvar gnus-newsgroup-auto-expire nil)
985 (defvar gnus-newsgroup-active nil)
987 (defvar gnus-newsgroup-data nil)
988 (defvar gnus-newsgroup-data-reverse nil)
989 (defvar gnus-newsgroup-limit nil)
990 (defvar gnus-newsgroup-limits nil)
992 (defvar gnus-newsgroup-unreads nil
993 "List of unread articles in the current newsgroup.")
995 (defvar gnus-newsgroup-unselected nil
996 "List of unselected unread articles in the current newsgroup.")
998 (defvar gnus-newsgroup-reads nil
999 "Alist of read articles and article marks in the current newsgroup.")
1001 (defvar gnus-newsgroup-expunged-tally nil)
1003 (defvar gnus-newsgroup-marked nil
1004 "List of ticked articles in the current newsgroup (a subset of unread art).")
1006 (defvar gnus-newsgroup-killed nil
1007 "List of ranges of articles that have been through the scoring process.")
1009 (defvar gnus-newsgroup-cached nil
1010 "List of articles that come from the article cache.")
1012 (defvar gnus-newsgroup-saved nil
1013 "List of articles that have been saved.")
1015 (defvar gnus-newsgroup-kill-headers nil)
1017 (defvar gnus-newsgroup-replied nil
1018 "List of articles that have been replied to in the current newsgroup.")
1020 (defvar gnus-newsgroup-expirable nil
1021 "List of articles in the current newsgroup that can be expired.")
1023 (defvar gnus-newsgroup-processable nil
1024 "List of articles in the current newsgroup that can be processed.")
1026 (defvar gnus-newsgroup-downloadable nil
1027 "List of articles in the current newsgroup that can be processed.")
1029 (defvar gnus-newsgroup-undownloaded nil
1030 "List of articles in the current newsgroup that haven't been downloaded..")
1032 (defvar gnus-newsgroup-unsendable nil
1033 "List of articles in the current newsgroup that won't be sent.")
1035 (defvar gnus-newsgroup-bookmarks nil
1036 "List of articles in the current newsgroup that have bookmarks.")
1038 (defvar gnus-newsgroup-dormant nil
1039 "List of dormant articles in the current newsgroup.")
1041 (defvar gnus-newsgroup-scored nil
1042 "List of scored articles in the current newsgroup.")
1044 (defvar gnus-newsgroup-headers nil
1045 "List of article headers in the current newsgroup.")
1047 (defvar gnus-newsgroup-threads nil)
1049 (defvar gnus-newsgroup-prepared nil
1050 "Whether the current group has been prepared properly.")
1052 (defvar gnus-newsgroup-ancient nil
1053 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1055 (defvar gnus-newsgroup-sparse nil)
1057 (defvar gnus-current-article nil)
1058 (defvar gnus-article-current nil)
1059 (defvar gnus-current-headers nil)
1060 (defvar gnus-have-all-headers nil)
1061 (defvar gnus-last-article nil)
1062 (defvar gnus-newsgroup-history nil)
1063 (defvar gnus-newsgroup-charset nil)
1064 (defvar gnus-newsgroup-ephemeral-charset nil)
1065 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1067 (defconst gnus-summary-local-variables
1068 '(gnus-newsgroup-name
1069 gnus-newsgroup-begin gnus-newsgroup-end
1070 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1071 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1072 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1073 gnus-newsgroup-unselected gnus-newsgroup-marked
1074 gnus-newsgroup-reads gnus-newsgroup-saved
1075 gnus-newsgroup-replied gnus-newsgroup-expirable
1076 gnus-newsgroup-processable gnus-newsgroup-killed
1077 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1078 gnus-newsgroup-unsendable
1079 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1080 gnus-newsgroup-headers gnus-newsgroup-threads
1081 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1082 gnus-current-article gnus-current-headers gnus-have-all-headers
1083 gnus-last-article gnus-article-internal-prepare-hook
1084 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1085 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1086 gnus-thread-expunge-below
1087 gnus-score-alist gnus-current-score-file
1088 (gnus-summary-expunge-below . global)
1089 (gnus-summary-mark-below . global)
1090 gnus-newsgroup-active gnus-scores-exclude-files
1091 gnus-newsgroup-history gnus-newsgroup-ancient
1092 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1093 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1094 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1095 (gnus-newsgroup-expunged-tally . 0)
1096 gnus-cache-removable-articles gnus-newsgroup-cached
1097 gnus-newsgroup-data gnus-newsgroup-data-reverse
1098 gnus-newsgroup-limit gnus-newsgroup-limits
1099 gnus-newsgroup-charset)
1100 "Variables that are buffer-local to the summary buffers.")
1102 ;; Byte-compiler warning.
1103 (defvar gnus-article-mode-map)
1107 (defvar gnus-decode-encoded-word-methods
1108 '(mail-decode-encoded-word-string)
1109 "List of methods used to decode encoded words.
1111 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item is
1112 FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1113 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1114 whose names match REGEXP.
1117 ((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1118 mail-decode-encoded-word-string
1119 (\"chinese\" . rfc1843-decode-string))
1122 (defvar gnus-decode-encoded-word-methods-cache nil)
1124 (defun gnus-multi-decode-encoded-word-string (string)
1125 "Apply the functions from `gnus-encoded-word-methods' that match."
1126 (unless (and gnus-decode-encoded-word-methods-cache
1127 (eq gnus-newsgroup-name
1128 (car gnus-decode-encoded-word-methods-cache)))
1129 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1132 (nconc gnus-decode-encoded-word-methods-cache (list x))
1133 (if (and gnus-newsgroup-name
1134 (string-match (car x) gnus-newsgroup-name))
1135 (nconc gnus-decode-encoded-word-methods-cache
1137 gnus-decode-encoded-word-methods))
1138 (let ((xlist gnus-decode-encoded-word-methods-cache))
1141 (setq string (funcall (pop xlist) string))))
1144 ;; Subject simplification.
1146 (defun gnus-simplify-whitespace (str)
1147 "Remove excessive whitespace."
1150 (while (string-match "[ \t][ \t]+" mystr)
1151 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1153 (substring mystr (match-end 0)))))
1155 (when (string-match "^[ \t]+" mystr)
1156 (setq mystr (substring mystr (match-end 0))))
1158 (when (string-match "[ \t]+$" mystr)
1159 (setq mystr (substring mystr 0 (match-beginning 0))))
1162 (defsubst gnus-simplify-subject-re (subject)
1163 "Remove \"Re:\" from subject lines."
1164 (if (string-match "^[Rr][Ee]: *" subject)
1165 (substring subject (match-end 0))
1168 (defun gnus-simplify-subject (subject &optional re-only)
1169 "Remove `Re:' and words in parentheses.
1170 If RE-ONLY is non-nil, strip leading `Re:'s only."
1171 (let ((case-fold-search t)) ;Ignore case.
1172 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1173 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1174 (setq subject (substring subject (match-end 0))))
1175 ;; Remove uninteresting prefixes.
1176 (when (and (not re-only)
1177 gnus-simplify-ignored-prefixes
1178 (string-match gnus-simplify-ignored-prefixes subject))
1179 (setq subject (substring subject (match-end 0))))
1180 ;; Remove words in parentheses from end.
1182 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1183 (setq subject (substring subject 0 (match-beginning 0)))))
1184 ;; Return subject string.
1187 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1189 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1190 (goto-char (point-min))
1191 (while (re-search-forward regexp nil t)
1192 (replace-match (or newtext ""))))
1194 (defun gnus-simplify-buffer-fuzzy ()
1195 "Simplify string in the buffer fuzzily.
1196 The string in the accessible portion of the current buffer is simplified.
1197 It is assumed to be a single-line subject.
1198 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1199 matter is removed. Additional things can be deleted by setting
1200 gnus-simplify-subject-fuzzy-regexp."
1201 (let ((case-fold-search t)
1203 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1205 (while (not (eq modified-tick (buffer-modified-tick)))
1206 (setq modified-tick (buffer-modified-tick))
1208 ((listp gnus-simplify-subject-fuzzy-regexp)
1209 (mapcar 'gnus-simplify-buffer-fuzzy-step
1210 gnus-simplify-subject-fuzzy-regexp))
1211 (gnus-simplify-subject-fuzzy-regexp
1212 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1213 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1214 (gnus-simplify-buffer-fuzzy-step
1215 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1216 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1218 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1219 (gnus-simplify-buffer-fuzzy-step " +" " ")
1220 (gnus-simplify-buffer-fuzzy-step " $")
1221 (gnus-simplify-buffer-fuzzy-step "^ +")))
1223 (defun gnus-simplify-subject-fuzzy (subject)
1224 "Simplify a subject string fuzzily.
1225 See `gnus-simplify-buffer-fuzzy' for details."
1227 (gnus-set-work-buffer)
1228 (let ((case-fold-search t))
1229 ;; Remove uninteresting prefixes.
1230 (when (and gnus-simplify-ignored-prefixes
1231 (string-match gnus-simplify-ignored-prefixes subject))
1232 (setq subject (substring subject (match-end 0))))
1234 (inline (gnus-simplify-buffer-fuzzy))
1237 (defsubst gnus-simplify-subject-fully (subject)
1238 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1240 (gnus-simplify-subject-functions
1241 (gnus-map-function gnus-simplify-subject-functions subject))
1242 ((null gnus-summary-gather-subject-limit)
1243 (gnus-simplify-subject-re subject))
1244 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1245 (gnus-simplify-subject-fuzzy subject))
1246 ((numberp gnus-summary-gather-subject-limit)
1247 (gnus-limit-string (gnus-simplify-subject-re subject)
1248 gnus-summary-gather-subject-limit))
1252 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1253 "Check whether two subjects are equal.
1254 If optional argument simple-first is t, first argument is already
1257 ((null simple-first)
1258 (equal (gnus-simplify-subject-fully s1)
1259 (gnus-simplify-subject-fully s2)))
1262 (gnus-simplify-subject-fully s2)))))
1264 (defun gnus-summary-bubble-group ()
1265 "Increase the score of the current group.
1266 This is a handy function to add to `gnus-summary-exit-hook' to
1267 increase the score of each group you read."
1268 (gnus-group-add-score gnus-newsgroup-name))
1272 ;;; Gnus summary mode
1275 (put 'gnus-summary-mode 'mode-class 'special)
1278 ;; Non-orthogonal keys
1280 (gnus-define-keys gnus-summary-mode-map
1281 " " gnus-summary-next-page
1282 "\177" gnus-summary-prev-page
1283 [delete] gnus-summary-prev-page
1284 [backspace] gnus-summary-prev-page
1285 "\r" gnus-summary-scroll-up
1286 "\M-\r" gnus-summary-scroll-down
1287 "n" gnus-summary-next-unread-article
1288 "p" gnus-summary-prev-unread-article
1289 "N" gnus-summary-next-article
1290 "P" gnus-summary-prev-article
1291 "\M-\C-n" gnus-summary-next-same-subject
1292 "\M-\C-p" gnus-summary-prev-same-subject
1293 "\M-n" gnus-summary-next-unread-subject
1294 "\M-p" gnus-summary-prev-unread-subject
1295 "." gnus-summary-first-unread-article
1296 "," gnus-summary-best-unread-article
1297 "\M-s" gnus-summary-search-article-forward
1298 "\M-r" gnus-summary-search-article-backward
1299 "<" gnus-summary-beginning-of-article
1300 ">" gnus-summary-end-of-article
1301 "j" gnus-summary-goto-article
1302 "^" gnus-summary-refer-parent-article
1303 "\M-^" gnus-summary-refer-article
1304 "u" gnus-summary-tick-article-forward
1305 "!" gnus-summary-tick-article-forward
1306 "U" gnus-summary-tick-article-backward
1307 "d" gnus-summary-mark-as-read-forward
1308 "D" gnus-summary-mark-as-read-backward
1309 "E" gnus-summary-mark-as-expirable
1310 "\M-u" gnus-summary-clear-mark-forward
1311 "\M-U" gnus-summary-clear-mark-backward
1312 "k" gnus-summary-kill-same-subject-and-select
1313 "\C-k" gnus-summary-kill-same-subject
1314 "\M-\C-k" gnus-summary-kill-thread
1315 "\M-\C-l" gnus-summary-lower-thread
1316 "e" gnus-summary-edit-article
1317 "#" gnus-summary-mark-as-processable
1318 "\M-#" gnus-summary-unmark-as-processable
1319 "\M-\C-t" gnus-summary-toggle-threads
1320 "\M-\C-s" gnus-summary-show-thread
1321 "\M-\C-h" gnus-summary-hide-thread
1322 "\M-\C-f" gnus-summary-next-thread
1323 "\M-\C-b" gnus-summary-prev-thread
1324 "\M-\C-u" gnus-summary-up-thread
1325 "\M-\C-d" gnus-summary-down-thread
1326 "&" gnus-summary-execute-command
1327 "c" gnus-summary-catchup-and-exit
1328 "\C-w" gnus-summary-mark-region-as-read
1329 "\C-t" gnus-summary-toggle-truncation
1330 "?" gnus-summary-mark-as-dormant
1331 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1332 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1333 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1334 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1335 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1336 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1337 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1338 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1339 "=" gnus-summary-expand-window
1340 "\C-x\C-s" gnus-summary-reselect-current-group
1341 "\M-g" gnus-summary-rescan-group
1342 "w" gnus-summary-stop-page-breaking
1343 "\C-c\C-r" gnus-summary-caesar-message
1344 "f" gnus-summary-followup
1345 "F" gnus-summary-followup-with-original
1346 "C" gnus-summary-cancel-article
1347 "r" gnus-summary-reply
1348 "R" gnus-summary-reply-with-original
1349 "\C-c\C-f" gnus-summary-mail-forward
1350 "o" gnus-summary-save-article
1351 "\C-o" gnus-summary-save-article-mail
1352 "|" gnus-summary-pipe-output
1353 "\M-k" gnus-summary-edit-local-kill
1354 "\M-K" gnus-summary-edit-global-kill
1356 "\C-c\C-d" gnus-summary-describe-group
1357 "q" gnus-summary-exit
1358 "Q" gnus-summary-exit-no-update
1359 "\C-c\C-i" gnus-info-find-node
1360 gnus-mouse-2 gnus-mouse-pick-article
1361 "m" gnus-summary-mail-other-window
1362 "a" gnus-summary-post-news
1363 "x" gnus-summary-limit-to-unread
1364 "s" gnus-summary-isearch-article
1365 "t" gnus-summary-toggle-header
1366 "g" gnus-summary-show-article
1367 "l" gnus-summary-goto-last-article
1368 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1369 "\C-d" gnus-summary-enter-digest-group
1370 "\M-\C-d" gnus-summary-read-document
1371 "\M-\C-e" gnus-summary-edit-parameters
1372 "\M-\C-a" gnus-summary-customize-parameters
1374 "*" gnus-cache-enter-article
1375 "\M-*" gnus-cache-remove-article
1376 "\M-&" gnus-summary-universal-argument
1377 "\C-l" gnus-recenter
1378 "I" gnus-summary-increase-score
1379 "L" gnus-summary-lower-score
1380 "\M-i" gnus-symbolic-argument
1381 "h" gnus-summary-select-article-buffer
1383 "b" gnus-article-view-part
1384 "\M-t" gnus-summary-toggle-display-buttonized
1386 "V" gnus-summary-score-map
1387 "X" gnus-uu-extract-map
1388 "S" gnus-summary-send-map)
1390 ;; Sort of orthogonal keymap
1391 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1392 "t" gnus-summary-tick-article-forward
1393 "!" gnus-summary-tick-article-forward
1394 "d" gnus-summary-mark-as-read-forward
1395 "r" gnus-summary-mark-as-read-forward
1396 "c" gnus-summary-clear-mark-forward
1397 " " gnus-summary-clear-mark-forward
1398 "e" gnus-summary-mark-as-expirable
1399 "x" gnus-summary-mark-as-expirable
1400 "?" gnus-summary-mark-as-dormant
1401 "b" gnus-summary-set-bookmark
1402 "B" gnus-summary-remove-bookmark
1403 "#" gnus-summary-mark-as-processable
1404 "\M-#" gnus-summary-unmark-as-processable
1405 "S" gnus-summary-limit-include-expunged
1406 "C" gnus-summary-catchup
1407 "H" gnus-summary-catchup-to-here
1408 "\C-c" gnus-summary-catchup-all
1409 "k" gnus-summary-kill-same-subject-and-select
1410 "K" gnus-summary-kill-same-subject
1411 "P" gnus-uu-mark-map)
1413 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1414 "c" gnus-summary-clear-above
1415 "u" gnus-summary-tick-above
1416 "m" gnus-summary-mark-above
1417 "k" gnus-summary-kill-below)
1419 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1420 "/" gnus-summary-limit-to-subject
1421 "n" gnus-summary-limit-to-articles
1422 "w" gnus-summary-pop-limit
1423 "s" gnus-summary-limit-to-subject
1424 "a" gnus-summary-limit-to-author
1425 "u" gnus-summary-limit-to-unread
1426 "m" gnus-summary-limit-to-marks
1427 "M" gnus-summary-limit-exclude-marks
1428 "v" gnus-summary-limit-to-score
1429 "*" gnus-summary-limit-include-cached
1430 "D" gnus-summary-limit-include-dormant
1431 "T" gnus-summary-limit-include-thread
1432 "d" gnus-summary-limit-exclude-dormant
1433 "t" gnus-summary-limit-to-age
1434 "x" gnus-summary-limit-to-extra
1435 "E" gnus-summary-limit-include-expunged
1436 "c" gnus-summary-limit-exclude-childless-dormant
1437 "C" gnus-summary-limit-mark-excluded-as-read)
1439 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1440 "n" gnus-summary-next-unread-article
1441 "p" gnus-summary-prev-unread-article
1442 "N" gnus-summary-next-article
1443 "P" gnus-summary-prev-article
1444 "\C-n" gnus-summary-next-same-subject
1445 "\C-p" gnus-summary-prev-same-subject
1446 "\M-n" gnus-summary-next-unread-subject
1447 "\M-p" gnus-summary-prev-unread-subject
1448 "f" gnus-summary-first-unread-article
1449 "b" gnus-summary-best-unread-article
1450 "j" gnus-summary-goto-article
1451 "g" gnus-summary-goto-subject
1452 "l" gnus-summary-goto-last-article
1453 "o" gnus-summary-pop-article)
1455 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1456 "k" gnus-summary-kill-thread
1457 "l" gnus-summary-lower-thread
1458 "i" gnus-summary-raise-thread
1459 "T" gnus-summary-toggle-threads
1460 "t" gnus-summary-rethread-current
1461 "^" gnus-summary-reparent-thread
1462 "s" gnus-summary-show-thread
1463 "S" gnus-summary-show-all-threads
1464 "h" gnus-summary-hide-thread
1465 "H" gnus-summary-hide-all-threads
1466 "n" gnus-summary-next-thread
1467 "p" gnus-summary-prev-thread
1468 "u" gnus-summary-up-thread
1469 "o" gnus-summary-top-thread
1470 "d" gnus-summary-down-thread
1471 "#" gnus-uu-mark-thread
1472 "\M-#" gnus-uu-unmark-thread)
1474 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1475 "g" gnus-summary-prepare
1476 "c" gnus-summary-insert-cached-articles)
1478 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1479 "c" gnus-summary-catchup-and-exit
1480 "C" gnus-summary-catchup-all-and-exit
1481 "E" gnus-summary-exit-no-update
1482 "Q" gnus-summary-exit
1483 "Z" gnus-summary-exit
1484 "n" gnus-summary-catchup-and-goto-next-group
1485 "R" gnus-summary-reselect-current-group
1486 "G" gnus-summary-rescan-group
1487 "N" gnus-summary-next-group
1488 "s" gnus-summary-save-newsrc
1489 "P" gnus-summary-prev-group)
1491 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1492 " " gnus-summary-next-page
1493 "n" gnus-summary-next-page
1494 "\177" gnus-summary-prev-page
1495 [delete] gnus-summary-prev-page
1496 "p" gnus-summary-prev-page
1497 "\r" gnus-summary-scroll-up
1498 "\M-\r" gnus-summary-scroll-down
1499 "<" gnus-summary-beginning-of-article
1500 ">" gnus-summary-end-of-article
1501 "b" gnus-summary-beginning-of-article
1502 "e" gnus-summary-end-of-article
1503 "^" gnus-summary-refer-parent-article
1504 "r" gnus-summary-refer-parent-article
1505 "D" gnus-summary-enter-digest-group
1506 "R" gnus-summary-refer-references
1507 "T" gnus-summary-refer-thread
1508 "g" gnus-summary-show-article
1509 "s" gnus-summary-isearch-article
1510 "P" gnus-summary-print-article
1511 "t" gnus-article-babel)
1513 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1514 "b" gnus-article-add-buttons
1515 "B" gnus-article-add-buttons-to-head
1516 "o" gnus-article-treat-overstrike
1517 "e" gnus-article-emphasize
1518 "w" gnus-article-fill-cited-article
1519 "Q" gnus-article-fill-long-lines
1520 "C" gnus-article-capitalize-sentences
1521 "c" gnus-article-remove-cr
1522 "q" gnus-article-de-quoted-unreadable
1523 "f" gnus-article-display-x-face
1524 "l" gnus-summary-stop-page-breaking
1525 "r" gnus-summary-caesar-message
1526 "t" gnus-article-hide-headers
1527 "v" gnus-summary-verbose-headers
1528 "H" gnus-article-strip-headers-in-body
1529 "d" gnus-article-treat-dumbquotes)
1531 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1532 "a" gnus-article-hide
1533 "h" gnus-article-hide-headers
1534 "b" gnus-article-hide-boring-headers
1535 "s" gnus-article-hide-signature
1536 "c" gnus-article-hide-citation
1537 "C" gnus-article-hide-citation-in-followups
1538 "l" gnus-article-hide-list-identifiers
1539 "p" gnus-article-hide-pgp
1540 "B" gnus-article-strip-banner
1541 "P" gnus-article-hide-pem
1542 "\C-c" gnus-article-hide-citation-maybe)
1544 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1545 "a" gnus-article-highlight
1546 "h" gnus-article-highlight-headers
1547 "c" gnus-article-highlight-citation
1548 "s" gnus-article-highlight-signature)
1550 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1551 "w" gnus-article-decode-mime-words
1552 "c" gnus-article-decode-charset
1553 "v" gnus-mime-view-all-parts
1554 "b" gnus-article-view-part)
1556 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1557 "z" gnus-article-date-ut
1558 "u" gnus-article-date-ut
1559 "l" gnus-article-date-local
1560 "e" gnus-article-date-lapsed
1561 "o" gnus-article-date-original
1562 "i" gnus-article-date-iso8601
1563 "s" gnus-article-date-user)
1565 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1566 "t" gnus-article-remove-trailing-blank-lines
1567 "l" gnus-article-strip-leading-blank-lines
1568 "m" gnus-article-strip-multiple-blank-lines
1569 "a" gnus-article-strip-blank-lines
1570 "A" gnus-article-strip-all-blank-lines
1571 "s" gnus-article-strip-leading-space
1572 "e" gnus-article-strip-trailing-space)
1574 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1576 "f" gnus-summary-fetch-faq
1577 "d" gnus-summary-describe-group
1578 "h" gnus-summary-describe-briefly
1579 "i" gnus-info-find-node)
1581 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1582 "e" gnus-summary-expire-articles
1583 "\M-\C-e" gnus-summary-expire-articles-now
1584 "\177" gnus-summary-delete-article
1585 [delete] gnus-summary-delete-article
1586 [backspace] gnus-summary-delete-article
1587 "m" gnus-summary-move-article
1588 "r" gnus-summary-respool-article
1589 "w" gnus-summary-edit-article
1590 "c" gnus-summary-copy-article
1591 "B" gnus-summary-crosspost-article
1592 "q" gnus-summary-respool-query
1593 "t" gnus-summary-respool-trace
1594 "i" gnus-summary-import-article
1595 "p" gnus-summary-article-posted-p)
1597 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1598 "o" gnus-summary-save-article
1599 "m" gnus-summary-save-article-mail
1600 "F" gnus-summary-write-article-file
1601 "r" gnus-summary-save-article-rmail
1602 "f" gnus-summary-save-article-file
1603 "b" gnus-summary-save-article-body-file
1604 "h" gnus-summary-save-article-folder
1605 "v" gnus-summary-save-article-vm
1606 "p" gnus-summary-pipe-output
1607 "s" gnus-soup-add-article)
1609 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1610 "b" gnus-summary-display-buttonized
1611 "m" gnus-summary-repair-multipart
1612 "v" gnus-article-view-part
1613 "o" gnus-article-save-part
1614 "c" gnus-article-copy-part
1615 "e" gnus-article-externalize-part
1616 "i" gnus-article-inline-part
1617 "|" gnus-article-pipe-part))
1619 (defun gnus-summary-make-menu-bar ()
1620 (gnus-turn-off-edit-menu 'summary)
1622 (unless (boundp 'gnus-summary-misc-menu)
1625 gnus-summary-kill-menu gnus-summary-mode-map ""
1630 ["Enter score..." gnus-summary-score-entry t]
1631 ["Customize" gnus-score-customize t])
1632 (gnus-make-score-map 'increase)
1633 (gnus-make-score-map 'lower)
1635 ["Kill below" gnus-summary-kill-below t]
1636 ["Mark above" gnus-summary-mark-above t]
1637 ["Tick above" gnus-summary-tick-above t]
1638 ["Clear above" gnus-summary-clear-above t])
1639 ["Current score" gnus-summary-current-score t]
1640 ["Set score" gnus-summary-set-score t]
1641 ["Switch current score file..." gnus-score-change-score-file t]
1642 ["Set mark below..." gnus-score-set-mark-below t]
1643 ["Set expunge below..." gnus-score-set-expunge-below t]
1644 ["Edit current score file" gnus-score-edit-current-scores t]
1645 ["Edit score file" gnus-score-edit-file t]
1646 ["Trace score" gnus-score-find-trace t]
1647 ["Find words" gnus-score-find-favourite-words t]
1648 ["Rescore buffer" gnus-summary-rescore t]
1649 ["Increase score..." gnus-summary-increase-score t]
1650 ["Lower score..." gnus-summary-lower-score t]))))
1652 ;; Define both the Article menu in the summary buffer and the equivalent
1653 ;; Commands menu in the article buffer here for consistency.
1656 ["All" gnus-article-hide t]
1657 ["Headers" gnus-article-hide-headers t]
1658 ["Signature" gnus-article-hide-signature t]
1659 ["Citation" gnus-article-hide-citation t]
1660 ["List identifiers" gnus-article-hide-list-identifiers t]
1661 ["PGP" gnus-article-hide-pgp t]
1662 ["Banner" gnus-article-strip-banner t]
1663 ["Boring headers" gnus-article-hide-boring-headers t])
1665 ["All" gnus-article-highlight t]
1666 ["Headers" gnus-article-highlight-headers t]
1667 ["Signature" gnus-article-highlight-signature t]
1668 ["Citation" gnus-article-highlight-citation t])
1670 ["Words" gnus-article-decode-mime-words t]
1671 ["Charset" gnus-article-decode-charset t]
1672 ["QP" gnus-article-de-quoted-unreadable t]
1673 ["View all" gnus-mime-view-all-parts t])
1675 ["Local" gnus-article-date-local t]
1676 ["ISO8601" gnus-article-date-iso8601 t]
1677 ["UT" gnus-article-date-ut t]
1678 ["Original" gnus-article-date-original t]
1679 ["Lapsed" gnus-article-date-lapsed t]
1680 ["User-defined" gnus-article-date-user t])
1683 ["Leading" gnus-article-strip-leading-blank-lines t]
1684 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1685 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1686 ["All of the above" gnus-article-strip-blank-lines t]
1687 ["All" gnus-article-strip-all-blank-lines t]
1688 ["Leading space" gnus-article-strip-leading-space t]
1689 ["Trailing space" gnus-article-strip-trailing-space t])
1690 ["Overstrike" gnus-article-treat-overstrike t]
1691 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1692 ["Emphasis" gnus-article-emphasize t]
1693 ["Word wrap" gnus-article-fill-cited-article t]
1694 ["Fill long lines" gnus-article-fill-long-lines t]
1695 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1696 ["CR" gnus-article-remove-cr t]
1697 ["Show X-Face" gnus-article-display-x-face t]
1698 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1699 ["Rot 13" gnus-summary-caesar-message t]
1700 ["Unix pipe" gnus-summary-pipe-message t]
1701 ["Add buttons" gnus-article-add-buttons t]
1702 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1703 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1704 ["Verbose header" gnus-summary-verbose-headers t]
1705 ["Toggle header" gnus-summary-toggle-header t]
1706 ["HZ" gnus-article-decode-HZ t])
1708 ["Save in default format" gnus-summary-save-article t]
1709 ["Save in file" gnus-summary-save-article-file t]
1710 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1711 ["Save in MH folder" gnus-summary-save-article-folder t]
1712 ["Save in VM folder" gnus-summary-save-article-vm t]
1713 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1714 ["Save body in file" gnus-summary-save-article-body-file t]
1715 ["Pipe through a filter" gnus-summary-pipe-output t]
1716 ["Add to SOUP packet" gnus-soup-add-article t]
1717 ["Print" gnus-summary-print-article t])
1719 ["Respool article..." gnus-summary-respool-article t]
1720 ["Move article..." gnus-summary-move-article
1721 (gnus-check-backend-function
1722 'request-move-article gnus-newsgroup-name)]
1723 ["Copy article..." gnus-summary-copy-article t]
1724 ["Crosspost article..." gnus-summary-crosspost-article
1725 (gnus-check-backend-function
1726 'request-replace-article gnus-newsgroup-name)]
1727 ["Import file..." gnus-summary-import-article t]
1728 ["Check if posted" gnus-summary-article-posted-p t]
1729 ["Edit article" gnus-summary-edit-article
1730 (not (gnus-group-read-only-p))]
1731 ["Delete article" gnus-summary-delete-article
1732 (gnus-check-backend-function
1733 'request-expire-articles gnus-newsgroup-name)]
1734 ["Query respool" gnus-summary-respool-query t]
1735 ["Trace respool" gnus-summary-respool-trace t]
1736 ["Delete expirable articles" gnus-summary-expire-articles-now
1737 (gnus-check-backend-function
1738 'request-expire-articles gnus-newsgroup-name)])
1740 ["Uudecode" gnus-uu-decode-uu t]
1741 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1742 ["Unshar" gnus-uu-decode-unshar t]
1743 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1744 ["Save" gnus-uu-decode-save t]
1745 ["Binhex" gnus-uu-decode-binhex t]
1746 ["Postscript" gnus-uu-decode-postscript t])
1748 ["Enter article" gnus-cache-enter-article t]
1749 ["Remove article" gnus-cache-remove-article t])
1750 ["Translate" gnus-article-babel t]
1751 ["Select article buffer" gnus-summary-select-article-buffer t]
1752 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1753 ["Isearch article..." gnus-summary-isearch-article t]
1754 ["Beginning of the article" gnus-summary-beginning-of-article t]
1755 ["End of the article" gnus-summary-end-of-article t]
1756 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1757 ["Fetch referenced articles" gnus-summary-refer-references t]
1758 ["Fetch current thread" gnus-summary-refer-thread t]
1759 ["Fetch article with id..." gnus-summary-refer-article t]
1760 ["Redisplay" gnus-summary-show-article t])))
1762 gnus-summary-article-menu gnus-summary-mode-map ""
1763 (cons "Article" innards))
1766 gnus-article-commands-menu gnus-article-mode-map ""
1767 (cons "Commands" innards)))
1770 gnus-summary-thread-menu gnus-summary-mode-map ""
1772 ["Toggle threading" gnus-summary-toggle-threads t]
1773 ["Hide threads" gnus-summary-hide-all-threads t]
1774 ["Show threads" gnus-summary-show-all-threads t]
1775 ["Hide thread" gnus-summary-hide-thread t]
1776 ["Show thread" gnus-summary-show-thread t]
1777 ["Go to next thread" gnus-summary-next-thread t]
1778 ["Go to previous thread" gnus-summary-prev-thread t]
1779 ["Go down thread" gnus-summary-down-thread t]
1780 ["Go up thread" gnus-summary-up-thread t]
1781 ["Top of thread" gnus-summary-top-thread t]
1782 ["Mark thread as read" gnus-summary-kill-thread t]
1783 ["Lower thread score" gnus-summary-lower-thread t]
1784 ["Raise thread score" gnus-summary-raise-thread t]
1785 ["Rethread current" gnus-summary-rethread-current t]))
1788 gnus-summary-post-menu gnus-summary-mode-map ""
1790 ["Post an article" gnus-summary-post-news t]
1791 ["Followup" gnus-summary-followup t]
1792 ["Followup and yank" gnus-summary-followup-with-original t]
1793 ["Supersede article" gnus-summary-supersede-article t]
1794 ["Cancel article" gnus-summary-cancel-article t]
1795 ["Reply" gnus-summary-reply t]
1796 ["Reply and yank" gnus-summary-reply-with-original t]
1797 ["Wide reply" gnus-summary-wide-reply t]
1798 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1799 ["Mail forward" gnus-summary-mail-forward t]
1800 ["Post forward" gnus-summary-post-forward t]
1801 ["Digest and mail" gnus-uu-digest-mail-forward t]
1802 ["Digest and post" gnus-uu-digest-post-forward t]
1803 ["Resend message" gnus-summary-resend-message t]
1804 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1805 ["Send a mail" gnus-summary-mail-other-window t]
1806 ["Uuencode and post" gnus-uu-post-news t]
1807 ["Followup via news" gnus-summary-followup-to-mail t]
1808 ["Followup via news and yank"
1809 gnus-summary-followup-to-mail-with-original t]
1811 ;;["Send" gnus-summary-send-draft t]
1812 ;;["Send bounced" gnus-resend-bounced-mail t])
1816 gnus-summary-misc-menu gnus-summary-mode-map ""
1819 ["Mark as read" gnus-summary-mark-as-read-forward t]
1820 ["Mark same subject and select"
1821 gnus-summary-kill-same-subject-and-select t]
1822 ["Mark same subject" gnus-summary-kill-same-subject t]
1823 ["Catchup" gnus-summary-catchup t]
1824 ["Catchup all" gnus-summary-catchup-all t]
1825 ["Catchup to here" gnus-summary-catchup-to-here t]
1826 ["Catchup region" gnus-summary-mark-region-as-read t]
1827 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1829 ["Tick" gnus-summary-tick-article-forward t]
1830 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1831 ["Remove marks" gnus-summary-clear-mark-forward t]
1832 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1833 ["Set bookmark" gnus-summary-set-bookmark t]
1834 ["Remove bookmark" gnus-summary-remove-bookmark t])
1836 ["Marks..." gnus-summary-limit-to-marks t]
1837 ["Subject..." gnus-summary-limit-to-subject t]
1838 ["Author..." gnus-summary-limit-to-author t]
1839 ["Age..." gnus-summary-limit-to-age t]
1840 ["Extra..." gnus-summary-limit-to-extra t]
1841 ["Score" gnus-summary-limit-to-score t]
1842 ["Unread" gnus-summary-limit-to-unread t]
1843 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1844 ["Articles" gnus-summary-limit-to-articles t]
1845 ["Pop limit" gnus-summary-pop-limit t]
1846 ["Show dormant" gnus-summary-limit-include-dormant t]
1847 ["Hide childless dormant"
1848 gnus-summary-limit-exclude-childless-dormant t]
1849 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1850 ["Hide marked" gnus-summary-limit-exclude-marks t]
1851 ["Show expunged" gnus-summary-show-all-expunged t])
1853 ["Set mark" gnus-summary-mark-as-processable t]
1854 ["Remove mark" gnus-summary-unmark-as-processable t]
1855 ["Remove all marks" gnus-summary-unmark-all-processable t]
1856 ["Mark above" gnus-uu-mark-over t]
1857 ["Mark series" gnus-uu-mark-series t]
1858 ["Mark region" gnus-uu-mark-region t]
1859 ["Unmark region" gnus-uu-unmark-region t]
1860 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1861 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1862 ["Mark all" gnus-uu-mark-all t]
1863 ["Mark buffer" gnus-uu-mark-buffer t]
1864 ["Mark sparse" gnus-uu-mark-sparse t]
1865 ["Mark thread" gnus-uu-mark-thread t]
1866 ["Unmark thread" gnus-uu-unmark-thread t]
1867 ("Process Mark Sets"
1868 ["Kill" gnus-summary-kill-process-mark t]
1869 ["Yank" gnus-summary-yank-process-mark
1870 gnus-newsgroup-process-stack]
1871 ["Save" gnus-summary-save-process-mark t]))
1873 ["Page forward" gnus-summary-next-page t]
1874 ["Page backward" gnus-summary-prev-page t]
1875 ["Line forward" gnus-summary-scroll-up t])
1877 ["Next unread article" gnus-summary-next-unread-article t]
1878 ["Previous unread article" gnus-summary-prev-unread-article t]
1879 ["Next article" gnus-summary-next-article t]
1880 ["Previous article" gnus-summary-prev-article t]
1881 ["Next unread subject" gnus-summary-next-unread-subject t]
1882 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1883 ["Next article same subject" gnus-summary-next-same-subject t]
1884 ["Previous article same subject" gnus-summary-prev-same-subject t]
1885 ["First unread article" gnus-summary-first-unread-article t]
1886 ["Best unread article" gnus-summary-best-unread-article t]
1887 ["Go to subject number..." gnus-summary-goto-subject t]
1888 ["Go to article number..." gnus-summary-goto-article t]
1889 ["Go to the last article" gnus-summary-goto-last-article t]
1890 ["Pop article off history" gnus-summary-pop-article t])
1892 ["Sort by number" gnus-summary-sort-by-number t]
1893 ["Sort by author" gnus-summary-sort-by-author t]
1894 ["Sort by subject" gnus-summary-sort-by-subject t]
1895 ["Sort by date" gnus-summary-sort-by-date t]
1896 ["Sort by score" gnus-summary-sort-by-score t]
1897 ["Sort by lines" gnus-summary-sort-by-lines t]
1898 ["Sort by characters" gnus-summary-sort-by-chars t])
1900 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1901 ["Describe group" gnus-summary-describe-group t]
1902 ["Read manual" gnus-info-find-node t])
1904 ["Pick and read" gnus-pick-mode t]
1905 ["Binary" gnus-binary-mode t])
1907 ["Regenerate" gnus-summary-prepare t]
1908 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1909 ["Toggle threading" gnus-summary-toggle-threads t])
1910 ["Filter articles..." gnus-summary-execute-command t]
1911 ["Run command on subjects..." gnus-summary-universal-argument t]
1912 ["Search articles forward..." gnus-summary-search-article-forward t]
1913 ["Search articles backward..." gnus-summary-search-article-backward t]
1914 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1915 ["Expand window" gnus-summary-expand-window t]
1916 ["Expire expirable articles" gnus-summary-expire-articles
1917 (gnus-check-backend-function
1918 'request-expire-articles gnus-newsgroup-name)]
1919 ["Edit local kill file" gnus-summary-edit-local-kill t]
1920 ["Edit main kill file" gnus-summary-edit-global-kill t]
1921 ["Edit group parameters" gnus-summary-edit-parameters t]
1922 ["Customize group parameters" gnus-summary-customize-parameters t]
1923 ["Send a bug report" gnus-bug t]
1925 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1926 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
1927 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1928 ["Exit group" gnus-summary-exit t]
1929 ["Exit group without updating" gnus-summary-exit-no-update t]
1930 ["Exit and goto next group" gnus-summary-next-group t]
1931 ["Exit and goto prev group" gnus-summary-prev-group t]
1932 ["Reselect group" gnus-summary-reselect-current-group t]
1933 ["Rescan group" gnus-summary-rescan-group t]
1934 ["Update dribble" gnus-summary-save-newsrc t])))
1936 (gnus-run-hooks 'gnus-summary-menu-hook)))
1938 (defun gnus-score-set-default (var value)
1939 "A version of set that updates the GNU Emacs menu-bar."
1941 ;; It is the message that forces the active status to be updated.
1944 (defun gnus-make-score-map (type)
1945 "Make a summary score map of type TYPE."
1948 (let ((headers '(("author" "from" string)
1949 ("subject" "subject" string)
1950 ("article body" "body" string)
1951 ("article head" "head" string)
1952 ("xref" "xref" string)
1953 ("extra header" "extra" string)
1954 ("lines" "lines" number)
1955 ("followups to author" "followup" string)))
1956 (types '((number ("less than" <)
1959 (string ("substring" s)
1963 (perms '(("temporary" (current-time-string))
1971 (if (eq type 'lower)
1976 (setq header (car headers))
1982 (let ((ts (cdr (assoc (nth 2 header) types)))
1998 'gnus-summary-score-entry
2000 (if (or (string= (nth 1 header)
2002 (string= (nth 1 header)
2005 (list 'gnus-summary-header
2007 (list 'quote (nth 1 (car ts)))
2008 (list 'gnus-score-delta-default
2015 (list (nreverse outp))))
2018 (list (nreverse outt))))
2020 (setq headers (cdr headers)))
2021 (list (nreverse outh))))))))
2025 (defun gnus-summary-mode (&optional group)
2026 "Major mode for reading articles.
2028 All normal editing commands are switched off.
2029 \\<gnus-summary-mode-map>
2030 Each line in this buffer represents one article. To read an
2031 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2032 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2035 You can also post articles and send mail from this buffer. To
2036 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2037 of an article, type `\\[gnus-summary-reply]'.
2039 There are approx. one gazillion commands you can execute in this
2040 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2042 The following commands are available:
2044 \\{gnus-summary-mode-map}"
2046 (when (gnus-visual-p 'summary-menu 'menu)
2047 (gnus-summary-make-menu-bar))
2048 (kill-all-local-variables)
2049 (gnus-summary-make-local-variables)
2050 (gnus-make-thread-indent-array)
2051 (gnus-simplify-mode-line)
2052 (setq major-mode 'gnus-summary-mode)
2053 (setq mode-name "Summary")
2054 (make-local-variable 'minor-mode-alist)
2055 (use-local-map gnus-summary-mode-map)
2056 (buffer-disable-undo)
2057 (setq buffer-read-only t) ;Disable modification
2058 (setq truncate-lines t)
2059 (setq selective-display t)
2060 (setq selective-display-ellipses t) ;Display `...'
2061 (gnus-summary-set-display-table)
2062 (gnus-set-default-directory)
2063 (setq gnus-newsgroup-name group)
2064 (make-local-variable 'gnus-summary-line-format)
2065 (make-local-variable 'gnus-summary-line-format-spec)
2066 (make-local-variable 'gnus-summary-dummy-line-format)
2067 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2068 (make-local-variable 'gnus-summary-mark-positions)
2069 (make-local-hook 'pre-command-hook)
2070 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2071 (gnus-run-hooks 'gnus-summary-mode-hook)
2072 (mm-enable-multibyte)
2073 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2074 (gnus-update-summary-mark-positions))
2076 (defun gnus-summary-make-local-variables ()
2077 "Make all the local summary buffer variables."
2079 (dolist (local gnus-summary-local-variables)
2082 (if (eq (cdr local) 'global)
2083 ;; Copy the global value of the variable.
2084 (setq global (symbol-value (car local)))
2085 ;; Use the value from the list.
2086 (setq global (eval (cdr local))))
2087 (set (make-local-variable (car local)) global))
2088 ;; Simple nil-valued local variable.
2089 (set (make-local-variable local) nil)))))
2091 (defun gnus-summary-clear-local-variables ()
2092 (let ((locals gnus-summary-local-variables))
2094 (if (consp (car locals))
2095 (and (vectorp (caar locals))
2096 (set (caar locals) nil))
2097 (and (vectorp (car locals))
2098 (set (car locals) nil)))
2099 (setq locals (cdr locals)))))
2101 ;; Summary data functions.
2103 (defmacro gnus-data-number (data)
2106 (defmacro gnus-data-set-number (data number)
2107 `(setcar ,data ,number))
2109 (defmacro gnus-data-mark (data)
2112 (defmacro gnus-data-set-mark (data mark)
2113 `(setcar (nthcdr 1 ,data) ,mark))
2115 (defmacro gnus-data-pos (data)
2118 (defmacro gnus-data-set-pos (data pos)
2119 `(setcar (nthcdr 2 ,data) ,pos))
2121 (defmacro gnus-data-header (data)
2124 (defmacro gnus-data-set-header (data header)
2125 `(setf (nth 3 ,data) ,header))
2127 (defmacro gnus-data-level (data)
2130 (defmacro gnus-data-unread-p (data)
2131 `(= (nth 1 ,data) gnus-unread-mark))
2133 (defmacro gnus-data-read-p (data)
2134 `(/= (nth 1 ,data) gnus-unread-mark))
2136 (defmacro gnus-data-pseudo-p (data)
2137 `(consp (nth 3 ,data)))
2139 (defmacro gnus-data-find (number)
2140 `(assq ,number gnus-newsgroup-data))
2142 (defmacro gnus-data-find-list (number &optional data)
2143 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2144 (memq (assq ,number bdata)
2147 (defmacro gnus-data-make (number mark pos header level)
2148 `(list ,number ,mark ,pos ,header ,level))
2150 (defun gnus-data-enter (after-article number mark pos header level offset)
2151 (let ((data (gnus-data-find-list after-article)))
2153 (error "No such article: %d" after-article))
2154 (setcdr data (cons (gnus-data-make number mark pos header level)
2156 (setq gnus-newsgroup-data-reverse nil)
2157 (gnus-data-update-list (cddr data) offset)))
2159 (defun gnus-data-enter-list (after-article list &optional offset)
2161 (let ((data (and after-article (gnus-data-find-list after-article)))
2165 (let ((odata gnus-newsgroup-data))
2166 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2168 (gnus-data-update-list odata offset)))
2169 ;; Find the last element in the list to be spliced into the main
2172 (setq list (cdr list)))
2175 (setcdr list gnus-newsgroup-data)
2176 (setq gnus-newsgroup-data ilist)
2178 (gnus-data-update-list (cdr list) offset)))
2179 (setcdr list (cdr data))
2182 (gnus-data-update-list (cdr list) offset))))
2183 (setq gnus-newsgroup-data-reverse nil))))
2185 (defun gnus-data-remove (article &optional offset)
2186 (let ((data gnus-newsgroup-data))
2187 (if (= (gnus-data-number (car data)) article)
2189 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2190 gnus-newsgroup-data-reverse nil)
2192 (gnus-data-update-list gnus-newsgroup-data offset)))
2194 (when (= (gnus-data-number (cadr data)) article)
2195 (setcdr data (cddr data))
2197 (gnus-data-update-list (cdr data) offset))
2199 gnus-newsgroup-data-reverse nil))
2200 (setq data (cdr data))))))
2202 (defmacro gnus-data-list (backward)
2204 (or gnus-newsgroup-data-reverse
2205 (setq gnus-newsgroup-data-reverse
2206 (reverse gnus-newsgroup-data)))
2207 gnus-newsgroup-data))
2209 (defun gnus-data-update-list (data offset)
2210 "Add OFFSET to the POS of all data entries in DATA."
2211 (setq gnus-newsgroup-data-reverse nil)
2213 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2214 (setq data (cdr data))))
2216 (defun gnus-summary-article-pseudo-p (article)
2217 "Say whether this article is a pseudo article or not."
2218 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2220 (defmacro gnus-summary-article-sparse-p (article)
2221 "Say whether this article is a sparse article or not."
2222 `(memq ,article gnus-newsgroup-sparse))
2224 (defmacro gnus-summary-article-ancient-p (article)
2225 "Say whether this article is a sparse article or not."
2226 `(memq ,article gnus-newsgroup-ancient))
2228 (defun gnus-article-parent-p (number)
2229 "Say whether this article is a parent or not."
2230 (let ((data (gnus-data-find-list number)))
2231 (and (cdr data) ; There has to be an article after...
2232 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2233 (gnus-data-level (nth 1 data))))))
2235 (defun gnus-article-children (number)
2236 "Return a list of all children to NUMBER."
2237 (let* ((data (gnus-data-find-list number))
2238 (level (gnus-data-level (car data)))
2240 (setq data (cdr data))
2242 (= (gnus-data-level (car data)) (1+ level)))
2243 (push (gnus-data-number (car data)) children)
2244 (setq data (cdr data)))
2247 (defmacro gnus-summary-skip-intangible ()
2248 "If the current article is intangible, then jump to a different article."
2249 '(let ((to (get-text-property (point) 'gnus-intangible)))
2250 (and to (gnus-summary-goto-subject to))))
2252 (defmacro gnus-summary-article-intangible-p ()
2253 "Say whether this article is intangible or not."
2254 '(get-text-property (point) 'gnus-intangible))
2256 (defun gnus-article-read-p (article)
2257 "Say whether ARTICLE is read or not."
2258 (not (or (memq article gnus-newsgroup-marked)
2259 (memq article gnus-newsgroup-unreads)
2260 (memq article gnus-newsgroup-unselected)
2261 (memq article gnus-newsgroup-dormant))))
2263 ;; Some summary mode macros.
2265 (defmacro gnus-summary-article-number ()
2266 "The article number of the article on the current line.
2267 If there isn's an article number here, then we return the current
2270 (gnus-summary-skip-intangible)
2271 (or (get-text-property (point) 'gnus-number)
2272 (gnus-summary-last-subject))))
2274 (defmacro gnus-summary-article-header (&optional number)
2275 "Return the header of article NUMBER."
2276 `(gnus-data-header (gnus-data-find
2277 ,(or number '(gnus-summary-article-number)))))
2279 (defmacro gnus-summary-thread-level (&optional number)
2280 "Return the level of thread that starts with article NUMBER."
2281 `(if (and (eq gnus-summary-make-false-root 'dummy)
2282 (get-text-property (point) 'gnus-intangible))
2284 (gnus-data-level (gnus-data-find
2285 ,(or number '(gnus-summary-article-number))))))
2287 (defmacro gnus-summary-article-mark (&optional number)
2288 "Return the mark of article NUMBER."
2289 `(gnus-data-mark (gnus-data-find
2290 ,(or number '(gnus-summary-article-number)))))
2292 (defmacro gnus-summary-article-pos (&optional number)
2293 "Return the position of the line of article NUMBER."
2294 `(gnus-data-pos (gnus-data-find
2295 ,(or number '(gnus-summary-article-number)))))
2297 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2298 (defmacro gnus-summary-article-subject (&optional number)
2299 "Return current subject string or nil if nothing."
2302 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2303 '(gnus-data-header (assq (gnus-summary-article-number)
2304 gnus-newsgroup-data)))))
2307 (mail-header-subject headers))))
2309 (defmacro gnus-summary-article-score (&optional number)
2310 "Return current article score."
2311 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2312 gnus-newsgroup-scored))
2313 gnus-summary-default-score 0))
2315 (defun gnus-summary-article-children (&optional number)
2316 "Return a list of article numbers that are children of article NUMBER."
2317 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2318 (level (gnus-data-level (car data)))
2320 (while (and (setq data (cdr data))
2321 (> (setq l (gnus-data-level (car data))) level))
2322 (and (= (1+ level) l)
2323 (push (gnus-data-number (car data))
2325 (nreverse children)))
2327 (defun gnus-summary-article-parent (&optional number)
2328 "Return the article number of the parent of article NUMBER."
2329 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2330 (gnus-data-list t)))
2331 (level (gnus-data-level (car data))))
2333 () ; This is a root.
2334 ;; We search until we find an article with a level less than
2335 ;; this one. That function has to be the parent.
2336 (while (and (setq data (cdr data))
2337 (not (< (gnus-data-level (car data)) level))))
2338 (and data (gnus-data-number (car data))))))
2340 (defun gnus-unread-mark-p (mark)
2341 "Say whether MARK is the unread mark."
2342 (= mark gnus-unread-mark))
2344 (defun gnus-read-mark-p (mark)
2345 "Say whether MARK is one of the marks that mark as read.
2346 This is all marks except unread, ticked, dormant, and expirable."
2347 (not (or (= mark gnus-unread-mark)
2348 (= mark gnus-ticked-mark)
2349 (= mark gnus-dormant-mark)
2350 (= mark gnus-expirable-mark))))
2352 (defmacro gnus-article-mark (number)
2353 "Return the MARK of article NUMBER.
2354 This macro should only be used when computing the mark the \"first\"
2355 time; i.e., when generating the summary lines. After that,
2356 `gnus-summary-article-mark' should be used to examine the
2359 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2360 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2361 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2362 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2363 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2364 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2365 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2366 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2367 gnus-ancient-mark))))
2369 ;; Saving hidden threads.
2371 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2372 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2374 (defmacro gnus-save-hidden-threads (&rest forms)
2375 "Save hidden threads, eval FORMS, and restore the hidden threads."
2376 (let ((config (make-symbol "config")))
2377 `(let ((,config (gnus-hidden-threads-configuration)))
2381 (gnus-restore-hidden-threads-configuration ,config)))))
2383 (defun gnus-data-compute-positions ()
2384 "Compute the positions of all articles."
2385 (setq gnus-newsgroup-data-reverse nil)
2386 (let ((data gnus-newsgroup-data))
2388 (gnus-save-hidden-threads
2389 (gnus-summary-show-all-threads)
2390 (goto-char (point-min))
2392 (while (get-text-property (point) 'gnus-intangible)
2394 (gnus-data-set-pos (car data) (+ (point) 3))
2395 (setq data (cdr data))
2396 (forward-line 1))))))
2398 (defun gnus-hidden-threads-configuration ()
2399 "Return the current hidden threads configuration."
2402 (goto-char (point-min))
2403 (while (search-forward "\r" nil t)
2404 (push (1- (point)) config))
2407 (defun gnus-restore-hidden-threads-configuration (config)
2408 "Restore hidden threads configuration from CONFIG."
2409 (let (point buffer-read-only)
2410 (while (setq point (pop config))
2411 (when (and (< point (point-max))
2413 (eq (char-after) ?\n))
2414 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2416 ;; Various summary mode internalish functions.
2418 (defun gnus-mouse-pick-article (e)
2421 (gnus-summary-next-page nil t))
2423 (defun gnus-summary-set-display-table ()
2424 ;; Change the display table. Odd characters have a tendency to mess
2425 ;; up nicely formatted displays - we make all possible glyphs
2426 ;; display only a single character.
2428 ;; We start from the standard display table, if any.
2429 (let ((table (or (copy-sequence standard-display-table)
2430 (make-display-table)))
2432 ;; Nix out all the control chars...
2433 (while (>= (setq i (1- i)) 0)
2434 (aset table i [??]))
2435 ;; ... but not newline and cr, of course. (cr is necessary for the
2436 ;; selective display).
2437 (aset table ?\n nil)
2438 (aset table ?\r nil)
2439 ;; We keep TAB as well.
2440 (aset table ?\t nil)
2441 ;; We nix out any glyphs over 126 that are not set already.
2443 (while (>= (setq i (1- i)) 127)
2444 ;; Only modify if the entry is nil.
2445 (unless (aref table i)
2446 (aset table i [??]))))
2447 (setq buffer-display-table table)))
2449 (defun gnus-summary-setup-buffer (group)
2450 "Initialize summary buffer."
2451 (let ((buffer (concat "*Summary " group "*")))
2452 (if (get-buffer buffer)
2455 (setq gnus-summary-buffer (current-buffer))
2456 (not gnus-newsgroup-prepared))
2457 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2458 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2459 (gnus-summary-mode group)
2461 (gnus-carpal-setup-buffer 'summary))
2462 (unless gnus-single-article-buffer
2463 (make-local-variable 'gnus-article-buffer)
2464 (make-local-variable 'gnus-article-current)
2465 (make-local-variable 'gnus-original-article-buffer))
2466 (setq gnus-newsgroup-name group)
2469 (defun gnus-set-global-variables ()
2470 ;; Set the global equivalents of the summary buffer-local variables
2471 ;; to the latest values they had. These reflect the summary buffer
2472 ;; that was in action when the last article was fetched.
2473 (when (eq major-mode 'gnus-summary-mode)
2474 (setq gnus-summary-buffer (current-buffer))
2475 (let ((name gnus-newsgroup-name)
2476 (marked gnus-newsgroup-marked)
2477 (unread gnus-newsgroup-unreads)
2478 (headers gnus-current-headers)
2479 (data gnus-newsgroup-data)
2480 (summary gnus-summary-buffer)
2481 (article-buffer gnus-article-buffer)
2482 (original gnus-original-article-buffer)
2483 (gac gnus-article-current)
2484 (reffed gnus-reffed-article-number)
2485 (score-file gnus-current-score-file)
2486 (default-charset gnus-newsgroup-charset))
2488 (set-buffer gnus-group-buffer)
2489 (setq gnus-newsgroup-name name
2490 gnus-newsgroup-marked marked
2491 gnus-newsgroup-unreads unread
2492 gnus-current-headers headers
2493 gnus-newsgroup-data data
2494 gnus-article-current gac
2495 gnus-summary-buffer summary
2496 gnus-article-buffer article-buffer
2497 gnus-original-article-buffer original
2498 gnus-reffed-article-number reffed
2499 gnus-current-score-file score-file
2500 gnus-newsgroup-charset default-charset)
2501 ;; The article buffer also has local variables.
2502 (when (gnus-buffer-live-p gnus-article-buffer)
2503 (set-buffer gnus-article-buffer)
2504 (setq gnus-summary-buffer summary))))))
2506 (defun gnus-summary-article-unread-p (article)
2507 "Say whether ARTICLE is unread or not."
2508 (memq article gnus-newsgroup-unreads))
2510 (defun gnus-summary-first-article-p (&optional article)
2511 "Return whether ARTICLE is the first article in the buffer."
2512 (if (not (setq article (or article (gnus-summary-article-number))))
2514 (eq article (caar gnus-newsgroup-data))))
2516 (defun gnus-summary-last-article-p (&optional article)
2517 "Return whether ARTICLE is the last article in the buffer."
2518 (if (not (setq article (or article (gnus-summary-article-number))))
2519 ;; All non-existent numbers are the last article. :-)
2521 (not (cdr (gnus-data-find-list article)))))
2523 (defun gnus-make-thread-indent-array ()
2525 (unless (and gnus-thread-indent-array
2526 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2527 (setq gnus-thread-indent-array (make-vector 201 "")
2528 gnus-thread-indent-array-level gnus-thread-indent-level)
2530 (aset gnus-thread-indent-array n
2531 (make-string (* n gnus-thread-indent-level) ? ))
2534 (defun gnus-update-summary-mark-positions ()
2535 "Compute where the summary marks are to go."
2537 (when (gnus-buffer-exists-p gnus-summary-buffer)
2538 (set-buffer gnus-summary-buffer))
2539 (let ((gnus-replied-mark 129)
2540 (gnus-score-below-mark 130)
2541 (gnus-score-over-mark 130)
2542 (gnus-download-mark 131)
2543 (spec gnus-summary-line-format-spec)
2546 (gnus-set-work-buffer)
2547 (let ((gnus-summary-line-format-spec spec)
2548 (gnus-newsgroup-downloadable '((0 . t))))
2549 (gnus-summary-insert-line
2550 [0 "" "" "" "" "" 0 0 "" nil] 0 nil 128 t nil "" nil 1)
2551 (goto-char (point-min))
2552 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2554 (goto-char (point-min))
2555 (push (cons 'replied (and (search-forward "\201" nil t)
2558 (goto-char (point-min))
2559 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2561 (goto-char (point-min))
2562 (push (cons 'download
2563 (and (search-forward "\203" nil t) (- (point) 2)))
2565 (setq gnus-summary-mark-positions pos))))
2567 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2568 "Insert a dummy root in the summary buffer."
2570 (gnus-add-text-properties
2571 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2572 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2574 (defun gnus-summary-from-or-to-or-newsgroups (header)
2575 (let ((to (cdr (assq 'To (mail-header-extra header))))
2576 (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header))))
2577 (mail-parse-charset gnus-newsgroup-charset)
2578 (mail-parse-ignored-charsets
2579 (save-excursion (set-buffer gnus-summary-buffer)
2580 gnus-newsgroup-ignored-charsets)))
2583 gnus-ignored-from-addresses
2584 (string-match gnus-ignored-from-addresses
2585 (mail-header-from header)))
2587 (or (car (funcall gnus-extract-address-components
2589 gnus-decode-encoded-word-function to)))
2590 (funcall gnus-decode-encoded-word-function to))))
2592 gnus-ignored-from-addresses
2593 (string-match gnus-ignored-from-addresses
2594 (mail-header-from header)))
2595 (concat "=> " newsgroups))
2597 (or (car (funcall gnus-extract-address-components
2598 (mail-header-from header)))
2599 (mail-header-from header))))))
2601 (defun gnus-summary-insert-line (gnus-tmp-header
2602 gnus-tmp-level gnus-tmp-current
2603 gnus-tmp-unread gnus-tmp-replied
2604 gnus-tmp-expirable gnus-tmp-subject-or-nil
2605 &optional gnus-tmp-dummy gnus-tmp-score
2607 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2608 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2609 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2610 (gnus-tmp-score-char
2611 (if (or (null gnus-summary-default-score)
2612 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2613 gnus-summary-zcore-fuzz))
2615 (if (< gnus-tmp-score gnus-summary-default-score)
2616 gnus-score-below-mark gnus-score-over-mark)))
2618 (cond (gnus-tmp-process gnus-process-mark)
2619 ((memq gnus-tmp-current gnus-newsgroup-cached)
2621 (gnus-tmp-replied gnus-replied-mark)
2622 ((memq gnus-tmp-current gnus-newsgroup-saved)
2624 (t gnus-unread-mark)))
2625 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2628 ((string-match "<[^>]+> *$" gnus-tmp-from)
2629 (let ((beg (match-beginning 0)))
2630 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2631 (substring gnus-tmp-from (1+ (match-beginning 0))
2632 (1- (match-end 0))))
2633 (substring gnus-tmp-from 0 beg))))
2634 ((string-match "(.+)" gnus-tmp-from)
2635 (substring gnus-tmp-from
2636 (1+ (match-beginning 0)) (1- (match-end 0))))
2638 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2639 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2640 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2641 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2642 (buffer-read-only nil))
2643 (when (string= gnus-tmp-name "")
2644 (setq gnus-tmp-name gnus-tmp-from))
2645 (unless (numberp gnus-tmp-lines)
2646 (setq gnus-tmp-lines 0))
2647 (gnus-put-text-property
2649 (progn (eval gnus-summary-line-format-spec) (point))
2650 'gnus-number gnus-tmp-number)
2651 (when (gnus-visual-p 'summary-highlight 'highlight)
2653 (gnus-run-hooks 'gnus-summary-update-hook)
2656 (defun gnus-summary-update-line (&optional dont-update)
2657 ;; Update summary line after change.
2658 (when (and gnus-summary-default-score
2659 (not gnus-summary-inhibit-highlight))
2660 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2661 (article (gnus-summary-article-number))
2662 (score (gnus-summary-article-score article)))
2664 (if (and gnus-summary-mark-below
2665 (< (gnus-summary-article-score)
2666 gnus-summary-mark-below))
2667 ;; This article has a low score, so we mark it as read.
2668 (when (memq article gnus-newsgroup-unreads)
2669 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2670 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2671 ;; This article was previously marked as read on account
2672 ;; of a low score, but now it has risen, so we mark it as
2674 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2675 (gnus-summary-update-mark
2676 (if (or (null gnus-summary-default-score)
2677 (<= (abs (- score gnus-summary-default-score))
2678 gnus-summary-zcore-fuzz))
2680 (if (< score gnus-summary-default-score)
2681 gnus-score-below-mark gnus-score-over-mark))
2683 ;; Do visual highlighting.
2684 (when (gnus-visual-p 'summary-highlight 'highlight)
2685 (gnus-run-hooks 'gnus-summary-update-hook)))))
2687 (defvar gnus-tmp-new-adopts nil)
2689 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2690 "Return the number of articles in THREAD.
2691 This may be 0 in some cases -- if none of the articles in
2692 the thread are to be displayed."
2694 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2696 ((not (listp thread))
2698 ((and (consp thread) (cdr thread))
2701 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2704 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2707 (when (and level (zerop level) gnus-tmp-new-adopts)
2710 'gnus-summary-number-of-articles-in-thread
2711 gnus-tmp-new-adopts))))
2713 (if (> number 1) gnus-not-empty-thread-mark
2714 gnus-empty-thread-mark)
2717 (defun gnus-summary-set-local-parameters (group)
2718 "Go through the local params of GROUP and set all variable specs in that list."
2719 (let ((params (gnus-group-find-parameter group))
2722 (setq elem (car params)
2723 params (cdr params))
2724 (and (consp elem) ; Has to be a cons.
2725 (consp (cdr elem)) ; The cdr has to be a list.
2726 (symbolp (car elem)) ; Has to be a symbol in there.
2727 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2728 (ignore-errors ; So we set it.
2729 (make-local-variable (car elem))
2730 (set (car elem) (eval (nth 1 elem))))))))
2732 (defun gnus-summary-read-group (group &optional show-all no-article
2733 kill-buffer no-display backward
2735 "Start reading news in newsgroup GROUP.
2736 If SHOW-ALL is non-nil, already read articles are also listed.
2737 If NO-ARTICLE is non-nil, no article is selected initially.
2738 If NO-DISPLAY, don't generate a summary buffer."
2742 (let ((gnus-auto-select-next nil))
2743 (or (gnus-summary-read-group-1
2744 group show-all no-article
2745 kill-buffer no-display
2748 select-articles nil)))))
2749 (eq gnus-auto-select-next 'quietly))
2750 (set-buffer gnus-group-buffer)
2751 ;; The entry function called above goes to the next
2752 ;; group automatically, so we go two groups back
2753 ;; if we are searching for the previous group.
2755 (gnus-group-prev-unread-group 2))
2756 (if (not (equal group (gnus-group-group-name)))
2757 (setq group (gnus-group-group-name))
2761 (defun gnus-summary-read-group-1 (group show-all no-article
2762 kill-buffer no-display
2763 &optional select-articles)
2764 ;; Killed foreign groups can't be entered.
2765 (when (and (not (gnus-group-native-p group))
2766 (not (gnus-gethash group gnus-newsrc-hashtb)))
2767 (error "Dead non-native groups can't be entered"))
2768 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2769 (let* ((new-group (gnus-summary-setup-buffer group))
2770 (quit-config (gnus-group-quit-config group))
2771 (did-select (and new-group (gnus-select-newsgroup
2772 group show-all select-articles))))
2774 ;; This summary buffer exists already, so we just select it.
2776 (gnus-set-global-variables)
2778 (gnus-kill-or-deaden-summary kill-buffer))
2779 (gnus-configure-windows 'summary 'force)
2780 (gnus-set-mode-line 'summary)
2781 (gnus-summary-position-point)
2784 ;; We couldn't select this group.
2786 (when (and (eq major-mode 'gnus-summary-mode)
2787 (not (equal (current-buffer) kill-buffer)))
2788 (kill-buffer (current-buffer))
2789 (if (not quit-config)
2791 ;; Update the info -- marks might need to be removed,
2793 (gnus-summary-update-info)
2794 (set-buffer gnus-group-buffer)
2795 (gnus-group-jump-to-group group)
2796 (gnus-group-next-unread-group 1))
2797 (gnus-handle-ephemeral-exit quit-config)))
2798 (gnus-message 3 "Can't select group")
2800 ;; The user did a `C-g' while prompting for number of articles,
2801 ;; so we exit this group.
2802 ((eq did-select 'quit)
2803 (and (eq major-mode 'gnus-summary-mode)
2804 (not (equal (current-buffer) kill-buffer))
2805 (kill-buffer (current-buffer)))
2807 (gnus-kill-or-deaden-summary kill-buffer))
2808 (if (not quit-config)
2810 (set-buffer gnus-group-buffer)
2811 (gnus-group-jump-to-group group)
2812 (gnus-group-next-unread-group 1)
2813 (gnus-configure-windows 'group 'force))
2814 (gnus-handle-ephemeral-exit quit-config))
2815 ;; Finally signal the quit.
2817 ;; The group was successfully selected.
2819 (gnus-set-global-variables)
2820 ;; Save the active value in effect when the group was entered.
2821 (setq gnus-newsgroup-active
2823 (gnus-active gnus-newsgroup-name)))
2824 ;; You can change the summary buffer in some way with this hook.
2825 (gnus-run-hooks 'gnus-select-group-hook)
2826 ;; Set any local variables in the group parameters.
2827 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2828 (gnus-update-format-specifications
2829 nil 'summary 'summary-mode 'summary-dummy)
2830 (gnus-update-summary-mark-positions)
2831 ;; Do score processing.
2832 (when gnus-use-scoring
2833 (gnus-possibly-score-headers))
2834 ;; Check whether to fill in the gaps in the threads.
2835 (when gnus-build-sparse-threads
2836 (gnus-build-sparse-threads))
2837 ;; Find the initial limit.
2838 (if gnus-show-threads
2840 (let ((gnus-newsgroup-dormant nil))
2841 (gnus-summary-initial-limit show-all))
2842 (gnus-summary-initial-limit show-all))
2843 ;; When untreaded, all articles are always shown.
2844 (setq gnus-newsgroup-limit
2846 (lambda (header) (mail-header-number header))
2847 gnus-newsgroup-headers)))
2848 ;; Generate the summary buffer.
2850 (gnus-summary-prepare))
2851 (when gnus-use-trees
2852 (gnus-tree-open group)
2853 (setq gnus-summary-highlight-line-function
2854 'gnus-tree-highlight-article))
2855 ;; If the summary buffer is empty, but there are some low-scored
2856 ;; articles or some excluded dormants, we include these in the
2858 (when (and (zerop (buffer-size))
2860 (cond (gnus-newsgroup-dormant
2861 (gnus-summary-limit-include-dormant))
2862 ((and gnus-newsgroup-scored show-all)
2863 (gnus-summary-limit-include-expunged t))))
2864 ;; Function `gnus-apply-kill-file' must be called in this hook.
2865 (gnus-run-hooks 'gnus-apply-kill-hook)
2866 (if (and (zerop (buffer-size))
2869 ;; This newsgroup is empty.
2870 (gnus-summary-catchup-and-exit nil t)
2871 (gnus-message 6 "No unread news")
2873 (gnus-kill-or-deaden-summary kill-buffer))
2874 ;; Return nil from this function.
2876 ;; Hide conversation thread subtrees. We cannot do this in
2877 ;; gnus-summary-prepare-hook since kill processing may not
2878 ;; work with hidden articles.
2879 (and gnus-show-threads
2880 gnus-thread-hide-subtree
2881 (gnus-summary-hide-all-threads))
2883 (gnus-kill-or-deaden-summary kill-buffer))
2884 ;; Show first unread article if requested.
2885 (if (and (not no-article)
2887 gnus-newsgroup-unreads
2888 gnus-auto-select-first)
2890 (gnus-configure-windows 'summary)
2892 ((eq gnus-auto-select-first 'best)
2893 (gnus-summary-best-unread-article))
2894 ((eq gnus-auto-select-first t)
2895 (gnus-summary-first-unread-article))
2896 ((gnus-functionp gnus-auto-select-first)
2897 (funcall gnus-auto-select-first))))
2898 ;; Don't select any articles, just move point to the first
2899 ;; article in the group.
2900 (goto-char (point-min))
2901 (gnus-summary-position-point)
2902 (gnus-configure-windows 'summary 'force)
2903 (gnus-set-mode-line 'summary))
2904 (when (get-buffer-window gnus-group-buffer t)
2905 ;; Gotta use windows, because recenter does weird stuff if
2906 ;; the current buffer ain't the displayed window.
2907 (let ((owin (selected-window)))
2908 (select-window (get-buffer-window gnus-group-buffer t))
2909 (when (gnus-group-goto-group group)
2911 (select-window owin)))
2912 ;; Mark this buffer as "prepared".
2913 (setq gnus-newsgroup-prepared t)
2914 (gnus-run-hooks 'gnus-summary-prepared-hook)
2917 (defun gnus-summary-prepare ()
2918 "Generate the summary buffer."
2920 (let ((buffer-read-only nil))
2922 (setq gnus-newsgroup-data nil
2923 gnus-newsgroup-data-reverse nil)
2924 (gnus-run-hooks 'gnus-summary-generate-hook)
2925 ;; Generate the buffer, either with threads or without.
2926 (when gnus-newsgroup-headers
2927 (gnus-summary-prepare-threads
2928 (if gnus-show-threads
2929 (gnus-sort-gathered-threads
2930 (funcall gnus-summary-thread-gathering-function
2932 (gnus-cut-threads (gnus-make-threads)))))
2933 ;; Unthreaded display.
2934 (gnus-sort-articles gnus-newsgroup-headers))))
2935 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2936 ;; Call hooks for modifying summary buffer.
2937 (goto-char (point-min))
2938 (gnus-run-hooks 'gnus-summary-prepare-hook)))
2940 (defsubst gnus-general-simplify-subject (subject)
2941 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2944 ;; Truncate the subject.
2945 (gnus-simplify-subject-functions
2946 (gnus-map-function gnus-simplify-subject-functions subject))
2947 ((numberp gnus-summary-gather-subject-limit)
2948 (setq subject (gnus-simplify-subject-re subject))
2949 (if (> (length subject) gnus-summary-gather-subject-limit)
2950 (substring subject 0 gnus-summary-gather-subject-limit)
2952 ;; Fuzzily simplify it.
2953 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2954 (gnus-simplify-subject-fuzzy subject))
2955 ;; Just remove the leading "Re:".
2957 (gnus-simplify-subject-re subject))))
2959 (if (and gnus-summary-gather-exclude-subject
2960 (string-match gnus-summary-gather-exclude-subject subject))
2961 nil ; This article shouldn't be gathered
2964 (defun gnus-summary-simplify-subject-query ()
2965 "Query where the respool algorithm would put this article."
2967 (gnus-summary-select-article)
2968 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2970 (defun gnus-gather-threads-by-subject (threads)
2971 "Gather threads by looking at Subject headers."
2972 (if (not gnus-summary-make-false-root)
2974 (let ((hashtb (gnus-make-hashtable 1024))
2977 subject hthread whole-subject)
2979 (setq subject (gnus-general-simplify-subject
2980 (setq whole-subject (mail-header-subject
2983 (if (setq hthread (gnus-gethash subject hashtb))
2985 ;; We enter a dummy root into the thread, if we
2986 ;; haven't done that already.
2987 (unless (stringp (caar hthread))
2988 (setcar hthread (list whole-subject (car hthread))))
2989 ;; We add this new gathered thread to this gathered
2991 (setcdr (car hthread)
2992 (nconc (cdar hthread) (list (car threads))))
2993 ;; Remove it from the list of threads.
2994 (setcdr prev (cdr threads))
2995 (setq threads prev))
2996 ;; Enter this thread into the hash table.
2997 (gnus-sethash subject threads hashtb)))
2999 (setq threads (cdr threads)))
3002 (defun gnus-gather-threads-by-references (threads)
3003 "Gather threads by looking at References headers."
3004 (let ((idhashtb (gnus-make-hashtable 1024))
3005 (thhashtb (gnus-make-hashtable 1024))
3008 ids references id gthread gid entered ref)
3010 (when (setq references (mail-header-references (caar threads)))
3011 (setq id (mail-header-id (caar threads))
3012 ids (gnus-split-references references)
3014 (while (setq ref (pop ids))
3015 (setq ids (delete ref ids))
3016 (if (not (setq gid (gnus-gethash ref idhashtb)))
3018 (gnus-sethash ref id idhashtb)
3019 (gnus-sethash id threads thhashtb))
3020 (setq gthread (gnus-gethash gid thhashtb))
3022 ;; We enter a dummy root into the thread, if we
3023 ;; haven't done that already.
3024 (unless (stringp (caar gthread))
3025 (setcar gthread (list (mail-header-subject (caar gthread))
3027 ;; We add this new gathered thread to this gathered
3029 (setcdr (car gthread)
3030 (nconc (cdar gthread) (list (car threads)))))
3031 ;; Add it into the thread hash table.
3032 (gnus-sethash id gthread thhashtb)
3034 ;; Remove it from the list of threads.
3035 (setcdr prev (cdr threads))
3036 (setq threads prev))))
3038 (setq threads (cdr threads)))
3041 (defun gnus-sort-gathered-threads (threads)
3042 "Sort subtreads inside each gathered thread by article number."
3043 (let ((result threads))
3045 (when (stringp (caar threads))
3046 (setcdr (car threads)
3047 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3048 (setq threads (cdr threads)))
3051 (defun gnus-thread-loop-p (root thread)
3052 "Say whether ROOT is in THREAD."
3053 (let ((stack (list thread))
3056 (while (setq thread (pop stack))
3057 (setq th (cdr thread))
3059 (not (eq (caar th) root)))
3062 ;; We have found a loop.
3064 (setcdr thread (delq (car th) (cdr thread)))
3065 (if (boundp (setq ref-dep (intern "none"
3066 gnus-newsgroup-dependencies)))
3067 (setcdr (symbol-value ref-dep)
3068 (nconc (cdr (symbol-value ref-dep))
3070 (set ref-dep (list nil (car th))))
3073 ;; Push all the subthreads onto the stack.
3074 (push (cdr thread) stack)))
3077 (defun gnus-make-threads ()
3078 "Go through the dependency hashtb and find the roots. Return all threads."
3080 (while (catch 'infloop
3083 ;; Deal with self-referencing References loops.
3084 (when (and (car (symbol-value refs))
3091 (car (symbol-value refs)) thread))
3092 (cdr (symbol-value refs)))))))
3095 (unless (car (symbol-value refs))
3096 ;; These threads do not refer back to any other articles,
3097 ;; so they're roots.
3098 (setq threads (append (cdr (symbol-value refs)) threads))))
3099 gnus-newsgroup-dependencies)))
3102 ;; Build the thread tree.
3103 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3104 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3106 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3107 if it was already present.
3109 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3110 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3111 Message-IDs will be renamed be renamed to a unique Message-ID before
3114 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3115 (let* ((id (mail-header-id header))
3116 (id-dep (and id (intern id dependencies)))
3117 ref ref-dep ref-header)
3118 ;; Enter this `header' in the `dependencies' table.
3122 ;; The first two cases do the normal part: enter a new `header'
3123 ;; in the `dependencies' table.
3124 ((not (boundp id-dep))
3125 (set id-dep (list header)))
3126 ((null (car (symbol-value id-dep)))
3127 (setcar (symbol-value id-dep) header))
3129 ;; From here the `header' was already present in the
3130 ;; `dependencies' table.
3132 ;; Overrides an existing entry;
3133 ;; just set the header part of the entry.
3134 (setcar (symbol-value id-dep) header))
3136 ;; Renames the existing `header' to a unique Message-ID.
3137 ((not gnus-summary-ignore-duplicates)
3138 ;; An article with this Message-ID has already been seen.
3139 ;; We rename the Message-ID.
3140 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3142 (mail-header-set-id header id))
3144 ;; The last case ignores an existing entry, except it adds any
3145 ;; additional Xrefs (in case the two articles came from different
3147 ;; Also sets `header' to `nil' meaning that the `dependencies'
3148 ;; table was *not* modified.
3150 (mail-header-set-xref
3151 (car (symbol-value id-dep))
3152 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3154 (or (mail-header-xref header) "")))
3158 ;; First check if that we are not creating a References loop.
3159 (setq ref (gnus-parent-id (mail-header-references header)))
3161 (setq ref-dep (intern-soft ref dependencies))
3163 (setq ref-header (car (symbol-value ref-dep))))
3164 (if (string= id ref)
3165 ;; Yuk! This is a reference loop. Make the article be a
3168 (mail-header-set-references (car (symbol-value id-dep)) "none")
3170 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3171 (setq ref (gnus-parent-id (mail-header-references header)))
3172 (setq ref-dep (intern (or ref "none") dependencies))
3173 (if (boundp ref-dep)
3174 (setcdr (symbol-value ref-dep)
3175 (nconc (cdr (symbol-value ref-dep))
3176 (list (symbol-value id-dep))))
3177 (set ref-dep (list nil (symbol-value id-dep)))))
3180 (defun gnus-build-sparse-threads ()
3181 (let ((headers gnus-newsgroup-headers)
3182 (mail-parse-charset gnus-newsgroup-charset)
3183 (gnus-summary-ignore-duplicates t)
3184 header references generation relations
3185 subject child end new-child date)
3186 ;; First we create an alist of generations/relations, where
3187 ;; generations is how much we trust the relation, and the relation
3189 (gnus-message 7 "Making sparse threads...")
3191 (nnheader-set-temp-buffer " *gnus sparse threads*")
3192 (while (setq header (pop headers))
3193 (when (and (setq references (mail-header-references header))
3194 (not (string= references "")))
3196 (setq child (mail-header-id header)
3197 subject (mail-header-subject header)
3198 date (mail-header-date header)
3200 (while (search-backward ">" nil t)
3201 (setq end (1+ (point)))
3202 (when (search-backward "<" nil t)
3203 (setq new-child (buffer-substring (point) end))
3204 (push (list (incf generation)
3205 child (setq child new-child)
3209 (push (list (1+ generation) child nil subject) relations))
3211 (kill-buffer (current-buffer)))
3212 ;; Sort over trustworthiness.
3215 (when (gnus-dependencies-add-header
3216 (make-full-mail-header
3217 gnus-reffed-article-number
3218 (nth 3 relation) "" (or (nth 4 relation) "")
3220 (or (nth 2 relation) "") 0 0 "")
3221 gnus-newsgroup-dependencies nil)
3222 (push gnus-reffed-article-number gnus-newsgroup-limit)
3223 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3224 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3225 gnus-newsgroup-reads)
3226 (decf gnus-reffed-article-number)))
3227 (sort relations 'car-less-than-car))
3228 (gnus-message 7 "Making sparse threads...done")))
3230 (defun gnus-build-old-threads ()
3231 ;; Look at all the articles that refer back to old articles, and
3232 ;; fetch the headers for the articles that aren't there. This will
3233 ;; build complete threads - if the roots haven't been expired by the
3235 (let ((mail-parse-charset gnus-newsgroup-charset)
3239 (when (not (car (symbol-value refs)))
3240 (setq heads (cdr (symbol-value refs)))
3242 (if (memq (mail-header-number (caar heads))
3243 gnus-newsgroup-dormant)
3244 (setq heads (cdr heads))
3245 (setq id (symbol-name refs))
3246 (while (and (setq id (gnus-build-get-header id))
3247 (not (car (gnus-id-to-thread id)))))
3248 (setq heads nil)))))
3249 gnus-newsgroup-dependencies)))
3251 ;; This function has to be called with point after the article number
3252 ;; on the beginning of the line.
3253 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3254 (let ((eol (gnus-point-at-eol))
3255 (buffer (current-buffer))
3258 ;; overview: [num subject from date id refs chars lines misc]
3261 (narrow-to-region (point) eol)
3266 (make-full-mail-header
3268 (funcall gnus-decode-encoded-word-function
3269 (nnheader-nov-field)) ; subject
3270 (funcall gnus-decode-encoded-word-function
3271 (nnheader-nov-field)) ; from
3272 (nnheader-nov-field) ; date
3273 (nnheader-nov-read-message-id) ; id
3274 (nnheader-nov-field) ; refs
3275 (nnheader-nov-read-integer) ; chars
3276 (nnheader-nov-read-integer) ; lines
3278 (nnheader-nov-field)) ; misc
3279 (nnheader-nov-parse-extra)))) ; extra
3283 (when gnus-alter-header-function
3284 (funcall gnus-alter-header-function header))
3285 (gnus-dependencies-add-header header dependencies force-new)))
3287 (defun gnus-build-get-header (id)
3288 ;; Look through the buffer of NOV lines and find the header to
3289 ;; ID. Enter this line into the dependencies hash table, and return
3290 ;; the id of the parent article (if any).
3291 (let ((deps gnus-newsgroup-dependencies)
3295 (set-buffer nntp-server-buffer)
3296 (let ((case-fold-search nil))
3297 (goto-char (point-min))
3298 (while (and (not found)
3299 (search-forward id nil t))
3301 (setq found (looking-at
3302 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3303 (regexp-quote id))))
3304 (or found (beginning-of-line 2)))
3308 (setq header (gnus-nov-parse-line
3309 (read (current-buffer)) deps))
3310 (gnus-parent-id (mail-header-references header))))))
3312 (let ((number (mail-header-number header)))
3313 (push number gnus-newsgroup-limit)
3314 (push header gnus-newsgroup-headers)
3315 (if (memq number gnus-newsgroup-unselected)
3317 (push number gnus-newsgroup-unreads)
3318 (setq gnus-newsgroup-unselected
3319 (delq number gnus-newsgroup-unselected)))
3320 (push number gnus-newsgroup-ancient)))))))
3322 (defun gnus-build-all-threads ()
3323 "Read all the headers."
3324 (let ((gnus-summary-ignore-duplicates t)
3325 (mail-parse-charset gnus-newsgroup-charset)
3326 (dependencies gnus-newsgroup-dependencies)
3329 (set-buffer nntp-server-buffer)
3330 (let ((case-fold-search nil))
3331 (goto-char (point-min))
3334 (setq article (read (current-buffer))
3335 header (gnus-nov-parse-line article dependencies)))
3338 (set-buffer gnus-summary-buffer)
3339 (push header gnus-newsgroup-headers)
3340 (if (memq (setq article (mail-header-number header))
3341 gnus-newsgroup-unselected)
3343 (push article gnus-newsgroup-unreads)
3344 (setq gnus-newsgroup-unselected
3345 (delq article gnus-newsgroup-unselected)))
3346 (push article gnus-newsgroup-ancient)))
3347 (forward-line 1)))))))
3349 (defun gnus-summary-update-article-line (article header)
3350 "Update the line for ARTICLE using HEADERS."
3351 (let* ((id (mail-header-id header))
3352 (thread (gnus-id-to-thread id)))
3354 (error "Article in no thread"))
3355 ;; Update the thread.
3356 (setcar thread header)
3357 (gnus-summary-goto-subject article)
3358 (let* ((datal (gnus-data-find-list article))
3360 (length (when (cdr datal)
3361 (- (gnus-data-pos data)
3362 (gnus-data-pos (cadr datal)))))
3363 (buffer-read-only nil)
3364 (level (gnus-summary-thread-level)))
3366 (gnus-summary-insert-line
3367 header level nil (gnus-article-mark article)
3368 (memq article gnus-newsgroup-replied)
3369 (memq article gnus-newsgroup-expirable)
3370 ;; Only insert the Subject string when it's different
3371 ;; from the previous Subject string.
3372 (if (gnus-subject-equal
3374 (mail-header-subject
3377 (gnus-data-find-list
3379 (gnus-data-list t)))))
3380 ;; Error on the side of excessive subjects.
3382 (mail-header-subject header))
3384 (mail-header-subject header))
3385 nil (cdr (assq article gnus-newsgroup-scored))
3386 (memq article gnus-newsgroup-processable))
3388 (gnus-data-update-list
3389 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3391 (defun gnus-summary-update-article (article &optional iheader)
3392 "Update ARTICLE in the summary buffer."
3393 (set-buffer gnus-summary-buffer)
3394 (let* ((header (gnus-summary-article-header article))
3395 (id (mail-header-id header))
3396 (data (gnus-data-find article))
3397 (thread (gnus-id-to-thread id))
3398 (references (mail-header-references header))
3402 (when (and references
3403 (not (equal "" references)))
3406 (buffer-read-only nil)
3412 (delq thread parent)))
3413 (if (gnus-summary-insert-subject id header)
3414 ;; Set the (possibly) new article number in the data structure.
3415 (gnus-data-set-number data (gnus-id-to-article id))
3419 (defun gnus-rebuild-thread (id &optional line)
3420 "Rebuild the thread containing ID.
3421 If LINE, insert the rebuilt thread starting on line LINE."
3422 (let ((buffer-read-only nil)
3423 old-pos current thread data)
3424 (if (not gnus-show-threads)
3425 (setq thread (list (car (gnus-id-to-thread id))))
3426 ;; Get the thread this article is part of.
3427 (setq thread (gnus-remove-thread id)))
3428 (setq old-pos (gnus-point-at-bol))
3429 (setq current (save-excursion
3430 (and (zerop (forward-line -1))
3431 (gnus-summary-article-number))))
3432 ;; If this is a gathered thread, we have to go some re-gathering.
3433 (when (stringp (car thread))
3434 (let ((subject (car thread))
3436 (setq thread (cdr thread))
3438 (unless (memq (setq thr (gnus-id-to-thread
3440 (mail-header-id (caar thread)))))
3443 (setq thread (cdr thread)))
3444 ;; We now have all (unique) roots.
3445 (if (= (length roots) 1)
3446 ;; All the loose roots are now one solid root.
3447 (setq thread (car roots))
3448 (setq thread (cons subject (gnus-sort-threads roots))))))
3450 ;; We then insert this thread into the summary buffer.
3452 (goto-char (point-min))
3453 (forward-line (1- line)))
3454 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3455 (if gnus-show-threads
3456 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3457 (gnus-summary-prepare-unthreaded thread))
3458 (setq data (nreverse gnus-newsgroup-data))
3459 (setq threads gnus-newsgroup-threads))
3460 ;; We splice the new data into the data structure.
3461 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3462 ;;!!! then we want to insert at the beginning of the buffer.
3463 ;;!!! That happens to be true with Gnus now, but that may
3464 ;;!!! change in the future. Perhaps.
3465 (gnus-data-enter-list
3466 (if line nil current) data (- (point) old-pos))
3467 (setq gnus-newsgroup-threads
3468 (nconc threads gnus-newsgroup-threads))
3469 (gnus-data-compute-positions))))
3471 (defun gnus-number-to-header (number)
3472 "Return the header for article NUMBER."
3473 (let ((headers gnus-newsgroup-headers))
3475 (not (= number (mail-header-number (car headers)))))
3480 (defun gnus-parent-headers (in-headers &optional generation)
3481 "Return the headers of the GENERATIONeth parent of HEADERS."
3483 (setq generation 1))
3485 (headers in-headers)
3488 (not (zerop generation))
3489 (setq references (mail-header-references headers)))
3490 (setq headers (if (and references
3491 (setq parent (gnus-parent-id references)))
3492 (car (gnus-id-to-thread parent))
3495 (and (not (eq headers in-headers))
3498 (defun gnus-id-to-thread (id)
3499 "Return the (sub-)thread where ID appears."
3500 (gnus-gethash id gnus-newsgroup-dependencies))
3502 (defun gnus-id-to-article (id)
3503 "Return the article number of ID."
3504 (let ((thread (gnus-id-to-thread id)))
3507 (mail-header-number (car thread)))))
3509 (defun gnus-id-to-header (id)
3510 "Return the article headers of ID."
3511 (car (gnus-id-to-thread id)))
3513 (defun gnus-article-displayed-root-p (article)
3514 "Say whether ARTICLE is a root(ish) article."
3515 (let ((level (gnus-summary-thread-level article))
3516 (refs (mail-header-references (gnus-summary-article-header article)))
3522 ((null (gnus-parent-id refs)) t)
3524 (null (setq particle (gnus-id-to-article
3525 (gnus-parent-id refs))))
3526 (null (gnus-summary-thread-level particle)))))))
3528 (defun gnus-root-id (id)
3529 "Return the id of the root of the thread where ID appears."
3531 (while (and id (setq prev (car (gnus-id-to-thread id))))
3533 id (gnus-parent-id (mail-header-references prev))))
3536 (defun gnus-articles-in-thread (thread)
3537 "Return the list of articles in THREAD."
3538 (cons (mail-header-number (car thread))
3539 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3541 (defun gnus-remove-thread (id &optional dont-remove)
3542 "Remove the thread that has ID in it."
3543 (let (headers thread last-id)
3544 ;; First go up in this thread until we find the root.
3545 (setq last-id (gnus-root-id id)
3546 headers (message-flatten-list (gnus-id-to-thread last-id)))
3547 ;; We have now found the real root of this thread. It might have
3548 ;; been gathered into some loose thread, so we have to search
3549 ;; through the threads to find the thread we wanted.
3550 (let ((threads gnus-newsgroup-threads)
3553 (setq sub (car threads))
3554 (if (stringp (car sub))
3555 ;; This is a gathered thread, so we look at the roots
3556 ;; below it to find whether this article is in this
3559 (setq sub (cdr sub))
3561 (when (member (caar sub) headers)
3562 (setq thread (car threads)
3565 (setq sub (cdr sub))))
3566 ;; It's an ordinary thread, so we check it.
3567 (when (eq (car sub) (car headers))
3570 (setq threads (cdr threads)))
3571 ;; If this article is in no thread, then it's a root.
3574 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3575 (setq thread (gnus-id-to-thread last-id)))
3578 thread ; We return this thread.
3580 (if (stringp (car thread))
3582 ;; If we use dummy roots, then we have to remove the
3583 ;; dummy root as well.
3584 (when (eq gnus-summary-make-false-root 'dummy)
3585 ;; We go to the dummy root by going to
3586 ;; the first sub-"thread", and then one line up.
3587 (gnus-summary-goto-article
3588 (mail-header-number (caadr thread)))
3591 (gnus-data-compute-positions))
3592 (setq thread (cdr thread))
3594 (gnus-remove-thread-1 (car thread))
3595 (setq thread (cdr thread))))
3596 (gnus-summary-show-all-threads)
3597 (gnus-remove-thread-1 thread))))))))
3599 (defun gnus-remove-thread-1 (thread)
3600 "Remove the thread THREAD recursively."
3601 (let ((number (mail-header-number (pop thread)))
3603 (setq thread (reverse thread))
3605 (gnus-remove-thread-1 (pop thread)))
3606 (when (setq d (gnus-data-find number))
3607 (goto-char (gnus-data-pos d))
3610 (- (gnus-point-at-bol)
3612 (1+ (gnus-point-at-eol))
3613 (gnus-delete-line)))))))
3615 (defun gnus-sort-threads (threads)
3617 (if (not gnus-thread-sort-functions)
3619 (gnus-message 8 "Sorting threads...")
3621 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3622 (gnus-message 8 "Sorting threads...done"))))
3624 (defun gnus-sort-articles (articles)
3626 (when gnus-article-sort-functions
3627 (gnus-message 7 "Sorting articles...")
3629 (setq gnus-newsgroup-headers
3630 (sort articles (gnus-make-sort-function
3631 gnus-article-sort-functions)))
3632 (gnus-message 7 "Sorting articles...done"))))
3634 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3635 (defmacro gnus-thread-header (thread)
3636 ;; Return header of first article in THREAD.
3637 ;; Note that THREAD must never, ever be anything else than a variable -
3638 ;; using some other form will lead to serious barfage.
3639 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3640 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3641 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
3644 (defsubst gnus-article-sort-by-number (h1 h2)
3645 "Sort articles by article number."
3646 (< (mail-header-number h1)
3647 (mail-header-number h2)))
3649 (defun gnus-thread-sort-by-number (h1 h2)
3650 "Sort threads by root article number."
3651 (gnus-article-sort-by-number
3652 (gnus-thread-header h1) (gnus-thread-header h2)))
3654 (defsubst gnus-article-sort-by-lines (h1 h2)
3655 "Sort articles by article Lines header."
3656 (< (mail-header-lines h1)
3657 (mail-header-lines h2)))
3659 (defun gnus-thread-sort-by-lines (h1 h2)
3660 "Sort threads by root article Lines header."
3661 (gnus-article-sort-by-lines
3662 (gnus-thread-header h1) (gnus-thread-header h2)))
3664 (defsubst gnus-article-sort-by-chars (h1 h2)
3665 "Sort articles by octet length."
3666 (< (mail-header-chars h1)
3667 (mail-header-chars h2)))
3669 (defun gnus-thread-sort-by-chars (h1 h2)
3670 "Sort threads by root article octet length."
3671 (gnus-article-sort-by-chars
3672 (gnus-thread-header h1) (gnus-thread-header h2)))
3674 (defsubst gnus-article-sort-by-author (h1 h2)
3675 "Sort articles by root author."
3677 (let ((extract (funcall
3678 gnus-extract-address-components
3679 (mail-header-from h1))))
3680 (or (car extract) (cadr extract) ""))
3681 (let ((extract (funcall
3682 gnus-extract-address-components
3683 (mail-header-from h2))))
3684 (or (car extract) (cadr extract) ""))))
3686 (defun gnus-thread-sort-by-author (h1 h2)
3687 "Sort threads by root author."
3688 (gnus-article-sort-by-author
3689 (gnus-thread-header h1) (gnus-thread-header h2)))
3691 (defsubst gnus-article-sort-by-subject (h1 h2)
3692 "Sort articles by root subject."
3694 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3695 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3697 (defun gnus-thread-sort-by-subject (h1 h2)
3698 "Sort threads by root subject."
3699 (gnus-article-sort-by-subject
3700 (gnus-thread-header h1) (gnus-thread-header h2)))
3702 (defsubst gnus-article-sort-by-date (h1 h2)
3703 "Sort articles by root article date."
3705 (gnus-date-get-time (mail-header-date h1))
3706 (gnus-date-get-time (mail-header-date h2))))
3708 (defun gnus-thread-sort-by-date (h1 h2)
3709 "Sort threads by root article date."
3710 (gnus-article-sort-by-date
3711 (gnus-thread-header h1) (gnus-thread-header h2)))
3713 (defsubst gnus-article-sort-by-score (h1 h2)
3714 "Sort articles by root article score.
3715 Unscored articles will be counted as having a score of zero."
3716 (> (or (cdr (assq (mail-header-number h1)
3717 gnus-newsgroup-scored))
3718 gnus-summary-default-score 0)
3719 (or (cdr (assq (mail-header-number h2)
3720 gnus-newsgroup-scored))
3721 gnus-summary-default-score 0)))
3723 (defun gnus-thread-sort-by-score (h1 h2)
3724 "Sort threads by root article score."
3725 (gnus-article-sort-by-score
3726 (gnus-thread-header h1) (gnus-thread-header h2)))
3728 (defun gnus-thread-sort-by-total-score (h1 h2)
3729 "Sort threads by the sum of all scores in the thread.
3730 Unscored articles will be counted as having a score of zero."
3731 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3733 (defun gnus-thread-total-score (thread)
3734 ;; This function find the total score of THREAD.
3735 (cond ((null thread)
3738 (if (stringp (car thread))
3739 (apply gnus-thread-score-function 0
3740 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3741 (gnus-thread-total-score-1 thread)))
3743 (gnus-thread-total-score-1 (list thread)))))
3745 (defun gnus-thread-total-score-1 (root)
3746 ;; This function find the total score of the thread below ROOT.
3747 (setq root (car root))
3748 (apply gnus-thread-score-function
3750 (mapcar 'gnus-thread-total-score
3751 (cdr (gnus-id-to-thread (mail-header-id root))))
3752 (when (> (mail-header-number root) 0)
3753 (list (or (cdr (assq (mail-header-number root)
3754 gnus-newsgroup-scored))
3755 gnus-summary-default-score 0))))
3756 (list gnus-summary-default-score)
3759 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3760 (defvar gnus-tmp-prev-subject nil)
3761 (defvar gnus-tmp-false-parent nil)
3762 (defvar gnus-tmp-root-expunged nil)
3763 (defvar gnus-tmp-dummy-line nil)
3765 (defvar gnus-tmp-header)
3766 (defun gnus-extra-header (type &optional header)
3767 "Return the extra header of TYPE."
3768 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
3771 (defun gnus-summary-prepare-threads (threads)
3772 "Prepare summary buffer from THREADS and indentation LEVEL.
3773 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3774 or a straight list of headers."
3775 (gnus-message 7 "Generating summary...")
3777 (setq gnus-newsgroup-threads threads)
3780 (let ((gnus-tmp-level 0)
3781 (default-score (or gnus-summary-default-score 0))
3782 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3783 thread number subject stack state gnus-tmp-gathered beg-match
3784 new-roots gnus-tmp-new-adopts thread-end
3785 gnus-tmp-header gnus-tmp-unread
3786 gnus-tmp-replied gnus-tmp-subject-or-nil
3787 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3788 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3789 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3791 (setq gnus-tmp-prev-subject nil)
3793 (if (vectorp (car threads))
3794 ;; If this is a straight (sic) list of headers, then a
3795 ;; threaded summary display isn't required, so we just create
3796 ;; an unthreaded one.
3797 (gnus-summary-prepare-unthreaded threads)
3799 ;; Do the threaded display.
3801 (while (or threads stack gnus-tmp-new-adopts new-roots)
3803 (if (and (= gnus-tmp-level 0)
3806 (not gnus-tmp-false-parent)
3807 (or gnus-tmp-new-adopts new-roots))
3808 (if gnus-tmp-new-adopts
3809 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3810 thread (list (car gnus-tmp-new-adopts))
3811 gnus-tmp-header (caar thread)
3812 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3814 (setq thread (list (car new-roots))
3815 gnus-tmp-header (caar thread)
3816 new-roots (cdr new-roots))))
3819 ;; If there are some threads, we do them before the
3820 ;; threads on the stack.
3821 (setq thread threads
3822 gnus-tmp-header (caar thread))
3823 ;; There were no current threads, so we pop something off
3825 (setq state (car stack)
3826 gnus-tmp-level (car state)
3829 gnus-tmp-header (caar thread))))
3831 (setq gnus-tmp-false-parent nil)
3832 (setq gnus-tmp-root-expunged nil)
3833 (setq thread-end nil)
3835 (if (stringp gnus-tmp-header)
3836 ;; The header is a dummy root.
3838 ((eq gnus-summary-make-false-root 'adopt)
3839 ;; We let the first article adopt the rest.
3840 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3842 (setq gnus-tmp-gathered
3844 (lambda (h) (mail-header-number (car h)))
3847 (setq thread (cons (list (caar thread)
3850 (setq gnus-tmp-level -1
3851 gnus-tmp-false-parent t))
3852 ((eq gnus-summary-make-false-root 'empty)
3853 ;; We print adopted articles with empty subject fields.
3854 (setq gnus-tmp-gathered
3856 (lambda (h) (mail-header-number (car h)))
3859 (setq gnus-tmp-level -1))
3860 ((eq gnus-summary-make-false-root 'dummy)
3861 ;; We remember that we probably want to output a dummy
3863 (setq gnus-tmp-dummy-line gnus-tmp-header)
3864 (setq gnus-tmp-prev-subject gnus-tmp-header))
3866 ;; We do not make a root for the gathered
3867 ;; sub-threads at all.
3868 (setq gnus-tmp-level -1)))
3870 (setq number (mail-header-number gnus-tmp-header)
3871 subject (mail-header-subject gnus-tmp-header))
3874 ;; If the thread has changed subject, we might want to make
3875 ;; this subthread into a root.
3876 ((and (null gnus-thread-ignore-subject)
3877 (not (zerop gnus-tmp-level))
3878 gnus-tmp-prev-subject
3880 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3881 (setq new-roots (nconc new-roots (list (car thread)))
3883 gnus-tmp-header nil))
3884 ;; If the article lies outside the current limit,
3885 ;; then we do not display it.
3886 ((not (memq number gnus-newsgroup-limit))
3887 (setq gnus-tmp-gathered
3889 (lambda (h) (mail-header-number (car h)))
3892 (setq gnus-tmp-new-adopts (if (cdar thread)
3893 (append gnus-tmp-new-adopts
3895 gnus-tmp-new-adopts)
3897 gnus-tmp-header nil)
3898 (when (zerop gnus-tmp-level)
3899 (setq gnus-tmp-root-expunged t)))
3900 ;; Perhaps this article is to be marked as read?
3901 ((and gnus-summary-mark-below
3902 (< (or (cdr (assq number gnus-newsgroup-scored))
3904 gnus-summary-mark-below)
3905 ;; Don't touch sparse articles.
3906 (not (gnus-summary-article-sparse-p number))
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 (when gnus-tmp-header
3916 ;; We may have an old dummy line to output before this
3918 (when (and gnus-tmp-dummy-line
3921 (mail-header-subject gnus-tmp-header)))
3922 (gnus-summary-insert-dummy-line
3923 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3924 (setq gnus-tmp-dummy-line nil))
3926 ;; Compute the mark.
3927 (setq gnus-tmp-unread (gnus-article-mark number))
3929 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3930 gnus-tmp-header gnus-tmp-level)
3931 gnus-newsgroup-data)
3933 ;; Actually insert the line.
3935 gnus-tmp-subject-or-nil
3937 ((and gnus-thread-ignore-subject
3938 gnus-tmp-prev-subject
3939 (not (inline (gnus-subject-equal
3940 gnus-tmp-prev-subject subject))))
3942 ((zerop gnus-tmp-level)
3943 (if (and (eq gnus-summary-make-false-root 'empty)
3944 (memq number gnus-tmp-gathered)
3945 gnus-tmp-prev-subject
3946 (inline (gnus-subject-equal
3947 gnus-tmp-prev-subject subject)))
3948 gnus-summary-same-subject
3950 (t gnus-summary-same-subject)))
3951 (if (and (eq gnus-summary-make-false-root 'adopt)
3952 (= gnus-tmp-level 1)
3953 (memq number gnus-tmp-gathered))
3954 (setq gnus-tmp-opening-bracket ?\<
3955 gnus-tmp-closing-bracket ?\>)
3956 (setq gnus-tmp-opening-bracket ?\[
3957 gnus-tmp-closing-bracket ?\]))
3959 gnus-tmp-indentation
3960 (aref gnus-thread-indent-array gnus-tmp-level)
3961 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3962 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3963 gnus-summary-default-score 0)
3965 (if (or (null gnus-summary-default-score)
3966 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3967 gnus-summary-zcore-fuzz))
3969 (if (< gnus-tmp-score gnus-summary-default-score)
3970 gnus-score-below-mark gnus-score-over-mark))
3972 (cond ((memq number gnus-newsgroup-processable)
3974 ((memq number gnus-newsgroup-cached)
3976 ((memq number gnus-newsgroup-replied)
3978 ((memq number gnus-newsgroup-saved)
3980 (t gnus-unread-mark))
3981 gnus-tmp-from (mail-header-from gnus-tmp-header)
3984 ((string-match "<[^>]+> *$" gnus-tmp-from)
3985 (setq beg-match (match-beginning 0))
3986 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3987 (substring gnus-tmp-from (1+ (match-beginning 0))
3988 (1- (match-end 0))))
3989 (substring gnus-tmp-from 0 beg-match)))
3990 ((string-match "(.+)" gnus-tmp-from)
3991 (substring gnus-tmp-from
3992 (1+ (match-beginning 0)) (1- (match-end 0))))
3994 (when (string= gnus-tmp-name "")
3995 (setq gnus-tmp-name gnus-tmp-from))
3996 (unless (numberp gnus-tmp-lines)
3997 (setq gnus-tmp-lines 0))
3998 (gnus-put-text-property
4000 (progn (eval gnus-summary-line-format-spec) (point))
4001 'gnus-number number)
4004 (gnus-run-hooks 'gnus-summary-update-hook)
4007 (setq gnus-tmp-prev-subject subject)))
4009 (when (nth 1 thread)
4010 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
4011 (incf gnus-tmp-level)
4012 (setq threads (if thread-end nil (cdar thread)))
4014 (setq gnus-tmp-level 0)))))
4015 (gnus-message 7 "Generating summary...done"))
4017 (defun gnus-summary-prepare-unthreaded (headers)
4018 "Generate an unthreaded summary buffer based on HEADERS."
4019 (let (header number mark)
4024 ;; We may have to root out some bad articles...
4025 (when (memq (setq number (mail-header-number
4026 (setq header (pop headers))))
4027 gnus-newsgroup-limit)
4028 ;; Mark article as read when it has a low score.
4029 (when (and gnus-summary-mark-below
4030 (< (or (cdr (assq number gnus-newsgroup-scored))
4031 gnus-summary-default-score 0)
4032 gnus-summary-mark-below)
4033 (not (gnus-summary-article-ancient-p number)))
4034 (setq gnus-newsgroup-unreads
4035 (delq number gnus-newsgroup-unreads))
4036 (if gnus-newsgroup-auto-expire
4037 (push number gnus-newsgroup-expirable)
4038 (push (cons number gnus-low-score-mark)
4039 gnus-newsgroup-reads)))
4041 (setq mark (gnus-article-mark number))
4042 (push (gnus-data-make number mark (1+ (point)) header 0)
4043 gnus-newsgroup-data)
4044 (gnus-summary-insert-line
4046 mark (memq number gnus-newsgroup-replied)
4047 (memq number gnus-newsgroup-expirable)
4048 (mail-header-subject header) nil
4049 (cdr (assq number gnus-newsgroup-scored))
4050 (memq number gnus-newsgroup-processable))))))
4052 (defun gnus-summary-remove-list-identifiers ()
4053 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4054 (let ((regexp (if (stringp gnus-list-identifiers)
4055 gnus-list-identifiers
4056 (mapconcat 'identity gnus-list-identifiers " *\\|"))))
4057 (dolist (header gnus-newsgroup-headers)
4058 (when (string-match (concat "\\(Re: +\\)?\\(" regexp " *\\)")
4059 (mail-header-subject header))
4060 (mail-header-set-subject
4061 header (concat (substring (mail-header-subject header)
4062 0 (match-beginning 2))
4063 (substring (mail-header-subject header)
4064 (match-end 2))))))))
4066 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4067 "Select newsgroup GROUP.
4068 If READ-ALL is non-nil, all articles in the group are selected.
4069 If SELECT-ARTICLES, only select those articles from GROUP."
4070 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4071 ;;!!! Dirty hack; should be removed.
4072 (gnus-summary-ignore-duplicates
4073 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4075 gnus-summary-ignore-duplicates))
4076 (info (nth 2 entry))
4077 articles fetched-articles cached)
4079 (unless (gnus-check-server
4080 (setq gnus-current-select-method
4081 (gnus-find-method-for-group group)))
4082 (error "Couldn't open server"))
4084 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4085 (gnus-activate-group group) ; Or we can activate it...
4086 (progn ; Or we bug out.
4087 (when (equal major-mode 'gnus-summary-mode)
4088 (kill-buffer (current-buffer)))
4089 (error "Couldn't request group %s: %s"
4090 group (gnus-status-message group))))
4092 (unless (gnus-request-group group t)
4093 (when (equal major-mode 'gnus-summary-mode)
4094 (kill-buffer (current-buffer)))
4095 (error "Couldn't request group %s: %s"
4096 group (gnus-status-message group)))
4098 (setq gnus-newsgroup-name group)
4099 (setq gnus-newsgroup-unselected nil)
4100 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4101 (gnus-summary-setup-default-charset)
4103 ;; Adjust and set lists of article marks.
4105 (gnus-adjust-marked-articles info))
4107 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4108 (when (gnus-virtual-group-p group)
4109 (setq cached gnus-newsgroup-cached))
4111 (setq gnus-newsgroup-unreads
4112 (gnus-set-difference
4113 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4114 gnus-newsgroup-dormant))
4116 (setq gnus-newsgroup-processable nil)
4118 (gnus-update-read-articles group gnus-newsgroup-unreads)
4120 (if (setq articles select-articles)
4121 (setq gnus-newsgroup-unselected
4122 (gnus-sorted-intersection
4123 gnus-newsgroup-unreads
4124 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4125 (setq articles (gnus-articles-to-read group read-all)))
4129 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4131 ((eq articles 0) nil)
4133 ;; Init the dependencies hash table.
4134 (setq gnus-newsgroup-dependencies
4135 (gnus-make-hashtable (length articles)))
4136 (gnus-set-global-variables)
4137 ;; Retrieve the headers and read them in.
4138 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
4139 (setq gnus-newsgroup-headers
4141 (setq gnus-headers-retrieved-by
4142 (gnus-retrieve-headers
4143 articles gnus-newsgroup-name
4144 ;; We might want to fetch old headers, but
4145 ;; not if there is only 1 article.
4147 (not (eq gnus-fetch-old-headers 'some))
4148 (not (numberp gnus-fetch-old-headers)))
4149 (> (length articles) 1))
4150 gnus-fetch-old-headers))))
4151 (gnus-get-newsgroup-headers-xover
4152 articles nil nil gnus-newsgroup-name t)
4153 (gnus-get-newsgroup-headers)))
4154 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
4156 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4158 (setq gnus-newsgroup-cached cached))
4160 ;; Suppress duplicates?
4161 (when gnus-suppress-duplicates
4162 (gnus-dup-suppress-articles))
4164 ;; Set the initial limit.
4165 (setq gnus-newsgroup-limit (copy-sequence articles))
4166 ;; Remove canceled articles from the list of unread articles.
4167 (setq gnus-newsgroup-unreads
4168 (gnus-set-sorted-intersection
4169 gnus-newsgroup-unreads
4170 (setq fetched-articles
4171 (mapcar (lambda (headers) (mail-header-number headers))
4172 gnus-newsgroup-headers))))
4173 ;; Removed marked articles that do not exist.
4174 (gnus-update-missing-marks
4175 (gnus-sorted-complement fetched-articles articles))
4176 ;; We might want to build some more threads first.
4177 (when (and gnus-fetch-old-headers
4178 (eq gnus-headers-retrieved-by 'nov))
4179 (if (eq gnus-fetch-old-headers 'invisible)
4180 (gnus-build-all-threads)
4181 (gnus-build-old-threads)))
4182 ;; Let the Gnus agent mark articles as read.
4184 (gnus-agent-get-undownloaded-list))
4185 ;; Remove list identifiers from subject
4186 (when gnus-list-identifiers
4187 (gnus-summary-remove-list-identifiers))
4188 ;; Check whether auto-expire is to be done in this group.
4189 (setq gnus-newsgroup-auto-expire
4190 (gnus-group-auto-expirable-p group))
4191 ;; Set up the article buffer now, if necessary.
4192 (unless gnus-single-article-buffer
4193 (gnus-article-setup-buffer))
4194 ;; First and last article in this newsgroup.
4195 (when gnus-newsgroup-headers
4196 (setq gnus-newsgroup-begin
4197 (mail-header-number (car gnus-newsgroup-headers))
4200 (gnus-last-element gnus-newsgroup-headers))))
4201 ;; GROUP is successfully selected.
4202 (or gnus-newsgroup-headers t)))))
4204 (defun gnus-articles-to-read (group &optional read-all)
4205 ;; Find out what articles the user wants to read.
4207 ;; Select all articles if `read-all' is non-nil, or if there
4208 ;; are no unread articles.
4210 (and (zerop (length gnus-newsgroup-marked))
4211 (zerop (length gnus-newsgroup-unreads)))
4212 (eq (gnus-group-find-parameter group 'display)
4215 (gnus-uncompress-range (gnus-active group))
4216 (gnus-cache-articles-in-group group))
4217 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4218 (copy-sequence gnus-newsgroup-unreads))
4220 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4221 (scored (length scored-list))
4222 (number (length articles))
4223 (marked (+ (length gnus-newsgroup-marked)
4224 (length gnus-newsgroup-dormant)))
4232 ((and (or (<= scored marked) (= scored number))
4233 (numberp gnus-large-newsgroup)
4234 (> number gnus-large-newsgroup))
4238 "How many articles from %s (default %d): "
4239 (gnus-limit-string gnus-newsgroup-name 35)
4241 (if (string-match "^[ \t]*$" input) number input)))
4242 ((and (> scored marked) (< scored number)
4243 (> (- scored number) 20))
4246 (format "%s %s (%d scored, %d total): "
4247 "How many articles from"
4248 group scored number))))
4249 (if (string-match "^[ \t]*$" input)
4253 (setq select (if (stringp select) (string-to-number select) select))
4254 (if (or (null select) (zerop select))
4256 (if (and (not (zerop scored)) (<= (abs select) scored))
4258 (setq articles (sort scored-list '<))
4259 (setq number (length articles)))
4260 (setq articles (copy-sequence articles)))
4262 (when (< (abs select) number)
4264 ;; Select the N oldest articles.
4265 (setcdr (nthcdr (1- (abs select)) articles) nil)
4266 ;; Select the N most recent articles.
4267 (setq articles (nthcdr (- number select) articles))))
4268 (setq gnus-newsgroup-unselected
4269 (gnus-sorted-intersection
4270 gnus-newsgroup-unreads
4271 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4274 (defun gnus-killed-articles (killed articles)
4277 (when (inline (gnus-member-of-range (car articles) killed))
4278 (push (car articles) out))
4279 (setq articles (cdr articles)))
4282 (defun gnus-uncompress-marks (marks)
4283 "Uncompress the mark ranges in MARKS."
4284 (let ((uncompressed '(score bookmark))
4287 (if (memq (caar marks) uncompressed)
4288 (push (car marks) out)
4289 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4290 (setq marks (cdr marks)))
4293 (defun gnus-adjust-marked-articles (info)
4294 "Set all article lists and remove all marks that are no longer valid."
4295 (let* ((marked-lists (gnus-info-marks info))
4296 (active (gnus-active (gnus-info-group info)))
4299 (types gnus-article-mark-lists)
4300 (uncompressed '(score bookmark killed))
4301 marks var articles article mark)
4304 (setq marks (pop marked-lists))
4305 (set (setq var (intern (format "gnus-newsgroup-%s"
4306 (car (rassq (setq mark (car marks))
4308 (if (memq (car marks) uncompressed) (cdr marks)
4309 (gnus-uncompress-range (cdr marks))))
4311 (setq articles (symbol-value var))
4313 ;; All articles have to be subsets of the active articles.
4315 ;; Adjust "simple" lists.
4316 ((memq mark '(tick dormant expire reply save))
4318 (when (or (< (setq article (pop articles)) min) (> article max))
4319 (set var (delq article (symbol-value var))))))
4321 ((memq mark uncompressed)
4322 (when (not (listp (cdr (symbol-value var))))
4323 (set var (list (symbol-value var))))
4324 (when (not (listp (cdr articles)))
4325 (setq articles (list articles)))
4327 (when (or (not (consp (setq article (pop articles))))
4328 (< (car article) min)
4329 (> (car article) max))
4330 (set var (delq article (symbol-value var))))))))))
4332 (defun gnus-update-missing-marks (missing)
4333 "Go through the list of MISSING articles and remove them from the mark lists."
4335 (let ((types gnus-article-mark-lists)
4337 ;; Go through all types.
4339 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4340 (when (symbol-value var)
4341 ;; This list has articles. So we delete all missing articles
4345 (set var (delq (pop m) (symbol-value var)))))))))
4347 (defun gnus-update-marks ()
4348 "Enter the various lists of marked articles into the newsgroup info list."
4349 (let ((types gnus-article-mark-lists)
4350 (info (gnus-get-info gnus-newsgroup-name))
4351 (uncompressed '(score bookmark killed))
4352 type list newmarked symbol delta-marks)
4354 ;; Add all marks lists to the list of marks lists.
4355 (while (setq type (pop types))
4356 (setq list (symbol-value
4358 (intern (format "gnus-newsgroup-%s"
4362 ;; Get rid of the entries of the articles that have the
4364 (when (and (eq (cdr type) 'score)
4368 (prev (cons nil list))
4371 (if (or (not (consp (car arts)))
4372 (= (cdar arts) gnus-summary-default-score))
4373 (setcdr prev (cdr arts))
4375 (setq arts (cdr arts)))
4376 (setq list (cdr all)))))
4378 (unless (memq (cdr type) uncompressed)
4379 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
4381 (when (gnus-check-backend-function
4382 'request-set-mark gnus-newsgroup-name)
4383 ;; uncompressed:s are not proper flags (they are cons cells)
4384 ;; cache is a internal gnus flag
4385 (unless (memq (cdr type) (cons 'cache uncompressed))
4386 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4387 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
4388 (add (gnus-remove-from-range
4389 (gnus-copy-sequence list) old)))
4391 (push (list add 'add (list (cdr type))) delta-marks))
4393 (push (list del 'del (list (cdr type))) delta-marks)))))
4396 (push (cons (cdr type) list) newmarked)))
4399 (unless (gnus-check-group gnus-newsgroup-name)
4400 (error "Can't open server for %s" gnus-newsgroup-name))
4401 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4403 ;; Enter these new marks into the info of the group.
4405 (setcar (nthcdr 3 info) newmarked)
4406 ;; Add the marks lists to the end of the info.
4408 (setcdr (nthcdr 2 info) (list newmarked))))
4410 ;; Cut off the end of the info if there's nothing else there.
4414 (when (nthcdr (decf i) info)
4415 (setcdr (nthcdr i info) nil)))))))
4417 (defun gnus-set-mode-line (where)
4418 "This function sets the mode line of the article or summary buffers.
4419 If WHERE is `summary', the summary mode line format will be used."
4420 ;; Is this mode line one we keep updated?
4421 (when (and (memq where gnus-updated-mode-lines)
4423 (intern (format "gnus-%s-mode-line-format-spec" where))))
4426 ;; We evaluate this in the summary buffer since these
4427 ;; variables are buffer-local to that buffer.
4428 (set-buffer gnus-summary-buffer)
4429 ;; We bind all these variables that are used in the `eval' form
4431 (let* ((mformat (symbol-value
4433 (format "gnus-%s-mode-line-format-spec" where))))
4434 (gnus-tmp-group-name gnus-newsgroup-name)
4435 (gnus-tmp-article-number (or gnus-current-article 0))
4436 (gnus-tmp-unread gnus-newsgroup-unreads)
4437 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4438 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4439 (gnus-tmp-unread-and-unselected
4440 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4441 (zerop gnus-tmp-unselected))
4443 ((zerop gnus-tmp-unselected)
4444 (format "{%d more}" gnus-tmp-unread-and-unticked))
4445 (t (format "{%d(+%d) more}"
4446 gnus-tmp-unread-and-unticked
4447 gnus-tmp-unselected))))
4449 (if (and gnus-current-headers
4450 (vectorp gnus-current-headers))
4451 (gnus-mode-string-quote
4452 (mail-header-subject gnus-current-headers))
4454 bufname-length max-len
4455 gnus-tmp-header);; passed as argument to any user-format-funcs
4456 (setq mode-string (eval mformat))
4457 (setq bufname-length (if (string-match "%b" mode-string)
4460 (if (eq where 'summary)
4462 (get-buffer gnus-article-buffer))))
4465 (setq max-len (max 4 (if gnus-mode-non-string-length
4467 gnus-mode-non-string-length
4469 (length mode-string))))
4470 ;; We might have to chop a bit of the string off...
4471 (when (> (length mode-string) max-len)
4473 (concat (truncate-string-to-width mode-string (- max-len 3))
4475 ;; Pad the mode string a bit.
4476 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4477 ;; Update the mode line.
4478 (setq mode-line-buffer-identification
4479 (gnus-mode-line-buffer-identification (list mode-string)))
4480 (set-buffer-modified-p t))))
4482 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4483 "Go through the HEADERS list and add all Xrefs to a hash table.
4484 The resulting hash table is returned, or nil if no Xrefs were found."
4485 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4486 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4487 (xref-hashtb (gnus-make-hashtable))
4488 start group entry number xrefs header)
4490 (setq header (pop headers))
4491 (when (and (setq xrefs (mail-header-xref header))
4492 (not (memq (setq number (mail-header-number header))
4495 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4496 (setq start (match-end 0))
4497 (setq group (if prefix
4498 (concat prefix (substring xrefs (match-beginning 1)
4500 (substring xrefs (match-beginning 1) (match-end 1))))
4502 (string-to-int (substring xrefs (match-beginning 2)
4504 (if (setq entry (gnus-gethash group xref-hashtb))
4505 (setcdr entry (cons number (cdr entry)))
4506 (gnus-sethash group (cons number nil) xref-hashtb)))))
4507 (and start xref-hashtb)))
4509 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4510 "Look through all the headers and mark the Xrefs as read."
4511 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4512 name entry info xref-hashtb idlist method nth4)
4514 (set-buffer gnus-group-buffer)
4515 (when (setq xref-hashtb
4516 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4519 (unless (string= from-newsgroup (setq name (symbol-name group)))
4520 (setq idlist (symbol-value group))
4521 ;; Dead groups are not updated.
4523 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4525 (when (stringp (setq nth4 (gnus-info-method info)))
4526 (setq nth4 (gnus-server-to-method nth4))))
4527 ;; Only do the xrefs if the group has the same
4528 ;; select method as the group we have just read.
4529 (or (gnus-methods-equal-p
4530 nth4 (gnus-find-method-for-group from-newsgroup))
4532 (equal nth4 (setq method (gnus-find-method-for-group
4534 (and (equal (car nth4) (car method))
4535 (equal (nth 1 nth4) (nth 1 method))))
4536 gnus-use-cross-reference
4537 (or (not (eq gnus-use-cross-reference t))
4539 ;; Only do cross-references on subscribed
4540 ;; groups, if that is what is wanted.
4541 (<= (gnus-info-level info) gnus-level-subscribed))
4542 (gnus-group-make-articles-read name idlist))))
4545 (defun gnus-compute-read-articles (group articles)
4546 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4547 (info (nth 2 entry))
4548 (active (gnus-active group))
4551 ;; First peel off all invalid article numbers.
4553 (let ((ids articles)
4555 (while (setq id (pop ids))
4556 (when (and first (> id (cdr active)))
4557 ;; We'll end up in this situation in one particular
4558 ;; obscure situation. If you re-scan a group and get
4559 ;; a new article that is cross-posted to a different
4560 ;; group that has not been re-scanned, you might get
4561 ;; crossposted article that has a higher number than
4562 ;; Gnus believes possible. So we re-activate this
4563 ;; group as well. This might mean doing the
4564 ;; crossposting thingy will *increase* the number
4565 ;; of articles in some groups. Tsk, tsk.
4566 (setq active (or (gnus-activate-group group) active)))
4567 (when (or (> id (cdr active))
4568 (< id (car active)))
4569 (setq articles (delq id articles))))))
4570 ;; If the read list is nil, we init it.
4572 (null (gnus-info-read info))
4574 (setq ninfo (cons 1 (1- (car active))))
4575 (setq ninfo (gnus-info-read info)))
4576 ;; Then we add the read articles to the range.
4578 ninfo (setq articles (sort articles '<))))))
4580 (defun gnus-group-make-articles-read (group articles)
4581 "Update the info of GROUP to say that ARTICLES are read."
4583 (entry (gnus-gethash group gnus-newsrc-hashtb))
4584 (info (nth 2 entry))
4585 (active (gnus-active group))
4588 (setq range (gnus-compute-read-articles group articles))
4590 (set-buffer gnus-group-buffer)
4593 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4594 (gnus-info-set-read ',info ',(gnus-info-read info))
4595 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4596 (gnus-group-update-group ,group t))))
4597 ;; Add the read articles to the range.
4598 (gnus-info-set-read info range)
4599 ;; Then we have to re-compute how many unread
4600 ;; articles there are in this group.
4604 (setq num (- (1+ (cdr active)) (car active))))
4605 ((not (listp (cdr range)))
4606 (setq num (- (cdr active) (- (1+ (cdr range))
4610 (if (numberp (car range))
4612 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4613 (setq range (cdr range)))
4614 (setq num (- (cdr active) num))))
4615 ;; Update the number of unread articles.
4617 ;; Update the group buffer.
4618 (gnus-group-update-group group t)))))
4620 (defvar gnus-newsgroup-none-id 0)
4622 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4623 (let ((cur nntp-server-buffer)
4626 (save-excursion (set-buffer gnus-summary-buffer)
4627 gnus-newsgroup-dependencies)))
4629 (mail-parse-charset gnus-newsgroup-charset)
4630 (mail-parse-ignored-charsets
4631 (save-excursion (condition-case nil
4632 (set-buffer gnus-summary-buffer)
4634 gnus-newsgroup-ignored-charsets)))
4636 (set-buffer nntp-server-buffer)
4637 ;; Translate all TAB characters into SPACE characters.
4638 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4639 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4640 (gnus-run-hooks 'gnus-parse-headers-hook)
4641 (let ((case-fold-search t)
4642 in-reply-to header p lines chars)
4643 (goto-char (point-min))
4644 ;; Search to the beginning of the next header. Error messages
4645 ;; do not begin with 2 or 3.
4646 (while (re-search-forward "^[23][0-9]+ " nil t)
4649 ;; This implementation of this function, with nine
4650 ;; search-forwards instead of the one re-search-forward and
4651 ;; a case (which basically was the old function) is actually
4652 ;; about twice as fast, even though it looks messier. You
4653 ;; can't have everything, I guess. Speed and elegance
4654 ;; doesn't always go hand in hand.
4663 (narrow-to-region (point)
4664 (or (and (search-forward "\n.\n" nil t)
4670 (if (search-forward "\nsubject: " nil t)
4671 (funcall gnus-decode-encoded-word-function
4672 (nnheader-header-value))
4677 (if (search-forward "\nfrom: " nil t)
4678 (funcall gnus-decode-encoded-word-function
4679 (nnheader-header-value))
4684 (if (search-forward "\ndate: " nil t)
4685 (nnheader-header-value) ""))
4689 (setq id (if (re-search-forward
4690 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4691 ;; We do it this way to make sure the Message-ID
4692 ;; is (somewhat) syntactically valid.
4693 (buffer-substring (match-beginning 1)
4695 ;; If there was no message-id, we just fake one
4696 ;; to make subsequent routines simpler.
4697 (nnheader-generate-fake-message-id))))
4701 (if (search-forward "\nreferences: " nil t)
4705 (nnheader-header-value)
4710 (search-backward ">" end t)
4713 (search-backward "<" end t)
4715 ;; Get the references from the in-reply-to header if there
4716 ;; were no references and the in-reply-to header looks
4718 (if (and (search-forward "\nin-reply-to: " nil t)
4719 (setq in-reply-to (nnheader-header-value))
4720 (string-match "<[^>]+>" in-reply-to))
4722 (setq ref (substring in-reply-to (match-beginning 0)
4724 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4725 (setq ref2 (substring in-reply-to (match-beginning 0)
4727 (when (> (length ref2) (length ref))
4734 (if (search-forward "\nchars: " nil t)
4735 (if (numberp (setq chars (ignore-errors (read cur))))
4741 (if (search-forward "\nlines: " nil t)
4742 (if (numberp (setq lines (ignore-errors (read cur))))
4748 (and (search-forward "\nxref: " nil t)
4749 (nnheader-header-value)))
4751 (when gnus-extra-headers
4752 (let ((extra gnus-extra-headers)
4756 (when (search-forward
4757 (concat "\n" (symbol-name (car extra)) ": ") nil t)
4758 (push (cons (car extra) (nnheader-header-value))
4762 (when (equal id ref)
4765 (when gnus-alter-header-function
4766 (funcall gnus-alter-header-function header)
4767 (setq id (mail-header-id header)
4768 ref (gnus-parent-id (mail-header-references header))))
4771 (gnus-dependencies-add-header
4772 header dependencies force-new))
4773 (push header headers))
4774 (goto-char (point-max))
4776 (nreverse headers)))))
4778 ;; Goes through the xover lines and returns a list of vectors
4779 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4780 force-new dependencies
4781 group also-fetch-heads)
4782 "Parse the news overview data in the server buffer, and return a
4783 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4784 ;; Get the Xref when the users reads the articles since most/some
4785 ;; NNTP servers do not include Xrefs when using XOVER.
4786 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4787 (let ((mail-parse-charset gnus-newsgroup-charset)
4788 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
4789 (cur nntp-server-buffer)
4790 (dependencies (or dependencies gnus-newsgroup-dependencies))
4791 number headers header)
4793 (set-buffer nntp-server-buffer)
4794 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4795 ;; Allow the user to mangle the headers before parsing them.
4796 (gnus-run-hooks 'gnus-parse-headers-hook)
4797 (goto-char (point-min))
4800 (while (and sequence (not (eobp)))
4801 (setq number (read cur))
4802 (while (and sequence
4803 (< (car sequence) number))
4804 (setq sequence (cdr sequence)))
4806 (eq number (car sequence))
4808 (setq sequence (cdr sequence))
4809 (setq header (inline
4810 (gnus-nov-parse-line
4811 number dependencies force-new))))
4812 (push header headers))
4815 (gnus-error 4 "Strange nov line (%d)"
4816 (count-lines (point-min) (point)))))
4818 ;; A common bug in inn is that if you have posted an article and
4819 ;; then retrieves the active file, it will answer correctly --
4820 ;; the new article is included. However, a NOV entry for the
4821 ;; article may not have been generated yet, so this may fail.
4822 ;; We work around this problem by retrieving the last few
4823 ;; headers using HEAD.
4824 (if (or (not also-fetch-heads)
4826 ;; We (probably) got all the headers.
4828 (let ((gnus-nov-is-evil t))
4831 (when (gnus-retrieve-headers sequence group)
4832 (gnus-get-newsgroup-headers))))))))
4834 (defun gnus-article-get-xrefs ()
4835 "Fill in the Xref value in `gnus-current-headers', if necessary.
4836 This is meant to be called in `gnus-article-internal-prepare-hook'."
4837 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4838 gnus-current-headers)))
4839 (or (not gnus-use-cross-reference)
4841 (and (mail-header-xref headers)
4842 (not (string= (mail-header-xref headers) "")))
4843 (let ((case-fold-search t)
4846 (nnheader-narrow-to-headers)
4847 (goto-char (point-min))
4848 (when (or (and (not (eobp))
4849 (eq (downcase (char-after)) ?x)
4850 (looking-at "Xref:"))
4851 (search-forward "\nXref:" nil t))
4852 (goto-char (1+ (match-end 0)))
4853 (setq xref (buffer-substring (point)
4854 (progn (end-of-line) (point))))
4855 (mail-header-set-xref headers xref)))))))
4857 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4858 "Find article ID and insert the summary line for that article.
4859 OLD-HEADER can either be a header or a line number to insert
4860 the subject line on."
4861 (let* ((line (and (numberp old-header) old-header))
4862 (old-header (and (vectorp old-header) old-header))
4863 (header (cond ((and old-header use-old-header)
4866 (gnus-number-to-header id))
4867 (gnus-number-to-header id))
4869 (gnus-read-header id))))
4870 (number (and (numberp id) id))
4873 ;; Rebuild the thread that this article is part of and go to the
4874 ;; article we have fetched.
4875 (when (and (not gnus-show-threads)
4878 (setq d (gnus-data-find (mail-header-number old-header))))
4879 (goto-char (gnus-data-pos d))
4882 (- (gnus-point-at-bol)
4884 (1+ (gnus-point-at-eol))
4885 (gnus-delete-line))))))
4887 (mail-header-set-number header (mail-header-number old-header)))
4888 (setq gnus-newsgroup-sparse
4889 (delq (setq number (mail-header-number header))
4890 gnus-newsgroup-sparse))
4891 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4892 (push number gnus-newsgroup-limit)
4893 (gnus-rebuild-thread (mail-header-id header) line)
4894 (gnus-summary-goto-subject number nil t))
4895 (when (and (numberp number)
4897 ;; We have to update the boundaries even if we can't fetch the
4898 ;; article if ID is a number -- so that the next `P' or `N'
4899 ;; command will fetch the previous (or next) article even
4900 ;; if the one we tried to fetch this time has been canceled.
4901 (when (> number gnus-newsgroup-end)
4902 (setq gnus-newsgroup-end number))
4903 (when (< number gnus-newsgroup-begin)
4904 (setq gnus-newsgroup-begin number))
4905 (setq gnus-newsgroup-unselected
4906 (delq number gnus-newsgroup-unselected)))
4907 ;; Report back a success?
4908 (and header (mail-header-number header))))
4910 ;;; Process/prefix in the summary buffer
4912 (defun gnus-summary-work-articles (n)
4913 "Return a list of articles to be worked upon.
4914 The prefix argument, the list of process marked articles, and the
4915 current article will be taken into consideration."
4917 (set-buffer gnus-summary-buffer)
4920 ;; A numerical prefix has been given.
4921 (setq n (prefix-numeric-value n))
4922 (let ((backward (< n 0))
4923 (n (abs (prefix-numeric-value n)))
4928 (push (setq article (gnus-summary-article-number))
4931 (gnus-summary-find-prev nil article)
4932 (gnus-summary-find-next nil article)))
4934 (nreverse articles)))
4935 ((and (gnus-region-active-p) (mark))
4936 (message "region active")
4937 ;; Work on the region between point and mark.
4938 (let ((max (max (point) (mark)))
4941 (goto-char (min (min (point) (mark))))
4944 (push (setq article (gnus-summary-article-number)) articles)
4945 (gnus-summary-find-next nil article)
4947 (nreverse articles))))
4948 (gnus-newsgroup-processable
4949 ;; There are process-marked articles present.
4950 ;; Save current state.
4951 (gnus-summary-save-process-mark)
4953 (reverse gnus-newsgroup-processable))
4955 ;; Just return the current article.
4956 (list (gnus-summary-article-number))))))
4958 (defmacro gnus-summary-iterate (arg &rest forms)
4959 "Iterate over the process/prefixed articles and do FORMS.
4960 ARG is the interactive prefix given to the command. FORMS will be
4961 executed with point over the summary line of the articles."
4962 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
4963 `(let ((,articles (gnus-summary-work-articles ,arg)))
4965 (gnus-summary-goto-subject (car ,articles))
4969 (put 'gnus-summary-iterate 'lisp-indent-function 1)
4970 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
4972 (defun gnus-summary-save-process-mark ()
4973 "Push the current set of process marked articles on the stack."
4975 (push (copy-sequence gnus-newsgroup-processable)
4976 gnus-newsgroup-process-stack))
4978 (defun gnus-summary-kill-process-mark ()
4979 "Push the current set of process marked articles on the stack and unmark."
4981 (gnus-summary-save-process-mark)
4982 (gnus-summary-unmark-all-processable))
4984 (defun gnus-summary-yank-process-mark ()
4985 "Pop the last process mark state off the stack and restore it."
4987 (unless gnus-newsgroup-process-stack
4988 (error "Empty mark stack"))
4989 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4991 (defun gnus-summary-process-mark-set (set)
4992 "Make SET into the current process marked articles."
4993 (gnus-summary-unmark-all-processable)
4995 (gnus-summary-set-process-mark (pop set))))
4997 ;;; Searching and stuff
4999 (defun gnus-summary-search-group (&optional backward use-level)
5000 "Search for next unread newsgroup.
5001 If optional argument BACKWARD is non-nil, search backward instead."
5003 (set-buffer gnus-group-buffer)
5004 (when (gnus-group-search-forward
5005 backward nil (if use-level (gnus-group-group-level) nil))
5006 (gnus-group-group-name))))
5008 (defun gnus-summary-best-group (&optional exclude-group)
5009 "Find the name of the best unread group.
5010 If EXCLUDE-GROUP, do not go to this group."
5012 (set-buffer gnus-group-buffer)
5014 (gnus-group-best-unread-group exclude-group))))
5016 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5017 (if backward (gnus-summary-find-prev)
5018 (let* ((dummy (gnus-summary-article-intangible-p))
5019 (article (or article (gnus-summary-article-number)))
5020 (arts (gnus-data-find-list article))
5022 (when (and (not dummy)
5023 (or (not gnus-summary-check-current)
5025 (not (gnus-data-unread-p (car arts)))))
5026 (setq arts (cdr arts)))
5031 (when (or (and undownloaded
5032 (eq gnus-undownloaded-mark
5033 (gnus-data-mark (car arts))))
5034 (gnus-data-unread-p (car arts)))
5035 (setq result (car arts)
5037 (setq arts (cdr arts)))
5040 (goto-char (gnus-data-pos result))
5041 (gnus-data-number result)))))
5043 (defun gnus-summary-find-prev (&optional unread article)
5044 (let* ((eobp (eobp))
5045 (article (or article (gnus-summary-article-number)))
5046 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5048 (when (and (not eobp)
5049 (or (not gnus-summary-check-current)
5051 (not (gnus-data-unread-p (car arts)))))
5052 (setq arts (cdr arts)))
5057 (when (gnus-data-unread-p (car arts))
5058 (setq result (car arts)
5060 (setq arts (cdr arts)))
5063 (goto-char (gnus-data-pos result))
5064 (gnus-data-number result))))
5066 (defun gnus-summary-find-subject (subject &optional unread backward article)
5067 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5068 (article (or article (gnus-summary-article-number)))
5069 (articles (gnus-data-list backward))
5070 (arts (gnus-data-find-list article articles))
5072 (when (or (not gnus-summary-check-current)
5074 (not (gnus-data-unread-p (car arts))))
5075 (setq arts (cdr arts)))
5077 (and (or (not unread)
5078 (gnus-data-unread-p (car arts)))
5079 (vectorp (gnus-data-header (car arts)))
5081 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5082 (setq result (car arts)
5084 (setq arts (cdr arts)))
5086 (goto-char (gnus-data-pos result))
5087 (gnus-data-number result))))
5089 (defun gnus-summary-search-forward (&optional unread subject backward)
5090 "Search forward for an article.
5091 If UNREAD, look for unread articles. If SUBJECT, look for
5092 articles with that subject. If BACKWARD, search backward instead."
5093 (cond (subject (gnus-summary-find-subject subject unread backward))
5094 (backward (gnus-summary-find-prev unread))
5095 (t (gnus-summary-find-next unread))))
5097 (defun gnus-recenter (&optional n)
5098 "Center point in window and redisplay frame.
5099 Also do horizontal recentering."
5101 (when (and gnus-auto-center-summary
5102 (not (eq gnus-auto-center-summary 'vertical)))
5103 (gnus-horizontal-recenter))
5106 (defun gnus-summary-recenter ()
5107 "Center point in the summary window.
5108 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5109 displayed, no centering will be performed."
5110 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5111 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5112 (let* ((top (cond ((< (window-height) 4) 0)
5113 ((< (window-height) 7) 1)
5114 (t (if (numberp gnus-auto-center-summary)
5115 gnus-auto-center-summary
5117 (height (1- (window-height)))
5118 (bottom (save-excursion (goto-char (point-max))
5119 (forward-line (- height))
5121 (window (get-buffer-window (current-buffer))))
5122 ;; The user has to want it.
5123 (when gnus-auto-center-summary
5124 (when (get-buffer-window gnus-article-buffer)
5125 ;; Only do recentering when the article buffer is displayed,
5126 ;; Set the window start to either `bottom', which is the biggest
5127 ;; possible valid number, or the second line from the top,
5128 ;; whichever is the least.
5130 window (min bottom (save-excursion
5131 (forward-line (- top)) (point)))
5133 ;; Do horizontal recentering while we're at it.
5134 (when (and (get-buffer-window (current-buffer) t)
5135 (not (eq gnus-auto-center-summary 'vertical)))
5136 (let ((selected (selected-window)))
5137 (select-window (get-buffer-window (current-buffer) t))
5138 (gnus-summary-position-point)
5139 (gnus-horizontal-recenter)
5140 (select-window selected))))))
5142 (defun gnus-summary-jump-to-group (newsgroup)
5143 "Move point to NEWSGROUP in group mode buffer."
5144 ;; Keep update point of group mode buffer if visible.
5145 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5146 (save-window-excursion
5147 ;; Take care of tree window mode.
5148 (when (get-buffer-window gnus-group-buffer)
5149 (pop-to-buffer gnus-group-buffer))
5150 (gnus-group-jump-to-group newsgroup))
5152 ;; Take care of tree window mode.
5153 (if (get-buffer-window gnus-group-buffer)
5154 (pop-to-buffer gnus-group-buffer)
5155 (set-buffer gnus-group-buffer))
5156 (gnus-group-jump-to-group newsgroup))))
5158 ;; This function returns a list of article numbers based on the
5159 ;; difference between the ranges of read articles in this group and
5160 ;; the range of active articles.
5161 (defun gnus-list-of-unread-articles (group)
5162 (let* ((read (gnus-info-read (gnus-get-info group)))
5163 (active (or (gnus-active group) (gnus-activate-group group)))
5166 ;; If none are read, then all are unread.
5168 (setq first (car active))
5169 ;; If the range of read articles is a single range, then the
5170 ;; first unread article is the article after the last read
5171 ;; article. Sounds logical, doesn't it?
5172 (if (and (not (listp (cdr read)))
5173 (or (< (car read) (car active))
5174 (progn (setq read (list read))
5176 (setq first (max (car active) (1+ (cdr read))))
5177 ;; `read' is a list of ranges.
5178 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5181 (setq first (car active)))
5184 (while (< first nlast)
5186 (setq first (1+ first))))
5187 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5188 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5189 (setq read (cdr read)))))
5190 ;; And add the last unread articles.
5191 (while (<= first last)
5193 (setq first (1+ first)))
5194 ;; Return the list of unread articles.
5195 (delq 0 (nreverse unread))))
5197 (defun gnus-list-of-read-articles (group)
5198 "Return a list of unread, unticked and non-dormant articles."
5199 (let* ((info (gnus-get-info group))
5200 (marked (gnus-info-marks info))
5201 (active (gnus-active group)))
5203 (gnus-set-difference
5204 (gnus-sorted-complement
5205 (gnus-uncompress-range active)
5206 (gnus-list-of-unread-articles group))
5208 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5209 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5211 ;; Various summary commands
5213 (defun gnus-summary-select-article-buffer ()
5214 "Reconfigure windows to show article buffer."
5216 (if (not (gnus-buffer-live-p gnus-article-buffer))
5217 (error "There is no article buffer for this summary buffer")
5218 (gnus-configure-windows 'article)
5219 (select-window (get-buffer-window gnus-article-buffer))))
5221 (defun gnus-summary-universal-argument (arg)
5222 "Perform any operation on all articles that are process/prefixed."
5224 (let ((articles (gnus-summary-work-articles arg))
5231 (substitute-command-keys
5232 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
5234 (gnus-error 1 "Undefined key")
5237 (gnus-summary-goto-subject (setq article (pop articles)))
5238 (let (gnus-newsgroup-processable)
5239 (command-execute func))
5240 (gnus-summary-remove-process-mark article)))))
5241 (gnus-summary-position-point))
5243 (defun gnus-summary-toggle-truncation (&optional arg)
5244 "Toggle truncation of summary lines.
5245 With arg, turn line truncation on iff arg is positive."
5247 (setq truncate-lines
5248 (if (null arg) (not truncate-lines)
5249 (> (prefix-numeric-value arg) 0)))
5252 (defun gnus-summary-reselect-current-group (&optional all rescan)
5253 "Exit and then reselect the current newsgroup.
5254 The prefix argument ALL means to select all articles."
5256 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5257 (error "Ephemeral groups can't be reselected"))
5258 (let ((current-subject (gnus-summary-article-number))
5259 (group gnus-newsgroup-name))
5260 (setq gnus-newsgroup-begin nil)
5262 ;; We have to adjust the point of group mode buffer because
5263 ;; point was moved to the next unread newsgroup by exiting.
5264 (gnus-summary-jump-to-group group)
5267 (gnus-group-get-new-news-this-group 1)))
5268 (gnus-group-read-group all t)
5269 (gnus-summary-goto-subject current-subject nil t)))
5271 (defun gnus-summary-rescan-group (&optional all)
5272 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5274 (gnus-summary-reselect-current-group all t))
5276 (defun gnus-summary-update-info (&optional non-destructive)
5278 (let ((group gnus-newsgroup-name))
5280 (when gnus-newsgroup-kill-headers
5281 (setq gnus-newsgroup-killed
5282 (gnus-compress-sequence
5284 (gnus-set-sorted-intersection
5285 (gnus-uncompress-range gnus-newsgroup-killed)
5286 (setq gnus-newsgroup-unselected
5287 (sort gnus-newsgroup-unselected '<)))
5288 (setq gnus-newsgroup-unreads
5289 (sort gnus-newsgroup-unreads '<)))
5291 (unless (listp (cdr gnus-newsgroup-killed))
5292 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5293 (let ((headers gnus-newsgroup-headers))
5294 ;; Set the new ranges of read articles.
5296 (set-buffer gnus-group-buffer)
5297 (gnus-undo-force-boundary))
5298 (gnus-update-read-articles
5299 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5300 ;; Set the current article marks.
5301 (let ((gnus-newsgroup-scored
5302 (if (and (not gnus-save-score)
5303 (not non-destructive))
5305 gnus-newsgroup-scored)))
5307 (gnus-update-marks)))
5308 ;; Do the cross-ref thing.
5309 (when gnus-use-cross-reference
5310 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5311 ;; Do not switch windows but change the buffer to work.
5312 (set-buffer gnus-group-buffer)
5313 (unless (gnus-ephemeral-group-p group)
5314 (gnus-group-update-group group)))))))
5316 (defun gnus-summary-save-newsrc (&optional force)
5317 "Save the current number of read/marked articles in the dribble buffer.
5318 The dribble buffer will then be saved.
5319 If FORCE (the prefix), also save the .newsrc file(s)."
5321 (gnus-summary-update-info t)
5323 (gnus-save-newsrc-file)
5324 (gnus-dribble-save)))
5326 (defun gnus-summary-exit (&optional temporary)
5327 "Exit reading current newsgroup, and then return to group selection mode.
5328 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
5330 (gnus-set-global-variables)
5331 (when (gnus-buffer-live-p gnus-article-buffer)
5333 (set-buffer gnus-article-buffer)
5334 (mm-destroy-parts gnus-article-mime-handles)))
5335 (gnus-kill-save-kill-buffer)
5336 (gnus-async-halt-prefetch)
5337 (let* ((group gnus-newsgroup-name)
5338 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5341 (buf (current-buffer)))
5343 ;; Do adaptive scoring, and possibly save score files.
5344 (when gnus-newsgroup-adaptive
5345 (gnus-score-adaptive))
5346 (when gnus-use-scoring
5348 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5349 ;; If we have several article buffers, we kill them at exit.
5350 (unless gnus-single-article-buffer
5351 (gnus-kill-buffer gnus-original-article-buffer)
5352 (setq gnus-article-current nil))
5353 (when gnus-use-cache
5354 (gnus-cache-possibly-remove-articles)
5355 (gnus-cache-save-buffers))
5356 (gnus-async-prefetch-remove-group group)
5357 (when gnus-suppress-duplicates
5358 (gnus-dup-enter-articles))
5359 (when gnus-use-trees
5360 (gnus-tree-close group))
5361 (when gnus-use-cache
5362 (gnus-cache-write-active))
5363 ;; Remove entries for this group.
5364 (nnmail-purge-split-history (gnus-group-real-name group))
5365 ;; Make all changes in this group permanent.
5367 (gnus-run-hooks 'gnus-exit-group-hook)
5368 (gnus-summary-update-info))
5369 (gnus-close-group group)
5370 ;; Make sure where we were, and go to next newsgroup.
5371 (set-buffer gnus-group-buffer)
5373 (gnus-group-jump-to-group group))
5374 (gnus-run-hooks 'gnus-summary-exit-hook)
5375 (unless (or quit-config
5376 ;; If this group has disappeared from the summary
5377 ;; buffer, don't skip forwards.
5378 (not (string= group (gnus-group-group-name))))
5379 (gnus-group-next-unread-group 1))
5380 (setq group-point (point))
5383 ;; If we have several article buffers, we kill them at exit.
5384 (unless gnus-single-article-buffer
5385 (gnus-kill-buffer gnus-article-buffer)
5386 (gnus-kill-buffer gnus-original-article-buffer)
5387 (setq gnus-article-current nil))
5389 (if (not gnus-kill-summary-on-exit)
5390 (gnus-deaden-summary)
5391 ;; We set all buffer-local variables to nil. It is unclear why
5392 ;; this is needed, but if we don't, buffer-local variables are
5393 ;; not garbage-collected, it seems. This would the lead to en
5394 ;; ever-growing Emacs.
5395 (gnus-summary-clear-local-variables)
5396 (when (get-buffer gnus-article-buffer)
5397 (bury-buffer gnus-article-buffer))
5398 ;; We clear the global counterparts of the buffer-local
5399 ;; variables as well, just to be on the safe side.
5400 (set-buffer gnus-group-buffer)
5401 (gnus-summary-clear-local-variables)
5402 ;; Return to group mode buffer.
5403 (when (eq mode 'gnus-summary-mode)
5404 (gnus-kill-buffer buf)))
5405 (setq gnus-current-select-method gnus-select-method)
5406 (pop-to-buffer gnus-group-buffer)
5407 (if (not quit-config)
5409 (goto-char group-point)
5410 (gnus-configure-windows 'group 'force))
5411 (gnus-handle-ephemeral-exit quit-config))
5412 ;; Clear the current group name.
5414 (setq gnus-newsgroup-name nil)))))
5416 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5417 (defun gnus-summary-exit-no-update (&optional no-questions)
5418 "Quit reading current newsgroup without updating read article info."
5420 (let* ((group gnus-newsgroup-name)
5421 (quit-config (gnus-group-quit-config group)))
5422 (when (or no-questions
5424 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5425 (gnus-async-halt-prefetch)
5427 (delq 'gnus-summary-expire-articles
5428 (copy-sequence gnus-summary-prepare-exit-hook)))
5429 (when (gnus-buffer-live-p gnus-article-buffer)
5431 (set-buffer gnus-article-buffer)
5432 (mm-destroy-parts gnus-article-mime-handles)))
5433 ;; If we have several article buffers, we kill them at exit.
5434 (unless gnus-single-article-buffer
5435 (gnus-kill-buffer gnus-article-buffer)
5436 (gnus-kill-buffer gnus-original-article-buffer)
5437 (setq gnus-article-current nil))
5438 (if (not gnus-kill-summary-on-exit)
5439 (gnus-deaden-summary)
5440 (gnus-close-group group)
5441 (gnus-summary-clear-local-variables)
5442 (set-buffer gnus-group-buffer)
5443 (gnus-summary-clear-local-variables)
5444 (when (get-buffer gnus-summary-buffer)
5445 (kill-buffer gnus-summary-buffer)))
5446 (unless gnus-single-article-buffer
5447 (setq gnus-article-current nil))
5448 (when gnus-use-trees
5449 (gnus-tree-close group))
5450 (gnus-async-prefetch-remove-group group)
5451 (when (get-buffer gnus-article-buffer)
5452 (bury-buffer gnus-article-buffer))
5453 ;; Return to the group buffer.
5454 (gnus-configure-windows 'group 'force)
5455 ;; Clear the current group name.
5456 (setq gnus-newsgroup-name nil)
5457 (when (equal (gnus-group-group-name) group)
5458 (gnus-group-next-unread-group 1))
5460 (gnus-handle-ephemeral-exit quit-config)))))
5462 (defun gnus-handle-ephemeral-exit (quit-config)
5463 "Handle movement when leaving an ephemeral group.
5464 The state which existed when entering the ephemeral is reset."
5465 (if (not (buffer-name (car quit-config)))
5466 (gnus-configure-windows 'group 'force)
5467 (set-buffer (car quit-config))
5468 (cond ((eq major-mode 'gnus-summary-mode)
5469 (gnus-set-global-variables))
5470 ((eq major-mode 'gnus-article-mode)
5472 ;; The `gnus-summary-buffer' variable may point
5473 ;; to the old summary buffer when using a single
5475 (unless (gnus-buffer-live-p gnus-summary-buffer)
5476 (set-buffer gnus-group-buffer))
5477 (set-buffer gnus-summary-buffer)
5478 (gnus-set-global-variables))))
5479 (if (or (eq (cdr quit-config) 'article)
5480 (eq (cdr quit-config) 'pick))
5482 ;; The current article may be from the ephemeral group
5483 ;; thus it is best that we reload this article
5484 (gnus-summary-show-article)
5485 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5486 (gnus-configure-windows 'pick 'force)
5487 (gnus-configure-windows (cdr quit-config) 'force)))
5488 (gnus-configure-windows (cdr quit-config) 'force))
5489 (when (eq major-mode 'gnus-summary-mode)
5490 (gnus-summary-next-subject 1 nil t)
5491 (gnus-summary-recenter)
5492 (gnus-summary-position-point))))
5496 (defvar gnus-dead-summary-mode-map nil)
5498 (unless gnus-dead-summary-mode-map
5499 (setq gnus-dead-summary-mode-map (make-keymap))
5500 (suppress-keymap gnus-dead-summary-mode-map)
5501 (substitute-key-definition
5502 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5503 (let ((keys '("\C-d" "\r" "\177" [delete])))
5505 (define-key gnus-dead-summary-mode-map
5506 (pop keys) 'gnus-summary-wake-up-the-dead))))
5508 (defvar gnus-dead-summary-mode nil
5509 "Minor mode for Gnus summary buffers.")
5511 (defun gnus-dead-summary-mode (&optional arg)
5512 "Minor mode for Gnus summary buffers."
5514 (when (eq major-mode 'gnus-summary-mode)
5515 (make-local-variable 'gnus-dead-summary-mode)
5516 (setq gnus-dead-summary-mode
5517 (if (null arg) (not gnus-dead-summary-mode)
5518 (> (prefix-numeric-value arg) 0)))
5519 (when gnus-dead-summary-mode
5520 (gnus-add-minor-mode
5521 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5523 (defun gnus-deaden-summary ()
5524 "Make the current summary buffer into a dead summary buffer."
5525 ;; Kill any previous dead summary buffer.
5526 (when (and gnus-dead-summary
5527 (buffer-name gnus-dead-summary))
5529 (set-buffer gnus-dead-summary)
5530 (when gnus-dead-summary-mode
5531 (kill-buffer (current-buffer)))))
5532 ;; Make this the current dead summary.
5533 (setq gnus-dead-summary (current-buffer))
5534 (gnus-dead-summary-mode 1)
5535 (let ((name (buffer-name)))
5536 (when (string-match "Summary" name)
5538 (concat (substring name 0 (match-beginning 0)) "Dead "
5539 (substring name (match-beginning 0)))
5542 (defun gnus-kill-or-deaden-summary (buffer)
5543 "Kill or deaden the summary BUFFER."
5545 (when (and (buffer-name buffer)
5546 (not gnus-single-article-buffer))
5549 (gnus-kill-buffer gnus-article-buffer)
5550 (gnus-kill-buffer gnus-original-article-buffer)))
5551 (cond (gnus-kill-summary-on-exit
5552 (when (and gnus-use-trees
5553 (gnus-buffer-exists-p buffer))
5556 (gnus-tree-close gnus-newsgroup-name)))
5557 (gnus-kill-buffer buffer))
5558 ((gnus-buffer-exists-p buffer)
5561 (gnus-deaden-summary))))))
5563 (defun gnus-summary-wake-up-the-dead (&rest args)
5564 "Wake up the dead summary buffer."
5566 (gnus-dead-summary-mode -1)
5567 (let ((name (buffer-name)))
5568 (when (string-match "Dead " name)
5570 (concat (substring name 0 (match-beginning 0))
5571 (substring name (match-end 0)))
5573 (gnus-message 3 "This dead summary is now alive again"))
5575 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5576 (defun gnus-summary-fetch-faq (&optional faq-dir)
5577 "Fetch the FAQ for the current group.
5578 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5582 (when current-prefix-arg
5584 "Faq dir: " (and (listp gnus-group-faq-directory)
5585 (mapcar (lambda (file) (list file))
5586 gnus-group-faq-directory))))))
5587 (let (gnus-faq-buffer)
5588 (when (setq gnus-faq-buffer
5589 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5590 (gnus-configure-windows 'summary-faq))))
5592 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5593 (defun gnus-summary-describe-group (&optional force)
5594 "Describe the current newsgroup."
5596 (gnus-group-describe-group force gnus-newsgroup-name))
5598 (defun gnus-summary-describe-briefly ()
5599 "Describe summary mode commands briefly."
5601 (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")))
5603 ;; Walking around group mode buffer from summary mode.
5605 (defun gnus-summary-next-group (&optional no-article target-group backward)
5606 "Exit current newsgroup and then select next unread newsgroup.
5607 If prefix argument NO-ARTICLE is non-nil, no article is selected
5608 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5609 previous group instead."
5611 ;; Stop pre-fetching.
5612 (gnus-async-halt-prefetch)
5613 (let ((current-group gnus-newsgroup-name)
5614 (current-buffer (current-buffer))
5616 ;; First we semi-exit this group to update Xrefs and all variables.
5617 ;; We can't do a real exit, because the window conf must remain
5618 ;; the same in case the user is prompted for info, and we don't
5619 ;; want the window conf to change before that...
5620 (gnus-summary-exit t)
5621 (while (not entered)
5622 ;; Then we find what group we are supposed to enter.
5623 (set-buffer gnus-group-buffer)
5624 (gnus-group-jump-to-group current-group)
5627 (if (eq gnus-keep-same-level 'best)
5628 (gnus-summary-best-group gnus-newsgroup-name)
5629 (gnus-summary-search-group backward gnus-keep-same-level))))
5630 (if (not target-group)
5631 ;; There are no further groups, so we return to the group
5634 (gnus-message 5 "Returning to the group buffer")
5636 (when (gnus-buffer-live-p current-buffer)
5637 (set-buffer current-buffer)
5638 (gnus-summary-exit))
5639 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5640 ;; We try to enter the target group.
5641 (gnus-group-jump-to-group target-group)
5642 (let ((unreads (gnus-group-group-unread)))
5643 (if (and (or (eq t unreads)
5644 (and unreads (not (zerop unreads))))
5645 (gnus-summary-read-group
5646 target-group nil no-article
5647 (and (buffer-name current-buffer) current-buffer)
5650 (setq current-group target-group
5651 target-group nil)))))))
5653 (defun gnus-summary-prev-group (&optional no-article)
5654 "Exit current newsgroup and then select previous unread newsgroup.
5655 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5657 (gnus-summary-next-group no-article nil t))
5659 ;; Walking around summary lines.
5661 (defun gnus-summary-first-subject (&optional unread undownloaded)
5662 "Go to the first unread subject.
5663 If UNREAD is non-nil, go to the first unread article.
5664 Returns the article selected or nil if there are no unread articles."
5669 ((null gnus-newsgroup-data)
5670 (gnus-message 3 "No articles in the group")
5672 ;; Pick the first article.
5674 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5675 (gnus-data-number (car gnus-newsgroup-data)))
5676 ;; No unread articles.
5677 ((null gnus-newsgroup-unreads)
5678 (gnus-message 3 "No more unread articles")
5680 ;; Find the first unread article.
5682 (let ((data gnus-newsgroup-data))
5684 (and (not (and undownloaded
5685 (eq gnus-undownloaded-mark
5686 (gnus-data-mark (car data)))))
5687 (not (gnus-data-unread-p (car data)))))
5688 (setq data (cdr data)))
5690 (goto-char (gnus-data-pos (car data)))
5691 (gnus-data-number (car data))))))
5692 (gnus-summary-position-point)))
5694 (defun gnus-summary-next-subject (n &optional unread dont-display)
5695 "Go to next N'th summary line.
5696 If N is negative, go to the previous N'th subject line.
5697 If UNREAD is non-nil, only unread articles are selected.
5698 The difference between N and the actual number of steps taken is
5701 (let ((backward (< n 0))
5705 (gnus-summary-find-prev unread)
5706 (gnus-summary-find-next unread)))
5707 (unless (zerop (setq n (1- n)))
5708 (gnus-summary-show-thread)))
5710 (gnus-message 7 "No more%s articles"
5711 (if unread " unread" "")))
5712 (unless dont-display
5713 (gnus-summary-recenter)
5714 (gnus-summary-position-point))
5717 (defun gnus-summary-next-unread-subject (n)
5718 "Go to next N'th unread summary line."
5720 (gnus-summary-next-subject n t))
5722 (defun gnus-summary-prev-subject (n &optional unread)
5723 "Go to previous N'th summary line.
5724 If optional argument UNREAD is non-nil, only unread article is selected."
5726 (gnus-summary-next-subject (- n) unread))
5728 (defun gnus-summary-prev-unread-subject (n)
5729 "Go to previous N'th unread summary line."
5731 (gnus-summary-next-subject (- n) t))
5733 (defun gnus-summary-goto-subject (article &optional force silent)
5734 "Go the subject line of ARTICLE.
5735 If FORCE, also allow jumping to articles not currently shown."
5736 (interactive "nArticle number: ")
5738 (data (gnus-data-find article)))
5739 ;; We read in the article if we have to.
5742 (gnus-summary-insert-subject
5744 (if (or (numberp force) (vectorp force)) force)
5746 (setq data (gnus-data-find article)))
5751 (gnus-message 3 "Can't find article %d" article))
5753 (goto-char (gnus-data-pos data))
5754 (gnus-summary-position-point)
5757 ;; Walking around summary lines with displaying articles.
5759 (defun gnus-summary-expand-window (&optional arg)
5760 "Make the summary buffer take up the entire Emacs frame.
5761 Given a prefix, will force an `article' buffer configuration."
5764 (gnus-configure-windows 'article 'force)
5765 (gnus-configure-windows 'summary 'force)))
5767 (defun gnus-summary-display-article (article &optional all-header)
5768 "Display ARTICLE in article buffer."
5769 (gnus-set-global-variables)
5773 (if gnus-summary-display-article-function
5774 (funcall gnus-summary-display-article-function article all-header)
5775 (gnus-article-prepare article all-header))
5776 (gnus-run-hooks 'gnus-select-article-hook)
5777 (when (and gnus-current-article
5778 (not (zerop gnus-current-article)))
5779 (gnus-summary-goto-subject gnus-current-article))
5780 (gnus-summary-recenter)
5781 (when (and gnus-use-trees gnus-show-threads)
5782 (gnus-possibly-generate-tree article)
5783 (gnus-highlight-selected-tree article))
5784 ;; Successfully display article.
5785 (gnus-article-set-window-start
5786 (cdr (assq article gnus-newsgroup-bookmarks))))))
5788 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5789 "Select the current article.
5790 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5791 non-nil, the article will be re-fetched even if it already present in
5792 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5794 ;; Make sure we are in the summary buffer to work around bbdb bug.
5795 (unless (eq major-mode 'gnus-summary-mode)
5796 (set-buffer gnus-summary-buffer))
5797 (let ((article (or article (gnus-summary-article-number)))
5798 (all-headers (not (not all-headers))) ;Must be T or NIL.
5799 gnus-summary-display-article-function)
5801 (gnus-summary-article-pseudo-p article)
5802 (error "This is a pseudo-article"))
5804 (set-buffer gnus-summary-buffer)
5805 (if (or (and gnus-single-article-buffer
5806 (or (null gnus-current-article)
5807 (null gnus-article-current)
5808 (null (get-buffer gnus-article-buffer))
5809 (not (eq article (cdr gnus-article-current)))
5810 (not (equal (car gnus-article-current)
5811 gnus-newsgroup-name))))
5812 (and (not gnus-single-article-buffer)
5813 (or (null gnus-current-article)
5814 (not (eq gnus-current-article article))))
5816 ;; The requested article is different from the current article.
5818 (gnus-summary-display-article article all-headers)
5819 (when (or all-headers gnus-show-all-headers)
5820 (gnus-article-show-all-headers))
5821 (gnus-article-set-window-start
5822 (cdr (assq article gnus-newsgroup-bookmarks)))
5824 (when (or all-headers gnus-show-all-headers)
5825 (gnus-article-show-all-headers))
5828 (defun gnus-summary-set-current-mark (&optional current-mark)
5829 "Obsolete function."
5832 (defun gnus-summary-next-article (&optional unread subject backward push)
5833 "Select the next article.
5834 If UNREAD, only unread articles are selected.
5835 If SUBJECT, only articles with SUBJECT are selected.
5836 If BACKWARD, the previous article is selected instead of the next."
5839 ;; Is there such an article?
5840 ((and (gnus-summary-search-forward unread subject backward)
5841 (or (gnus-summary-display-article (gnus-summary-article-number))
5842 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5843 (gnus-summary-position-point))
5844 ;; If not, we try the first unread, if that is wanted.
5846 gnus-auto-select-same
5847 (gnus-summary-first-unread-article))
5848 (gnus-summary-position-point)
5849 (gnus-message 6 "Wrapped"))
5850 ;; Try to get next/previous article not displayed in this group.
5851 ((and gnus-auto-extend-newsgroup
5852 (not unread) (not subject))
5853 (gnus-summary-goto-article
5854 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5855 nil (count-lines (point-min) (point))))
5856 ;; Go to next/previous group.
5858 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5859 (gnus-summary-jump-to-group gnus-newsgroup-name))
5860 (let ((cmd last-command-char)
5863 (set-buffer gnus-group-buffer)
5866 (if (eq gnus-keep-same-level 'best)
5867 (gnus-summary-best-group gnus-newsgroup-name)
5868 (gnus-summary-search-group backward gnus-keep-same-level))))
5869 ;; For some reason, the group window gets selected. We change
5871 (select-window (get-buffer-window (current-buffer)))
5872 ;; Select next unread newsgroup automagically.
5874 ((or (not gnus-auto-select-next)
5876 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5877 ((or (eq gnus-auto-select-next 'quietly)
5878 (and (eq gnus-auto-select-next 'slightly-quietly)
5880 (and (eq gnus-auto-select-next 'almost-quietly)
5881 (gnus-summary-last-article-p)))
5883 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5885 (gnus-message 7 "No more%s articles (%s)..."
5886 (if unread " unread" "")
5887 (if group (concat "selecting " group)
5889 (gnus-summary-next-group nil group backward)))
5891 (when (gnus-key-press-event-p last-input-event)
5892 (gnus-summary-walk-group-buffer
5893 gnus-newsgroup-name cmd unread backward point))))))))
5895 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5896 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5897 (?\C-p (gnus-group-prev-unread-group 1))))
5898 (cursor-in-echo-area t)
5899 keve key group ended)
5901 (set-buffer gnus-group-buffer)
5904 (if (eq gnus-keep-same-level 'best)
5905 (gnus-summary-best-group gnus-newsgroup-name)
5906 (gnus-summary-search-group backward gnus-keep-same-level))))
5909 5 "No more%s articles%s" (if unread " unread" "")
5911 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5912 (format " (Type %s for %s [%s])"
5913 (single-key-description cmd) group
5914 (car (gnus-gethash group gnus-newsrc-hashtb)))
5915 (format " (Type %s to exit %s)"
5916 (single-key-description cmd)
5917 gnus-newsgroup-name)))
5918 ;; Confirm auto selection.
5919 (setq key (car (setq keve (gnus-read-event-char))))
5922 ((assq key keystrokes)
5923 (let ((obuf (current-buffer)))
5924 (switch-to-buffer gnus-group-buffer)
5926 (gnus-group-jump-to-group group))
5927 (eval (cadr (assq key keystrokes)))
5928 (setq group (gnus-group-group-name))
5929 (switch-to-buffer obuf))
5933 (gnus-ephemeral-group-p gnus-newsgroup-name))
5935 (gnus-summary-next-group nil group backward)))
5937 (push (cdr keve) unread-command-events))))))
5939 (defun gnus-summary-next-unread-article ()
5940 "Select unread article after current one."
5942 (gnus-summary-next-article
5943 (or (not (eq gnus-summary-goto-unread 'never))
5944 (gnus-summary-last-article-p (gnus-summary-article-number)))
5945 (and gnus-auto-select-same
5946 (gnus-summary-article-subject))))
5948 (defun gnus-summary-prev-article (&optional unread subject)
5949 "Select the article after the current one.
5950 If UNREAD is non-nil, only unread articles are selected."
5952 (gnus-summary-next-article unread subject t))
5954 (defun gnus-summary-prev-unread-article ()
5955 "Select unread article before current one."
5957 (gnus-summary-prev-article
5958 (or (not (eq gnus-summary-goto-unread 'never))
5959 (gnus-summary-first-article-p (gnus-summary-article-number)))
5960 (and gnus-auto-select-same
5961 (gnus-summary-article-subject))))
5963 (defun gnus-summary-next-page (&optional lines circular)
5964 "Show next page of the selected article.
5965 If at the end of the current article, select the next article.
5966 LINES says how many lines should be scrolled up.
5968 If CIRCULAR is non-nil, go to the start of the article instead of
5969 selecting the next article when reaching the end of the current
5972 (setq gnus-summary-buffer (current-buffer))
5973 (gnus-set-global-variables)
5974 (let ((article (gnus-summary-article-number))
5975 (article-window (get-buffer-window gnus-article-buffer t))
5977 ;; If the buffer is empty, we have no article.
5979 (error "No article to select"))
5980 (gnus-configure-windows 'article)
5981 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
5982 (if (and (eq gnus-summary-goto-unread 'never)
5983 (not (gnus-summary-last-article-p article)))
5984 (gnus-summary-next-article)
5985 (gnus-summary-next-unread-article))
5986 (if (or (null gnus-current-article)
5987 (null gnus-article-current)
5988 (/= article (cdr gnus-article-current))
5989 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5990 ;; Selected subject is different from current article's.
5991 (gnus-summary-display-article article)
5992 (when article-window
5993 (gnus-eval-in-buffer-window gnus-article-buffer
5994 (setq endp (gnus-article-next-page lines)))
5997 (gnus-summary-beginning-of-article))
5999 (gnus-message 3 "End of message"))
6001 (if (and (eq gnus-summary-goto-unread 'never)
6002 (not (gnus-summary-last-article-p article)))
6003 (gnus-summary-next-article)
6004 (gnus-summary-next-unread-article))))))))
6005 (gnus-summary-recenter)
6006 (gnus-summary-position-point)))
6008 (defun gnus-summary-prev-page (&optional lines move)
6009 "Show previous page of selected article.
6010 Argument LINES specifies lines to be scrolled down.
6011 If MOVE, move to the previous unread article if point is at
6012 the beginning of the buffer."
6014 (let ((article (gnus-summary-article-number))
6015 (article-window (get-buffer-window gnus-article-buffer t))
6017 (gnus-configure-windows 'article)
6018 (if (or (null gnus-current-article)
6019 (null gnus-article-current)
6020 (/= article (cdr gnus-article-current))
6021 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6022 ;; Selected subject is different from current article's.
6023 (gnus-summary-display-article article)
6024 (gnus-summary-recenter)
6025 (when article-window
6026 (gnus-eval-in-buffer-window gnus-article-buffer
6027 (setq endp (gnus-article-prev-page lines)))
6028 (when (and move endp)
6030 (gnus-message 3 "Beginning of message"))
6032 (if (and (eq gnus-summary-goto-unread 'never)
6033 (not (gnus-summary-first-article-p article)))
6034 (gnus-summary-prev-article)
6035 (gnus-summary-prev-unread-article))))))))
6036 (gnus-summary-position-point))
6038 (defun gnus-summary-prev-page-or-article (&optional lines)
6039 "Show previous page of selected article.
6040 Argument LINES specifies lines to be scrolled down.
6041 If at the beginning of the article, go to the next article."
6043 (gnus-summary-prev-page lines t))
6045 (defun gnus-summary-scroll-up (lines)
6046 "Scroll up (or down) one line current article.
6047 Argument LINES specifies lines to be scrolled up (or down if negative)."
6049 (gnus-configure-windows 'article)
6050 (gnus-summary-show-thread)
6051 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6052 (gnus-eval-in-buffer-window gnus-article-buffer
6054 (when (gnus-article-next-page lines)
6055 (gnus-message 3 "End of message")))
6057 (gnus-article-prev-page (- lines))))))
6058 (gnus-summary-recenter)
6059 (gnus-summary-position-point))
6061 (defun gnus-summary-scroll-down (lines)
6062 "Scroll down (or up) one line current article.
6063 Argument LINES specifies lines to be scrolled down (or up if negative)."
6065 (gnus-summary-scroll-up (- lines)))
6067 (defun gnus-summary-next-same-subject ()
6068 "Select next article which has the same subject as current one."
6070 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6072 (defun gnus-summary-prev-same-subject ()
6073 "Select previous article which has the same subject as current one."
6075 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6077 (defun gnus-summary-next-unread-same-subject ()
6078 "Select next unread article which has the same subject as current one."
6080 (gnus-summary-next-article t (gnus-summary-article-subject)))
6082 (defun gnus-summary-prev-unread-same-subject ()
6083 "Select previous unread article which has the same subject as current one."
6085 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6087 (defun gnus-summary-first-unread-article ()
6088 "Select the first unread article.
6089 Return nil if there are no unread articles."
6092 (when (gnus-summary-first-subject t)
6093 (gnus-summary-show-thread)
6094 (gnus-summary-first-subject t)
6095 (gnus-summary-display-article (gnus-summary-article-number)))
6096 (gnus-summary-position-point)))
6098 (defun gnus-summary-first-unread-subject ()
6099 "Place the point on the subject line of the first unread article.
6100 Return nil if there are no unread articles."
6103 (when (gnus-summary-first-subject t)
6104 (gnus-summary-show-thread)
6105 (gnus-summary-first-subject t))
6106 (gnus-summary-position-point)))
6108 (defun gnus-summary-first-article ()
6109 "Select the first article.
6110 Return nil if there are no articles."
6113 (when (gnus-summary-first-subject)
6114 (gnus-summary-show-thread)
6115 (gnus-summary-first-subject)
6116 (gnus-summary-display-article (gnus-summary-article-number)))
6117 (gnus-summary-position-point)))
6119 (defun gnus-summary-best-unread-article ()
6120 "Select the unread article with the highest score."
6122 (let ((best -1000000)
6123 (data gnus-newsgroup-data)
6126 (and (gnus-data-unread-p (car data))
6128 (gnus-summary-article-score (gnus-data-number (car data))))
6131 article (gnus-data-number (car data))))
6132 (setq data (cdr data)))
6135 (gnus-summary-goto-article article)
6136 (error "No unread articles"))
6137 (gnus-summary-position-point))))
6139 (defun gnus-summary-last-subject ()
6140 "Go to the last displayed subject line in the group."
6141 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6143 (gnus-summary-goto-subject article))))
6145 (defun gnus-summary-goto-article (article &optional all-headers force)
6146 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6147 If ALL-HEADERS is non-nil, no header lines are hidden.
6148 If FORCE, go to the article even if it isn't displayed. If FORCE
6149 is a number, it is the line the article is to be displayed on."
6153 "Article number or Message-ID: "
6154 (mapcar (lambda (number) (list (int-to-string number)))
6155 gnus-newsgroup-limit))
6159 (if (and (stringp article)
6160 (string-match "@" article))
6161 (gnus-summary-refer-article article)
6162 (when (stringp article)
6163 (setq article (string-to-number article)))
6164 (if (gnus-summary-goto-subject article force)
6165 (gnus-summary-display-article article all-headers)
6166 (gnus-message 4 "Couldn't go to article %s" article) nil))
6167 (gnus-summary-position-point)))
6169 (defun gnus-summary-goto-last-article ()
6170 "Go to the previously read article."
6173 (when gnus-last-article
6174 (gnus-summary-goto-article gnus-last-article nil t))
6175 (gnus-summary-position-point)))
6177 (defun gnus-summary-pop-article (number)
6178 "Pop one article off the history and go to the previous.
6179 NUMBER articles will be popped off."
6182 (setq gnus-newsgroup-history
6183 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6185 (gnus-summary-goto-article (car to) nil t)
6186 (error "Article history empty")))
6187 (gnus-summary-position-point))
6189 ;; Summary commands and functions for limiting the summary buffer.
6191 (defun gnus-summary-limit-to-articles (n)
6192 "Limit the summary buffer to the next N articles.
6193 If not given a prefix, use the process marked articles instead."
6196 (let ((articles (gnus-summary-work-articles n)))
6197 (setq gnus-newsgroup-processable nil)
6198 (gnus-summary-limit articles))
6199 (gnus-summary-position-point)))
6201 (defun gnus-summary-pop-limit (&optional total)
6202 "Restore the previous limit.
6203 If given a prefix, remove all limits."
6206 (setq gnus-newsgroup-limits
6207 (list (mapcar (lambda (h) (mail-header-number h))
6208 gnus-newsgroup-headers))))
6209 (unless gnus-newsgroup-limits
6210 (error "No limit to pop"))
6212 (gnus-summary-limit nil 'pop)
6213 (gnus-summary-position-point)))
6215 (defun gnus-summary-limit-to-subject (subject &optional header)
6216 "Limit the summary buffer to articles that have subjects that match a regexp."
6217 (interactive "sLimit to subject (regexp): ")
6219 (setq header "subject"))
6220 (when (not (equal "" subject))
6222 (let ((articles (gnus-summary-find-matching
6223 (or header "subject") subject 'all)))
6225 (error "Found no matches for \"%s\"" subject))
6226 (gnus-summary-limit articles))
6227 (gnus-summary-position-point))))
6229 (defun gnus-summary-limit-to-author (from)
6230 "Limit the summary buffer to articles that have authors that match a regexp."
6231 (interactive "sLimit to author (regexp): ")
6232 (gnus-summary-limit-to-subject from "from"))
6234 (defun gnus-summary-limit-to-age (age &optional younger-p)
6235 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6236 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6237 articles that are younger than AGE days."
6239 (let ((younger current-prefix-arg)
6242 (while (not days-got)
6243 (setq days (if younger
6244 (read-string "Limit to articles within (in days): ")
6245 (read-string "Limit to articles old than (in days): ")))
6246 (when (> (length days) 0)
6247 (setq days (read days)))
6250 (message "Please enter a number.")
6252 (list days younger)))
6254 (let ((data gnus-newsgroup-data)
6255 (cutoff (days-to-time age))
6256 articles d date is-younger)
6257 (while (setq d (pop data))
6258 (when (and (vectorp (gnus-data-header d))
6259 (setq date (mail-header-date (gnus-data-header d))))
6260 (setq is-younger (time-less-p
6261 (time-since (condition-case ()
6268 (push (gnus-data-number d) articles))))
6269 (gnus-summary-limit (nreverse articles)))
6270 (gnus-summary-position-point)))
6272 (defun gnus-summary-limit-to-extra (header regexp)
6273 "Limit the summary buffer to articles that match an 'extra' header."
6277 (gnus-completing-read
6278 (symbol-name (car gnus-extra-headers))
6279 "Limit extra header:"
6281 (cons (symbol-name x) x))
6286 (read-string (format "Limit to header %s (regexp): " header)))))
6287 (when (not (equal "" regexp))
6289 (let ((articles (gnus-summary-find-matching
6290 (cons 'extra header) regexp 'all)))
6292 (error "Found no matches for \"%s\"" regexp))
6293 (gnus-summary-limit articles))
6294 (gnus-summary-position-point))))
6296 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6298 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6300 (defun gnus-summary-limit-to-unread (&optional all)
6301 "Limit the summary buffer to articles that are not marked as read.
6302 If ALL is non-nil, limit strictly to unread articles."
6305 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6306 (gnus-summary-limit-to-marks
6307 ;; Concat all the marks that say that an article is read and have
6309 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6310 gnus-killed-mark gnus-kill-file-mark
6311 gnus-low-score-mark gnus-expirable-mark
6312 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6313 gnus-duplicate-mark gnus-souped-mark)
6316 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6317 (make-obsolete 'gnus-summary-delete-marked-with
6318 'gnus-summary-limit-exlude-marks)
6320 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6321 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6322 If REVERSE, limit the summary buffer to articles that are marked
6323 with MARKS. MARKS can either be a string of marks or a list of marks.
6324 Returns how many articles were removed."
6325 (interactive "sMarks: ")
6326 (gnus-summary-limit-to-marks marks t))
6328 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6329 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6330 If REVERSE (the prefix), limit the summary buffer to articles that are
6331 not marked with MARKS. MARKS can either be a string of marks or a
6333 Returns how many articles were removed."
6334 (interactive "sMarks: \nP")
6336 (let ((data gnus-newsgroup-data)
6337 (marks (if (listp marks) marks
6338 (append marks nil))) ; Transform to list.
6341 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6342 (memq (gnus-data-mark (car data)) marks))
6343 (push (gnus-data-number (car data)) articles))
6344 (setq data (cdr data)))
6345 (gnus-summary-limit articles))
6346 (gnus-summary-position-point)))
6348 (defun gnus-summary-limit-to-score (&optional score)
6349 "Limit to articles with score at or above SCORE."
6351 (setq score (if score
6352 (prefix-numeric-value score)
6353 (or gnus-summary-default-score 0)))
6354 (let ((data gnus-newsgroup-data)
6357 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6359 (push (gnus-data-number (car data)) articles))
6360 (setq data (cdr data)))
6362 (gnus-summary-limit articles)
6363 (gnus-summary-position-point))))
6365 (defun gnus-summary-limit-include-thread (id)
6366 "Display all the hidden articles that in the current thread."
6367 (interactive (list (mail-header-id (gnus-summary-article-header))))
6368 (let ((articles (gnus-articles-in-thread
6369 (gnus-id-to-thread (gnus-root-id id)))))
6371 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6372 (gnus-summary-position-point))))
6374 (defun gnus-summary-limit-include-dormant ()
6375 "Display all the hidden articles that are marked as dormant.
6376 Note that this command only works on a subset of the articles currently
6377 fetched for this group."
6379 (unless gnus-newsgroup-dormant
6380 (error "There are no dormant articles in this group"))
6382 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6383 (gnus-summary-position-point)))
6385 (defun gnus-summary-limit-exclude-dormant ()
6386 "Hide all dormant articles."
6389 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6390 (gnus-summary-position-point)))
6392 (defun gnus-summary-limit-exclude-childless-dormant ()
6393 "Hide all dormant articles that have no children."
6395 (let ((data (gnus-data-list t))
6396 articles d children)
6397 ;; Find all articles that are either not dormant or have
6399 (while (setq d (pop data))
6400 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6402 (gnus-article-children (gnus-data-number d)))
6405 (when (memq (car children) articles)
6410 (push (gnus-data-number d) articles)))
6413 (gnus-summary-limit articles)
6414 (gnus-summary-position-point))))
6416 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6417 "Mark all unread excluded articles as read.
6418 If ALL, mark even excluded ticked and dormants as read."
6420 (let ((articles (gnus-sorted-complement
6422 (mapcar (lambda (h) (mail-header-number h))
6423 gnus-newsgroup-headers)
6425 (sort gnus-newsgroup-limit '<)))
6427 (setq gnus-newsgroup-unreads
6428 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6430 (setq gnus-newsgroup-dormant nil
6431 gnus-newsgroup-marked nil
6432 gnus-newsgroup-reads
6434 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6435 gnus-newsgroup-reads))
6436 (while (setq article (pop articles))
6437 (unless (or (memq article gnus-newsgroup-dormant)
6438 (memq article gnus-newsgroup-marked))
6439 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6441 (defun gnus-summary-limit (articles &optional pop)
6443 ;; We pop the previous limit off the stack and use that.
6444 (setq articles (car gnus-newsgroup-limits)
6445 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6446 ;; We use the new limit, so we push the old limit on the stack.
6447 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6449 (setq gnus-newsgroup-limit articles)
6450 (let ((total (length gnus-newsgroup-data))
6451 (data (gnus-data-find-list (gnus-summary-article-number)))
6452 (gnus-summary-mark-below nil) ; Inhibit this.
6454 ;; This will do all the work of generating the new summary buffer
6455 ;; according to the new limit.
6456 (gnus-summary-prepare)
6457 ;; Hide any threads, possibly.
6458 (and gnus-show-threads
6459 gnus-thread-hide-subtree
6460 (gnus-summary-hide-all-threads))
6461 ;; Try to return to the article you were at, or one in the
6464 ;; We try to find some article after the current one.
6466 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6469 (setq data (cdr data))))
6471 ;; If there is no data, that means that we were after the last
6472 ;; article. The same goes when we can't find any articles
6473 ;; after the current one.
6474 (goto-char (point-max))
6475 (gnus-summary-find-prev))
6476 (gnus-set-mode-line 'summary)
6477 ;; We return how many articles were removed from the summary
6478 ;; buffer as a result of the new limit.
6479 (- total (length gnus-newsgroup-data))))
6481 (defsubst gnus-invisible-cut-children (threads)
6484 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6489 (defsubst gnus-cut-thread (thread)
6490 "Go forwards in the thread until we find an article that we want to display."
6491 (when (or (eq gnus-fetch-old-headers 'some)
6492 (eq gnus-fetch-old-headers 'invisible)
6493 (numberp gnus-fetch-old-headers)
6494 (eq gnus-build-sparse-threads 'some)
6495 (eq gnus-build-sparse-threads 'more))
6496 ;; Deal with old-fetched headers and sparse threads.
6500 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6501 (gnus-summary-article-ancient-p
6502 (mail-header-number (car thread))))
6503 (if (or (<= (length (cdr thread)) 1)
6504 (eq gnus-fetch-old-headers 'invisible))
6505 (setq gnus-newsgroup-limit
6506 (delq (mail-header-number (car thread))
6507 gnus-newsgroup-limit)
6508 thread (cadr thread))
6509 (when (gnus-invisible-cut-children (cdr thread))
6510 (let ((th (cdr thread)))
6512 (if (memq (mail-header-number (caar th))
6513 gnus-newsgroup-limit)
6514 (setq thread (car th)
6516 (setq th (cdr th))))))))))
6519 (defun gnus-cut-threads (threads)
6520 "Cut off all uninteresting articles from the beginning of threads."
6521 (when (or (eq gnus-fetch-old-headers 'some)
6522 (eq gnus-fetch-old-headers 'invisible)
6523 (numberp gnus-fetch-old-headers)
6524 (eq gnus-build-sparse-threads 'some)
6525 (eq gnus-build-sparse-threads 'more))
6528 (setcar th (gnus-cut-thread (car th)))
6529 (setq th (cdr th)))))
6530 ;; Remove nixed out threads.
6533 (defun gnus-summary-initial-limit (&optional show-if-empty)
6534 "Figure out what the initial limit is supposed to be on group entry.
6535 This entails weeding out unwanted dormants, low-scored articles,
6536 fetch-old-headers verbiage, and so on."
6537 ;; Most groups have nothing to remove.
6538 (if (or gnus-inhibit-limiting
6539 (and (null gnus-newsgroup-dormant)
6540 (not (eq gnus-fetch-old-headers 'some))
6541 (not (numberp gnus-fetch-old-headers))
6542 (not (eq gnus-fetch-old-headers 'invisible))
6543 (null gnus-summary-expunge-below)
6544 (not (eq gnus-build-sparse-threads 'some))
6545 (not (eq gnus-build-sparse-threads 'more))
6546 (null gnus-thread-expunge-below)
6547 (not gnus-use-nocem)))
6549 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6550 (setq gnus-newsgroup-limit nil)
6553 (unless (car (symbol-value node))
6554 ;; These threads have no parents -- they are roots.
6555 (let ((nodes (cdr (symbol-value node)))
6558 (if (and gnus-thread-expunge-below
6559 (< (gnus-thread-total-score (car nodes))
6560 gnus-thread-expunge-below))
6561 (gnus-expunge-thread (pop nodes))
6562 (setq thread (pop nodes))
6563 (gnus-summary-limit-children thread))))))
6564 gnus-newsgroup-dependencies)
6565 ;; If this limitation resulted in an empty group, we might
6566 ;; pop the previous limit and use it instead.
6567 (when (and (not gnus-newsgroup-limit)
6569 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6570 gnus-newsgroup-limit))
6572 (defun gnus-summary-limit-children (thread)
6573 "Return 1 if this subthread is visible and 0 if it is not."
6574 ;; First we get the number of visible children to this thread. This
6575 ;; is done by recursing down the thread using this function, so this
6576 ;; will really go down to a leaf article first, before slowly
6577 ;; working its way up towards the root.
6581 (apply '+ (mapcar 'gnus-summary-limit-children
6584 (number (mail-header-number (car thread)))
6587 (not (memq number gnus-newsgroup-marked))
6589 ;; If this article is dormant and has absolutely no visible
6590 ;; children, then this article isn't visible.
6591 (and (memq number gnus-newsgroup-dormant)
6593 ;; If this is "fetch-old-headered" and there is no
6594 ;; visible children, then we don't want this article.
6595 (and (or (eq gnus-fetch-old-headers 'some)
6596 (numberp gnus-fetch-old-headers))
6597 (gnus-summary-article-ancient-p number)
6599 ;; If this is "fetch-old-headered" and `invisible', then
6600 ;; we don't want this article.
6601 (and (eq gnus-fetch-old-headers 'invisible)
6602 (gnus-summary-article-ancient-p number))
6603 ;; If this is a sparsely inserted article with no children,
6604 ;; we don't want it.
6605 (and (eq gnus-build-sparse-threads 'some)
6606 (gnus-summary-article-sparse-p number)
6608 ;; If we use expunging, and this article is really
6609 ;; low-scored, then we don't want this article.
6610 (when (and gnus-summary-expunge-below
6612 (or (cdr (assq number gnus-newsgroup-scored))
6613 gnus-summary-default-score))
6614 gnus-summary-expunge-below))
6615 ;; We increase the expunge-tally here, but that has
6616 ;; nothing to do with the limits, really.
6617 (incf gnus-newsgroup-expunged-tally)
6618 ;; We also mark as read here, if that's wanted.
6619 (when (and gnus-summary-mark-below
6620 (< score gnus-summary-mark-below))
6621 (setq gnus-newsgroup-unreads
6622 (delq number gnus-newsgroup-unreads))
6623 (if gnus-newsgroup-auto-expire
6624 (push number gnus-newsgroup-expirable)
6625 (push (cons number gnus-low-score-mark)
6626 gnus-newsgroup-reads)))
6628 ;; Check NoCeM things.
6629 (if (and gnus-use-nocem
6630 (gnus-nocem-unwanted-article-p
6631 (mail-header-id (car thread))))
6633 (setq gnus-newsgroup-unreads
6634 (delq number gnus-newsgroup-unreads))
6636 ;; Nope, invisible article.
6638 ;; Ok, this article is to be visible, so we add it to the limit
6640 (push number gnus-newsgroup-limit)
6643 (defun gnus-expunge-thread (thread)
6644 "Mark all articles in THREAD as read."
6645 (let* ((number (mail-header-number (car thread))))
6646 (incf gnus-newsgroup-expunged-tally)
6647 ;; We also mark as read here, if that's wanted.
6648 (setq gnus-newsgroup-unreads
6649 (delq number gnus-newsgroup-unreads))
6650 (if gnus-newsgroup-auto-expire
6651 (push number gnus-newsgroup-expirable)
6652 (push (cons number gnus-low-score-mark)
6653 gnus-newsgroup-reads)))
6654 ;; Go recursively through all subthreads.
6655 (mapcar 'gnus-expunge-thread (cdr thread)))
6657 ;; Summary article oriented commands
6659 (defun gnus-summary-refer-parent-article (n)
6660 "Refer parent article N times.
6661 If N is negative, go to ancestor -N instead.
6662 The difference between N and the number of articles fetched is returned."
6666 (when (not (natnump n))
6671 (setq header (gnus-summary-article-header))
6672 (if (and (eq (mail-header-number header)
6673 (cdr gnus-article-current))
6674 (equal gnus-newsgroup-name
6675 (car gnus-article-current)))
6676 ;; If we try to find the parent of the currently
6677 ;; displayed article, then we take a look at the actual
6678 ;; References header, since this is slightly more
6679 ;; reliable than the References field we got from the
6682 (set-buffer gnus-original-article-buffer)
6683 (nnheader-narrow-to-headers)
6684 (unless (setq ref (message-fetch-field "references"))
6685 (setq ref (message-fetch-field "in-reply-to")))
6688 ;; It's not the current article, so we take a bet on
6689 ;; the value we got from the server.
6690 (mail-header-references header)))
6692 (not (equal ref "")))
6693 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6694 (gnus-message 1 "Couldn't find parent"))
6695 (gnus-message 1 "No references in article %d"
6696 (gnus-summary-article-number))
6699 (gnus-summary-position-point)
6702 (defun gnus-summary-refer-references ()
6703 "Fetch all articles mentioned in the References header.
6704 Return the number of articles fetched."
6706 (let ((ref (mail-header-references (gnus-summary-article-header)))
6707 (current (gnus-summary-article-number))
6711 (error "No References in the current article")
6712 ;; For each Message-ID in the References header...
6713 (while (string-match "<[^>]*>" ref)
6715 ;; ... fetch that article.
6716 (gnus-summary-refer-article
6717 (prog1 (match-string 0 ref)
6718 (setq ref (substring ref (match-end 0))))))
6719 (gnus-summary-goto-subject current)
6720 (gnus-summary-position-point)
6723 (defun gnus-summary-refer-thread (&optional limit)
6724 "Fetch all articles in the current thread.
6725 If LIMIT (the numerical prefix), fetch that many old headers instead
6726 of what's specified by the `gnus-refer-thread-limit' variable."
6728 (let ((id (mail-header-id (gnus-summary-article-header)))
6729 (limit (if limit (prefix-numeric-value limit)
6730 gnus-refer-thread-limit)))
6731 ;; We want to fetch LIMIT *old* headers, but we also have to
6732 ;; re-fetch all the headers in the current buffer, because many of
6733 ;; them may be undisplayed. So we adjust LIMIT.
6734 (when (numberp limit)
6735 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6736 (unless (eq gnus-fetch-old-headers 'invisible)
6737 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6738 ;; Retrieve the headers and read them in.
6739 (if (eq (gnus-retrieve-headers
6740 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6742 (gnus-build-all-threads)
6743 (error "Can't fetch thread from backends that don't support NOV"))
6744 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6745 (gnus-summary-limit-include-thread id)))
6747 (defun gnus-summary-refer-article (message-id)
6748 "Fetch an article specified by MESSAGE-ID."
6749 (interactive "sMessage-ID: ")
6750 (when (and (stringp message-id)
6751 (not (zerop (length message-id))))
6752 ;; Construct the correct Message-ID if necessary.
6753 ;; Suggested by tale@pawl.rpi.edu.
6754 (unless (string-match "^<" message-id)
6755 (setq message-id (concat "<" message-id)))
6756 (unless (string-match ">$" message-id)
6757 (setq message-id (concat message-id ">")))
6758 (let* ((header (gnus-id-to-header message-id))
6760 (gnus-summary-article-sparse-p
6761 (mail-header-number header))
6762 (memq (mail-header-number header)
6763 gnus-newsgroup-limit)))
6766 ;; If the article is present in the buffer we just go to it.
6768 (or (not (gnus-summary-article-sparse-p
6769 (mail-header-number header)))
6772 (gnus-summary-goto-article
6773 (mail-header-number header) nil t)
6775 (gnus-summary-update-article (mail-header-number header)))))
6777 ;; We fetch the article.
6779 (dolist (gnus-override-method (gnus-refer-article-methods))
6780 (gnus-check-server gnus-override-method)
6781 ;; Fetch the header, and display the article.
6782 (when (setq number (gnus-summary-insert-subject message-id))
6783 (gnus-summary-select-article nil nil nil number)
6785 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
6787 (defun gnus-refer-article-methods ()
6788 "Return a list of referrable methods."
6790 ;; No method, so we default to current and native.
6791 ((null gnus-refer-article-method)
6792 (list gnus-current-select-method gnus-select-method))
6794 ((eq 'current gnus-refer-article-method)
6795 (list gnus-current-select-method))
6796 ;; List of select methods.
6797 ((not (stringp (cadr gnus-refer-article-method)))
6799 (dolist (method gnus-refer-article-method)
6800 (push (if (eq 'current method)
6801 gnus-current-select-method
6805 ;; One single select method.
6807 (list gnus-refer-article-method))))
6809 (defun gnus-summary-edit-parameters ()
6810 "Edit the group parameters of the current group."
6812 (gnus-group-edit-group gnus-newsgroup-name 'params))
6814 (defun gnus-summary-customize-parameters ()
6815 "Customize the group parameters of the current group."
6817 (gnus-group-customize gnus-newsgroup-name))
6819 (defun gnus-summary-enter-digest-group (&optional force)
6820 "Enter an nndoc group based on the current article.
6821 If FORCE, force a digest interpretation. If not, try
6822 to guess what the document format is."
6824 (let ((conf gnus-current-window-configuration))
6826 (gnus-summary-select-article))
6827 (setq gnus-current-window-configuration conf)
6828 (let* ((name (format "%s-%d"
6829 (gnus-group-prefixed-name
6830 gnus-newsgroup-name (list 'nndoc ""))
6832 (set-buffer gnus-summary-buffer)
6833 gnus-current-article)))
6834 (ogroup gnus-newsgroup-name)
6835 (params (append (gnus-info-params (gnus-get-info ogroup))
6836 (list (cons 'to-group ogroup))
6837 (list (cons 'save-article-group ogroup))))
6838 (case-fold-search t)
6839 (buf (current-buffer))
6842 (set-buffer gnus-original-article-buffer)
6843 ;; Have the digest group inherit the main mail address of
6844 ;; the parent article.
6845 (when (setq to-address (or (message-fetch-field "reply-to")
6846 (message-fetch-field "from")))
6847 (setq params (append (list (cons 'to-address to-address)))))
6848 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6849 (insert-buffer-substring gnus-original-article-buffer)
6850 ;; Remove lines that may lead nndoc to misinterpret the
6853 (goto-char (point-min))
6854 (or (search-forward "\n\n" nil t) (point)))
6855 (goto-char (point-min))
6856 (delete-matching-lines "^Path:\\|^From ")
6859 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
6860 (gnus-newsgroup-ephemeral-ignored-charsets
6861 gnus-newsgroup-ignored-charsets))
6862 (gnus-group-read-ephemeral-group
6863 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6865 ,(if force 'mbox 'guess))) t))
6866 ;; Make all postings to this group go to the parent group.
6867 (nconc (gnus-info-params (gnus-get-info name))
6869 ;; Couldn't select this doc group.
6870 (switch-to-buffer buf)
6871 (gnus-set-global-variables)
6872 (gnus-configure-windows 'summary)
6873 (gnus-message 3 "Article couldn't be entered?"))
6874 (kill-buffer dig)))))
6876 (defun gnus-summary-read-document (n)
6877 "Open a new group based on the current article(s).
6878 This will allow you to read digests and other similar
6879 documents as newsgroups.
6880 Obeys the standard process/prefix convention."
6882 (let* ((articles (gnus-summary-work-articles n))
6883 (ogroup gnus-newsgroup-name)
6884 (params (append (gnus-info-params (gnus-get-info ogroup))
6885 (list (cons 'to-group ogroup))))
6886 article group egroup groups vgroup)
6887 (while (setq article (pop articles))
6888 (setq group (format "%s-%d" gnus-newsgroup-name article))
6889 (gnus-summary-remove-process-mark article)
6890 (when (gnus-summary-display-article article)
6893 (insert-buffer-substring gnus-original-article-buffer)
6894 ;; Remove some headers that may lead nndoc to make
6896 (message-narrow-to-head)
6897 (goto-char (point-min))
6898 (delete-matching-lines "^\\(Path\\):\\|^From ")
6901 (gnus-group-read-ephemeral-group
6902 group `(nndoc ,group (nndoc-address ,(current-buffer))
6903 (nndoc-article-type guess))
6906 ;; Make all postings to this group go to the parent group.
6907 (nconc (gnus-info-params (gnus-get-info egroup))
6909 (push egroup groups))
6910 ;; Couldn't select this doc group.
6911 (gnus-error 3 "Article couldn't be entered"))))))
6912 ;; Now we have selected all the documents.
6915 (error "None of the articles could be interpreted as documents"))
6916 ((gnus-group-read-ephemeral-group
6917 (setq vgroup (format
6918 "nnvirtual:%s-%s" gnus-newsgroup-name
6919 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6920 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6922 (cons (current-buffer) 'summary)))
6924 (error "Couldn't select virtual nndoc group")))))
6926 (defun gnus-summary-isearch-article (&optional regexp-p)
6927 "Do incremental search forward on the current article.
6928 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6930 (gnus-summary-select-article)
6931 (gnus-configure-windows 'article)
6932 (gnus-eval-in-buffer-window gnus-article-buffer
6935 (isearch-forward regexp-p))))
6937 (defun gnus-summary-search-article-forward (regexp &optional backward)
6938 "Search for an article containing REGEXP forward.
6939 If BACKWARD, search backward instead."
6942 (format "Search article %s (regexp%s): "
6943 (if current-prefix-arg "backward" "forward")
6944 (if gnus-last-search-regexp
6945 (concat ", default " gnus-last-search-regexp)
6947 current-prefix-arg))
6948 (if (string-equal regexp "")
6949 (setq regexp (or gnus-last-search-regexp ""))
6950 (setq gnus-last-search-regexp regexp))
6951 (if (gnus-summary-search-article regexp backward)
6952 (gnus-summary-show-thread)
6953 (error "Search failed: \"%s\"" regexp)))
6955 (defun gnus-summary-search-article-backward (regexp)
6956 "Search for an article containing REGEXP backward."
6959 (format "Search article backward (regexp%s): "
6960 (if gnus-last-search-regexp
6961 (concat ", default " gnus-last-search-regexp)
6963 (gnus-summary-search-article-forward regexp 'backward))
6965 (defun gnus-summary-search-article (regexp &optional backward)
6966 "Search for an article containing REGEXP.
6967 Optional argument BACKWARD means do search for backward.
6968 `gnus-select-article-hook' is not called during the search."
6969 ;; We have to require this here to make sure that the following
6970 ;; dynamic binding isn't shadowed by autoloading.
6971 (require 'gnus-async)
6973 (let ((gnus-select-article-hook nil) ;Disable hook.
6974 (gnus-article-prepare-hook nil)
6975 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6976 (gnus-use-article-prefetch nil)
6977 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
6978 (gnus-use-trees nil) ;Inhibit updating tree buffer.
6979 (sum (current-buffer))
6980 (gnus-display-mime-function nil)
6983 (gnus-save-hidden-threads
6984 (gnus-summary-select-article)
6985 (set-buffer gnus-article-buffer)
6986 (goto-char (window-point (get-buffer-window (current-buffer))))
6990 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
6992 (re-search-backward regexp nil t)
6993 (re-search-forward regexp nil t))
6994 ;; We found the regexp.
6999 (get-buffer-window (current-buffer))
7003 (get-buffer-window (current-buffer))
7006 (setq point (point)))
7007 ;; We didn't find it, so we go to the next article.
7010 (while (eq found 'not)
7011 (if (not (if backward (gnus-summary-find-prev)
7012 (gnus-summary-find-next)))
7013 ;; No more articles.
7015 ;; Select the next article and adjust point.
7016 (unless (gnus-summary-article-sparse-p
7017 (gnus-summary-article-number))
7019 (gnus-summary-select-article)
7020 (set-buffer gnus-article-buffer)
7022 (goto-char (if backward (point-max) (point-min))))))))
7023 (gnus-message 7 ""))
7024 ;; Return whether we found the regexp.
7025 (when (eq found 'found)
7027 (gnus-summary-show-thread)
7028 (gnus-summary-goto-subject gnus-current-article)
7029 (gnus-summary-position-point)
7032 (defun gnus-summary-find-matching (header regexp &optional backward unread
7034 "Return a list of all articles that match REGEXP on HEADER.
7035 The search stars on the current article and goes forwards unless
7036 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
7037 If UNREAD is non-nil, only unread articles will
7038 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
7039 in the comparisons."
7040 (let ((data (if (eq backward 'all) gnus-newsgroup-data
7041 (gnus-data-find-list
7042 (gnus-summary-article-number) (gnus-data-list backward))))
7043 (case-fold-search (not not-case-fold))
7046 (if (eq (car header) 'extra)
7049 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
7051 (error "%s is an invalid header" header))
7052 (unless (fboundp (intern (concat "mail-header-" header)))
7053 (error "%s is not a valid header" header))
7054 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
7057 (and (or (not unread) ; We want all articles...
7058 (gnus-data-unread-p d)) ; Or just unreads.
7059 (vectorp (gnus-data-header d)) ; It's not a pseudo.
7060 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
7061 (push (gnus-data-number d) articles)) ; Success!
7062 (setq data (cdr data)))
7063 (nreverse articles)))
7065 (defun gnus-summary-execute-command (header regexp command &optional backward)
7066 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7067 If HEADER is an empty string (or nil), the match is done on the entire
7068 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7070 (list (let ((completion-ignore-case t))
7073 (mapcar (lambda (string) (list string))
7074 '("Number" "Subject" "From" "Lines" "Date"
7075 "Message-ID" "Xref" "References" "Body"))
7076 nil 'require-match))
7077 (read-string "Regexp: ")
7078 (read-key-sequence "Command: ")
7079 current-prefix-arg))
7080 (when (equal header "Body")
7082 ;; Hidden thread subtrees must be searched as well.
7083 (gnus-summary-show-all-threads)
7084 ;; We don't want to change current point nor window configuration.
7086 (save-window-excursion
7087 (gnus-message 6 "Executing %s..." (key-description command))
7088 ;; We'd like to execute COMMAND interactively so as to give arguments.
7089 (gnus-execute header regexp
7090 `(call-interactively ',(key-binding command))
7092 (gnus-message 6 "Executing %s...done" (key-description command)))))
7094 (defun gnus-summary-beginning-of-article ()
7095 "Scroll the article back to the beginning."
7097 (gnus-summary-select-article)
7098 (gnus-configure-windows 'article)
7099 (gnus-eval-in-buffer-window gnus-article-buffer
7101 (goto-char (point-min))
7102 (when gnus-page-broken
7103 (gnus-narrow-to-page))))
7105 (defun gnus-summary-end-of-article ()
7106 "Scroll to the end of the article."
7108 (gnus-summary-select-article)
7109 (gnus-configure-windows 'article)
7110 (gnus-eval-in-buffer-window gnus-article-buffer
7112 (goto-char (point-max))
7114 (when gnus-page-broken
7115 (gnus-narrow-to-page))))
7117 (defun gnus-summary-print-article (&optional filename n)
7118 "Generate and print a PostScript image of the N next (mail) articles.
7120 If N is negative, print the N previous articles. If N is nil and articles
7121 have been marked with the process mark, print these instead.
7123 If the optional first argument FILENAME is nil, send the image to the
7124 printer. If FILENAME is a string, save the PostScript image in a file with
7125 that name. If FILENAME is a number, prompt the user for the name of the file
7127 (interactive (list (ps-print-preprint current-prefix-arg)
7128 current-prefix-arg))
7129 (dolist (article (gnus-summary-work-articles n))
7130 (gnus-summary-select-article nil nil 'pseudo article)
7131 (gnus-eval-in-buffer-window gnus-article-buffer
7132 (let ((buffer (generate-new-buffer " *print*")))
7135 (copy-to-buffer buffer (point-min) (point-max))
7137 (gnus-article-delete-invisible-text)
7138 (let ((ps-left-header
7141 (mail-header-subject gnus-current-headers) ")")
7143 (mail-header-from gnus-current-headers) ")")))
7146 "/pagenumberstring load"
7148 (mail-header-date gnus-current-headers) ")"))))
7149 (gnus-run-hooks 'gnus-ps-print-hook)
7151 (ps-print-buffer-with-faces filename))))
7152 (kill-buffer buffer))))))
7154 (defun gnus-summary-show-article (&optional arg)
7155 "Force re-fetching of the current article.
7156 If ARG (the prefix) is a number, show the article with the charset
7157 defined in `gnus-summary-show-article-charset-alist', or the charset
7159 If ARG (the prefix) is non-nil and not a number, show the raw article
7160 without any article massaging functions being run."
7164 (let ((gnus-newsgroup-charset
7165 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
7166 (read-coding-system "Charset: ")))
7167 (gnus-newsgroup-ignored-charsets 'gnus-all))
7168 (gnus-summary-select-article nil 'force)))
7170 ;; Select the article the normal way.
7171 (gnus-summary-select-article nil 'force))
7173 ;; We have to require this here to make sure that the following
7174 ;; dynamic binding isn't shadowed by autoloading.
7175 (require 'gnus-async)
7177 ;; Bind the article treatment functions to nil.
7178 (let ((gnus-have-all-headers t)
7179 gnus-article-prepare-hook
7180 gnus-article-decode-hook
7181 gnus-display-mime-function
7183 ;; Destroy any MIME parts.
7184 (when (gnus-buffer-live-p gnus-article-buffer)
7186 (set-buffer gnus-article-buffer)
7187 (mm-destroy-parts gnus-article-mime-handles)))
7188 (gnus-summary-select-article nil 'force))))
7189 (gnus-summary-goto-subject gnus-current-article)
7190 (gnus-summary-position-point))
7192 (defun gnus-summary-verbose-headers (&optional arg)
7193 "Toggle permanent full header display.
7194 If ARG is a positive number, turn header display on.
7195 If ARG is a negative number, turn header display off."
7197 (setq gnus-show-all-headers
7198 (cond ((or (not (numberp arg))
7200 (not gnus-show-all-headers))
7203 (gnus-summary-show-article))
7205 (defun gnus-summary-toggle-header (&optional arg)
7206 "Show the headers if they are hidden, or hide them if they are shown.
7207 If ARG is a positive number, show the entire header.
7208 If ARG is a negative number, hide the unwanted header lines."
7211 (set-buffer gnus-article-buffer)
7213 (let* ((buffer-read-only nil)
7214 (inhibit-point-motion-hooks t)
7220 (article-narrow-to-head)
7221 (gnus-article-hidden-text-p 'headers))))
7222 (goto-char (point-min))
7223 (when (search-forward "\n\n" nil t)
7224 (delete-region (point-min) (1- (point))))
7225 (goto-char (point-min))
7227 (set-buffer gnus-original-article-buffer)
7228 (goto-char (point-min))
7229 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
7230 (insert-buffer-substring gnus-original-article-buffer 1 e)
7232 (narrow-to-region (point-min) (point))
7233 (article-decode-encoded-words)
7235 (let ((gnus-treat-hide-headers nil)
7236 (gnus-treat-hide-boring-headers nil))
7237 (gnus-treat-article 'head))
7238 (gnus-treat-article 'head)))))))
7240 (defun gnus-summary-show-all-headers ()
7241 "Make all header lines visible."
7243 (gnus-article-show-all-headers))
7245 (defun gnus-summary-caesar-message (&optional arg)
7246 "Caesar rotate the current article by 13.
7247 The numerical prefix specifies how many places to rotate each letter
7250 (gnus-summary-select-article)
7251 (let ((mail-header-separator ""))
7252 (gnus-eval-in-buffer-window gnus-article-buffer
7255 (let ((start (window-start))
7257 (message-caesar-buffer-body arg)
7258 (set-window-start (get-buffer-window (current-buffer)) start))))))
7260 (defun gnus-summary-stop-page-breaking ()
7261 "Stop page breaking in the current article."
7263 (gnus-summary-select-article)
7264 (gnus-eval-in-buffer-window gnus-article-buffer
7266 (when (gnus-visual-p 'page-marker)
7267 (let ((buffer-read-only nil))
7268 (gnus-remove-text-with-property 'gnus-prev)
7269 (gnus-remove-text-with-property 'gnus-next))
7270 (setq gnus-page-broken nil))))
7272 (defun gnus-summary-move-article (&optional n to-newsgroup
7273 select-method action)
7274 "Move the current article to a different newsgroup.
7275 If N is a positive number, move the N next articles.
7276 If N is a negative number, move the N previous articles.
7277 If N is nil and any articles have been marked with the process mark,
7278 move those articles instead.
7279 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7280 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7281 re-spool using this method.
7283 For this function to work, both the current newsgroup and the
7284 newsgroup that you want to move to have to support the `request-move'
7285 and `request-accept' functions.
7287 ACTION can be either `move' (the default), `crosspost' or `copy'."
7290 (setq action 'move))
7291 ;; Disable marking as read.
7292 (let (gnus-mark-article-hook)
7293 (save-window-excursion
7294 (gnus-summary-select-article)))
7295 ;; Check whether the source group supports the required functions.
7296 (cond ((and (eq action 'move)
7297 (not (gnus-check-backend-function
7298 'request-move-article gnus-newsgroup-name)))
7299 (error "The current group does not support article moving"))
7300 ((and (eq action 'crosspost)
7301 (not (gnus-check-backend-function
7302 'request-replace-article gnus-newsgroup-name)))
7303 (error "The current group does not support article editing")))
7304 (let ((articles (gnus-summary-work-articles n))
7305 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
7306 (names '((move "Move" "Moving")
7307 (copy "Copy" "Copying")
7308 (crosspost "Crosspost" "Crossposting")))
7309 (copy-buf (save-excursion
7310 (nnheader-set-temp-buffer " *copy article*")))
7311 art-group to-method new-xref article to-groups)
7312 (unless (assq action names)
7313 (error "Unknown action %s" action))
7314 ;; Read the newsgroup name.
7315 (when (and (not to-newsgroup)
7316 (not select-method))
7318 (gnus-read-move-group-name
7319 (cadr (assq action names))
7320 (symbol-value (intern (format "gnus-current-%s-group" action)))
7322 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
7323 (setq to-method (or select-method
7324 (gnus-group-name-to-method to-newsgroup)))
7325 ;; Check the method we are to move this article to...
7326 (unless (gnus-check-backend-function
7327 'request-accept-article (car to-method))
7328 (error "%s does not support article copying" (car to-method)))
7329 (unless (gnus-check-server to-method)
7330 (error "Can't open server %s" (car to-method)))
7331 (gnus-message 6 "%s to %s: %s..."
7332 (caddr (assq action names))
7333 (or (car select-method) to-newsgroup) articles)
7335 (setq article (pop articles))
7339 ;; Move the article.
7341 ;; Remove this article from future suppression.
7342 (gnus-dup-unsuppress-article article)
7343 (gnus-request-move-article
7344 article ; Article to move
7345 gnus-newsgroup-name ; From newsgroup
7346 (nth 1 (gnus-find-method-for-group
7347 gnus-newsgroup-name)) ; Server
7348 (list 'gnus-request-accept-article
7349 to-newsgroup (list 'quote select-method)
7350 (not articles) t) ; Accept form
7351 (not articles))) ; Only save nov last time
7352 ;; Copy the article.
7355 (set-buffer copy-buf)
7356 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
7357 (gnus-request-accept-article
7358 to-newsgroup select-method (not articles) t))))
7359 ;; Crosspost the article.
7360 ((eq action 'crosspost)
7361 (let ((xref (message-tokenize-header
7362 (mail-header-xref (gnus-summary-article-header article))
7364 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
7367 (setq xref (list (system-name))))
7370 (mapconcat 'identity
7371 (delete "Xref:" (delete new-xref xref))
7375 (set-buffer copy-buf)
7376 ;; First put the article in the destination group.
7377 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7378 (when (consp (setq art-group
7379 (gnus-request-accept-article
7380 to-newsgroup select-method (not articles))))
7381 (setq new-xref (concat new-xref " " (car art-group)
7382 ":" (cdr art-group)))
7383 ;; Now we have the new Xrefs header, so we insert
7384 ;; it and replace the new article.
7385 (nnheader-replace-header "Xref" new-xref)
7386 (gnus-request-replace-article
7387 (cdr art-group) to-newsgroup (current-buffer))
7391 (gnus-message 1 "Couldn't %s article %s: %s"
7392 (cadr (assq action names)) article
7393 (nnheader-get-report (car to-method))))
7394 ((and (eq art-group 'junk)
7396 (gnus-summary-mark-article article gnus-canceled-mark)
7397 (gnus-message 4 "Deleted article %s" article))
7399 (let* ((pto-group (gnus-group-prefixed-name
7400 (car art-group) to-method))
7402 (gnus-gethash pto-group gnus-newsrc-hashtb))
7403 (info (nth 2 entry))
7404 (to-group (gnus-info-group info))
7406 ;; Update the group that has been moved to.
7408 (memq action '(move copy)))
7409 (unless (member to-group to-groups)
7410 (push to-group to-groups))
7412 (unless (memq article gnus-newsgroup-unreads)
7413 (push 'read to-marks)
7415 info (gnus-add-to-range (gnus-info-read info)
7416 (list (cdr art-group)))))
7418 ;; See whether the article is to be put in the cache.
7419 (let ((marks gnus-article-mark-lists)
7420 (to-article (cdr art-group)))
7422 ;; Enter the article into the cache in the new group,
7423 ;; if that is required.
7424 (when gnus-use-cache
7425 (gnus-cache-possibly-enter-article
7427 (memq article gnus-newsgroup-marked)
7428 (memq article gnus-newsgroup-dormant)
7429 (memq article gnus-newsgroup-unreads)))
7431 (when gnus-preserve-marks
7432 ;; Copy any marks over to the new group.
7433 (when (and (equal to-group gnus-newsgroup-name)
7434 (not (memq article gnus-newsgroup-unreads)))
7435 ;; Mark this article as read in this group.
7436 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7437 (setcdr (gnus-active to-group) to-article)
7438 (setcdr gnus-newsgroup-active to-article))
7441 (when (memq article (symbol-value
7442 (intern (format "gnus-newsgroup-%s"
7444 (push (cdar marks) to-marks)
7445 ;; If the other group is the same as this group,
7446 ;; then we have to add the mark to the list.
7447 (when (equal to-group gnus-newsgroup-name)
7448 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7451 (intern (format "gnus-newsgroup-%s"
7453 ;; Copy the marks to other group.
7454 (gnus-add-marked-articles
7455 to-group (cdar marks) (list to-article) info))
7456 (setq marks (cdr marks)))
7458 (gnus-request-set-mark to-group (list (list (list to-article)
7463 (concat "(gnus-group-set-info '"
7464 (gnus-prin1-to-string (gnus-get-info to-group))
7467 ;; Update the Xref header in this article to point to
7468 ;; the new crossposted article we have just created.
7469 (when (eq action 'crosspost)
7471 (set-buffer copy-buf)
7472 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7473 (nnheader-replace-header "Xref" new-xref)
7474 (gnus-request-replace-article
7475 article gnus-newsgroup-name (current-buffer)))))
7477 ;;;!!!Why is this necessary?
7478 (set-buffer gnus-summary-buffer)
7480 (gnus-summary-goto-subject article)
7481 (when (eq action 'move)
7482 (gnus-summary-mark-article article gnus-canceled-mark))))
7483 (gnus-summary-remove-process-mark article))
7484 ;; Re-activate all groups that have been moved to.
7487 (set-buffer gnus-group-buffer)
7488 (when (gnus-group-goto-group (car to-groups) t)
7489 (gnus-group-get-new-news-this-group 1 t))
7492 (gnus-kill-buffer copy-buf)
7493 (gnus-summary-position-point)
7494 (gnus-set-mode-line 'summary)))
7496 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7497 "Move the current article to a different newsgroup.
7498 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7499 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7500 re-spool using this method."
7502 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7504 (defun gnus-summary-crosspost-article (&optional n)
7505 "Crosspost the current article to some other group."
7507 (gnus-summary-move-article n nil nil 'crosspost))
7509 (defcustom gnus-summary-respool-default-method nil
7510 "Default method for respooling an article.
7511 If nil, use to the current newsgroup method."
7512 :type '(choice (gnus-select-method :value (nnml ""))
7514 :group 'gnus-summary-mail)
7516 (defun gnus-summary-respool-article (&optional n method)
7517 "Respool the current article.
7518 The article will be squeezed through the mail spooling process again,
7519 which means that it will be put in some mail newsgroup or other
7520 depending on `nnmail-split-methods'.
7521 If N is a positive number, respool the N next articles.
7522 If N is a negative number, respool the N previous articles.
7523 If N is nil and any articles have been marked with the process mark,
7524 respool those articles instead.
7526 Respooling can be done both from mail groups and \"real\" newsgroups.
7527 In the former case, the articles in question will be moved from the
7528 current group into whatever groups they are destined to. In the
7529 latter case, they will be copied into the relevant groups."
7531 (list current-prefix-arg
7532 (let* ((methods (gnus-methods-using 'respool))
7534 (symbol-name (or gnus-summary-respool-default-method
7535 (car (gnus-find-method-for-group
7536 gnus-newsgroup-name)))))
7538 (gnus-completing-read
7539 methname "What backend do you want to use when respooling?"
7540 methods nil t nil 'gnus-mail-method-history))
7543 ((zerop (length (setq ms (gnus-servers-using-backend
7545 (list (intern method) ""))
7549 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7550 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7553 (error "No method given for respooling"))
7554 (if (assoc (symbol-name
7555 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7556 (gnus-methods-using 'respool))
7557 (gnus-summary-move-article n nil method)
7558 (gnus-summary-copy-article n nil method)))
7560 (defun gnus-summary-import-article (file)
7561 "Import an arbitrary file into a mail newsgroup."
7562 (interactive "fImport file: ")
7563 (let ((group gnus-newsgroup-name)
7564 (now (current-time))
7566 (unless (gnus-check-backend-function 'request-accept-article group)
7567 (error "%s does not support article importing" group))
7568 (or (file-readable-p file)
7569 (not (file-regular-p file))
7570 (error "Can't read %s" file))
7572 (set-buffer (gnus-get-buffer-create " *import file*"))
7574 (insert-file-contents file)
7575 (goto-char (point-min))
7576 (unless (nnheader-article-p)
7577 ;; This doesn't look like an article, so we fudge some headers.
7578 (setq atts (file-attributes file)
7579 lines (count-lines (point-min) (point-max)))
7580 (insert "From: " (read-string "From: ") "\n"
7581 "Subject: " (read-string "Subject: ") "\n"
7582 "Date: " (message-make-date (nth 5 atts))
7584 "Message-ID: " (message-make-message-id) "\n"
7585 "Lines: " (int-to-string lines) "\n"
7586 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7587 (gnus-request-accept-article group nil t)
7588 (kill-buffer (current-buffer)))))
7590 (defun gnus-summary-article-posted-p ()
7591 "Say whether the current (mail) article is available from news as well.
7592 This will be the case if the article has both been mailed and posted."
7594 (let ((id (mail-header-references (gnus-summary-article-header)))
7595 (gnus-override-method (car (gnus-refer-article-methods))))
7596 (if (gnus-request-head id "")
7597 (gnus-message 2 "The current message was found on %s"
7598 gnus-override-method)
7599 (gnus-message 2 "The current message couldn't be found on %s"
7600 gnus-override-method)
7603 (defun gnus-summary-expire-articles (&optional now)
7604 "Expire all articles that are marked as expirable in the current group."
7606 (when (gnus-check-backend-function
7607 'request-expire-articles gnus-newsgroup-name)
7608 ;; This backend supports expiry.
7609 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7610 (expirable (if total
7612 ;; We need to update the info for
7613 ;; this group for `gnus-list-of-read-articles'
7614 ;; to give us the right answer.
7615 (gnus-run-hooks 'gnus-exit-group-hook)
7616 (gnus-summary-update-info)
7617 (gnus-list-of-read-articles gnus-newsgroup-name))
7618 (setq gnus-newsgroup-expirable
7619 (sort gnus-newsgroup-expirable '<))))
7620 (expiry-wait (if now 'immediate
7621 (gnus-group-find-parameter
7622 gnus-newsgroup-name 'expiry-wait)))
7625 ;; There are expirable articles in this group, so we run them
7626 ;; through the expiry process.
7627 (gnus-message 6 "Expiring articles...")
7628 (unless (gnus-check-group gnus-newsgroup-name)
7629 (error "Can't open server for %s" gnus-newsgroup-name))
7630 ;; The list of articles that weren't expired is returned.
7633 (let ((nnmail-expiry-wait-function nil)
7634 (nnmail-expiry-wait expiry-wait))
7635 (setq es (gnus-request-expire-articles
7636 expirable gnus-newsgroup-name)))
7637 (setq es (gnus-request-expire-articles
7638 expirable gnus-newsgroup-name))))
7640 (setq gnus-newsgroup-expirable es))
7641 ;; We go through the old list of expirable, and mark all
7642 ;; really expired articles as nonexistent.
7643 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7644 (let ((gnus-use-cache nil))
7646 (unless (memq (car expirable) es)
7647 (when (gnus-data-find (car expirable))
7648 (gnus-summary-mark-article
7649 (car expirable) gnus-canceled-mark)))
7650 (setq expirable (cdr expirable)))))
7651 (gnus-message 6 "Expiring articles...done")))))
7653 (defun gnus-summary-expire-articles-now ()
7654 "Expunge all expirable articles in the current group.
7655 This means that *all* articles that are marked as expirable will be
7656 deleted forever, right now."
7658 (or gnus-expert-user
7660 "Are you really, really, really sure you want to delete all these messages? ")
7662 (gnus-summary-expire-articles t))
7664 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7665 (defun gnus-summary-delete-article (&optional n)
7666 "Delete the N next (mail) articles.
7667 This command actually deletes articles. This is not a marking
7668 command. The article will disappear forever from your life, never to
7670 If N is negative, delete backwards.
7671 If N is nil and articles have been marked with the process mark,
7672 delete these instead."
7674 (unless (gnus-check-backend-function 'request-expire-articles
7675 gnus-newsgroup-name)
7676 (error "The current newsgroup does not support article deletion"))
7677 ;; Compute the list of articles to delete.
7678 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
7680 (if (and gnus-novice-user
7681 (not (gnus-yes-or-no-p
7682 (format "Do you really want to delete %s forever? "
7683 (if (> (length articles) 1)
7684 (format "these %s articles" (length articles))
7687 ;; Delete the articles.
7688 (setq not-deleted (gnus-request-expire-articles
7689 articles gnus-newsgroup-name 'force))
7691 (gnus-summary-remove-process-mark (car articles))
7692 ;; The backend might not have been able to delete the article
7694 (unless (memq (car articles) not-deleted)
7695 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7696 (setq articles (cdr articles)))
7698 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7699 (gnus-summary-position-point)
7700 (gnus-set-mode-line 'summary)
7703 (defun gnus-summary-edit-article (&optional force)
7704 "Edit the current article.
7705 This will have permanent effect only in mail groups.
7706 If FORCE is non-nil, allow editing of articles even in read-only
7710 (set-buffer gnus-summary-buffer)
7711 (let ((mail-parse-charset gnus-newsgroup-charset)
7712 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
7713 (gnus-set-global-variables)
7714 (when (and (not force)
7715 (gnus-group-read-only-p))
7716 (error "The current newsgroup does not support article editing"))
7717 (gnus-summary-show-article t)
7718 (gnus-article-edit-article
7720 `(lambda (no-highlight)
7721 (let ((mail-parse-charset ',gnus-newsgroup-charset)
7722 (mail-parse-ignored-charsets
7723 ',gnus-newsgroup-ignored-charsets))
7725 (gnus-summary-edit-article-done
7726 ,(or (mail-header-references gnus-current-headers) "")
7727 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
7729 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7731 (defun gnus-summary-edit-article-done (&optional references read-only buffer
7733 "Make edits to the current article permanent."
7735 ;; Replace the article.
7736 (let ((buf (current-buffer)))
7738 (insert-buffer-substring buf)
7739 (if (and (not read-only)
7740 (not (gnus-request-replace-article
7741 (cdr gnus-article-current) (car gnus-article-current)
7742 (current-buffer) t)))
7743 (error "Couldn't replace article")
7744 ;; Update the summary buffer.
7746 (equal (message-tokenize-header references " ")
7747 (message-tokenize-header
7748 (or (message-fetch-field "references") "") " ")))
7749 ;; We only have to update this line.
7752 (message-narrow-to-head)
7753 (let ((head (buffer-string))
7756 (insert (format "211 %d Article retrieved.\n"
7757 (cdr gnus-article-current)))
7760 (let ((nntp-server-buffer (current-buffer)))
7761 (setq header (car (gnus-get-newsgroup-headers
7763 (set-buffer gnus-summary-buffer)
7764 gnus-newsgroup-dependencies)
7767 (set-buffer gnus-summary-buffer)
7768 (gnus-data-set-header
7769 (gnus-data-find (cdr gnus-article-current))
7771 (gnus-summary-update-article-line
7772 (cdr gnus-article-current) header))))))
7774 (set-buffer (or buffer gnus-summary-buffer))
7775 (gnus-summary-update-article (cdr gnus-article-current)))
7776 ;; Prettify the article buffer again.
7777 (unless no-highlight
7779 (set-buffer gnus-article-buffer)
7780 ;;;!!! Fix this -- article should be rehighlighted.
7781 ;;;(gnus-run-hooks 'gnus-article-display-hook)
7782 (set-buffer gnus-original-article-buffer)
7783 (gnus-request-article
7784 (cdr gnus-article-current)
7785 (car gnus-article-current) (current-buffer))))
7786 ;; Prettify the summary buffer line.
7787 (when (gnus-visual-p 'summary-highlight 'highlight)
7788 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
7790 (defun gnus-summary-edit-wash (key)
7791 "Perform editing command KEY in the article buffer."
7795 (message "%s" (concat (this-command-keys) "- "))
7798 (gnus-summary-edit-article)
7799 (execute-kbd-macro (concat (this-command-keys) key))
7800 (gnus-article-edit-done))
7804 (defun gnus-summary-respool-query (&optional silent trace)
7805 "Query where the respool algorithm would put this article."
7807 (let (gnus-mark-article-hook)
7808 (gnus-summary-select-article)
7810 (set-buffer gnus-original-article-buffer)
7812 (message-narrow-to-head)
7813 (let ((groups (nnmail-article-group 'identity trace)))
7816 (message "This message would go to %s"
7817 (mapconcat 'car groups ", "))
7818 (message "This message would go to no groups"))
7821 (defun gnus-summary-respool-trace ()
7822 "Trace where the respool algorithm would put this article.
7823 Display a buffer showing all fancy splitting patterns which matched."
7825 (gnus-summary-respool-query nil t))
7827 ;; Summary marking commands.
7829 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
7830 "Mark articles which has the same subject as read, and then select the next.
7831 If UNMARK is positive, remove any kind of mark.
7832 If UNMARK is negative, tick articles."
7835 (setq unmark (prefix-numeric-value unmark)))
7837 (gnus-summary-mark-same-subject
7838 (gnus-summary-article-subject) unmark)))
7839 ;; Select next unread article. If auto-select-same mode, should
7840 ;; select the first unread article.
7841 (gnus-summary-next-article t (and gnus-auto-select-same
7842 (gnus-summary-article-subject)))
7843 (gnus-message 7 "%d article%s marked as %s"
7844 count (if (= count 1) " is" "s are")
7845 (if unmark "unread" "read"))))
7847 (defun gnus-summary-kill-same-subject (&optional unmark)
7848 "Mark articles which has the same subject as read.
7849 If UNMARK is positive, remove any kind of mark.
7850 If UNMARK is negative, tick articles."
7853 (setq unmark (prefix-numeric-value unmark)))
7855 (gnus-summary-mark-same-subject
7856 (gnus-summary-article-subject) unmark)))
7857 ;; If marked as read, go to next unread subject.
7859 ;; Go to next unread subject.
7860 (gnus-summary-next-subject 1 t))
7861 (gnus-message 7 "%d articles are marked as %s"
7862 count (if unmark "unread" "read"))))
7864 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7865 "Mark articles with same SUBJECT as read, and return marked number.
7866 If optional argument UNMARK is positive, remove any kinds of marks.
7867 If optional argument UNMARK is negative, mark articles as unread instead."
7871 ((null unmark) ; Mark as read.
7874 (gnus-summary-mark-article-as-read gnus-killed-mark)
7875 (gnus-summary-show-thread) t)
7876 (gnus-summary-find-subject subject))
7877 (setq count (1+ count))))
7878 ((> unmark 0) ; Tick.
7881 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
7882 (gnus-summary-show-thread) t)
7883 (gnus-summary-find-subject subject))
7884 (setq count (1+ count))))
7885 (t ; Mark as unread.
7888 (gnus-summary-mark-article-as-unread gnus-unread-mark)
7889 (gnus-summary-show-thread) t)
7890 (gnus-summary-find-subject subject))
7891 (setq count (1+ count)))))
7892 (gnus-set-mode-line 'summary)
7893 ;; Return the number of marked articles.
7896 (defun gnus-summary-mark-as-processable (n &optional unmark)
7897 "Set the process mark on the next N articles.
7898 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7899 the process mark instead. The difference between N and the actual
7900 number of articles marked is returned."
7902 (let ((backward (< n 0))
7907 (gnus-summary-remove-process-mark
7908 (gnus-summary-article-number))
7909 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7910 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7913 (gnus-message 7 "No more articles"))
7914 (gnus-summary-recenter)
7915 (gnus-summary-position-point)
7918 (defun gnus-summary-unmark-as-processable (n)
7919 "Remove the process mark from the next N articles.
7920 If N is negative, unmark backward instead. The difference between N and
7921 the actual number of articles unmarked is returned."
7923 (gnus-summary-mark-as-processable n t))
7925 (defun gnus-summary-unmark-all-processable ()
7926 "Remove the process mark from all articles."
7929 (while gnus-newsgroup-processable
7930 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7931 (gnus-summary-position-point))
7933 (defun gnus-summary-mark-as-expirable (n)
7934 "Mark N articles forward as expirable.
7935 If N is negative, mark backward instead. The difference between N and
7936 the actual number of articles marked is returned."
7938 (gnus-summary-mark-forward n gnus-expirable-mark))
7940 (defun gnus-summary-mark-article-as-replied (article)
7941 "Mark ARTICLE replied and update the summary line."
7942 (push article gnus-newsgroup-replied)
7943 (let ((buffer-read-only nil))
7944 (when (gnus-summary-goto-subject article nil t)
7945 (gnus-summary-update-secondary-mark article))))
7947 (defun gnus-summary-set-bookmark (article)
7948 "Set a bookmark in current article."
7949 (interactive (list (gnus-summary-article-number)))
7950 (when (or (not (get-buffer gnus-article-buffer))
7951 (not gnus-current-article)
7952 (not gnus-article-current)
7953 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7954 (error "No current article selected"))
7955 ;; Remove old bookmark, if one exists.
7956 (let ((old (assq article gnus-newsgroup-bookmarks)))
7958 (setq gnus-newsgroup-bookmarks
7959 (delq old gnus-newsgroup-bookmarks))))
7960 ;; Set the new bookmark, which is on the form
7961 ;; (article-number . line-number-in-body).
7965 (set-buffer gnus-article-buffer)
7969 (goto-char (point-min))
7970 (search-forward "\n\n" nil t)
7973 gnus-newsgroup-bookmarks)
7974 (gnus-message 6 "A bookmark has been added to the current article."))
7976 (defun gnus-summary-remove-bookmark (article)
7977 "Remove the bookmark from the current article."
7978 (interactive (list (gnus-summary-article-number)))
7979 ;; Remove old bookmark, if one exists.
7980 (let ((old (assq article gnus-newsgroup-bookmarks)))
7983 (setq gnus-newsgroup-bookmarks
7984 (delq old gnus-newsgroup-bookmarks))
7985 (gnus-message 6 "Removed bookmark."))
7986 (gnus-message 6 "No bookmark in current article."))))
7988 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7989 (defun gnus-summary-mark-as-dormant (n)
7990 "Mark N articles forward as dormant.
7991 If N is negative, mark backward instead. The difference between N and
7992 the actual number of articles marked is returned."
7994 (gnus-summary-mark-forward n gnus-dormant-mark))
7996 (defun gnus-summary-set-process-mark (article)
7997 "Set the process mark on ARTICLE and update the summary line."
7998 (setq gnus-newsgroup-processable
8000 (delq article gnus-newsgroup-processable)))
8001 (when (gnus-summary-goto-subject article)
8002 (gnus-summary-show-thread)
8003 (gnus-summary-goto-subject article)
8004 (gnus-summary-update-secondary-mark article)))
8006 (defun gnus-summary-remove-process-mark (article)
8007 "Remove the process mark from ARTICLE and update the summary line."
8008 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
8009 (when (gnus-summary-goto-subject article)
8010 (gnus-summary-show-thread)
8011 (gnus-summary-goto-subject article)
8012 (gnus-summary-update-secondary-mark article)))
8014 (defun gnus-summary-set-saved-mark (article)
8015 "Set the process mark on ARTICLE and update the summary line."
8016 (push article gnus-newsgroup-saved)
8017 (when (gnus-summary-goto-subject article)
8018 (gnus-summary-update-secondary-mark article)))
8020 (defun gnus-summary-mark-forward (n &optional mark no-expire)
8021 "Mark N articles as read forwards.
8022 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
8023 The difference between N and the actual number of articles marked is
8025 Iff NO-EXPIRE, auto-expiry will be inhibited."
8027 (gnus-summary-show-thread)
8028 (let ((backward (< n 0))
8029 (gnus-summary-goto-unread
8030 (and gnus-summary-goto-unread
8031 (not (eq gnus-summary-goto-unread 'never))
8032 (not (memq mark (list gnus-unread-mark
8033 gnus-ticked-mark gnus-dormant-mark)))))
8035 (mark (or mark gnus-del-mark)))
8037 (gnus-summary-mark-article nil mark no-expire)
8038 (zerop (gnus-summary-next-subject
8040 (and gnus-summary-goto-unread
8041 (not (eq gnus-summary-goto-unread 'never)))
8045 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
8046 (gnus-summary-recenter)
8047 (gnus-summary-position-point)
8048 (gnus-set-mode-line 'summary)
8051 (defun gnus-summary-mark-article-as-read (mark)
8052 "Mark the current article quickly as read with MARK."
8053 (let ((article (gnus-summary-article-number)))
8054 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8055 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8056 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8057 (push (cons article mark) gnus-newsgroup-reads)
8058 ;; Possibly remove from cache, if that is used.
8059 (when gnus-use-cache
8060 (gnus-cache-enter-remove-article article))
8061 ;; Allow the backend to change the mark.
8062 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8063 ;; Check for auto-expiry.
8064 (when (and gnus-newsgroup-auto-expire
8065 (memq mark gnus-auto-expirable-marks))
8066 (setq mark gnus-expirable-mark)
8067 ;; Let the backend know about the mark change.
8068 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8069 (push article gnus-newsgroup-expirable))
8070 ;; Set the mark in the buffer.
8071 (gnus-summary-update-mark mark 'unread)
8074 (defun gnus-summary-mark-article-as-unread (mark)
8075 "Mark the current article quickly as unread with MARK."
8076 (let* ((article (gnus-summary-article-number))
8077 (old-mark (gnus-summary-article-mark article)))
8078 ;; Allow the backend to change the mark.
8079 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8080 (if (eq mark old-mark)
8084 (gnus-error 1 "Can't mark negative article numbers")
8086 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8087 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8088 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
8089 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
8090 (cond ((= mark gnus-ticked-mark)
8091 (push article gnus-newsgroup-marked))
8092 ((= mark gnus-dormant-mark)
8093 (push article gnus-newsgroup-dormant))
8095 (push article gnus-newsgroup-unreads)))
8096 (gnus-pull article gnus-newsgroup-reads)
8098 ;; See whether the article is to be put in the cache.
8100 (vectorp (gnus-summary-article-header article))
8102 (gnus-cache-possibly-enter-article
8103 gnus-newsgroup-name article
8104 (= mark gnus-ticked-mark)
8105 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8108 (gnus-summary-update-mark mark 'unread)
8111 (defun gnus-summary-mark-article (&optional article mark no-expire)
8112 "Mark ARTICLE with MARK. MARK can be any character.
8113 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
8114 `??' (dormant) and `?E' (expirable).
8115 If MARK is nil, then the default character `?r' is used.
8116 If ARTICLE is nil, then the article on the current line will be
8118 Iff NO-EXPIRE, auto-expiry will be inhibited."
8119 ;; The mark might be a string.
8120 (when (stringp mark)
8121 (setq mark (aref mark 0)))
8122 ;; If no mark is given, then we check auto-expiring.
8124 (setq mark gnus-del-mark))
8125 (when (and (not no-expire)
8126 gnus-newsgroup-auto-expire
8127 (memq mark gnus-auto-expirable-marks))
8128 (setq mark gnus-expirable-mark))
8129 (let ((article (or article (gnus-summary-article-number)))
8130 (old-mark (gnus-summary-article-mark article)))
8131 ;; Allow the backend to change the mark.
8132 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8133 (if (eq mark old-mark)
8136 (error "No article on current line"))
8137 (if (not (if (or (= mark gnus-unread-mark)
8138 (= mark gnus-ticked-mark)
8139 (= mark gnus-dormant-mark))
8140 (gnus-mark-article-as-unread article mark)
8141 (gnus-mark-article-as-read article mark)))
8143 ;; See whether the article is to be put in the cache.
8145 (not (= mark gnus-canceled-mark))
8146 (vectorp (gnus-summary-article-header article))
8148 (gnus-cache-possibly-enter-article
8149 gnus-newsgroup-name article
8150 (= mark gnus-ticked-mark)
8151 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8153 (when (gnus-summary-goto-subject article nil t)
8154 (let ((buffer-read-only nil))
8155 (gnus-summary-show-thread)
8157 (gnus-summary-update-mark mark 'unread)
8160 (defun gnus-summary-update-secondary-mark (article)
8161 "Update the secondary (read, process, cache) mark."
8162 (gnus-summary-update-mark
8163 (cond ((memq article gnus-newsgroup-processable)
8165 ((memq article gnus-newsgroup-cached)
8167 ((memq article gnus-newsgroup-replied)
8169 ((memq article gnus-newsgroup-saved)
8171 (t gnus-unread-mark))
8173 (when (gnus-visual-p 'summary-highlight 'highlight)
8174 (gnus-run-hooks 'gnus-summary-update-hook))
8177 (defun gnus-summary-update-mark (mark type)
8178 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
8179 (buffer-read-only nil))
8180 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
8182 (when (looking-at "\r")
8184 (when (<= (+ forward (point)) (point-max))
8185 ;; Go to the right position on the line.
8186 (goto-char (+ forward (point)))
8187 ;; Replace the old mark with the new mark.
8188 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
8189 ;; Optionally update the marks by some user rule.
8190 (when (eq type 'unread)
8192 (gnus-data-find (gnus-summary-article-number)) mark)
8193 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
8195 (defun gnus-mark-article-as-read (article &optional mark)
8196 "Enter ARTICLE in the pertinent lists and remove it from others."
8197 ;; Make the article expirable.
8198 (let ((mark (or mark gnus-del-mark)))
8199 (if (= mark gnus-expirable-mark)
8200 (push article gnus-newsgroup-expirable)
8201 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
8202 ;; Remove from unread and marked lists.
8203 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8204 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8205 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8206 (push (cons article mark) gnus-newsgroup-reads)
8207 ;; Possibly remove from cache, if that is used.
8208 (when gnus-use-cache
8209 (gnus-cache-enter-remove-article article))
8212 (defun gnus-mark-article-as-unread (article &optional mark)
8213 "Enter ARTICLE in the pertinent lists and remove it from others."
8214 (let ((mark (or mark gnus-ticked-mark)))
8217 (gnus-error 1 "Can't mark negative article numbers")
8219 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
8220 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
8221 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
8222 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8224 ;; Unsuppress duplicates?
8225 (when gnus-suppress-duplicates
8226 (gnus-dup-unsuppress-article article))
8228 (cond ((= mark gnus-ticked-mark)
8229 (push article gnus-newsgroup-marked))
8230 ((= mark gnus-dormant-mark)
8231 (push article gnus-newsgroup-dormant))
8233 (push article gnus-newsgroup-unreads)))
8234 (gnus-pull article gnus-newsgroup-reads)
8237 (defalias 'gnus-summary-mark-as-unread-forward
8238 'gnus-summary-tick-article-forward)
8239 (make-obsolete 'gnus-summary-mark-as-unread-forward
8240 'gnus-summary-tick-article-forward)
8241 (defun gnus-summary-tick-article-forward (n)
8242 "Tick N articles forwards.
8243 If N is negative, tick backwards instead.
8244 The difference between N and the number of articles ticked is returned."
8246 (gnus-summary-mark-forward n gnus-ticked-mark))
8248 (defalias 'gnus-summary-mark-as-unread-backward
8249 'gnus-summary-tick-article-backward)
8250 (make-obsolete 'gnus-summary-mark-as-unread-backward
8251 'gnus-summary-tick-article-backward)
8252 (defun gnus-summary-tick-article-backward (n)
8253 "Tick N articles backwards.
8254 The difference between N and the number of articles ticked is returned."
8256 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
8258 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8259 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8260 (defun gnus-summary-tick-article (&optional article clear-mark)
8261 "Mark current article as unread.
8262 Optional 1st argument ARTICLE specifies article number to be marked as unread.
8263 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
8265 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
8268 (defun gnus-summary-mark-as-read-forward (n)
8269 "Mark N articles as read forwards.
8270 If N is negative, mark backwards instead.
8271 The difference between N and the actual number of articles marked is
8274 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
8276 (defun gnus-summary-mark-as-read-backward (n)
8277 "Mark the N articles as read backwards.
8278 The difference between N and the actual number of articles marked is
8281 (gnus-summary-mark-forward
8282 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
8284 (defun gnus-summary-mark-as-read (&optional article mark)
8285 "Mark current article as read.
8286 ARTICLE specifies the article to be marked as read.
8287 MARK specifies a string to be inserted at the beginning of the line."
8288 (gnus-summary-mark-article article mark))
8290 (defun gnus-summary-clear-mark-forward (n)
8291 "Clear marks from N articles forward.
8292 If N is negative, clear backward instead.
8293 The difference between N and the number of marks cleared is returned."
8295 (gnus-summary-mark-forward n gnus-unread-mark))
8297 (defun gnus-summary-clear-mark-backward (n)
8298 "Clear marks from N articles backward.
8299 The difference between N and the number of marks cleared is returned."
8301 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8303 (defun gnus-summary-mark-unread-as-read ()
8304 "Intended to be used by `gnus-summary-mark-article-hook'."
8305 (when (memq gnus-current-article gnus-newsgroup-unreads)
8306 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
8308 (defun gnus-summary-mark-read-and-unread-as-read ()
8309 "Intended to be used by `gnus-summary-mark-article-hook'."
8310 (let ((mark (gnus-summary-article-mark)))
8311 (when (or (gnus-unread-mark-p mark)
8312 (gnus-read-mark-p mark))
8313 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
8315 (defun gnus-summary-mark-region-as-read (point mark all)
8316 "Mark all unread articles between point and mark as read.
8317 If given a prefix, mark all articles between point and mark as read,
8318 even ticked and dormant ones."
8319 (interactive "r\nP")
8328 (memq (setq article (gnus-summary-article-number))
8329 gnus-newsgroup-unreads))
8330 (gnus-summary-mark-article article gnus-del-mark))
8332 (gnus-summary-find-next))))))
8334 (defun gnus-summary-mark-below (score mark)
8335 "Mark articles with score less than SCORE with MARK."
8336 (interactive "P\ncMark: ")
8337 (setq score (if score
8338 (prefix-numeric-value score)
8339 (or gnus-summary-default-score 0)))
8341 (set-buffer gnus-summary-buffer)
8342 (goto-char (point-min))
8345 (and (< (gnus-summary-article-score) score)
8346 (gnus-summary-mark-article nil mark))
8347 (gnus-summary-find-next)))))
8349 (defun gnus-summary-kill-below (&optional score)
8350 "Mark articles with score below SCORE as read."
8352 (gnus-summary-mark-below score gnus-killed-mark))
8354 (defun gnus-summary-clear-above (&optional score)
8355 "Clear all marks from articles with score above SCORE."
8357 (gnus-summary-mark-above score gnus-unread-mark))
8359 (defun gnus-summary-tick-above (&optional score)
8360 "Tick all articles with score above SCORE."
8362 (gnus-summary-mark-above score gnus-ticked-mark))
8364 (defun gnus-summary-mark-above (score mark)
8365 "Mark articles with score over SCORE with MARK."
8366 (interactive "P\ncMark: ")
8367 (setq score (if score
8368 (prefix-numeric-value score)
8369 (or gnus-summary-default-score 0)))
8371 (set-buffer gnus-summary-buffer)
8372 (goto-char (point-min))
8374 (when (> (gnus-summary-article-score) score)
8375 (gnus-summary-mark-article nil mark))
8377 (gnus-summary-find-next)))))
8379 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8380 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
8381 (defun gnus-summary-limit-include-expunged (&optional no-error)
8382 "Display all the hidden articles that were expunged for low scores."
8384 (let ((buffer-read-only nil))
8385 (let ((scored gnus-newsgroup-scored)
8388 (unless (gnus-summary-goto-subject (caar scored))
8389 (and (setq h (gnus-summary-article-header (caar scored)))
8390 (< (cdar scored) gnus-summary-expunge-below)
8392 (setq scored (cdr scored)))
8394 (when (not no-error)
8395 (error "No expunged articles hidden"))
8396 (goto-char (point-min))
8397 (gnus-summary-prepare-unthreaded (nreverse headers))
8398 (goto-char (point-min))
8399 (gnus-summary-position-point)
8402 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
8403 "Mark all unread articles in this newsgroup as read.
8404 If prefix argument ALL is non-nil, ticked and dormant articles will
8405 also be marked as read.
8406 If QUIETLY is non-nil, no questions will be asked.
8407 If TO-HERE is non-nil, it should be a point in the buffer. All
8408 articles before this point will be marked as read.
8409 Note that this function will only catch up the unread article
8410 in the current summary buffer limitation.
8411 The number of articles marked as read is returned."
8416 (not gnus-interactive-catchup) ;Without confirmation?
8420 "Mark absolutely all articles as read? "
8421 "Mark all unread articles as read? ")))
8423 (not gnus-newsgroup-adaptive)
8424 (not gnus-newsgroup-auto-expire)
8425 (not gnus-suppress-duplicates)
8426 (or (not gnus-use-cache)
8427 (eq gnus-use-cache 'passive)))
8430 (setq gnus-newsgroup-marked nil
8431 gnus-newsgroup-dormant nil))
8432 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8433 ;; We actually mark all articles as canceled, which we
8434 ;; have to do when using auto-expiry or adaptive scoring.
8435 (gnus-summary-show-all-threads)
8436 (when (gnus-summary-first-subject (not all) t)
8438 (if to-here (< (point) to-here) t)
8439 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8440 (gnus-summary-find-next (not all) nil nil t))))
8441 (gnus-set-mode-line 'summary))
8443 (gnus-summary-position-point)))
8445 (defun gnus-summary-catchup-to-here (&optional all)
8446 "Mark all unticked articles before the current one as read.
8447 If ALL is non-nil, also mark ticked and dormant articles as read."
8450 (gnus-save-hidden-threads
8451 (let ((beg (point)))
8452 ;; We check that there are unread articles.
8453 (when (or all (gnus-summary-find-prev))
8454 (gnus-summary-catchup all t beg)))))
8455 (gnus-summary-position-point))
8457 (defun gnus-summary-catchup-all (&optional quietly)
8458 "Mark all articles in this newsgroup as read."
8460 (gnus-summary-catchup t quietly))
8462 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8463 "Mark all unread articles in this group as read, then exit.
8464 If prefix argument ALL is non-nil, all articles are marked as read."
8466 (when (gnus-summary-catchup all quietly nil 'fast)
8467 ;; Select next newsgroup or exit.
8468 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
8469 (eq gnus-auto-select-next 'quietly))
8470 (gnus-summary-next-group nil)
8471 (gnus-summary-exit))))
8473 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8474 "Mark all articles in this newsgroup as read, and then exit."
8476 (gnus-summary-catchup-and-exit t quietly))
8478 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8479 "Mark all articles in this group as read and select the next group.
8480 If given a prefix, mark all articles, unread as well as ticked, as
8484 (gnus-summary-catchup all))
8485 (gnus-summary-next-group))
8487 ;; Thread-based commands.
8489 (defun gnus-summary-articles-in-thread (&optional article)
8490 "Return a list of all articles in the current thread.
8491 If ARTICLE is non-nil, return all articles in the thread that starts
8493 (let* ((article (or article (gnus-summary-article-number)))
8494 (data (gnus-data-find-list article))
8495 (top-level (gnus-data-level (car data)))
8497 (cond ((null gnus-thread-operation-ignore-subject)
8498 (gnus-simplify-subject-re
8499 (mail-header-subject (gnus-data-header (car data)))))
8500 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8501 (gnus-simplify-subject-fuzzy
8502 (mail-header-subject (gnus-data-header (car data)))))
8504 (end-point (save-excursion
8505 (if (gnus-summary-go-to-next-thread)
8506 (point) (point-max))))
8509 (< (gnus-data-pos (car data)) end-point))
8510 (when (or (not top-subject)
8511 (string= top-subject
8512 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8513 (gnus-simplify-subject-fuzzy
8514 (mail-header-subject
8515 (gnus-data-header (car data))))
8516 (gnus-simplify-subject-re
8517 (mail-header-subject
8518 (gnus-data-header (car data)))))))
8519 (push (gnus-data-number (car data)) articles))
8520 (unless (and (setq data (cdr data))
8521 (> (gnus-data-level (car data)) top-level))
8523 ;; Return the list of articles.
8524 (nreverse articles)))
8526 (defun gnus-summary-rethread-current ()
8527 "Rethread the thread the current article is part of."
8529 (let* ((gnus-show-threads t)
8530 (article (gnus-summary-article-number))
8531 (id (mail-header-id (gnus-summary-article-header)))
8532 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8534 (error "No article on the current line"))
8535 (gnus-rebuild-thread id)
8536 (gnus-summary-goto-subject article)))
8538 (defun gnus-summary-reparent-thread ()
8539 "Make the current article child of the marked (or previous) article.
8541 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8542 is non-nil or the Subject: of both articles are the same."
8544 (unless (not (gnus-group-read-only-p))
8545 (error "The current newsgroup does not support article editing"))
8546 (unless (<= (length gnus-newsgroup-processable) 1)
8547 (error "No more than one article may be marked"))
8548 (save-window-excursion
8549 (let ((gnus-article-buffer " *reparent*")
8550 (current-article (gnus-summary-article-number))
8551 ;; First grab the marked article, otherwise one line up.
8552 (parent-article (if (not (null gnus-newsgroup-processable))
8553 (car gnus-newsgroup-processable)
8555 (if (eq (forward-line -1) 0)
8556 (gnus-summary-article-number)
8557 (error "Beginning of summary buffer"))))))
8558 (unless (not (eq current-article parent-article))
8559 (error "An article may not be self-referential"))
8560 (let ((message-id (mail-header-id
8561 (gnus-summary-article-header parent-article))))
8562 (unless (and message-id (not (equal message-id "")))
8563 (error "No message-id in desired parent"))
8564 (gnus-with-article current-article
8565 (goto-char (point-min))
8566 (if (re-search-forward "^References: " nil t)
8568 (re-search-forward "^[^ \t]" nil t)
8571 (insert " " message-id))
8572 (insert "References: " message-id "\n")))
8573 (set-buffer gnus-summary-buffer)
8574 (gnus-summary-unmark-all-processable)
8575 (gnus-summary-update-article current-article)
8576 (gnus-summary-rethread-current)
8577 (gnus-message 3 "Article %d is now the child of article %d"
8578 current-article parent-article)))))
8580 (defun gnus-summary-toggle-threads (&optional arg)
8581 "Toggle showing conversation threads.
8582 If ARG is positive number, turn showing conversation threads on."
8584 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8585 (setq gnus-show-threads
8586 (if (null arg) (not gnus-show-threads)
8587 (> (prefix-numeric-value arg) 0)))
8588 (gnus-summary-prepare)
8589 (gnus-summary-goto-subject current)
8590 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8591 (gnus-summary-position-point)))
8593 (defun gnus-summary-show-all-threads ()
8597 (let ((buffer-read-only nil))
8598 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8599 (gnus-summary-position-point))
8601 (defun gnus-summary-show-thread ()
8602 "Show thread subtrees.
8603 Returns nil if no thread was there to be shown."
8605 (let ((buffer-read-only nil)
8607 ;; first goto end then to beg, to have point at beg after let
8608 (end (progn (end-of-line) (point)))
8609 (beg (progn (beginning-of-line) (point))))
8611 ;; Any hidden lines here?
8612 (search-forward "\r" end t)
8613 (subst-char-in-region beg end ?\^M ?\n t)
8615 (gnus-summary-position-point))))
8617 (defun gnus-summary-hide-all-threads ()
8618 "Hide all thread subtrees."
8621 (goto-char (point-min))
8622 (gnus-summary-hide-thread)
8623 (while (zerop (gnus-summary-next-thread 1 t))
8624 (gnus-summary-hide-thread)))
8625 (gnus-summary-position-point))
8627 (defun gnus-summary-hide-thread ()
8628 "Hide thread subtrees.
8629 Returns nil if no threads were there to be hidden."
8631 (let ((buffer-read-only nil)
8633 (article (gnus-summary-article-number)))
8635 ;; Go forward until either the buffer ends or the subthread
8637 (when (and (not (eobp))
8638 (or (zerop (gnus-summary-next-thread 1 t))
8639 (goto-char (point-max))))
8641 (if (and (> (point) start)
8642 (search-backward "\n" start t))
8644 (subst-char-in-region start (point) ?\n ?\^M)
8645 (gnus-summary-goto-subject article))
8649 (defun gnus-summary-go-to-next-thread (&optional previous)
8650 "Go to the same level (or less) next thread.
8651 If PREVIOUS is non-nil, go to previous thread instead.
8652 Return the article number moved to, or nil if moving was impossible."
8653 (let ((level (gnus-summary-thread-level))
8654 (way (if previous -1 1))
8657 (while (and (not (eobp))
8658 (< level (gnus-summary-thread-level)))
8666 (gnus-summary-article-number)
8669 (defun gnus-summary-next-thread (n &optional silent)
8670 "Go to the same level next N'th thread.
8671 If N is negative, search backward instead.
8672 Returns the difference between N and the number of skips actually
8675 If SILENT, don't output messages."
8677 (let ((backward (< n 0))
8680 (gnus-summary-go-to-next-thread backward))
8683 (gnus-summary-position-point))
8684 (when (and (not silent) (/= 0 n))
8685 (gnus-message 7 "No more threads"))
8688 (defun gnus-summary-prev-thread (n)
8689 "Go to the same level previous N'th thread.
8690 Returns the difference between N and the number of skips actually
8693 (gnus-summary-next-thread (- n)))
8695 (defun gnus-summary-go-down-thread ()
8696 "Go down one level in the current thread."
8697 (let ((children (gnus-summary-article-children)))
8699 (gnus-summary-goto-subject (car children)))))
8701 (defun gnus-summary-go-up-thread ()
8702 "Go up one level in the current thread."
8703 (let ((parent (gnus-summary-article-parent)))
8705 (gnus-summary-goto-subject parent))))
8707 (defun gnus-summary-down-thread (n)
8708 "Go down thread N steps.
8709 If N is negative, go up instead.
8710 Returns the difference between N and how many steps down that were
8716 (if up (gnus-summary-go-up-thread)
8717 (gnus-summary-go-down-thread)))
8719 (gnus-summary-position-point)
8721 (gnus-message 7 "Can't go further"))
8724 (defun gnus-summary-up-thread (n)
8725 "Go up thread N steps.
8726 If N is negative, go up instead.
8727 Returns the difference between N and how many steps down that were
8730 (gnus-summary-down-thread (- n)))
8732 (defun gnus-summary-top-thread ()
8733 "Go to the top of the thread."
8735 (while (gnus-summary-go-up-thread))
8736 (gnus-summary-article-number))
8738 (defun gnus-summary-kill-thread (&optional unmark)
8739 "Mark articles under current thread as read.
8740 If the prefix argument is positive, remove any kinds of marks.
8741 If the prefix argument is negative, tick articles instead."
8744 (setq unmark (prefix-numeric-value unmark)))
8745 (let ((articles (gnus-summary-articles-in-thread)))
8747 ;; Expand the thread.
8748 (gnus-summary-show-thread)
8749 ;; Mark all the articles.
8751 (gnus-summary-goto-subject (car articles))
8752 (cond ((null unmark)
8753 (gnus-summary-mark-article-as-read gnus-killed-mark))
8755 (gnus-summary-mark-article-as-unread gnus-unread-mark))
8757 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
8758 (setq articles (cdr articles))))
8759 ;; Hide killed subtrees.
8761 gnus-thread-hide-killed
8762 (gnus-summary-hide-thread))
8763 ;; If marked as read, go to next unread subject.
8765 ;; Go to next unread subject.
8766 (gnus-summary-next-subject 1 t)))
8767 (gnus-set-mode-line 'summary))
8769 ;; Summary sorting commands
8771 (defun gnus-summary-sort-by-number (&optional reverse)
8772 "Sort the summary buffer by article number.
8773 Argument REVERSE means reverse order."
8775 (gnus-summary-sort 'number reverse))
8777 (defun gnus-summary-sort-by-author (&optional reverse)
8778 "Sort the summary buffer by author name alphabetically.
8779 If case-fold-search is non-nil, case of letters is ignored.
8780 Argument REVERSE means reverse order."
8782 (gnus-summary-sort 'author reverse))
8784 (defun gnus-summary-sort-by-subject (&optional reverse)
8785 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8786 If case-fold-search is non-nil, case of letters is ignored.
8787 Argument REVERSE means reverse order."
8789 (gnus-summary-sort 'subject reverse))
8791 (defun gnus-summary-sort-by-date (&optional reverse)
8792 "Sort the summary buffer by date.
8793 Argument REVERSE means reverse order."
8795 (gnus-summary-sort 'date reverse))
8797 (defun gnus-summary-sort-by-score (&optional reverse)
8798 "Sort the summary buffer by score.
8799 Argument REVERSE means reverse order."
8801 (gnus-summary-sort 'score reverse))
8803 (defun gnus-summary-sort-by-lines (&optional reverse)
8804 "Sort the summary buffer by the number of lines.
8805 Argument REVERSE means reverse order."
8807 (gnus-summary-sort 'lines reverse))
8809 (defun gnus-summary-sort-by-chars (&optional reverse)
8810 "Sort the summary buffer by article length.
8811 Argument REVERSE means reverse order."
8813 (gnus-summary-sort 'chars reverse))
8815 (defun gnus-summary-sort (predicate reverse)
8816 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
8817 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
8818 (article (intern (format "gnus-article-sort-by-%s" predicate)))
8819 (gnus-thread-sort-functions
8824 (gnus-article-sort-functions
8830 (gnus-summary-prepare-hook nil))
8831 ;; We do the sorting by regenerating the threads.
8832 (gnus-summary-prepare)
8833 ;; Hide subthreads if needed.
8834 (when (and gnus-show-threads gnus-thread-hide-subtree)
8835 (gnus-summary-hide-all-threads))))
8837 ;; Summary saving commands.
8839 (defun gnus-summary-save-article (&optional n not-saved)
8840 "Save the current article using the default saver function.
8841 If N is a positive number, save the N next articles.
8842 If N is a negative number, save the N previous articles.
8843 If N is nil and any articles have been marked with the process mark,
8844 save those articles instead.
8845 The variable `gnus-default-article-saver' specifies the saver function."
8847 (let* ((articles (gnus-summary-work-articles n))
8848 (save-buffer (save-excursion
8849 (nnheader-set-temp-buffer " *Gnus Save*")))
8850 (num (length articles))
8852 (dolist (article articles)
8853 (setq header (gnus-summary-article-header article))
8854 (if (not (vectorp header))
8855 ;; This is a pseudo-article.
8856 (if (assq 'name header)
8857 (gnus-copy-file (cdr (assq 'name header)))
8858 (gnus-message 1 "Article %d is unsaveable" article))
8859 ;; This is a real article.
8860 (save-window-excursion
8861 (gnus-summary-select-article t nil nil article))
8863 (set-buffer save-buffer)
8865 (insert-buffer-substring gnus-original-article-buffer))
8866 (setq file (gnus-article-save save-buffer file num))
8867 (gnus-summary-remove-process-mark article)
8869 (gnus-summary-set-saved-mark article))))
8870 (gnus-kill-buffer save-buffer)
8871 (gnus-summary-position-point)
8872 (gnus-set-mode-line 'summary)
8875 (defun gnus-summary-pipe-output (&optional arg)
8876 "Pipe the current article to a subprocess.
8877 If N is a positive number, pipe the N next articles.
8878 If N is a negative number, pipe the N previous articles.
8879 If N is nil and any articles have been marked with the process mark,
8880 pipe those articles instead."
8882 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8883 (gnus-summary-save-article arg t))
8884 (gnus-configure-windows 'pipe))
8886 (defun gnus-summary-save-article-mail (&optional arg)
8887 "Append the current article to an mail file.
8888 If N is a positive number, save the N next articles.
8889 If N is a negative number, save the N previous articles.
8890 If N is nil and any articles have been marked with the process mark,
8891 save those articles instead."
8893 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8894 (gnus-summary-save-article arg)))
8896 (defun gnus-summary-save-article-rmail (&optional arg)
8897 "Append the current article to an rmail file.
8898 If N is a positive number, save the N next articles.
8899 If N is a negative number, save the N previous articles.
8900 If N is nil and any articles have been marked with the process mark,
8901 save those articles instead."
8903 (let ((gnus-default-article-saver 'rmail-output-to-rmail-file))
8904 (gnus-summary-save-article arg)))
8906 (defun gnus-summary-save-article-file (&optional arg)
8907 "Append the current article to a file.
8908 If N is a positive number, save the N next articles.
8909 If N is a negative number, save the N previous articles.
8910 If N is nil and any articles have been marked with the process mark,
8911 save those articles instead."
8913 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8914 (gnus-summary-save-article arg)))
8916 (defun gnus-summary-write-article-file (&optional arg)
8917 "Write the current article to a file, deleting the previous file.
8918 If N is a positive number, save the N next articles.
8919 If N is a negative number, save the N previous articles.
8920 If N is nil and any articles have been marked with the process mark,
8921 save those articles instead."
8923 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
8924 (gnus-summary-save-article arg)))
8926 (defun gnus-summary-save-article-body-file (&optional arg)
8927 "Append the current article body to a file.
8928 If N is a positive number, save the N next articles.
8929 If N is a negative number, save the N previous articles.
8930 If N is nil and any articles have been marked with the process mark,
8931 save those articles instead."
8933 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
8934 (gnus-summary-save-article arg)))
8936 (defun gnus-summary-pipe-message (program)
8937 "Pipe the current article through PROGRAM."
8938 (interactive "sProgram: ")
8939 (gnus-summary-select-article)
8940 (let ((mail-header-separator ""))
8941 (gnus-eval-in-buffer-window gnus-article-buffer
8944 (let ((start (window-start))
8946 (message-pipe-buffer-body program)
8947 (set-window-start (get-buffer-window (current-buffer)) start))))))
8949 (defun gnus-get-split-value (methods)
8950 "Return a value based on the split METHODS."
8951 (let (split-name method result match)
8954 (set-buffer gnus-original-article-buffer)
8956 (nnheader-narrow-to-headers)
8958 (goto-char (point-min))
8959 (setq method (pop methods))
8960 (setq match (car method))
8963 ;; Regular expression.
8965 (re-search-forward match nil t)))
8966 ((gnus-functionp match)
8970 (setq result (funcall match gnus-newsgroup-name))))
8975 (setq result (eval match)))))
8976 (setq split-name (append (cdr method) split-name))
8977 (cond ((stringp result)
8978 (push (expand-file-name
8979 result gnus-article-save-directory)
8982 (setq split-name (append result split-name)))))))))
8983 (nreverse split-name)))
8985 (defun gnus-valid-move-group-p (group)
8988 (symbol-value group)
8989 (gnus-get-function (gnus-find-method-for-group
8990 (symbol-name group)) 'request-accept-article t)))
8992 (defun gnus-read-move-group-name (prompt default articles prefix)
8993 "Read a group name."
8994 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
8995 (minibuffer-confirm-incomplete nil) ; XEmacs
8999 (if (> (length articles) 1)
9000 (format "these %d articles" (length articles))
9005 (gnus-completing-read default prom
9007 'gnus-valid-move-group-p
9009 'gnus-group-history))
9010 ((= 1 (length split-name))
9011 (gnus-completing-read (car split-name) prom
9013 'gnus-valid-move-group-p
9015 'gnus-group-history))
9017 (gnus-completing-read nil prom
9018 (mapcar (lambda (el) (list el))
9019 (nreverse split-name))
9021 'gnus-group-history)))))
9023 (if (or (string= to-newsgroup "")
9024 (string= to-newsgroup prefix))
9025 (setq to-newsgroup default))
9026 (unless to-newsgroup
9027 (error "No group name entered"))
9028 (or (gnus-active to-newsgroup)
9029 (gnus-activate-group to-newsgroup)
9030 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
9032 (or (and (gnus-request-create-group
9033 to-newsgroup (gnus-group-name-to-method to-newsgroup))
9034 (gnus-activate-group
9035 to-newsgroup nil nil
9036 (gnus-group-name-to-method to-newsgroup))
9037 (gnus-subscribe-group to-newsgroup))
9038 (error "Couldn't create group %s" to-newsgroup)))
9039 (error "No such group: %s" to-newsgroup)))
9042 (defun gnus-summary-save-parts (type dir n reverse)
9043 "Save parts matching TYPE to DIR.
9044 If REVERSE, save parts that do not match TYPE."
9046 (list (read-string "Save parts of type: " "image/.*")
9047 (read-file-name "Save to directory: " t nil t)
9048 current-prefix-arg))
9049 (gnus-summary-iterate n
9050 (let ((gnus-display-mime-function nil)
9051 (gnus-inhibit-treatment t))
9052 (gnus-summary-select-article))
9054 (set-buffer gnus-article-buffer)
9055 (let ((handles (or (mm-dissect-buffer) (mm-uu-dissect))))
9057 (gnus-summary-save-parts-1 type dir handles reverse)
9058 (mm-destroy-parts handles))))))
9060 (defun gnus-summary-save-parts-1 (type dir handle reverse)
9061 (if (stringp (car handle))
9062 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
9065 (not (string-match type (mm-handle-media-type handle)))
9066 (string-match type (mm-handle-media-type handle)))
9067 (let ((file (expand-file-name
9068 (file-name-nondirectory
9070 (mail-content-type-get
9071 (mm-handle-disposition handle) 'filename)
9072 (concat gnus-newsgroup-name "." gnus-current-article)))
9074 (unless (file-exists-p file)
9075 (mm-save-part-to-file handle file))))))
9077 ;; Summary extract commands
9079 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
9080 (let ((buffer-read-only nil)
9081 (article (gnus-summary-article-number))
9083 (unless (gnus-summary-goto-subject article)
9084 (error "No such article: %d" article))
9085 (gnus-summary-position-point)
9086 ;; If all commands are to be bunched up on one line, we collect
9088 (unless gnus-view-pseudos-separately
9089 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
9092 (setq action (cdr (assq 'action (car ps))))
9093 (setq files (list (cdr (assq 'name (car ps)))))
9094 (while (and ps (cdr ps)
9095 (string= (or action "1")
9096 (or (cdr (assq 'action (cadr ps))) "2")))
9097 (push (cdr (assq 'name (cadr ps))) files)
9098 (setcdr ps (cddr ps)))
9100 (when (not (string-match "%s" action))
9103 (when (assq 'execute (car ps))
9104 (setcdr (assq 'execute (car ps))
9105 (funcall (if (string-match "%s" action)
9114 (setq ps (cdr ps)))))
9115 (if (and gnus-view-pseudos (not not-view))
9117 (when (assq 'execute (car pslist))
9118 (gnus-execute-command (cdr (assq 'execute (car pslist)))
9119 (eq gnus-view-pseudos 'not-confirm)))
9120 (setq pslist (cdr pslist)))
9123 (setq after-article (or (cdr (assq 'article (car pslist)))
9124 (gnus-summary-article-number)))
9125 (gnus-summary-goto-subject after-article)
9128 (insert " " (file-name-nondirectory
9129 (cdr (assq 'name (car pslist))))
9130 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
9132 (forward-line -1) ; back to `b'
9133 (gnus-add-text-properties
9134 b (1- e) (list 'gnus-number gnus-reffed-article-number
9135 gnus-mouse-face-prop gnus-mouse-face))
9137 after-article gnus-reffed-article-number
9138 gnus-unread-mark b (car pslist) 0 (- e b))
9139 (push gnus-reffed-article-number gnus-newsgroup-unreads)
9140 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
9141 (setq pslist (cdr pslist)))))))
9143 (defun gnus-pseudos< (p1 p2)
9144 (let ((c1 (cdr (assq 'action p1)))
9145 (c2 (cdr (assq 'action p2))))
9146 (and c1 c2 (string< c1 c2))))
9148 (defun gnus-request-pseudo-article (props)
9149 (cond ((assq 'execute props)
9150 (gnus-execute-command (cdr (assq 'execute props)))))
9151 (let ((gnus-current-article (gnus-summary-article-number)))
9152 (gnus-run-hooks 'gnus-mark-article-hook)))
9154 (defun gnus-execute-command (command &optional automatic)
9156 (gnus-article-setup-buffer)
9157 (set-buffer gnus-article-buffer)
9158 (setq buffer-read-only nil)
9159 (let ((command (if automatic command
9160 (read-string "Command: " (cons command 0)))))
9162 (insert "$ " command "\n\n")
9163 (if gnus-view-pseudo-asynchronously
9164 (start-process "gnus-execute" (current-buffer) shell-file-name
9165 shell-command-switch command)
9166 (call-process shell-file-name nil t nil
9167 shell-command-switch command)))))
9169 ;; Summary kill commands.
9171 (defun gnus-summary-edit-global-kill (article)
9172 "Edit the \"global\" kill file."
9173 (interactive (list (gnus-summary-article-number)))
9174 (gnus-group-edit-global-kill article))
9176 (defun gnus-summary-edit-local-kill ()
9177 "Edit a local kill file applied to the current newsgroup."
9179 (setq gnus-current-headers (gnus-summary-article-header))
9180 (gnus-group-edit-local-kill
9181 (gnus-summary-article-number) gnus-newsgroup-name))
9185 (defun gnus-read-header (id &optional header)
9186 "Read the headers of article ID and enter them into the Gnus system."
9187 (let ((group gnus-newsgroup-name)
9188 (gnus-override-method
9190 gnus-override-method
9191 (and (gnus-news-group-p gnus-newsgroup-name)
9192 (car (gnus-refer-article-methods)))))
9194 ;; First we check to see whether the header in question is already
9197 ;; This is a Message-ID.
9198 (setq header (or header (gnus-id-to-header id)))
9199 ;; This is an article number.
9200 (setq header (or header (gnus-summary-article-header id))))
9202 (not (gnus-summary-article-sparse-p (mail-header-number header))))
9203 ;; We have found the header.
9205 ;; If this is a sparse article, we have to nix out its
9206 ;; previous entry in the thread hashtb.
9208 (gnus-summary-article-sparse-p (mail-header-number header)))
9209 (let* ((parent (gnus-parent-id (mail-header-references header)))
9210 (thread (and parent (gnus-id-to-thread parent))))
9212 (delq (assq header thread) thread))))
9213 ;; We have to really fetch the header to this article.
9215 (set-buffer nntp-server-buffer)
9216 (when (setq where (gnus-request-head id group))
9217 (nnheader-fold-continuation-lines)
9218 (goto-char (point-max))
9220 (goto-char (point-min))
9224 ((cdr where) (cdr where))
9225 (header (mail-header-number header))
9226 (t gnus-reffed-article-number))
9228 (insert " Article retrieved.\n"))
9230 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
9231 () ; Malformed head.
9232 (unless (gnus-summary-article-sparse-p (mail-header-number header))
9233 (when (and (stringp id)
9234 (not (string= (gnus-group-real-name group)
9236 ;; If we fetched by Message-ID and the article came
9237 ;; from a different group, we fudge some bogus article
9238 ;; numbers for this article.
9239 (mail-header-set-number header gnus-reffed-article-number))
9241 (set-buffer gnus-summary-buffer)
9242 (decf gnus-reffed-article-number)
9243 (gnus-remove-header (mail-header-number header))
9244 (push header gnus-newsgroup-headers)
9245 (setq gnus-current-headers header)
9246 (push (mail-header-number header) gnus-newsgroup-limit)))
9249 (defun gnus-remove-header (number)
9250 "Remove header NUMBER from `gnus-newsgroup-headers'."
9251 (if (and gnus-newsgroup-headers
9252 (= number (mail-header-number (car gnus-newsgroup-headers))))
9253 (pop gnus-newsgroup-headers)
9254 (let ((headers gnus-newsgroup-headers))
9255 (while (and (cdr headers)
9256 (not (= number (mail-header-number (cadr headers)))))
9259 (setcdr headers (cddr headers))))))
9262 ;;; summary highlights
9265 (defun gnus-highlight-selected-summary ()
9266 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
9267 ;; Highlight selected article in summary buffer
9268 (when gnus-summary-selected-face
9270 (let* ((beg (progn (beginning-of-line) (point)))
9271 (end (progn (end-of-line) (point)))
9272 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
9273 (from (if (get-text-property beg gnus-mouse-face-prop)
9275 (or (next-single-property-change
9276 beg gnus-mouse-face-prop nil end)
9281 (or (next-single-property-change
9282 from gnus-mouse-face-prop nil end)
9284 ;; If no mouse-face prop on line we will have to = from = end,
9285 ;; so we highlight the entire line instead.
9286 (when (= (+ to 2) from)
9289 (if gnus-newsgroup-selected-overlay
9290 ;; Move old overlay.
9292 gnus-newsgroup-selected-overlay from to (current-buffer))
9293 ;; Create new overlay.
9295 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
9296 'face gnus-summary-selected-face))))))
9298 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
9299 (defun gnus-summary-highlight-line ()
9300 "Highlight current line according to `gnus-summary-highlight'."
9301 (let* ((list gnus-summary-highlight)
9303 (end (progn (end-of-line) (point)))
9304 ;; now find out where the line starts and leave point there.
9305 (beg (progn (beginning-of-line) (point)))
9306 (article (gnus-summary-article-number))
9307 (score (or (cdr (assq (or article gnus-current-article)
9308 gnus-newsgroup-scored))
9309 gnus-summary-default-score 0))
9310 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
9311 (inhibit-read-only t))
9312 ;; Eval the cars of the lists until we find a match.
9313 (let ((default gnus-summary-default-score))
9315 (not (eval (caar list))))
9316 (setq list (cdr list))))
9317 (let ((face (cdar list)))
9318 (unless (eq face (get-text-property beg 'face))
9319 (gnus-put-text-property-excluding-characters-with-faces
9321 (setq face (if (boundp face) (symbol-value face) face)))
9322 (when gnus-summary-highlight-line-function
9323 (funcall gnus-summary-highlight-line-function article face))))
9326 (defun gnus-update-read-articles (group unread &optional compute)
9327 "Update the list of read articles in GROUP."
9328 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
9329 (entry (gnus-gethash group gnus-newsrc-hashtb))
9330 (info (nth 2 entry))
9332 (unread (sort (copy-sequence unread) '<))
9334 (if (or (not info) (not active))
9335 ;; There is no info on this group if it was, in fact,
9336 ;; killed. Gnus stores no information on killed groups, so
9337 ;; there's nothing to be done.
9338 ;; One could store the information somewhere temporarily,
9339 ;; perhaps... Hmmm...
9341 ;; Remove any negative articles numbers.
9342 (while (and unread (< (car unread) 0))
9343 (setq unread (cdr unread)))
9344 ;; Remove any expired article numbers
9345 (while (and unread (< (car unread) (car active)))
9346 (setq unread (cdr unread)))
9347 ;; Compute the ranges of read articles by looking at the list of
9350 (when (/= (car unread) prev)
9351 (push (if (= prev (1- (car unread))) prev
9352 (cons prev (1- (car unread))))
9354 (setq prev (1+ (car unread)))
9355 (setq unread (cdr unread)))
9356 (when (<= prev (cdr active))
9357 (push (cons prev (cdr active)) read))
9358 (setq read (if (> (length read) 1) (nreverse read) read))
9362 (set-buffer gnus-group-buffer)
9365 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
9366 (gnus-info-set-read ',info ',(gnus-info-read info))
9367 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
9368 (gnus-group-update-group ,group t))))
9369 ;; Propagate the read marks to the backend.
9370 (if (gnus-check-backend-function 'request-set-mark group)
9371 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
9372 (add (gnus-remove-from-range read (gnus-info-read info))))
9374 (unless (gnus-check-group group)
9375 (error "Can't open server for %s" group))
9376 (gnus-request-set-mark
9377 group (delq nil (list (if add (list add 'add '(read)))
9378 (if del (list del 'del '(read)))))))))
9379 ;; Enter this list into the group info.
9380 (gnus-info-set-read info read)
9381 ;; Set the number of unread articles in gnus-newsrc-hashtb.
9382 (gnus-get-unread-articles-in-group info (gnus-active group))
9385 (defun gnus-offer-save-summaries ()
9386 "Offer to save all active summary buffers."
9388 (let ((buflist (buffer-list))
9390 ;; Go through all buffers and find all summaries.
9392 (and (setq bufname (buffer-name (car buflist)))
9393 (string-match "Summary" bufname)
9395 (set-buffer bufname)
9396 ;; We check that this is, indeed, a summary buffer.
9397 (and (eq major-mode 'gnus-summary-mode)
9398 ;; Also make sure this isn't bogus.
9399 gnus-newsgroup-prepared
9400 ;; Also make sure that this isn't a dead summary buffer.
9401 (not gnus-dead-summary-mode)))
9402 (push bufname buffers))
9403 (setq buflist (cdr buflist)))
9404 ;; Go through all these summary buffers and offer to save them.
9407 "Update summary buffer %s? "
9409 (switch-to-buffer buf)
9410 (gnus-summary-exit))
9413 (defun gnus-summary-setup-default-charset ()
9414 "Setup newsgroup default charset."
9415 (if (equal gnus-newsgroup-name "nndraft:drafts")
9416 (setq gnus-newsgroup-charset nil)
9417 (let* ((name (and gnus-newsgroup-name
9418 (gnus-group-real-name gnus-newsgroup-name)))
9420 (or gnus-newsgroup-ephemeral-ignored-charsets
9422 (and gnus-newsgroup-name
9423 (or (gnus-group-find-parameter gnus-newsgroup-name
9424 'ignored-charsets t)
9425 (let ((alist gnus-group-ignored-charsets-alist)
9426 elem (charsets nil))
9427 (while (setq elem (pop alist))
9429 (string-match (car elem) name))
9431 charsets (cdr elem))))
9433 gnus-newsgroup-ignored-charsets))))
9434 (setq gnus-newsgroup-charset
9435 (or gnus-newsgroup-ephemeral-charset
9436 (and gnus-newsgroup-name
9437 (or (gnus-group-find-parameter gnus-newsgroup-name 'charset)
9438 (let ((alist gnus-group-charset-alist)
9440 (while (setq elem (pop alist))
9442 (string-match (car elem) name))
9444 charset (cadr elem))))
9446 gnus-default-charset))
9447 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
9448 ignored-charsets))))
9454 (defun gnus-summary-display-buttonized (&optional show-all-parts)
9455 "Display the current article buffer fully MIME-buttonized.
9456 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
9457 treated as multipart/mixed."
9460 (let ((gnus-unbuttonized-mime-types nil)
9461 (gnus-mime-display-multipart-as-mixed show-all-parts))
9462 (gnus-summary-show-article)))
9464 (defun gnus-summary-repair-multipart (article)
9465 "Add a Content-Type header to a multipart article without one."
9466 (interactive (list (gnus-summary-article-number)))
9467 (gnus-with-article article
9468 (message-narrow-to-head)
9469 (goto-char (point-max))
9471 (when (search-forward "\n--" nil t)
9472 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
9473 (message-narrow-to-head)
9474 (message-remove-header "Mime-Version")
9475 (message-remove-header "Content-Type")
9476 (goto-char (point-max))
9477 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
9479 (insert "Mime-Version: 1.0\n")
9481 (let (gnus-mark-article-hook)
9482 (gnus-summary-select-article t t nil article)))
9484 (defun gnus-summary-toggle-display-buttonized ()
9485 "Toggle the buttonizing of the article buffer."
9488 (if (setq gnus-inhibit-mime-unbuttonizing
9489 (not gnus-inhibit-mime-unbuttonizing))
9490 (let ((gnus-unbuttonized-mime-types nil))
9491 (gnus-summary-show-article))
9492 (gnus-summary-show-article)))
9498 (defmacro gnus-with-article (article &rest forms)
9499 "Select ARTICLE and perform FORMS in the original article buffer.
9500 Then replace the article with the result."
9502 ;; We don't want the article to be marked as read.
9503 (let (gnus-mark-article-hook)
9504 (gnus-summary-select-article t t nil ,article))
9505 (set-buffer gnus-original-article-buffer)
9507 (if (not (gnus-check-backend-function
9508 'request-replace-article (car gnus-article-current)))
9509 (gnus-message 5 "Read-only group; not replacing")
9510 (unless (gnus-request-replace-article
9511 ,article (car gnus-article-current)
9513 (error "Couldn't replace article")))
9514 ;; The cache and backlog have to be flushed somewhat.
9515 (when gnus-keep-backlog
9516 (gnus-backlog-remove-article
9517 (car gnus-article-current) (cdr gnus-article-current)))
9518 (when gnus-use-cache
9519 (gnus-cache-update-article
9520 (car gnus-article-current) (cdr gnus-article-current)))))
9522 (put 'gnus-with-article 'lisp-indent-function 1)
9523 (put 'gnus-with-article 'edebug-form-spec '(form body))
9526 ;;; Generic summary marking commands
9529 (defvar gnus-summary-marking-alist
9530 '((read gnus-del-mark "d")
9531 (unread gnus-unread-mark "u")
9532 (ticked gnus-ticked-mark "!")
9533 (dormant gnus-dormant-mark "?")
9534 (expirable gnus-expirable-mark "e"))
9535 "An alist of names/marks/keystrokes.")
9537 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
9538 (defvar gnus-summary-mark-map)
9540 (defun gnus-summary-make-all-marking-commands ()
9541 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
9542 (dolist (elem gnus-summary-marking-alist)
9543 (apply 'gnus-summary-make-marking-command elem)))
9545 (defun gnus-summary-make-marking-command (name mark keystroke)
9546 (let ((map (make-sparse-keymap)))
9547 (define-key gnus-summary-generic-mark-map keystroke map)
9548 (dolist (lway `((next "next" next nil "n")
9549 (next-unread "next unread" next t "N")
9550 (prev "previous" prev nil "p")
9551 (prev-unread "previous unread" prev t "P")
9552 (nomove "" nil nil ,keystroke)))
9553 (let ((func (gnus-summary-make-marking-command-1
9554 mark (car lway) lway name)))
9555 (setq func (eval func))
9556 (define-key map (nth 4 lway) func)))))
9558 (defun gnus-summary-make-marking-command-1 (mark way lway name)
9560 (format "gnus-summary-put-mark-as-%s%s"
9561 name (if (eq way 'nomove)
9563 (concat "-" (symbol-name way)))))
9566 "Mark the current article as %s%s.
9567 If N, the prefix, then repeat N times.
9568 If N is negative, move in reverse order.
9569 The difference between N and the actual number of articles marked is
9573 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
9575 (defun gnus-summary-generic-mark (n mark move unread)
9576 "Mark N articles with MARK."
9577 (unless (eq major-mode 'gnus-summary-mode)
9578 (error "This command can only be used in the summary buffer"))
9579 (gnus-summary-show-thread)
9583 ((eq move 'prev) -1)
9589 nummove (* -1 nummove))))
9591 (gnus-summary-mark-article nil mark)
9592 (zerop (gnus-summary-next-subject nummove unread t)))
9595 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9596 (gnus-summary-recenter)
9597 (gnus-summary-position-point)
9598 (gnus-set-mode-line 'summary)
9601 (gnus-summary-make-all-marking-commands)
9607 (run-hooks 'gnus-sum-load-hook)
9609 ;;; gnus-sum.el ends here