1 ;;; gnus-sum.el --- summary mode commands for Gnus
2 ;; Copyright (C) 1996-2000 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 summary mode.
700 This hook is not called from the non-updating exit commands like `Q'."
704 (defcustom gnus-summary-update-hook
705 (list 'gnus-summary-highlight-line)
706 "*A hook called when a summary line is changed.
707 The hook will not be called if `gnus-visual' is nil.
709 The default function `gnus-summary-highlight-line' will
710 highlight the line according to the `gnus-summary-highlight'
712 :group 'gnus-summary-visual
715 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
716 "*A hook called when an article is selected for the first time.
717 The hook is intended to mark an article as read (or unread)
718 automatically when it is selected."
719 :group 'gnus-summary-choose
722 (defcustom gnus-group-no-more-groups-hook nil
723 "*A hook run when returning to group mode having no more (unread) groups."
724 :group 'gnus-group-select
727 (defcustom gnus-ps-print-hook nil
728 "*A hook run before ps-printing something from Gnus."
732 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
733 "Face used for highlighting the current article in the summary buffer."
734 :group 'gnus-summary-visual
737 (defcustom gnus-summary-highlight
738 '(((= mark gnus-canceled-mark)
739 . gnus-summary-cancelled-face)
740 ((and (> score default)
741 (or (= mark gnus-dormant-mark)
742 (= mark gnus-ticked-mark)))
743 . gnus-summary-high-ticked-face)
744 ((and (< score default)
745 (or (= mark gnus-dormant-mark)
746 (= mark gnus-ticked-mark)))
747 . gnus-summary-low-ticked-face)
748 ((or (= mark gnus-dormant-mark)
749 (= mark gnus-ticked-mark))
750 . gnus-summary-normal-ticked-face)
751 ((and (> score default) (= mark gnus-ancient-mark))
752 . gnus-summary-high-ancient-face)
753 ((and (< score default) (= mark gnus-ancient-mark))
754 . gnus-summary-low-ancient-face)
755 ((= mark gnus-ancient-mark)
756 . gnus-summary-normal-ancient-face)
757 ((and (> score default) (= mark gnus-unread-mark))
758 . gnus-summary-high-unread-face)
759 ((and (< score default) (= mark gnus-unread-mark))
760 . gnus-summary-low-unread-face)
761 ((= mark gnus-unread-mark)
762 . gnus-summary-normal-unread-face)
763 ((and (> score default) (memq mark (list gnus-downloadable-mark
764 gnus-undownloaded-mark)))
765 . gnus-summary-high-unread-face)
766 ((and (< score default) (memq mark (list gnus-downloadable-mark
767 gnus-undownloaded-mark)))
768 . gnus-summary-low-unread-face)
769 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
770 . gnus-summary-normal-unread-face)
772 . gnus-summary-high-read-face)
774 . gnus-summary-low-read-face)
776 . gnus-summary-normal-read-face))
777 "*Controls the highlighting of summary buffer lines.
779 A list of (FORM . FACE) pairs. When deciding how a a particular
780 summary line should be displayed, each form is evaluated. The content
781 of the face field after the first true form is used. You can change
782 how those summary lines are displayed, by editing the face field.
784 You can use the following variables in the FORM field.
786 score: The articles score
787 default: The default article score.
788 below: The score below which articles are automatically marked as read.
789 mark: The articles mark."
790 :group 'gnus-summary-visual
791 :type '(repeat (cons (sexp :tag "Form" nil)
794 (defcustom gnus-alter-header-function nil
795 "Function called to allow alteration of article header structures.
796 The function is called with one parameter, the article header vector,
797 which it may alter in any way.")
799 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
800 "Variable that says which function should be used to decode a string with encoded words.")
802 (defcustom gnus-extra-headers nil
803 "*Extra headers to parse."
805 :type '(repeat symbol))
807 (defcustom gnus-ignored-from-addresses
808 (and user-mail-address (regexp-quote user-mail-address))
809 "*Regexp of From headers that may be suppressed in favor of To headers."
813 (defcustom gnus-group-charset-alist
814 '(("^hk\\>\\|^tw\\>\\|\\<big5\\>" cn-big5)
815 ("^cn\\>\\|\\<chinese\\>" cn-gb-2312)
816 ("^fj\\>\\|^japan\\>" iso-2022-jp-2)
817 ("^tnn\\>\\|^pin\\>\\|^sci.lang.japan" iso-2022-7bit)
818 ("^relcom\\>" koi8-r)
820 ("^\\(cz\\|hun\\|pl\\|sk\\|hr\\)\\>" iso-8859-2)
821 ("^israel\\>" iso-8859-1)
823 ("^alt.chinese.text.big5\\>" chinese-big5)
824 ("^soc.culture.vietnamese\\>" vietnamese-viqr)
825 ("^\\(comp\\|rec\\|alt\\|sci\\|soc\\|news\\|gnu\\|bofh\\)\\>" iso-8859-1)
827 "Alist of regexps (to match group names) and default charsets to be used when reading."
828 :type '(repeat (list (regexp :tag "Group")
829 (symbol :tag "Charset")))
830 :group 'gnus-charset)
832 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
833 "List of charsets that should be ignored.
834 When these charsets are used in the \"charset\" parameter, the
835 default charset will be used instead."
836 :type '(repeat symbol)
837 :group 'gnus-charset)
839 (defcustom gnus-group-ignored-charsets-alist
840 '(("alt\\.chinese\\.text" iso-8859-1))
841 "Alist of regexps (to match group names) and charsets that should be ignored.
842 When these charsets are used in the \"charset\" parameter, the
843 default charset will be used instead."
844 :type '(repeat (cons (regexp :tag "Group")
846 :group 'gnus-charset)
848 (defcustom gnus-group-highlight-words-alist nil
849 "Alist of group regexps and highlight regexps.
850 This variable uses the same syntax as `gnus-emphasis-alist'."
851 :type '(repeat (cons (regexp :tag "Group")
852 (repeat (list (regexp :tag "Highlight regexp")
853 (number :tag "Group for entire word" 0)
854 (number :tag "Group for displayed part" 0)
856 gnus-emphasis-highlight-words)))))
857 :group 'gnus-summary-visual)
859 (defcustom gnus-summary-show-article-charset-alist
861 "Alist of number and charset.
862 The article will be shown with the charset corresponding to the
864 For example: ((1 . cn-gb-2312) (2 . big5))."
865 :type '(repeat (cons (number :tag "Argument" 1)
866 (symbol :tag "Charset")))
867 :group 'gnus-charset)
869 (defcustom gnus-preserve-marks t
870 "Whether marks are preserved when moving, copying and respooling messages."
872 :group 'gnus-summary-marks)
874 ;;; Internal variables
876 (defvar gnus-article-mime-handles nil)
877 (defvar gnus-article-decoded-p nil)
878 (defvar gnus-scores-exclude-files nil)
879 (defvar gnus-page-broken nil)
880 (defvar gnus-inhibit-mime-unbuttonizing nil)
882 (defvar gnus-original-article nil)
883 (defvar gnus-article-internal-prepare-hook nil)
884 (defvar gnus-newsgroup-process-stack nil)
886 (defvar gnus-thread-indent-array nil)
887 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
888 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
889 "Function called to sort the articles within a thread after it has been gathered together.")
891 ;; Avoid highlighting in kill files.
892 (defvar gnus-summary-inhibit-highlight nil)
893 (defvar gnus-newsgroup-selected-overlay nil)
894 (defvar gnus-inhibit-limiting nil)
895 (defvar gnus-newsgroup-adaptive-score-file nil)
896 (defvar gnus-current-score-file nil)
897 (defvar gnus-current-move-group nil)
898 (defvar gnus-current-copy-group nil)
899 (defvar gnus-current-crosspost-group nil)
901 (defvar gnus-newsgroup-dependencies nil)
902 (defvar gnus-newsgroup-adaptive nil)
903 (defvar gnus-summary-display-article-function nil)
904 (defvar gnus-summary-highlight-line-function nil
905 "Function called after highlighting a summary line.")
907 (defvar gnus-summary-line-format-alist
908 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
909 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
910 (?s gnus-tmp-subject-or-nil ?s)
911 (?n gnus-tmp-name ?s)
912 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
914 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
916 (?F gnus-tmp-from ?s)
917 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
918 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
919 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
920 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
921 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
922 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
923 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
924 (?L gnus-tmp-lines ?d)
925 (?I gnus-tmp-indentation ?s)
926 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
927 (?R gnus-tmp-replied ?c)
928 (?\[ gnus-tmp-opening-bracket ?c)
929 (?\] gnus-tmp-closing-bracket ?c)
930 (?\> (make-string gnus-tmp-level ? ) ?s)
931 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
932 (?i gnus-tmp-score ?d)
933 (?z gnus-tmp-score-char ?c)
934 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
935 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
936 (?U gnus-tmp-unread ?c)
937 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header) ?s)
938 (?t (gnus-summary-number-of-articles-in-thread
939 (and (boundp 'thread) (car thread)) gnus-tmp-level)
941 (?e (gnus-summary-number-of-articles-in-thread
942 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
944 (?u gnus-tmp-user-defined ?s)
945 (?P (gnus-pick-line-number) ?d))
946 "An alist of format specifications that can appear in summary lines,
947 and what variables they correspond with, along with the type of the
948 variable (string, integer, character, etc).")
950 (defvar gnus-summary-dummy-line-format-alist
951 `((?S gnus-tmp-subject ?s)
952 (?N gnus-tmp-number ?d)
953 (?u gnus-tmp-user-defined ?s)))
955 (defvar gnus-summary-mode-line-format-alist
956 `((?G gnus-tmp-group-name ?s)
957 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
958 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
959 (?A gnus-tmp-article-number ?d)
960 (?Z gnus-tmp-unread-and-unselected ?s)
962 (?U gnus-tmp-unread-and-unticked ?d)
963 (?S gnus-tmp-subject ?s)
964 (?e gnus-tmp-unselected ?d)
965 (?u gnus-tmp-user-defined ?s)
966 (?d (length gnus-newsgroup-dormant) ?d)
967 (?t (length gnus-newsgroup-marked) ?d)
968 (?r (length gnus-newsgroup-reads) ?d)
969 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
970 (?E gnus-newsgroup-expunged-tally ?d)
971 (?s (gnus-current-score-file-nondirectory) ?s)))
973 (defvar gnus-last-search-regexp nil
974 "Default regexp for article search command.")
976 (defvar gnus-last-shell-command nil
977 "Default shell command on article.")
979 (defvar gnus-newsgroup-begin nil)
980 (defvar gnus-newsgroup-end nil)
981 (defvar gnus-newsgroup-last-rmail nil)
982 (defvar gnus-newsgroup-last-mail nil)
983 (defvar gnus-newsgroup-last-folder nil)
984 (defvar gnus-newsgroup-last-file nil)
985 (defvar gnus-newsgroup-auto-expire nil)
986 (defvar gnus-newsgroup-active nil)
988 (defvar gnus-newsgroup-data nil)
989 (defvar gnus-newsgroup-data-reverse nil)
990 (defvar gnus-newsgroup-limit nil)
991 (defvar gnus-newsgroup-limits nil)
993 (defvar gnus-newsgroup-unreads nil
994 "List of unread articles in the current newsgroup.")
996 (defvar gnus-newsgroup-unselected nil
997 "List of unselected unread articles in the current newsgroup.")
999 (defvar gnus-newsgroup-reads nil
1000 "Alist of read articles and article marks in the current newsgroup.")
1002 (defvar gnus-newsgroup-expunged-tally nil)
1004 (defvar gnus-newsgroup-marked nil
1005 "List of ticked articles in the current newsgroup (a subset of unread art).")
1007 (defvar gnus-newsgroup-killed nil
1008 "List of ranges of articles that have been through the scoring process.")
1010 (defvar gnus-newsgroup-cached nil
1011 "List of articles that come from the article cache.")
1013 (defvar gnus-newsgroup-saved nil
1014 "List of articles that have been saved.")
1016 (defvar gnus-newsgroup-kill-headers nil)
1018 (defvar gnus-newsgroup-replied nil
1019 "List of articles that have been replied to in the current newsgroup.")
1021 (defvar gnus-newsgroup-expirable nil
1022 "List of articles in the current newsgroup that can be expired.")
1024 (defvar gnus-newsgroup-processable nil
1025 "List of articles in the current newsgroup that can be processed.")
1027 (defvar gnus-newsgroup-downloadable nil
1028 "List of articles in the current newsgroup that can be processed.")
1030 (defvar gnus-newsgroup-undownloaded nil
1031 "List of articles in the current newsgroup that haven't been downloaded..")
1033 (defvar gnus-newsgroup-unsendable nil
1034 "List of articles in the current newsgroup that won't be sent.")
1036 (defvar gnus-newsgroup-bookmarks nil
1037 "List of articles in the current newsgroup that have bookmarks.")
1039 (defvar gnus-newsgroup-dormant nil
1040 "List of dormant articles in the current newsgroup.")
1042 (defvar gnus-newsgroup-scored nil
1043 "List of scored articles in the current newsgroup.")
1045 (defvar gnus-newsgroup-headers nil
1046 "List of article headers in the current newsgroup.")
1048 (defvar gnus-newsgroup-threads nil)
1050 (defvar gnus-newsgroup-prepared nil
1051 "Whether the current group has been prepared properly.")
1053 (defvar gnus-newsgroup-ancient nil
1054 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1056 (defvar gnus-newsgroup-sparse nil)
1058 (defvar gnus-current-article nil)
1059 (defvar gnus-article-current nil)
1060 (defvar gnus-current-headers nil)
1061 (defvar gnus-have-all-headers nil)
1062 (defvar gnus-last-article nil)
1063 (defvar gnus-newsgroup-history nil)
1064 (defvar gnus-newsgroup-charset nil)
1065 (defvar gnus-newsgroup-ephemeral-charset nil)
1066 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1068 (defconst gnus-summary-local-variables
1069 '(gnus-newsgroup-name
1070 gnus-newsgroup-begin gnus-newsgroup-end
1071 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1072 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1073 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1074 gnus-newsgroup-unselected gnus-newsgroup-marked
1075 gnus-newsgroup-reads gnus-newsgroup-saved
1076 gnus-newsgroup-replied gnus-newsgroup-expirable
1077 gnus-newsgroup-processable gnus-newsgroup-killed
1078 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1079 gnus-newsgroup-unsendable
1080 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1081 gnus-newsgroup-headers gnus-newsgroup-threads
1082 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1083 gnus-current-article gnus-current-headers gnus-have-all-headers
1084 gnus-last-article gnus-article-internal-prepare-hook
1085 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1086 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1087 gnus-thread-expunge-below
1088 gnus-score-alist gnus-current-score-file
1089 (gnus-summary-expunge-below . global)
1090 (gnus-summary-mark-below . global)
1091 gnus-newsgroup-active gnus-scores-exclude-files
1092 gnus-newsgroup-history gnus-newsgroup-ancient
1093 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1094 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1095 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1096 (gnus-newsgroup-expunged-tally . 0)
1097 gnus-cache-removable-articles gnus-newsgroup-cached
1098 gnus-newsgroup-data gnus-newsgroup-data-reverse
1099 gnus-newsgroup-limit gnus-newsgroup-limits
1100 gnus-newsgroup-charset)
1101 "Variables that are buffer-local to the summary buffers.")
1103 ;; Byte-compiler warning.
1104 (defvar gnus-article-mode-map)
1108 (defvar gnus-decode-encoded-word-methods
1109 '(mail-decode-encoded-word-string)
1110 "List of methods used to decode encoded words.
1112 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item is
1113 FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1114 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1115 whose names match REGEXP.
1118 ((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1119 mail-decode-encoded-word-string
1120 (\"chinese\" . rfc1843-decode-string))
1123 (defvar gnus-decode-encoded-word-methods-cache nil)
1125 (defun gnus-multi-decode-encoded-word-string (string)
1126 "Apply the functions from `gnus-encoded-word-methods' that match."
1127 (unless (and gnus-decode-encoded-word-methods-cache
1128 (eq gnus-newsgroup-name
1129 (car gnus-decode-encoded-word-methods-cache)))
1130 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1133 (nconc gnus-decode-encoded-word-methods-cache (list x))
1134 (if (and gnus-newsgroup-name
1135 (string-match (car x) gnus-newsgroup-name))
1136 (nconc gnus-decode-encoded-word-methods-cache
1138 gnus-decode-encoded-word-methods))
1139 (let ((xlist gnus-decode-encoded-word-methods-cache))
1142 (setq string (funcall (pop xlist) string))))
1145 ;; Subject simplification.
1147 (defun gnus-simplify-whitespace (str)
1148 "Remove excessive whitespace."
1151 (while (string-match "[ \t][ \t]+" mystr)
1152 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1154 (substring mystr (match-end 0)))))
1156 (when (string-match "^[ \t]+" mystr)
1157 (setq mystr (substring mystr (match-end 0))))
1159 (when (string-match "[ \t]+$" mystr)
1160 (setq mystr (substring mystr 0 (match-beginning 0))))
1163 (defsubst gnus-simplify-subject-re (subject)
1164 "Remove \"Re:\" from subject lines."
1165 (if (string-match "^[Rr][Ee]: *" subject)
1166 (substring subject (match-end 0))
1169 (defun gnus-simplify-subject (subject &optional re-only)
1170 "Remove `Re:' and words in parentheses.
1171 If RE-ONLY is non-nil, strip leading `Re:'s only."
1172 (let ((case-fold-search t)) ;Ignore case.
1173 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1174 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1175 (setq subject (substring subject (match-end 0))))
1176 ;; Remove uninteresting prefixes.
1177 (when (and (not re-only)
1178 gnus-simplify-ignored-prefixes
1179 (string-match gnus-simplify-ignored-prefixes subject))
1180 (setq subject (substring subject (match-end 0))))
1181 ;; Remove words in parentheses from end.
1183 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1184 (setq subject (substring subject 0 (match-beginning 0)))))
1185 ;; Return subject string.
1188 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1190 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1191 (goto-char (point-min))
1192 (while (re-search-forward regexp nil t)
1193 (replace-match (or newtext ""))))
1195 (defun gnus-simplify-buffer-fuzzy ()
1196 "Simplify string in the buffer fuzzily.
1197 The string in the accessible portion of the current buffer is simplified.
1198 It is assumed to be a single-line subject.
1199 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1200 matter is removed. Additional things can be deleted by setting
1201 gnus-simplify-subject-fuzzy-regexp."
1202 (let ((case-fold-search t)
1204 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1206 (while (not (eq modified-tick (buffer-modified-tick)))
1207 (setq modified-tick (buffer-modified-tick))
1209 ((listp gnus-simplify-subject-fuzzy-regexp)
1210 (mapcar 'gnus-simplify-buffer-fuzzy-step
1211 gnus-simplify-subject-fuzzy-regexp))
1212 (gnus-simplify-subject-fuzzy-regexp
1213 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1214 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1215 (gnus-simplify-buffer-fuzzy-step
1216 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1217 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1219 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1220 (gnus-simplify-buffer-fuzzy-step " +" " ")
1221 (gnus-simplify-buffer-fuzzy-step " $")
1222 (gnus-simplify-buffer-fuzzy-step "^ +")))
1224 (defun gnus-simplify-subject-fuzzy (subject)
1225 "Simplify a subject string fuzzily.
1226 See `gnus-simplify-buffer-fuzzy' for details."
1228 (gnus-set-work-buffer)
1229 (let ((case-fold-search t))
1230 ;; Remove uninteresting prefixes.
1231 (when (and gnus-simplify-ignored-prefixes
1232 (string-match gnus-simplify-ignored-prefixes subject))
1233 (setq subject (substring subject (match-end 0))))
1235 (inline (gnus-simplify-buffer-fuzzy))
1238 (defsubst gnus-simplify-subject-fully (subject)
1239 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1241 (gnus-simplify-subject-functions
1242 (gnus-map-function gnus-simplify-subject-functions subject))
1243 ((null gnus-summary-gather-subject-limit)
1244 (gnus-simplify-subject-re subject))
1245 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1246 (gnus-simplify-subject-fuzzy subject))
1247 ((numberp gnus-summary-gather-subject-limit)
1248 (gnus-limit-string (gnus-simplify-subject-re subject)
1249 gnus-summary-gather-subject-limit))
1253 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1254 "Check whether two subjects are equal.
1255 If optional argument simple-first is t, first argument is already
1258 ((null simple-first)
1259 (equal (gnus-simplify-subject-fully s1)
1260 (gnus-simplify-subject-fully s2)))
1263 (gnus-simplify-subject-fully s2)))))
1265 (defun gnus-summary-bubble-group ()
1266 "Increase the score of the current group.
1267 This is a handy function to add to `gnus-summary-exit-hook' to
1268 increase the score of each group you read."
1269 (gnus-group-add-score gnus-newsgroup-name))
1273 ;;; Gnus summary mode
1276 (put 'gnus-summary-mode 'mode-class 'special)
1279 ;; Non-orthogonal keys
1281 (gnus-define-keys gnus-summary-mode-map
1282 " " gnus-summary-next-page
1283 "\177" gnus-summary-prev-page
1284 [delete] gnus-summary-prev-page
1285 [backspace] gnus-summary-prev-page
1286 "\r" gnus-summary-scroll-up
1287 "\M-\r" gnus-summary-scroll-down
1288 "n" gnus-summary-next-unread-article
1289 "p" gnus-summary-prev-unread-article
1290 "N" gnus-summary-next-article
1291 "P" gnus-summary-prev-article
1292 "\M-\C-n" gnus-summary-next-same-subject
1293 "\M-\C-p" gnus-summary-prev-same-subject
1294 "\M-n" gnus-summary-next-unread-subject
1295 "\M-p" gnus-summary-prev-unread-subject
1296 "." gnus-summary-first-unread-article
1297 "," gnus-summary-best-unread-article
1298 "\M-s" gnus-summary-search-article-forward
1299 "\M-r" gnus-summary-search-article-backward
1300 "<" gnus-summary-beginning-of-article
1301 ">" gnus-summary-end-of-article
1302 "j" gnus-summary-goto-article
1303 "^" gnus-summary-refer-parent-article
1304 "\M-^" gnus-summary-refer-article
1305 "u" gnus-summary-tick-article-forward
1306 "!" gnus-summary-tick-article-forward
1307 "U" gnus-summary-tick-article-backward
1308 "d" gnus-summary-mark-as-read-forward
1309 "D" gnus-summary-mark-as-read-backward
1310 "E" gnus-summary-mark-as-expirable
1311 "\M-u" gnus-summary-clear-mark-forward
1312 "\M-U" gnus-summary-clear-mark-backward
1313 "k" gnus-summary-kill-same-subject-and-select
1314 "\C-k" gnus-summary-kill-same-subject
1315 "\M-\C-k" gnus-summary-kill-thread
1316 "\M-\C-l" gnus-summary-lower-thread
1317 "e" gnus-summary-edit-article
1318 "#" gnus-summary-mark-as-processable
1319 "\M-#" gnus-summary-unmark-as-processable
1320 "\M-\C-t" gnus-summary-toggle-threads
1321 "\M-\C-s" gnus-summary-show-thread
1322 "\M-\C-h" gnus-summary-hide-thread
1323 "\M-\C-f" gnus-summary-next-thread
1324 "\M-\C-b" gnus-summary-prev-thread
1325 "\M-\C-u" gnus-summary-up-thread
1326 "\M-\C-d" gnus-summary-down-thread
1327 "&" gnus-summary-execute-command
1328 "c" gnus-summary-catchup-and-exit
1329 "\C-w" gnus-summary-mark-region-as-read
1330 "\C-t" gnus-summary-toggle-truncation
1331 "?" gnus-summary-mark-as-dormant
1332 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1333 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1334 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1335 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1336 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1337 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1338 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1339 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1340 "=" gnus-summary-expand-window
1341 "\C-x\C-s" gnus-summary-reselect-current-group
1342 "\M-g" gnus-summary-rescan-group
1343 "w" gnus-summary-stop-page-breaking
1344 "\C-c\C-r" gnus-summary-caesar-message
1345 "f" gnus-summary-followup
1346 "F" gnus-summary-followup-with-original
1347 "C" gnus-summary-cancel-article
1348 "r" gnus-summary-reply
1349 "R" gnus-summary-reply-with-original
1350 "\C-c\C-f" gnus-summary-mail-forward
1351 "o" gnus-summary-save-article
1352 "\C-o" gnus-summary-save-article-mail
1353 "|" gnus-summary-pipe-output
1354 "\M-k" gnus-summary-edit-local-kill
1355 "\M-K" gnus-summary-edit-global-kill
1357 "\C-c\C-d" gnus-summary-describe-group
1358 "q" gnus-summary-exit
1359 "Q" gnus-summary-exit-no-update
1360 "\C-c\C-i" gnus-info-find-node
1361 gnus-mouse-2 gnus-mouse-pick-article
1362 "m" gnus-summary-mail-other-window
1363 "a" gnus-summary-post-news
1364 "x" gnus-summary-limit-to-unread
1365 "s" gnus-summary-isearch-article
1366 "t" gnus-summary-toggle-header
1367 "g" gnus-summary-show-article
1368 "l" gnus-summary-goto-last-article
1369 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1370 "\C-d" gnus-summary-enter-digest-group
1371 "\M-\C-d" gnus-summary-read-document
1372 "\M-\C-e" gnus-summary-edit-parameters
1373 "\M-\C-a" gnus-summary-customize-parameters
1375 "*" gnus-cache-enter-article
1376 "\M-*" gnus-cache-remove-article
1377 "\M-&" gnus-summary-universal-argument
1378 "\C-l" gnus-recenter
1379 "I" gnus-summary-increase-score
1380 "L" gnus-summary-lower-score
1381 "\M-i" gnus-symbolic-argument
1382 "h" gnus-summary-select-article-buffer
1384 "b" gnus-article-view-part
1385 "\M-t" gnus-summary-toggle-display-buttonized
1387 "V" gnus-summary-score-map
1388 "X" gnus-uu-extract-map
1389 "S" gnus-summary-send-map)
1391 ;; Sort of orthogonal keymap
1392 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1393 "t" gnus-summary-tick-article-forward
1394 "!" gnus-summary-tick-article-forward
1395 "d" gnus-summary-mark-as-read-forward
1396 "r" gnus-summary-mark-as-read-forward
1397 "c" gnus-summary-clear-mark-forward
1398 " " gnus-summary-clear-mark-forward
1399 "e" gnus-summary-mark-as-expirable
1400 "x" gnus-summary-mark-as-expirable
1401 "?" gnus-summary-mark-as-dormant
1402 "b" gnus-summary-set-bookmark
1403 "B" gnus-summary-remove-bookmark
1404 "#" gnus-summary-mark-as-processable
1405 "\M-#" gnus-summary-unmark-as-processable
1406 "S" gnus-summary-limit-include-expunged
1407 "C" gnus-summary-catchup
1408 "H" gnus-summary-catchup-to-here
1409 "\C-c" gnus-summary-catchup-all
1410 "k" gnus-summary-kill-same-subject-and-select
1411 "K" gnus-summary-kill-same-subject
1412 "P" gnus-uu-mark-map)
1414 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1415 "c" gnus-summary-clear-above
1416 "u" gnus-summary-tick-above
1417 "m" gnus-summary-mark-above
1418 "k" gnus-summary-kill-below)
1420 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1421 "/" gnus-summary-limit-to-subject
1422 "n" gnus-summary-limit-to-articles
1423 "w" gnus-summary-pop-limit
1424 "s" gnus-summary-limit-to-subject
1425 "a" gnus-summary-limit-to-author
1426 "u" gnus-summary-limit-to-unread
1427 "m" gnus-summary-limit-to-marks
1428 "M" gnus-summary-limit-exclude-marks
1429 "v" gnus-summary-limit-to-score
1430 "*" gnus-summary-limit-include-cached
1431 "D" gnus-summary-limit-include-dormant
1432 "T" gnus-summary-limit-include-thread
1433 "d" gnus-summary-limit-exclude-dormant
1434 "t" gnus-summary-limit-to-age
1435 "x" gnus-summary-limit-to-extra
1436 "E" gnus-summary-limit-include-expunged
1437 "c" gnus-summary-limit-exclude-childless-dormant
1438 "C" gnus-summary-limit-mark-excluded-as-read)
1440 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1441 "n" gnus-summary-next-unread-article
1442 "p" gnus-summary-prev-unread-article
1443 "N" gnus-summary-next-article
1444 "P" gnus-summary-prev-article
1445 "\C-n" gnus-summary-next-same-subject
1446 "\C-p" gnus-summary-prev-same-subject
1447 "\M-n" gnus-summary-next-unread-subject
1448 "\M-p" gnus-summary-prev-unread-subject
1449 "f" gnus-summary-first-unread-article
1450 "b" gnus-summary-best-unread-article
1451 "j" gnus-summary-goto-article
1452 "g" gnus-summary-goto-subject
1453 "l" gnus-summary-goto-last-article
1454 "o" gnus-summary-pop-article)
1456 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1457 "k" gnus-summary-kill-thread
1458 "l" gnus-summary-lower-thread
1459 "i" gnus-summary-raise-thread
1460 "T" gnus-summary-toggle-threads
1461 "t" gnus-summary-rethread-current
1462 "^" gnus-summary-reparent-thread
1463 "s" gnus-summary-show-thread
1464 "S" gnus-summary-show-all-threads
1465 "h" gnus-summary-hide-thread
1466 "H" gnus-summary-hide-all-threads
1467 "n" gnus-summary-next-thread
1468 "p" gnus-summary-prev-thread
1469 "u" gnus-summary-up-thread
1470 "o" gnus-summary-top-thread
1471 "d" gnus-summary-down-thread
1472 "#" gnus-uu-mark-thread
1473 "\M-#" gnus-uu-unmark-thread)
1475 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1476 "g" gnus-summary-prepare
1477 "c" gnus-summary-insert-cached-articles)
1479 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1480 "c" gnus-summary-catchup-and-exit
1481 "C" gnus-summary-catchup-all-and-exit
1482 "E" gnus-summary-exit-no-update
1483 "Q" gnus-summary-exit
1484 "Z" gnus-summary-exit
1485 "n" gnus-summary-catchup-and-goto-next-group
1486 "R" gnus-summary-reselect-current-group
1487 "G" gnus-summary-rescan-group
1488 "N" gnus-summary-next-group
1489 "s" gnus-summary-save-newsrc
1490 "P" gnus-summary-prev-group)
1492 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1493 " " gnus-summary-next-page
1494 "n" gnus-summary-next-page
1495 "\177" gnus-summary-prev-page
1496 [delete] gnus-summary-prev-page
1497 "p" gnus-summary-prev-page
1498 "\r" gnus-summary-scroll-up
1499 "\M-\r" gnus-summary-scroll-down
1500 "<" gnus-summary-beginning-of-article
1501 ">" gnus-summary-end-of-article
1502 "b" gnus-summary-beginning-of-article
1503 "e" gnus-summary-end-of-article
1504 "^" gnus-summary-refer-parent-article
1505 "r" gnus-summary-refer-parent-article
1506 "D" gnus-summary-enter-digest-group
1507 "R" gnus-summary-refer-references
1508 "T" gnus-summary-refer-thread
1509 "g" gnus-summary-show-article
1510 "s" gnus-summary-isearch-article
1511 "P" gnus-summary-print-article
1512 "t" gnus-article-babel)
1514 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1515 "b" gnus-article-add-buttons
1516 "B" gnus-article-add-buttons-to-head
1517 "o" gnus-article-treat-overstrike
1518 "e" gnus-article-emphasize
1519 "w" gnus-article-fill-cited-article
1520 "Q" gnus-article-fill-long-lines
1521 "C" gnus-article-capitalize-sentences
1522 "c" gnus-article-remove-cr
1523 "q" gnus-article-de-quoted-unreadable
1524 "f" gnus-article-display-x-face
1525 "l" gnus-summary-stop-page-breaking
1526 "r" gnus-summary-caesar-message
1527 "t" gnus-article-hide-headers
1528 "v" gnus-summary-verbose-headers
1529 "H" gnus-article-strip-headers-in-body
1530 "d" gnus-article-treat-dumbquotes)
1532 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1533 "a" gnus-article-hide
1534 "h" gnus-article-hide-headers
1535 "b" gnus-article-hide-boring-headers
1536 "s" gnus-article-hide-signature
1537 "c" gnus-article-hide-citation
1538 "C" gnus-article-hide-citation-in-followups
1539 "l" gnus-article-hide-list-identifiers
1540 "p" gnus-article-hide-pgp
1541 "B" gnus-article-strip-banner
1542 "P" gnus-article-hide-pem
1543 "\C-c" gnus-article-hide-citation-maybe)
1545 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1546 "a" gnus-article-highlight
1547 "h" gnus-article-highlight-headers
1548 "c" gnus-article-highlight-citation
1549 "s" gnus-article-highlight-signature)
1551 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1552 "w" gnus-article-decode-mime-words
1553 "c" gnus-article-decode-charset
1554 "v" gnus-mime-view-all-parts
1555 "b" gnus-article-view-part)
1557 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1558 "z" gnus-article-date-ut
1559 "u" gnus-article-date-ut
1560 "l" gnus-article-date-local
1561 "e" gnus-article-date-lapsed
1562 "o" gnus-article-date-original
1563 "i" gnus-article-date-iso8601
1564 "s" gnus-article-date-user)
1566 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1567 "t" gnus-article-remove-trailing-blank-lines
1568 "l" gnus-article-strip-leading-blank-lines
1569 "m" gnus-article-strip-multiple-blank-lines
1570 "a" gnus-article-strip-blank-lines
1571 "A" gnus-article-strip-all-blank-lines
1572 "s" gnus-article-strip-leading-space
1573 "e" gnus-article-strip-trailing-space)
1575 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1577 "f" gnus-summary-fetch-faq
1578 "d" gnus-summary-describe-group
1579 "h" gnus-summary-describe-briefly
1580 "i" gnus-info-find-node)
1582 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1583 "e" gnus-summary-expire-articles
1584 "\M-\C-e" gnus-summary-expire-articles-now
1585 "\177" gnus-summary-delete-article
1586 [delete] gnus-summary-delete-article
1587 [backspace] gnus-summary-delete-article
1588 "m" gnus-summary-move-article
1589 "r" gnus-summary-respool-article
1590 "w" gnus-summary-edit-article
1591 "c" gnus-summary-copy-article
1592 "B" gnus-summary-crosspost-article
1593 "q" gnus-summary-respool-query
1594 "t" gnus-summary-respool-trace
1595 "i" gnus-summary-import-article
1596 "p" gnus-summary-article-posted-p)
1598 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1599 "o" gnus-summary-save-article
1600 "m" gnus-summary-save-article-mail
1601 "F" gnus-summary-write-article-file
1602 "r" gnus-summary-save-article-rmail
1603 "f" gnus-summary-save-article-file
1604 "b" gnus-summary-save-article-body-file
1605 "h" gnus-summary-save-article-folder
1606 "v" gnus-summary-save-article-vm
1607 "p" gnus-summary-pipe-output
1608 "s" gnus-soup-add-article)
1610 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1611 "b" gnus-summary-display-buttonized
1612 "m" gnus-summary-repair-multipart
1613 "v" gnus-article-view-part
1614 "o" gnus-article-save-part
1615 "c" gnus-article-copy-part
1616 "e" gnus-article-externalize-part
1617 "i" gnus-article-inline-part
1618 "|" gnus-article-pipe-part))
1620 (defun gnus-summary-make-menu-bar ()
1621 (gnus-turn-off-edit-menu 'summary)
1623 (unless (boundp 'gnus-summary-misc-menu)
1626 gnus-summary-kill-menu gnus-summary-mode-map ""
1631 ["Enter score..." gnus-summary-score-entry t]
1632 ["Customize" gnus-score-customize t])
1633 (gnus-make-score-map 'increase)
1634 (gnus-make-score-map 'lower)
1636 ["Kill below" gnus-summary-kill-below t]
1637 ["Mark above" gnus-summary-mark-above t]
1638 ["Tick above" gnus-summary-tick-above t]
1639 ["Clear above" gnus-summary-clear-above t])
1640 ["Current score" gnus-summary-current-score t]
1641 ["Set score" gnus-summary-set-score t]
1642 ["Switch current score file..." gnus-score-change-score-file t]
1643 ["Set mark below..." gnus-score-set-mark-below t]
1644 ["Set expunge below..." gnus-score-set-expunge-below t]
1645 ["Edit current score file" gnus-score-edit-current-scores t]
1646 ["Edit score file" gnus-score-edit-file t]
1647 ["Trace score" gnus-score-find-trace t]
1648 ["Find words" gnus-score-find-favourite-words t]
1649 ["Rescore buffer" gnus-summary-rescore t]
1650 ["Increase score..." gnus-summary-increase-score t]
1651 ["Lower score..." gnus-summary-lower-score t]))))
1653 ;; Define both the Article menu in the summary buffer and the equivalent
1654 ;; Commands menu in the article buffer here for consistency.
1657 ["All" gnus-article-hide t]
1658 ["Headers" gnus-article-hide-headers t]
1659 ["Signature" gnus-article-hide-signature t]
1660 ["Citation" gnus-article-hide-citation t]
1661 ["List identifiers" gnus-article-hide-list-identifiers t]
1662 ["PGP" gnus-article-hide-pgp t]
1663 ["Banner" gnus-article-strip-banner t]
1664 ["Boring headers" gnus-article-hide-boring-headers t])
1666 ["All" gnus-article-highlight t]
1667 ["Headers" gnus-article-highlight-headers t]
1668 ["Signature" gnus-article-highlight-signature t]
1669 ["Citation" gnus-article-highlight-citation t])
1671 ["Words" gnus-article-decode-mime-words t]
1672 ["Charset" gnus-article-decode-charset t]
1673 ["QP" gnus-article-de-quoted-unreadable t]
1674 ["View all" gnus-mime-view-all-parts t])
1676 ["Local" gnus-article-date-local t]
1677 ["ISO8601" gnus-article-date-iso8601 t]
1678 ["UT" gnus-article-date-ut t]
1679 ["Original" gnus-article-date-original t]
1680 ["Lapsed" gnus-article-date-lapsed t]
1681 ["User-defined" gnus-article-date-user t])
1684 ["Leading" gnus-article-strip-leading-blank-lines t]
1685 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1686 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1687 ["All of the above" gnus-article-strip-blank-lines t]
1688 ["All" gnus-article-strip-all-blank-lines t]
1689 ["Leading space" gnus-article-strip-leading-space t]
1690 ["Trailing space" gnus-article-strip-trailing-space t])
1691 ["Overstrike" gnus-article-treat-overstrike t]
1692 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1693 ["Emphasis" gnus-article-emphasize t]
1694 ["Word wrap" gnus-article-fill-cited-article t]
1695 ["Fill long lines" gnus-article-fill-long-lines t]
1696 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1697 ["CR" gnus-article-remove-cr t]
1698 ["Show X-Face" gnus-article-display-x-face t]
1699 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1700 ["Rot 13" gnus-summary-caesar-message t]
1701 ["Unix pipe" gnus-summary-pipe-message t]
1702 ["Add buttons" gnus-article-add-buttons t]
1703 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1704 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1705 ["Verbose header" gnus-summary-verbose-headers t]
1706 ["Toggle header" gnus-summary-toggle-header t]
1707 ["HZ" gnus-article-decode-HZ t])
1709 ["Save in default format" gnus-summary-save-article t]
1710 ["Save in file" gnus-summary-save-article-file t]
1711 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1712 ["Save in MH folder" gnus-summary-save-article-folder t]
1713 ["Save in VM folder" gnus-summary-save-article-vm t]
1714 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1715 ["Save body in file" gnus-summary-save-article-body-file t]
1716 ["Pipe through a filter" gnus-summary-pipe-output t]
1717 ["Add to SOUP packet" gnus-soup-add-article t]
1718 ["Print" gnus-summary-print-article t])
1720 ["Respool article..." gnus-summary-respool-article t]
1721 ["Move article..." gnus-summary-move-article
1722 (gnus-check-backend-function
1723 'request-move-article gnus-newsgroup-name)]
1724 ["Copy article..." gnus-summary-copy-article t]
1725 ["Crosspost article..." gnus-summary-crosspost-article
1726 (gnus-check-backend-function
1727 'request-replace-article gnus-newsgroup-name)]
1728 ["Import file..." gnus-summary-import-article t]
1729 ["Check if posted" gnus-summary-article-posted-p t]
1730 ["Edit article" gnus-summary-edit-article
1731 (not (gnus-group-read-only-p))]
1732 ["Delete article" gnus-summary-delete-article
1733 (gnus-check-backend-function
1734 'request-expire-articles gnus-newsgroup-name)]
1735 ["Query respool" gnus-summary-respool-query t]
1736 ["Trace respool" gnus-summary-respool-trace t]
1737 ["Delete expirable articles" gnus-summary-expire-articles-now
1738 (gnus-check-backend-function
1739 'request-expire-articles gnus-newsgroup-name)])
1741 ["Uudecode" gnus-uu-decode-uu t]
1742 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1743 ["Unshar" gnus-uu-decode-unshar t]
1744 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1745 ["Save" gnus-uu-decode-save t]
1746 ["Binhex" gnus-uu-decode-binhex t]
1747 ["Postscript" gnus-uu-decode-postscript t])
1749 ["Enter article" gnus-cache-enter-article t]
1750 ["Remove article" gnus-cache-remove-article t])
1751 ["Translate" gnus-article-babel t]
1752 ["Select article buffer" gnus-summary-select-article-buffer t]
1753 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1754 ["Isearch article..." gnus-summary-isearch-article t]
1755 ["Beginning of the article" gnus-summary-beginning-of-article t]
1756 ["End of the article" gnus-summary-end-of-article t]
1757 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1758 ["Fetch referenced articles" gnus-summary-refer-references t]
1759 ["Fetch current thread" gnus-summary-refer-thread t]
1760 ["Fetch article with id..." gnus-summary-refer-article t]
1761 ["Redisplay" gnus-summary-show-article t])))
1763 gnus-summary-article-menu gnus-summary-mode-map ""
1764 (cons "Article" innards))
1767 gnus-article-commands-menu gnus-article-mode-map ""
1768 (cons "Commands" innards)))
1771 gnus-summary-thread-menu gnus-summary-mode-map ""
1773 ["Toggle threading" gnus-summary-toggle-threads t]
1774 ["Hide threads" gnus-summary-hide-all-threads t]
1775 ["Show threads" gnus-summary-show-all-threads t]
1776 ["Hide thread" gnus-summary-hide-thread t]
1777 ["Show thread" gnus-summary-show-thread t]
1778 ["Go to next thread" gnus-summary-next-thread t]
1779 ["Go to previous thread" gnus-summary-prev-thread t]
1780 ["Go down thread" gnus-summary-down-thread t]
1781 ["Go up thread" gnus-summary-up-thread t]
1782 ["Top of thread" gnus-summary-top-thread t]
1783 ["Mark thread as read" gnus-summary-kill-thread t]
1784 ["Lower thread score" gnus-summary-lower-thread t]
1785 ["Raise thread score" gnus-summary-raise-thread t]
1786 ["Rethread current" gnus-summary-rethread-current t]))
1789 gnus-summary-post-menu gnus-summary-mode-map ""
1791 ["Post an article" gnus-summary-post-news t]
1792 ["Followup" gnus-summary-followup t]
1793 ["Followup and yank" gnus-summary-followup-with-original t]
1794 ["Supersede article" gnus-summary-supersede-article t]
1795 ["Cancel article" gnus-summary-cancel-article t]
1796 ["Reply" gnus-summary-reply t]
1797 ["Reply and yank" gnus-summary-reply-with-original t]
1798 ["Wide reply" gnus-summary-wide-reply t]
1799 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1800 ["Mail forward" gnus-summary-mail-forward t]
1801 ["Post forward" gnus-summary-post-forward t]
1802 ["Digest and mail" gnus-uu-digest-mail-forward t]
1803 ["Digest and post" gnus-uu-digest-post-forward t]
1804 ["Resend message" gnus-summary-resend-message t]
1805 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1806 ["Send a mail" gnus-summary-mail-other-window t]
1807 ["Uuencode and post" gnus-uu-post-news t]
1808 ["Followup via news" gnus-summary-followup-to-mail t]
1809 ["Followup via news and yank"
1810 gnus-summary-followup-to-mail-with-original t]
1812 ;;["Send" gnus-summary-send-draft t]
1813 ;;["Send bounced" gnus-resend-bounced-mail t])
1817 gnus-summary-misc-menu gnus-summary-mode-map ""
1820 ["Mark as read" gnus-summary-mark-as-read-forward t]
1821 ["Mark same subject and select"
1822 gnus-summary-kill-same-subject-and-select t]
1823 ["Mark same subject" gnus-summary-kill-same-subject t]
1824 ["Catchup" gnus-summary-catchup t]
1825 ["Catchup all" gnus-summary-catchup-all t]
1826 ["Catchup to here" gnus-summary-catchup-to-here t]
1827 ["Catchup region" gnus-summary-mark-region-as-read t]
1828 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1830 ["Tick" gnus-summary-tick-article-forward t]
1831 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1832 ["Remove marks" gnus-summary-clear-mark-forward t]
1833 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1834 ["Set bookmark" gnus-summary-set-bookmark t]
1835 ["Remove bookmark" gnus-summary-remove-bookmark t])
1837 ["Marks..." gnus-summary-limit-to-marks t]
1838 ["Subject..." gnus-summary-limit-to-subject t]
1839 ["Author..." gnus-summary-limit-to-author t]
1840 ["Age..." gnus-summary-limit-to-age t]
1841 ["Extra..." gnus-summary-limit-to-extra t]
1842 ["Score" gnus-summary-limit-to-score t]
1843 ["Unread" gnus-summary-limit-to-unread t]
1844 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1845 ["Articles" gnus-summary-limit-to-articles t]
1846 ["Pop limit" gnus-summary-pop-limit t]
1847 ["Show dormant" gnus-summary-limit-include-dormant t]
1848 ["Hide childless dormant"
1849 gnus-summary-limit-exclude-childless-dormant t]
1850 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1851 ["Hide marked" gnus-summary-limit-exclude-marks t]
1852 ["Show expunged" gnus-summary-show-all-expunged t])
1854 ["Set mark" gnus-summary-mark-as-processable t]
1855 ["Remove mark" gnus-summary-unmark-as-processable t]
1856 ["Remove all marks" gnus-summary-unmark-all-processable t]
1857 ["Mark above" gnus-uu-mark-over t]
1858 ["Mark series" gnus-uu-mark-series t]
1859 ["Mark region" gnus-uu-mark-region t]
1860 ["Unmark region" gnus-uu-unmark-region t]
1861 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1862 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1863 ["Mark all" gnus-uu-mark-all t]
1864 ["Mark buffer" gnus-uu-mark-buffer t]
1865 ["Mark sparse" gnus-uu-mark-sparse t]
1866 ["Mark thread" gnus-uu-mark-thread t]
1867 ["Unmark thread" gnus-uu-unmark-thread t]
1868 ("Process Mark Sets"
1869 ["Kill" gnus-summary-kill-process-mark t]
1870 ["Yank" gnus-summary-yank-process-mark
1871 gnus-newsgroup-process-stack]
1872 ["Save" gnus-summary-save-process-mark t]))
1874 ["Page forward" gnus-summary-next-page t]
1875 ["Page backward" gnus-summary-prev-page t]
1876 ["Line forward" gnus-summary-scroll-up t])
1878 ["Next unread article" gnus-summary-next-unread-article t]
1879 ["Previous unread article" gnus-summary-prev-unread-article t]
1880 ["Next article" gnus-summary-next-article t]
1881 ["Previous article" gnus-summary-prev-article t]
1882 ["Next unread subject" gnus-summary-next-unread-subject t]
1883 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1884 ["Next article same subject" gnus-summary-next-same-subject t]
1885 ["Previous article same subject" gnus-summary-prev-same-subject t]
1886 ["First unread article" gnus-summary-first-unread-article t]
1887 ["Best unread article" gnus-summary-best-unread-article t]
1888 ["Go to subject number..." gnus-summary-goto-subject t]
1889 ["Go to article number..." gnus-summary-goto-article t]
1890 ["Go to the last article" gnus-summary-goto-last-article t]
1891 ["Pop article off history" gnus-summary-pop-article t])
1893 ["Sort by number" gnus-summary-sort-by-number t]
1894 ["Sort by author" gnus-summary-sort-by-author t]
1895 ["Sort by subject" gnus-summary-sort-by-subject t]
1896 ["Sort by date" gnus-summary-sort-by-date t]
1897 ["Sort by score" gnus-summary-sort-by-score t]
1898 ["Sort by lines" gnus-summary-sort-by-lines t]
1899 ["Sort by characters" gnus-summary-sort-by-chars t])
1901 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1902 ["Describe group" gnus-summary-describe-group t]
1903 ["Read manual" gnus-info-find-node t])
1905 ["Pick and read" gnus-pick-mode t]
1906 ["Binary" gnus-binary-mode t])
1908 ["Regenerate" gnus-summary-prepare t]
1909 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1910 ["Toggle threading" gnus-summary-toggle-threads t])
1911 ["Filter articles..." gnus-summary-execute-command t]
1912 ["Run command on subjects..." gnus-summary-universal-argument t]
1913 ["Search articles forward..." gnus-summary-search-article-forward t]
1914 ["Search articles backward..." gnus-summary-search-article-backward t]
1915 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1916 ["Expand window" gnus-summary-expand-window t]
1917 ["Expire expirable articles" gnus-summary-expire-articles
1918 (gnus-check-backend-function
1919 'request-expire-articles gnus-newsgroup-name)]
1920 ["Edit local kill file" gnus-summary-edit-local-kill t]
1921 ["Edit main kill file" gnus-summary-edit-global-kill t]
1922 ["Edit group parameters" gnus-summary-edit-parameters t]
1923 ["Customize group parameters" gnus-summary-customize-parameters t]
1924 ["Send a bug report" gnus-bug t]
1926 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1927 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
1928 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1929 ["Exit group" gnus-summary-exit t]
1930 ["Exit group without updating" gnus-summary-exit-no-update t]
1931 ["Exit and goto next group" gnus-summary-next-group t]
1932 ["Exit and goto prev group" gnus-summary-prev-group t]
1933 ["Reselect group" gnus-summary-reselect-current-group t]
1934 ["Rescan group" gnus-summary-rescan-group t]
1935 ["Update dribble" gnus-summary-save-newsrc t])))
1937 (gnus-run-hooks 'gnus-summary-menu-hook)))
1939 (defun gnus-score-set-default (var value)
1940 "A version of set that updates the GNU Emacs menu-bar."
1942 ;; It is the message that forces the active status to be updated.
1945 (defun gnus-make-score-map (type)
1946 "Make a summary score map of type TYPE."
1949 (let ((headers '(("author" "from" string)
1950 ("subject" "subject" string)
1951 ("article body" "body" string)
1952 ("article head" "head" string)
1953 ("xref" "xref" string)
1954 ("extra header" "extra" string)
1955 ("lines" "lines" number)
1956 ("followups to author" "followup" string)))
1957 (types '((number ("less than" <)
1960 (string ("substring" s)
1964 (perms '(("temporary" (current-time-string))
1972 (if (eq type 'lower)
1977 (setq header (car headers))
1983 (let ((ts (cdr (assoc (nth 2 header) types)))
1999 'gnus-summary-score-entry
2001 (if (or (string= (nth 1 header)
2003 (string= (nth 1 header)
2006 (list 'gnus-summary-header
2008 (list 'quote (nth 1 (car ts)))
2009 (list 'gnus-score-delta-default
2016 (list (nreverse outp))))
2019 (list (nreverse outt))))
2021 (setq headers (cdr headers)))
2022 (list (nreverse outh))))))))
2026 (defun gnus-summary-mode (&optional group)
2027 "Major mode for reading articles.
2029 All normal editing commands are switched off.
2030 \\<gnus-summary-mode-map>
2031 Each line in this buffer represents one article. To read an
2032 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2033 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2036 You can also post articles and send mail from this buffer. To
2037 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2038 of an article, type `\\[gnus-summary-reply]'.
2040 There are approx. one gazillion commands you can execute in this
2041 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2043 The following commands are available:
2045 \\{gnus-summary-mode-map}"
2047 (when (gnus-visual-p 'summary-menu 'menu)
2048 (gnus-summary-make-menu-bar))
2049 (kill-all-local-variables)
2050 (gnus-summary-make-local-variables)
2051 (gnus-make-thread-indent-array)
2052 (gnus-simplify-mode-line)
2053 (setq major-mode 'gnus-summary-mode)
2054 (setq mode-name "Summary")
2055 (make-local-variable 'minor-mode-alist)
2056 (use-local-map gnus-summary-mode-map)
2057 (buffer-disable-undo)
2058 (setq buffer-read-only t) ;Disable modification
2059 (setq truncate-lines t)
2060 (setq selective-display t)
2061 (setq selective-display-ellipses t) ;Display `...'
2062 (gnus-summary-set-display-table)
2063 (gnus-set-default-directory)
2064 (setq gnus-newsgroup-name group)
2065 (make-local-variable 'gnus-summary-line-format)
2066 (make-local-variable 'gnus-summary-line-format-spec)
2067 (make-local-variable 'gnus-summary-dummy-line-format)
2068 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2069 (make-local-variable 'gnus-summary-mark-positions)
2070 (make-local-hook 'pre-command-hook)
2071 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2072 (gnus-run-hooks 'gnus-summary-mode-hook)
2073 (mm-enable-multibyte)
2074 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2075 (gnus-update-summary-mark-positions))
2077 (defun gnus-summary-make-local-variables ()
2078 "Make all the local summary buffer variables."
2080 (dolist (local gnus-summary-local-variables)
2083 (if (eq (cdr local) 'global)
2084 ;; Copy the global value of the variable.
2085 (setq global (symbol-value (car local)))
2086 ;; Use the value from the list.
2087 (setq global (eval (cdr local))))
2088 (set (make-local-variable (car local)) global))
2089 ;; Simple nil-valued local variable.
2090 (set (make-local-variable local) nil)))))
2092 (defun gnus-summary-clear-local-variables ()
2093 (let ((locals gnus-summary-local-variables))
2095 (if (consp (car locals))
2096 (and (vectorp (caar locals))
2097 (set (caar locals) nil))
2098 (and (vectorp (car locals))
2099 (set (car locals) nil)))
2100 (setq locals (cdr locals)))))
2102 ;; Summary data functions.
2104 (defmacro gnus-data-number (data)
2107 (defmacro gnus-data-set-number (data number)
2108 `(setcar ,data ,number))
2110 (defmacro gnus-data-mark (data)
2113 (defmacro gnus-data-set-mark (data mark)
2114 `(setcar (nthcdr 1 ,data) ,mark))
2116 (defmacro gnus-data-pos (data)
2119 (defmacro gnus-data-set-pos (data pos)
2120 `(setcar (nthcdr 2 ,data) ,pos))
2122 (defmacro gnus-data-header (data)
2125 (defmacro gnus-data-set-header (data header)
2126 `(setf (nth 3 ,data) ,header))
2128 (defmacro gnus-data-level (data)
2131 (defmacro gnus-data-unread-p (data)
2132 `(= (nth 1 ,data) gnus-unread-mark))
2134 (defmacro gnus-data-read-p (data)
2135 `(/= (nth 1 ,data) gnus-unread-mark))
2137 (defmacro gnus-data-pseudo-p (data)
2138 `(consp (nth 3 ,data)))
2140 (defmacro gnus-data-find (number)
2141 `(assq ,number gnus-newsgroup-data))
2143 (defmacro gnus-data-find-list (number &optional data)
2144 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2145 (memq (assq ,number bdata)
2148 (defmacro gnus-data-make (number mark pos header level)
2149 `(list ,number ,mark ,pos ,header ,level))
2151 (defun gnus-data-enter (after-article number mark pos header level offset)
2152 (let ((data (gnus-data-find-list after-article)))
2154 (error "No such article: %d" after-article))
2155 (setcdr data (cons (gnus-data-make number mark pos header level)
2157 (setq gnus-newsgroup-data-reverse nil)
2158 (gnus-data-update-list (cddr data) offset)))
2160 (defun gnus-data-enter-list (after-article list &optional offset)
2162 (let ((data (and after-article (gnus-data-find-list after-article)))
2166 (let ((odata gnus-newsgroup-data))
2167 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2169 (gnus-data-update-list odata offset)))
2170 ;; Find the last element in the list to be spliced into the main
2173 (setq list (cdr list)))
2176 (setcdr list gnus-newsgroup-data)
2177 (setq gnus-newsgroup-data ilist)
2179 (gnus-data-update-list (cdr list) offset)))
2180 (setcdr list (cdr data))
2183 (gnus-data-update-list (cdr list) offset))))
2184 (setq gnus-newsgroup-data-reverse nil))))
2186 (defun gnus-data-remove (article &optional offset)
2187 (let ((data gnus-newsgroup-data))
2188 (if (= (gnus-data-number (car data)) article)
2190 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2191 gnus-newsgroup-data-reverse nil)
2193 (gnus-data-update-list gnus-newsgroup-data offset)))
2195 (when (= (gnus-data-number (cadr data)) article)
2196 (setcdr data (cddr data))
2198 (gnus-data-update-list (cdr data) offset))
2200 gnus-newsgroup-data-reverse nil))
2201 (setq data (cdr data))))))
2203 (defmacro gnus-data-list (backward)
2205 (or gnus-newsgroup-data-reverse
2206 (setq gnus-newsgroup-data-reverse
2207 (reverse gnus-newsgroup-data)))
2208 gnus-newsgroup-data))
2210 (defun gnus-data-update-list (data offset)
2211 "Add OFFSET to the POS of all data entries in DATA."
2212 (setq gnus-newsgroup-data-reverse nil)
2214 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2215 (setq data (cdr data))))
2217 (defun gnus-summary-article-pseudo-p (article)
2218 "Say whether this article is a pseudo article or not."
2219 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2221 (defmacro gnus-summary-article-sparse-p (article)
2222 "Say whether this article is a sparse article or not."
2223 `(memq ,article gnus-newsgroup-sparse))
2225 (defmacro gnus-summary-article-ancient-p (article)
2226 "Say whether this article is a sparse article or not."
2227 `(memq ,article gnus-newsgroup-ancient))
2229 (defun gnus-article-parent-p (number)
2230 "Say whether this article is a parent or not."
2231 (let ((data (gnus-data-find-list number)))
2232 (and (cdr data) ; There has to be an article after...
2233 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2234 (gnus-data-level (nth 1 data))))))
2236 (defun gnus-article-children (number)
2237 "Return a list of all children to NUMBER."
2238 (let* ((data (gnus-data-find-list number))
2239 (level (gnus-data-level (car data)))
2241 (setq data (cdr data))
2243 (= (gnus-data-level (car data)) (1+ level)))
2244 (push (gnus-data-number (car data)) children)
2245 (setq data (cdr data)))
2248 (defmacro gnus-summary-skip-intangible ()
2249 "If the current article is intangible, then jump to a different article."
2250 '(let ((to (get-text-property (point) 'gnus-intangible)))
2251 (and to (gnus-summary-goto-subject to))))
2253 (defmacro gnus-summary-article-intangible-p ()
2254 "Say whether this article is intangible or not."
2255 '(get-text-property (point) 'gnus-intangible))
2257 (defun gnus-article-read-p (article)
2258 "Say whether ARTICLE is read or not."
2259 (not (or (memq article gnus-newsgroup-marked)
2260 (memq article gnus-newsgroup-unreads)
2261 (memq article gnus-newsgroup-unselected)
2262 (memq article gnus-newsgroup-dormant))))
2264 ;; Some summary mode macros.
2266 (defmacro gnus-summary-article-number ()
2267 "The article number of the article on the current line.
2268 If there isn's an article number here, then we return the current
2271 (gnus-summary-skip-intangible)
2272 (or (get-text-property (point) 'gnus-number)
2273 (gnus-summary-last-subject))))
2275 (defmacro gnus-summary-article-header (&optional number)
2276 "Return the header of article NUMBER."
2277 `(gnus-data-header (gnus-data-find
2278 ,(or number '(gnus-summary-article-number)))))
2280 (defmacro gnus-summary-thread-level (&optional number)
2281 "Return the level of thread that starts with article NUMBER."
2282 `(if (and (eq gnus-summary-make-false-root 'dummy)
2283 (get-text-property (point) 'gnus-intangible))
2285 (gnus-data-level (gnus-data-find
2286 ,(or number '(gnus-summary-article-number))))))
2288 (defmacro gnus-summary-article-mark (&optional number)
2289 "Return the mark of article NUMBER."
2290 `(gnus-data-mark (gnus-data-find
2291 ,(or number '(gnus-summary-article-number)))))
2293 (defmacro gnus-summary-article-pos (&optional number)
2294 "Return the position of the line of article NUMBER."
2295 `(gnus-data-pos (gnus-data-find
2296 ,(or number '(gnus-summary-article-number)))))
2298 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2299 (defmacro gnus-summary-article-subject (&optional number)
2300 "Return current subject string or nil if nothing."
2303 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2304 '(gnus-data-header (assq (gnus-summary-article-number)
2305 gnus-newsgroup-data)))))
2308 (mail-header-subject headers))))
2310 (defmacro gnus-summary-article-score (&optional number)
2311 "Return current article score."
2312 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2313 gnus-newsgroup-scored))
2314 gnus-summary-default-score 0))
2316 (defun gnus-summary-article-children (&optional number)
2317 "Return a list of article numbers that are children of article NUMBER."
2318 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2319 (level (gnus-data-level (car data)))
2321 (while (and (setq data (cdr data))
2322 (> (setq l (gnus-data-level (car data))) level))
2323 (and (= (1+ level) l)
2324 (push (gnus-data-number (car data))
2326 (nreverse children)))
2328 (defun gnus-summary-article-parent (&optional number)
2329 "Return the article number of the parent of article NUMBER."
2330 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2331 (gnus-data-list t)))
2332 (level (gnus-data-level (car data))))
2334 () ; This is a root.
2335 ;; We search until we find an article with a level less than
2336 ;; this one. That function has to be the parent.
2337 (while (and (setq data (cdr data))
2338 (not (< (gnus-data-level (car data)) level))))
2339 (and data (gnus-data-number (car data))))))
2341 (defun gnus-unread-mark-p (mark)
2342 "Say whether MARK is the unread mark."
2343 (= mark gnus-unread-mark))
2345 (defun gnus-read-mark-p (mark)
2346 "Say whether MARK is one of the marks that mark as read.
2347 This is all marks except unread, ticked, dormant, and expirable."
2348 (not (or (= mark gnus-unread-mark)
2349 (= mark gnus-ticked-mark)
2350 (= mark gnus-dormant-mark)
2351 (= mark gnus-expirable-mark))))
2353 (defmacro gnus-article-mark (number)
2354 "Return the MARK of article NUMBER.
2355 This macro should only be used when computing the mark the \"first\"
2356 time; i.e., when generating the summary lines. After that,
2357 `gnus-summary-article-mark' should be used to examine the
2360 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2361 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2362 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2363 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2364 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2365 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2366 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2367 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2368 gnus-ancient-mark))))
2370 ;; Saving hidden threads.
2372 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2373 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2375 (defmacro gnus-save-hidden-threads (&rest forms)
2376 "Save hidden threads, eval FORMS, and restore the hidden threads."
2377 (let ((config (make-symbol "config")))
2378 `(let ((,config (gnus-hidden-threads-configuration)))
2382 (gnus-restore-hidden-threads-configuration ,config)))))
2384 (defun gnus-data-compute-positions ()
2385 "Compute the positions of all articles."
2386 (setq gnus-newsgroup-data-reverse nil)
2387 (let ((data gnus-newsgroup-data))
2389 (gnus-save-hidden-threads
2390 (gnus-summary-show-all-threads)
2391 (goto-char (point-min))
2393 (while (get-text-property (point) 'gnus-intangible)
2395 (gnus-data-set-pos (car data) (+ (point) 3))
2396 (setq data (cdr data))
2397 (forward-line 1))))))
2399 (defun gnus-hidden-threads-configuration ()
2400 "Return the current hidden threads configuration."
2403 (goto-char (point-min))
2404 (while (search-forward "\r" nil t)
2405 (push (1- (point)) config))
2408 (defun gnus-restore-hidden-threads-configuration (config)
2409 "Restore hidden threads configuration from CONFIG."
2410 (let (point buffer-read-only)
2411 (while (setq point (pop config))
2412 (when (and (< point (point-max))
2414 (eq (char-after) ?\n))
2415 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2417 ;; Various summary mode internalish functions.
2419 (defun gnus-mouse-pick-article (e)
2422 (gnus-summary-next-page nil t))
2424 (defun gnus-summary-set-display-table ()
2425 ;; Change the display table. Odd characters have a tendency to mess
2426 ;; up nicely formatted displays - we make all possible glyphs
2427 ;; display only a single character.
2429 ;; We start from the standard display table, if any.
2430 (let ((table (or (copy-sequence standard-display-table)
2431 (make-display-table)))
2433 ;; Nix out all the control chars...
2434 (while (>= (setq i (1- i)) 0)
2435 (aset table i [??]))
2436 ;; ... but not newline and cr, of course. (cr is necessary for the
2437 ;; selective display).
2438 (aset table ?\n nil)
2439 (aset table ?\r nil)
2440 ;; We keep TAB as well.
2441 (aset table ?\t nil)
2442 ;; We nix out any glyphs over 126 that are not set already.
2444 (while (>= (setq i (1- i)) 127)
2445 ;; Only modify if the entry is nil.
2446 (unless (aref table i)
2447 (aset table i [??]))))
2448 (setq buffer-display-table table)))
2450 (defun gnus-summary-setup-buffer (group)
2451 "Initialize summary buffer."
2452 (let ((buffer (concat "*Summary " group "*")))
2453 (if (get-buffer buffer)
2456 (setq gnus-summary-buffer (current-buffer))
2457 (not gnus-newsgroup-prepared))
2458 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2459 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2460 (gnus-summary-mode group)
2462 (gnus-carpal-setup-buffer 'summary))
2463 (unless gnus-single-article-buffer
2464 (make-local-variable 'gnus-article-buffer)
2465 (make-local-variable 'gnus-article-current)
2466 (make-local-variable 'gnus-original-article-buffer))
2467 (setq gnus-newsgroup-name group)
2470 (defun gnus-set-global-variables ()
2471 ;; Set the global equivalents of the summary buffer-local variables
2472 ;; to the latest values they had. These reflect the summary buffer
2473 ;; that was in action when the last article was fetched.
2474 (when (eq major-mode 'gnus-summary-mode)
2475 (setq gnus-summary-buffer (current-buffer))
2476 (let ((name gnus-newsgroup-name)
2477 (marked gnus-newsgroup-marked)
2478 (unread gnus-newsgroup-unreads)
2479 (headers gnus-current-headers)
2480 (data gnus-newsgroup-data)
2481 (summary gnus-summary-buffer)
2482 (article-buffer gnus-article-buffer)
2483 (original gnus-original-article-buffer)
2484 (gac gnus-article-current)
2485 (reffed gnus-reffed-article-number)
2486 (score-file gnus-current-score-file)
2487 (default-charset gnus-newsgroup-charset))
2489 (set-buffer gnus-group-buffer)
2490 (setq gnus-newsgroup-name name
2491 gnus-newsgroup-marked marked
2492 gnus-newsgroup-unreads unread
2493 gnus-current-headers headers
2494 gnus-newsgroup-data data
2495 gnus-article-current gac
2496 gnus-summary-buffer summary
2497 gnus-article-buffer article-buffer
2498 gnus-original-article-buffer original
2499 gnus-reffed-article-number reffed
2500 gnus-current-score-file score-file
2501 gnus-newsgroup-charset default-charset)
2502 ;; The article buffer also has local variables.
2503 (when (gnus-buffer-live-p gnus-article-buffer)
2504 (set-buffer gnus-article-buffer)
2505 (setq gnus-summary-buffer summary))))))
2507 (defun gnus-summary-article-unread-p (article)
2508 "Say whether ARTICLE is unread or not."
2509 (memq article gnus-newsgroup-unreads))
2511 (defun gnus-summary-first-article-p (&optional article)
2512 "Return whether ARTICLE is the first article in the buffer."
2513 (if (not (setq article (or article (gnus-summary-article-number))))
2515 (eq article (caar gnus-newsgroup-data))))
2517 (defun gnus-summary-last-article-p (&optional article)
2518 "Return whether ARTICLE is the last article in the buffer."
2519 (if (not (setq article (or article (gnus-summary-article-number))))
2520 ;; All non-existent numbers are the last article. :-)
2522 (not (cdr (gnus-data-find-list article)))))
2524 (defun gnus-make-thread-indent-array ()
2526 (unless (and gnus-thread-indent-array
2527 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2528 (setq gnus-thread-indent-array (make-vector 201 "")
2529 gnus-thread-indent-array-level gnus-thread-indent-level)
2531 (aset gnus-thread-indent-array n
2532 (make-string (* n gnus-thread-indent-level) ? ))
2535 (defun gnus-update-summary-mark-positions ()
2536 "Compute where the summary marks are to go."
2538 (when (gnus-buffer-exists-p gnus-summary-buffer)
2539 (set-buffer gnus-summary-buffer))
2540 (let ((gnus-replied-mark 129)
2541 (gnus-score-below-mark 130)
2542 (gnus-score-over-mark 130)
2543 (gnus-download-mark 131)
2544 (spec gnus-summary-line-format-spec)
2547 (gnus-set-work-buffer)
2548 (let ((gnus-summary-line-format-spec spec)
2549 (gnus-newsgroup-downloadable '((0 . t))))
2550 (gnus-summary-insert-line
2551 [0 "" "" "" "" "" 0 0 "" nil] 0 nil 128 t nil "" nil 1)
2552 (goto-char (point-min))
2553 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2555 (goto-char (point-min))
2556 (push (cons 'replied (and (search-forward "\201" nil t)
2559 (goto-char (point-min))
2560 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2562 (goto-char (point-min))
2563 (push (cons 'download
2564 (and (search-forward "\203" nil t) (- (point) 2)))
2566 (setq gnus-summary-mark-positions pos))))
2568 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2569 "Insert a dummy root in the summary buffer."
2571 (gnus-add-text-properties
2572 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2573 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2575 (defun gnus-summary-from-or-to-or-newsgroups (header)
2576 (let ((to (cdr (assq 'To (mail-header-extra header))))
2577 (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header))))
2578 (mail-parse-charset gnus-newsgroup-charset)
2579 (mail-parse-ignored-charsets
2580 (save-excursion (set-buffer gnus-summary-buffer)
2581 gnus-newsgroup-ignored-charsets)))
2584 gnus-ignored-from-addresses
2585 (string-match gnus-ignored-from-addresses
2586 (mail-header-from header)))
2588 (or (car (funcall gnus-extract-address-components
2590 gnus-decode-encoded-word-function to)))
2591 (funcall gnus-decode-encoded-word-function to))))
2593 gnus-ignored-from-addresses
2594 (string-match gnus-ignored-from-addresses
2595 (mail-header-from header)))
2596 (concat "=> " newsgroups))
2598 (or (car (funcall gnus-extract-address-components
2599 (mail-header-from header)))
2600 (mail-header-from header))))))
2602 (defun gnus-summary-insert-line (gnus-tmp-header
2603 gnus-tmp-level gnus-tmp-current
2604 gnus-tmp-unread gnus-tmp-replied
2605 gnus-tmp-expirable gnus-tmp-subject-or-nil
2606 &optional gnus-tmp-dummy gnus-tmp-score
2608 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2609 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2610 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2611 (gnus-tmp-score-char
2612 (if (or (null gnus-summary-default-score)
2613 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2614 gnus-summary-zcore-fuzz))
2616 (if (< gnus-tmp-score gnus-summary-default-score)
2617 gnus-score-below-mark gnus-score-over-mark)))
2619 (cond (gnus-tmp-process gnus-process-mark)
2620 ((memq gnus-tmp-current gnus-newsgroup-cached)
2622 (gnus-tmp-replied gnus-replied-mark)
2623 ((memq gnus-tmp-current gnus-newsgroup-saved)
2625 (t gnus-unread-mark)))
2626 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2629 ((string-match "<[^>]+> *$" gnus-tmp-from)
2630 (let ((beg (match-beginning 0)))
2631 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2632 (substring gnus-tmp-from (1+ (match-beginning 0))
2633 (1- (match-end 0))))
2634 (substring gnus-tmp-from 0 beg))))
2635 ((string-match "(.+)" gnus-tmp-from)
2636 (substring gnus-tmp-from
2637 (1+ (match-beginning 0)) (1- (match-end 0))))
2639 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2640 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2641 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2642 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2643 (buffer-read-only nil))
2644 (when (string= gnus-tmp-name "")
2645 (setq gnus-tmp-name gnus-tmp-from))
2646 (unless (numberp gnus-tmp-lines)
2647 (setq gnus-tmp-lines 0))
2648 (gnus-put-text-property
2650 (progn (eval gnus-summary-line-format-spec) (point))
2651 'gnus-number gnus-tmp-number)
2652 (when (gnus-visual-p 'summary-highlight 'highlight)
2654 (gnus-run-hooks 'gnus-summary-update-hook)
2657 (defun gnus-summary-update-line (&optional dont-update)
2658 ;; Update summary line after change.
2659 (when (and gnus-summary-default-score
2660 (not gnus-summary-inhibit-highlight))
2661 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2662 (article (gnus-summary-article-number))
2663 (score (gnus-summary-article-score article)))
2665 (if (and gnus-summary-mark-below
2666 (< (gnus-summary-article-score)
2667 gnus-summary-mark-below))
2668 ;; This article has a low score, so we mark it as read.
2669 (when (memq article gnus-newsgroup-unreads)
2670 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2671 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2672 ;; This article was previously marked as read on account
2673 ;; of a low score, but now it has risen, so we mark it as
2675 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2676 (gnus-summary-update-mark
2677 (if (or (null gnus-summary-default-score)
2678 (<= (abs (- score gnus-summary-default-score))
2679 gnus-summary-zcore-fuzz))
2681 (if (< score gnus-summary-default-score)
2682 gnus-score-below-mark gnus-score-over-mark))
2684 ;; Do visual highlighting.
2685 (when (gnus-visual-p 'summary-highlight 'highlight)
2686 (gnus-run-hooks 'gnus-summary-update-hook)))))
2688 (defvar gnus-tmp-new-adopts nil)
2690 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2691 "Return the number of articles in THREAD.
2692 This may be 0 in some cases -- if none of the articles in
2693 the thread are to be displayed."
2695 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2697 ((not (listp thread))
2699 ((and (consp thread) (cdr thread))
2702 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2705 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2708 (when (and level (zerop level) gnus-tmp-new-adopts)
2711 'gnus-summary-number-of-articles-in-thread
2712 gnus-tmp-new-adopts))))
2714 (if (> number 1) gnus-not-empty-thread-mark
2715 gnus-empty-thread-mark)
2718 (defun gnus-summary-set-local-parameters (group)
2719 "Go through the local params of GROUP and set all variable specs in that list."
2720 (let ((params (gnus-group-find-parameter group))
2723 (setq elem (car params)
2724 params (cdr params))
2725 (and (consp elem) ; Has to be a cons.
2726 (consp (cdr elem)) ; The cdr has to be a list.
2727 (symbolp (car elem)) ; Has to be a symbol in there.
2728 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2729 (ignore-errors ; So we set it.
2730 (make-local-variable (car elem))
2731 (set (car elem) (eval (nth 1 elem))))))))
2733 (defun gnus-summary-read-group (group &optional show-all no-article
2734 kill-buffer no-display backward
2736 "Start reading news in newsgroup GROUP.
2737 If SHOW-ALL is non-nil, already read articles are also listed.
2738 If NO-ARTICLE is non-nil, no article is selected initially.
2739 If NO-DISPLAY, don't generate a summary buffer."
2743 (let ((gnus-auto-select-next nil))
2744 (or (gnus-summary-read-group-1
2745 group show-all no-article
2746 kill-buffer no-display
2749 select-articles nil)))))
2750 (eq gnus-auto-select-next 'quietly))
2751 (set-buffer gnus-group-buffer)
2752 ;; The entry function called above goes to the next
2753 ;; group automatically, so we go two groups back
2754 ;; if we are searching for the previous group.
2756 (gnus-group-prev-unread-group 2))
2757 (if (not (equal group (gnus-group-group-name)))
2758 (setq group (gnus-group-group-name))
2762 (defun gnus-summary-read-group-1 (group show-all no-article
2763 kill-buffer no-display
2764 &optional select-articles)
2765 ;; Killed foreign groups can't be entered.
2766 (when (and (not (gnus-group-native-p group))
2767 (not (gnus-gethash group gnus-newsrc-hashtb)))
2768 (error "Dead non-native groups can't be entered"))
2769 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2770 (let* ((new-group (gnus-summary-setup-buffer group))
2771 (quit-config (gnus-group-quit-config group))
2772 (did-select (and new-group (gnus-select-newsgroup
2773 group show-all select-articles))))
2775 ;; This summary buffer exists already, so we just select it.
2777 (gnus-set-global-variables)
2779 (gnus-kill-or-deaden-summary kill-buffer))
2780 (gnus-configure-windows 'summary 'force)
2781 (gnus-set-mode-line 'summary)
2782 (gnus-summary-position-point)
2785 ;; We couldn't select this group.
2787 (when (and (eq major-mode 'gnus-summary-mode)
2788 (not (equal (current-buffer) kill-buffer)))
2789 (kill-buffer (current-buffer))
2790 (if (not quit-config)
2792 ;; Update the info -- marks might need to be removed,
2794 (gnus-summary-update-info)
2795 (set-buffer gnus-group-buffer)
2796 (gnus-group-jump-to-group group)
2797 (gnus-group-next-unread-group 1))
2798 (gnus-handle-ephemeral-exit quit-config)))
2799 (gnus-message 3 "Can't select group")
2801 ;; The user did a `C-g' while prompting for number of articles,
2802 ;; so we exit this group.
2803 ((eq did-select 'quit)
2804 (and (eq major-mode 'gnus-summary-mode)
2805 (not (equal (current-buffer) kill-buffer))
2806 (kill-buffer (current-buffer)))
2808 (gnus-kill-or-deaden-summary kill-buffer))
2809 (if (not quit-config)
2811 (set-buffer gnus-group-buffer)
2812 (gnus-group-jump-to-group group)
2813 (gnus-group-next-unread-group 1)
2814 (gnus-configure-windows 'group 'force))
2815 (gnus-handle-ephemeral-exit quit-config))
2816 ;; Finally signal the quit.
2818 ;; The group was successfully selected.
2820 (gnus-set-global-variables)
2821 ;; Save the active value in effect when the group was entered.
2822 (setq gnus-newsgroup-active
2824 (gnus-active gnus-newsgroup-name)))
2825 ;; You can change the summary buffer in some way with this hook.
2826 (gnus-run-hooks 'gnus-select-group-hook)
2827 ;; Set any local variables in the group parameters.
2828 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2829 (gnus-update-format-specifications
2830 nil 'summary 'summary-mode 'summary-dummy)
2831 (gnus-update-summary-mark-positions)
2832 ;; Do score processing.
2833 (when gnus-use-scoring
2834 (gnus-possibly-score-headers))
2835 ;; Check whether to fill in the gaps in the threads.
2836 (when gnus-build-sparse-threads
2837 (gnus-build-sparse-threads))
2838 ;; Find the initial limit.
2839 (if gnus-show-threads
2841 (let ((gnus-newsgroup-dormant nil))
2842 (gnus-summary-initial-limit show-all))
2843 (gnus-summary-initial-limit show-all))
2844 ;; When untreaded, all articles are always shown.
2845 (setq gnus-newsgroup-limit
2847 (lambda (header) (mail-header-number header))
2848 gnus-newsgroup-headers)))
2849 ;; Generate the summary buffer.
2851 (gnus-summary-prepare))
2852 (when gnus-use-trees
2853 (gnus-tree-open group)
2854 (setq gnus-summary-highlight-line-function
2855 'gnus-tree-highlight-article))
2856 ;; If the summary buffer is empty, but there are some low-scored
2857 ;; articles or some excluded dormants, we include these in the
2859 (when (and (zerop (buffer-size))
2861 (cond (gnus-newsgroup-dormant
2862 (gnus-summary-limit-include-dormant))
2863 ((and gnus-newsgroup-scored show-all)
2864 (gnus-summary-limit-include-expunged t))))
2865 ;; Function `gnus-apply-kill-file' must be called in this hook.
2866 (gnus-run-hooks 'gnus-apply-kill-hook)
2867 (if (and (zerop (buffer-size))
2870 ;; This newsgroup is empty.
2871 (gnus-summary-catchup-and-exit nil t)
2872 (gnus-message 6 "No unread news")
2874 (gnus-kill-or-deaden-summary kill-buffer))
2875 ;; Return nil from this function.
2877 ;; Hide conversation thread subtrees. We cannot do this in
2878 ;; gnus-summary-prepare-hook since kill processing may not
2879 ;; work with hidden articles.
2880 (and gnus-show-threads
2881 gnus-thread-hide-subtree
2882 (gnus-summary-hide-all-threads))
2884 (gnus-kill-or-deaden-summary kill-buffer))
2885 ;; Show first unread article if requested.
2886 (if (and (not no-article)
2888 gnus-newsgroup-unreads
2889 gnus-auto-select-first)
2891 (gnus-configure-windows 'summary)
2893 ((eq gnus-auto-select-first 'best)
2894 (gnus-summary-best-unread-article))
2895 ((eq gnus-auto-select-first t)
2896 (gnus-summary-first-unread-article))
2897 ((gnus-functionp gnus-auto-select-first)
2898 (funcall gnus-auto-select-first))))
2899 ;; Don't select any articles, just move point to the first
2900 ;; article in the group.
2901 (goto-char (point-min))
2902 (gnus-summary-position-point)
2903 (gnus-configure-windows 'summary 'force)
2904 (gnus-set-mode-line 'summary))
2905 (when (get-buffer-window gnus-group-buffer t)
2906 ;; Gotta use windows, because recenter does weird stuff if
2907 ;; the current buffer ain't the displayed window.
2908 (let ((owin (selected-window)))
2909 (select-window (get-buffer-window gnus-group-buffer t))
2910 (when (gnus-group-goto-group group)
2912 (select-window owin)))
2913 ;; Mark this buffer as "prepared".
2914 (setq gnus-newsgroup-prepared t)
2915 (gnus-run-hooks 'gnus-summary-prepared-hook)
2918 (defun gnus-summary-prepare ()
2919 "Generate the summary buffer."
2921 (let ((buffer-read-only nil))
2923 (setq gnus-newsgroup-data nil
2924 gnus-newsgroup-data-reverse nil)
2925 (gnus-run-hooks 'gnus-summary-generate-hook)
2926 ;; Generate the buffer, either with threads or without.
2927 (when gnus-newsgroup-headers
2928 (gnus-summary-prepare-threads
2929 (if gnus-show-threads
2930 (gnus-sort-gathered-threads
2931 (funcall gnus-summary-thread-gathering-function
2933 (gnus-cut-threads (gnus-make-threads)))))
2934 ;; Unthreaded display.
2935 (gnus-sort-articles gnus-newsgroup-headers))))
2936 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2937 ;; Call hooks for modifying summary buffer.
2938 (goto-char (point-min))
2939 (gnus-run-hooks 'gnus-summary-prepare-hook)))
2941 (defsubst gnus-general-simplify-subject (subject)
2942 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2945 ;; Truncate the subject.
2946 (gnus-simplify-subject-functions
2947 (gnus-map-function gnus-simplify-subject-functions subject))
2948 ((numberp gnus-summary-gather-subject-limit)
2949 (setq subject (gnus-simplify-subject-re subject))
2950 (if (> (length subject) gnus-summary-gather-subject-limit)
2951 (substring subject 0 gnus-summary-gather-subject-limit)
2953 ;; Fuzzily simplify it.
2954 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2955 (gnus-simplify-subject-fuzzy subject))
2956 ;; Just remove the leading "Re:".
2958 (gnus-simplify-subject-re subject))))
2960 (if (and gnus-summary-gather-exclude-subject
2961 (string-match gnus-summary-gather-exclude-subject subject))
2962 nil ; This article shouldn't be gathered
2965 (defun gnus-summary-simplify-subject-query ()
2966 "Query where the respool algorithm would put this article."
2968 (gnus-summary-select-article)
2969 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2971 (defun gnus-gather-threads-by-subject (threads)
2972 "Gather threads by looking at Subject headers."
2973 (if (not gnus-summary-make-false-root)
2975 (let ((hashtb (gnus-make-hashtable 1024))
2978 subject hthread whole-subject)
2980 (setq subject (gnus-general-simplify-subject
2981 (setq whole-subject (mail-header-subject
2984 (if (setq hthread (gnus-gethash subject hashtb))
2986 ;; We enter a dummy root into the thread, if we
2987 ;; haven't done that already.
2988 (unless (stringp (caar hthread))
2989 (setcar hthread (list whole-subject (car hthread))))
2990 ;; We add this new gathered thread to this gathered
2992 (setcdr (car hthread)
2993 (nconc (cdar hthread) (list (car threads))))
2994 ;; Remove it from the list of threads.
2995 (setcdr prev (cdr threads))
2996 (setq threads prev))
2997 ;; Enter this thread into the hash table.
2998 (gnus-sethash subject threads hashtb)))
3000 (setq threads (cdr threads)))
3003 (defun gnus-gather-threads-by-references (threads)
3004 "Gather threads by looking at References headers."
3005 (let ((idhashtb (gnus-make-hashtable 1024))
3006 (thhashtb (gnus-make-hashtable 1024))
3009 ids references id gthread gid entered ref)
3011 (when (setq references (mail-header-references (caar threads)))
3012 (setq id (mail-header-id (caar threads))
3013 ids (gnus-split-references references)
3015 (while (setq ref (pop ids))
3016 (setq ids (delete ref ids))
3017 (if (not (setq gid (gnus-gethash ref idhashtb)))
3019 (gnus-sethash ref id idhashtb)
3020 (gnus-sethash id threads thhashtb))
3021 (setq gthread (gnus-gethash gid thhashtb))
3023 ;; We enter a dummy root into the thread, if we
3024 ;; haven't done that already.
3025 (unless (stringp (caar gthread))
3026 (setcar gthread (list (mail-header-subject (caar gthread))
3028 ;; We add this new gathered thread to this gathered
3030 (setcdr (car gthread)
3031 (nconc (cdar gthread) (list (car threads)))))
3032 ;; Add it into the thread hash table.
3033 (gnus-sethash id gthread thhashtb)
3035 ;; Remove it from the list of threads.
3036 (setcdr prev (cdr threads))
3037 (setq threads prev))))
3039 (setq threads (cdr threads)))
3042 (defun gnus-sort-gathered-threads (threads)
3043 "Sort subtreads inside each gathered thread by article number."
3044 (let ((result threads))
3046 (when (stringp (caar threads))
3047 (setcdr (car threads)
3048 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3049 (setq threads (cdr threads)))
3052 (defun gnus-thread-loop-p (root thread)
3053 "Say whether ROOT is in THREAD."
3054 (let ((stack (list thread))
3057 (while (setq thread (pop stack))
3058 (setq th (cdr thread))
3060 (not (eq (caar th) root)))
3063 ;; We have found a loop.
3065 (setcdr thread (delq (car th) (cdr thread)))
3066 (if (boundp (setq ref-dep (intern "none"
3067 gnus-newsgroup-dependencies)))
3068 (setcdr (symbol-value ref-dep)
3069 (nconc (cdr (symbol-value ref-dep))
3071 (set ref-dep (list nil (car th))))
3074 ;; Push all the subthreads onto the stack.
3075 (push (cdr thread) stack)))
3078 (defun gnus-make-threads ()
3079 "Go through the dependency hashtb and find the roots. Return all threads."
3081 (while (catch 'infloop
3084 ;; Deal with self-referencing References loops.
3085 (when (and (car (symbol-value refs))
3092 (car (symbol-value refs)) thread))
3093 (cdr (symbol-value refs)))))))
3096 (unless (car (symbol-value refs))
3097 ;; These threads do not refer back to any other articles,
3098 ;; so they're roots.
3099 (setq threads (append (cdr (symbol-value refs)) threads))))
3100 gnus-newsgroup-dependencies)))
3103 ;; Build the thread tree.
3104 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3105 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3107 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3108 if it was already present.
3110 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3111 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3112 Message-IDs will be renamed be renamed to a unique Message-ID before
3115 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3116 (let* ((id (mail-header-id header))
3117 (id-dep (and id (intern id dependencies)))
3118 ref ref-dep ref-header)
3119 ;; Enter this `header' in the `dependencies' table.
3123 ;; The first two cases do the normal part: enter a new `header'
3124 ;; in the `dependencies' table.
3125 ((not (boundp id-dep))
3126 (set id-dep (list header)))
3127 ((null (car (symbol-value id-dep)))
3128 (setcar (symbol-value id-dep) header))
3130 ;; From here the `header' was already present in the
3131 ;; `dependencies' table.
3133 ;; Overrides an existing entry;
3134 ;; just set the header part of the entry.
3135 (setcar (symbol-value id-dep) header))
3137 ;; Renames the existing `header' to a unique Message-ID.
3138 ((not gnus-summary-ignore-duplicates)
3139 ;; An article with this Message-ID has already been seen.
3140 ;; We rename the Message-ID.
3141 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3143 (mail-header-set-id header id))
3145 ;; The last case ignores an existing entry, except it adds any
3146 ;; additional Xrefs (in case the two articles came from different
3148 ;; Also sets `header' to `nil' meaning that the `dependencies'
3149 ;; table was *not* modified.
3151 (mail-header-set-xref
3152 (car (symbol-value id-dep))
3153 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3155 (or (mail-header-xref header) "")))
3159 ;; First check if that we are not creating a References loop.
3160 (setq ref (gnus-parent-id (mail-header-references header)))
3162 (setq ref-dep (intern-soft ref dependencies))
3164 (setq ref-header (car (symbol-value ref-dep))))
3165 (if (string= id ref)
3166 ;; Yuk! This is a reference loop. Make the article be a
3169 (mail-header-set-references (car (symbol-value id-dep)) "none")
3171 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3172 (setq ref (gnus-parent-id (mail-header-references header)))
3173 (setq ref-dep (intern (or ref "none") dependencies))
3174 (if (boundp ref-dep)
3175 (setcdr (symbol-value ref-dep)
3176 (nconc (cdr (symbol-value ref-dep))
3177 (list (symbol-value id-dep))))
3178 (set ref-dep (list nil (symbol-value id-dep)))))
3181 (defun gnus-build-sparse-threads ()
3182 (let ((headers gnus-newsgroup-headers)
3183 (mail-parse-charset gnus-newsgroup-charset)
3184 (gnus-summary-ignore-duplicates t)
3185 header references generation relations
3186 subject child end new-child date)
3187 ;; First we create an alist of generations/relations, where
3188 ;; generations is how much we trust the relation, and the relation
3190 (gnus-message 7 "Making sparse threads...")
3192 (nnheader-set-temp-buffer " *gnus sparse threads*")
3193 (while (setq header (pop headers))
3194 (when (and (setq references (mail-header-references header))
3195 (not (string= references "")))
3197 (setq child (mail-header-id header)
3198 subject (mail-header-subject header)
3199 date (mail-header-date header)
3201 (while (search-backward ">" nil t)
3202 (setq end (1+ (point)))
3203 (when (search-backward "<" nil t)
3204 (setq new-child (buffer-substring (point) end))
3205 (push (list (incf generation)
3206 child (setq child new-child)
3210 (push (list (1+ generation) child nil subject) relations))
3212 (kill-buffer (current-buffer)))
3213 ;; Sort over trustworthiness.
3216 (when (gnus-dependencies-add-header
3217 (make-full-mail-header
3218 gnus-reffed-article-number
3219 (nth 3 relation) "" (or (nth 4 relation) "")
3221 (or (nth 2 relation) "") 0 0 "")
3222 gnus-newsgroup-dependencies nil)
3223 (push gnus-reffed-article-number gnus-newsgroup-limit)
3224 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3225 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3226 gnus-newsgroup-reads)
3227 (decf gnus-reffed-article-number)))
3228 (sort relations 'car-less-than-car))
3229 (gnus-message 7 "Making sparse threads...done")))
3231 (defun gnus-build-old-threads ()
3232 ;; Look at all the articles that refer back to old articles, and
3233 ;; fetch the headers for the articles that aren't there. This will
3234 ;; build complete threads - if the roots haven't been expired by the
3236 (let ((mail-parse-charset gnus-newsgroup-charset)
3240 (when (not (car (symbol-value refs)))
3241 (setq heads (cdr (symbol-value refs)))
3243 (if (memq (mail-header-number (caar heads))
3244 gnus-newsgroup-dormant)
3245 (setq heads (cdr heads))
3246 (setq id (symbol-name refs))
3247 (while (and (setq id (gnus-build-get-header id))
3248 (not (car (gnus-id-to-thread id)))))
3249 (setq heads nil)))))
3250 gnus-newsgroup-dependencies)))
3252 ;; This function has to be called with point after the article number
3253 ;; on the beginning of the line.
3254 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3255 (let ((eol (gnus-point-at-eol))
3256 (buffer (current-buffer))
3259 ;; overview: [num subject from date id refs chars lines misc]
3262 (narrow-to-region (point) eol)
3267 (make-full-mail-header
3269 (funcall gnus-decode-encoded-word-function
3270 (nnheader-nov-field)) ; subject
3271 (funcall gnus-decode-encoded-word-function
3272 (nnheader-nov-field)) ; from
3273 (nnheader-nov-field) ; date
3274 (nnheader-nov-read-message-id) ; id
3275 (nnheader-nov-field) ; refs
3276 (nnheader-nov-read-integer) ; chars
3277 (nnheader-nov-read-integer) ; lines
3279 (nnheader-nov-field)) ; misc
3280 (nnheader-nov-parse-extra)))) ; extra
3284 (when gnus-alter-header-function
3285 (funcall gnus-alter-header-function header))
3286 (gnus-dependencies-add-header header dependencies force-new)))
3288 (defun gnus-build-get-header (id)
3289 ;; Look through the buffer of NOV lines and find the header to
3290 ;; ID. Enter this line into the dependencies hash table, and return
3291 ;; the id of the parent article (if any).
3292 (let ((deps gnus-newsgroup-dependencies)
3296 (set-buffer nntp-server-buffer)
3297 (let ((case-fold-search nil))
3298 (goto-char (point-min))
3299 (while (and (not found)
3300 (search-forward id nil t))
3302 (setq found (looking-at
3303 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3304 (regexp-quote id))))
3305 (or found (beginning-of-line 2)))
3309 (setq header (gnus-nov-parse-line
3310 (read (current-buffer)) deps))
3311 (gnus-parent-id (mail-header-references header))))))
3313 (let ((number (mail-header-number header)))
3314 (push number gnus-newsgroup-limit)
3315 (push header gnus-newsgroup-headers)
3316 (if (memq number gnus-newsgroup-unselected)
3318 (push number gnus-newsgroup-unreads)
3319 (setq gnus-newsgroup-unselected
3320 (delq number gnus-newsgroup-unselected)))
3321 (push number gnus-newsgroup-ancient)))))))
3323 (defun gnus-build-all-threads ()
3324 "Read all the headers."
3325 (let ((gnus-summary-ignore-duplicates t)
3326 (mail-parse-charset gnus-newsgroup-charset)
3327 (dependencies gnus-newsgroup-dependencies)
3330 (set-buffer nntp-server-buffer)
3331 (let ((case-fold-search nil))
3332 (goto-char (point-min))
3335 (setq article (read (current-buffer))
3336 header (gnus-nov-parse-line article dependencies)))
3339 (set-buffer gnus-summary-buffer)
3340 (push header gnus-newsgroup-headers)
3341 (if (memq (setq article (mail-header-number header))
3342 gnus-newsgroup-unselected)
3344 (push article gnus-newsgroup-unreads)
3345 (setq gnus-newsgroup-unselected
3346 (delq article gnus-newsgroup-unselected)))
3347 (push article gnus-newsgroup-ancient)))
3348 (forward-line 1)))))))
3350 (defun gnus-summary-update-article-line (article header)
3351 "Update the line for ARTICLE using HEADERS."
3352 (let* ((id (mail-header-id header))
3353 (thread (gnus-id-to-thread id)))
3355 (error "Article in no thread"))
3356 ;; Update the thread.
3357 (setcar thread header)
3358 (gnus-summary-goto-subject article)
3359 (let* ((datal (gnus-data-find-list article))
3361 (length (when (cdr datal)
3362 (- (gnus-data-pos data)
3363 (gnus-data-pos (cadr datal)))))
3364 (buffer-read-only nil)
3365 (level (gnus-summary-thread-level)))
3367 (gnus-summary-insert-line
3368 header level nil (gnus-article-mark article)
3369 (memq article gnus-newsgroup-replied)
3370 (memq article gnus-newsgroup-expirable)
3371 ;; Only insert the Subject string when it's different
3372 ;; from the previous Subject string.
3377 (mail-header-subject
3380 (gnus-data-find-list
3382 (gnus-data-list t)))))
3383 ;; Error on the side of excessive subjects.
3385 (mail-header-subject header)))
3387 (mail-header-subject header))
3388 nil (cdr (assq article gnus-newsgroup-scored))
3389 (memq article gnus-newsgroup-processable))
3391 (gnus-data-update-list
3392 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3394 (defun gnus-summary-update-article (article &optional iheader)
3395 "Update ARTICLE in the summary buffer."
3396 (set-buffer gnus-summary-buffer)
3397 (let* ((header (gnus-summary-article-header article))
3398 (id (mail-header-id header))
3399 (data (gnus-data-find article))
3400 (thread (gnus-id-to-thread id))
3401 (references (mail-header-references header))
3405 (when (and references
3406 (not (equal "" references)))
3409 (buffer-read-only nil)
3415 (delq thread parent)))
3416 (if (gnus-summary-insert-subject id header)
3417 ;; Set the (possibly) new article number in the data structure.
3418 (gnus-data-set-number data (gnus-id-to-article id))
3422 (defun gnus-rebuild-thread (id &optional line)
3423 "Rebuild the thread containing ID.
3424 If LINE, insert the rebuilt thread starting on line LINE."
3425 (let ((buffer-read-only nil)
3426 old-pos current thread data)
3427 (if (not gnus-show-threads)
3428 (setq thread (list (car (gnus-id-to-thread id))))
3429 ;; Get the thread this article is part of.
3430 (setq thread (gnus-remove-thread id)))
3431 (setq old-pos (gnus-point-at-bol))
3432 (setq current (save-excursion
3433 (and (zerop (forward-line -1))
3434 (gnus-summary-article-number))))
3435 ;; If this is a gathered thread, we have to go some re-gathering.
3436 (when (stringp (car thread))
3437 (let ((subject (car thread))
3439 (setq thread (cdr thread))
3441 (unless (memq (setq thr (gnus-id-to-thread
3443 (mail-header-id (caar thread)))))
3446 (setq thread (cdr thread)))
3447 ;; We now have all (unique) roots.
3448 (if (= (length roots) 1)
3449 ;; All the loose roots are now one solid root.
3450 (setq thread (car roots))
3451 (setq thread (cons subject (gnus-sort-threads roots))))))
3453 ;; We then insert this thread into the summary buffer.
3455 (goto-char (point-min))
3456 (forward-line (1- line)))
3457 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3458 (if gnus-show-threads
3459 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3460 (gnus-summary-prepare-unthreaded thread))
3461 (setq data (nreverse gnus-newsgroup-data))
3462 (setq threads gnus-newsgroup-threads))
3463 ;; We splice the new data into the data structure.
3464 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3465 ;;!!! then we want to insert at the beginning of the buffer.
3466 ;;!!! That happens to be true with Gnus now, but that may
3467 ;;!!! change in the future. Perhaps.
3468 (gnus-data-enter-list
3469 (if line nil current) data (- (point) old-pos))
3470 (setq gnus-newsgroup-threads
3471 (nconc threads gnus-newsgroup-threads))
3472 (gnus-data-compute-positions))))
3474 (defun gnus-number-to-header (number)
3475 "Return the header for article NUMBER."
3476 (let ((headers gnus-newsgroup-headers))
3478 (not (= number (mail-header-number (car headers)))))
3483 (defun gnus-parent-headers (in-headers &optional generation)
3484 "Return the headers of the GENERATIONeth parent of HEADERS."
3486 (setq generation 1))
3488 (headers in-headers)
3491 (not (zerop generation))
3492 (setq references (mail-header-references headers)))
3493 (setq headers (if (and references
3494 (setq parent (gnus-parent-id references)))
3495 (car (gnus-id-to-thread parent))
3498 (and (not (eq headers in-headers))
3501 (defun gnus-id-to-thread (id)
3502 "Return the (sub-)thread where ID appears."
3503 (gnus-gethash id gnus-newsgroup-dependencies))
3505 (defun gnus-id-to-article (id)
3506 "Return the article number of ID."
3507 (let ((thread (gnus-id-to-thread id)))
3510 (mail-header-number (car thread)))))
3512 (defun gnus-id-to-header (id)
3513 "Return the article headers of ID."
3514 (car (gnus-id-to-thread id)))
3516 (defun gnus-article-displayed-root-p (article)
3517 "Say whether ARTICLE is a root(ish) article."
3518 (let ((level (gnus-summary-thread-level article))
3519 (refs (mail-header-references (gnus-summary-article-header article)))
3525 ((null (gnus-parent-id refs)) t)
3527 (null (setq particle (gnus-id-to-article
3528 (gnus-parent-id refs))))
3529 (null (gnus-summary-thread-level particle)))))))
3531 (defun gnus-root-id (id)
3532 "Return the id of the root of the thread where ID appears."
3534 (while (and id (setq prev (car (gnus-id-to-thread id))))
3536 id (gnus-parent-id (mail-header-references prev))))
3539 (defun gnus-articles-in-thread (thread)
3540 "Return the list of articles in THREAD."
3541 (cons (mail-header-number (car thread))
3542 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3544 (defun gnus-remove-thread (id &optional dont-remove)
3545 "Remove the thread that has ID in it."
3546 (let (headers thread last-id)
3547 ;; First go up in this thread until we find the root.
3548 (setq last-id (gnus-root-id id)
3549 headers (message-flatten-list (gnus-id-to-thread last-id)))
3550 ;; We have now found the real root of this thread. It might have
3551 ;; been gathered into some loose thread, so we have to search
3552 ;; through the threads to find the thread we wanted.
3553 (let ((threads gnus-newsgroup-threads)
3556 (setq sub (car threads))
3557 (if (stringp (car sub))
3558 ;; This is a gathered thread, so we look at the roots
3559 ;; below it to find whether this article is in this
3562 (setq sub (cdr sub))
3564 (when (member (caar sub) headers)
3565 (setq thread (car threads)
3568 (setq sub (cdr sub))))
3569 ;; It's an ordinary thread, so we check it.
3570 (when (eq (car sub) (car headers))
3573 (setq threads (cdr threads)))
3574 ;; If this article is in no thread, then it's a root.
3577 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3578 (setq thread (gnus-id-to-thread last-id)))
3581 thread ; We return this thread.
3583 (if (stringp (car thread))
3585 ;; If we use dummy roots, then we have to remove the
3586 ;; dummy root as well.
3587 (when (eq gnus-summary-make-false-root 'dummy)
3588 ;; We go to the dummy root by going to
3589 ;; the first sub-"thread", and then one line up.
3590 (gnus-summary-goto-article
3591 (mail-header-number (caadr thread)))
3594 (gnus-data-compute-positions))
3595 (setq thread (cdr thread))
3597 (gnus-remove-thread-1 (car thread))
3598 (setq thread (cdr thread))))
3599 (gnus-remove-thread-1 thread))))))))
3601 (defun gnus-remove-thread-1 (thread)
3602 "Remove the thread THREAD recursively."
3603 (let ((number (mail-header-number (pop thread)))
3605 (setq thread (reverse thread))
3607 (gnus-remove-thread-1 (pop thread)))
3608 (when (setq d (gnus-data-find number))
3609 (goto-char (gnus-data-pos d))
3610 (gnus-summary-show-thread)
3613 (- (gnus-point-at-bol)
3615 (1+ (gnus-point-at-eol))
3616 (gnus-delete-line)))))))
3618 (defun gnus-sort-threads (threads)
3620 (if (not gnus-thread-sort-functions)
3622 (gnus-message 8 "Sorting threads...")
3624 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3625 (gnus-message 8 "Sorting threads...done"))))
3627 (defun gnus-sort-articles (articles)
3629 (when gnus-article-sort-functions
3630 (gnus-message 7 "Sorting articles...")
3632 (setq gnus-newsgroup-headers
3633 (sort articles (gnus-make-sort-function
3634 gnus-article-sort-functions)))
3635 (gnus-message 7 "Sorting articles...done"))))
3637 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3638 (defmacro gnus-thread-header (thread)
3639 ;; Return header of first article in THREAD.
3640 ;; Note that THREAD must never, ever be anything else than a variable -
3641 ;; using some other form will lead to serious barfage.
3642 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3643 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3644 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
3647 (defsubst gnus-article-sort-by-number (h1 h2)
3648 "Sort articles by article number."
3649 (< (mail-header-number h1)
3650 (mail-header-number h2)))
3652 (defun gnus-thread-sort-by-number (h1 h2)
3653 "Sort threads by root article number."
3654 (gnus-article-sort-by-number
3655 (gnus-thread-header h1) (gnus-thread-header h2)))
3657 (defsubst gnus-article-sort-by-lines (h1 h2)
3658 "Sort articles by article Lines header."
3659 (< (mail-header-lines h1)
3660 (mail-header-lines h2)))
3662 (defun gnus-thread-sort-by-lines (h1 h2)
3663 "Sort threads by root article Lines header."
3664 (gnus-article-sort-by-lines
3665 (gnus-thread-header h1) (gnus-thread-header h2)))
3667 (defsubst gnus-article-sort-by-chars (h1 h2)
3668 "Sort articles by octet length."
3669 (< (mail-header-chars h1)
3670 (mail-header-chars h2)))
3672 (defun gnus-thread-sort-by-chars (h1 h2)
3673 "Sort threads by root article octet length."
3674 (gnus-article-sort-by-chars
3675 (gnus-thread-header h1) (gnus-thread-header h2)))
3677 (defsubst gnus-article-sort-by-author (h1 h2)
3678 "Sort articles by root author."
3680 (let ((extract (funcall
3681 gnus-extract-address-components
3682 (mail-header-from h1))))
3683 (or (car extract) (cadr extract) ""))
3684 (let ((extract (funcall
3685 gnus-extract-address-components
3686 (mail-header-from h2))))
3687 (or (car extract) (cadr extract) ""))))
3689 (defun gnus-thread-sort-by-author (h1 h2)
3690 "Sort threads by root author."
3691 (gnus-article-sort-by-author
3692 (gnus-thread-header h1) (gnus-thread-header h2)))
3694 (defsubst gnus-article-sort-by-subject (h1 h2)
3695 "Sort articles by root subject."
3697 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3698 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3700 (defun gnus-thread-sort-by-subject (h1 h2)
3701 "Sort threads by root subject."
3702 (gnus-article-sort-by-subject
3703 (gnus-thread-header h1) (gnus-thread-header h2)))
3705 (defsubst gnus-article-sort-by-date (h1 h2)
3706 "Sort articles by root article date."
3708 (gnus-date-get-time (mail-header-date h1))
3709 (gnus-date-get-time (mail-header-date h2))))
3711 (defun gnus-thread-sort-by-date (h1 h2)
3712 "Sort threads by root article date."
3713 (gnus-article-sort-by-date
3714 (gnus-thread-header h1) (gnus-thread-header h2)))
3716 (defsubst gnus-article-sort-by-score (h1 h2)
3717 "Sort articles by root article score.
3718 Unscored articles will be counted as having a score of zero."
3719 (> (or (cdr (assq (mail-header-number h1)
3720 gnus-newsgroup-scored))
3721 gnus-summary-default-score 0)
3722 (or (cdr (assq (mail-header-number h2)
3723 gnus-newsgroup-scored))
3724 gnus-summary-default-score 0)))
3726 (defun gnus-thread-sort-by-score (h1 h2)
3727 "Sort threads by root article score."
3728 (gnus-article-sort-by-score
3729 (gnus-thread-header h1) (gnus-thread-header h2)))
3731 (defun gnus-thread-sort-by-total-score (h1 h2)
3732 "Sort threads by the sum of all scores in the thread.
3733 Unscored articles will be counted as having a score of zero."
3734 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3736 (defun gnus-thread-total-score (thread)
3737 ;; This function find the total score of THREAD.
3738 (cond ((null thread)
3741 (if (stringp (car thread))
3742 (apply gnus-thread-score-function 0
3743 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3744 (gnus-thread-total-score-1 thread)))
3746 (gnus-thread-total-score-1 (list thread)))))
3748 (defun gnus-thread-total-score-1 (root)
3749 ;; This function find the total score of the thread below ROOT.
3750 (setq root (car root))
3751 (apply gnus-thread-score-function
3753 (mapcar 'gnus-thread-total-score
3754 (cdr (gnus-id-to-thread (mail-header-id root))))
3755 (when (> (mail-header-number root) 0)
3756 (list (or (cdr (assq (mail-header-number root)
3757 gnus-newsgroup-scored))
3758 gnus-summary-default-score 0))))
3759 (list gnus-summary-default-score)
3762 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3763 (defvar gnus-tmp-prev-subject nil)
3764 (defvar gnus-tmp-false-parent nil)
3765 (defvar gnus-tmp-root-expunged nil)
3766 (defvar gnus-tmp-dummy-line nil)
3768 (defvar gnus-tmp-header)
3769 (defun gnus-extra-header (type &optional header)
3770 "Return the extra header of TYPE."
3771 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
3774 (defun gnus-summary-prepare-threads (threads)
3775 "Prepare summary buffer from THREADS and indentation LEVEL.
3776 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3777 or a straight list of headers."
3778 (gnus-message 7 "Generating summary...")
3780 (setq gnus-newsgroup-threads threads)
3783 (let ((gnus-tmp-level 0)
3784 (default-score (or gnus-summary-default-score 0))
3785 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3786 thread number subject stack state gnus-tmp-gathered beg-match
3787 new-roots gnus-tmp-new-adopts thread-end
3788 gnus-tmp-header gnus-tmp-unread
3789 gnus-tmp-replied gnus-tmp-subject-or-nil
3790 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3791 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3792 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3794 (setq gnus-tmp-prev-subject nil)
3796 (if (vectorp (car threads))
3797 ;; If this is a straight (sic) list of headers, then a
3798 ;; threaded summary display isn't required, so we just create
3799 ;; an unthreaded one.
3800 (gnus-summary-prepare-unthreaded threads)
3802 ;; Do the threaded display.
3804 (while (or threads stack gnus-tmp-new-adopts new-roots)
3806 (if (and (= gnus-tmp-level 0)
3809 (not gnus-tmp-false-parent)
3810 (or gnus-tmp-new-adopts new-roots))
3811 (if gnus-tmp-new-adopts
3812 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3813 thread (list (car gnus-tmp-new-adopts))
3814 gnus-tmp-header (caar thread)
3815 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3817 (setq thread (list (car new-roots))
3818 gnus-tmp-header (caar thread)
3819 new-roots (cdr new-roots))))
3822 ;; If there are some threads, we do them before the
3823 ;; threads on the stack.
3824 (setq thread threads
3825 gnus-tmp-header (caar thread))
3826 ;; There were no current threads, so we pop something off
3828 (setq state (car stack)
3829 gnus-tmp-level (car state)
3832 gnus-tmp-header (caar thread))))
3834 (setq gnus-tmp-false-parent nil)
3835 (setq gnus-tmp-root-expunged nil)
3836 (setq thread-end nil)
3838 (if (stringp gnus-tmp-header)
3839 ;; The header is a dummy root.
3841 ((eq gnus-summary-make-false-root 'adopt)
3842 ;; We let the first article adopt the rest.
3843 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3845 (setq gnus-tmp-gathered
3847 (lambda (h) (mail-header-number (car h)))
3850 (setq thread (cons (list (caar thread)
3853 (setq gnus-tmp-level -1
3854 gnus-tmp-false-parent t))
3855 ((eq gnus-summary-make-false-root 'empty)
3856 ;; We print adopted articles with empty subject fields.
3857 (setq gnus-tmp-gathered
3859 (lambda (h) (mail-header-number (car h)))
3862 (setq gnus-tmp-level -1))
3863 ((eq gnus-summary-make-false-root 'dummy)
3864 ;; We remember that we probably want to output a dummy
3866 (setq gnus-tmp-dummy-line gnus-tmp-header)
3867 (setq gnus-tmp-prev-subject gnus-tmp-header))
3869 ;; We do not make a root for the gathered
3870 ;; sub-threads at all.
3871 (setq gnus-tmp-level -1)))
3873 (setq number (mail-header-number gnus-tmp-header)
3874 subject (mail-header-subject gnus-tmp-header))
3877 ;; If the thread has changed subject, we might want to make
3878 ;; this subthread into a root.
3879 ((and (null gnus-thread-ignore-subject)
3880 (not (zerop gnus-tmp-level))
3881 gnus-tmp-prev-subject
3883 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3884 (setq new-roots (nconc new-roots (list (car thread)))
3886 gnus-tmp-header nil))
3887 ;; If the article lies outside the current limit,
3888 ;; then we do not display it.
3889 ((not (memq number gnus-newsgroup-limit))
3890 (setq gnus-tmp-gathered
3892 (lambda (h) (mail-header-number (car h)))
3895 (setq gnus-tmp-new-adopts (if (cdar thread)
3896 (append gnus-tmp-new-adopts
3898 gnus-tmp-new-adopts)
3900 gnus-tmp-header nil)
3901 (when (zerop gnus-tmp-level)
3902 (setq gnus-tmp-root-expunged t)))
3903 ;; Perhaps this article is to be marked as read?
3904 ((and gnus-summary-mark-below
3905 (< (or (cdr (assq number gnus-newsgroup-scored))
3907 gnus-summary-mark-below)
3908 ;; Don't touch sparse articles.
3909 (not (gnus-summary-article-sparse-p number))
3910 (not (gnus-summary-article-ancient-p number)))
3911 (setq gnus-newsgroup-unreads
3912 (delq number gnus-newsgroup-unreads))
3913 (if gnus-newsgroup-auto-expire
3914 (push number gnus-newsgroup-expirable)
3915 (push (cons number gnus-low-score-mark)
3916 gnus-newsgroup-reads))))
3918 (when gnus-tmp-header
3919 ;; We may have an old dummy line to output before this
3921 (when (and gnus-tmp-dummy-line
3924 (mail-header-subject gnus-tmp-header)))
3925 (gnus-summary-insert-dummy-line
3926 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3927 (setq gnus-tmp-dummy-line nil))
3929 ;; Compute the mark.
3930 (setq gnus-tmp-unread (gnus-article-mark number))
3932 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3933 gnus-tmp-header gnus-tmp-level)
3934 gnus-newsgroup-data)
3936 ;; Actually insert the line.
3938 gnus-tmp-subject-or-nil
3940 ((and gnus-thread-ignore-subject
3941 gnus-tmp-prev-subject
3942 (not (inline (gnus-subject-equal
3943 gnus-tmp-prev-subject subject))))
3945 ((zerop gnus-tmp-level)
3946 (if (and (eq gnus-summary-make-false-root 'empty)
3947 (memq number gnus-tmp-gathered)
3948 gnus-tmp-prev-subject
3949 (inline (gnus-subject-equal
3950 gnus-tmp-prev-subject subject)))
3951 gnus-summary-same-subject
3953 (t gnus-summary-same-subject)))
3954 (if (and (eq gnus-summary-make-false-root 'adopt)
3955 (= gnus-tmp-level 1)
3956 (memq number gnus-tmp-gathered))
3957 (setq gnus-tmp-opening-bracket ?\<
3958 gnus-tmp-closing-bracket ?\>)
3959 (setq gnus-tmp-opening-bracket ?\[
3960 gnus-tmp-closing-bracket ?\]))
3962 gnus-tmp-indentation
3963 (aref gnus-thread-indent-array gnus-tmp-level)
3964 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3965 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3966 gnus-summary-default-score 0)
3968 (if (or (null gnus-summary-default-score)
3969 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3970 gnus-summary-zcore-fuzz))
3972 (if (< gnus-tmp-score gnus-summary-default-score)
3973 gnus-score-below-mark gnus-score-over-mark))
3975 (cond ((memq number gnus-newsgroup-processable)
3977 ((memq number gnus-newsgroup-cached)
3979 ((memq number gnus-newsgroup-replied)
3981 ((memq number gnus-newsgroup-saved)
3983 (t gnus-unread-mark))
3984 gnus-tmp-from (mail-header-from gnus-tmp-header)
3987 ((string-match "<[^>]+> *$" gnus-tmp-from)
3988 (setq beg-match (match-beginning 0))
3989 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3990 (substring gnus-tmp-from (1+ (match-beginning 0))
3991 (1- (match-end 0))))
3992 (substring gnus-tmp-from 0 beg-match)))
3993 ((string-match "(.+)" gnus-tmp-from)
3994 (substring gnus-tmp-from
3995 (1+ (match-beginning 0)) (1- (match-end 0))))
3997 (when (string= gnus-tmp-name "")
3998 (setq gnus-tmp-name gnus-tmp-from))
3999 (unless (numberp gnus-tmp-lines)
4000 (setq gnus-tmp-lines 0))
4001 (gnus-put-text-property
4003 (progn (eval gnus-summary-line-format-spec) (point))
4004 'gnus-number number)
4007 (gnus-run-hooks 'gnus-summary-update-hook)
4010 (setq gnus-tmp-prev-subject subject)))
4012 (when (nth 1 thread)
4013 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
4014 (incf gnus-tmp-level)
4015 (setq threads (if thread-end nil (cdar thread)))
4017 (setq gnus-tmp-level 0)))))
4018 (gnus-message 7 "Generating summary...done"))
4020 (defun gnus-summary-prepare-unthreaded (headers)
4021 "Generate an unthreaded summary buffer based on HEADERS."
4022 (let (header number mark)
4027 ;; We may have to root out some bad articles...
4028 (when (memq (setq number (mail-header-number
4029 (setq header (pop headers))))
4030 gnus-newsgroup-limit)
4031 ;; Mark article as read when it has a low score.
4032 (when (and gnus-summary-mark-below
4033 (< (or (cdr (assq number gnus-newsgroup-scored))
4034 gnus-summary-default-score 0)
4035 gnus-summary-mark-below)
4036 (not (gnus-summary-article-ancient-p number)))
4037 (setq gnus-newsgroup-unreads
4038 (delq number gnus-newsgroup-unreads))
4039 (if gnus-newsgroup-auto-expire
4040 (push number gnus-newsgroup-expirable)
4041 (push (cons number gnus-low-score-mark)
4042 gnus-newsgroup-reads)))
4044 (setq mark (gnus-article-mark number))
4045 (push (gnus-data-make number mark (1+ (point)) header 0)
4046 gnus-newsgroup-data)
4047 (gnus-summary-insert-line
4049 mark (memq number gnus-newsgroup-replied)
4050 (memq number gnus-newsgroup-expirable)
4051 (mail-header-subject header) nil
4052 (cdr (assq number gnus-newsgroup-scored))
4053 (memq number gnus-newsgroup-processable))))))
4055 (defun gnus-summary-remove-list-identifiers ()
4056 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4057 (let ((regexp (if (stringp gnus-list-identifiers)
4058 gnus-list-identifiers
4059 (mapconcat 'identity gnus-list-identifiers " *\\|"))))
4060 (dolist (header gnus-newsgroup-headers)
4061 (when (string-match (concat "\\(Re: +\\)?\\(" regexp " *\\)")
4062 (mail-header-subject header))
4063 (mail-header-set-subject
4064 header (concat (substring (mail-header-subject header)
4065 0 (match-beginning 2))
4066 (substring (mail-header-subject header)
4067 (match-end 2))))))))
4069 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4070 "Select newsgroup GROUP.
4071 If READ-ALL is non-nil, all articles in the group are selected.
4072 If SELECT-ARTICLES, only select those articles from GROUP."
4073 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4074 ;;!!! Dirty hack; should be removed.
4075 (gnus-summary-ignore-duplicates
4076 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4078 gnus-summary-ignore-duplicates))
4079 (info (nth 2 entry))
4080 articles fetched-articles cached)
4082 (unless (gnus-check-server
4083 (setq gnus-current-select-method
4084 (gnus-find-method-for-group group)))
4085 (error "Couldn't open server"))
4087 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4088 (gnus-activate-group group) ; Or we can activate it...
4089 (progn ; Or we bug out.
4090 (when (equal major-mode 'gnus-summary-mode)
4091 (kill-buffer (current-buffer)))
4092 (error "Couldn't request group %s: %s"
4093 group (gnus-status-message group))))
4095 (unless (gnus-request-group group t)
4096 (when (equal major-mode 'gnus-summary-mode)
4097 (kill-buffer (current-buffer)))
4098 (error "Couldn't request group %s: %s"
4099 group (gnus-status-message group)))
4101 (setq gnus-newsgroup-name group)
4102 (setq gnus-newsgroup-unselected nil)
4103 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4104 (gnus-summary-setup-default-charset)
4106 ;; Adjust and set lists of article marks.
4108 (gnus-adjust-marked-articles info))
4110 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4111 (when (gnus-virtual-group-p group)
4112 (setq cached gnus-newsgroup-cached))
4114 (setq gnus-newsgroup-unreads
4115 (gnus-set-difference
4116 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4117 gnus-newsgroup-dormant))
4119 (setq gnus-newsgroup-processable nil)
4121 (gnus-update-read-articles group gnus-newsgroup-unreads)
4123 (if (setq articles select-articles)
4124 (setq gnus-newsgroup-unselected
4125 (gnus-sorted-intersection
4126 gnus-newsgroup-unreads
4127 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4128 (setq articles (gnus-articles-to-read group read-all)))
4132 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4134 ((eq articles 0) nil)
4136 ;; Init the dependencies hash table.
4137 (setq gnus-newsgroup-dependencies
4138 (gnus-make-hashtable (length articles)))
4139 (gnus-set-global-variables)
4140 ;; Retrieve the headers and read them in.
4141 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
4142 (setq gnus-newsgroup-headers
4144 (setq gnus-headers-retrieved-by
4145 (gnus-retrieve-headers
4146 articles gnus-newsgroup-name
4147 ;; We might want to fetch old headers, but
4148 ;; not if there is only 1 article.
4150 (not (eq gnus-fetch-old-headers 'some))
4151 (not (numberp gnus-fetch-old-headers)))
4152 (> (length articles) 1))
4153 gnus-fetch-old-headers))))
4154 (gnus-get-newsgroup-headers-xover
4155 articles nil nil gnus-newsgroup-name t)
4156 (gnus-get-newsgroup-headers)))
4157 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
4159 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4161 (setq gnus-newsgroup-cached cached))
4163 ;; Suppress duplicates?
4164 (when gnus-suppress-duplicates
4165 (gnus-dup-suppress-articles))
4167 ;; Set the initial limit.
4168 (setq gnus-newsgroup-limit (copy-sequence articles))
4169 ;; Remove canceled articles from the list of unread articles.
4170 (setq gnus-newsgroup-unreads
4171 (gnus-set-sorted-intersection
4172 gnus-newsgroup-unreads
4173 (setq fetched-articles
4174 (mapcar (lambda (headers) (mail-header-number headers))
4175 gnus-newsgroup-headers))))
4176 ;; Removed marked articles that do not exist.
4177 (gnus-update-missing-marks
4178 (gnus-sorted-complement fetched-articles articles))
4179 ;; We might want to build some more threads first.
4180 (when (and gnus-fetch-old-headers
4181 (eq gnus-headers-retrieved-by 'nov))
4182 (if (eq gnus-fetch-old-headers 'invisible)
4183 (gnus-build-all-threads)
4184 (gnus-build-old-threads)))
4185 ;; Let the Gnus agent mark articles as read.
4187 (gnus-agent-get-undownloaded-list))
4188 ;; Remove list identifiers from subject
4189 (when gnus-list-identifiers
4190 (gnus-summary-remove-list-identifiers))
4191 ;; Check whether auto-expire is to be done in this group.
4192 (setq gnus-newsgroup-auto-expire
4193 (gnus-group-auto-expirable-p group))
4194 ;; Set up the article buffer now, if necessary.
4195 (unless gnus-single-article-buffer
4196 (gnus-article-setup-buffer))
4197 ;; First and last article in this newsgroup.
4198 (when gnus-newsgroup-headers
4199 (setq gnus-newsgroup-begin
4200 (mail-header-number (car gnus-newsgroup-headers))
4203 (gnus-last-element gnus-newsgroup-headers))))
4204 ;; GROUP is successfully selected.
4205 (or gnus-newsgroup-headers t)))))
4207 (defun gnus-articles-to-read (group &optional read-all)
4208 ;; Find out what articles the user wants to read.
4210 ;; Select all articles if `read-all' is non-nil, or if there
4211 ;; are no unread articles.
4213 (and (zerop (length gnus-newsgroup-marked))
4214 (zerop (length gnus-newsgroup-unreads)))
4215 (eq (gnus-group-find-parameter group 'display)
4218 (gnus-uncompress-range (gnus-active group))
4219 (gnus-cache-articles-in-group group))
4220 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4221 (copy-sequence gnus-newsgroup-unreads))
4223 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4224 (scored (length scored-list))
4225 (number (length articles))
4226 (marked (+ (length gnus-newsgroup-marked)
4227 (length gnus-newsgroup-dormant)))
4235 ((and (or (<= scored marked) (= scored number))
4236 (numberp gnus-large-newsgroup)
4237 (> number gnus-large-newsgroup))
4241 "How many articles from %s (default %d): "
4242 (gnus-limit-string gnus-newsgroup-name 35)
4244 (if (string-match "^[ \t]*$" input) number input)))
4245 ((and (> scored marked) (< scored number)
4246 (> (- scored number) 20))
4249 (format "%s %s (%d scored, %d total): "
4250 "How many articles from"
4251 group scored number))))
4252 (if (string-match "^[ \t]*$" input)
4256 (setq select (if (stringp select) (string-to-number select) select))
4257 (if (or (null select) (zerop select))
4259 (if (and (not (zerop scored)) (<= (abs select) scored))
4261 (setq articles (sort scored-list '<))
4262 (setq number (length articles)))
4263 (setq articles (copy-sequence articles)))
4265 (when (< (abs select) number)
4267 ;; Select the N oldest articles.
4268 (setcdr (nthcdr (1- (abs select)) articles) nil)
4269 ;; Select the N most recent articles.
4270 (setq articles (nthcdr (- number select) articles))))
4271 (setq gnus-newsgroup-unselected
4272 (gnus-sorted-intersection
4273 gnus-newsgroup-unreads
4274 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4277 (defun gnus-killed-articles (killed articles)
4280 (when (inline (gnus-member-of-range (car articles) killed))
4281 (push (car articles) out))
4282 (setq articles (cdr articles)))
4285 (defun gnus-uncompress-marks (marks)
4286 "Uncompress the mark ranges in MARKS."
4287 (let ((uncompressed '(score bookmark))
4290 (if (memq (caar marks) uncompressed)
4291 (push (car marks) out)
4292 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4293 (setq marks (cdr marks)))
4296 (defun gnus-adjust-marked-articles (info)
4297 "Set all article lists and remove all marks that are no longer valid."
4298 (let* ((marked-lists (gnus-info-marks info))
4299 (active (gnus-active (gnus-info-group info)))
4302 (types gnus-article-mark-lists)
4303 (uncompressed '(score bookmark killed))
4304 marks var articles article mark)
4307 (setq marks (pop marked-lists))
4308 (set (setq var (intern (format "gnus-newsgroup-%s"
4309 (car (rassq (setq mark (car marks))
4311 (if (memq (car marks) uncompressed) (cdr marks)
4312 (gnus-uncompress-range (cdr marks))))
4314 (setq articles (symbol-value var))
4316 ;; All articles have to be subsets of the active articles.
4318 ;; Adjust "simple" lists.
4319 ((memq mark '(tick dormant expire reply save))
4321 (when (or (< (setq article (pop articles)) min) (> article max))
4322 (set var (delq article (symbol-value var))))))
4324 ((memq mark uncompressed)
4325 (when (not (listp (cdr (symbol-value var))))
4326 (set var (list (symbol-value var))))
4327 (when (not (listp (cdr articles)))
4328 (setq articles (list articles)))
4330 (when (or (not (consp (setq article (pop articles))))
4331 (< (car article) min)
4332 (> (car article) max))
4333 (set var (delq article (symbol-value var))))))))))
4335 (defun gnus-update-missing-marks (missing)
4336 "Go through the list of MISSING articles and remove them from the mark lists."
4338 (let ((types gnus-article-mark-lists)
4340 ;; Go through all types.
4342 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4343 (when (symbol-value var)
4344 ;; This list has articles. So we delete all missing articles
4348 (set var (delq (pop m) (symbol-value var)))))))))
4350 (defun gnus-update-marks ()
4351 "Enter the various lists of marked articles into the newsgroup info list."
4352 (let ((types gnus-article-mark-lists)
4353 (info (gnus-get-info gnus-newsgroup-name))
4354 (uncompressed '(score bookmark killed))
4355 type list newmarked symbol delta-marks)
4357 ;; Add all marks lists to the list of marks lists.
4358 (while (setq type (pop types))
4359 (setq list (symbol-value
4361 (intern (format "gnus-newsgroup-%s"
4365 ;; Get rid of the entries of the articles that have the
4367 (when (and (eq (cdr type) 'score)
4371 (prev (cons nil list))
4374 (if (or (not (consp (car arts)))
4375 (= (cdar arts) gnus-summary-default-score))
4376 (setcdr prev (cdr arts))
4378 (setq arts (cdr arts)))
4379 (setq list (cdr all)))))
4381 (unless (memq (cdr type) uncompressed)
4382 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
4384 (when (gnus-check-backend-function
4385 'request-set-mark gnus-newsgroup-name)
4386 ;; uncompressed:s are not proper flags (they are cons cells)
4387 ;; cache is a internal gnus flag
4388 (unless (memq (cdr type) (cons 'cache uncompressed))
4389 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4390 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
4391 (add (gnus-remove-from-range
4392 (gnus-copy-sequence list) old)))
4394 (push (list add 'add (list (cdr type))) delta-marks))
4396 (push (list del 'del (list (cdr type))) delta-marks)))))
4399 (push (cons (cdr type) list) newmarked)))
4402 (unless (gnus-check-group gnus-newsgroup-name)
4403 (error "Can't open server for %s" gnus-newsgroup-name))
4404 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4406 ;; Enter these new marks into the info of the group.
4408 (setcar (nthcdr 3 info) newmarked)
4409 ;; Add the marks lists to the end of the info.
4411 (setcdr (nthcdr 2 info) (list newmarked))))
4413 ;; Cut off the end of the info if there's nothing else there.
4417 (when (nthcdr (decf i) info)
4418 (setcdr (nthcdr i info) nil)))))))
4420 (defun gnus-set-mode-line (where)
4421 "This function sets the mode line of the article or summary buffers.
4422 If WHERE is `summary', the summary mode line format will be used."
4423 ;; Is this mode line one we keep updated?
4424 (when (and (memq where gnus-updated-mode-lines)
4426 (intern (format "gnus-%s-mode-line-format-spec" where))))
4429 ;; We evaluate this in the summary buffer since these
4430 ;; variables are buffer-local to that buffer.
4431 (set-buffer gnus-summary-buffer)
4432 ;; We bind all these variables that are used in the `eval' form
4434 (let* ((mformat (symbol-value
4436 (format "gnus-%s-mode-line-format-spec" where))))
4437 (gnus-tmp-group-name gnus-newsgroup-name)
4438 (gnus-tmp-article-number (or gnus-current-article 0))
4439 (gnus-tmp-unread gnus-newsgroup-unreads)
4440 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4441 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4442 (gnus-tmp-unread-and-unselected
4443 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4444 (zerop gnus-tmp-unselected))
4446 ((zerop gnus-tmp-unselected)
4447 (format "{%d more}" gnus-tmp-unread-and-unticked))
4448 (t (format "{%d(+%d) more}"
4449 gnus-tmp-unread-and-unticked
4450 gnus-tmp-unselected))))
4452 (if (and gnus-current-headers
4453 (vectorp gnus-current-headers))
4454 (gnus-mode-string-quote
4455 (mail-header-subject gnus-current-headers))
4457 bufname-length max-len
4458 gnus-tmp-header);; passed as argument to any user-format-funcs
4459 (setq mode-string (eval mformat))
4460 (setq bufname-length (if (string-match "%b" mode-string)
4463 (if (eq where 'summary)
4465 (get-buffer gnus-article-buffer))))
4468 (setq max-len (max 4 (if gnus-mode-non-string-length
4470 gnus-mode-non-string-length
4472 (length mode-string))))
4473 ;; We might have to chop a bit of the string off...
4474 (when (> (length mode-string) max-len)
4476 (concat (truncate-string-to-width mode-string (- max-len 3))
4478 ;; Pad the mode string a bit.
4479 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4480 ;; Update the mode line.
4481 (setq mode-line-buffer-identification
4482 (gnus-mode-line-buffer-identification (list mode-string)))
4483 (set-buffer-modified-p t))))
4485 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4486 "Go through the HEADERS list and add all Xrefs to a hash table.
4487 The resulting hash table is returned, or nil if no Xrefs were found."
4488 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4489 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4490 (xref-hashtb (gnus-make-hashtable))
4491 start group entry number xrefs header)
4493 (setq header (pop headers))
4494 (when (and (setq xrefs (mail-header-xref header))
4495 (not (memq (setq number (mail-header-number header))
4498 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4499 (setq start (match-end 0))
4500 (setq group (if prefix
4501 (concat prefix (substring xrefs (match-beginning 1)
4503 (substring xrefs (match-beginning 1) (match-end 1))))
4505 (string-to-int (substring xrefs (match-beginning 2)
4507 (if (setq entry (gnus-gethash group xref-hashtb))
4508 (setcdr entry (cons number (cdr entry)))
4509 (gnus-sethash group (cons number nil) xref-hashtb)))))
4510 (and start xref-hashtb)))
4512 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4513 "Look through all the headers and mark the Xrefs as read."
4514 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4515 name entry info xref-hashtb idlist method nth4)
4517 (set-buffer gnus-group-buffer)
4518 (when (setq xref-hashtb
4519 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4522 (unless (string= from-newsgroup (setq name (symbol-name group)))
4523 (setq idlist (symbol-value group))
4524 ;; Dead groups are not updated.
4526 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4528 (when (stringp (setq nth4 (gnus-info-method info)))
4529 (setq nth4 (gnus-server-to-method nth4))))
4530 ;; Only do the xrefs if the group has the same
4531 ;; select method as the group we have just read.
4532 (or (gnus-methods-equal-p
4533 nth4 (gnus-find-method-for-group from-newsgroup))
4535 (equal nth4 (setq method (gnus-find-method-for-group
4537 (and (equal (car nth4) (car method))
4538 (equal (nth 1 nth4) (nth 1 method))))
4539 gnus-use-cross-reference
4540 (or (not (eq gnus-use-cross-reference t))
4542 ;; Only do cross-references on subscribed
4543 ;; groups, if that is what is wanted.
4544 (<= (gnus-info-level info) gnus-level-subscribed))
4545 (gnus-group-make-articles-read name idlist))))
4548 (defun gnus-compute-read-articles (group articles)
4549 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4550 (info (nth 2 entry))
4551 (active (gnus-active group))
4554 ;; First peel off all invalid article numbers.
4556 (let ((ids articles)
4558 (while (setq id (pop ids))
4559 (when (and first (> id (cdr active)))
4560 ;; We'll end up in this situation in one particular
4561 ;; obscure situation. If you re-scan a group and get
4562 ;; a new article that is cross-posted to a different
4563 ;; group that has not been re-scanned, you might get
4564 ;; crossposted article that has a higher number than
4565 ;; Gnus believes possible. So we re-activate this
4566 ;; group as well. This might mean doing the
4567 ;; crossposting thingy will *increase* the number
4568 ;; of articles in some groups. Tsk, tsk.
4569 (setq active (or (gnus-activate-group group) active)))
4570 (when (or (> id (cdr active))
4571 (< id (car active)))
4572 (setq articles (delq id articles))))))
4573 ;; If the read list is nil, we init it.
4575 (null (gnus-info-read info))
4577 (setq ninfo (cons 1 (1- (car active))))
4578 (setq ninfo (gnus-info-read info)))
4579 ;; Then we add the read articles to the range.
4581 ninfo (setq articles (sort articles '<))))))
4583 (defun gnus-group-make-articles-read (group articles)
4584 "Update the info of GROUP to say that ARTICLES are read."
4586 (entry (gnus-gethash group gnus-newsrc-hashtb))
4587 (info (nth 2 entry))
4588 (active (gnus-active group))
4591 (setq range (gnus-compute-read-articles group articles))
4593 (set-buffer gnus-group-buffer)
4596 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4597 (gnus-info-set-read ',info ',(gnus-info-read info))
4598 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4599 (gnus-group-update-group ,group t))))
4600 ;; Add the read articles to the range.
4601 (gnus-info-set-read info range)
4602 ;; Then we have to re-compute how many unread
4603 ;; articles there are in this group.
4607 (setq num (- (1+ (cdr active)) (car active))))
4608 ((not (listp (cdr range)))
4609 (setq num (- (cdr active) (- (1+ (cdr range))
4613 (if (numberp (car range))
4615 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4616 (setq range (cdr range)))
4617 (setq num (- (cdr active) num))))
4618 ;; Update the number of unread articles.
4620 ;; Update the group buffer.
4621 (gnus-group-update-group group t)))))
4623 (defvar gnus-newsgroup-none-id 0)
4625 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4626 (let ((cur nntp-server-buffer)
4629 (save-excursion (set-buffer gnus-summary-buffer)
4630 gnus-newsgroup-dependencies)))
4632 (mail-parse-charset gnus-newsgroup-charset)
4633 (mail-parse-ignored-charsets
4634 (save-excursion (condition-case nil
4635 (set-buffer gnus-summary-buffer)
4637 gnus-newsgroup-ignored-charsets)))
4639 (set-buffer nntp-server-buffer)
4640 ;; Translate all TAB characters into SPACE characters.
4641 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4642 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4643 (gnus-run-hooks 'gnus-parse-headers-hook)
4644 (let ((case-fold-search t)
4645 in-reply-to header p lines chars)
4646 (goto-char (point-min))
4647 ;; Search to the beginning of the next header. Error messages
4648 ;; do not begin with 2 or 3.
4649 (while (re-search-forward "^[23][0-9]+ " nil t)
4652 ;; This implementation of this function, with nine
4653 ;; search-forwards instead of the one re-search-forward and
4654 ;; a case (which basically was the old function) is actually
4655 ;; about twice as fast, even though it looks messier. You
4656 ;; can't have everything, I guess. Speed and elegance
4657 ;; doesn't always go hand in hand.
4666 (narrow-to-region (point)
4667 (or (and (search-forward "\n.\n" nil t)
4673 (if (search-forward "\nsubject: " nil t)
4674 (funcall gnus-decode-encoded-word-function
4675 (nnheader-header-value))
4680 (if (search-forward "\nfrom: " nil t)
4681 (funcall gnus-decode-encoded-word-function
4682 (nnheader-header-value))
4687 (if (search-forward "\ndate: " nil t)
4688 (nnheader-header-value) ""))
4692 (setq id (if (re-search-forward
4693 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4694 ;; We do it this way to make sure the Message-ID
4695 ;; is (somewhat) syntactically valid.
4696 (buffer-substring (match-beginning 1)
4698 ;; If there was no message-id, we just fake one
4699 ;; to make subsequent routines simpler.
4700 (nnheader-generate-fake-message-id))))
4704 (if (search-forward "\nreferences: " nil t)
4708 (nnheader-header-value)
4713 (search-backward ">" end t)
4716 (search-backward "<" end t)
4718 ;; Get the references from the in-reply-to header if there
4719 ;; were no references and the in-reply-to header looks
4721 (if (and (search-forward "\nin-reply-to: " nil t)
4722 (setq in-reply-to (nnheader-header-value))
4723 (string-match "<[^>]+>" in-reply-to))
4725 (setq ref (substring in-reply-to (match-beginning 0)
4727 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4728 (setq ref2 (substring in-reply-to (match-beginning 0)
4730 (when (> (length ref2) (length ref))
4737 (if (search-forward "\nchars: " nil t)
4738 (if (numberp (setq chars (ignore-errors (read cur))))
4744 (if (search-forward "\nlines: " nil t)
4745 (if (numberp (setq lines (ignore-errors (read cur))))
4751 (and (search-forward "\nxref: " nil t)
4752 (nnheader-header-value)))
4754 (when gnus-extra-headers
4755 (let ((extra gnus-extra-headers)
4759 (when (search-forward
4760 (concat "\n" (symbol-name (car extra)) ": ") nil t)
4761 (push (cons (car extra) (nnheader-header-value))
4765 (when (equal id ref)
4768 (when gnus-alter-header-function
4769 (funcall gnus-alter-header-function header)
4770 (setq id (mail-header-id header)
4771 ref (gnus-parent-id (mail-header-references header))))
4774 (gnus-dependencies-add-header
4775 header dependencies force-new))
4776 (push header headers))
4777 (goto-char (point-max))
4779 (nreverse headers)))))
4781 ;; Goes through the xover lines and returns a list of vectors
4782 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4783 force-new dependencies
4784 group also-fetch-heads)
4785 "Parse the news overview data in the server buffer, and return a
4786 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4787 ;; Get the Xref when the users reads the articles since most/some
4788 ;; NNTP servers do not include Xrefs when using XOVER.
4789 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4790 (let ((mail-parse-charset gnus-newsgroup-charset)
4791 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
4792 (cur nntp-server-buffer)
4793 (dependencies (or dependencies gnus-newsgroup-dependencies))
4794 number headers header)
4796 (set-buffer nntp-server-buffer)
4797 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4798 ;; Allow the user to mangle the headers before parsing them.
4799 (gnus-run-hooks 'gnus-parse-headers-hook)
4800 (goto-char (point-min))
4803 (while (and sequence (not (eobp)))
4804 (setq number (read cur))
4805 (while (and sequence
4806 (< (car sequence) number))
4807 (setq sequence (cdr sequence)))
4809 (eq number (car sequence))
4811 (setq sequence (cdr sequence))
4812 (setq header (inline
4813 (gnus-nov-parse-line
4814 number dependencies force-new))))
4815 (push header headers))
4818 (gnus-error 4 "Strange nov line (%d)"
4819 (count-lines (point-min) (point)))))
4821 ;; A common bug in inn is that if you have posted an article and
4822 ;; then retrieves the active file, it will answer correctly --
4823 ;; the new article is included. However, a NOV entry for the
4824 ;; article may not have been generated yet, so this may fail.
4825 ;; We work around this problem by retrieving the last few
4826 ;; headers using HEAD.
4827 (if (or (not also-fetch-heads)
4829 ;; We (probably) got all the headers.
4831 (let ((gnus-nov-is-evil t))
4834 (when (gnus-retrieve-headers sequence group)
4835 (gnus-get-newsgroup-headers))))))))
4837 (defun gnus-article-get-xrefs ()
4838 "Fill in the Xref value in `gnus-current-headers', if necessary.
4839 This is meant to be called in `gnus-article-internal-prepare-hook'."
4840 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4841 gnus-current-headers)))
4842 (or (not gnus-use-cross-reference)
4844 (and (mail-header-xref headers)
4845 (not (string= (mail-header-xref headers) "")))
4846 (let ((case-fold-search t)
4849 (nnheader-narrow-to-headers)
4850 (goto-char (point-min))
4851 (when (or (and (not (eobp))
4852 (eq (downcase (char-after)) ?x)
4853 (looking-at "Xref:"))
4854 (search-forward "\nXref:" nil t))
4855 (goto-char (1+ (match-end 0)))
4856 (setq xref (buffer-substring (point)
4857 (progn (end-of-line) (point))))
4858 (mail-header-set-xref headers xref)))))))
4860 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4861 "Find article ID and insert the summary line for that article.
4862 OLD-HEADER can either be a header or a line number to insert
4863 the subject line on."
4864 (let* ((line (and (numberp old-header) old-header))
4865 (old-header (and (vectorp old-header) old-header))
4866 (header (cond ((and old-header use-old-header)
4869 (gnus-number-to-header id))
4870 (gnus-number-to-header id))
4872 (gnus-read-header id))))
4873 (number (and (numberp id) id))
4876 ;; Rebuild the thread that this article is part of and go to the
4877 ;; article we have fetched.
4878 (when (and (not gnus-show-threads)
4881 (setq d (gnus-data-find (mail-header-number old-header))))
4882 (goto-char (gnus-data-pos d))
4885 (- (gnus-point-at-bol)
4887 (1+ (gnus-point-at-eol))
4888 (gnus-delete-line))))))
4890 (mail-header-set-number header (mail-header-number old-header)))
4891 (setq gnus-newsgroup-sparse
4892 (delq (setq number (mail-header-number header))
4893 gnus-newsgroup-sparse))
4894 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4895 (push number gnus-newsgroup-limit)
4896 (gnus-rebuild-thread (mail-header-id header) line)
4897 (gnus-summary-goto-subject number nil t))
4898 (when (and (numberp number)
4900 ;; We have to update the boundaries even if we can't fetch the
4901 ;; article if ID is a number -- so that the next `P' or `N'
4902 ;; command will fetch the previous (or next) article even
4903 ;; if the one we tried to fetch this time has been canceled.
4904 (when (> number gnus-newsgroup-end)
4905 (setq gnus-newsgroup-end number))
4906 (when (< number gnus-newsgroup-begin)
4907 (setq gnus-newsgroup-begin number))
4908 (setq gnus-newsgroup-unselected
4909 (delq number gnus-newsgroup-unselected)))
4910 ;; Report back a success?
4911 (and header (mail-header-number header))))
4913 ;;; Process/prefix in the summary buffer
4915 (defun gnus-summary-work-articles (n)
4916 "Return a list of articles to be worked upon.
4917 The prefix argument, the list of process marked articles, and the
4918 current article will be taken into consideration."
4920 (set-buffer gnus-summary-buffer)
4923 ;; A numerical prefix has been given.
4924 (setq n (prefix-numeric-value n))
4925 (let ((backward (< n 0))
4926 (n (abs (prefix-numeric-value n)))
4931 (push (setq article (gnus-summary-article-number))
4934 (gnus-summary-find-prev nil article)
4935 (gnus-summary-find-next nil article)))
4937 (nreverse articles)))
4938 ((and (gnus-region-active-p) (mark))
4939 (message "region active")
4940 ;; Work on the region between point and mark.
4941 (let ((max (max (point) (mark)))
4944 (goto-char (min (min (point) (mark))))
4947 (push (setq article (gnus-summary-article-number)) articles)
4948 (gnus-summary-find-next nil article)
4950 (nreverse articles))))
4951 (gnus-newsgroup-processable
4952 ;; There are process-marked articles present.
4953 ;; Save current state.
4954 (gnus-summary-save-process-mark)
4956 (reverse gnus-newsgroup-processable))
4958 ;; Just return the current article.
4959 (list (gnus-summary-article-number))))))
4961 (defmacro gnus-summary-iterate (arg &rest forms)
4962 "Iterate over the process/prefixed articles and do FORMS.
4963 ARG is the interactive prefix given to the command. FORMS will be
4964 executed with point over the summary line of the articles."
4965 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
4966 `(let ((,articles (gnus-summary-work-articles ,arg)))
4968 (gnus-summary-goto-subject (car ,articles))
4972 (put 'gnus-summary-iterate 'lisp-indent-function 1)
4973 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
4975 (defun gnus-summary-save-process-mark ()
4976 "Push the current set of process marked articles on the stack."
4978 (push (copy-sequence gnus-newsgroup-processable)
4979 gnus-newsgroup-process-stack))
4981 (defun gnus-summary-kill-process-mark ()
4982 "Push the current set of process marked articles on the stack and unmark."
4984 (gnus-summary-save-process-mark)
4985 (gnus-summary-unmark-all-processable))
4987 (defun gnus-summary-yank-process-mark ()
4988 "Pop the last process mark state off the stack and restore it."
4990 (unless gnus-newsgroup-process-stack
4991 (error "Empty mark stack"))
4992 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4994 (defun gnus-summary-process-mark-set (set)
4995 "Make SET into the current process marked articles."
4996 (gnus-summary-unmark-all-processable)
4998 (gnus-summary-set-process-mark (pop set))))
5000 ;;; Searching and stuff
5002 (defun gnus-summary-search-group (&optional backward use-level)
5003 "Search for next unread newsgroup.
5004 If optional argument BACKWARD is non-nil, search backward instead."
5006 (set-buffer gnus-group-buffer)
5007 (when (gnus-group-search-forward
5008 backward nil (if use-level (gnus-group-group-level) nil))
5009 (gnus-group-group-name))))
5011 (defun gnus-summary-best-group (&optional exclude-group)
5012 "Find the name of the best unread group.
5013 If EXCLUDE-GROUP, do not go to this group."
5015 (set-buffer gnus-group-buffer)
5017 (gnus-group-best-unread-group exclude-group))))
5019 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5020 (if backward (gnus-summary-find-prev)
5021 (let* ((dummy (gnus-summary-article-intangible-p))
5022 (article (or article (gnus-summary-article-number)))
5023 (arts (gnus-data-find-list article))
5025 (when (and (not dummy)
5026 (or (not gnus-summary-check-current)
5028 (not (gnus-data-unread-p (car arts)))))
5029 (setq arts (cdr arts)))
5034 (when (or (and undownloaded
5035 (eq gnus-undownloaded-mark
5036 (gnus-data-mark (car arts))))
5037 (gnus-data-unread-p (car arts)))
5038 (setq result (car arts)
5040 (setq arts (cdr arts)))
5043 (goto-char (gnus-data-pos result))
5044 (gnus-data-number result)))))
5046 (defun gnus-summary-find-prev (&optional unread article)
5047 (let* ((eobp (eobp))
5048 (article (or article (gnus-summary-article-number)))
5049 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5051 (when (and (not eobp)
5052 (or (not gnus-summary-check-current)
5054 (not (gnus-data-unread-p (car arts)))))
5055 (setq arts (cdr arts)))
5060 (when (gnus-data-unread-p (car arts))
5061 (setq result (car arts)
5063 (setq arts (cdr arts)))
5066 (goto-char (gnus-data-pos result))
5067 (gnus-data-number result))))
5069 (defun gnus-summary-find-subject (subject &optional unread backward article)
5070 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5071 (article (or article (gnus-summary-article-number)))
5072 (articles (gnus-data-list backward))
5073 (arts (gnus-data-find-list article articles))
5075 (when (or (not gnus-summary-check-current)
5077 (not (gnus-data-unread-p (car arts))))
5078 (setq arts (cdr arts)))
5080 (and (or (not unread)
5081 (gnus-data-unread-p (car arts)))
5082 (vectorp (gnus-data-header (car arts)))
5084 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5085 (setq result (car arts)
5087 (setq arts (cdr arts)))
5089 (goto-char (gnus-data-pos result))
5090 (gnus-data-number result))))
5092 (defun gnus-summary-search-forward (&optional unread subject backward)
5093 "Search forward for an article.
5094 If UNREAD, look for unread articles. If SUBJECT, look for
5095 articles with that subject. If BACKWARD, search backward instead."
5096 (cond (subject (gnus-summary-find-subject subject unread backward))
5097 (backward (gnus-summary-find-prev unread))
5098 (t (gnus-summary-find-next unread))))
5100 (defun gnus-recenter (&optional n)
5101 "Center point in window and redisplay frame.
5102 Also do horizontal recentering."
5105 gnus-auto-center-summary
5106 (not (eq gnus-auto-center-summary 'vertical)))
5107 (gnus-horizontal-recenter))
5110 (defun gnus-summary-recenter ()
5111 "Center point in the summary window.
5112 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5113 displayed, no centering will be performed."
5114 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5115 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5117 (let* ((top (cond ((< (window-height) 4) 0)
5118 ((< (window-height) 7) 1)
5119 (t (if (numberp gnus-auto-center-summary)
5120 gnus-auto-center-summary
5122 (height (1- (window-height)))
5123 (bottom (save-excursion (goto-char (point-max))
5124 (forward-line (- height))
5126 (window (get-buffer-window (current-buffer))))
5127 ;; The user has to want it.
5128 (when gnus-auto-center-summary
5129 (when (get-buffer-window gnus-article-buffer)
5130 ;; Only do recentering when the article buffer is displayed,
5131 ;; Set the window start to either `bottom', which is the biggest
5132 ;; possible valid number, or the second line from the top,
5133 ;; whichever is the least.
5135 window (min bottom (save-excursion
5136 (forward-line (- top)) (point)))
5138 ;; Do horizontal recentering while we're at it.
5139 (when (and (get-buffer-window (current-buffer) t)
5140 (not (eq gnus-auto-center-summary 'vertical)))
5141 (let ((selected (selected-window)))
5142 (select-window (get-buffer-window (current-buffer) t))
5143 (gnus-summary-position-point)
5144 (gnus-horizontal-recenter)
5145 (select-window selected))))))
5147 (defun gnus-summary-jump-to-group (newsgroup)
5148 "Move point to NEWSGROUP in group mode buffer."
5149 ;; Keep update point of group mode buffer if visible.
5150 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5151 (save-window-excursion
5152 ;; Take care of tree window mode.
5153 (when (get-buffer-window gnus-group-buffer)
5154 (pop-to-buffer gnus-group-buffer))
5155 (gnus-group-jump-to-group newsgroup))
5157 ;; Take care of tree window mode.
5158 (if (get-buffer-window gnus-group-buffer)
5159 (pop-to-buffer gnus-group-buffer)
5160 (set-buffer gnus-group-buffer))
5161 (gnus-group-jump-to-group newsgroup))))
5163 ;; This function returns a list of article numbers based on the
5164 ;; difference between the ranges of read articles in this group and
5165 ;; the range of active articles.
5166 (defun gnus-list-of-unread-articles (group)
5167 (let* ((read (gnus-info-read (gnus-get-info group)))
5168 (active (or (gnus-active group) (gnus-activate-group group)))
5171 ;; If none are read, then all are unread.
5173 (setq first (car active))
5174 ;; If the range of read articles is a single range, then the
5175 ;; first unread article is the article after the last read
5176 ;; article. Sounds logical, doesn't it?
5177 (if (and (not (listp (cdr read)))
5178 (or (< (car read) (car active))
5179 (progn (setq read (list read))
5181 (setq first (max (car active) (1+ (cdr read))))
5182 ;; `read' is a list of ranges.
5183 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5186 (setq first (car active)))
5189 (while (< first nlast)
5191 (setq first (1+ first))))
5192 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5193 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5194 (setq read (cdr read)))))
5195 ;; And add the last unread articles.
5196 (while (<= first last)
5198 (setq first (1+ first)))
5199 ;; Return the list of unread articles.
5200 (delq 0 (nreverse unread))))
5202 (defun gnus-list-of-read-articles (group)
5203 "Return a list of unread, unticked and non-dormant articles."
5204 (let* ((info (gnus-get-info group))
5205 (marked (gnus-info-marks info))
5206 (active (gnus-active group)))
5208 (gnus-set-difference
5209 (gnus-sorted-complement
5210 (gnus-uncompress-range active)
5211 (gnus-list-of-unread-articles group))
5213 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5214 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5216 ;; Various summary commands
5218 (defun gnus-summary-select-article-buffer ()
5219 "Reconfigure windows to show article buffer."
5221 (if (not (gnus-buffer-live-p gnus-article-buffer))
5222 (error "There is no article buffer for this summary buffer")
5223 (gnus-configure-windows 'article)
5224 (select-window (get-buffer-window gnus-article-buffer))))
5226 (defun gnus-summary-universal-argument (arg)
5227 "Perform any operation on all articles that are process/prefixed."
5229 (let ((articles (gnus-summary-work-articles arg))
5236 (substitute-command-keys
5237 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
5239 (gnus-error 1 "Undefined key")
5242 (gnus-summary-goto-subject (setq article (pop articles)))
5243 (let (gnus-newsgroup-processable)
5244 (command-execute func))
5245 (gnus-summary-remove-process-mark article)))))
5246 (gnus-summary-position-point))
5248 (defun gnus-summary-toggle-truncation (&optional arg)
5249 "Toggle truncation of summary lines.
5250 With arg, turn line truncation on iff arg is positive."
5252 (setq truncate-lines
5253 (if (null arg) (not truncate-lines)
5254 (> (prefix-numeric-value arg) 0)))
5257 (defun gnus-summary-reselect-current-group (&optional all rescan)
5258 "Exit and then reselect the current newsgroup.
5259 The prefix argument ALL means to select all articles."
5261 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5262 (error "Ephemeral groups can't be reselected"))
5263 (let ((current-subject (gnus-summary-article-number))
5264 (group gnus-newsgroup-name))
5265 (setq gnus-newsgroup-begin nil)
5267 ;; We have to adjust the point of group mode buffer because
5268 ;; point was moved to the next unread newsgroup by exiting.
5269 (gnus-summary-jump-to-group group)
5272 (gnus-group-get-new-news-this-group 1)))
5273 (gnus-group-read-group all t)
5274 (gnus-summary-goto-subject current-subject nil t)))
5276 (defun gnus-summary-rescan-group (&optional all)
5277 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5279 (gnus-summary-reselect-current-group all t))
5281 (defun gnus-summary-update-info (&optional non-destructive)
5283 (let ((group gnus-newsgroup-name))
5285 (when gnus-newsgroup-kill-headers
5286 (setq gnus-newsgroup-killed
5287 (gnus-compress-sequence
5289 (gnus-set-sorted-intersection
5290 (gnus-uncompress-range gnus-newsgroup-killed)
5291 (setq gnus-newsgroup-unselected
5292 (sort gnus-newsgroup-unselected '<)))
5293 (setq gnus-newsgroup-unreads
5294 (sort gnus-newsgroup-unreads '<)))
5296 (unless (listp (cdr gnus-newsgroup-killed))
5297 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5298 (let ((headers gnus-newsgroup-headers))
5299 ;; Set the new ranges of read articles.
5301 (set-buffer gnus-group-buffer)
5302 (gnus-undo-force-boundary))
5303 (gnus-update-read-articles
5304 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5305 ;; Set the current article marks.
5306 (let ((gnus-newsgroup-scored
5307 (if (and (not gnus-save-score)
5308 (not non-destructive))
5310 gnus-newsgroup-scored)))
5312 (gnus-update-marks)))
5313 ;; Do the cross-ref thing.
5314 (when gnus-use-cross-reference
5315 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5316 ;; Do not switch windows but change the buffer to work.
5317 (set-buffer gnus-group-buffer)
5318 (unless (gnus-ephemeral-group-p group)
5319 (gnus-group-update-group group)))))))
5321 (defun gnus-summary-save-newsrc (&optional force)
5322 "Save the current number of read/marked articles in the dribble buffer.
5323 The dribble buffer will then be saved.
5324 If FORCE (the prefix), also save the .newsrc file(s)."
5326 (gnus-summary-update-info t)
5328 (gnus-save-newsrc-file)
5329 (gnus-dribble-save)))
5331 (defun gnus-summary-exit (&optional temporary)
5332 "Exit reading current newsgroup, and then return to group selection mode.
5333 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
5335 (gnus-set-global-variables)
5336 (when (gnus-buffer-live-p gnus-article-buffer)
5338 (set-buffer gnus-article-buffer)
5339 (mm-destroy-parts gnus-article-mime-handles)))
5340 (gnus-kill-save-kill-buffer)
5341 (gnus-async-halt-prefetch)
5342 (let* ((group gnus-newsgroup-name)
5343 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5346 (buf (current-buffer)))
5348 ;; Do adaptive scoring, and possibly save score files.
5349 (when gnus-newsgroup-adaptive
5350 (gnus-score-adaptive))
5351 (when gnus-use-scoring
5353 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5354 ;; If we have several article buffers, we kill them at exit.
5355 (unless gnus-single-article-buffer
5356 (gnus-kill-buffer gnus-original-article-buffer)
5357 (setq gnus-article-current nil))
5358 (when gnus-use-cache
5359 (gnus-cache-possibly-remove-articles)
5360 (gnus-cache-save-buffers))
5361 (gnus-async-prefetch-remove-group group)
5362 (when gnus-suppress-duplicates
5363 (gnus-dup-enter-articles))
5364 (when gnus-use-trees
5365 (gnus-tree-close group))
5366 (when gnus-use-cache
5367 (gnus-cache-write-active))
5368 ;; Remove entries for this group.
5369 (nnmail-purge-split-history (gnus-group-real-name group))
5370 ;; Make all changes in this group permanent.
5372 (gnus-run-hooks 'gnus-exit-group-hook)
5373 (gnus-summary-update-info))
5374 (gnus-close-group group)
5375 ;; Make sure where we were, and go to next newsgroup.
5376 (set-buffer gnus-group-buffer)
5378 (gnus-group-jump-to-group group))
5379 (gnus-run-hooks 'gnus-summary-exit-hook)
5380 (unless (or quit-config
5381 ;; If this group has disappeared from the summary
5382 ;; buffer, don't skip forwards.
5383 (not (string= group (gnus-group-group-name))))
5384 (gnus-group-next-unread-group 1))
5385 (setq group-point (point))
5388 ;; If we have several article buffers, we kill them at exit.
5389 (unless gnus-single-article-buffer
5390 (gnus-kill-buffer gnus-article-buffer)
5391 (gnus-kill-buffer gnus-original-article-buffer)
5392 (setq gnus-article-current nil))
5394 (if (not gnus-kill-summary-on-exit)
5395 (gnus-deaden-summary)
5396 ;; We set all buffer-local variables to nil. It is unclear why
5397 ;; this is needed, but if we don't, buffer-local variables are
5398 ;; not garbage-collected, it seems. This would the lead to en
5399 ;; ever-growing Emacs.
5400 (gnus-summary-clear-local-variables)
5401 (when (get-buffer gnus-article-buffer)
5402 (bury-buffer gnus-article-buffer))
5403 ;; We clear the global counterparts of the buffer-local
5404 ;; variables as well, just to be on the safe side.
5405 (set-buffer gnus-group-buffer)
5406 (gnus-summary-clear-local-variables)
5407 ;; Return to group mode buffer.
5408 (when (eq mode 'gnus-summary-mode)
5409 (gnus-kill-buffer buf)))
5410 (setq gnus-current-select-method gnus-select-method)
5411 (pop-to-buffer gnus-group-buffer)
5412 (if (not quit-config)
5414 (goto-char group-point)
5415 (gnus-configure-windows 'group 'force))
5416 (gnus-handle-ephemeral-exit quit-config))
5417 ;; Clear the current group name.
5419 (setq gnus-newsgroup-name nil)))))
5421 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5422 (defun gnus-summary-exit-no-update (&optional no-questions)
5423 "Quit reading current newsgroup without updating read article info."
5425 (let* ((group gnus-newsgroup-name)
5426 (quit-config (gnus-group-quit-config group)))
5427 (when (or no-questions
5429 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5430 (gnus-async-halt-prefetch)
5432 (delq 'gnus-summary-expire-articles
5433 (copy-sequence gnus-summary-prepare-exit-hook)))
5434 (when (gnus-buffer-live-p gnus-article-buffer)
5436 (set-buffer gnus-article-buffer)
5437 (mm-destroy-parts gnus-article-mime-handles)))
5438 ;; If we have several article buffers, we kill them at exit.
5439 (unless gnus-single-article-buffer
5440 (gnus-kill-buffer gnus-article-buffer)
5441 (gnus-kill-buffer gnus-original-article-buffer)
5442 (setq gnus-article-current nil))
5443 (if (not gnus-kill-summary-on-exit)
5444 (gnus-deaden-summary)
5445 (gnus-close-group group)
5446 (gnus-summary-clear-local-variables)
5447 (set-buffer gnus-group-buffer)
5448 (gnus-summary-clear-local-variables)
5449 (when (get-buffer gnus-summary-buffer)
5450 (kill-buffer gnus-summary-buffer)))
5451 (unless gnus-single-article-buffer
5452 (setq gnus-article-current nil))
5453 (when gnus-use-trees
5454 (gnus-tree-close group))
5455 (gnus-async-prefetch-remove-group group)
5456 (when (get-buffer gnus-article-buffer)
5457 (bury-buffer gnus-article-buffer))
5458 ;; Return to the group buffer.
5459 (gnus-configure-windows 'group 'force)
5460 ;; Clear the current group name.
5461 (setq gnus-newsgroup-name nil)
5462 (when (equal (gnus-group-group-name) group)
5463 (gnus-group-next-unread-group 1))
5465 (gnus-handle-ephemeral-exit quit-config)))))
5467 (defun gnus-handle-ephemeral-exit (quit-config)
5468 "Handle movement when leaving an ephemeral group.
5469 The state which existed when entering the ephemeral is reset."
5470 (if (not (buffer-name (car quit-config)))
5471 (gnus-configure-windows 'group 'force)
5472 (set-buffer (car quit-config))
5473 (cond ((eq major-mode 'gnus-summary-mode)
5474 (gnus-set-global-variables))
5475 ((eq major-mode 'gnus-article-mode)
5477 ;; The `gnus-summary-buffer' variable may point
5478 ;; to the old summary buffer when using a single
5480 (unless (gnus-buffer-live-p gnus-summary-buffer)
5481 (set-buffer gnus-group-buffer))
5482 (set-buffer gnus-summary-buffer)
5483 (gnus-set-global-variables))))
5484 (if (or (eq (cdr quit-config) 'article)
5485 (eq (cdr quit-config) 'pick))
5487 ;; The current article may be from the ephemeral group
5488 ;; thus it is best that we reload this article
5489 (gnus-summary-show-article)
5490 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5491 (gnus-configure-windows 'pick 'force)
5492 (gnus-configure-windows (cdr quit-config) 'force)))
5493 (gnus-configure-windows (cdr quit-config) 'force))
5494 (when (eq major-mode 'gnus-summary-mode)
5495 (gnus-summary-next-subject 1 nil t)
5496 (gnus-summary-recenter)
5497 (gnus-summary-position-point))))
5501 (defvar gnus-dead-summary-mode-map nil)
5503 (unless gnus-dead-summary-mode-map
5504 (setq gnus-dead-summary-mode-map (make-keymap))
5505 (suppress-keymap gnus-dead-summary-mode-map)
5506 (substitute-key-definition
5507 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5508 (let ((keys '("\C-d" "\r" "\177" [delete])))
5510 (define-key gnus-dead-summary-mode-map
5511 (pop keys) 'gnus-summary-wake-up-the-dead))))
5513 (defvar gnus-dead-summary-mode nil
5514 "Minor mode for Gnus summary buffers.")
5516 (defun gnus-dead-summary-mode (&optional arg)
5517 "Minor mode for Gnus summary buffers."
5519 (when (eq major-mode 'gnus-summary-mode)
5520 (make-local-variable 'gnus-dead-summary-mode)
5521 (setq gnus-dead-summary-mode
5522 (if (null arg) (not gnus-dead-summary-mode)
5523 (> (prefix-numeric-value arg) 0)))
5524 (when gnus-dead-summary-mode
5525 (gnus-add-minor-mode
5526 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5528 (defun gnus-deaden-summary ()
5529 "Make the current summary buffer into a dead summary buffer."
5530 ;; Kill any previous dead summary buffer.
5531 (when (and gnus-dead-summary
5532 (buffer-name gnus-dead-summary))
5534 (set-buffer gnus-dead-summary)
5535 (when gnus-dead-summary-mode
5536 (kill-buffer (current-buffer)))))
5537 ;; Make this the current dead summary.
5538 (setq gnus-dead-summary (current-buffer))
5539 (gnus-dead-summary-mode 1)
5540 (let ((name (buffer-name)))
5541 (when (string-match "Summary" name)
5543 (concat (substring name 0 (match-beginning 0)) "Dead "
5544 (substring name (match-beginning 0)))
5548 (defun gnus-kill-or-deaden-summary (buffer)
5549 "Kill or deaden the summary BUFFER."
5551 (when (and (buffer-name buffer)
5552 (not gnus-single-article-buffer))
5555 (gnus-kill-buffer gnus-article-buffer)
5556 (gnus-kill-buffer gnus-original-article-buffer)))
5557 (cond (gnus-kill-summary-on-exit
5558 (when (and gnus-use-trees
5559 (gnus-buffer-exists-p buffer))
5562 (gnus-tree-close gnus-newsgroup-name)))
5563 (gnus-kill-buffer buffer))
5564 ((gnus-buffer-exists-p buffer)
5567 (gnus-deaden-summary))))))
5569 (defun gnus-summary-wake-up-the-dead (&rest args)
5570 "Wake up the dead summary buffer."
5572 (gnus-dead-summary-mode -1)
5573 (let ((name (buffer-name)))
5574 (when (string-match "Dead " name)
5576 (concat (substring name 0 (match-beginning 0))
5577 (substring name (match-end 0)))
5579 (gnus-message 3 "This dead summary is now alive again"))
5581 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5582 (defun gnus-summary-fetch-faq (&optional faq-dir)
5583 "Fetch the FAQ for the current group.
5584 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5588 (when current-prefix-arg
5590 "Faq dir: " (and (listp gnus-group-faq-directory)
5591 (mapcar (lambda (file) (list file))
5592 gnus-group-faq-directory))))))
5593 (let (gnus-faq-buffer)
5594 (when (setq gnus-faq-buffer
5595 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5596 (gnus-configure-windows 'summary-faq))))
5598 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5599 (defun gnus-summary-describe-group (&optional force)
5600 "Describe the current newsgroup."
5602 (gnus-group-describe-group force gnus-newsgroup-name))
5604 (defun gnus-summary-describe-briefly ()
5605 "Describe summary mode commands briefly."
5607 (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")))
5609 ;; Walking around group mode buffer from summary mode.
5611 (defun gnus-summary-next-group (&optional no-article target-group backward)
5612 "Exit current newsgroup and then select next unread newsgroup.
5613 If prefix argument NO-ARTICLE is non-nil, no article is selected
5614 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5615 previous group instead."
5617 ;; Stop pre-fetching.
5618 (gnus-async-halt-prefetch)
5619 (let ((current-group gnus-newsgroup-name)
5620 (current-buffer (current-buffer))
5622 ;; First we semi-exit this group to update Xrefs and all variables.
5623 ;; We can't do a real exit, because the window conf must remain
5624 ;; the same in case the user is prompted for info, and we don't
5625 ;; want the window conf to change before that...
5626 (gnus-summary-exit t)
5627 (while (not entered)
5628 ;; Then we find what group we are supposed to enter.
5629 (set-buffer gnus-group-buffer)
5630 (gnus-group-jump-to-group current-group)
5633 (if (eq gnus-keep-same-level 'best)
5634 (gnus-summary-best-group gnus-newsgroup-name)
5635 (gnus-summary-search-group backward gnus-keep-same-level))))
5636 (if (not target-group)
5637 ;; There are no further groups, so we return to the group
5640 (gnus-message 5 "Returning to the group buffer")
5642 (when (gnus-buffer-live-p current-buffer)
5643 (set-buffer current-buffer)
5644 (gnus-summary-exit))
5645 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5646 ;; We try to enter the target group.
5647 (gnus-group-jump-to-group target-group)
5648 (let ((unreads (gnus-group-group-unread)))
5649 (if (and (or (eq t unreads)
5650 (and unreads (not (zerop unreads))))
5651 (gnus-summary-read-group
5652 target-group nil no-article
5653 (and (buffer-name current-buffer) current-buffer)
5656 (setq current-group target-group
5657 target-group nil)))))))
5659 (defun gnus-summary-prev-group (&optional no-article)
5660 "Exit current newsgroup and then select previous unread newsgroup.
5661 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5663 (gnus-summary-next-group no-article nil t))
5665 ;; Walking around summary lines.
5667 (defun gnus-summary-first-subject (&optional unread undownloaded)
5668 "Go to the first unread subject.
5669 If UNREAD is non-nil, go to the first unread article.
5670 Returns the article selected or nil if there are no unread articles."
5675 ((null gnus-newsgroup-data)
5676 (gnus-message 3 "No articles in the group")
5678 ;; Pick the first article.
5680 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5681 (gnus-data-number (car gnus-newsgroup-data)))
5682 ;; No unread articles.
5683 ((null gnus-newsgroup-unreads)
5684 (gnus-message 3 "No more unread articles")
5686 ;; Find the first unread article.
5688 (let ((data gnus-newsgroup-data))
5690 (and (not (and undownloaded
5691 (eq gnus-undownloaded-mark
5692 (gnus-data-mark (car data)))))
5693 (not (gnus-data-unread-p (car data)))))
5694 (setq data (cdr data)))
5696 (goto-char (gnus-data-pos (car data)))
5697 (gnus-data-number (car data))))))
5698 (gnus-summary-position-point)))
5700 (defun gnus-summary-next-subject (n &optional unread dont-display)
5701 "Go to next N'th summary line.
5702 If N is negative, go to the previous N'th subject line.
5703 If UNREAD is non-nil, only unread articles are selected.
5704 The difference between N and the actual number of steps taken is
5707 (let ((backward (< n 0))
5711 (gnus-summary-find-prev unread)
5712 (gnus-summary-find-next unread)))
5713 (unless (zerop (setq n (1- n)))
5714 (gnus-summary-show-thread)))
5716 (gnus-message 7 "No more%s articles"
5717 (if unread " unread" "")))
5718 (unless dont-display
5719 (gnus-summary-recenter)
5720 (gnus-summary-position-point))
5723 (defun gnus-summary-next-unread-subject (n)
5724 "Go to next N'th unread summary line."
5726 (gnus-summary-next-subject n t))
5728 (defun gnus-summary-prev-subject (n &optional unread)
5729 "Go to previous N'th summary line.
5730 If optional argument UNREAD is non-nil, only unread article is selected."
5732 (gnus-summary-next-subject (- n) unread))
5734 (defun gnus-summary-prev-unread-subject (n)
5735 "Go to previous N'th unread summary line."
5737 (gnus-summary-next-subject (- n) t))
5739 (defun gnus-summary-goto-subject (article &optional force silent)
5740 "Go the subject line of ARTICLE.
5741 If FORCE, also allow jumping to articles not currently shown."
5742 (interactive "nArticle number: ")
5744 (data (gnus-data-find article)))
5745 ;; We read in the article if we have to.
5748 (gnus-summary-insert-subject
5750 (if (or (numberp force) (vectorp force)) force)
5752 (setq data (gnus-data-find article)))
5757 (gnus-message 3 "Can't find article %d" article))
5759 (goto-char (gnus-data-pos data))
5760 (gnus-summary-position-point)
5763 ;; Walking around summary lines with displaying articles.
5765 (defun gnus-summary-expand-window (&optional arg)
5766 "Make the summary buffer take up the entire Emacs frame.
5767 Given a prefix, will force an `article' buffer configuration."
5770 (gnus-configure-windows 'article 'force)
5771 (gnus-configure-windows 'summary 'force)))
5773 (defun gnus-summary-display-article (article &optional all-header)
5774 "Display ARTICLE in article buffer."
5775 (gnus-set-global-variables)
5779 (if gnus-summary-display-article-function
5780 (funcall gnus-summary-display-article-function article all-header)
5781 (gnus-article-prepare article all-header))
5782 (gnus-run-hooks 'gnus-select-article-hook)
5783 (when (and gnus-current-article
5784 (not (zerop gnus-current-article)))
5785 (gnus-summary-goto-subject gnus-current-article))
5786 (gnus-summary-recenter)
5787 (when (and gnus-use-trees gnus-show-threads)
5788 (gnus-possibly-generate-tree article)
5789 (gnus-highlight-selected-tree article))
5790 ;; Successfully display article.
5791 (gnus-article-set-window-start
5792 (cdr (assq article gnus-newsgroup-bookmarks))))))
5794 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5795 "Select the current article.
5796 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5797 non-nil, the article will be re-fetched even if it already present in
5798 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5800 ;; Make sure we are in the summary buffer to work around bbdb bug.
5801 (unless (eq major-mode 'gnus-summary-mode)
5802 (set-buffer gnus-summary-buffer))
5803 (let ((article (or article (gnus-summary-article-number)))
5804 (all-headers (not (not all-headers))) ;Must be T or NIL.
5805 gnus-summary-display-article-function)
5807 (gnus-summary-article-pseudo-p article)
5808 (error "This is a pseudo-article"))
5810 (set-buffer gnus-summary-buffer)
5811 (if (or (and gnus-single-article-buffer
5812 (or (null gnus-current-article)
5813 (null gnus-article-current)
5814 (null (get-buffer gnus-article-buffer))
5815 (not (eq article (cdr gnus-article-current)))
5816 (not (equal (car gnus-article-current)
5817 gnus-newsgroup-name))))
5818 (and (not gnus-single-article-buffer)
5819 (or (null gnus-current-article)
5820 (not (eq gnus-current-article article))))
5822 ;; The requested article is different from the current article.
5824 (gnus-summary-display-article article all-headers)
5825 (when (or all-headers gnus-show-all-headers)
5826 (gnus-article-show-all-headers))
5827 (gnus-article-set-window-start
5828 (cdr (assq article gnus-newsgroup-bookmarks)))
5830 (when (or all-headers gnus-show-all-headers)
5831 (gnus-article-show-all-headers))
5834 (defun gnus-summary-set-current-mark (&optional current-mark)
5835 "Obsolete function."
5838 (defun gnus-summary-next-article (&optional unread subject backward push)
5839 "Select the next article.
5840 If UNREAD, only unread articles are selected.
5841 If SUBJECT, only articles with SUBJECT are selected.
5842 If BACKWARD, the previous article is selected instead of the next."
5845 ;; Is there such an article?
5846 ((and (gnus-summary-search-forward unread subject backward)
5847 (or (gnus-summary-display-article (gnus-summary-article-number))
5848 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5849 (gnus-summary-position-point))
5850 ;; If not, we try the first unread, if that is wanted.
5852 gnus-auto-select-same
5853 (gnus-summary-first-unread-article))
5854 (gnus-summary-position-point)
5855 (gnus-message 6 "Wrapped"))
5856 ;; Try to get next/previous article not displayed in this group.
5857 ((and gnus-auto-extend-newsgroup
5858 (not unread) (not subject))
5859 (gnus-summary-goto-article
5860 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5861 nil (count-lines (point-min) (point))))
5862 ;; Go to next/previous group.
5864 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5865 (gnus-summary-jump-to-group gnus-newsgroup-name))
5866 (let ((cmd last-command-char)
5869 (set-buffer gnus-group-buffer)
5872 (if (eq gnus-keep-same-level 'best)
5873 (gnus-summary-best-group gnus-newsgroup-name)
5874 (gnus-summary-search-group backward gnus-keep-same-level))))
5875 ;; For some reason, the group window gets selected. We change
5877 (select-window (get-buffer-window (current-buffer)))
5878 ;; Select next unread newsgroup automagically.
5880 ((or (not gnus-auto-select-next)
5882 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5883 ((or (eq gnus-auto-select-next 'quietly)
5884 (and (eq gnus-auto-select-next 'slightly-quietly)
5886 (and (eq gnus-auto-select-next 'almost-quietly)
5887 (gnus-summary-last-article-p)))
5889 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5891 (gnus-message 7 "No more%s articles (%s)..."
5892 (if unread " unread" "")
5893 (if group (concat "selecting " group)
5895 (gnus-summary-next-group nil group backward)))
5897 (when (gnus-key-press-event-p last-input-event)
5898 (gnus-summary-walk-group-buffer
5899 gnus-newsgroup-name cmd unread backward point))))))))
5901 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5902 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5903 (?\C-p (gnus-group-prev-unread-group 1))))
5904 (cursor-in-echo-area t)
5905 keve key group ended)
5907 (set-buffer gnus-group-buffer)
5910 (if (eq gnus-keep-same-level 'best)
5911 (gnus-summary-best-group gnus-newsgroup-name)
5912 (gnus-summary-search-group backward gnus-keep-same-level))))
5915 5 "No more%s articles%s" (if unread " unread" "")
5917 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5918 (format " (Type %s for %s [%s])"
5919 (single-key-description cmd) group
5920 (car (gnus-gethash group gnus-newsrc-hashtb)))
5921 (format " (Type %s to exit %s)"
5922 (single-key-description cmd)
5923 gnus-newsgroup-name)))
5924 ;; Confirm auto selection.
5925 (setq key (car (setq keve (gnus-read-event-char))))
5928 ((assq key keystrokes)
5929 (let ((obuf (current-buffer)))
5930 (switch-to-buffer gnus-group-buffer)
5932 (gnus-group-jump-to-group group))
5933 (eval (cadr (assq key keystrokes)))
5934 (setq group (gnus-group-group-name))
5935 (switch-to-buffer obuf))
5939 (gnus-ephemeral-group-p gnus-newsgroup-name))
5941 (gnus-summary-next-group nil group backward)))
5943 (push (cdr keve) unread-command-events))))))
5945 (defun gnus-summary-next-unread-article ()
5946 "Select unread article after current one."
5948 (gnus-summary-next-article
5949 (or (not (eq gnus-summary-goto-unread 'never))
5950 (gnus-summary-last-article-p (gnus-summary-article-number)))
5951 (and gnus-auto-select-same
5952 (gnus-summary-article-subject))))
5954 (defun gnus-summary-prev-article (&optional unread subject)
5955 "Select the article after the current one.
5956 If UNREAD is non-nil, only unread articles are selected."
5958 (gnus-summary-next-article unread subject t))
5960 (defun gnus-summary-prev-unread-article ()
5961 "Select unread article before current one."
5963 (gnus-summary-prev-article
5964 (or (not (eq gnus-summary-goto-unread 'never))
5965 (gnus-summary-first-article-p (gnus-summary-article-number)))
5966 (and gnus-auto-select-same
5967 (gnus-summary-article-subject))))
5969 (defun gnus-summary-next-page (&optional lines circular)
5970 "Show next page of the selected article.
5971 If at the end of the current article, select the next article.
5972 LINES says how many lines should be scrolled up.
5974 If CIRCULAR is non-nil, go to the start of the article instead of
5975 selecting the next article when reaching the end of the current
5978 (setq gnus-summary-buffer (current-buffer))
5979 (gnus-set-global-variables)
5980 (let ((article (gnus-summary-article-number))
5981 (article-window (get-buffer-window gnus-article-buffer t))
5983 ;; If the buffer is empty, we have no article.
5985 (error "No article to select"))
5986 (gnus-configure-windows 'article)
5987 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
5988 (if (and (eq gnus-summary-goto-unread 'never)
5989 (not (gnus-summary-last-article-p article)))
5990 (gnus-summary-next-article)
5991 (gnus-summary-next-unread-article))
5992 (if (or (null gnus-current-article)
5993 (null gnus-article-current)
5994 (/= article (cdr gnus-article-current))
5995 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5996 ;; Selected subject is different from current article's.
5997 (gnus-summary-display-article article)
5998 (when article-window
5999 (gnus-eval-in-buffer-window gnus-article-buffer
6000 (setq endp (gnus-article-next-page lines)))
6003 (gnus-summary-beginning-of-article))
6005 (gnus-message 3 "End of message"))
6007 (if (and (eq gnus-summary-goto-unread 'never)
6008 (not (gnus-summary-last-article-p article)))
6009 (gnus-summary-next-article)
6010 (gnus-summary-next-unread-article))))))))
6011 (gnus-summary-recenter)
6012 (gnus-summary-position-point)))
6014 (defun gnus-summary-prev-page (&optional lines move)
6015 "Show previous page of selected article.
6016 Argument LINES specifies lines to be scrolled down.
6017 If MOVE, move to the previous unread article if point is at
6018 the beginning of the buffer."
6020 (let ((article (gnus-summary-article-number))
6021 (article-window (get-buffer-window gnus-article-buffer t))
6023 (gnus-configure-windows 'article)
6024 (if (or (null gnus-current-article)
6025 (null gnus-article-current)
6026 (/= article (cdr gnus-article-current))
6027 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6028 ;; Selected subject is different from current article's.
6029 (gnus-summary-display-article article)
6030 (gnus-summary-recenter)
6031 (when article-window
6032 (gnus-eval-in-buffer-window gnus-article-buffer
6033 (setq endp (gnus-article-prev-page lines)))
6034 (when (and move endp)
6036 (gnus-message 3 "Beginning of message"))
6038 (if (and (eq gnus-summary-goto-unread 'never)
6039 (not (gnus-summary-first-article-p article)))
6040 (gnus-summary-prev-article)
6041 (gnus-summary-prev-unread-article))))))))
6042 (gnus-summary-position-point))
6044 (defun gnus-summary-prev-page-or-article (&optional lines)
6045 "Show previous page of selected article.
6046 Argument LINES specifies lines to be scrolled down.
6047 If at the beginning of the article, go to the next article."
6049 (gnus-summary-prev-page lines t))
6051 (defun gnus-summary-scroll-up (lines)
6052 "Scroll up (or down) one line current article.
6053 Argument LINES specifies lines to be scrolled up (or down if negative)."
6055 (gnus-configure-windows 'article)
6056 (gnus-summary-show-thread)
6057 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6058 (gnus-eval-in-buffer-window gnus-article-buffer
6060 (when (gnus-article-next-page lines)
6061 (gnus-message 3 "End of message")))
6063 (gnus-article-prev-page (- lines))))))
6064 (gnus-summary-recenter)
6065 (gnus-summary-position-point))
6067 (defun gnus-summary-scroll-down (lines)
6068 "Scroll down (or up) one line current article.
6069 Argument LINES specifies lines to be scrolled down (or up if negative)."
6071 (gnus-summary-scroll-up (- lines)))
6073 (defun gnus-summary-next-same-subject ()
6074 "Select next article which has the same subject as current one."
6076 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6078 (defun gnus-summary-prev-same-subject ()
6079 "Select previous article which has the same subject as current one."
6081 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6083 (defun gnus-summary-next-unread-same-subject ()
6084 "Select next unread article which has the same subject as current one."
6086 (gnus-summary-next-article t (gnus-summary-article-subject)))
6088 (defun gnus-summary-prev-unread-same-subject ()
6089 "Select previous unread article which has the same subject as current one."
6091 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6093 (defun gnus-summary-first-unread-article ()
6094 "Select the first unread article.
6095 Return nil if there are no unread articles."
6098 (when (gnus-summary-first-subject t)
6099 (gnus-summary-show-thread)
6100 (gnus-summary-first-subject t)
6101 (gnus-summary-display-article (gnus-summary-article-number)))
6102 (gnus-summary-position-point)))
6104 (defun gnus-summary-first-unread-subject ()
6105 "Place the point on the subject line of the first unread article.
6106 Return nil if there are no unread articles."
6109 (when (gnus-summary-first-subject t)
6110 (gnus-summary-show-thread)
6111 (gnus-summary-first-subject t))
6112 (gnus-summary-position-point)))
6114 (defun gnus-summary-first-article ()
6115 "Select the first article.
6116 Return nil if there are no articles."
6119 (when (gnus-summary-first-subject)
6120 (gnus-summary-show-thread)
6121 (gnus-summary-first-subject)
6122 (gnus-summary-display-article (gnus-summary-article-number)))
6123 (gnus-summary-position-point)))
6125 (defun gnus-summary-best-unread-article ()
6126 "Select the unread article with the highest score."
6128 (let ((best -1000000)
6129 (data gnus-newsgroup-data)
6132 (and (gnus-data-unread-p (car data))
6134 (gnus-summary-article-score (gnus-data-number (car data))))
6137 article (gnus-data-number (car data))))
6138 (setq data (cdr data)))
6141 (gnus-summary-goto-article article)
6142 (error "No unread articles"))
6143 (gnus-summary-position-point))))
6145 (defun gnus-summary-last-subject ()
6146 "Go to the last displayed subject line in the group."
6147 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6149 (gnus-summary-goto-subject article))))
6151 (defun gnus-summary-goto-article (article &optional all-headers force)
6152 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6153 If ALL-HEADERS is non-nil, no header lines are hidden.
6154 If FORCE, go to the article even if it isn't displayed. If FORCE
6155 is a number, it is the line the article is to be displayed on."
6159 "Article number or Message-ID: "
6160 (mapcar (lambda (number) (list (int-to-string number)))
6161 gnus-newsgroup-limit))
6165 (if (and (stringp article)
6166 (string-match "@" article))
6167 (gnus-summary-refer-article article)
6168 (when (stringp article)
6169 (setq article (string-to-number article)))
6170 (if (gnus-summary-goto-subject article force)
6171 (gnus-summary-display-article article all-headers)
6172 (gnus-message 4 "Couldn't go to article %s" article) nil))
6173 (gnus-summary-position-point)))
6175 (defun gnus-summary-goto-last-article ()
6176 "Go to the previously read article."
6179 (when gnus-last-article
6180 (gnus-summary-goto-article gnus-last-article nil t))
6181 (gnus-summary-position-point)))
6183 (defun gnus-summary-pop-article (number)
6184 "Pop one article off the history and go to the previous.
6185 NUMBER articles will be popped off."
6188 (setq gnus-newsgroup-history
6189 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6191 (gnus-summary-goto-article (car to) nil t)
6192 (error "Article history empty")))
6193 (gnus-summary-position-point))
6195 ;; Summary commands and functions for limiting the summary buffer.
6197 (defun gnus-summary-limit-to-articles (n)
6198 "Limit the summary buffer to the next N articles.
6199 If not given a prefix, use the process marked articles instead."
6202 (let ((articles (gnus-summary-work-articles n)))
6203 (setq gnus-newsgroup-processable nil)
6204 (gnus-summary-limit articles))
6205 (gnus-summary-position-point)))
6207 (defun gnus-summary-pop-limit (&optional total)
6208 "Restore the previous limit.
6209 If given a prefix, remove all limits."
6212 (setq gnus-newsgroup-limits
6213 (list (mapcar (lambda (h) (mail-header-number h))
6214 gnus-newsgroup-headers))))
6215 (unless gnus-newsgroup-limits
6216 (error "No limit to pop"))
6218 (gnus-summary-limit nil 'pop)
6219 (gnus-summary-position-point)))
6221 (defun gnus-summary-limit-to-subject (subject &optional header)
6222 "Limit the summary buffer to articles that have subjects that match a regexp."
6223 (interactive "sLimit to subject (regexp): ")
6225 (setq header "subject"))
6226 (when (not (equal "" subject))
6228 (let ((articles (gnus-summary-find-matching
6229 (or header "subject") subject 'all)))
6231 (error "Found no matches for \"%s\"" subject))
6232 (gnus-summary-limit articles))
6233 (gnus-summary-position-point))))
6235 (defun gnus-summary-limit-to-author (from)
6236 "Limit the summary buffer to articles that have authors that match a regexp."
6237 (interactive "sLimit to author (regexp): ")
6238 (gnus-summary-limit-to-subject from "from"))
6240 (defun gnus-summary-limit-to-age (age &optional younger-p)
6241 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6242 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6243 articles that are younger than AGE days."
6245 (let ((younger current-prefix-arg)
6248 (while (not days-got)
6249 (setq days (if younger
6250 (read-string "Limit to articles within (in days): ")
6251 (read-string "Limit to articles old than (in days): ")))
6252 (when (> (length days) 0)
6253 (setq days (read days)))
6256 (message "Please enter a number.")
6258 (list days younger)))
6260 (let ((data gnus-newsgroup-data)
6261 (cutoff (days-to-time age))
6262 articles d date is-younger)
6263 (while (setq d (pop data))
6264 (when (and (vectorp (gnus-data-header d))
6265 (setq date (mail-header-date (gnus-data-header d))))
6266 (setq is-younger (time-less-p
6267 (time-since (condition-case ()
6274 (push (gnus-data-number d) articles))))
6275 (gnus-summary-limit (nreverse articles)))
6276 (gnus-summary-position-point)))
6278 (defun gnus-summary-limit-to-extra (header regexp)
6279 "Limit the summary buffer to articles that match an 'extra' header."
6283 (gnus-completing-read
6284 (symbol-name (car gnus-extra-headers))
6285 "Limit extra header:"
6287 (cons (symbol-name x) x))
6292 (read-string (format "Limit to header %s (regexp): " header)))))
6293 (when (not (equal "" regexp))
6295 (let ((articles (gnus-summary-find-matching
6296 (cons 'extra header) regexp 'all)))
6298 (error "Found no matches for \"%s\"" regexp))
6299 (gnus-summary-limit articles))
6300 (gnus-summary-position-point))))
6302 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6304 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6306 (defun gnus-summary-limit-to-unread (&optional all)
6307 "Limit the summary buffer to articles that are not marked as read.
6308 If ALL is non-nil, limit strictly to unread articles."
6311 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6312 (gnus-summary-limit-to-marks
6313 ;; Concat all the marks that say that an article is read and have
6315 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6316 gnus-killed-mark gnus-kill-file-mark
6317 gnus-low-score-mark gnus-expirable-mark
6318 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6319 gnus-duplicate-mark gnus-souped-mark)
6322 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6323 (make-obsolete 'gnus-summary-delete-marked-with
6324 'gnus-summary-limit-exlude-marks)
6326 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6327 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6328 If REVERSE, limit the summary buffer to articles that are marked
6329 with MARKS. MARKS can either be a string of marks or a list of marks.
6330 Returns how many articles were removed."
6331 (interactive "sMarks: ")
6332 (gnus-summary-limit-to-marks marks t))
6334 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6335 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6336 If REVERSE (the prefix), limit the summary buffer to articles that are
6337 not marked with MARKS. MARKS can either be a string of marks or a
6339 Returns how many articles were removed."
6340 (interactive "sMarks: \nP")
6342 (let ((data gnus-newsgroup-data)
6343 (marks (if (listp marks) marks
6344 (append marks nil))) ; Transform to list.
6347 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6348 (memq (gnus-data-mark (car data)) marks))
6349 (push (gnus-data-number (car data)) articles))
6350 (setq data (cdr data)))
6351 (gnus-summary-limit articles))
6352 (gnus-summary-position-point)))
6354 (defun gnus-summary-limit-to-score (&optional score)
6355 "Limit to articles with score at or above SCORE."
6357 (setq score (if score
6358 (prefix-numeric-value score)
6359 (or gnus-summary-default-score 0)))
6360 (let ((data gnus-newsgroup-data)
6363 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6365 (push (gnus-data-number (car data)) articles))
6366 (setq data (cdr data)))
6368 (gnus-summary-limit articles)
6369 (gnus-summary-position-point))))
6371 (defun gnus-summary-limit-include-thread (id)
6372 "Display all the hidden articles that in the current thread."
6373 (interactive (list (mail-header-id (gnus-summary-article-header))))
6374 (let ((articles (gnus-articles-in-thread
6375 (gnus-id-to-thread (gnus-root-id id)))))
6377 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6378 (gnus-summary-position-point))))
6380 (defun gnus-summary-limit-include-dormant ()
6381 "Display all the hidden articles that are marked as dormant.
6382 Note that this command only works on a subset of the articles currently
6383 fetched for this group."
6385 (unless gnus-newsgroup-dormant
6386 (error "There are no dormant articles in this group"))
6388 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6389 (gnus-summary-position-point)))
6391 (defun gnus-summary-limit-exclude-dormant ()
6392 "Hide all dormant articles."
6395 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6396 (gnus-summary-position-point)))
6398 (defun gnus-summary-limit-exclude-childless-dormant ()
6399 "Hide all dormant articles that have no children."
6401 (let ((data (gnus-data-list t))
6402 articles d children)
6403 ;; Find all articles that are either not dormant or have
6405 (while (setq d (pop data))
6406 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6408 (gnus-article-children (gnus-data-number d)))
6411 (when (memq (car children) articles)
6416 (push (gnus-data-number d) articles)))
6419 (gnus-summary-limit articles)
6420 (gnus-summary-position-point))))
6422 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6423 "Mark all unread excluded articles as read.
6424 If ALL, mark even excluded ticked and dormants as read."
6426 (let ((articles (gnus-sorted-complement
6428 (mapcar (lambda (h) (mail-header-number h))
6429 gnus-newsgroup-headers)
6431 (sort gnus-newsgroup-limit '<)))
6433 (setq gnus-newsgroup-unreads
6434 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6436 (setq gnus-newsgroup-dormant nil
6437 gnus-newsgroup-marked nil
6438 gnus-newsgroup-reads
6440 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6441 gnus-newsgroup-reads))
6442 (while (setq article (pop articles))
6443 (unless (or (memq article gnus-newsgroup-dormant)
6444 (memq article gnus-newsgroup-marked))
6445 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6447 (defun gnus-summary-limit (articles &optional pop)
6449 ;; We pop the previous limit off the stack and use that.
6450 (setq articles (car gnus-newsgroup-limits)
6451 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6452 ;; We use the new limit, so we push the old limit on the stack.
6453 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6455 (setq gnus-newsgroup-limit articles)
6456 (let ((total (length gnus-newsgroup-data))
6457 (data (gnus-data-find-list (gnus-summary-article-number)))
6458 (gnus-summary-mark-below nil) ; Inhibit this.
6460 ;; This will do all the work of generating the new summary buffer
6461 ;; according to the new limit.
6462 (gnus-summary-prepare)
6463 ;; Hide any threads, possibly.
6464 (and gnus-show-threads
6465 gnus-thread-hide-subtree
6466 (gnus-summary-hide-all-threads))
6467 ;; Try to return to the article you were at, or one in the
6470 ;; We try to find some article after the current one.
6472 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6475 (setq data (cdr data))))
6477 ;; If there is no data, that means that we were after the last
6478 ;; article. The same goes when we can't find any articles
6479 ;; after the current one.
6480 (goto-char (point-max))
6481 (gnus-summary-find-prev))
6482 (gnus-set-mode-line 'summary)
6483 ;; We return how many articles were removed from the summary
6484 ;; buffer as a result of the new limit.
6485 (- total (length gnus-newsgroup-data))))
6487 (defsubst gnus-invisible-cut-children (threads)
6490 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6495 (defsubst gnus-cut-thread (thread)
6496 "Go forwards in the thread until we find an article that we want to display."
6497 (when (or (eq gnus-fetch-old-headers 'some)
6498 (eq gnus-fetch-old-headers 'invisible)
6499 (numberp gnus-fetch-old-headers)
6500 (eq gnus-build-sparse-threads 'some)
6501 (eq gnus-build-sparse-threads 'more))
6502 ;; Deal with old-fetched headers and sparse threads.
6506 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6507 (gnus-summary-article-ancient-p
6508 (mail-header-number (car thread))))
6509 (if (or (<= (length (cdr thread)) 1)
6510 (eq gnus-fetch-old-headers 'invisible))
6511 (setq gnus-newsgroup-limit
6512 (delq (mail-header-number (car thread))
6513 gnus-newsgroup-limit)
6514 thread (cadr thread))
6515 (when (gnus-invisible-cut-children (cdr thread))
6516 (let ((th (cdr thread)))
6518 (if (memq (mail-header-number (caar th))
6519 gnus-newsgroup-limit)
6520 (setq thread (car th)
6522 (setq th (cdr th))))))))))
6525 (defun gnus-cut-threads (threads)
6526 "Cut off all uninteresting articles from the beginning of threads."
6527 (when (or (eq gnus-fetch-old-headers 'some)
6528 (eq gnus-fetch-old-headers 'invisible)
6529 (numberp gnus-fetch-old-headers)
6530 (eq gnus-build-sparse-threads 'some)
6531 (eq gnus-build-sparse-threads 'more))
6534 (setcar th (gnus-cut-thread (car th)))
6535 (setq th (cdr th)))))
6536 ;; Remove nixed out threads.
6539 (defun gnus-summary-initial-limit (&optional show-if-empty)
6540 "Figure out what the initial limit is supposed to be on group entry.
6541 This entails weeding out unwanted dormants, low-scored articles,
6542 fetch-old-headers verbiage, and so on."
6543 ;; Most groups have nothing to remove.
6544 (if (or gnus-inhibit-limiting
6545 (and (null gnus-newsgroup-dormant)
6546 (not (eq gnus-fetch-old-headers 'some))
6547 (not (numberp gnus-fetch-old-headers))
6548 (not (eq gnus-fetch-old-headers 'invisible))
6549 (null gnus-summary-expunge-below)
6550 (not (eq gnus-build-sparse-threads 'some))
6551 (not (eq gnus-build-sparse-threads 'more))
6552 (null gnus-thread-expunge-below)
6553 (not gnus-use-nocem)))
6555 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6556 (setq gnus-newsgroup-limit nil)
6559 (unless (car (symbol-value node))
6560 ;; These threads have no parents -- they are roots.
6561 (let ((nodes (cdr (symbol-value node)))
6564 (if (and gnus-thread-expunge-below
6565 (< (gnus-thread-total-score (car nodes))
6566 gnus-thread-expunge-below))
6567 (gnus-expunge-thread (pop nodes))
6568 (setq thread (pop nodes))
6569 (gnus-summary-limit-children thread))))))
6570 gnus-newsgroup-dependencies)
6571 ;; If this limitation resulted in an empty group, we might
6572 ;; pop the previous limit and use it instead.
6573 (when (and (not gnus-newsgroup-limit)
6575 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6576 gnus-newsgroup-limit))
6578 (defun gnus-summary-limit-children (thread)
6579 "Return 1 if this subthread is visible and 0 if it is not."
6580 ;; First we get the number of visible children to this thread. This
6581 ;; is done by recursing down the thread using this function, so this
6582 ;; will really go down to a leaf article first, before slowly
6583 ;; working its way up towards the root.
6587 (apply '+ (mapcar 'gnus-summary-limit-children
6590 (number (mail-header-number (car thread)))
6593 (not (memq number gnus-newsgroup-marked))
6595 ;; If this article is dormant and has absolutely no visible
6596 ;; children, then this article isn't visible.
6597 (and (memq number gnus-newsgroup-dormant)
6599 ;; If this is "fetch-old-headered" and there is no
6600 ;; visible children, then we don't want this article.
6601 (and (or (eq gnus-fetch-old-headers 'some)
6602 (numberp gnus-fetch-old-headers))
6603 (gnus-summary-article-ancient-p number)
6605 ;; If this is "fetch-old-headered" and `invisible', then
6606 ;; we don't want this article.
6607 (and (eq gnus-fetch-old-headers 'invisible)
6608 (gnus-summary-article-ancient-p number))
6609 ;; If this is a sparsely inserted article with no children,
6610 ;; we don't want it.
6611 (and (eq gnus-build-sparse-threads 'some)
6612 (gnus-summary-article-sparse-p number)
6614 ;; If we use expunging, and this article is really
6615 ;; low-scored, then we don't want this article.
6616 (when (and gnus-summary-expunge-below
6618 (or (cdr (assq number gnus-newsgroup-scored))
6619 gnus-summary-default-score))
6620 gnus-summary-expunge-below))
6621 ;; We increase the expunge-tally here, but that has
6622 ;; nothing to do with the limits, really.
6623 (incf gnus-newsgroup-expunged-tally)
6624 ;; We also mark as read here, if that's wanted.
6625 (when (and gnus-summary-mark-below
6626 (< score gnus-summary-mark-below))
6627 (setq gnus-newsgroup-unreads
6628 (delq number gnus-newsgroup-unreads))
6629 (if gnus-newsgroup-auto-expire
6630 (push number gnus-newsgroup-expirable)
6631 (push (cons number gnus-low-score-mark)
6632 gnus-newsgroup-reads)))
6634 ;; Check NoCeM things.
6635 (if (and gnus-use-nocem
6636 (gnus-nocem-unwanted-article-p
6637 (mail-header-id (car thread))))
6639 (setq gnus-newsgroup-unreads
6640 (delq number gnus-newsgroup-unreads))
6642 ;; Nope, invisible article.
6644 ;; Ok, this article is to be visible, so we add it to the limit
6646 (push number gnus-newsgroup-limit)
6649 (defun gnus-expunge-thread (thread)
6650 "Mark all articles in THREAD as read."
6651 (let* ((number (mail-header-number (car thread))))
6652 (incf gnus-newsgroup-expunged-tally)
6653 ;; We also mark as read here, if that's wanted.
6654 (setq gnus-newsgroup-unreads
6655 (delq number gnus-newsgroup-unreads))
6656 (if gnus-newsgroup-auto-expire
6657 (push number gnus-newsgroup-expirable)
6658 (push (cons number gnus-low-score-mark)
6659 gnus-newsgroup-reads)))
6660 ;; Go recursively through all subthreads.
6661 (mapcar 'gnus-expunge-thread (cdr thread)))
6663 ;; Summary article oriented commands
6665 (defun gnus-summary-refer-parent-article (n)
6666 "Refer parent article N times.
6667 If N is negative, go to ancestor -N instead.
6668 The difference between N and the number of articles fetched is returned."
6672 (when (not (natnump n))
6677 (setq header (gnus-summary-article-header))
6678 (if (and (eq (mail-header-number header)
6679 (cdr gnus-article-current))
6680 (equal gnus-newsgroup-name
6681 (car gnus-article-current)))
6682 ;; If we try to find the parent of the currently
6683 ;; displayed article, then we take a look at the actual
6684 ;; References header, since this is slightly more
6685 ;; reliable than the References field we got from the
6688 (set-buffer gnus-original-article-buffer)
6689 (nnheader-narrow-to-headers)
6690 (unless (setq ref (message-fetch-field "references"))
6691 (setq ref (message-fetch-field "in-reply-to")))
6694 ;; It's not the current article, so we take a bet on
6695 ;; the value we got from the server.
6696 (mail-header-references header)))
6698 (not (equal ref "")))
6699 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6700 (gnus-message 1 "Couldn't find parent"))
6701 (gnus-message 1 "No references in article %d"
6702 (gnus-summary-article-number))
6705 (gnus-summary-position-point)
6708 (defun gnus-summary-refer-references ()
6709 "Fetch all articles mentioned in the References header.
6710 Return the number of articles fetched."
6712 (let ((ref (mail-header-references (gnus-summary-article-header)))
6713 (current (gnus-summary-article-number))
6717 (error "No References in the current article")
6718 ;; For each Message-ID in the References header...
6719 (while (string-match "<[^>]*>" ref)
6721 ;; ... fetch that article.
6722 (gnus-summary-refer-article
6723 (prog1 (match-string 0 ref)
6724 (setq ref (substring ref (match-end 0))))))
6725 (gnus-summary-goto-subject current)
6726 (gnus-summary-position-point)
6729 (defun gnus-summary-refer-thread (&optional limit)
6730 "Fetch all articles in the current thread.
6731 If LIMIT (the numerical prefix), fetch that many old headers instead
6732 of what's specified by the `gnus-refer-thread-limit' variable."
6734 (let ((id (mail-header-id (gnus-summary-article-header)))
6735 (limit (if limit (prefix-numeric-value limit)
6736 gnus-refer-thread-limit)))
6737 ;; We want to fetch LIMIT *old* headers, but we also have to
6738 ;; re-fetch all the headers in the current buffer, because many of
6739 ;; them may be undisplayed. So we adjust LIMIT.
6740 (when (numberp limit)
6741 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6742 (unless (eq gnus-fetch-old-headers 'invisible)
6743 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6744 ;; Retrieve the headers and read them in.
6745 (if (eq (gnus-retrieve-headers
6746 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6748 (gnus-build-all-threads)
6749 (error "Can't fetch thread from backends that don't support NOV"))
6750 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6751 (gnus-summary-limit-include-thread id)))
6753 (defun gnus-summary-refer-article (message-id)
6754 "Fetch an article specified by MESSAGE-ID."
6755 (interactive "sMessage-ID: ")
6756 (when (and (stringp message-id)
6757 (not (zerop (length message-id))))
6758 ;; Construct the correct Message-ID if necessary.
6759 ;; Suggested by tale@pawl.rpi.edu.
6760 (unless (string-match "^<" message-id)
6761 (setq message-id (concat "<" message-id)))
6762 (unless (string-match ">$" message-id)
6763 (setq message-id (concat message-id ">")))
6764 (let* ((header (gnus-id-to-header message-id))
6766 (gnus-summary-article-sparse-p
6767 (mail-header-number header))
6768 (memq (mail-header-number header)
6769 gnus-newsgroup-limit)))
6772 ;; If the article is present in the buffer we just go to it.
6774 (or (not (gnus-summary-article-sparse-p
6775 (mail-header-number header)))
6778 (gnus-summary-goto-article
6779 (mail-header-number header) nil t)
6781 (gnus-summary-update-article (mail-header-number header)))))
6783 ;; We fetch the article.
6785 (dolist (gnus-override-method (gnus-refer-article-methods))
6786 (gnus-check-server gnus-override-method)
6787 ;; Fetch the header, and display the article.
6788 (when (setq number (gnus-summary-insert-subject message-id))
6789 (gnus-summary-select-article nil nil nil number)
6791 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
6793 (defun gnus-refer-article-methods ()
6794 "Return a list of referrable methods."
6796 ;; No method, so we default to current and native.
6797 ((null gnus-refer-article-method)
6798 (list gnus-current-select-method gnus-select-method))
6800 ((eq 'current gnus-refer-article-method)
6801 (list gnus-current-select-method))
6802 ;; List of select methods.
6803 ((not (stringp (cadr gnus-refer-article-method)))
6805 (dolist (method gnus-refer-article-method)
6806 (push (if (eq 'current method)
6807 gnus-current-select-method
6811 ;; One single select method.
6813 (list gnus-refer-article-method))))
6815 (defun gnus-summary-edit-parameters ()
6816 "Edit the group parameters of the current group."
6818 (gnus-group-edit-group gnus-newsgroup-name 'params))
6820 (defun gnus-summary-customize-parameters ()
6821 "Customize the group parameters of the current group."
6823 (gnus-group-customize gnus-newsgroup-name))
6825 (defun gnus-summary-enter-digest-group (&optional force)
6826 "Enter an nndoc group based on the current article.
6827 If FORCE, force a digest interpretation. If not, try
6828 to guess what the document format is."
6830 (let ((conf gnus-current-window-configuration))
6832 (gnus-summary-select-article))
6833 (setq gnus-current-window-configuration conf)
6834 (let* ((name (format "%s-%d"
6835 (gnus-group-prefixed-name
6836 gnus-newsgroup-name (list 'nndoc ""))
6838 (set-buffer gnus-summary-buffer)
6839 gnus-current-article)))
6840 (ogroup gnus-newsgroup-name)
6841 (params (append (gnus-info-params (gnus-get-info ogroup))
6842 (list (cons 'to-group ogroup))
6843 (list (cons 'save-article-group ogroup))))
6844 (case-fold-search t)
6845 (buf (current-buffer))
6848 (set-buffer gnus-original-article-buffer)
6849 ;; Have the digest group inherit the main mail address of
6850 ;; the parent article.
6851 (when (setq to-address (or (message-fetch-field "reply-to")
6852 (message-fetch-field "from")))
6853 (setq params (append (list (cons 'to-address to-address)))))
6854 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6855 (insert-buffer-substring gnus-original-article-buffer)
6856 ;; Remove lines that may lead nndoc to misinterpret the
6859 (goto-char (point-min))
6860 (or (search-forward "\n\n" nil t) (point)))
6861 (goto-char (point-min))
6862 (delete-matching-lines "^Path:\\|^From ")
6865 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
6866 (gnus-newsgroup-ephemeral-ignored-charsets
6867 gnus-newsgroup-ignored-charsets))
6868 (gnus-group-read-ephemeral-group
6869 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6871 ,(if force 'mbox 'guess))) t))
6872 ;; Make all postings to this group go to the parent group.
6873 (nconc (gnus-info-params (gnus-get-info name))
6875 ;; Couldn't select this doc group.
6876 (switch-to-buffer buf)
6877 (gnus-set-global-variables)
6878 (gnus-configure-windows 'summary)
6879 (gnus-message 3 "Article couldn't be entered?"))
6880 (kill-buffer dig)))))
6882 (defun gnus-summary-read-document (n)
6883 "Open a new group based on the current article(s).
6884 This will allow you to read digests and other similar
6885 documents as newsgroups.
6886 Obeys the standard process/prefix convention."
6888 (let* ((articles (gnus-summary-work-articles n))
6889 (ogroup gnus-newsgroup-name)
6890 (params (append (gnus-info-params (gnus-get-info ogroup))
6891 (list (cons 'to-group ogroup))))
6892 article group egroup groups vgroup)
6893 (while (setq article (pop articles))
6894 (setq group (format "%s-%d" gnus-newsgroup-name article))
6895 (gnus-summary-remove-process-mark article)
6896 (when (gnus-summary-display-article article)
6899 (insert-buffer-substring gnus-original-article-buffer)
6900 ;; Remove some headers that may lead nndoc to make
6902 (message-narrow-to-head)
6903 (goto-char (point-min))
6904 (delete-matching-lines "^\\(Path\\):\\|^From ")
6907 (gnus-group-read-ephemeral-group
6908 group `(nndoc ,group (nndoc-address ,(current-buffer))
6909 (nndoc-article-type guess))
6912 ;; Make all postings to this group go to the parent group.
6913 (nconc (gnus-info-params (gnus-get-info egroup))
6915 (push egroup groups))
6916 ;; Couldn't select this doc group.
6917 (gnus-error 3 "Article couldn't be entered"))))))
6918 ;; Now we have selected all the documents.
6921 (error "None of the articles could be interpreted as documents"))
6922 ((gnus-group-read-ephemeral-group
6923 (setq vgroup (format
6924 "nnvirtual:%s-%s" gnus-newsgroup-name
6925 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6926 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6928 (cons (current-buffer) 'summary)))
6930 (error "Couldn't select virtual nndoc group")))))
6932 (defun gnus-summary-isearch-article (&optional regexp-p)
6933 "Do incremental search forward on the current article.
6934 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6936 (gnus-summary-select-article)
6937 (gnus-configure-windows 'article)
6938 (gnus-eval-in-buffer-window gnus-article-buffer
6941 (isearch-forward regexp-p))))
6943 (defun gnus-summary-search-article-forward (regexp &optional backward)
6944 "Search for an article containing REGEXP forward.
6945 If BACKWARD, search backward instead."
6948 (format "Search article %s (regexp%s): "
6949 (if current-prefix-arg "backward" "forward")
6950 (if gnus-last-search-regexp
6951 (concat ", default " gnus-last-search-regexp)
6953 current-prefix-arg))
6954 (if (string-equal regexp "")
6955 (setq regexp (or gnus-last-search-regexp ""))
6956 (setq gnus-last-search-regexp regexp))
6957 (if (gnus-summary-search-article regexp backward)
6958 (gnus-summary-show-thread)
6959 (error "Search failed: \"%s\"" regexp)))
6961 (defun gnus-summary-search-article-backward (regexp)
6962 "Search for an article containing REGEXP backward."
6965 (format "Search article backward (regexp%s): "
6966 (if gnus-last-search-regexp
6967 (concat ", default " gnus-last-search-regexp)
6969 (gnus-summary-search-article-forward regexp 'backward))
6971 (defun gnus-summary-search-article (regexp &optional backward)
6972 "Search for an article containing REGEXP.
6973 Optional argument BACKWARD means do search for backward.
6974 `gnus-select-article-hook' is not called during the search."
6975 ;; We have to require this here to make sure that the following
6976 ;; dynamic binding isn't shadowed by autoloading.
6977 (require 'gnus-async)
6979 (let ((gnus-select-article-hook nil) ;Disable hook.
6980 (gnus-article-prepare-hook nil)
6981 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6982 (gnus-use-article-prefetch nil)
6983 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
6984 (gnus-use-trees nil) ;Inhibit updating tree buffer.
6985 (sum (current-buffer))
6986 (gnus-display-mime-function nil)
6989 (gnus-save-hidden-threads
6990 (gnus-summary-select-article)
6991 (set-buffer gnus-article-buffer)
6992 (goto-char (window-point (get-buffer-window (current-buffer))))
6996 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
6998 (re-search-backward regexp nil t)
6999 (re-search-forward regexp nil t))
7000 ;; We found the regexp.
7005 (get-buffer-window (current-buffer))
7009 (get-buffer-window (current-buffer))
7012 (setq point (point)))
7013 ;; We didn't find it, so we go to the next article.
7016 (while (eq found 'not)
7017 (if (not (if backward (gnus-summary-find-prev)
7018 (gnus-summary-find-next)))
7019 ;; No more articles.
7021 ;; Select the next article and adjust point.
7022 (unless (gnus-summary-article-sparse-p
7023 (gnus-summary-article-number))
7025 (gnus-summary-select-article)
7026 (set-buffer gnus-article-buffer)
7028 (goto-char (if backward (point-max) (point-min))))))))
7029 (gnus-message 7 ""))
7030 ;; Return whether we found the regexp.
7031 (when (eq found 'found)
7033 (gnus-summary-show-thread)
7034 (gnus-summary-goto-subject gnus-current-article)
7035 (gnus-summary-position-point)
7038 (defun gnus-summary-find-matching (header regexp &optional backward unread
7040 "Return a list of all articles that match REGEXP on HEADER.
7041 The search stars on the current article and goes forwards unless
7042 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
7043 If UNREAD is non-nil, only unread articles will
7044 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
7045 in the comparisons."
7046 (let ((data (if (eq backward 'all) gnus-newsgroup-data
7047 (gnus-data-find-list
7048 (gnus-summary-article-number) (gnus-data-list backward))))
7049 (case-fold-search (not not-case-fold))
7052 (if (eq (car header) 'extra)
7055 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
7057 (error "%s is an invalid header" header))
7058 (unless (fboundp (intern (concat "mail-header-" header)))
7059 (error "%s is not a valid header" header))
7060 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
7063 (and (or (not unread) ; We want all articles...
7064 (gnus-data-unread-p d)) ; Or just unreads.
7065 (vectorp (gnus-data-header d)) ; It's not a pseudo.
7066 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
7067 (push (gnus-data-number d) articles)) ; Success!
7068 (setq data (cdr data)))
7069 (nreverse articles)))
7071 (defun gnus-summary-execute-command (header regexp command &optional backward)
7072 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7073 If HEADER is an empty string (or nil), the match is done on the entire
7074 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7076 (list (let ((completion-ignore-case t))
7079 (mapcar (lambda (string) (list string))
7080 '("Number" "Subject" "From" "Lines" "Date"
7081 "Message-ID" "Xref" "References" "Body"))
7082 nil 'require-match))
7083 (read-string "Regexp: ")
7084 (read-key-sequence "Command: ")
7085 current-prefix-arg))
7086 (when (equal header "Body")
7088 ;; Hidden thread subtrees must be searched as well.
7089 (gnus-summary-show-all-threads)
7090 ;; We don't want to change current point nor window configuration.
7092 (save-window-excursion
7093 (gnus-message 6 "Executing %s..." (key-description command))
7094 ;; We'd like to execute COMMAND interactively so as to give arguments.
7095 (gnus-execute header regexp
7096 `(call-interactively ',(key-binding command))
7098 (gnus-message 6 "Executing %s...done" (key-description command)))))
7100 (defun gnus-summary-beginning-of-article ()
7101 "Scroll the article back to the beginning."
7103 (gnus-summary-select-article)
7104 (gnus-configure-windows 'article)
7105 (gnus-eval-in-buffer-window gnus-article-buffer
7107 (goto-char (point-min))
7108 (when gnus-page-broken
7109 (gnus-narrow-to-page))))
7111 (defun gnus-summary-end-of-article ()
7112 "Scroll to the end of the article."
7114 (gnus-summary-select-article)
7115 (gnus-configure-windows 'article)
7116 (gnus-eval-in-buffer-window gnus-article-buffer
7118 (goto-char (point-max))
7120 (when gnus-page-broken
7121 (gnus-narrow-to-page))))
7123 (defun gnus-summary-print-article (&optional filename n)
7124 "Generate and print a PostScript image of the N next (mail) articles.
7126 If N is negative, print the N previous articles. If N is nil and articles
7127 have been marked with the process mark, print these instead.
7129 If the optional first argument FILENAME is nil, send the image to the
7130 printer. If FILENAME is a string, save the PostScript image in a file with
7131 that name. If FILENAME is a number, prompt the user for the name of the file
7133 (interactive (list (ps-print-preprint current-prefix-arg)
7134 current-prefix-arg))
7135 (dolist (article (gnus-summary-work-articles n))
7136 (gnus-summary-select-article nil nil 'pseudo article)
7137 (gnus-eval-in-buffer-window gnus-article-buffer
7138 (let ((buffer (generate-new-buffer " *print*")))
7141 (copy-to-buffer buffer (point-min) (point-max))
7143 (gnus-article-delete-invisible-text)
7144 (let ((ps-left-header
7147 (mail-header-subject gnus-current-headers) ")")
7149 (mail-header-from gnus-current-headers) ")")))
7152 "/pagenumberstring load"
7154 (mail-header-date gnus-current-headers) ")"))))
7155 (gnus-run-hooks 'gnus-ps-print-hook)
7157 (ps-print-buffer-with-faces filename))))
7158 (kill-buffer buffer))))))
7160 (defun gnus-summary-show-article (&optional arg)
7161 "Force re-fetching of the current article.
7162 If ARG (the prefix) is a number, show the article with the charset
7163 defined in `gnus-summary-show-article-charset-alist', or the charset
7165 If ARG (the prefix) is non-nil and not a number, show the raw article
7166 without any article massaging functions being run."
7170 (let ((gnus-newsgroup-charset
7171 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
7172 (read-coding-system "Charset: ")))
7173 (gnus-newsgroup-ignored-charsets 'gnus-all))
7174 (gnus-summary-select-article nil 'force)))
7176 ;; Select the article the normal way.
7177 (gnus-summary-select-article nil 'force))
7179 ;; We have to require this here to make sure that the following
7180 ;; dynamic binding isn't shadowed by autoloading.
7181 (require 'gnus-async)
7183 ;; Bind the article treatment functions to nil.
7184 (let ((gnus-have-all-headers t)
7185 gnus-article-prepare-hook
7186 gnus-article-decode-hook
7187 gnus-display-mime-function
7189 ;; Destroy any MIME parts.
7190 (when (gnus-buffer-live-p gnus-article-buffer)
7192 (set-buffer gnus-article-buffer)
7193 (mm-destroy-parts gnus-article-mime-handles)))
7194 (gnus-summary-select-article nil 'force))))
7195 (gnus-summary-goto-subject gnus-current-article)
7196 (gnus-summary-position-point))
7198 (defun gnus-summary-verbose-headers (&optional arg)
7199 "Toggle permanent full header display.
7200 If ARG is a positive number, turn header display on.
7201 If ARG is a negative number, turn header display off."
7203 (setq gnus-show-all-headers
7204 (cond ((or (not (numberp arg))
7206 (not gnus-show-all-headers))
7209 (gnus-summary-show-article))
7211 (defun gnus-summary-toggle-header (&optional arg)
7212 "Show the headers if they are hidden, or hide them if they are shown.
7213 If ARG is a positive number, show the entire header.
7214 If ARG is a negative number, hide the unwanted header lines."
7217 (set-buffer gnus-article-buffer)
7219 (let* ((buffer-read-only nil)
7220 (inhibit-point-motion-hooks t)
7226 (article-narrow-to-head)
7227 (gnus-article-hidden-text-p 'headers))))
7228 (goto-char (point-min))
7229 (when (search-forward "\n\n" nil t)
7230 (delete-region (point-min) (1- (point))))
7231 (goto-char (point-min))
7233 (set-buffer gnus-original-article-buffer)
7234 (goto-char (point-min))
7235 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
7236 (insert-buffer-substring gnus-original-article-buffer 1 e)
7238 (narrow-to-region (point-min) (point))
7239 (article-decode-encoded-words)
7241 (let ((gnus-treat-hide-headers nil)
7242 (gnus-treat-hide-boring-headers nil))
7243 (setq gnus-article-wash-types
7244 (delq 'headers gnus-article-wash-types))
7245 (gnus-treat-article 'head))
7246 (gnus-treat-article 'head)))
7247 (gnus-set-mode-line 'article)))))
7249 (defun gnus-summary-show-all-headers ()
7250 "Make all header lines visible."
7252 (gnus-article-show-all-headers))
7254 (defun gnus-summary-caesar-message (&optional arg)
7255 "Caesar rotate the current article by 13.
7256 The numerical prefix specifies how many places to rotate each letter
7259 (gnus-summary-select-article)
7260 (let ((mail-header-separator ""))
7261 (gnus-eval-in-buffer-window gnus-article-buffer
7264 (let ((start (window-start))
7266 (message-caesar-buffer-body arg)
7267 (set-window-start (get-buffer-window (current-buffer)) start))))))
7269 (defun gnus-summary-stop-page-breaking ()
7270 "Stop page breaking in the current article."
7272 (gnus-summary-select-article)
7273 (gnus-eval-in-buffer-window gnus-article-buffer
7275 (when (gnus-visual-p 'page-marker)
7276 (let ((buffer-read-only nil))
7277 (gnus-remove-text-with-property 'gnus-prev)
7278 (gnus-remove-text-with-property 'gnus-next))
7279 (setq gnus-page-broken nil))))
7281 (defun gnus-summary-move-article (&optional n to-newsgroup
7282 select-method action)
7283 "Move the current article to a different newsgroup.
7284 If N is a positive number, move the N next articles.
7285 If N is a negative number, move the N previous articles.
7286 If N is nil and any articles have been marked with the process mark,
7287 move those articles instead.
7288 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7289 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7290 re-spool using this method.
7292 For this function to work, both the current newsgroup and the
7293 newsgroup that you want to move to have to support the `request-move'
7294 and `request-accept' functions.
7296 ACTION can be either `move' (the default), `crosspost' or `copy'."
7299 (setq action 'move))
7300 ;; Disable marking as read.
7301 (let (gnus-mark-article-hook)
7302 (save-window-excursion
7303 (gnus-summary-select-article)))
7304 ;; Check whether the source group supports the required functions.
7305 (cond ((and (eq action 'move)
7306 (not (gnus-check-backend-function
7307 'request-move-article gnus-newsgroup-name)))
7308 (error "The current group does not support article moving"))
7309 ((and (eq action 'crosspost)
7310 (not (gnus-check-backend-function
7311 'request-replace-article gnus-newsgroup-name)))
7312 (error "The current group does not support article editing")))
7313 (let ((articles (gnus-summary-work-articles n))
7314 (prefix (if (gnus-check-backend-function
7315 'request-move-article gnus-newsgroup-name)
7316 (gnus-group-real-prefix gnus-newsgroup-name)
7318 (names '((move "Move" "Moving")
7319 (copy "Copy" "Copying")
7320 (crosspost "Crosspost" "Crossposting")))
7321 (copy-buf (save-excursion
7322 (nnheader-set-temp-buffer " *copy article*")))
7323 art-group to-method new-xref article to-groups)
7324 (unless (assq action names)
7325 (error "Unknown action %s" action))
7326 ;; Read the newsgroup name.
7327 (when (and (not to-newsgroup)
7328 (not select-method))
7330 (gnus-read-move-group-name
7331 (cadr (assq action names))
7332 (symbol-value (intern (format "gnus-current-%s-group" action)))
7334 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
7335 (setq to-method (or select-method
7336 (gnus-group-method to-newsgroup)))
7337 ;; Check the method we are to move this article to...
7338 (unless (gnus-check-backend-function
7339 'request-accept-article (car to-method))
7340 (error "%s does not support article copying" (car to-method)))
7341 (unless (gnus-check-server to-method)
7342 (error "Can't open server %s" (car to-method)))
7343 (gnus-message 6 "%s to %s: %s..."
7344 (caddr (assq action names))
7345 (or (car select-method) to-newsgroup) articles)
7347 (setq article (pop articles))
7351 ;; Move the article.
7353 ;; Remove this article from future suppression.
7354 (gnus-dup-unsuppress-article article)
7355 (gnus-request-move-article
7356 article ; Article to move
7357 gnus-newsgroup-name ; From newsgroup
7358 (nth 1 (gnus-find-method-for-group
7359 gnus-newsgroup-name)) ; Server
7360 (list 'gnus-request-accept-article
7361 to-newsgroup (list 'quote select-method)
7362 (not articles) t) ; Accept form
7363 (not articles))) ; Only save nov last time
7364 ;; Copy the article.
7367 (set-buffer copy-buf)
7368 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
7369 (gnus-request-accept-article
7370 to-newsgroup select-method (not articles) t))))
7371 ;; Crosspost the article.
7372 ((eq action 'crosspost)
7373 (let ((xref (message-tokenize-header
7374 (mail-header-xref (gnus-summary-article-header article))
7376 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
7379 (setq xref (list (system-name))))
7382 (mapconcat 'identity
7383 (delete "Xref:" (delete new-xref xref))
7387 (set-buffer copy-buf)
7388 ;; First put the article in the destination group.
7389 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7390 (when (consp (setq art-group
7391 (gnus-request-accept-article
7392 to-newsgroup select-method (not articles))))
7393 (setq new-xref (concat new-xref " " (car art-group)
7394 ":" (cdr art-group)))
7395 ;; Now we have the new Xrefs header, so we insert
7396 ;; it and replace the new article.
7397 (nnheader-replace-header "Xref" new-xref)
7398 (gnus-request-replace-article
7399 (cdr art-group) to-newsgroup (current-buffer))
7403 (gnus-message 1 "Couldn't %s article %s: %s"
7404 (cadr (assq action names)) article
7405 (nnheader-get-report (car to-method))))
7406 ((eq art-group 'junk)
7407 (when (eq action 'move)
7408 (gnus-summary-mark-article article gnus-canceled-mark)
7409 (gnus-message 4 "Deleted article %s" article)))
7411 (let* ((pto-group (gnus-group-prefixed-name
7412 (car art-group) to-method))
7414 (gnus-gethash pto-group gnus-newsrc-hashtb))
7415 (info (nth 2 entry))
7416 (to-group (gnus-info-group info))
7418 ;; Update the group that has been moved to.
7420 (memq action '(move copy)))
7421 (unless (member to-group to-groups)
7422 (push to-group to-groups))
7424 (unless (memq article gnus-newsgroup-unreads)
7425 (push 'read to-marks)
7427 info (gnus-add-to-range (gnus-info-read info)
7428 (list (cdr art-group)))))
7430 ;; See whether the article is to be put in the cache.
7431 (let ((marks gnus-article-mark-lists)
7432 (to-article (cdr art-group)))
7434 ;; Enter the article into the cache in the new group,
7435 ;; if that is required.
7436 (when gnus-use-cache
7437 (gnus-cache-possibly-enter-article
7439 (memq article gnus-newsgroup-marked)
7440 (memq article gnus-newsgroup-dormant)
7441 (memq article gnus-newsgroup-unreads)))
7443 (when gnus-preserve-marks
7444 ;; Copy any marks over to the new group.
7445 (when (and (equal to-group gnus-newsgroup-name)
7446 (not (memq article gnus-newsgroup-unreads)))
7447 ;; Mark this article as read in this group.
7448 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7449 (setcdr (gnus-active to-group) to-article)
7450 (setcdr gnus-newsgroup-active to-article))
7453 (when (memq article (symbol-value
7454 (intern (format "gnus-newsgroup-%s"
7456 (push (cdar marks) to-marks)
7457 ;; If the other group is the same as this group,
7458 ;; then we have to add the mark to the list.
7459 (when (equal to-group gnus-newsgroup-name)
7460 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7463 (intern (format "gnus-newsgroup-%s"
7465 ;; Copy the marks to other group.
7466 (gnus-add-marked-articles
7467 to-group (cdar marks) (list to-article) info))
7468 (setq marks (cdr marks)))
7470 (gnus-request-set-mark to-group (list (list (list to-article)
7475 (concat "(gnus-group-set-info '"
7476 (gnus-prin1-to-string (gnus-get-info to-group))
7479 ;; Update the Xref header in this article to point to
7480 ;; the new crossposted article we have just created.
7481 (when (eq action 'crosspost)
7483 (set-buffer copy-buf)
7484 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7485 (nnheader-replace-header "Xref" new-xref)
7486 (gnus-request-replace-article
7487 article gnus-newsgroup-name (current-buffer)))))
7489 ;;;!!!Why is this necessary?
7490 (set-buffer gnus-summary-buffer)
7492 (gnus-summary-goto-subject article)
7493 (when (eq action 'move)
7494 (gnus-summary-mark-article article gnus-canceled-mark))))
7495 (gnus-summary-remove-process-mark article))
7496 ;; Re-activate all groups that have been moved to.
7499 (set-buffer gnus-group-buffer)
7500 (when (gnus-group-goto-group (car to-groups) t)
7501 (gnus-group-get-new-news-this-group 1 t))
7504 (gnus-kill-buffer copy-buf)
7505 (gnus-summary-position-point)
7506 (gnus-set-mode-line 'summary)))
7508 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7509 "Move the current article to a different newsgroup.
7510 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7511 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7512 re-spool using this method."
7514 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7516 (defun gnus-summary-crosspost-article (&optional n)
7517 "Crosspost the current article to some other group."
7519 (gnus-summary-move-article n nil nil 'crosspost))
7521 (defcustom gnus-summary-respool-default-method nil
7522 "Default method for respooling an article.
7523 If nil, use to the current newsgroup method."
7524 :type '(choice (gnus-select-method :value (nnml ""))
7526 :group 'gnus-summary-mail)
7528 (defun gnus-summary-respool-article (&optional n method)
7529 "Respool the current article.
7530 The article will be squeezed through the mail spooling process again,
7531 which means that it will be put in some mail newsgroup or other
7532 depending on `nnmail-split-methods'.
7533 If N is a positive number, respool the N next articles.
7534 If N is a negative number, respool the N previous articles.
7535 If N is nil and any articles have been marked with the process mark,
7536 respool those articles instead.
7538 Respooling can be done both from mail groups and \"real\" newsgroups.
7539 In the former case, the articles in question will be moved from the
7540 current group into whatever groups they are destined to. In the
7541 latter case, they will be copied into the relevant groups."
7543 (list current-prefix-arg
7544 (let* ((methods (gnus-methods-using 'respool))
7546 (symbol-name (or gnus-summary-respool-default-method
7547 (car (gnus-find-method-for-group
7548 gnus-newsgroup-name)))))
7550 (gnus-completing-read
7551 methname "What backend do you want to use when respooling?"
7552 methods nil t nil 'gnus-mail-method-history))
7555 ((zerop (length (setq ms (gnus-servers-using-backend
7557 (list (intern method) ""))
7561 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7562 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7565 (error "No method given for respooling"))
7566 (if (assoc (symbol-name
7567 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7568 (gnus-methods-using 'respool))
7569 (gnus-summary-move-article n nil method)
7570 (gnus-summary-copy-article n nil method)))
7572 (defun gnus-summary-import-article (file)
7573 "Import an arbitrary file into a mail newsgroup."
7574 (interactive "fImport file: ")
7575 (let ((group gnus-newsgroup-name)
7576 (now (current-time))
7578 (unless (gnus-check-backend-function 'request-accept-article group)
7579 (error "%s does not support article importing" group))
7580 (or (file-readable-p file)
7581 (not (file-regular-p file))
7582 (error "Can't read %s" file))
7584 (set-buffer (gnus-get-buffer-create " *import file*"))
7586 (insert-file-contents file)
7587 (goto-char (point-min))
7588 (unless (nnheader-article-p)
7589 ;; This doesn't look like an article, so we fudge some headers.
7590 (setq atts (file-attributes file)
7591 lines (count-lines (point-min) (point-max)))
7592 (insert "From: " (read-string "From: ") "\n"
7593 "Subject: " (read-string "Subject: ") "\n"
7594 "Date: " (message-make-date (nth 5 atts))
7596 "Message-ID: " (message-make-message-id) "\n"
7597 "Lines: " (int-to-string lines) "\n"
7598 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7599 (gnus-request-accept-article group nil t)
7600 (kill-buffer (current-buffer)))))
7602 (defun gnus-summary-article-posted-p ()
7603 "Say whether the current (mail) article is available from news as well.
7604 This will be the case if the article has both been mailed and posted."
7606 (let ((id (mail-header-references (gnus-summary-article-header)))
7607 (gnus-override-method (car (gnus-refer-article-methods))))
7608 (if (gnus-request-head id "")
7609 (gnus-message 2 "The current message was found on %s"
7610 gnus-override-method)
7611 (gnus-message 2 "The current message couldn't be found on %s"
7612 gnus-override-method)
7615 (defun gnus-summary-expire-articles (&optional now)
7616 "Expire all articles that are marked as expirable in the current group."
7618 (when (gnus-check-backend-function
7619 'request-expire-articles gnus-newsgroup-name)
7620 ;; This backend supports expiry.
7621 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7622 (expirable (if total
7624 ;; We need to update the info for
7625 ;; this group for `gnus-list-of-read-articles'
7626 ;; to give us the right answer.
7627 (gnus-run-hooks 'gnus-exit-group-hook)
7628 (gnus-summary-update-info)
7629 (gnus-list-of-read-articles gnus-newsgroup-name))
7630 (setq gnus-newsgroup-expirable
7631 (sort gnus-newsgroup-expirable '<))))
7632 (expiry-wait (if now 'immediate
7633 (gnus-group-find-parameter
7634 gnus-newsgroup-name 'expiry-wait)))
7637 ;; There are expirable articles in this group, so we run them
7638 ;; through the expiry process.
7639 (gnus-message 6 "Expiring articles...")
7640 (unless (gnus-check-group gnus-newsgroup-name)
7641 (error "Can't open server for %s" gnus-newsgroup-name))
7642 ;; The list of articles that weren't expired is returned.
7645 (let ((nnmail-expiry-wait-function nil)
7646 (nnmail-expiry-wait expiry-wait))
7647 (setq es (gnus-request-expire-articles
7648 expirable gnus-newsgroup-name)))
7649 (setq es (gnus-request-expire-articles
7650 expirable gnus-newsgroup-name))))
7652 (setq gnus-newsgroup-expirable es))
7653 ;; We go through the old list of expirable, and mark all
7654 ;; really expired articles as nonexistent.
7655 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7656 (let ((gnus-use-cache nil))
7658 (unless (memq (car expirable) es)
7659 (when (gnus-data-find (car expirable))
7660 (gnus-summary-mark-article
7661 (car expirable) gnus-canceled-mark)))
7662 (setq expirable (cdr expirable)))))
7663 (gnus-message 6 "Expiring articles...done")))))
7665 (defun gnus-summary-expire-articles-now ()
7666 "Expunge all expirable articles in the current group.
7667 This means that *all* articles that are marked as expirable will be
7668 deleted forever, right now."
7670 (or gnus-expert-user
7672 "Are you really, really, really sure you want to delete all these messages? ")
7674 (gnus-summary-expire-articles t))
7676 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7677 (defun gnus-summary-delete-article (&optional n)
7678 "Delete the N next (mail) articles.
7679 This command actually deletes articles. This is not a marking
7680 command. The article will disappear forever from your life, never to
7682 If N is negative, delete backwards.
7683 If N is nil and articles have been marked with the process mark,
7684 delete these instead."
7686 (unless (gnus-check-backend-function 'request-expire-articles
7687 gnus-newsgroup-name)
7688 (error "The current newsgroup does not support article deletion"))
7689 ;; Compute the list of articles to delete.
7690 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
7692 (if (and gnus-novice-user
7693 (not (gnus-yes-or-no-p
7694 (format "Do you really want to delete %s forever? "
7695 (if (> (length articles) 1)
7696 (format "these %s articles" (length articles))
7699 ;; Delete the articles.
7700 (setq not-deleted (gnus-request-expire-articles
7701 articles gnus-newsgroup-name 'force))
7703 (gnus-summary-remove-process-mark (car articles))
7704 ;; The backend might not have been able to delete the article
7706 (unless (memq (car articles) not-deleted)
7707 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7708 (setq articles (cdr articles)))
7710 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7711 (gnus-summary-position-point)
7712 (gnus-set-mode-line 'summary)
7715 (defun gnus-summary-edit-article (&optional force)
7716 "Edit the current article.
7717 This will have permanent effect only in mail groups.
7718 If FORCE is non-nil, allow editing of articles even in read-only
7722 (set-buffer gnus-summary-buffer)
7723 (let ((mail-parse-charset gnus-newsgroup-charset)
7724 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
7725 (gnus-set-global-variables)
7726 (when (and (not force)
7727 (gnus-group-read-only-p))
7728 (error "The current newsgroup does not support article editing"))
7729 (gnus-summary-show-article t)
7730 (gnus-article-edit-article
7732 `(lambda (no-highlight)
7733 (let ((mail-parse-charset ',gnus-newsgroup-charset)
7734 (mail-parse-ignored-charsets
7735 ',gnus-newsgroup-ignored-charsets))
7737 (gnus-summary-edit-article-done
7738 ,(or (mail-header-references gnus-current-headers) "")
7739 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
7741 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7743 (defun gnus-summary-edit-article-done (&optional references read-only buffer
7745 "Make edits to the current article permanent."
7747 ;; Replace the article.
7748 (let ((buf (current-buffer)))
7750 (insert-buffer-substring buf)
7751 (if (and (not read-only)
7752 (not (gnus-request-replace-article
7753 (cdr gnus-article-current) (car gnus-article-current)
7754 (current-buffer) t)))
7755 (error "Couldn't replace article")
7756 ;; Update the summary buffer.
7758 (equal (message-tokenize-header references " ")
7759 (message-tokenize-header
7760 (or (message-fetch-field "references") "") " ")))
7761 ;; We only have to update this line.
7764 (message-narrow-to-head)
7765 (let ((head (buffer-string))
7768 (insert (format "211 %d Article retrieved.\n"
7769 (cdr gnus-article-current)))
7772 (let ((nntp-server-buffer (current-buffer)))
7773 (setq header (car (gnus-get-newsgroup-headers
7775 (set-buffer gnus-summary-buffer)
7776 gnus-newsgroup-dependencies)
7779 (set-buffer gnus-summary-buffer)
7780 (gnus-data-set-header
7781 (gnus-data-find (cdr gnus-article-current))
7783 (gnus-summary-update-article-line
7784 (cdr gnus-article-current) header))))))
7786 (set-buffer (or buffer gnus-summary-buffer))
7787 (gnus-summary-update-article (cdr gnus-article-current)))
7788 ;; Prettify the article buffer again.
7789 (unless no-highlight
7791 (set-buffer gnus-article-buffer)
7792 ;;;!!! Fix this -- article should be rehighlighted.
7793 ;;;(gnus-run-hooks 'gnus-article-display-hook)
7794 (set-buffer gnus-original-article-buffer)
7795 (gnus-request-article
7796 (cdr gnus-article-current)
7797 (car gnus-article-current) (current-buffer))))
7798 ;; Prettify the summary buffer line.
7799 (when (gnus-visual-p 'summary-highlight 'highlight)
7800 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
7802 (defun gnus-summary-edit-wash (key)
7803 "Perform editing command KEY in the article buffer."
7807 (message "%s" (concat (this-command-keys) "- "))
7810 (gnus-summary-edit-article)
7811 (execute-kbd-macro (concat (this-command-keys) key))
7812 (gnus-article-edit-done))
7816 (defun gnus-summary-respool-query (&optional silent trace)
7817 "Query where the respool algorithm would put this article."
7819 (let (gnus-mark-article-hook)
7820 (gnus-summary-select-article)
7822 (set-buffer gnus-original-article-buffer)
7824 (message-narrow-to-head)
7825 (let ((groups (nnmail-article-group 'identity trace)))
7828 (message "This message would go to %s"
7829 (mapconcat 'car groups ", "))
7830 (message "This message would go to no groups"))
7833 (defun gnus-summary-respool-trace ()
7834 "Trace where the respool algorithm would put this article.
7835 Display a buffer showing all fancy splitting patterns which matched."
7837 (gnus-summary-respool-query nil t))
7839 ;; Summary marking commands.
7841 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
7842 "Mark articles which has the same subject as read, and then select the next.
7843 If UNMARK is positive, remove any kind of mark.
7844 If UNMARK is negative, tick articles."
7847 (setq unmark (prefix-numeric-value unmark)))
7849 (gnus-summary-mark-same-subject
7850 (gnus-summary-article-subject) unmark)))
7851 ;; Select next unread article. If auto-select-same mode, should
7852 ;; select the first unread article.
7853 (gnus-summary-next-article t (and gnus-auto-select-same
7854 (gnus-summary-article-subject)))
7855 (gnus-message 7 "%d article%s marked as %s"
7856 count (if (= count 1) " is" "s are")
7857 (if unmark "unread" "read"))))
7859 (defun gnus-summary-kill-same-subject (&optional unmark)
7860 "Mark articles which has the same subject as read.
7861 If UNMARK is positive, remove any kind of mark.
7862 If UNMARK is negative, tick articles."
7865 (setq unmark (prefix-numeric-value unmark)))
7867 (gnus-summary-mark-same-subject
7868 (gnus-summary-article-subject) unmark)))
7869 ;; If marked as read, go to next unread subject.
7871 ;; Go to next unread subject.
7872 (gnus-summary-next-subject 1 t))
7873 (gnus-message 7 "%d articles are marked as %s"
7874 count (if unmark "unread" "read"))))
7876 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7877 "Mark articles with same SUBJECT as read, and return marked number.
7878 If optional argument UNMARK is positive, remove any kinds of marks.
7879 If optional argument UNMARK is negative, mark articles as unread instead."
7883 ((null unmark) ; Mark as read.
7886 (gnus-summary-mark-article-as-read gnus-killed-mark)
7887 (gnus-summary-show-thread) t)
7888 (gnus-summary-find-subject subject))
7889 (setq count (1+ count))))
7890 ((> unmark 0) ; Tick.
7893 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
7894 (gnus-summary-show-thread) t)
7895 (gnus-summary-find-subject subject))
7896 (setq count (1+ count))))
7897 (t ; Mark as unread.
7900 (gnus-summary-mark-article-as-unread gnus-unread-mark)
7901 (gnus-summary-show-thread) t)
7902 (gnus-summary-find-subject subject))
7903 (setq count (1+ count)))))
7904 (gnus-set-mode-line 'summary)
7905 ;; Return the number of marked articles.
7908 (defun gnus-summary-mark-as-processable (n &optional unmark)
7909 "Set the process mark on the next N articles.
7910 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7911 the process mark instead. The difference between N and the actual
7912 number of articles marked is returned."
7914 (let ((backward (< n 0))
7919 (gnus-summary-remove-process-mark
7920 (gnus-summary-article-number))
7921 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7922 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7925 (gnus-message 7 "No more articles"))
7926 (gnus-summary-recenter)
7927 (gnus-summary-position-point)
7930 (defun gnus-summary-unmark-as-processable (n)
7931 "Remove the process mark from the next N articles.
7932 If N is negative, unmark backward instead. The difference between N and
7933 the actual number of articles unmarked is returned."
7935 (gnus-summary-mark-as-processable n t))
7937 (defun gnus-summary-unmark-all-processable ()
7938 "Remove the process mark from all articles."
7941 (while gnus-newsgroup-processable
7942 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7943 (gnus-summary-position-point))
7945 (defun gnus-summary-mark-as-expirable (n)
7946 "Mark N articles forward as expirable.
7947 If N is negative, mark backward instead. The difference between N and
7948 the actual number of articles marked is returned."
7950 (gnus-summary-mark-forward n gnus-expirable-mark))
7952 (defun gnus-summary-mark-article-as-replied (article)
7953 "Mark ARTICLE replied and update the summary line."
7954 (push article gnus-newsgroup-replied)
7955 (let ((buffer-read-only nil))
7956 (when (gnus-summary-goto-subject article nil t)
7957 (gnus-summary-update-secondary-mark article))))
7959 (defun gnus-summary-set-bookmark (article)
7960 "Set a bookmark in current article."
7961 (interactive (list (gnus-summary-article-number)))
7962 (when (or (not (get-buffer gnus-article-buffer))
7963 (not gnus-current-article)
7964 (not gnus-article-current)
7965 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7966 (error "No current article selected"))
7967 ;; Remove old bookmark, if one exists.
7968 (let ((old (assq article gnus-newsgroup-bookmarks)))
7970 (setq gnus-newsgroup-bookmarks
7971 (delq old gnus-newsgroup-bookmarks))))
7972 ;; Set the new bookmark, which is on the form
7973 ;; (article-number . line-number-in-body).
7977 (set-buffer gnus-article-buffer)
7981 (goto-char (point-min))
7982 (search-forward "\n\n" nil t)
7985 gnus-newsgroup-bookmarks)
7986 (gnus-message 6 "A bookmark has been added to the current article."))
7988 (defun gnus-summary-remove-bookmark (article)
7989 "Remove the bookmark from the current article."
7990 (interactive (list (gnus-summary-article-number)))
7991 ;; Remove old bookmark, if one exists.
7992 (let ((old (assq article gnus-newsgroup-bookmarks)))
7995 (setq gnus-newsgroup-bookmarks
7996 (delq old gnus-newsgroup-bookmarks))
7997 (gnus-message 6 "Removed bookmark."))
7998 (gnus-message 6 "No bookmark in current article."))))
8000 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8001 (defun gnus-summary-mark-as-dormant (n)
8002 "Mark N articles forward as dormant.
8003 If N is negative, mark backward instead. The difference between N and
8004 the actual number of articles marked is returned."
8006 (gnus-summary-mark-forward n gnus-dormant-mark))
8008 (defun gnus-summary-set-process-mark (article)
8009 "Set the process mark on ARTICLE and update the summary line."
8010 (setq gnus-newsgroup-processable
8012 (delq article gnus-newsgroup-processable)))
8013 (when (gnus-summary-goto-subject article)
8014 (gnus-summary-show-thread)
8015 (gnus-summary-goto-subject article)
8016 (gnus-summary-update-secondary-mark article)))
8018 (defun gnus-summary-remove-process-mark (article)
8019 "Remove the process mark from ARTICLE and update the summary line."
8020 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
8021 (when (gnus-summary-goto-subject article)
8022 (gnus-summary-show-thread)
8023 (gnus-summary-goto-subject article)
8024 (gnus-summary-update-secondary-mark article)))
8026 (defun gnus-summary-set-saved-mark (article)
8027 "Set the process mark on ARTICLE and update the summary line."
8028 (push article gnus-newsgroup-saved)
8029 (when (gnus-summary-goto-subject article)
8030 (gnus-summary-update-secondary-mark article)))
8032 (defun gnus-summary-mark-forward (n &optional mark no-expire)
8033 "Mark N articles as read forwards.
8034 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
8035 The difference between N and the actual number of articles marked is
8037 Iff NO-EXPIRE, auto-expiry will be inhibited."
8039 (gnus-summary-show-thread)
8040 (let ((backward (< n 0))
8041 (gnus-summary-goto-unread
8042 (and gnus-summary-goto-unread
8043 (not (eq gnus-summary-goto-unread 'never))
8044 (not (memq mark (list gnus-unread-mark
8045 gnus-ticked-mark gnus-dormant-mark)))))
8047 (mark (or mark gnus-del-mark)))
8049 (gnus-summary-mark-article nil mark no-expire)
8050 (zerop (gnus-summary-next-subject
8052 (and gnus-summary-goto-unread
8053 (not (eq gnus-summary-goto-unread 'never)))
8057 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
8058 (gnus-summary-recenter)
8059 (gnus-summary-position-point)
8060 (gnus-set-mode-line 'summary)
8063 (defun gnus-summary-mark-article-as-read (mark)
8064 "Mark the current article quickly as read with MARK."
8065 (let ((article (gnus-summary-article-number)))
8066 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8067 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8068 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8069 (push (cons article mark) gnus-newsgroup-reads)
8070 ;; Possibly remove from cache, if that is used.
8071 (when gnus-use-cache
8072 (gnus-cache-enter-remove-article article))
8073 ;; Allow the backend to change the mark.
8074 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8075 ;; Check for auto-expiry.
8076 (when (and gnus-newsgroup-auto-expire
8077 (memq mark gnus-auto-expirable-marks))
8078 (setq mark gnus-expirable-mark)
8079 ;; Let the backend know about the mark change.
8080 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8081 (push article gnus-newsgroup-expirable))
8082 ;; Set the mark in the buffer.
8083 (gnus-summary-update-mark mark 'unread)
8086 (defun gnus-summary-mark-article-as-unread (mark)
8087 "Mark the current article quickly as unread with MARK."
8088 (let* ((article (gnus-summary-article-number))
8089 (old-mark (gnus-summary-article-mark article)))
8090 ;; Allow the backend to change the mark.
8091 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8092 (if (eq mark old-mark)
8096 (gnus-error 1 "Can't mark negative article numbers")
8098 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8099 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8100 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
8101 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
8102 (cond ((= mark gnus-ticked-mark)
8103 (push article gnus-newsgroup-marked))
8104 ((= mark gnus-dormant-mark)
8105 (push article gnus-newsgroup-dormant))
8107 (push article gnus-newsgroup-unreads)))
8108 (gnus-pull article gnus-newsgroup-reads)
8110 ;; See whether the article is to be put in the cache.
8112 (vectorp (gnus-summary-article-header article))
8114 (gnus-cache-possibly-enter-article
8115 gnus-newsgroup-name article
8116 (= mark gnus-ticked-mark)
8117 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8120 (gnus-summary-update-mark mark 'unread)
8123 (defun gnus-summary-mark-article (&optional article mark no-expire)
8124 "Mark ARTICLE with MARK. MARK can be any character.
8125 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
8126 `??' (dormant) and `?E' (expirable).
8127 If MARK is nil, then the default character `?r' is used.
8128 If ARTICLE is nil, then the article on the current line will be
8130 Iff NO-EXPIRE, auto-expiry will be inhibited."
8131 ;; The mark might be a string.
8132 (when (stringp mark)
8133 (setq mark (aref mark 0)))
8134 ;; If no mark is given, then we check auto-expiring.
8136 (setq mark gnus-del-mark))
8137 (when (and (not no-expire)
8138 gnus-newsgroup-auto-expire
8139 (memq mark gnus-auto-expirable-marks))
8140 (setq mark gnus-expirable-mark))
8141 (let ((article (or article (gnus-summary-article-number)))
8142 (old-mark (gnus-summary-article-mark article)))
8143 ;; Allow the backend to change the mark.
8144 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8145 (if (eq mark old-mark)
8148 (error "No article on current line"))
8149 (if (not (if (or (= mark gnus-unread-mark)
8150 (= mark gnus-ticked-mark)
8151 (= mark gnus-dormant-mark))
8152 (gnus-mark-article-as-unread article mark)
8153 (gnus-mark-article-as-read article mark)))
8155 ;; See whether the article is to be put in the cache.
8157 (not (= mark gnus-canceled-mark))
8158 (vectorp (gnus-summary-article-header article))
8160 (gnus-cache-possibly-enter-article
8161 gnus-newsgroup-name article
8162 (= mark gnus-ticked-mark)
8163 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8165 (when (gnus-summary-goto-subject article nil t)
8166 (let ((buffer-read-only nil))
8167 (gnus-summary-show-thread)
8169 (gnus-summary-update-mark mark 'unread)
8172 (defun gnus-summary-update-secondary-mark (article)
8173 "Update the secondary (read, process, cache) mark."
8174 (gnus-summary-update-mark
8175 (cond ((memq article gnus-newsgroup-processable)
8177 ((memq article gnus-newsgroup-cached)
8179 ((memq article gnus-newsgroup-replied)
8181 ((memq article gnus-newsgroup-saved)
8183 (t gnus-unread-mark))
8185 (when (gnus-visual-p 'summary-highlight 'highlight)
8186 (gnus-run-hooks 'gnus-summary-update-hook))
8189 (defun gnus-summary-update-mark (mark type)
8190 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
8191 (buffer-read-only nil))
8192 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
8194 (when (looking-at "\r")
8196 (when (<= (+ forward (point)) (point-max))
8197 ;; Go to the right position on the line.
8198 (goto-char (+ forward (point)))
8199 ;; Replace the old mark with the new mark.
8200 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
8201 ;; Optionally update the marks by some user rule.
8202 (when (eq type 'unread)
8204 (gnus-data-find (gnus-summary-article-number)) mark)
8205 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
8207 (defun gnus-mark-article-as-read (article &optional mark)
8208 "Enter ARTICLE in the pertinent lists and remove it from others."
8209 ;; Make the article expirable.
8210 (let ((mark (or mark gnus-del-mark)))
8211 (if (= mark gnus-expirable-mark)
8212 (push article gnus-newsgroup-expirable)
8213 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
8214 ;; Remove from unread and marked lists.
8215 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8216 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8217 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8218 (push (cons article mark) gnus-newsgroup-reads)
8219 ;; Possibly remove from cache, if that is used.
8220 (when gnus-use-cache
8221 (gnus-cache-enter-remove-article article))
8224 (defun gnus-mark-article-as-unread (article &optional mark)
8225 "Enter ARTICLE in the pertinent lists and remove it from others."
8226 (let ((mark (or mark gnus-ticked-mark)))
8229 (gnus-error 1 "Can't mark negative article numbers")
8231 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
8232 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
8233 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
8234 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8236 ;; Unsuppress duplicates?
8237 (when gnus-suppress-duplicates
8238 (gnus-dup-unsuppress-article article))
8240 (cond ((= mark gnus-ticked-mark)
8241 (push article gnus-newsgroup-marked))
8242 ((= mark gnus-dormant-mark)
8243 (push article gnus-newsgroup-dormant))
8245 (push article gnus-newsgroup-unreads)))
8246 (gnus-pull article gnus-newsgroup-reads)
8249 (defalias 'gnus-summary-mark-as-unread-forward
8250 'gnus-summary-tick-article-forward)
8251 (make-obsolete 'gnus-summary-mark-as-unread-forward
8252 'gnus-summary-tick-article-forward)
8253 (defun gnus-summary-tick-article-forward (n)
8254 "Tick N articles forwards.
8255 If N is negative, tick backwards instead.
8256 The difference between N and the number of articles ticked is returned."
8258 (gnus-summary-mark-forward n gnus-ticked-mark))
8260 (defalias 'gnus-summary-mark-as-unread-backward
8261 'gnus-summary-tick-article-backward)
8262 (make-obsolete 'gnus-summary-mark-as-unread-backward
8263 'gnus-summary-tick-article-backward)
8264 (defun gnus-summary-tick-article-backward (n)
8265 "Tick N articles backwards.
8266 The difference between N and the number of articles ticked is returned."
8268 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
8270 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8271 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8272 (defun gnus-summary-tick-article (&optional article clear-mark)
8273 "Mark current article as unread.
8274 Optional 1st argument ARTICLE specifies article number to be marked as unread.
8275 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
8277 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
8280 (defun gnus-summary-mark-as-read-forward (n)
8281 "Mark N articles as read forwards.
8282 If N is negative, mark backwards instead.
8283 The difference between N and the actual number of articles marked is
8286 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
8288 (defun gnus-summary-mark-as-read-backward (n)
8289 "Mark the N articles as read backwards.
8290 The difference between N and the actual number of articles marked is
8293 (gnus-summary-mark-forward
8294 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
8296 (defun gnus-summary-mark-as-read (&optional article mark)
8297 "Mark current article as read.
8298 ARTICLE specifies the article to be marked as read.
8299 MARK specifies a string to be inserted at the beginning of the line."
8300 (gnus-summary-mark-article article mark))
8302 (defun gnus-summary-clear-mark-forward (n)
8303 "Clear marks from N articles forward.
8304 If N is negative, clear backward instead.
8305 The difference between N and the number of marks cleared is returned."
8307 (gnus-summary-mark-forward n gnus-unread-mark))
8309 (defun gnus-summary-clear-mark-backward (n)
8310 "Clear marks from N articles backward.
8311 The difference between N and the number of marks cleared is returned."
8313 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8315 (defun gnus-summary-mark-unread-as-read ()
8316 "Intended to be used by `gnus-summary-mark-article-hook'."
8317 (when (memq gnus-current-article gnus-newsgroup-unreads)
8318 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
8320 (defun gnus-summary-mark-read-and-unread-as-read ()
8321 "Intended to be used by `gnus-summary-mark-article-hook'."
8322 (let ((mark (gnus-summary-article-mark)))
8323 (when (or (gnus-unread-mark-p mark)
8324 (gnus-read-mark-p mark))
8325 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
8327 (defun gnus-summary-mark-region-as-read (point mark all)
8328 "Mark all unread articles between point and mark as read.
8329 If given a prefix, mark all articles between point and mark as read,
8330 even ticked and dormant ones."
8331 (interactive "r\nP")
8340 (memq (setq article (gnus-summary-article-number))
8341 gnus-newsgroup-unreads))
8342 (gnus-summary-mark-article article gnus-del-mark))
8344 (gnus-summary-find-next))))))
8346 (defun gnus-summary-mark-below (score mark)
8347 "Mark articles with score less than SCORE with MARK."
8348 (interactive "P\ncMark: ")
8349 (setq score (if score
8350 (prefix-numeric-value score)
8351 (or gnus-summary-default-score 0)))
8353 (set-buffer gnus-summary-buffer)
8354 (goto-char (point-min))
8357 (and (< (gnus-summary-article-score) score)
8358 (gnus-summary-mark-article nil mark))
8359 (gnus-summary-find-next)))))
8361 (defun gnus-summary-kill-below (&optional score)
8362 "Mark articles with score below SCORE as read."
8364 (gnus-summary-mark-below score gnus-killed-mark))
8366 (defun gnus-summary-clear-above (&optional score)
8367 "Clear all marks from articles with score above SCORE."
8369 (gnus-summary-mark-above score gnus-unread-mark))
8371 (defun gnus-summary-tick-above (&optional score)
8372 "Tick all articles with score above SCORE."
8374 (gnus-summary-mark-above score gnus-ticked-mark))
8376 (defun gnus-summary-mark-above (score mark)
8377 "Mark articles with score over SCORE with MARK."
8378 (interactive "P\ncMark: ")
8379 (setq score (if score
8380 (prefix-numeric-value score)
8381 (or gnus-summary-default-score 0)))
8383 (set-buffer gnus-summary-buffer)
8384 (goto-char (point-min))
8386 (when (> (gnus-summary-article-score) score)
8387 (gnus-summary-mark-article nil mark))
8389 (gnus-summary-find-next)))))
8391 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8392 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
8393 (defun gnus-summary-limit-include-expunged (&optional no-error)
8394 "Display all the hidden articles that were expunged for low scores."
8396 (let ((buffer-read-only nil))
8397 (let ((scored gnus-newsgroup-scored)
8400 (unless (gnus-summary-goto-subject (caar scored))
8401 (and (setq h (gnus-summary-article-header (caar scored)))
8402 (< (cdar scored) gnus-summary-expunge-below)
8404 (setq scored (cdr scored)))
8406 (when (not no-error)
8407 (error "No expunged articles hidden"))
8408 (goto-char (point-min))
8409 (gnus-summary-prepare-unthreaded (nreverse headers))
8410 (goto-char (point-min))
8411 (gnus-summary-position-point)
8414 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
8415 "Mark all unread articles in this newsgroup as read.
8416 If prefix argument ALL is non-nil, ticked and dormant articles will
8417 also be marked as read.
8418 If QUIETLY is non-nil, no questions will be asked.
8419 If TO-HERE is non-nil, it should be a point in the buffer. All
8420 articles before this point will be marked as read.
8421 Note that this function will only catch up the unread article
8422 in the current summary buffer limitation.
8423 The number of articles marked as read is returned."
8428 (not gnus-interactive-catchup) ;Without confirmation?
8432 "Mark absolutely all articles as read? "
8433 "Mark all unread articles as read? ")))
8435 (not gnus-newsgroup-adaptive)
8436 (not gnus-newsgroup-auto-expire)
8437 (not gnus-suppress-duplicates)
8438 (or (not gnus-use-cache)
8439 (eq gnus-use-cache 'passive)))
8442 (setq gnus-newsgroup-marked nil
8443 gnus-newsgroup-dormant nil))
8444 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8445 ;; We actually mark all articles as canceled, which we
8446 ;; have to do when using auto-expiry or adaptive scoring.
8447 (gnus-summary-show-all-threads)
8448 (when (gnus-summary-first-subject (not all) t)
8450 (if to-here (< (point) to-here) t)
8451 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8452 (gnus-summary-find-next (not all) nil nil t))))
8453 (gnus-set-mode-line 'summary))
8455 (gnus-summary-position-point)))
8457 (defun gnus-summary-catchup-to-here (&optional all)
8458 "Mark all unticked articles before the current one as read.
8459 If ALL is non-nil, also mark ticked and dormant articles as read."
8462 (gnus-save-hidden-threads
8463 (let ((beg (point)))
8464 ;; We check that there are unread articles.
8465 (when (or all (gnus-summary-find-prev))
8466 (gnus-summary-catchup all t beg)))))
8467 (gnus-summary-position-point))
8469 (defun gnus-summary-catchup-all (&optional quietly)
8470 "Mark all articles in this newsgroup as read."
8472 (gnus-summary-catchup t quietly))
8474 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8475 "Mark all unread articles in this group as read, then exit.
8476 If prefix argument ALL is non-nil, all articles are marked as read."
8478 (when (gnus-summary-catchup all quietly nil 'fast)
8479 ;; Select next newsgroup or exit.
8480 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
8481 (eq gnus-auto-select-next 'quietly))
8482 (gnus-summary-next-group nil)
8483 (gnus-summary-exit))))
8485 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8486 "Mark all articles in this newsgroup as read, and then exit."
8488 (gnus-summary-catchup-and-exit t quietly))
8490 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8491 "Mark all articles in this group as read and select the next group.
8492 If given a prefix, mark all articles, unread as well as ticked, as
8496 (gnus-summary-catchup all))
8497 (gnus-summary-next-group))
8499 ;; Thread-based commands.
8501 (defun gnus-summary-articles-in-thread (&optional article)
8502 "Return a list of all articles in the current thread.
8503 If ARTICLE is non-nil, return all articles in the thread that starts
8505 (let* ((article (or article (gnus-summary-article-number)))
8506 (data (gnus-data-find-list article))
8507 (top-level (gnus-data-level (car data)))
8509 (cond ((null gnus-thread-operation-ignore-subject)
8510 (gnus-simplify-subject-re
8511 (mail-header-subject (gnus-data-header (car data)))))
8512 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8513 (gnus-simplify-subject-fuzzy
8514 (mail-header-subject (gnus-data-header (car data)))))
8516 (end-point (save-excursion
8517 (if (gnus-summary-go-to-next-thread)
8518 (point) (point-max))))
8521 (< (gnus-data-pos (car data)) end-point))
8522 (when (or (not top-subject)
8523 (string= top-subject
8524 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8525 (gnus-simplify-subject-fuzzy
8526 (mail-header-subject
8527 (gnus-data-header (car data))))
8528 (gnus-simplify-subject-re
8529 (mail-header-subject
8530 (gnus-data-header (car data)))))))
8531 (push (gnus-data-number (car data)) articles))
8532 (unless (and (setq data (cdr data))
8533 (> (gnus-data-level (car data)) top-level))
8535 ;; Return the list of articles.
8536 (nreverse articles)))
8538 (defun gnus-summary-rethread-current ()
8539 "Rethread the thread the current article is part of."
8541 (let* ((gnus-show-threads t)
8542 (article (gnus-summary-article-number))
8543 (id (mail-header-id (gnus-summary-article-header)))
8544 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8546 (error "No article on the current line"))
8547 (gnus-rebuild-thread id)
8548 (gnus-summary-goto-subject article)))
8550 (defun gnus-summary-reparent-thread ()
8551 "Make the current article child of the marked (or previous) article.
8553 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8554 is non-nil or the Subject: of both articles are the same."
8556 (unless (not (gnus-group-read-only-p))
8557 (error "The current newsgroup does not support article editing"))
8558 (unless (<= (length gnus-newsgroup-processable) 1)
8559 (error "No more than one article may be marked"))
8560 (save-window-excursion
8561 (let ((gnus-article-buffer " *reparent*")
8562 (current-article (gnus-summary-article-number))
8563 ;; First grab the marked article, otherwise one line up.
8564 (parent-article (if (not (null gnus-newsgroup-processable))
8565 (car gnus-newsgroup-processable)
8567 (if (eq (forward-line -1) 0)
8568 (gnus-summary-article-number)
8569 (error "Beginning of summary buffer"))))))
8570 (unless (not (eq current-article parent-article))
8571 (error "An article may not be self-referential"))
8572 (let ((message-id (mail-header-id
8573 (gnus-summary-article-header parent-article))))
8574 (unless (and message-id (not (equal message-id "")))
8575 (error "No message-id in desired parent"))
8576 (gnus-with-article current-article
8577 (goto-char (point-min))
8578 (if (re-search-forward "^References: " nil t)
8580 (re-search-forward "^[^ \t]" nil t)
8583 (insert " " message-id))
8584 (insert "References: " message-id "\n")))
8585 (set-buffer gnus-summary-buffer)
8586 (gnus-summary-unmark-all-processable)
8587 (gnus-summary-update-article current-article)
8588 (gnus-summary-rethread-current)
8589 (gnus-message 3 "Article %d is now the child of article %d"
8590 current-article parent-article)))))
8592 (defun gnus-summary-toggle-threads (&optional arg)
8593 "Toggle showing conversation threads.
8594 If ARG is positive number, turn showing conversation threads on."
8596 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8597 (setq gnus-show-threads
8598 (if (null arg) (not gnus-show-threads)
8599 (> (prefix-numeric-value arg) 0)))
8600 (gnus-summary-prepare)
8601 (gnus-summary-goto-subject current)
8602 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8603 (gnus-summary-position-point)))
8605 (defun gnus-summary-show-all-threads ()
8609 (let ((buffer-read-only nil))
8610 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8611 (gnus-summary-position-point))
8613 (defun gnus-summary-show-thread ()
8614 "Show thread subtrees.
8615 Returns nil if no thread was there to be shown."
8617 (let ((buffer-read-only nil)
8619 ;; first goto end then to beg, to have point at beg after let
8620 (end (progn (end-of-line) (point)))
8621 (beg (progn (beginning-of-line) (point))))
8623 ;; Any hidden lines here?
8624 (search-forward "\r" end t)
8625 (subst-char-in-region beg end ?\^M ?\n t)
8627 (gnus-summary-position-point))))
8629 (defun gnus-summary-hide-all-threads ()
8630 "Hide all thread subtrees."
8633 (goto-char (point-min))
8634 (gnus-summary-hide-thread)
8635 (while (zerop (gnus-summary-next-thread 1 t))
8636 (gnus-summary-hide-thread)))
8637 (gnus-summary-position-point))
8639 (defun gnus-summary-hide-thread ()
8640 "Hide thread subtrees.
8641 Returns nil if no threads were there to be hidden."
8643 (let ((buffer-read-only nil)
8645 (article (gnus-summary-article-number)))
8647 ;; Go forward until either the buffer ends or the subthread
8649 (when (and (not (eobp))
8650 (or (zerop (gnus-summary-next-thread 1 t))
8651 (goto-char (point-max))))
8653 (if (and (> (point) start)
8654 (search-backward "\n" start t))
8656 (subst-char-in-region start (point) ?\n ?\^M)
8657 (gnus-summary-goto-subject article))
8661 (defun gnus-summary-go-to-next-thread (&optional previous)
8662 "Go to the same level (or less) next thread.
8663 If PREVIOUS is non-nil, go to previous thread instead.
8664 Return the article number moved to, or nil if moving was impossible."
8665 (let ((level (gnus-summary-thread-level))
8666 (way (if previous -1 1))
8669 (while (and (not (eobp))
8670 (< level (gnus-summary-thread-level)))
8678 (gnus-summary-article-number)
8681 (defun gnus-summary-next-thread (n &optional silent)
8682 "Go to the same level next N'th thread.
8683 If N is negative, search backward instead.
8684 Returns the difference between N and the number of skips actually
8687 If SILENT, don't output messages."
8689 (let ((backward (< n 0))
8692 (gnus-summary-go-to-next-thread backward))
8695 (gnus-summary-position-point))
8696 (when (and (not silent) (/= 0 n))
8697 (gnus-message 7 "No more threads"))
8700 (defun gnus-summary-prev-thread (n)
8701 "Go to the same level previous N'th thread.
8702 Returns the difference between N and the number of skips actually
8705 (gnus-summary-next-thread (- n)))
8707 (defun gnus-summary-go-down-thread ()
8708 "Go down one level in the current thread."
8709 (let ((children (gnus-summary-article-children)))
8711 (gnus-summary-goto-subject (car children)))))
8713 (defun gnus-summary-go-up-thread ()
8714 "Go up one level in the current thread."
8715 (let ((parent (gnus-summary-article-parent)))
8717 (gnus-summary-goto-subject parent))))
8719 (defun gnus-summary-down-thread (n)
8720 "Go down thread N steps.
8721 If N is negative, go up instead.
8722 Returns the difference between N and how many steps down that were
8728 (if up (gnus-summary-go-up-thread)
8729 (gnus-summary-go-down-thread)))
8731 (gnus-summary-position-point)
8733 (gnus-message 7 "Can't go further"))
8736 (defun gnus-summary-up-thread (n)
8737 "Go up thread N steps.
8738 If N is negative, go up instead.
8739 Returns the difference between N and how many steps down that were
8742 (gnus-summary-down-thread (- n)))
8744 (defun gnus-summary-top-thread ()
8745 "Go to the top of the thread."
8747 (while (gnus-summary-go-up-thread))
8748 (gnus-summary-article-number))
8750 (defun gnus-summary-kill-thread (&optional unmark)
8751 "Mark articles under current thread as read.
8752 If the prefix argument is positive, remove any kinds of marks.
8753 If the prefix argument is negative, tick articles instead."
8756 (setq unmark (prefix-numeric-value unmark)))
8757 (let ((articles (gnus-summary-articles-in-thread)))
8759 ;; Expand the thread.
8760 (gnus-summary-show-thread)
8761 ;; Mark all the articles.
8763 (gnus-summary-goto-subject (car articles))
8764 (cond ((null unmark)
8765 (gnus-summary-mark-article-as-read gnus-killed-mark))
8767 (gnus-summary-mark-article-as-unread gnus-unread-mark))
8769 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
8770 (setq articles (cdr articles))))
8771 ;; Hide killed subtrees.
8773 gnus-thread-hide-killed
8774 (gnus-summary-hide-thread))
8775 ;; If marked as read, go to next unread subject.
8777 ;; Go to next unread subject.
8778 (gnus-summary-next-subject 1 t)))
8779 (gnus-set-mode-line 'summary))
8781 ;; Summary sorting commands
8783 (defun gnus-summary-sort-by-number (&optional reverse)
8784 "Sort the summary buffer by article number.
8785 Argument REVERSE means reverse order."
8787 (gnus-summary-sort 'number reverse))
8789 (defun gnus-summary-sort-by-author (&optional reverse)
8790 "Sort the summary buffer by author name alphabetically.
8791 If case-fold-search is non-nil, case of letters is ignored.
8792 Argument REVERSE means reverse order."
8794 (gnus-summary-sort 'author reverse))
8796 (defun gnus-summary-sort-by-subject (&optional reverse)
8797 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8798 If case-fold-search is non-nil, case of letters is ignored.
8799 Argument REVERSE means reverse order."
8801 (gnus-summary-sort 'subject reverse))
8803 (defun gnus-summary-sort-by-date (&optional reverse)
8804 "Sort the summary buffer by date.
8805 Argument REVERSE means reverse order."
8807 (gnus-summary-sort 'date reverse))
8809 (defun gnus-summary-sort-by-score (&optional reverse)
8810 "Sort the summary buffer by score.
8811 Argument REVERSE means reverse order."
8813 (gnus-summary-sort 'score reverse))
8815 (defun gnus-summary-sort-by-lines (&optional reverse)
8816 "Sort the summary buffer by the number of lines.
8817 Argument REVERSE means reverse order."
8819 (gnus-summary-sort 'lines reverse))
8821 (defun gnus-summary-sort-by-chars (&optional reverse)
8822 "Sort the summary buffer by article length.
8823 Argument REVERSE means reverse order."
8825 (gnus-summary-sort 'chars reverse))
8827 (defun gnus-summary-sort (predicate reverse)
8828 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
8829 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
8830 (article (intern (format "gnus-article-sort-by-%s" predicate)))
8831 (gnus-thread-sort-functions
8836 (gnus-article-sort-functions
8842 (gnus-summary-prepare-hook nil))
8843 ;; We do the sorting by regenerating the threads.
8844 (gnus-summary-prepare)
8845 ;; Hide subthreads if needed.
8846 (when (and gnus-show-threads gnus-thread-hide-subtree)
8847 (gnus-summary-hide-all-threads))))
8849 ;; Summary saving commands.
8851 (defun gnus-summary-save-article (&optional n not-saved)
8852 "Save the current article using the default saver function.
8853 If N is a positive number, save the N next articles.
8854 If N is a negative number, save the N previous articles.
8855 If N is nil and any articles have been marked with the process mark,
8856 save those articles instead.
8857 The variable `gnus-default-article-saver' specifies the saver function."
8859 (let* ((articles (gnus-summary-work-articles n))
8860 (save-buffer (save-excursion
8861 (nnheader-set-temp-buffer " *Gnus Save*")))
8862 (num (length articles))
8864 (dolist (article articles)
8865 (setq header (gnus-summary-article-header article))
8866 (if (not (vectorp header))
8867 ;; This is a pseudo-article.
8868 (if (assq 'name header)
8869 (gnus-copy-file (cdr (assq 'name header)))
8870 (gnus-message 1 "Article %d is unsaveable" article))
8871 ;; This is a real article.
8872 (save-window-excursion
8873 (gnus-summary-select-article t nil nil article))
8875 (set-buffer save-buffer)
8877 (insert-buffer-substring gnus-original-article-buffer))
8878 (setq file (gnus-article-save save-buffer file num))
8879 (gnus-summary-remove-process-mark article)
8881 (gnus-summary-set-saved-mark article))))
8882 (gnus-kill-buffer save-buffer)
8883 (gnus-summary-position-point)
8884 (gnus-set-mode-line 'summary)
8887 (defun gnus-summary-pipe-output (&optional arg)
8888 "Pipe the current article to a subprocess.
8889 If N is a positive number, pipe the N next articles.
8890 If N is a negative number, pipe the N previous articles.
8891 If N is nil and any articles have been marked with the process mark,
8892 pipe those articles instead."
8894 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8895 (gnus-summary-save-article arg t))
8896 (gnus-configure-windows 'pipe))
8898 (defun gnus-summary-save-article-mail (&optional arg)
8899 "Append the current article to an mail file.
8900 If N is a positive number, save the N next articles.
8901 If N is a negative number, save the N previous articles.
8902 If N is nil and any articles have been marked with the process mark,
8903 save those articles instead."
8905 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8906 (gnus-summary-save-article arg)))
8908 (defun gnus-summary-save-article-rmail (&optional arg)
8909 "Append the current article to an rmail file.
8910 If N is a positive number, save the N next articles.
8911 If N is a negative number, save the N previous articles.
8912 If N is nil and any articles have been marked with the process mark,
8913 save those articles instead."
8915 (let ((gnus-default-article-saver 'rmail-output-to-rmail-file))
8916 (gnus-summary-save-article arg)))
8918 (defun gnus-summary-save-article-file (&optional arg)
8919 "Append the current article to a file.
8920 If N is a positive number, save the N next articles.
8921 If N is a negative number, save the N previous articles.
8922 If N is nil and any articles have been marked with the process mark,
8923 save those articles instead."
8925 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8926 (gnus-summary-save-article arg)))
8928 (defun gnus-summary-write-article-file (&optional arg)
8929 "Write the current article to a file, deleting the previous file.
8930 If N is a positive number, save the N next articles.
8931 If N is a negative number, save the N previous articles.
8932 If N is nil and any articles have been marked with the process mark,
8933 save those articles instead."
8935 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
8936 (gnus-summary-save-article arg)))
8938 (defun gnus-summary-save-article-body-file (&optional arg)
8939 "Append the current article body to a file.
8940 If N is a positive number, save the N next articles.
8941 If N is a negative number, save the N previous articles.
8942 If N is nil and any articles have been marked with the process mark,
8943 save those articles instead."
8945 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
8946 (gnus-summary-save-article arg)))
8948 (defun gnus-summary-pipe-message (program)
8949 "Pipe the current article through PROGRAM."
8950 (interactive "sProgram: ")
8951 (gnus-summary-select-article)
8952 (let ((mail-header-separator ""))
8953 (gnus-eval-in-buffer-window gnus-article-buffer
8956 (let ((start (window-start))
8958 (message-pipe-buffer-body program)
8959 (set-window-start (get-buffer-window (current-buffer)) start))))))
8961 (defun gnus-get-split-value (methods)
8962 "Return a value based on the split METHODS."
8963 (let (split-name method result match)
8966 (set-buffer gnus-original-article-buffer)
8968 (nnheader-narrow-to-headers)
8970 (goto-char (point-min))
8971 (setq method (pop methods))
8972 (setq match (car method))
8975 ;; Regular expression.
8977 (re-search-forward match nil t)))
8978 ((gnus-functionp match)
8982 (setq result (funcall match gnus-newsgroup-name))))
8987 (setq result (eval match)))))
8988 (setq split-name (append (cdr method) split-name))
8989 (cond ((stringp result)
8990 (push (expand-file-name
8991 result gnus-article-save-directory)
8994 (setq split-name (append result split-name)))))))))
8995 (nreverse split-name)))
8997 (defun gnus-valid-move-group-p (group)
9000 (symbol-value group)
9001 (gnus-get-function (gnus-find-method-for-group
9002 (symbol-name group)) 'request-accept-article t)))
9004 (defun gnus-read-move-group-name (prompt default articles prefix)
9005 "Read a group name."
9006 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
9007 (minibuffer-confirm-incomplete nil) ; XEmacs
9011 (if (> (length articles) 1)
9012 (format "these %d articles" (length articles))
9017 (gnus-completing-read default prom
9019 'gnus-valid-move-group-p
9021 'gnus-group-history))
9022 ((= 1 (length split-name))
9023 (gnus-completing-read (car split-name) prom
9025 'gnus-valid-move-group-p
9027 'gnus-group-history))
9029 (gnus-completing-read nil prom
9030 (mapcar (lambda (el) (list el))
9031 (nreverse split-name))
9033 'gnus-group-history)))))
9035 (if (or (string= to-newsgroup "")
9036 (string= to-newsgroup prefix))
9037 (setq to-newsgroup default))
9038 (unless to-newsgroup
9039 (error "No group name entered"))
9040 (or (gnus-active to-newsgroup)
9041 (gnus-activate-group to-newsgroup nil nil
9042 (gnus-group-method to-newsgroup))
9043 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
9045 (or (and (gnus-request-create-group
9046 to-newsgroup (gnus-group-method to-newsgroup))
9047 (gnus-activate-group
9048 to-newsgroup nil nil
9049 (gnus-group-method to-newsgroup))
9050 (gnus-subscribe-group to-newsgroup))
9051 (error "Couldn't create group %s" to-newsgroup)))
9052 (error "No such group: %s" to-newsgroup)))
9055 (defun gnus-summary-save-parts (type dir n &optional reverse)
9056 "Save parts matching TYPE to DIR.
9057 If REVERSE, save parts that do not match TYPE."
9059 (list (read-string "Save parts of type: " "image/.*")
9060 (read-file-name "Save to directory: " nil nil t)
9061 current-prefix-arg))
9062 (gnus-summary-iterate n
9063 (let ((gnus-display-mime-function nil)
9064 (gnus-inhibit-treatment t))
9065 (gnus-summary-select-article))
9067 (set-buffer gnus-article-buffer)
9068 (let ((handles (or (mm-dissect-buffer) (mm-uu-dissect))))
9070 (gnus-summary-save-parts-1 type dir handles reverse)
9071 (mm-destroy-parts handles))))))
9073 (defun gnus-summary-save-parts-1 (type dir handle reverse)
9074 (if (stringp (car handle))
9075 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
9078 (not (string-match type (mm-handle-media-type handle)))
9079 (string-match type (mm-handle-media-type handle)))
9080 (let ((file (expand-file-name
9081 (file-name-nondirectory
9083 (mail-content-type-get
9084 (mm-handle-disposition handle) 'filename)
9085 (concat gnus-newsgroup-name "." gnus-current-article)))
9087 (unless (file-exists-p file)
9088 (mm-save-part-to-file handle file))))))
9090 ;; Summary extract commands
9092 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
9093 (let ((buffer-read-only nil)
9094 (article (gnus-summary-article-number))
9096 (unless (gnus-summary-goto-subject article)
9097 (error "No such article: %d" article))
9098 (gnus-summary-position-point)
9099 ;; If all commands are to be bunched up on one line, we collect
9101 (unless gnus-view-pseudos-separately
9102 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
9105 (setq action (cdr (assq 'action (car ps))))
9106 (setq files (list (cdr (assq 'name (car ps)))))
9107 (while (and ps (cdr ps)
9108 (string= (or action "1")
9109 (or (cdr (assq 'action (cadr ps))) "2")))
9110 (push (cdr (assq 'name (cadr ps))) files)
9111 (setcdr ps (cddr ps)))
9113 (when (not (string-match "%s" action))
9116 (when (assq 'execute (car ps))
9117 (setcdr (assq 'execute (car ps))
9118 (funcall (if (string-match "%s" action)
9127 (setq ps (cdr ps)))))
9128 (if (and gnus-view-pseudos (not not-view))
9130 (when (assq 'execute (car pslist))
9131 (gnus-execute-command (cdr (assq 'execute (car pslist)))
9132 (eq gnus-view-pseudos 'not-confirm)))
9133 (setq pslist (cdr pslist)))
9136 (setq after-article (or (cdr (assq 'article (car pslist)))
9137 (gnus-summary-article-number)))
9138 (gnus-summary-goto-subject after-article)
9141 (insert " " (file-name-nondirectory
9142 (cdr (assq 'name (car pslist))))
9143 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
9145 (forward-line -1) ; back to `b'
9146 (gnus-add-text-properties
9147 b (1- e) (list 'gnus-number gnus-reffed-article-number
9148 gnus-mouse-face-prop gnus-mouse-face))
9150 after-article gnus-reffed-article-number
9151 gnus-unread-mark b (car pslist) 0 (- e b))
9152 (push gnus-reffed-article-number gnus-newsgroup-unreads)
9153 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
9154 (setq pslist (cdr pslist)))))))
9156 (defun gnus-pseudos< (p1 p2)
9157 (let ((c1 (cdr (assq 'action p1)))
9158 (c2 (cdr (assq 'action p2))))
9159 (and c1 c2 (string< c1 c2))))
9161 (defun gnus-request-pseudo-article (props)
9162 (cond ((assq 'execute props)
9163 (gnus-execute-command (cdr (assq 'execute props)))))
9164 (let ((gnus-current-article (gnus-summary-article-number)))
9165 (gnus-run-hooks 'gnus-mark-article-hook)))
9167 (defun gnus-execute-command (command &optional automatic)
9169 (gnus-article-setup-buffer)
9170 (set-buffer gnus-article-buffer)
9171 (setq buffer-read-only nil)
9172 (let ((command (if automatic command
9173 (read-string "Command: " (cons command 0)))))
9175 (insert "$ " command "\n\n")
9176 (if gnus-view-pseudo-asynchronously
9177 (start-process "gnus-execute" (current-buffer) shell-file-name
9178 shell-command-switch command)
9179 (call-process shell-file-name nil t nil
9180 shell-command-switch command)))))
9182 ;; Summary kill commands.
9184 (defun gnus-summary-edit-global-kill (article)
9185 "Edit the \"global\" kill file."
9186 (interactive (list (gnus-summary-article-number)))
9187 (gnus-group-edit-global-kill article))
9189 (defun gnus-summary-edit-local-kill ()
9190 "Edit a local kill file applied to the current newsgroup."
9192 (setq gnus-current-headers (gnus-summary-article-header))
9193 (gnus-group-edit-local-kill
9194 (gnus-summary-article-number) gnus-newsgroup-name))
9198 (defun gnus-read-header (id &optional header)
9199 "Read the headers of article ID and enter them into the Gnus system."
9200 (let ((group gnus-newsgroup-name)
9201 (gnus-override-method
9203 gnus-override-method
9204 (and (gnus-news-group-p gnus-newsgroup-name)
9205 (car (gnus-refer-article-methods)))))
9207 ;; First we check to see whether the header in question is already
9210 ;; This is a Message-ID.
9211 (setq header (or header (gnus-id-to-header id)))
9212 ;; This is an article number.
9213 (setq header (or header (gnus-summary-article-header id))))
9215 (not (gnus-summary-article-sparse-p (mail-header-number header))))
9216 ;; We have found the header.
9218 ;; If this is a sparse article, we have to nix out its
9219 ;; previous entry in the thread hashtb.
9221 (gnus-summary-article-sparse-p (mail-header-number header)))
9222 (let* ((parent (gnus-parent-id (mail-header-references header)))
9223 (thread (and parent (gnus-id-to-thread parent))))
9225 (delq (assq header thread) thread))))
9226 ;; We have to really fetch the header to this article.
9228 (set-buffer nntp-server-buffer)
9229 (when (setq where (gnus-request-head id group))
9230 (nnheader-fold-continuation-lines)
9231 (goto-char (point-max))
9233 (goto-char (point-min))
9237 ((cdr where) (cdr where))
9238 (header (mail-header-number header))
9239 (t gnus-reffed-article-number))
9241 (insert " Article retrieved.\n"))
9243 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
9244 () ; Malformed head.
9245 (unless (gnus-summary-article-sparse-p (mail-header-number header))
9246 (when (and (stringp id)
9247 (not (string= (gnus-group-real-name group)
9249 ;; If we fetched by Message-ID and the article came
9250 ;; from a different group, we fudge some bogus article
9251 ;; numbers for this article.
9252 (mail-header-set-number header gnus-reffed-article-number))
9254 (set-buffer gnus-summary-buffer)
9255 (decf gnus-reffed-article-number)
9256 (gnus-remove-header (mail-header-number header))
9257 (push header gnus-newsgroup-headers)
9258 (setq gnus-current-headers header)
9259 (push (mail-header-number header) gnus-newsgroup-limit)))
9262 (defun gnus-remove-header (number)
9263 "Remove header NUMBER from `gnus-newsgroup-headers'."
9264 (if (and gnus-newsgroup-headers
9265 (= number (mail-header-number (car gnus-newsgroup-headers))))
9266 (pop gnus-newsgroup-headers)
9267 (let ((headers gnus-newsgroup-headers))
9268 (while (and (cdr headers)
9269 (not (= number (mail-header-number (cadr headers)))))
9272 (setcdr headers (cddr headers))))))
9275 ;;; summary highlights
9278 (defun gnus-highlight-selected-summary ()
9279 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
9280 ;; Highlight selected article in summary buffer
9281 (when gnus-summary-selected-face
9283 (let* ((beg (progn (beginning-of-line) (point)))
9284 (end (progn (end-of-line) (point)))
9285 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
9286 (from (if (get-text-property beg gnus-mouse-face-prop)
9288 (or (next-single-property-change
9289 beg gnus-mouse-face-prop nil end)
9294 (or (next-single-property-change
9295 from gnus-mouse-face-prop nil end)
9297 ;; If no mouse-face prop on line we will have to = from = end,
9298 ;; so we highlight the entire line instead.
9299 (when (= (+ to 2) from)
9302 (if gnus-newsgroup-selected-overlay
9303 ;; Move old overlay.
9305 gnus-newsgroup-selected-overlay from to (current-buffer))
9306 ;; Create new overlay.
9308 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
9309 'face gnus-summary-selected-face))))))
9311 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
9312 (defun gnus-summary-highlight-line ()
9313 "Highlight current line according to `gnus-summary-highlight'."
9314 (let* ((list gnus-summary-highlight)
9316 (end (progn (end-of-line) (point)))
9317 ;; now find out where the line starts and leave point there.
9318 (beg (progn (beginning-of-line) (point)))
9319 (article (gnus-summary-article-number))
9320 (score (or (cdr (assq (or article gnus-current-article)
9321 gnus-newsgroup-scored))
9322 gnus-summary-default-score 0))
9323 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
9324 (inhibit-read-only t))
9325 ;; Eval the cars of the lists until we find a match.
9326 (let ((default gnus-summary-default-score))
9328 (not (eval (caar list))))
9329 (setq list (cdr list))))
9330 (let ((face (cdar list)))
9331 (unless (eq face (get-text-property beg 'face))
9332 (gnus-put-text-property-excluding-characters-with-faces
9334 (setq face (if (boundp face) (symbol-value face) face)))
9335 (when gnus-summary-highlight-line-function
9336 (funcall gnus-summary-highlight-line-function article face))))
9339 (defun gnus-update-read-articles (group unread &optional compute)
9340 "Update the list of read articles in GROUP."
9341 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
9342 (entry (gnus-gethash group gnus-newsrc-hashtb))
9343 (info (nth 2 entry))
9345 (unread (sort (copy-sequence unread) '<))
9347 (if (or (not info) (not active))
9348 ;; There is no info on this group if it was, in fact,
9349 ;; killed. Gnus stores no information on killed groups, so
9350 ;; there's nothing to be done.
9351 ;; One could store the information somewhere temporarily,
9352 ;; perhaps... Hmmm...
9354 ;; Remove any negative articles numbers.
9355 (while (and unread (< (car unread) 0))
9356 (setq unread (cdr unread)))
9357 ;; Remove any expired article numbers
9358 (while (and unread (< (car unread) (car active)))
9359 (setq unread (cdr unread)))
9360 ;; Compute the ranges of read articles by looking at the list of
9363 (when (/= (car unread) prev)
9364 (push (if (= prev (1- (car unread))) prev
9365 (cons prev (1- (car unread))))
9367 (setq prev (1+ (car unread)))
9368 (setq unread (cdr unread)))
9369 (when (<= prev (cdr active))
9370 (push (cons prev (cdr active)) read))
9371 (setq read (if (> (length read) 1) (nreverse read) read))
9375 (set-buffer gnus-group-buffer)
9378 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
9379 (gnus-info-set-read ',info ',(gnus-info-read info))
9380 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
9381 (gnus-group-update-group ,group t))))
9382 ;; Propagate the read marks to the backend.
9383 (if (gnus-check-backend-function 'request-set-mark group)
9384 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
9385 (add (gnus-remove-from-range read (gnus-info-read info))))
9387 (unless (gnus-check-group group)
9388 (error "Can't open server for %s" group))
9389 (gnus-request-set-mark
9390 group (delq nil (list (if add (list add 'add '(read)))
9391 (if del (list del 'del '(read)))))))))
9392 ;; Enter this list into the group info.
9393 (gnus-info-set-read info read)
9394 ;; Set the number of unread articles in gnus-newsrc-hashtb.
9395 (gnus-get-unread-articles-in-group info (gnus-active group))
9398 (defun gnus-offer-save-summaries ()
9399 "Offer to save all active summary buffers."
9401 (let ((buflist (buffer-list))
9403 ;; Go through all buffers and find all summaries.
9405 (and (setq bufname (buffer-name (car buflist)))
9406 (string-match "Summary" bufname)
9408 (set-buffer bufname)
9409 ;; We check that this is, indeed, a summary buffer.
9410 (and (eq major-mode 'gnus-summary-mode)
9411 ;; Also make sure this isn't bogus.
9412 gnus-newsgroup-prepared
9413 ;; Also make sure that this isn't a dead summary buffer.
9414 (not gnus-dead-summary-mode)))
9415 (push bufname buffers))
9416 (setq buflist (cdr buflist)))
9417 ;; Go through all these summary buffers and offer to save them.
9420 "Update summary buffer %s? "
9422 (switch-to-buffer buf)
9423 (gnus-summary-exit))
9426 (defun gnus-summary-setup-default-charset ()
9427 "Setup newsgroup default charset."
9428 (if (equal gnus-newsgroup-name "nndraft:drafts")
9429 (setq gnus-newsgroup-charset nil)
9430 (let* ((name (and gnus-newsgroup-name
9431 (gnus-group-real-name gnus-newsgroup-name)))
9433 (or gnus-newsgroup-ephemeral-ignored-charsets
9435 (and gnus-newsgroup-name
9436 (or (gnus-group-find-parameter gnus-newsgroup-name
9437 'ignored-charsets t)
9438 (let ((alist gnus-group-ignored-charsets-alist)
9439 elem (charsets nil))
9440 (while (setq elem (pop alist))
9442 (string-match (car elem) name))
9444 charsets (cdr elem))))
9446 gnus-newsgroup-ignored-charsets))))
9447 (setq gnus-newsgroup-charset
9448 (or gnus-newsgroup-ephemeral-charset
9449 (and gnus-newsgroup-name
9450 (or (gnus-group-find-parameter gnus-newsgroup-name 'charset)
9451 (let ((alist gnus-group-charset-alist)
9453 (while (setq elem (pop alist))
9455 (string-match (car elem) name))
9457 charset (cadr elem))))
9459 gnus-default-charset))
9460 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
9461 ignored-charsets))))
9467 (defun gnus-summary-display-buttonized (&optional show-all-parts)
9468 "Display the current article buffer fully MIME-buttonized.
9469 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
9470 treated as multipart/mixed."
9473 (let ((gnus-unbuttonized-mime-types nil)
9474 (gnus-mime-display-multipart-as-mixed show-all-parts))
9475 (gnus-summary-show-article)))
9477 (defun gnus-summary-repair-multipart (article)
9478 "Add a Content-Type header to a multipart article without one."
9479 (interactive (list (gnus-summary-article-number)))
9480 (gnus-with-article article
9481 (message-narrow-to-head)
9482 (goto-char (point-max))
9484 (when (search-forward "\n--" nil t)
9485 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
9486 (message-narrow-to-head)
9487 (message-remove-header "Mime-Version")
9488 (message-remove-header "Content-Type")
9489 (goto-char (point-max))
9490 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
9492 (insert "Mime-Version: 1.0\n")
9494 (let (gnus-mark-article-hook)
9495 (gnus-summary-select-article t t nil article)))
9497 (defun gnus-summary-toggle-display-buttonized ()
9498 "Toggle the buttonizing of the article buffer."
9501 (if (setq gnus-inhibit-mime-unbuttonizing
9502 (not gnus-inhibit-mime-unbuttonizing))
9503 (let ((gnus-unbuttonized-mime-types nil))
9504 (gnus-summary-show-article))
9505 (gnus-summary-show-article)))
9511 (defmacro gnus-with-article (article &rest forms)
9512 "Select ARTICLE and perform FORMS in the original article buffer.
9513 Then replace the article with the result."
9515 ;; We don't want the article to be marked as read.
9516 (let (gnus-mark-article-hook)
9517 (gnus-summary-select-article t t nil ,article))
9518 (set-buffer gnus-original-article-buffer)
9520 (if (not (gnus-check-backend-function
9521 'request-replace-article (car gnus-article-current)))
9522 (gnus-message 5 "Read-only group; not replacing")
9523 (unless (gnus-request-replace-article
9524 ,article (car gnus-article-current)
9526 (error "Couldn't replace article")))
9527 ;; The cache and backlog have to be flushed somewhat.
9528 (when gnus-keep-backlog
9529 (gnus-backlog-remove-article
9530 (car gnus-article-current) (cdr gnus-article-current)))
9531 (when gnus-use-cache
9532 (gnus-cache-update-article
9533 (car gnus-article-current) (cdr gnus-article-current)))))
9535 (put 'gnus-with-article 'lisp-indent-function 1)
9536 (put 'gnus-with-article 'edebug-form-spec '(form body))
9539 ;;; Generic summary marking commands
9542 (defvar gnus-summary-marking-alist
9543 '((read gnus-del-mark "d")
9544 (unread gnus-unread-mark "u")
9545 (ticked gnus-ticked-mark "!")
9546 (dormant gnus-dormant-mark "?")
9547 (expirable gnus-expirable-mark "e"))
9548 "An alist of names/marks/keystrokes.")
9550 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
9551 (defvar gnus-summary-mark-map)
9553 (defun gnus-summary-make-all-marking-commands ()
9554 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
9555 (dolist (elem gnus-summary-marking-alist)
9556 (apply 'gnus-summary-make-marking-command elem)))
9558 (defun gnus-summary-make-marking-command (name mark keystroke)
9559 (let ((map (make-sparse-keymap)))
9560 (define-key gnus-summary-generic-mark-map keystroke map)
9561 (dolist (lway `((next "next" next nil "n")
9562 (next-unread "next unread" next t "N")
9563 (prev "previous" prev nil "p")
9564 (prev-unread "previous unread" prev t "P")
9565 (nomove "" nil nil ,keystroke)))
9566 (let ((func (gnus-summary-make-marking-command-1
9567 mark (car lway) lway name)))
9568 (setq func (eval func))
9569 (define-key map (nth 4 lway) func)))))
9571 (defun gnus-summary-make-marking-command-1 (mark way lway name)
9573 (format "gnus-summary-put-mark-as-%s%s"
9574 name (if (eq way 'nomove)
9576 (concat "-" (symbol-name way)))))
9579 "Mark the current article as %s%s.
9580 If N, the prefix, then repeat N times.
9581 If N is negative, move in reverse order.
9582 The difference between N and the actual number of articles marked is
9586 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
9588 (defun gnus-summary-generic-mark (n mark move unread)
9589 "Mark N articles with MARK."
9590 (unless (eq major-mode 'gnus-summary-mode)
9591 (error "This command can only be used in the summary buffer"))
9592 (gnus-summary-show-thread)
9596 ((eq move 'prev) -1)
9602 nummove (* -1 nummove))))
9604 (gnus-summary-mark-article nil mark)
9605 (zerop (gnus-summary-next-subject nummove unread t)))
9608 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9609 (gnus-summary-recenter)
9610 (gnus-summary-position-point)
9611 (gnus-set-mode-line 'summary)
9614 (gnus-summary-make-all-marking-commands)
9620 (run-hooks 'gnus-sum-load-hook)
9622 ;;; gnus-sum.el ends here