1 ;;; gnus-sum.el --- summary mode commands for Gnus
2 ;; Copyright (C) 1996,97,98 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))
37 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
39 (defcustom gnus-kill-summary-on-exit t
40 "*If non-nil, kill the summary buffer when you exit from it.
41 If nil, the summary will become a \"*Dead Summary*\" buffer, and
42 it will be killed sometime later."
43 :group 'gnus-summary-exit
46 (defcustom gnus-fetch-old-headers nil
47 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
48 If an unread article in the group refers to an older, already read (or
49 just marked as read) article, the old article will not normally be
50 displayed in the Summary buffer. If this variable is non-nil, Gnus
51 will attempt to grab the headers to the old articles, and thereby
52 build complete threads. If it has the value `some', only enough
53 headers to connect otherwise loose threads will be displayed. This
54 variable can also be a number. In that case, no more than that number
55 of old headers will be fetched. If it has the value `invisible', all
56 old headers will be fetched, but none will be displayed.
58 The server has to support NOV for any of this to work."
60 :type '(choice (const :tag "off" nil)
63 (sexp :menu-tag "other" t)))
65 (defcustom gnus-refer-thread-limit 200
66 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
67 If t, fetch all the available old headers."
70 (sexp :menu-tag "other" t)))
72 (defcustom gnus-summary-make-false-root 'adopt
73 "*nil means that Gnus won't gather loose threads.
74 If the root of a thread has expired or been read in a previous
75 session, the information necessary to build a complete thread has been
76 lost. Instead of having many small sub-threads from this original thread
77 scattered all over the summary buffer, Gnus can gather them.
79 If non-nil, Gnus will try to gather all loose sub-threads from an
80 original thread into one large thread.
82 If this variable is non-nil, it should be one of `none', `adopt',
85 If this variable is `none', Gnus will not make a false root, but just
86 present the sub-threads after another.
87 If this variable is `dummy', Gnus will create a dummy root that will
88 have all the sub-threads as children.
89 If this variable is `adopt', Gnus will make one of the \"children\"
90 the parent and mark all the step-children as such.
91 If this variable is `empty', the \"children\" are printed with empty
92 subject fields. (Or rather, they will be printed with a string
93 given by the `gnus-summary-same-subject' variable.)"
95 :type '(choice (const :tag "off" nil)
101 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
102 "*A regexp to match subjects to be excluded from loose thread gathering.
103 As loose thread gathering is done on subjects only, that means that
104 there can be many false gatherings performed. By rooting out certain
105 common subjects, gathering might become saner."
109 (defcustom gnus-summary-gather-subject-limit nil
110 "*Maximum length of subject comparisons when gathering loose threads.
111 Use nil to compare full subjects. Setting this variable to a low
112 number will help gather threads that have been corrupted by
113 newsreaders chopping off subject lines, but it might also mean that
114 unrelated articles that have subject that happen to begin with the
115 same few characters will be incorrectly gathered.
117 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
120 :type '(choice (const :tag "off" nil)
122 (sexp :menu-tag "on" t)))
124 (defcustom gnus-simplify-subject-functions nil
125 "List of functions taking a string argument that simplify subjects.
126 The functions are applied recursively.
128 Useful functions to put in this list include: `gnus-simplify-subject-re',
129 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
131 :type '(repeat function))
133 (defcustom gnus-simplify-ignored-prefixes nil
134 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
136 :type '(choice (const :tag "off" nil)
139 (defcustom gnus-build-sparse-threads nil
140 "*If non-nil, fill in the gaps in threads.
141 If `some', only fill in the gaps that are needed to tie loose threads
142 together. If `more', fill in all leaf nodes that Gnus can find. If
143 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
145 :type '(choice (const :tag "off" nil)
148 (sexp :menu-tag "all" t)))
150 (defcustom gnus-summary-thread-gathering-function
151 'gnus-gather-threads-by-subject
152 "*Function used for gathering loose threads.
153 There are two pre-defined functions: `gnus-gather-threads-by-subject',
154 which only takes Subjects into consideration; and
155 `gnus-gather-threads-by-references', which compared the References
156 headers of the articles to find matches."
158 :type '(radio (function-item gnus-gather-threads-by-subject)
159 (function-item gnus-gather-threads-by-references)
160 (function :tag "other")))
162 (defcustom gnus-summary-same-subject ""
163 "*String indicating that the current article has the same subject as the previous.
164 This variable will only be used if the value of
165 `gnus-summary-make-false-root' is `empty'."
166 :group 'gnus-summary-format
169 (defcustom gnus-summary-goto-unread t
170 "*If t, marking commands will go to the next unread article.
171 If `never', commands that usually go to the next unread article, will
172 go to the next article, whether it is read or not.
173 If nil, only the marking commands will go to the next (un)read article."
174 :group 'gnus-summary-marks
175 :link '(custom-manual "(gnus)Setting Marks")
176 :type '(choice (const :tag "off" nil)
178 (sexp :menu-tag "on" t)))
180 (defcustom gnus-summary-default-score 0
181 "*Default article score level.
182 All scores generated by the score files will be added to this score.
183 If this variable is nil, scoring will be disabled."
184 :group 'gnus-score-default
185 :type '(choice (const :tag "disable")
188 (defcustom gnus-summary-zcore-fuzz 0
189 "*Fuzziness factor for the zcore in the summary buffer.
190 Articles with scores closer than this to `gnus-summary-default-score'
192 :group 'gnus-summary-format
195 (defcustom gnus-simplify-subject-fuzzy-regexp nil
196 "*Strings to be removed when doing fuzzy matches.
197 This can either be a regular expression or list of regular expressions
198 that will be removed from subject strings if fuzzy subject
199 simplification is selected."
201 :type '(repeat regexp))
203 (defcustom gnus-show-threads t
204 "*If non-nil, display threads in summary mode."
208 (defcustom gnus-thread-hide-subtree nil
209 "*If non-nil, hide all threads initially.
210 If threads are hidden, you have to run the command
211 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
212 to expose hidden threads."
216 (defcustom gnus-thread-hide-killed t
217 "*If non-nil, hide killed threads automatically."
221 (defcustom gnus-thread-ignore-subject t
222 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
223 If nil, articles that have different subjects from their parents will
224 start separate threads."
228 (defcustom gnus-thread-operation-ignore-subject t
229 "*If non-nil, subjects will be ignored when doing thread commands.
230 This affects commands like `gnus-summary-kill-thread' and
231 `gnus-summary-lower-thread'.
233 If this variable is nil, articles in the same thread with different
234 subjects will not be included in the operation in question. If this
235 variable is `fuzzy', only articles that have subjects that are fuzzily
236 equal will be included."
238 :type '(choice (const :tag "off" nil)
242 (defcustom gnus-thread-indent-level 4
243 "*Number that says how much each sub-thread should be indented."
247 (defcustom gnus-auto-extend-newsgroup t
248 "*If non-nil, extend newsgroup forward and backward when requested."
249 :group 'gnus-summary-choose
252 (defcustom gnus-auto-select-first t
253 "*If nil, don't select the first unread article when entering a group.
254 If this variable is `best', select the highest-scored unread article
255 in the group. If neither nil nor `best', select the first unread
258 If you want to prevent automatic selection of the first unread article
259 in some newsgroups, set the variable to nil in
260 `gnus-select-group-hook'."
261 :group 'gnus-group-select
262 :type '(choice (const :tag "none" nil)
264 (sexp :menu-tag "first" t)))
266 (defcustom gnus-auto-select-next t
267 "*If non-nil, offer to go to the next group from the end of the previous.
268 If the value is t and the next newsgroup is empty, Gnus will exit
269 summary mode and go back to group mode. If the value is neither nil
270 nor t, Gnus will select the following unread newsgroup. In
271 particular, if the value is the symbol `quietly', the next unread
272 newsgroup will be selected without any confirmation, and if it is
273 `almost-quietly', the next group will be selected without any
274 confirmation if you are located on the last article in the group.
275 Finally, if this variable is `slightly-quietly', the `Z n' command
276 will go to the next group without confirmation."
277 :group 'gnus-summary-maneuvering
278 :type '(choice (const :tag "off" nil)
280 (const almost-quietly)
281 (const slightly-quietly)
282 (sexp :menu-tag "on" t)))
284 (defcustom gnus-auto-select-same nil
285 "*If non-nil, select the next article with the same subject.
286 If there are no more articles with the same subject, go to
287 the first unread article."
288 :group 'gnus-summary-maneuvering
291 (defcustom gnus-summary-check-current nil
292 "*If non-nil, consider the current article when moving.
293 The \"unread\" movement commands will stay on the same line if the
294 current article is unread."
295 :group 'gnus-summary-maneuvering
298 (defcustom gnus-auto-center-summary t
299 "*If non-nil, always center the current summary buffer.
300 In particular, if `vertical' do only vertical recentering. If non-nil
301 and non-`vertical', do both horizontal and vertical recentering."
302 :group 'gnus-summary-maneuvering
303 :type '(choice (const :tag "none" nil)
305 (sexp :menu-tag "both" t)))
307 (defcustom gnus-show-all-headers nil
308 "*If non-nil, don't hide any headers."
309 :group 'gnus-article-hiding
310 :group 'gnus-article-headers
313 (defcustom gnus-summary-ignore-duplicates nil
314 "*If non-nil, ignore articles with identical Message-ID headers."
318 (defcustom gnus-single-article-buffer t
319 "*If non-nil, display all articles in the same buffer.
320 If nil, each group will get its own article buffer."
321 :group 'gnus-article-various
324 (defcustom gnus-break-pages t
325 "*If non-nil, do page breaking on articles.
326 The page delimiter is specified by the `gnus-page-delimiter'
328 :group 'gnus-article-various
331 (defcustom gnus-show-mime nil
332 "*If non-nil, do mime processing of articles.
333 The articles will simply be fed to the function given by
334 `gnus-show-mime-method'."
335 :group 'gnus-article-mime
338 (defcustom gnus-move-split-methods nil
339 "*Variable used to suggest where articles are to be moved to.
340 It uses the same syntax as the `gnus-split-methods' variable."
341 :group 'gnus-summary-mail
342 :type '(repeat (choice (list :value (fun) function)
343 (cons :value ("" "") regexp (repeat string))
346 (defcustom gnus-unread-mark ?
347 "*Mark used for unread articles."
348 :group 'gnus-summary-marks
351 (defcustom gnus-ticked-mark ?!
352 "*Mark used for ticked articles."
353 :group 'gnus-summary-marks
356 (defcustom gnus-dormant-mark ??
357 "*Mark used for dormant articles."
358 :group 'gnus-summary-marks
361 (defcustom gnus-del-mark ?r
362 "*Mark used for del'd articles."
363 :group 'gnus-summary-marks
366 (defcustom gnus-read-mark ?R
367 "*Mark used for read articles."
368 :group 'gnus-summary-marks
371 (defcustom gnus-expirable-mark ?E
372 "*Mark used for expirable articles."
373 :group 'gnus-summary-marks
376 (defcustom gnus-killed-mark ?K
377 "*Mark used for killed articles."
378 :group 'gnus-summary-marks
381 (defcustom gnus-souped-mark ?F
382 "*Mark used for killed articles."
383 :group 'gnus-summary-marks
386 (defcustom gnus-kill-file-mark ?X
387 "*Mark used for articles killed by kill files."
388 :group 'gnus-summary-marks
391 (defcustom gnus-low-score-mark ?Y
392 "*Mark used for articles with a low score."
393 :group 'gnus-summary-marks
396 (defcustom gnus-catchup-mark ?C
397 "*Mark used for articles that are caught up."
398 :group 'gnus-summary-marks
401 (defcustom gnus-replied-mark ?A
402 "*Mark used for articles that have been replied to."
403 :group 'gnus-summary-marks
406 (defcustom gnus-cached-mark ?*
407 "*Mark used for articles that are in the cache."
408 :group 'gnus-summary-marks
411 (defcustom gnus-saved-mark ?S
412 "*Mark used for articles that have been saved to."
413 :group 'gnus-summary-marks
416 (defcustom gnus-ancient-mark ?O
417 "*Mark used for ancient articles."
418 :group 'gnus-summary-marks
421 (defcustom gnus-sparse-mark ?Q
422 "*Mark used for sparsely reffed articles."
423 :group 'gnus-summary-marks
426 (defcustom gnus-canceled-mark ?G
427 "*Mark used for canceled articles."
428 :group 'gnus-summary-marks
431 (defcustom gnus-duplicate-mark ?M
432 "*Mark used for duplicate articles."
433 :group 'gnus-summary-marks
436 (defcustom gnus-undownloaded-mark ?@
437 "*Mark used for articles that weren't downloaded."
438 :group 'gnus-summary-marks
441 (defcustom gnus-downloadable-mark ?%
442 "*Mark used for articles that are to be downloaded."
443 :group 'gnus-summary-marks
446 (defcustom gnus-unsendable-mark ?=
447 "*Mark used for articles that won't be sent."
448 :group 'gnus-summary-marks
451 (defcustom gnus-score-over-mark ?+
452 "*Score mark used for articles with high scores."
453 :group 'gnus-summary-marks
456 (defcustom gnus-score-below-mark ?-
457 "*Score mark used for articles with low scores."
458 :group 'gnus-summary-marks
461 (defcustom gnus-empty-thread-mark ?
462 "*There is no thread under the article."
463 :group 'gnus-summary-marks
466 (defcustom gnus-not-empty-thread-mark ?=
467 "*There is a thread under the article."
468 :group 'gnus-summary-marks
471 (defcustom gnus-view-pseudo-asynchronously nil
472 "*If non-nil, Gnus will view pseudo-articles asynchronously."
473 :group 'gnus-extract-view
476 (defcustom gnus-view-pseudos nil
477 "*If `automatic', pseudo-articles will be viewed automatically.
478 If `not-confirm', pseudos will be viewed automatically, and the user
479 will not be asked to confirm the command."
480 :group 'gnus-extract-view
481 :type '(choice (const :tag "off" nil)
483 (const not-confirm)))
485 (defcustom gnus-view-pseudos-separately t
486 "*If non-nil, one pseudo-article will be created for each file to be viewed.
487 If nil, all files that use the same viewing command will be given as a
488 list of parameters to that command."
489 :group 'gnus-extract-view
492 (defcustom gnus-insert-pseudo-articles t
493 "*If non-nil, insert pseudo-articles when decoding articles."
494 :group 'gnus-extract-view
497 (defcustom gnus-summary-dummy-line-format
499 "*The format specification for the dummy roots in the summary buffer.
500 It works along the same lines as a normal formatting string,
501 with some simple extensions.
504 :group 'gnus-threading
507 (defcustom gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
508 "*The format specification for the summary mode line.
509 It works along the same lines as a normal formatting string,
510 with some simple extensions:
513 %p Unprefixed group name
514 %A Current article number
515 %z Current article score
517 %U Number of unread articles in the group
518 %e Number of unselected articles in the group
519 %Z A string with unread/unselected article counts
520 %g Shortish group name
521 %S Subject of the current article
523 %s Current score file name
524 %d Number of dormant articles
525 %r Number of articles that have been marked as read in this session
526 %E Number of articles expunged by the score files"
527 :group 'gnus-summary-format
530 (defcustom gnus-summary-mark-below 0
531 "*Mark all articles with a score below this variable as read.
532 This variable is local to each summary buffer and usually set by the
534 :group 'gnus-score-default
537 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
538 "*List of functions used for sorting articles in the summary buffer.
539 This variable is only used when not using a threaded display."
540 :group 'gnus-summary-sort
541 :type '(repeat (choice (function-item gnus-article-sort-by-number)
542 (function-item gnus-article-sort-by-author)
543 (function-item gnus-article-sort-by-subject)
544 (function-item gnus-article-sort-by-date)
545 (function-item gnus-article-sort-by-score)
546 (function :tag "other"))))
548 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
549 "*List of functions used for sorting threads in the summary buffer.
550 By default, threads are sorted by article number.
552 Each function takes two threads and return non-nil if the first thread
553 should be sorted before the other. If you use more than one function,
554 the primary sort function should be the last. You should probably
555 always include `gnus-thread-sort-by-number' in the list of sorting
556 functions -- preferably first.
558 Ready-made functions include `gnus-thread-sort-by-number',
559 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
560 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
561 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
562 :group 'gnus-summary-sort
563 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
564 (function-item gnus-thread-sort-by-author)
565 (function-item gnus-thread-sort-by-subject)
566 (function-item gnus-thread-sort-by-date)
567 (function-item gnus-thread-sort-by-score)
568 (function-item gnus-thread-sort-by-total-score)
569 (function :tag "other"))))
571 (defcustom gnus-thread-score-function '+
572 "*Function used for calculating the total score of a thread.
574 The function is called with the scores of the article and each
575 subthread and should then return the score of the thread.
577 Some functions you can use are `+', `max', or `min'."
578 :group 'gnus-summary-sort
581 (defcustom gnus-summary-expunge-below nil
582 "All articles that have a score less than this variable will be expunged.
583 This variable is local to the summary buffers."
584 :group 'gnus-score-default
585 :type '(choice (const :tag "off" nil)
588 (defcustom gnus-thread-expunge-below nil
589 "All threads that have a total score less than this variable will be expunged.
590 See `gnus-thread-score-function' for en explanation of what a
593 This variable is local to the summary buffers."
594 :group 'gnus-treading
595 :group 'gnus-score-default
596 :type '(choice (const :tag "off" nil)
599 (defcustom gnus-summary-mode-hook nil
600 "*A hook for Gnus summary mode.
601 This hook is run before any variables are set in the summary buffer."
602 :group 'gnus-summary-various
605 (defcustom gnus-summary-menu-hook nil
606 "*Hook run after the creation of the summary mode menu."
607 :group 'gnus-summary-visual
610 (defcustom gnus-summary-exit-hook nil
611 "*A hook called on exit from the summary buffer.
612 It will be called with point in the group buffer."
613 :group 'gnus-summary-exit
616 (defcustom gnus-summary-prepare-hook nil
617 "*A hook called after the summary buffer has been generated.
618 If you want to modify the summary buffer, you can use this hook."
619 :group 'gnus-summary-various
622 (defcustom gnus-summary-prepared-hook nil
623 "*A hook called as the last thing after the summary buffer has been generated."
624 :group 'gnus-summary-various
627 (defcustom gnus-summary-generate-hook nil
628 "*A hook run just before generating the summary buffer.
629 This hook is commonly used to customize threading variables and the
631 :group 'gnus-summary-various
634 (defcustom gnus-select-group-hook nil
635 "*A hook called when a newsgroup is selected.
637 If you'd like to simplify subjects like the
638 `gnus-summary-next-same-subject' command does, you can use the
641 (setq gnus-select-group-hook
644 (mapcar (lambda (header)
645 (mail-header-set-subject
647 (gnus-simplify-subject
648 (mail-header-subject header) 're-only)))
649 gnus-newsgroup-headers))))"
650 :group 'gnus-group-select
653 (defcustom gnus-select-article-hook nil
654 "*A hook called when an article is selected."
655 :group 'gnus-summary-choose
658 (defcustom gnus-visual-mark-article-hook
659 (list 'gnus-highlight-selected-summary)
660 "*Hook run after selecting an article in the summary buffer.
661 It is meant to be used for highlighting the article in some way. It
662 is not run if `gnus-visual' is nil."
663 :group 'gnus-summary-visual
666 (defcustom gnus-parse-headers-hook nil
667 "*A hook called before parsing the headers."
671 (defcustom gnus-exit-group-hook nil
672 "*A hook called when exiting (not quitting) summary mode."
676 (defcustom gnus-summary-update-hook
677 (list 'gnus-summary-highlight-line)
678 "*A hook called when a summary line is changed.
679 The hook will not be called if `gnus-visual' is nil.
681 The default function `gnus-summary-highlight-line' will
682 highlight the line according to the `gnus-summary-highlight'
684 :group 'gnus-summary-visual
687 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
688 "*A hook called when an article is selected for the first time.
689 The hook is intended to mark an article as read (or unread)
690 automatically when it is selected."
691 :group 'gnus-summary-choose
694 (defcustom gnus-group-no-more-groups-hook nil
695 "*A hook run when returning to group mode having no more (unread) groups."
696 :group 'gnus-group-select
699 (defcustom gnus-ps-print-hook nil
700 "*A hook run before ps-printing something from Gnus."
704 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
705 "Face used for highlighting the current article in the summary buffer."
706 :group 'gnus-summary-visual
709 (defcustom gnus-summary-highlight
710 '(((= mark gnus-canceled-mark)
711 . gnus-summary-cancelled-face)
712 ((and (> score default)
713 (or (= mark gnus-dormant-mark)
714 (= mark gnus-ticked-mark)))
715 . gnus-summary-high-ticked-face)
716 ((and (< score default)
717 (or (= mark gnus-dormant-mark)
718 (= mark gnus-ticked-mark)))
719 . gnus-summary-low-ticked-face)
720 ((or (= mark gnus-dormant-mark)
721 (= mark gnus-ticked-mark))
722 . gnus-summary-normal-ticked-face)
723 ((and (> score default) (= mark gnus-ancient-mark))
724 . gnus-summary-high-ancient-face)
725 ((and (< score default) (= mark gnus-ancient-mark))
726 . gnus-summary-low-ancient-face)
727 ((= mark gnus-ancient-mark)
728 . gnus-summary-normal-ancient-face)
729 ((and (> score default) (= mark gnus-unread-mark))
730 . gnus-summary-high-unread-face)
731 ((and (< score default) (= mark gnus-unread-mark))
732 . gnus-summary-low-unread-face)
733 ((= mark gnus-unread-mark)
734 . gnus-summary-normal-unread-face)
735 ((and (> score default) (memq mark (list gnus-downloadable-mark
736 gnus-undownloaded-mark)))
737 . gnus-summary-high-unread-face)
738 ((and (< score default) (memq mark (list gnus-downloadable-mark
739 gnus-undownloaded-mark)))
740 . gnus-summary-low-unread-face)
741 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
742 . gnus-summary-normal-unread-face)
744 . gnus-summary-high-read-face)
746 . gnus-summary-low-read-face)
748 . gnus-summary-normal-read-face))
749 "*Controls the highlighting of summary buffer lines.
751 A list of (FORM . FACE) pairs. When deciding how a a particular
752 summary line should be displayed, each form is evaluated. The content
753 of the face field after the first true form is used. You can change
754 how those summary lines are displayed, by editing the face field.
756 You can use the following variables in the FORM field.
758 score: The articles score
759 default: The default article score.
760 below: The score below which articles are automatically marked as read.
761 mark: The articles mark."
762 :group 'gnus-summary-visual
763 :type '(repeat (cons (sexp :tag "Form" nil)
766 (defcustom gnus-alter-header-function nil
767 "Function called to allow alteration of article header structures.
768 The function is called with one parameter, the article header vector,
769 which it may alter in any way.")
771 ;;; Internal variables
773 (defvar gnus-scores-exclude-files nil)
774 (defvar gnus-page-broken nil)
776 (defvar gnus-original-article nil)
777 (defvar gnus-article-internal-prepare-hook nil)
778 (defvar gnus-newsgroup-process-stack nil)
780 (defvar gnus-thread-indent-array nil)
781 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
783 ;; Avoid highlighting in kill files.
784 (defvar gnus-summary-inhibit-highlight nil)
785 (defvar gnus-newsgroup-selected-overlay nil)
786 (defvar gnus-inhibit-limiting nil)
787 (defvar gnus-newsgroup-adaptive-score-file nil)
788 (defvar gnus-current-score-file nil)
789 (defvar gnus-current-move-group nil)
790 (defvar gnus-current-copy-group nil)
791 (defvar gnus-current-crosspost-group nil)
793 (defvar gnus-newsgroup-dependencies nil)
794 (defvar gnus-newsgroup-adaptive nil)
795 (defvar gnus-summary-display-article-function nil)
796 (defvar gnus-summary-highlight-line-function nil
797 "Function called after highlighting a summary line.")
799 (defvar gnus-summary-line-format-alist
800 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
801 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
802 (?s gnus-tmp-subject-or-nil ?s)
803 (?n gnus-tmp-name ?s)
804 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
806 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
808 (?F gnus-tmp-from ?s)
809 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
810 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
811 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
812 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
813 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
814 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
815 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
816 (?L gnus-tmp-lines ?d)
817 (?I gnus-tmp-indentation ?s)
818 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
819 (?R gnus-tmp-replied ?c)
820 (?\[ gnus-tmp-opening-bracket ?c)
821 (?\] gnus-tmp-closing-bracket ?c)
822 (?\> (make-string gnus-tmp-level ? ) ?s)
823 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
824 (?i gnus-tmp-score ?d)
825 (?z gnus-tmp-score-char ?c)
826 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
827 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
828 (?U gnus-tmp-unread ?c)
829 (?t (gnus-summary-number-of-articles-in-thread
830 (and (boundp 'thread) (car thread)) gnus-tmp-level)
832 (?e (gnus-summary-number-of-articles-in-thread
833 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
835 (?u gnus-tmp-user-defined ?s)
836 (?P (gnus-pick-line-number) ?d))
837 "An alist of format specifications that can appear in summary lines,
838 and what variables they correspond with, along with the type of the
839 variable (string, integer, character, etc).")
841 (defvar gnus-summary-dummy-line-format-alist
842 `((?S gnus-tmp-subject ?s)
843 (?N gnus-tmp-number ?d)
844 (?u gnus-tmp-user-defined ?s)))
846 (defvar gnus-summary-mode-line-format-alist
847 `((?G gnus-tmp-group-name ?s)
848 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
849 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
850 (?A gnus-tmp-article-number ?d)
851 (?Z gnus-tmp-unread-and-unselected ?s)
853 (?U gnus-tmp-unread-and-unticked ?d)
854 (?S gnus-tmp-subject ?s)
855 (?e gnus-tmp-unselected ?d)
856 (?u gnus-tmp-user-defined ?s)
857 (?d (length gnus-newsgroup-dormant) ?d)
858 (?t (length gnus-newsgroup-marked) ?d)
859 (?r (length gnus-newsgroup-reads) ?d)
860 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
861 (?E gnus-newsgroup-expunged-tally ?d)
862 (?s (gnus-current-score-file-nondirectory) ?s)))
864 (defvar gnus-last-search-regexp nil
865 "Default regexp for article search command.")
867 (defvar gnus-last-shell-command nil
868 "Default shell command on article.")
870 (defvar gnus-newsgroup-begin nil)
871 (defvar gnus-newsgroup-end nil)
872 (defvar gnus-newsgroup-last-rmail nil)
873 (defvar gnus-newsgroup-last-mail nil)
874 (defvar gnus-newsgroup-last-folder nil)
875 (defvar gnus-newsgroup-last-file nil)
876 (defvar gnus-newsgroup-auto-expire nil)
877 (defvar gnus-newsgroup-active nil)
879 (defvar gnus-newsgroup-data nil)
880 (defvar gnus-newsgroup-data-reverse nil)
881 (defvar gnus-newsgroup-limit nil)
882 (defvar gnus-newsgroup-limits nil)
884 (defvar gnus-newsgroup-unreads nil
885 "List of unread articles in the current newsgroup.")
887 (defvar gnus-newsgroup-unselected nil
888 "List of unselected unread articles in the current newsgroup.")
890 (defvar gnus-newsgroup-reads nil
891 "Alist of read articles and article marks in the current newsgroup.")
893 (defvar gnus-newsgroup-expunged-tally nil)
895 (defvar gnus-newsgroup-marked nil
896 "List of ticked articles in the current newsgroup (a subset of unread art).")
898 (defvar gnus-newsgroup-killed nil
899 "List of ranges of articles that have been through the scoring process.")
901 (defvar gnus-newsgroup-cached nil
902 "List of articles that come from the article cache.")
904 (defvar gnus-newsgroup-saved nil
905 "List of articles that have been saved.")
907 (defvar gnus-newsgroup-kill-headers nil)
909 (defvar gnus-newsgroup-replied nil
910 "List of articles that have been replied to in the current newsgroup.")
912 (defvar gnus-newsgroup-expirable nil
913 "List of articles in the current newsgroup that can be expired.")
915 (defvar gnus-newsgroup-processable nil
916 "List of articles in the current newsgroup that can be processed.")
918 (defvar gnus-newsgroup-downloadable nil
919 "List of articles in the current newsgroup that can be processed.")
921 (defvar gnus-newsgroup-undownloaded nil
922 "List of articles in the current newsgroup that haven't been downloaded..")
924 (defvar gnus-newsgroup-unsendable nil
925 "List of articles in the current newsgroup that won't be sent.")
927 (defvar gnus-newsgroup-bookmarks nil
928 "List of articles in the current newsgroup that have bookmarks.")
930 (defvar gnus-newsgroup-dormant nil
931 "List of dormant articles in the current newsgroup.")
933 (defvar gnus-newsgroup-scored nil
934 "List of scored articles in the current newsgroup.")
936 (defvar gnus-newsgroup-headers nil
937 "List of article headers in the current newsgroup.")
939 (defvar gnus-newsgroup-threads nil)
941 (defvar gnus-newsgroup-prepared nil
942 "Whether the current group has been prepared properly.")
944 (defvar gnus-newsgroup-ancient nil
945 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
947 (defvar gnus-newsgroup-sparse nil)
949 (defvar gnus-current-article nil)
950 (defvar gnus-article-current nil)
951 (defvar gnus-current-headers nil)
952 (defvar gnus-have-all-headers nil)
953 (defvar gnus-last-article nil)
954 (defvar gnus-newsgroup-history nil)
956 (defconst gnus-summary-local-variables
957 '(gnus-newsgroup-name
958 gnus-newsgroup-begin gnus-newsgroup-end
959 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
960 gnus-newsgroup-last-folder gnus-newsgroup-last-file
961 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
962 gnus-newsgroup-unselected gnus-newsgroup-marked
963 gnus-newsgroup-reads gnus-newsgroup-saved
964 gnus-newsgroup-replied gnus-newsgroup-expirable
965 gnus-newsgroup-processable gnus-newsgroup-killed
966 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
967 gnus-newsgroup-unsendable
968 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
969 gnus-newsgroup-headers gnus-newsgroup-threads
970 gnus-newsgroup-prepared gnus-summary-highlight-line-function
971 gnus-current-article gnus-current-headers gnus-have-all-headers
972 gnus-last-article gnus-article-internal-prepare-hook
973 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
974 gnus-newsgroup-scored gnus-newsgroup-kill-headers
975 gnus-thread-expunge-below
976 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
977 (gnus-summary-mark-below . global)
978 gnus-newsgroup-active gnus-scores-exclude-files
979 gnus-newsgroup-history gnus-newsgroup-ancient
980 gnus-newsgroup-sparse gnus-newsgroup-process-stack
981 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
982 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
983 (gnus-newsgroup-expunged-tally . 0)
984 gnus-cache-removable-articles gnus-newsgroup-cached
985 gnus-newsgroup-data gnus-newsgroup-data-reverse
986 gnus-newsgroup-limit gnus-newsgroup-limits)
987 "Variables that are buffer-local to the summary buffers.")
989 ;; Byte-compiler warning.
990 (defvar gnus-article-mode-map)
992 ;; Subject simplification.
994 (defun gnus-simplify-whitespace (str)
995 "Remove excessive whitespace."
998 (while (string-match "[ \t][ \t]+" mystr)
999 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1001 (substring mystr (match-end 0)))))
1003 (when (string-match "^[ \t]+" mystr)
1004 (setq mystr (substring mystr (match-end 0))))
1006 (when (string-match "[ \t]+$" mystr)
1007 (setq mystr (substring mystr 0 (match-beginning 0))))
1010 (defsubst gnus-simplify-subject-re (subject)
1011 "Remove \"Re:\" from subject lines."
1012 (if (string-match "^[Rr][Ee]: *" subject)
1013 (substring subject (match-end 0))
1016 (defun gnus-simplify-subject (subject &optional re-only)
1017 "Remove `Re:' and words in parentheses.
1018 If RE-ONLY is non-nil, strip leading `Re:'s only."
1019 (let ((case-fold-search t)) ;Ignore case.
1020 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1021 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1022 (setq subject (substring subject (match-end 0))))
1023 ;; Remove uninteresting prefixes.
1024 (when (and (not re-only)
1025 gnus-simplify-ignored-prefixes
1026 (string-match gnus-simplify-ignored-prefixes subject))
1027 (setq subject (substring subject (match-end 0))))
1028 ;; Remove words in parentheses from end.
1030 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1031 (setq subject (substring subject 0 (match-beginning 0)))))
1032 ;; Return subject string.
1035 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1037 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1038 (goto-char (point-min))
1039 (while (re-search-forward regexp nil t)
1040 (replace-match (or newtext ""))))
1042 (defun gnus-simplify-buffer-fuzzy ()
1043 "Simplify string in the buffer fuzzily.
1044 The string in the accessible portion of the current buffer is simplified.
1045 It is assumed to be a single-line subject.
1046 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1047 matter is removed. Additional things can be deleted by setting
1048 gnus-simplify-subject-fuzzy-regexp."
1049 (let ((case-fold-search t)
1051 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1053 (while (not (eq modified-tick (buffer-modified-tick)))
1054 (setq modified-tick (buffer-modified-tick))
1056 ((listp gnus-simplify-subject-fuzzy-regexp)
1057 (mapcar 'gnus-simplify-buffer-fuzzy-step
1058 gnus-simplify-subject-fuzzy-regexp))
1059 (gnus-simplify-subject-fuzzy-regexp
1060 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1061 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1062 (gnus-simplify-buffer-fuzzy-step
1063 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1064 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1066 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1067 (gnus-simplify-buffer-fuzzy-step " +" " ")
1068 (gnus-simplify-buffer-fuzzy-step " $")
1069 (gnus-simplify-buffer-fuzzy-step "^ +")))
1071 (defun gnus-simplify-subject-fuzzy (subject)
1072 "Simplify a subject string fuzzily.
1073 See `gnus-simplify-buffer-fuzzy' for details."
1075 (gnus-set-work-buffer)
1076 (let ((case-fold-search t))
1077 ;; Remove uninteresting prefixes.
1078 (when (and gnus-simplify-ignored-prefixes
1079 (string-match gnus-simplify-ignored-prefixes subject))
1080 (setq subject (substring subject (match-end 0))))
1082 (inline (gnus-simplify-buffer-fuzzy))
1085 (defsubst gnus-simplify-subject-fully (subject)
1086 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1088 (gnus-simplify-subject-functions
1089 (gnus-map-function gnus-simplify-subject-functions subject))
1090 ((null gnus-summary-gather-subject-limit)
1091 (gnus-simplify-subject-re subject))
1092 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1093 (gnus-simplify-subject-fuzzy subject))
1094 ((numberp gnus-summary-gather-subject-limit)
1095 (gnus-limit-string (gnus-simplify-subject-re subject)
1096 gnus-summary-gather-subject-limit))
1100 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1101 "Check whether two subjects are equal.
1102 If optional argument simple-first is t, first argument is already
1105 ((null simple-first)
1106 (equal (gnus-simplify-subject-fully s1)
1107 (gnus-simplify-subject-fully s2)))
1110 (gnus-simplify-subject-fully s2)))))
1112 (defun gnus-summary-bubble-group ()
1113 "Increase the score of the current group.
1114 This is a handy function to add to `gnus-summary-exit-hook' to
1115 increase the score of each group you read."
1116 (gnus-group-add-score gnus-newsgroup-name))
1120 ;;; Gnus summary mode
1123 (put 'gnus-summary-mode 'mode-class 'special)
1126 ;; Non-orthogonal keys
1128 (gnus-define-keys gnus-summary-mode-map
1129 " " gnus-summary-next-page
1130 "\177" gnus-summary-prev-page
1131 [delete] gnus-summary-prev-page
1132 [backspace] gnus-summary-prev-page
1133 "\r" gnus-summary-scroll-up
1134 "\M-\r" gnus-summary-scroll-down
1135 "n" gnus-summary-next-unread-article
1136 "p" gnus-summary-prev-unread-article
1137 "N" gnus-summary-next-article
1138 "P" gnus-summary-prev-article
1139 "\M-\C-n" gnus-summary-next-same-subject
1140 "\M-\C-p" gnus-summary-prev-same-subject
1141 "\M-n" gnus-summary-next-unread-subject
1142 "\M-p" gnus-summary-prev-unread-subject
1143 "." gnus-summary-first-unread-article
1144 "," gnus-summary-best-unread-article
1145 "\M-s" gnus-summary-search-article-forward
1146 "\M-r" gnus-summary-search-article-backward
1147 "<" gnus-summary-beginning-of-article
1148 ">" gnus-summary-end-of-article
1149 "j" gnus-summary-goto-article
1150 "^" gnus-summary-refer-parent-article
1151 "\M-^" gnus-summary-refer-article
1152 "u" gnus-summary-tick-article-forward
1153 "!" gnus-summary-tick-article-forward
1154 "U" gnus-summary-tick-article-backward
1155 "d" gnus-summary-mark-as-read-forward
1156 "D" gnus-summary-mark-as-read-backward
1157 "E" gnus-summary-mark-as-expirable
1158 "\M-u" gnus-summary-clear-mark-forward
1159 "\M-U" gnus-summary-clear-mark-backward
1160 "k" gnus-summary-kill-same-subject-and-select
1161 "\C-k" gnus-summary-kill-same-subject
1162 "\M-\C-k" gnus-summary-kill-thread
1163 "\M-\C-l" gnus-summary-lower-thread
1164 "e" gnus-summary-edit-article
1165 "#" gnus-summary-mark-as-processable
1166 "\M-#" gnus-summary-unmark-as-processable
1167 "\M-\C-t" gnus-summary-toggle-threads
1168 "\M-\C-s" gnus-summary-show-thread
1169 "\M-\C-h" gnus-summary-hide-thread
1170 "\M-\C-f" gnus-summary-next-thread
1171 "\M-\C-b" gnus-summary-prev-thread
1172 "\M-\C-u" gnus-summary-up-thread
1173 "\M-\C-d" gnus-summary-down-thread
1174 "&" gnus-summary-execute-command
1175 "c" gnus-summary-catchup-and-exit
1176 "\C-w" gnus-summary-mark-region-as-read
1177 "\C-t" gnus-summary-toggle-truncation
1178 "?" gnus-summary-mark-as-dormant
1179 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1180 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1181 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1182 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1183 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1184 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1185 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1186 "=" gnus-summary-expand-window
1187 "\C-x\C-s" gnus-summary-reselect-current-group
1188 "\M-g" gnus-summary-rescan-group
1189 "w" gnus-summary-stop-page-breaking
1190 "\C-c\C-r" gnus-summary-caesar-message
1191 "\M-t" gnus-summary-toggle-mime
1192 "f" gnus-summary-followup
1193 "F" gnus-summary-followup-with-original
1194 "C" gnus-summary-cancel-article
1195 "r" gnus-summary-reply
1196 "R" gnus-summary-reply-with-original
1197 "\C-c\C-f" gnus-summary-mail-forward
1198 "o" gnus-summary-save-article
1199 "\C-o" gnus-summary-save-article-mail
1200 "|" gnus-summary-pipe-output
1201 "\M-k" gnus-summary-edit-local-kill
1202 "\M-K" gnus-summary-edit-global-kill
1204 "\C-c\C-d" gnus-summary-describe-group
1205 "q" gnus-summary-exit
1206 "Q" gnus-summary-exit-no-update
1207 "\C-c\C-i" gnus-info-find-node
1208 gnus-mouse-2 gnus-mouse-pick-article
1209 "m" gnus-summary-mail-other-window
1210 "a" gnus-summary-post-news
1211 "x" gnus-summary-limit-to-unread
1212 "s" gnus-summary-isearch-article
1213 "t" gnus-article-hide-headers
1214 "g" gnus-summary-show-article
1215 "l" gnus-summary-goto-last-article
1216 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1217 "\C-d" gnus-summary-enter-digest-group
1218 "\M-\C-d" gnus-summary-read-document
1219 "\M-\C-e" gnus-summary-edit-parameters
1221 "*" gnus-cache-enter-article
1222 "\M-*" gnus-cache-remove-article
1223 "\M-&" gnus-summary-universal-argument
1224 "\C-l" gnus-recenter
1225 "I" gnus-summary-increase-score
1226 "L" gnus-summary-lower-score
1227 "\M-i" gnus-symbolic-argument
1228 "h" gnus-summary-select-article-buffer
1230 "V" gnus-summary-score-map
1231 "X" gnus-uu-extract-map
1232 "S" gnus-summary-send-map)
1234 ;; Sort of orthogonal keymap
1235 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1236 "t" gnus-summary-tick-article-forward
1237 "!" gnus-summary-tick-article-forward
1238 "d" gnus-summary-mark-as-read-forward
1239 "r" gnus-summary-mark-as-read-forward
1240 "c" gnus-summary-clear-mark-forward
1241 " " gnus-summary-clear-mark-forward
1242 "e" gnus-summary-mark-as-expirable
1243 "x" gnus-summary-mark-as-expirable
1244 "?" gnus-summary-mark-as-dormant
1245 "b" gnus-summary-set-bookmark
1246 "B" gnus-summary-remove-bookmark
1247 "#" gnus-summary-mark-as-processable
1248 "\M-#" gnus-summary-unmark-as-processable
1249 "S" gnus-summary-limit-include-expunged
1250 "C" gnus-summary-catchup
1251 "H" gnus-summary-catchup-to-here
1252 "\C-c" gnus-summary-catchup-all
1253 "k" gnus-summary-kill-same-subject-and-select
1254 "K" gnus-summary-kill-same-subject
1255 "P" gnus-uu-mark-map)
1257 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1258 "c" gnus-summary-clear-above
1259 "u" gnus-summary-tick-above
1260 "m" gnus-summary-mark-above
1261 "k" gnus-summary-kill-below)
1263 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1264 "/" gnus-summary-limit-to-subject
1265 "n" gnus-summary-limit-to-articles
1266 "w" gnus-summary-pop-limit
1267 "s" gnus-summary-limit-to-subject
1268 "a" gnus-summary-limit-to-author
1269 "u" gnus-summary-limit-to-unread
1270 "m" gnus-summary-limit-to-marks
1271 "v" gnus-summary-limit-to-score
1272 "*" gnus-summary-limit-include-cached
1273 "D" gnus-summary-limit-include-dormant
1274 "T" gnus-summary-limit-include-thread
1275 "d" gnus-summary-limit-exclude-dormant
1276 "t" gnus-summary-limit-to-age
1277 "E" gnus-summary-limit-include-expunged
1278 "c" gnus-summary-limit-exclude-childless-dormant
1279 "C" gnus-summary-limit-mark-excluded-as-read)
1281 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1282 "n" gnus-summary-next-unread-article
1283 "p" gnus-summary-prev-unread-article
1284 "N" gnus-summary-next-article
1285 "P" gnus-summary-prev-article
1286 "\C-n" gnus-summary-next-same-subject
1287 "\C-p" gnus-summary-prev-same-subject
1288 "\M-n" gnus-summary-next-unread-subject
1289 "\M-p" gnus-summary-prev-unread-subject
1290 "f" gnus-summary-first-unread-article
1291 "b" gnus-summary-best-unread-article
1292 "j" gnus-summary-goto-article
1293 "g" gnus-summary-goto-subject
1294 "l" gnus-summary-goto-last-article
1295 "o" gnus-summary-pop-article)
1297 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1298 "k" gnus-summary-kill-thread
1299 "l" gnus-summary-lower-thread
1300 "i" gnus-summary-raise-thread
1301 "T" gnus-summary-toggle-threads
1302 "t" gnus-summary-rethread-current
1303 "^" gnus-summary-reparent-thread
1304 "s" gnus-summary-show-thread
1305 "S" gnus-summary-show-all-threads
1306 "h" gnus-summary-hide-thread
1307 "H" gnus-summary-hide-all-threads
1308 "n" gnus-summary-next-thread
1309 "p" gnus-summary-prev-thread
1310 "u" gnus-summary-up-thread
1311 "o" gnus-summary-top-thread
1312 "d" gnus-summary-down-thread
1313 "#" gnus-uu-mark-thread
1314 "\M-#" gnus-uu-unmark-thread)
1316 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1317 "g" gnus-summary-prepare
1318 "c" gnus-summary-insert-cached-articles)
1320 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1321 "c" gnus-summary-catchup-and-exit
1322 "C" gnus-summary-catchup-all-and-exit
1323 "E" gnus-summary-exit-no-update
1324 "Q" gnus-summary-exit
1325 "Z" gnus-summary-exit
1326 "n" gnus-summary-catchup-and-goto-next-group
1327 "R" gnus-summary-reselect-current-group
1328 "G" gnus-summary-rescan-group
1329 "N" gnus-summary-next-group
1330 "s" gnus-summary-save-newsrc
1331 "P" gnus-summary-prev-group)
1333 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1334 " " gnus-summary-next-page
1335 "n" gnus-summary-next-page
1336 "\177" gnus-summary-prev-page
1337 [delete] gnus-summary-prev-page
1338 "p" gnus-summary-prev-page
1339 "\r" gnus-summary-scroll-up
1340 "\M-\r" gnus-summary-scroll-down
1341 "<" gnus-summary-beginning-of-article
1342 ">" gnus-summary-end-of-article
1343 "b" gnus-summary-beginning-of-article
1344 "e" gnus-summary-end-of-article
1345 "^" gnus-summary-refer-parent-article
1346 "r" gnus-summary-refer-parent-article
1347 "R" gnus-summary-refer-references
1348 "T" gnus-summary-refer-thread
1349 "g" gnus-summary-show-article
1350 "s" gnus-summary-isearch-article
1351 "P" gnus-summary-print-article)
1353 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1354 "b" gnus-article-add-buttons
1355 "B" gnus-article-add-buttons-to-head
1356 "o" gnus-article-treat-overstrike
1357 "e" gnus-article-emphasize
1358 "w" gnus-article-fill-cited-article
1359 "c" gnus-article-remove-cr
1360 "q" gnus-article-de-quoted-unreadable
1361 "f" gnus-article-display-x-face
1362 "l" gnus-summary-stop-page-breaking
1363 "r" gnus-summary-caesar-message
1364 "t" gnus-article-hide-headers
1365 "v" gnus-summary-verbose-headers
1366 "m" gnus-summary-toggle-mime
1367 "h" gnus-article-treat-html
1368 "d" gnus-article-treat-dumbquotes)
1370 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1371 "a" gnus-article-hide
1372 "h" gnus-article-hide-headers
1373 "b" gnus-article-hide-boring-headers
1374 "s" gnus-article-hide-signature
1375 "c" gnus-article-hide-citation
1376 "C" gnus-article-hide-citation-in-followups
1377 "p" gnus-article-hide-pgp
1378 "P" gnus-article-hide-pem
1379 "\C-c" gnus-article-hide-citation-maybe)
1381 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1382 "a" gnus-article-highlight
1383 "h" gnus-article-highlight-headers
1384 "c" gnus-article-highlight-citation
1385 "s" gnus-article-highlight-signature)
1387 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1388 "w" gnus-article-decode-mime-words)
1390 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1391 "z" gnus-article-date-ut
1392 "u" gnus-article-date-ut
1393 "l" gnus-article-date-local
1394 "e" gnus-article-date-lapsed
1395 "o" gnus-article-date-original
1396 "i" gnus-article-date-iso8601
1397 "s" gnus-article-date-user)
1399 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1400 "t" gnus-article-remove-trailing-blank-lines
1401 "l" gnus-article-strip-leading-blank-lines
1402 "m" gnus-article-strip-multiple-blank-lines
1403 "a" gnus-article-strip-blank-lines
1404 "A" gnus-article-strip-all-blank-lines
1405 "s" gnus-article-strip-leading-space)
1407 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1409 "f" gnus-summary-fetch-faq
1410 "d" gnus-summary-describe-group
1411 "h" gnus-summary-describe-briefly
1412 "i" gnus-info-find-node)
1414 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1415 "e" gnus-summary-expire-articles
1416 "\M-\C-e" gnus-summary-expire-articles-now
1417 "\177" gnus-summary-delete-article
1418 [delete] gnus-summary-delete-article
1419 "m" gnus-summary-move-article
1420 "r" gnus-summary-respool-article
1421 "w" gnus-summary-edit-article
1422 "c" gnus-summary-copy-article
1423 "B" gnus-summary-crosspost-article
1424 "q" gnus-summary-respool-query
1425 "t" gnus-summary-respool-trace
1426 "i" gnus-summary-import-article
1427 "p" gnus-summary-article-posted-p)
1429 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1430 "o" gnus-summary-save-article
1431 "m" gnus-summary-save-article-mail
1432 "F" gnus-summary-write-article-file
1433 "r" gnus-summary-save-article-rmail
1434 "f" gnus-summary-save-article-file
1435 "b" gnus-summary-save-article-body-file
1436 "h" gnus-summary-save-article-folder
1437 "v" gnus-summary-save-article-vm
1438 "p" gnus-summary-pipe-output
1439 "s" gnus-soup-add-article))
1441 (defun gnus-summary-make-menu-bar ()
1442 (gnus-turn-off-edit-menu 'summary)
1444 (unless (boundp 'gnus-summary-misc-menu)
1447 gnus-summary-kill-menu gnus-summary-mode-map ""
1452 ["Enter score..." gnus-summary-score-entry t]
1453 ["Customize" gnus-score-customize t])
1454 (gnus-make-score-map 'increase)
1455 (gnus-make-score-map 'lower)
1457 ["Kill below" gnus-summary-kill-below t]
1458 ["Mark above" gnus-summary-mark-above t]
1459 ["Tick above" gnus-summary-tick-above t]
1460 ["Clear above" gnus-summary-clear-above t])
1461 ["Current score" gnus-summary-current-score t]
1462 ["Set score" gnus-summary-set-score t]
1463 ["Switch current score file..." gnus-score-change-score-file t]
1464 ["Set mark below..." gnus-score-set-mark-below t]
1465 ["Set expunge below..." gnus-score-set-expunge-below t]
1466 ["Edit current score file" gnus-score-edit-current-scores t]
1467 ["Edit score file" gnus-score-edit-file t]
1468 ["Trace score" gnus-score-find-trace t]
1469 ["Find words" gnus-score-find-favourite-words t]
1470 ["Rescore buffer" gnus-summary-rescore t]
1471 ["Increase score..." gnus-summary-increase-score t]
1472 ["Lower score..." gnus-summary-lower-score t]))))
1474 ;; Define both the Article menu in the summary buffer and the equivalent
1475 ;; Commands menu in the article buffer here for consistency.
1478 ["All" gnus-article-hide t]
1479 ["Headers" gnus-article-hide-headers t]
1480 ["Signature" gnus-article-hide-signature t]
1481 ["Citation" gnus-article-hide-citation t]
1482 ["PGP" gnus-article-hide-pgp t]
1483 ["Boring headers" gnus-article-hide-boring-headers t])
1485 ["All" gnus-article-highlight t]
1486 ["Headers" gnus-article-highlight-headers t]
1487 ["Signature" gnus-article-highlight-signature t]
1488 ["Citation" gnus-article-highlight-citation t])
1490 ["Words" gnus-article-decode-mime-words t]
1491 ["QP" gnus-article-de-quoted-unreadable t])
1493 ["Local" gnus-article-date-local t]
1494 ["ISO8601" gnus-article-date-iso8601 t]
1495 ["UT" gnus-article-date-ut t]
1496 ["Original" gnus-article-date-original t]
1497 ["Lapsed" gnus-article-date-lapsed t]
1498 ["User-defined" gnus-article-date-user t])
1501 ["Leading" gnus-article-strip-leading-blank-lines t]
1502 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1503 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1504 ["All of the above" gnus-article-strip-blank-lines t]
1505 ["All" gnus-article-strip-all-blank-lines t]
1506 ["Leading space" gnus-article-strip-leading-space t])
1507 ["Overstrike" gnus-article-treat-overstrike t]
1508 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1509 ["Emphasis" gnus-article-emphasize t]
1510 ["Word wrap" gnus-article-fill-cited-article t]
1511 ["CR" gnus-article-remove-cr t]
1512 ["Show X-Face" gnus-article-display-x-face t]
1513 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1514 ["UnHTMLize" gnus-article-treat-html t]
1515 ["Rot 13" gnus-summary-caesar-message t]
1516 ["Unix pipe" gnus-summary-pipe-message t]
1517 ["Add buttons" gnus-article-add-buttons t]
1518 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1519 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1520 ["Toggle MIME" gnus-summary-toggle-mime t]
1521 ["Verbose header" gnus-summary-verbose-headers t]
1522 ["Toggle header" gnus-summary-toggle-header t])
1524 ["Save in default format" gnus-summary-save-article t]
1525 ["Save in file" gnus-summary-save-article-file t]
1526 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1527 ["Save in MH folder" gnus-summary-save-article-folder t]
1528 ["Save in VM folder" gnus-summary-save-article-vm t]
1529 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1530 ["Save body in file" gnus-summary-save-article-body-file t]
1531 ["Pipe through a filter" gnus-summary-pipe-output t]
1532 ["Add to SOUP packet" gnus-soup-add-article t]
1533 ["Print" gnus-summary-print-article t])
1535 ["Respool article..." gnus-summary-respool-article t]
1536 ["Move article..." gnus-summary-move-article
1537 (gnus-check-backend-function
1538 'request-move-article gnus-newsgroup-name)]
1539 ["Copy article..." gnus-summary-copy-article t]
1540 ["Crosspost article..." gnus-summary-crosspost-article
1541 (gnus-check-backend-function
1542 'request-replace-article gnus-newsgroup-name)]
1543 ["Import file..." gnus-summary-import-article t]
1544 ["Check if posted" gnus-summary-article-posted-p t]
1545 ["Edit article" gnus-summary-edit-article
1546 (not (gnus-group-read-only-p))]
1547 ["Delete article" gnus-summary-delete-article
1548 (gnus-check-backend-function
1549 'request-expire-articles gnus-newsgroup-name)]
1550 ["Query respool" gnus-summary-respool-query t]
1551 ["Trace respool" gnus-summary-respool-trace t]
1552 ["Delete expirable articles" gnus-summary-expire-articles-now
1553 (gnus-check-backend-function
1554 'request-expire-articles gnus-newsgroup-name)])
1556 ["Uudecode" gnus-uu-decode-uu t]
1557 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1558 ["Unshar" gnus-uu-decode-unshar t]
1559 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1560 ["Save" gnus-uu-decode-save t]
1561 ["Binhex" gnus-uu-decode-binhex t]
1562 ["Postscript" gnus-uu-decode-postscript t])
1564 ["Enter article" gnus-cache-enter-article t]
1565 ["Remove article" gnus-cache-remove-article t])
1566 ["Select article buffer" gnus-summary-select-article-buffer t]
1567 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1568 ["Isearch article..." gnus-summary-isearch-article t]
1569 ["Beginning of the article" gnus-summary-beginning-of-article t]
1570 ["End of the article" gnus-summary-end-of-article t]
1571 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1572 ["Fetch referenced articles" gnus-summary-refer-references t]
1573 ["Fetch current thread" gnus-summary-refer-thread t]
1574 ["Fetch article with id..." gnus-summary-refer-article t]
1575 ["Redisplay" gnus-summary-show-article t])))
1577 gnus-summary-article-menu gnus-summary-mode-map ""
1578 (cons "Article" innards))
1581 gnus-article-commands-menu gnus-article-mode-map ""
1582 (cons "Commands" innards)))
1585 gnus-summary-thread-menu gnus-summary-mode-map ""
1587 ["Toggle threading" gnus-summary-toggle-threads t]
1588 ["Hide threads" gnus-summary-hide-all-threads t]
1589 ["Show threads" gnus-summary-show-all-threads t]
1590 ["Hide thread" gnus-summary-hide-thread t]
1591 ["Show thread" gnus-summary-show-thread t]
1592 ["Go to next thread" gnus-summary-next-thread t]
1593 ["Go to previous thread" gnus-summary-prev-thread t]
1594 ["Go down thread" gnus-summary-down-thread t]
1595 ["Go up thread" gnus-summary-up-thread t]
1596 ["Top of thread" gnus-summary-top-thread t]
1597 ["Mark thread as read" gnus-summary-kill-thread t]
1598 ["Lower thread score" gnus-summary-lower-thread t]
1599 ["Raise thread score" gnus-summary-raise-thread t]
1600 ["Rethread current" gnus-summary-rethread-current t]
1604 gnus-summary-post-menu gnus-summary-mode-map ""
1606 ["Post an article" gnus-summary-post-news t]
1607 ["Followup" gnus-summary-followup t]
1608 ["Followup and yank" gnus-summary-followup-with-original t]
1609 ["Supersede article" gnus-summary-supersede-article t]
1610 ["Cancel article" gnus-summary-cancel-article t]
1611 ["Reply" gnus-summary-reply t]
1612 ["Reply and yank" gnus-summary-reply-with-original t]
1613 ["Wide reply" gnus-summary-wide-reply t]
1614 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1615 ["Mail forward" gnus-summary-mail-forward t]
1616 ["Post forward" gnus-summary-post-forward t]
1617 ["Digest and mail" gnus-uu-digest-mail-forward t]
1618 ["Digest and post" gnus-uu-digest-post-forward t]
1619 ["Resend message" gnus-summary-resend-message t]
1620 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1621 ["Send a mail" gnus-summary-mail-other-window t]
1622 ["Uuencode and post" gnus-uu-post-news t]
1623 ["Followup via news" gnus-summary-followup-to-mail t]
1624 ["Followup via news and yank"
1625 gnus-summary-followup-to-mail-with-original t]
1627 ;;["Send" gnus-summary-send-draft t]
1628 ;;["Send bounced" gnus-resend-bounced-mail t])
1632 gnus-summary-misc-menu gnus-summary-mode-map ""
1635 ["Mark as read" gnus-summary-mark-as-read-forward t]
1636 ["Mark same subject and select"
1637 gnus-summary-kill-same-subject-and-select t]
1638 ["Mark same subject" gnus-summary-kill-same-subject t]
1639 ["Catchup" gnus-summary-catchup t]
1640 ["Catchup all" gnus-summary-catchup-all t]
1641 ["Catchup to here" gnus-summary-catchup-to-here t]
1642 ["Catchup region" gnus-summary-mark-region-as-read t]
1643 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1645 ["Tick" gnus-summary-tick-article-forward t]
1646 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1647 ["Remove marks" gnus-summary-clear-mark-forward t]
1648 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1649 ["Set bookmark" gnus-summary-set-bookmark t]
1650 ["Remove bookmark" gnus-summary-remove-bookmark t])
1652 ["Marks..." gnus-summary-limit-to-marks t]
1653 ["Subject..." gnus-summary-limit-to-subject t]
1654 ["Author..." gnus-summary-limit-to-author t]
1655 ["Age..." gnus-summary-limit-to-age t]
1656 ["Score" gnus-summary-limit-to-score t]
1657 ["Unread" gnus-summary-limit-to-unread t]
1658 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1659 ["Articles" gnus-summary-limit-to-articles t]
1660 ["Pop limit" gnus-summary-pop-limit t]
1661 ["Show dormant" gnus-summary-limit-include-dormant t]
1662 ["Hide childless dormant"
1663 gnus-summary-limit-exclude-childless-dormant t]
1664 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1665 ["Show expunged" gnus-summary-show-all-expunged t])
1667 ["Set mark" gnus-summary-mark-as-processable t]
1668 ["Remove mark" gnus-summary-unmark-as-processable t]
1669 ["Remove all marks" gnus-summary-unmark-all-processable t]
1670 ["Mark above" gnus-uu-mark-over t]
1671 ["Mark series" gnus-uu-mark-series t]
1672 ["Mark region" gnus-uu-mark-region t]
1673 ["Unmark region" gnus-uu-unmark-region t]
1674 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1675 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1676 ["Mark all" gnus-uu-mark-all t]
1677 ["Mark buffer" gnus-uu-mark-buffer t]
1678 ["Mark sparse" gnus-uu-mark-sparse t]
1679 ["Mark thread" gnus-uu-mark-thread t]
1680 ["Unmark thread" gnus-uu-unmark-thread t]
1681 ("Process Mark Sets"
1682 ["Kill" gnus-summary-kill-process-mark t]
1683 ["Yank" gnus-summary-yank-process-mark
1684 gnus-newsgroup-process-stack]
1685 ["Save" gnus-summary-save-process-mark t]))
1687 ["Page forward" gnus-summary-next-page t]
1688 ["Page backward" gnus-summary-prev-page t]
1689 ["Line forward" gnus-summary-scroll-up t])
1691 ["Next unread article" gnus-summary-next-unread-article t]
1692 ["Previous unread article" gnus-summary-prev-unread-article t]
1693 ["Next article" gnus-summary-next-article t]
1694 ["Previous article" gnus-summary-prev-article t]
1695 ["Next unread subject" gnus-summary-next-unread-subject t]
1696 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1697 ["Next article same subject" gnus-summary-next-same-subject t]
1698 ["Previous article same subject" gnus-summary-prev-same-subject t]
1699 ["First unread article" gnus-summary-first-unread-article t]
1700 ["Best unread article" gnus-summary-best-unread-article t]
1701 ["Go to subject number..." gnus-summary-goto-subject t]
1702 ["Go to article number..." gnus-summary-goto-article t]
1703 ["Go to the last article" gnus-summary-goto-last-article t]
1704 ["Pop article off history" gnus-summary-pop-article t])
1706 ["Sort by number" gnus-summary-sort-by-number t]
1707 ["Sort by author" gnus-summary-sort-by-author t]
1708 ["Sort by subject" gnus-summary-sort-by-subject t]
1709 ["Sort by date" gnus-summary-sort-by-date t]
1710 ["Sort by score" gnus-summary-sort-by-score t]
1711 ["Sort by lines" gnus-summary-sort-by-lines t])
1713 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1714 ["Describe group" gnus-summary-describe-group t]
1715 ["Read manual" gnus-info-find-node t])
1717 ["Pick and read" gnus-pick-mode t]
1718 ["Binary" gnus-binary-mode t])
1720 ["Regenerate" gnus-summary-prepare t]
1721 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1722 ["Toggle threading" gnus-summary-toggle-threads t])
1723 ["Filter articles..." gnus-summary-execute-command t]
1724 ["Run command on subjects..." gnus-summary-universal-argument t]
1725 ["Search articles forward..." gnus-summary-search-article-forward t]
1726 ["Search articles backward..." gnus-summary-search-article-backward t]
1727 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1728 ["Expand window" gnus-summary-expand-window t]
1729 ["Expire expirable articles" gnus-summary-expire-articles
1730 (gnus-check-backend-function
1731 'request-expire-articles gnus-newsgroup-name)]
1732 ["Edit local kill file" gnus-summary-edit-local-kill t]
1733 ["Edit main kill file" gnus-summary-edit-global-kill t]
1734 ["Edit group parameters" gnus-summary-edit-parameters t]
1735 ["Send a bug report" gnus-bug t]
1737 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1738 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
1739 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1740 ["Exit group" gnus-summary-exit t]
1741 ["Exit group without updating" gnus-summary-exit-no-update t]
1742 ["Exit and goto next group" gnus-summary-next-group t]
1743 ["Exit and goto prev group" gnus-summary-prev-group t]
1744 ["Reselect group" gnus-summary-reselect-current-group t]
1745 ["Rescan group" gnus-summary-rescan-group t]
1746 ["Update dribble" gnus-summary-save-newsrc t])))
1748 (gnus-run-hooks 'gnus-summary-menu-hook)))
1750 (defun gnus-score-set-default (var value)
1751 "A version of set that updates the GNU Emacs menu-bar."
1753 ;; It is the message that forces the active status to be updated.
1756 (defun gnus-make-score-map (type)
1757 "Make a summary score map of type TYPE."
1760 (let ((headers '(("author" "from" string)
1761 ("subject" "subject" string)
1762 ("article body" "body" string)
1763 ("article head" "head" string)
1764 ("xref" "xref" string)
1765 ("lines" "lines" number)
1766 ("followups to author" "followup" string)))
1767 (types '((number ("less than" <)
1770 (string ("substring" s)
1774 (perms '(("temporary" (current-time-string))
1782 (if (eq type 'lower)
1787 (setq header (car headers))
1793 (let ((ts (cdr (assoc (nth 2 header) types)))
1809 'gnus-summary-score-entry
1811 (if (or (string= (nth 1 header)
1813 (string= (nth 1 header)
1816 (list 'gnus-summary-header
1818 (list 'quote (nth 1 (car ts)))
1819 (list 'gnus-score-default nil)
1825 (list (nreverse outp))))
1828 (list (nreverse outt))))
1830 (setq headers (cdr headers)))
1831 (list (nreverse outh))))))))
1835 (defun gnus-summary-mode (&optional group)
1836 "Major mode for reading articles.
1838 All normal editing commands are switched off.
1839 \\<gnus-summary-mode-map>
1840 Each line in this buffer represents one article. To read an
1841 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
1842 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
1845 You can also post articles and send mail from this buffer. To
1846 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
1847 of an article, type `\\[gnus-summary-reply]'.
1849 There are approx. one gazillion commands you can execute in this
1850 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
1852 The following commands are available:
1854 \\{gnus-summary-mode-map}"
1856 (when (gnus-visual-p 'summary-menu 'menu)
1857 (gnus-summary-make-menu-bar))
1858 (kill-all-local-variables)
1859 (gnus-summary-make-local-variables)
1860 (gnus-make-thread-indent-array)
1861 (gnus-simplify-mode-line)
1862 (setq major-mode 'gnus-summary-mode)
1863 (setq mode-name "Summary")
1864 (make-local-variable 'minor-mode-alist)
1865 (use-local-map gnus-summary-mode-map)
1866 (buffer-disable-undo (current-buffer))
1867 (setq buffer-read-only t) ;Disable modification
1868 (setq truncate-lines t)
1869 (setq selective-display t)
1870 (setq selective-display-ellipses t) ;Display `...'
1871 (gnus-summary-set-display-table)
1872 (gnus-set-default-directory)
1873 (setq gnus-newsgroup-name group)
1874 (make-local-variable 'gnus-summary-line-format)
1875 (make-local-variable 'gnus-summary-line-format-spec)
1876 (make-local-variable 'gnus-summary-dummy-line-format)
1877 (make-local-variable 'gnus-summary-dummy-line-format-spec)
1878 (make-local-variable 'gnus-summary-mark-positions)
1879 (make-local-hook 'post-command-hook)
1880 (add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
1881 (make-local-hook 'pre-command-hook)
1882 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
1883 (gnus-run-hooks 'gnus-summary-mode-hook)
1884 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
1885 (gnus-update-summary-mark-positions))
1887 (defun gnus-summary-make-local-variables ()
1888 "Make all the local summary buffer variables."
1889 (let ((locals gnus-summary-local-variables)
1891 (while (setq local (pop locals))
1894 (if (eq (cdr local) 'global)
1895 ;; Copy the global value of the variable.
1896 (setq global (symbol-value (car local)))
1897 ;; Use the value from the list.
1898 (setq global (eval (cdr local))))
1899 (make-local-variable (car local))
1900 (set (car local) global))
1901 ;; Simple nil-valued local variable.
1902 (make-local-variable local)
1905 (defun gnus-summary-clear-local-variables ()
1906 (let ((locals gnus-summary-local-variables))
1908 (if (consp (car locals))
1909 (and (vectorp (caar locals))
1910 (set (caar locals) nil))
1911 (and (vectorp (car locals))
1912 (set (car locals) nil)))
1913 (setq locals (cdr locals)))))
1915 ;; Summary data functions.
1917 (defmacro gnus-data-number (data)
1920 (defmacro gnus-data-set-number (data number)
1921 `(setcar ,data ,number))
1923 (defmacro gnus-data-mark (data)
1926 (defmacro gnus-data-set-mark (data mark)
1927 `(setcar (nthcdr 1 ,data) ,mark))
1929 (defmacro gnus-data-pos (data)
1932 (defmacro gnus-data-set-pos (data pos)
1933 `(setcar (nthcdr 2 ,data) ,pos))
1935 (defmacro gnus-data-header (data)
1938 (defmacro gnus-data-set-header (data header)
1939 `(setf (nth 3 ,data) ,header))
1941 (defmacro gnus-data-level (data)
1944 (defmacro gnus-data-unread-p (data)
1945 `(= (nth 1 ,data) gnus-unread-mark))
1947 (defmacro gnus-data-read-p (data)
1948 `(/= (nth 1 ,data) gnus-unread-mark))
1950 (defmacro gnus-data-pseudo-p (data)
1951 `(consp (nth 3 ,data)))
1953 (defmacro gnus-data-find (number)
1954 `(assq ,number gnus-newsgroup-data))
1956 (defmacro gnus-data-find-list (number &optional data)
1957 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
1958 (memq (assq ,number bdata)
1961 (defmacro gnus-data-make (number mark pos header level)
1962 `(list ,number ,mark ,pos ,header ,level))
1964 (defun gnus-data-enter (after-article number mark pos header level offset)
1965 (let ((data (gnus-data-find-list after-article)))
1967 (error "No such article: %d" after-article))
1968 (setcdr data (cons (gnus-data-make number mark pos header level)
1970 (setq gnus-newsgroup-data-reverse nil)
1971 (gnus-data-update-list (cddr data) offset)))
1973 (defun gnus-data-enter-list (after-article list &optional offset)
1975 (let ((data (and after-article (gnus-data-find-list after-article)))
1979 (let ((odata gnus-newsgroup-data))
1980 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
1982 (gnus-data-update-list odata offset)))
1983 ;; Find the last element in the list to be spliced into the main
1986 (setq list (cdr list)))
1989 (setcdr list gnus-newsgroup-data)
1990 (setq gnus-newsgroup-data ilist)
1992 (gnus-data-update-list (cdr list) offset)))
1993 (setcdr list (cdr data))
1996 (gnus-data-update-list (cdr list) offset))))
1997 (setq gnus-newsgroup-data-reverse nil))))
1999 (defun gnus-data-remove (article &optional offset)
2000 (let ((data gnus-newsgroup-data))
2001 (if (= (gnus-data-number (car data)) article)
2003 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2004 gnus-newsgroup-data-reverse nil)
2006 (gnus-data-update-list gnus-newsgroup-data offset)))
2008 (when (= (gnus-data-number (cadr data)) article)
2009 (setcdr data (cddr data))
2011 (gnus-data-update-list (cdr data) offset))
2013 gnus-newsgroup-data-reverse nil))
2014 (setq data (cdr data))))))
2016 (defmacro gnus-data-list (backward)
2018 (or gnus-newsgroup-data-reverse
2019 (setq gnus-newsgroup-data-reverse
2020 (reverse gnus-newsgroup-data)))
2021 gnus-newsgroup-data))
2023 (defun gnus-data-update-list (data offset)
2024 "Add OFFSET to the POS of all data entries in DATA."
2025 (setq gnus-newsgroup-data-reverse nil)
2027 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2028 (setq data (cdr data))))
2030 (defun gnus-data-compute-positions ()
2031 "Compute the positions of all articles."
2032 (setq gnus-newsgroup-data-reverse nil)
2033 (let ((data gnus-newsgroup-data))
2035 (gnus-save-hidden-threads
2036 (goto-char (point-min))
2038 (while (get-text-property (point) 'gnus-intangible)
2040 (gnus-data-set-pos (car data) (+ (point) 3))
2041 (setq data (cdr data))
2042 (forward-line 1))))))
2044 (defun gnus-summary-article-pseudo-p (article)
2045 "Say whether this article is a pseudo article or not."
2046 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2048 (defmacro gnus-summary-article-sparse-p (article)
2049 "Say whether this article is a sparse article or not."
2050 `(memq ,article gnus-newsgroup-sparse))
2052 (defmacro gnus-summary-article-ancient-p (article)
2053 "Say whether this article is a sparse article or not."
2054 `(memq ,article gnus-newsgroup-ancient))
2056 (defun gnus-article-parent-p (number)
2057 "Say whether this article is a parent or not."
2058 (let ((data (gnus-data-find-list number)))
2059 (and (cdr data) ; There has to be an article after...
2060 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2061 (gnus-data-level (nth 1 data))))))
2063 (defun gnus-article-children (number)
2064 "Return a list of all children to NUMBER."
2065 (let* ((data (gnus-data-find-list number))
2066 (level (gnus-data-level (car data)))
2068 (setq data (cdr data))
2070 (= (gnus-data-level (car data)) (1+ level)))
2071 (push (gnus-data-number (car data)) children)
2072 (setq data (cdr data)))
2075 (defmacro gnus-summary-skip-intangible ()
2076 "If the current article is intangible, then jump to a different article."
2077 '(let ((to (get-text-property (point) 'gnus-intangible)))
2078 (and to (gnus-summary-goto-subject to))))
2080 (defmacro gnus-summary-article-intangible-p ()
2081 "Say whether this article is intangible or not."
2082 '(get-text-property (point) 'gnus-intangible))
2084 (defun gnus-article-read-p (article)
2085 "Say whether ARTICLE is read or not."
2086 (not (or (memq article gnus-newsgroup-marked)
2087 (memq article gnus-newsgroup-unreads)
2088 (memq article gnus-newsgroup-unselected)
2089 (memq article gnus-newsgroup-dormant))))
2091 ;; Some summary mode macros.
2093 (defmacro gnus-summary-article-number ()
2094 "The article number of the article on the current line.
2095 If there isn's an article number here, then we return the current
2098 (gnus-summary-skip-intangible)
2099 (or (get-text-property (point) 'gnus-number)
2100 (gnus-summary-last-subject))))
2102 (defmacro gnus-summary-article-header (&optional number)
2103 "Return the header of article NUMBER."
2104 `(gnus-data-header (gnus-data-find
2105 ,(or number '(gnus-summary-article-number)))))
2107 (defmacro gnus-summary-thread-level (&optional number)
2108 "Return the level of thread that starts with article NUMBER."
2109 `(if (and (eq gnus-summary-make-false-root 'dummy)
2110 (get-text-property (point) 'gnus-intangible))
2112 (gnus-data-level (gnus-data-find
2113 ,(or number '(gnus-summary-article-number))))))
2115 (defmacro gnus-summary-article-mark (&optional number)
2116 "Return the mark of article NUMBER."
2117 `(gnus-data-mark (gnus-data-find
2118 ,(or number '(gnus-summary-article-number)))))
2120 (defmacro gnus-summary-article-pos (&optional number)
2121 "Return the position of the line of article NUMBER."
2122 `(gnus-data-pos (gnus-data-find
2123 ,(or number '(gnus-summary-article-number)))))
2125 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2126 (defmacro gnus-summary-article-subject (&optional number)
2127 "Return current subject string or nil if nothing."
2130 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2131 '(gnus-data-header (assq (gnus-summary-article-number)
2132 gnus-newsgroup-data)))))
2135 (mail-header-subject headers))))
2137 (defmacro gnus-summary-article-score (&optional number)
2138 "Return current article score."
2139 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2140 gnus-newsgroup-scored))
2141 gnus-summary-default-score 0))
2143 (defun gnus-summary-article-children (&optional number)
2144 "Return a list of article numbers that are children of article NUMBER."
2145 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2146 (level (gnus-data-level (car data)))
2148 (while (and (setq data (cdr data))
2149 (> (setq l (gnus-data-level (car data))) level))
2150 (and (= (1+ level) l)
2151 (push (gnus-data-number (car data))
2153 (nreverse children)))
2155 (defun gnus-summary-article-parent (&optional number)
2156 "Return the article number of the parent of article NUMBER."
2157 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2158 (gnus-data-list t)))
2159 (level (gnus-data-level (car data))))
2161 () ; This is a root.
2162 ;; We search until we find an article with a level less than
2163 ;; this one. That function has to be the parent.
2164 (while (and (setq data (cdr data))
2165 (not (< (gnus-data-level (car data)) level))))
2166 (and data (gnus-data-number (car data))))))
2168 (defun gnus-unread-mark-p (mark)
2169 "Say whether MARK is the unread mark."
2170 (= mark gnus-unread-mark))
2172 (defun gnus-read-mark-p (mark)
2173 "Say whether MARK is one of the marks that mark as read.
2174 This is all marks except unread, ticked, dormant, and expirable."
2175 (not (or (= mark gnus-unread-mark)
2176 (= mark gnus-ticked-mark)
2177 (= mark gnus-dormant-mark)
2178 (= mark gnus-expirable-mark))))
2180 (defmacro gnus-article-mark (number)
2181 "Return the MARK of article NUMBER.
2182 This macro should only be used when computing the mark the \"first\"
2183 time; i.e., when generating the summary lines. After that,
2184 `gnus-summary-article-mark' should be used to examine the
2187 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2188 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2189 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2190 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2191 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2192 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2193 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2194 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2195 gnus-ancient-mark))))
2197 ;; Saving hidden threads.
2199 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2200 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2202 (defmacro gnus-save-hidden-threads (&rest forms)
2203 "Save hidden threads, eval FORMS, and restore the hidden threads."
2204 (let ((config (make-symbol "config")))
2205 `(let ((,config (gnus-hidden-threads-configuration)))
2209 (gnus-restore-hidden-threads-configuration ,config)))))
2211 (defun gnus-hidden-threads-configuration ()
2212 "Return the current hidden threads configuration."
2215 (goto-char (point-min))
2216 (while (search-forward "\r" nil t)
2217 (push (1- (point)) config))
2220 (defun gnus-restore-hidden-threads-configuration (config)
2221 "Restore hidden threads configuration from CONFIG."
2222 (let (point buffer-read-only)
2223 (while (setq point (pop config))
2224 (when (and (< point (point-max))
2226 (= (following-char) ?\n))
2227 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2229 ;; Various summary mode internalish functions.
2231 (defun gnus-mouse-pick-article (e)
2234 (gnus-summary-next-page nil t))
2236 (defun gnus-summary-set-display-table ()
2237 ;; Change the display table. Odd characters have a tendency to mess
2238 ;; up nicely formatted displays - we make all possible glyphs
2239 ;; display only a single character.
2241 ;; We start from the standard display table, if any.
2242 (let ((table (or (copy-sequence standard-display-table)
2243 (make-display-table)))
2245 ;; Nix out all the control chars...
2246 (while (>= (setq i (1- i)) 0)
2247 (aset table i [??]))
2248 ;; ... but not newline and cr, of course. (cr is necessary for the
2249 ;; selective display).
2250 (aset table ?\n nil)
2251 (aset table ?\r nil)
2252 ;; We keep TAB as well.
2253 (aset table ?\t nil)
2254 ;; We nix out any glyphs over 126 that are not set already.
2256 (while (>= (setq i (1- i)) 127)
2257 ;; Only modify if the entry is nil.
2258 (unless (aref table i)
2259 (aset table i [??]))))
2260 (setq buffer-display-table table)))
2262 (defun gnus-summary-setup-buffer (group)
2263 "Initialize summary buffer."
2264 (let ((buffer (concat "*Summary " group "*")))
2265 (if (get-buffer buffer)
2268 (setq gnus-summary-buffer (current-buffer))
2269 (not gnus-newsgroup-prepared))
2270 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2271 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2272 (gnus-summary-mode group)
2274 (gnus-carpal-setup-buffer 'summary))
2275 (unless gnus-single-article-buffer
2276 (make-local-variable 'gnus-article-buffer)
2277 (make-local-variable 'gnus-article-current)
2278 (make-local-variable 'gnus-original-article-buffer))
2279 (setq gnus-newsgroup-name group)
2282 (defun gnus-set-global-variables ()
2283 ;; Set the global equivalents of the summary buffer-local variables
2284 ;; to the latest values they had. These reflect the summary buffer
2285 ;; that was in action when the last article was fetched.
2286 (when (eq major-mode 'gnus-summary-mode)
2287 (setq gnus-summary-buffer (current-buffer))
2288 (let ((name gnus-newsgroup-name)
2289 (marked gnus-newsgroup-marked)
2290 (unread gnus-newsgroup-unreads)
2291 (headers gnus-current-headers)
2292 (data gnus-newsgroup-data)
2293 (summary gnus-summary-buffer)
2294 (article-buffer gnus-article-buffer)
2295 (original gnus-original-article-buffer)
2296 (gac gnus-article-current)
2297 (reffed gnus-reffed-article-number)
2298 (score-file gnus-current-score-file))
2300 (set-buffer gnus-group-buffer)
2301 (setq gnus-newsgroup-name name
2302 gnus-newsgroup-marked marked
2303 gnus-newsgroup-unreads unread
2304 gnus-current-headers headers
2305 gnus-newsgroup-data data
2306 gnus-article-current gac
2307 gnus-summary-buffer summary
2308 gnus-article-buffer article-buffer
2309 gnus-original-article-buffer original
2310 gnus-reffed-article-number reffed
2311 gnus-current-score-file score-file)
2312 ;; The article buffer also has local variables.
2313 (when (gnus-buffer-live-p gnus-article-buffer)
2314 (set-buffer gnus-article-buffer)
2315 (setq gnus-summary-buffer summary))))))
2317 (defun gnus-summary-article-unread-p (article)
2318 "Say whether ARTICLE is unread or not."
2319 (memq article gnus-newsgroup-unreads))
2321 (defun gnus-summary-first-article-p (&optional article)
2322 "Return whether ARTICLE is the first article in the buffer."
2323 (if (not (setq article (or article (gnus-summary-article-number))))
2325 (eq article (caar gnus-newsgroup-data))))
2327 (defun gnus-summary-last-article-p (&optional article)
2328 "Return whether ARTICLE is the last article in the buffer."
2329 (if (not (setq article (or article (gnus-summary-article-number))))
2330 t ; All non-existent numbers are the last article. :-)
2331 (not (cdr (gnus-data-find-list article)))))
2333 (defun gnus-make-thread-indent-array ()
2335 (unless (and gnus-thread-indent-array
2336 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2337 (setq gnus-thread-indent-array (make-vector 201 "")
2338 gnus-thread-indent-array-level gnus-thread-indent-level)
2340 (aset gnus-thread-indent-array n
2341 (make-string (* n gnus-thread-indent-level) ? ))
2344 (defun gnus-update-summary-mark-positions ()
2345 "Compute where the summary marks are to go."
2347 (when (gnus-buffer-exists-p gnus-summary-buffer)
2348 (set-buffer gnus-summary-buffer))
2349 (let ((gnus-replied-mark 129)
2350 (gnus-score-below-mark 130)
2351 (gnus-score-over-mark 130)
2352 (gnus-download-mark 131)
2353 (spec gnus-summary-line-format-spec)
2356 (gnus-set-work-buffer)
2357 (let ((gnus-summary-line-format-spec spec)
2358 (gnus-newsgroup-downloadable '((0 . t))))
2359 (gnus-summary-insert-line
2360 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2361 (goto-char (point-min))
2362 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2364 (goto-char (point-min))
2365 (push (cons 'replied (and (search-forward "\201" nil t)
2368 (goto-char (point-min))
2369 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2371 (goto-char (point-min))
2372 (push (cons 'download
2373 (and (search-forward "\203" nil t) (- (point) 2)))
2375 (setq gnus-summary-mark-positions pos))))
2377 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2378 "Insert a dummy root in the summary buffer."
2380 (gnus-add-text-properties
2381 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2382 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2384 (defun gnus-summary-insert-line (gnus-tmp-header
2385 gnus-tmp-level gnus-tmp-current
2386 gnus-tmp-unread gnus-tmp-replied
2387 gnus-tmp-expirable gnus-tmp-subject-or-nil
2388 &optional gnus-tmp-dummy gnus-tmp-score
2390 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2391 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2392 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2393 (gnus-tmp-score-char
2394 (if (or (null gnus-summary-default-score)
2395 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2396 gnus-summary-zcore-fuzz))
2398 (if (< gnus-tmp-score gnus-summary-default-score)
2399 gnus-score-below-mark gnus-score-over-mark)))
2401 (cond (gnus-tmp-process gnus-process-mark)
2402 ((memq gnus-tmp-current gnus-newsgroup-cached)
2404 (gnus-tmp-replied gnus-replied-mark)
2405 ((memq gnus-tmp-current gnus-newsgroup-saved)
2407 (t gnus-unread-mark)))
2408 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2411 ((string-match "<[^>]+> *$" gnus-tmp-from)
2412 (let ((beg (match-beginning 0)))
2413 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2414 (substring gnus-tmp-from (1+ (match-beginning 0))
2415 (1- (match-end 0))))
2416 (substring gnus-tmp-from 0 beg))))
2417 ((string-match "(.+)" gnus-tmp-from)
2418 (substring gnus-tmp-from
2419 (1+ (match-beginning 0)) (1- (match-end 0))))
2421 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2422 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2423 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2424 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2425 (buffer-read-only nil))
2426 (when (string= gnus-tmp-name "")
2427 (setq gnus-tmp-name gnus-tmp-from))
2428 (unless (numberp gnus-tmp-lines)
2429 (setq gnus-tmp-lines 0))
2430 (gnus-put-text-property-excluding-characters-with-faces
2432 (progn (eval gnus-summary-line-format-spec) (point))
2433 'gnus-number gnus-tmp-number)
2434 (when (gnus-visual-p 'summary-highlight 'highlight)
2436 (gnus-run-hooks 'gnus-summary-update-hook)
2439 (defun gnus-summary-update-line (&optional dont-update)
2440 ;; Update summary line after change.
2441 (when (and gnus-summary-default-score
2442 (not gnus-summary-inhibit-highlight))
2443 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2444 (article (gnus-summary-article-number))
2445 (score (gnus-summary-article-score article)))
2447 (if (and gnus-summary-mark-below
2448 (< (gnus-summary-article-score)
2449 gnus-summary-mark-below))
2450 ;; This article has a low score, so we mark it as read.
2451 (when (memq article gnus-newsgroup-unreads)
2452 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2453 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2454 ;; This article was previously marked as read on account
2455 ;; of a low score, but now it has risen, so we mark it as
2457 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2458 (gnus-summary-update-mark
2459 (if (or (null gnus-summary-default-score)
2460 (<= (abs (- score gnus-summary-default-score))
2461 gnus-summary-zcore-fuzz))
2463 (if (< score gnus-summary-default-score)
2464 gnus-score-below-mark gnus-score-over-mark))
2466 ;; Do visual highlighting.
2467 (when (gnus-visual-p 'summary-highlight 'highlight)
2468 (gnus-run-hooks 'gnus-summary-update-hook)))))
2470 (defvar gnus-tmp-new-adopts nil)
2472 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2473 "Return the number of articles in THREAD.
2474 This may be 0 in some cases -- if none of the articles in
2475 the thread are to be displayed."
2477 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2479 ((not (listp thread))
2481 ((and (consp thread) (cdr thread))
2484 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2487 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2490 (when (and level (zerop level) gnus-tmp-new-adopts)
2493 'gnus-summary-number-of-articles-in-thread
2494 gnus-tmp-new-adopts))))
2496 (if (> number 1) gnus-not-empty-thread-mark
2497 gnus-empty-thread-mark)
2500 (defun gnus-summary-set-local-parameters (group)
2501 "Go through the local params of GROUP and set all variable specs in that list."
2502 (let ((params (gnus-group-find-parameter group))
2505 (setq elem (car params)
2506 params (cdr params))
2507 (and (consp elem) ; Has to be a cons.
2508 (consp (cdr elem)) ; The cdr has to be a list.
2509 (symbolp (car elem)) ; Has to be a symbol in there.
2510 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2511 (ignore-errors ; So we set it.
2512 (make-local-variable (car elem))
2513 (set (car elem) (eval (nth 1 elem))))))))
2515 (defun gnus-summary-read-group (group &optional show-all no-article
2516 kill-buffer no-display backward
2518 "Start reading news in newsgroup GROUP.
2519 If SHOW-ALL is non-nil, already read articles are also listed.
2520 If NO-ARTICLE is non-nil, no article is selected initially.
2521 If NO-DISPLAY, don't generate a summary buffer."
2525 (let ((gnus-auto-select-next nil))
2526 (or (gnus-summary-read-group-1
2527 group show-all no-article
2528 kill-buffer no-display
2531 select-articles nil)))))
2532 (eq gnus-auto-select-next 'quietly))
2533 (set-buffer gnus-group-buffer)
2534 ;; The entry function called above goes to the next
2535 ;; group automatically, so we go two groups back
2536 ;; if we are searching for the previous group.
2538 (gnus-group-prev-unread-group 2))
2539 (if (not (equal group (gnus-group-group-name)))
2540 (setq group (gnus-group-group-name))
2544 (defun gnus-summary-read-group-1 (group show-all no-article
2545 kill-buffer no-display
2546 &optional select-articles)
2547 ;; Killed foreign groups can't be entered.
2548 (when (and (not (gnus-group-native-p group))
2549 (not (gnus-gethash group gnus-newsrc-hashtb)))
2550 (error "Dead non-native groups can't be entered"))
2551 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2552 (let* ((new-group (gnus-summary-setup-buffer group))
2553 (quit-config (gnus-group-quit-config group))
2554 (did-select (and new-group (gnus-select-newsgroup
2555 group show-all select-articles))))
2557 ;; This summary buffer exists already, so we just select it.
2559 (gnus-set-global-variables)
2561 (gnus-kill-or-deaden-summary kill-buffer))
2562 (gnus-configure-windows 'summary 'force)
2563 (gnus-set-mode-line 'summary)
2564 (gnus-summary-position-point)
2567 ;; We couldn't select this group.
2569 (when (and (eq major-mode 'gnus-summary-mode)
2570 (not (equal (current-buffer) kill-buffer)))
2571 (kill-buffer (current-buffer))
2572 (if (not quit-config)
2574 ;; Update the info -- marks might need to be removed,
2576 (gnus-summary-update-info)
2577 (set-buffer gnus-group-buffer)
2578 (gnus-group-jump-to-group group)
2579 (gnus-group-next-unread-group 1))
2580 (gnus-handle-ephemeral-exit quit-config)))
2581 (gnus-message 3 "Can't select group")
2583 ;; The user did a `C-g' while prompting for number of articles,
2584 ;; so we exit this group.
2585 ((eq did-select 'quit)
2586 (and (eq major-mode 'gnus-summary-mode)
2587 (not (equal (current-buffer) kill-buffer))
2588 (kill-buffer (current-buffer)))
2590 (gnus-kill-or-deaden-summary kill-buffer))
2591 (if (not quit-config)
2593 (set-buffer gnus-group-buffer)
2594 (gnus-group-jump-to-group group)
2595 (gnus-group-next-unread-group 1)
2596 (gnus-configure-windows 'group 'force))
2597 (gnus-handle-ephemeral-exit quit-config))
2598 ;; Finally signal the quit.
2600 ;; The group was successfully selected.
2602 (gnus-set-global-variables)
2603 ;; Save the active value in effect when the group was entered.
2604 (setq gnus-newsgroup-active
2606 (gnus-active gnus-newsgroup-name)))
2607 ;; You can change the summary buffer in some way with this hook.
2608 (gnus-run-hooks 'gnus-select-group-hook)
2609 ;; Set any local variables in the group parameters.
2610 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2611 (gnus-update-format-specifications
2612 nil 'summary 'summary-mode 'summary-dummy)
2613 ;; Do score processing.
2614 (when gnus-use-scoring
2615 (gnus-possibly-score-headers))
2616 ;; Check whether to fill in the gaps in the threads.
2617 (when gnus-build-sparse-threads
2618 (gnus-build-sparse-threads))
2619 ;; Find the initial limit.
2620 (if gnus-show-threads
2622 (let ((gnus-newsgroup-dormant nil))
2623 (gnus-summary-initial-limit show-all))
2624 (gnus-summary-initial-limit show-all))
2625 (setq gnus-newsgroup-limit
2627 (lambda (header) (mail-header-number header))
2628 gnus-newsgroup-headers)))
2629 ;; Generate the summary buffer.
2631 (gnus-summary-prepare))
2632 (when gnus-use-trees
2633 (gnus-tree-open group)
2634 (setq gnus-summary-highlight-line-function
2635 'gnus-tree-highlight-article))
2636 ;; If the summary buffer is empty, but there are some low-scored
2637 ;; articles or some excluded dormants, we include these in the
2639 (when (and (zerop (buffer-size))
2641 (cond (gnus-newsgroup-dormant
2642 (gnus-summary-limit-include-dormant))
2643 ((and gnus-newsgroup-scored show-all)
2644 (gnus-summary-limit-include-expunged t))))
2645 ;; Function `gnus-apply-kill-file' must be called in this hook.
2646 (gnus-run-hooks 'gnus-apply-kill-hook)
2647 (if (and (zerop (buffer-size))
2650 ;; This newsgroup is empty.
2651 (gnus-summary-catchup-and-exit nil t)
2652 (gnus-message 6 "No unread news")
2654 (gnus-kill-or-deaden-summary kill-buffer))
2655 ;; Return nil from this function.
2657 ;; Hide conversation thread subtrees. We cannot do this in
2658 ;; gnus-summary-prepare-hook since kill processing may not
2659 ;; work with hidden articles.
2660 (and gnus-show-threads
2661 gnus-thread-hide-subtree
2662 (gnus-summary-hide-all-threads))
2664 (gnus-kill-or-deaden-summary kill-buffer))
2665 ;; Show first unread article if requested.
2666 (if (and (not no-article)
2668 gnus-newsgroup-unreads
2669 gnus-auto-select-first)
2670 (unless (if (eq gnus-auto-select-first 'best)
2671 (gnus-summary-best-unread-article)
2672 (gnus-summary-first-unread-article))
2673 (gnus-configure-windows 'summary))
2674 ;; Don't select any articles, just move point to the first
2675 ;; article in the group.
2676 (goto-char (point-min))
2677 (gnus-summary-position-point)
2678 (gnus-configure-windows 'summary 'force)
2679 (gnus-set-mode-line 'summary))
2680 (when (get-buffer-window gnus-group-buffer t)
2681 ;; Gotta use windows, because recenter does weird stuff if
2682 ;; the current buffer ain't the displayed window.
2683 (let ((owin (selected-window)))
2684 (select-window (get-buffer-window gnus-group-buffer t))
2685 (when (gnus-group-goto-group group)
2687 (select-window owin)))
2688 ;; Mark this buffer as "prepared".
2689 (setq gnus-newsgroup-prepared t)
2690 (gnus-run-hooks 'gnus-summary-prepared-hook)
2693 (defun gnus-summary-prepare ()
2694 "Generate the summary buffer."
2696 (let ((buffer-read-only nil))
2698 (setq gnus-newsgroup-data nil
2699 gnus-newsgroup-data-reverse nil)
2700 (gnus-run-hooks 'gnus-summary-generate-hook)
2701 ;; Generate the buffer, either with threads or without.
2702 (when gnus-newsgroup-headers
2703 (gnus-summary-prepare-threads
2704 (if gnus-show-threads
2705 (gnus-sort-gathered-threads
2706 (funcall gnus-summary-thread-gathering-function
2708 (gnus-cut-threads (gnus-make-threads)))))
2709 ;; Unthreaded display.
2710 (gnus-sort-articles gnus-newsgroup-headers))))
2711 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2712 ;; Call hooks for modifying summary buffer.
2713 (goto-char (point-min))
2714 (gnus-run-hooks 'gnus-summary-prepare-hook)))
2716 (defsubst gnus-general-simplify-subject (subject)
2717 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2720 ;; Truncate the subject.
2721 (gnus-simplify-subject-functions
2722 (gnus-map-function gnus-simplify-subject-functions subject))
2723 ((numberp gnus-summary-gather-subject-limit)
2724 (setq subject (gnus-simplify-subject-re subject))
2725 (if (> (length subject) gnus-summary-gather-subject-limit)
2726 (substring subject 0 gnus-summary-gather-subject-limit)
2728 ;; Fuzzily simplify it.
2729 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2730 (gnus-simplify-subject-fuzzy subject))
2731 ;; Just remove the leading "Re:".
2733 (gnus-simplify-subject-re subject))))
2735 (if (and gnus-summary-gather-exclude-subject
2736 (string-match gnus-summary-gather-exclude-subject subject))
2737 nil ; This article shouldn't be gathered
2740 (defun gnus-summary-simplify-subject-query ()
2741 "Query where the respool algorithm would put this article."
2743 (gnus-summary-select-article)
2744 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2746 (defun gnus-gather-threads-by-subject (threads)
2747 "Gather threads by looking at Subject headers."
2748 (if (not gnus-summary-make-false-root)
2750 (let ((hashtb (gnus-make-hashtable 1024))
2753 subject hthread whole-subject)
2755 (setq subject (gnus-general-simplify-subject
2756 (setq whole-subject (mail-header-subject
2759 (if (setq hthread (gnus-gethash subject hashtb))
2761 ;; We enter a dummy root into the thread, if we
2762 ;; haven't done that already.
2763 (unless (stringp (caar hthread))
2764 (setcar hthread (list whole-subject (car hthread))))
2765 ;; We add this new gathered thread to this gathered
2767 (setcdr (car hthread)
2768 (nconc (cdar hthread) (list (car threads))))
2769 ;; Remove it from the list of threads.
2770 (setcdr prev (cdr threads))
2771 (setq threads prev))
2772 ;; Enter this thread into the hash table.
2773 (gnus-sethash subject threads hashtb)))
2775 (setq threads (cdr threads)))
2778 (defun gnus-gather-threads-by-references (threads)
2779 "Gather threads by looking at References headers."
2780 (let ((idhashtb (gnus-make-hashtable 1024))
2781 (thhashtb (gnus-make-hashtable 1024))
2784 ids references id gthread gid entered ref)
2786 (when (setq references (mail-header-references (caar threads)))
2787 (setq id (mail-header-id (caar threads))
2788 ids (gnus-split-references references)
2790 (while (setq ref (pop ids))
2791 (setq ids (delete ref ids))
2792 (if (not (setq gid (gnus-gethash ref idhashtb)))
2794 (gnus-sethash ref id idhashtb)
2795 (gnus-sethash id threads thhashtb))
2796 (setq gthread (gnus-gethash gid thhashtb))
2798 ;; We enter a dummy root into the thread, if we
2799 ;; haven't done that already.
2800 (unless (stringp (caar gthread))
2801 (setcar gthread (list (mail-header-subject (caar gthread))
2803 ;; We add this new gathered thread to this gathered
2805 (setcdr (car gthread)
2806 (nconc (cdar gthread) (list (car threads)))))
2807 ;; Add it into the thread hash table.
2808 (gnus-sethash id gthread thhashtb)
2810 ;; Remove it from the list of threads.
2811 (setcdr prev (cdr threads))
2812 (setq threads prev))))
2814 (setq threads (cdr threads)))
2817 (defun gnus-sort-gathered-threads (threads)
2818 "Sort subtreads inside each gathered thread by article number."
2819 (let ((result threads))
2821 (when (stringp (caar threads))
2822 (setcdr (car threads)
2823 (sort (cdar threads) 'gnus-thread-sort-by-number)))
2824 (setq threads (cdr threads)))
2827 (defun gnus-thread-loop-p (root thread)
2828 "Say whether ROOT is in THREAD."
2829 (let ((stack (list thread))
2832 (while (setq thread (pop stack))
2833 (setq th (cdr thread))
2835 (not (eq (caar th) root)))
2838 ;; We have found a loop.
2840 (setcdr thread (delq (car th) (cdr thread)))
2841 (if (boundp (setq ref-dep (intern "none"
2842 gnus-newsgroup-dependencies)))
2843 (setcdr (symbol-value ref-dep)
2844 (nconc (cdr (symbol-value ref-dep))
2846 (set ref-dep (list nil (car th))))
2849 ;; Push all the subthreads onto the stack.
2850 (push (cdr thread) stack)))
2853 (defun gnus-make-threads ()
2854 "Go through the dependency hashtb and find the roots. Return all threads."
2856 (while (catch 'infloop
2859 ;; Deal with self-referencing References loops.
2860 (when (and (car (symbol-value refs))
2867 (car (symbol-value refs)) thread))
2868 (cdr (symbol-value refs)))))))
2871 (unless (car (symbol-value refs))
2872 ;; These threads do not refer back to any other articles,
2873 ;; so they're roots.
2874 (setq threads (append (cdr (symbol-value refs)) threads))))
2875 gnus-newsgroup-dependencies)))
2878 ;; Build the thread tree.
2879 (defun gnus-dependencies-add-header (header dependencies force-new)
2880 "Enter HEADER into the DEPENDENCIES table if it is not already there.
2882 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
2883 if it was already present.
2885 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
2886 will not be entered in the DEPENDENCIES table. Otherwise duplicate
2887 Message-IDs will be renamed be renamed to a unique Message-ID before
2890 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
2891 (let* ((id (mail-header-id header))
2892 (id-dep (and id (intern id dependencies)))
2893 ref ref-dep ref-header)
2894 ;; Enter this `header' in the `dependencies' table.
2898 ;; The first two cases do the normal part: enter a new `header'
2899 ;; in the `dependencies' table.
2900 ((not (boundp id-dep))
2901 (set id-dep (list header)))
2902 ((null (car (symbol-value id-dep)))
2903 (setcar (symbol-value id-dep) header))
2905 ;; From here the `header' was already present in the
2906 ;; `dependencies' table.
2908 ;; Overrides an existing entry;
2909 ;; just set the header part of the entry.
2910 (setcar (symbol-value id-dep) header))
2912 ;; Renames the existing `header' to a unique Message-ID.
2913 ((not gnus-summary-ignore-duplicates)
2914 ;; An article with this Message-ID has already been seen.
2915 ;; We rename the Message-ID.
2916 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
2918 (mail-header-set-id header id))
2920 ;; The last case ignores an existing entry, except it adds any
2921 ;; additional Xrefs (in case the two articles came from different
2923 ;; Also sets `header' to `nil' meaning that the `dependencies'
2924 ;; table was *not* modified.
2926 (mail-header-set-xref
2927 (car (symbol-value id-dep))
2928 (concat (or (mail-header-xref (car (symbol-value id-dep)))
2930 (or (mail-header-xref header) "")))
2934 ;; First check if that we are not creating a References loop.
2935 (setq ref (gnus-parent-id (mail-header-references header)))
2937 (setq ref-dep (intern-soft ref dependencies))
2939 (setq ref-header (car (symbol-value ref-dep))))
2940 (if (string= id ref)
2941 ;; Yuk! This is a reference loop. Make the article be a
2944 (mail-header-set-references (car (symbol-value id-dep)) "none")
2946 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
2947 (setq ref (gnus-parent-id (mail-header-references header)))
2948 (setq ref-dep (intern (or ref "none") dependencies))
2949 (if (boundp ref-dep)
2950 (setcdr (symbol-value ref-dep)
2951 (nconc (cdr (symbol-value ref-dep))
2952 (list (symbol-value id-dep))))
2953 (set ref-dep (list nil (symbol-value id-dep)))))
2956 (defun gnus-build-sparse-threads ()
2957 (let ((headers gnus-newsgroup-headers)
2958 (gnus-summary-ignore-duplicates t)
2959 header references generation relations
2960 subject child end new-child date)
2961 ;; First we create an alist of generations/relations, where
2962 ;; generations is how much we trust the relation, and the relation
2964 (gnus-message 7 "Making sparse threads...")
2966 (nnheader-set-temp-buffer " *gnus sparse threads*")
2967 (while (setq header (pop headers))
2968 (when (and (setq references (mail-header-references header))
2969 (not (string= references "")))
2971 (setq child (mail-header-id header)
2972 subject (mail-header-subject header)
2973 date (mail-header-date header)
2975 (while (search-backward ">" nil t)
2976 (setq end (1+ (point)))
2977 (when (search-backward "<" nil t)
2978 (setq new-child (buffer-substring (point) end))
2979 (push (list (incf generation)
2980 child (setq child new-child)
2984 (push (list (1+ generation) child nil subject) relations))
2986 (kill-buffer (current-buffer)))
2987 ;; Sort over trustworthiness.
2990 (when (gnus-dependencies-add-header
2991 (make-full-mail-header
2992 gnus-reffed-article-number
2993 (nth 3 relation) "" (or (nth 4 relation) "")
2995 (or (nth 2 relation) "") 0 0 "")
2996 gnus-newsgroup-dependencies nil)
2997 (push gnus-reffed-article-number gnus-newsgroup-limit)
2998 (push gnus-reffed-article-number gnus-newsgroup-sparse)
2999 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3000 gnus-newsgroup-reads)
3001 (decf gnus-reffed-article-number)))
3002 (sort relations 'car-less-than-car))
3003 (gnus-message 7 "Making sparse threads...done")))
3005 (defun gnus-build-old-threads ()
3006 ;; Look at all the articles that refer back to old articles, and
3007 ;; fetch the headers for the articles that aren't there. This will
3008 ;; build complete threads - if the roots haven't been expired by the
3013 (when (not (car (symbol-value refs)))
3014 (setq heads (cdr (symbol-value refs)))
3016 (if (memq (mail-header-number (caar heads))
3017 gnus-newsgroup-dormant)
3018 (setq heads (cdr heads))
3019 (setq id (symbol-name refs))
3020 (while (and (setq id (gnus-build-get-header id))
3021 (not (car (gnus-id-to-thread id)))))
3022 (setq heads nil)))))
3023 gnus-newsgroup-dependencies)))
3025 ;; The following macros and functions were written by Felix Lee
3026 ;; <flee@cse.psu.edu>.
3028 (defmacro gnus-nov-read-integer ()
3030 (if (= (following-char) ?\t)
3032 (let ((num (ignore-errors (read buffer))))
3033 (if (numberp num) num 0)))
3035 (search-forward "\t" eol 'move))))
3037 (defmacro gnus-nov-skip-field ()
3038 '(search-forward "\t" eol 'move))
3040 (defmacro gnus-nov-field ()
3041 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
3043 ;; This function has to be called with point after the article number
3044 ;; on the beginning of the line.
3045 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3046 (let ((eol (gnus-point-at-eol))
3047 (buffer (current-buffer))
3050 ;; overview: [num subject from date id refs chars lines misc]
3053 (narrow-to-region (point) eol)
3058 (make-full-mail-header
3060 (rfc2047-decode-string (gnus-nov-field)) ; subject
3061 (rfc2047-decode-string (gnus-nov-field)) ; from
3062 (gnus-nov-field) ; date
3063 (or (gnus-nov-field)
3064 (nnheader-generate-fake-message-id)) ; id
3065 (gnus-nov-field) ; refs
3066 (gnus-nov-read-integer) ; chars
3067 (gnus-nov-read-integer) ; lines
3068 (unless (= (following-char) ?\n)
3069 (gnus-nov-field))))) ; misc
3073 (when gnus-alter-header-function
3074 (funcall gnus-alter-header-function header))
3075 (gnus-dependencies-add-header header dependencies force-new)))
3077 (defun gnus-build-get-header (id)
3078 ;; Look through the buffer of NOV lines and find the header to
3079 ;; ID. Enter this line into the dependencies hash table, and return
3080 ;; the id of the parent article (if any).
3081 (let ((deps gnus-newsgroup-dependencies)
3085 (set-buffer nntp-server-buffer)
3086 (let ((case-fold-search nil))
3087 (goto-char (point-min))
3088 (while (and (not found)
3089 (search-forward id nil t))
3091 (setq found (looking-at
3092 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3093 (regexp-quote id))))
3094 (or found (beginning-of-line 2)))
3098 (setq header (gnus-nov-parse-line
3099 (read (current-buffer)) deps))
3100 (gnus-parent-id (mail-header-references header))))))
3102 (let ((number (mail-header-number header)))
3103 (push number gnus-newsgroup-limit)
3104 (push header gnus-newsgroup-headers)
3105 (if (memq number gnus-newsgroup-unselected)
3107 (push number gnus-newsgroup-unreads)
3108 (setq gnus-newsgroup-unselected
3109 (delq number gnus-newsgroup-unselected)))
3110 (push number gnus-newsgroup-ancient)))))))
3112 (defun gnus-build-all-threads ()
3113 "Read all the headers."
3114 (let ((gnus-summary-ignore-duplicates t)
3115 (dependencies gnus-newsgroup-dependencies)
3118 (set-buffer nntp-server-buffer)
3119 (let ((case-fold-search nil))
3120 (goto-char (point-min))
3123 (setq article (read (current-buffer))
3124 header (gnus-nov-parse-line
3125 article dependencies)))
3128 (set-buffer gnus-summary-buffer)
3129 (push header gnus-newsgroup-headers)
3130 (if (memq (setq article (mail-header-number header))
3131 gnus-newsgroup-unselected)
3133 (push article gnus-newsgroup-unreads)
3134 (setq gnus-newsgroup-unselected
3135 (delq article gnus-newsgroup-unselected)))
3136 (push article gnus-newsgroup-ancient)))
3137 (forward-line 1)))))))
3139 (defun gnus-summary-update-article-line (article header)
3140 "Update the line for ARTICLE using HEADERS."
3141 (let* ((id (mail-header-id header))
3142 (thread (gnus-id-to-thread id)))
3144 (error "Article in no thread"))
3145 ;; Update the thread.
3146 (setcar thread header)
3147 (gnus-summary-goto-subject article)
3148 (let* ((datal (gnus-data-find-list article))
3150 (length (when (cdr datal)
3151 (- (gnus-data-pos data)
3152 (gnus-data-pos (cadr datal)))))
3153 (buffer-read-only nil)
3154 (level (gnus-summary-thread-level)))
3156 (gnus-summary-insert-line
3157 header level nil (gnus-article-mark article)
3158 (memq article gnus-newsgroup-replied)
3159 (memq article gnus-newsgroup-expirable)
3160 ;; Only insert the Subject string when it's different
3161 ;; from the previous Subject string.
3162 (if (gnus-subject-equal
3164 (mail-header-subject
3167 (gnus-data-find-list
3169 (gnus-data-list t)))))
3170 ;; Error on the side of excessive subjects.
3172 (mail-header-subject header))
3174 (mail-header-subject header))
3175 nil (cdr (assq article gnus-newsgroup-scored))
3176 (memq article gnus-newsgroup-processable))
3178 (gnus-data-update-list
3179 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3181 (defun gnus-summary-update-article (article &optional iheader)
3182 "Update ARTICLE in the summary buffer."
3183 (set-buffer gnus-summary-buffer)
3184 (let* ((header (gnus-summary-article-header article))
3185 (id (mail-header-id header))
3186 (data (gnus-data-find article))
3187 (thread (gnus-id-to-thread id))
3188 (references (mail-header-references header))
3192 (when (and references
3193 (not (equal "" references)))
3196 (buffer-read-only nil)
3202 (delq thread parent)))
3203 (if (gnus-summary-insert-subject id header)
3204 ;; Set the (possibly) new article number in the data structure.
3205 (gnus-data-set-number data (gnus-id-to-article id))
3209 (defun gnus-rebuild-thread (id &optional line)
3210 "Rebuild the thread containing ID.
3211 If LINE, insert the rebuilt thread starting on line LINE."
3212 (let ((buffer-read-only nil)
3213 old-pos current thread data)
3214 (if (not gnus-show-threads)
3215 (setq thread (list (car (gnus-id-to-thread id))))
3216 ;; Get the thread this article is part of.
3217 (setq thread (gnus-remove-thread id)))
3218 (setq old-pos (gnus-point-at-bol))
3219 (setq current (save-excursion
3220 (and (zerop (forward-line -1))
3221 (gnus-summary-article-number))))
3222 ;; If this is a gathered thread, we have to go some re-gathering.
3223 (when (stringp (car thread))
3224 (let ((subject (car thread))
3226 (setq thread (cdr thread))
3228 (unless (memq (setq thr (gnus-id-to-thread
3230 (mail-header-id (caar thread)))))
3233 (setq thread (cdr thread)))
3234 ;; We now have all (unique) roots.
3235 (if (= (length roots) 1)
3236 ;; All the loose roots are now one solid root.
3237 (setq thread (car roots))
3238 (setq thread (cons subject (gnus-sort-threads roots))))))
3240 ;; We then insert this thread into the summary buffer.
3242 (goto-char (point-min))
3243 (forward-line (1- line)))
3244 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3245 (if gnus-show-threads
3246 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3247 (gnus-summary-prepare-unthreaded thread))
3248 (setq data (nreverse gnus-newsgroup-data))
3249 (setq threads gnus-newsgroup-threads))
3250 ;; We splice the new data into the data structure.
3251 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3252 ;;!!! then we want to insert at the beginning of the buffer.
3253 ;;!!! That happens to be true with Gnus now, but that may
3254 ;;!!! change in the future. Perhaps.
3255 (gnus-data-enter-list
3256 (if line nil current) data (- (point) old-pos))
3257 (setq gnus-newsgroup-threads
3258 (nconc threads gnus-newsgroup-threads))
3259 (gnus-data-compute-positions))))
3261 (defun gnus-number-to-header (number)
3262 "Return the header for article NUMBER."
3263 (let ((headers gnus-newsgroup-headers))
3265 (not (= number (mail-header-number (car headers)))))
3270 (defun gnus-parent-headers (in-headers &optional generation)
3271 "Return the headers of the GENERATIONeth parent of HEADERS."
3273 (setq generation 1))
3275 (headers in-headers)
3278 (not (zerop generation))
3279 (setq references (mail-header-references headers)))
3280 (setq headers (if (and references
3281 (setq parent (gnus-parent-id references)))
3282 (car (gnus-id-to-thread parent))
3285 (and (not (eq headers in-headers))
3288 (defun gnus-id-to-thread (id)
3289 "Return the (sub-)thread where ID appears."
3290 (gnus-gethash id gnus-newsgroup-dependencies))
3292 (defun gnus-id-to-article (id)
3293 "Return the article number of ID."
3294 (let ((thread (gnus-id-to-thread id)))
3297 (mail-header-number (car thread)))))
3299 (defun gnus-id-to-header (id)
3300 "Return the article headers of ID."
3301 (car (gnus-id-to-thread id)))
3303 (defun gnus-article-displayed-root-p (article)
3304 "Say whether ARTICLE is a root(ish) article."
3305 (let ((level (gnus-summary-thread-level article))
3306 (refs (mail-header-references (gnus-summary-article-header article)))
3312 ((null (gnus-parent-id refs)) t)
3314 (null (setq particle (gnus-id-to-article
3315 (gnus-parent-id refs))))
3316 (null (gnus-summary-thread-level particle)))))))
3318 (defun gnus-root-id (id)
3319 "Return the id of the root of the thread where ID appears."
3321 (while (and id (setq prev (car (gnus-id-to-thread id))))
3323 id (gnus-parent-id (mail-header-references prev))))
3326 (defun gnus-articles-in-thread (thread)
3327 "Return the list of articles in THREAD."
3328 (cons (mail-header-number (car thread))
3329 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3331 (defun gnus-remove-thread (id &optional dont-remove)
3332 "Remove the thread that has ID in it."
3333 (let (headers thread last-id)
3334 ;; First go up in this thread until we find the root.
3335 (setq last-id (gnus-root-id id)
3336 headers (message-flatten-list (gnus-id-to-thread last-id)))
3337 ;; We have now found the real root of this thread. It might have
3338 ;; been gathered into some loose thread, so we have to search
3339 ;; through the threads to find the thread we wanted.
3340 (let ((threads gnus-newsgroup-threads)
3343 (setq sub (car threads))
3344 (if (stringp (car sub))
3345 ;; This is a gathered thread, so we look at the roots
3346 ;; below it to find whether this article is in this
3349 (setq sub (cdr sub))
3351 (when (member (caar sub) headers)
3352 (setq thread (car threads)
3355 (setq sub (cdr sub))))
3356 ;; It's an ordinary thread, so we check it.
3357 (when (eq (car sub) (car headers))
3360 (setq threads (cdr threads)))
3361 ;; If this article is in no thread, then it's a root.
3364 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3365 (setq thread (gnus-id-to-thread last-id)))
3368 thread ; We return this thread.
3370 (if (stringp (car thread))
3372 ;; If we use dummy roots, then we have to remove the
3373 ;; dummy root as well.
3374 (when (eq gnus-summary-make-false-root 'dummy)
3375 ;; We go to the dummy root by going to
3376 ;; the first sub-"thread", and then one line up.
3377 (gnus-summary-goto-article
3378 (mail-header-number (caadr thread)))
3381 (gnus-data-compute-positions))
3382 (setq thread (cdr thread))
3384 (gnus-remove-thread-1 (car thread))
3385 (setq thread (cdr thread))))
3386 (gnus-remove-thread-1 thread))))))))
3388 (defun gnus-remove-thread-1 (thread)
3389 "Remove the thread THREAD recursively."
3390 (let ((number (mail-header-number (pop thread)))
3392 (setq thread (reverse thread))
3394 (gnus-remove-thread-1 (pop thread)))
3395 (when (setq d (gnus-data-find number))
3396 (goto-char (gnus-data-pos d))
3399 (- (gnus-point-at-bol)
3401 (1+ (gnus-point-at-eol))
3402 (gnus-delete-line)))))))
3404 (defun gnus-sort-threads (threads)
3406 (if (not gnus-thread-sort-functions)
3408 (gnus-message 8 "Sorting threads...")
3410 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3411 (gnus-message 8 "Sorting threads...done"))))
3413 (defun gnus-sort-articles (articles)
3415 (when gnus-article-sort-functions
3416 (gnus-message 7 "Sorting articles...")
3418 (setq gnus-newsgroup-headers
3419 (sort articles (gnus-make-sort-function
3420 gnus-article-sort-functions)))
3421 (gnus-message 7 "Sorting articles...done"))))
3423 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3424 (defmacro gnus-thread-header (thread)
3425 ;; Return header of first article in THREAD.
3426 ;; Note that THREAD must never, ever be anything else than a variable -
3427 ;; using some other form will lead to serious barfage.
3428 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3429 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3430 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
3433 (defsubst gnus-article-sort-by-number (h1 h2)
3434 "Sort articles by article number."
3435 (< (mail-header-number h1)
3436 (mail-header-number h2)))
3438 (defun gnus-thread-sort-by-number (h1 h2)
3439 "Sort threads by root article number."
3440 (gnus-article-sort-by-number
3441 (gnus-thread-header h1) (gnus-thread-header h2)))
3443 (defsubst gnus-article-sort-by-lines (h1 h2)
3444 "Sort articles by article Lines header."
3445 (< (mail-header-lines h1)
3446 (mail-header-lines h2)))
3448 (defun gnus-thread-sort-by-lines (h1 h2)
3449 "Sort threads by root article Lines header."
3450 (gnus-article-sort-by-lines
3451 (gnus-thread-header h1) (gnus-thread-header h2)))
3453 (defsubst gnus-article-sort-by-author (h1 h2)
3454 "Sort articles by root author."
3456 (let ((extract (funcall
3457 gnus-extract-address-components
3458 (mail-header-from h1))))
3459 (or (car extract) (cadr extract) ""))
3460 (let ((extract (funcall
3461 gnus-extract-address-components
3462 (mail-header-from h2))))
3463 (or (car extract) (cadr extract) ""))))
3465 (defun gnus-thread-sort-by-author (h1 h2)
3466 "Sort threads by root author."
3467 (gnus-article-sort-by-author
3468 (gnus-thread-header h1) (gnus-thread-header h2)))
3470 (defsubst gnus-article-sort-by-subject (h1 h2)
3471 "Sort articles by root subject."
3473 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3474 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3476 (defun gnus-thread-sort-by-subject (h1 h2)
3477 "Sort threads by root subject."
3478 (gnus-article-sort-by-subject
3479 (gnus-thread-header h1) (gnus-thread-header h2)))
3481 (defsubst gnus-article-sort-by-date (h1 h2)
3482 "Sort articles by root article date."
3484 (gnus-date-get-time (mail-header-date h1))
3485 (gnus-date-get-time (mail-header-date h2))))
3487 (defun gnus-thread-sort-by-date (h1 h2)
3488 "Sort threads by root article date."
3489 (gnus-article-sort-by-date
3490 (gnus-thread-header h1) (gnus-thread-header h2)))
3492 (defsubst gnus-article-sort-by-score (h1 h2)
3493 "Sort articles by root article score.
3494 Unscored articles will be counted as having a score of zero."
3495 (> (or (cdr (assq (mail-header-number h1)
3496 gnus-newsgroup-scored))
3497 gnus-summary-default-score 0)
3498 (or (cdr (assq (mail-header-number h2)
3499 gnus-newsgroup-scored))
3500 gnus-summary-default-score 0)))
3502 (defun gnus-thread-sort-by-score (h1 h2)
3503 "Sort threads by root article score."
3504 (gnus-article-sort-by-score
3505 (gnus-thread-header h1) (gnus-thread-header h2)))
3507 (defun gnus-thread-sort-by-total-score (h1 h2)
3508 "Sort threads by the sum of all scores in the thread.
3509 Unscored articles will be counted as having a score of zero."
3510 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3512 (defun gnus-thread-total-score (thread)
3513 ;; This function find the total score of THREAD.
3514 (cond ((null thread)
3517 (if (stringp (car thread))
3518 (apply gnus-thread-score-function 0
3519 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3520 (gnus-thread-total-score-1 thread)))
3522 (gnus-thread-total-score-1 (list thread)))))
3524 (defun gnus-thread-total-score-1 (root)
3525 ;; This function find the total score of the thread below ROOT.
3526 (setq root (car root))
3527 (apply gnus-thread-score-function
3529 (mapcar 'gnus-thread-total-score
3530 (cdr (gnus-id-to-thread (mail-header-id root))))
3531 (when (> (mail-header-number root) 0)
3532 (list (or (cdr (assq (mail-header-number root)
3533 gnus-newsgroup-scored))
3534 gnus-summary-default-score 0))))
3535 (list gnus-summary-default-score)
3538 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3539 (defvar gnus-tmp-prev-subject nil)
3540 (defvar gnus-tmp-false-parent nil)
3541 (defvar gnus-tmp-root-expunged nil)
3542 (defvar gnus-tmp-dummy-line nil)
3544 (defun gnus-summary-prepare-threads (threads)
3545 "Prepare summary buffer from THREADS and indentation LEVEL.
3546 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3547 or a straight list of headers."
3548 (gnus-message 7 "Generating summary...")
3550 (setq gnus-newsgroup-threads threads)
3553 (let ((gnus-tmp-level 0)
3554 (default-score (or gnus-summary-default-score 0))
3555 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3556 thread number subject stack state gnus-tmp-gathered beg-match
3557 new-roots gnus-tmp-new-adopts thread-end
3558 gnus-tmp-header gnus-tmp-unread
3559 gnus-tmp-replied gnus-tmp-subject-or-nil
3560 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3561 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3562 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3564 (setq gnus-tmp-prev-subject nil)
3566 (if (vectorp (car threads))
3567 ;; If this is a straight (sic) list of headers, then a
3568 ;; threaded summary display isn't required, so we just create
3569 ;; an unthreaded one.
3570 (gnus-summary-prepare-unthreaded threads)
3572 ;; Do the threaded display.
3574 (while (or threads stack gnus-tmp-new-adopts new-roots)
3576 (if (and (= gnus-tmp-level 0)
3579 (not gnus-tmp-false-parent)
3580 (or gnus-tmp-new-adopts new-roots))
3581 (if gnus-tmp-new-adopts
3582 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3583 thread (list (car gnus-tmp-new-adopts))
3584 gnus-tmp-header (caar thread)
3585 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3587 (setq thread (list (car new-roots))
3588 gnus-tmp-header (caar thread)
3589 new-roots (cdr new-roots))))
3592 ;; If there are some threads, we do them before the
3593 ;; threads on the stack.
3594 (setq thread threads
3595 gnus-tmp-header (caar thread))
3596 ;; There were no current threads, so we pop something off
3598 (setq state (car stack)
3599 gnus-tmp-level (car state)
3602 gnus-tmp-header (caar thread))))
3604 (setq gnus-tmp-false-parent nil)
3605 (setq gnus-tmp-root-expunged nil)
3606 (setq thread-end nil)
3608 (if (stringp gnus-tmp-header)
3609 ;; The header is a dummy root.
3611 ((eq gnus-summary-make-false-root 'adopt)
3612 ;; We let the first article adopt the rest.
3613 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3615 (setq gnus-tmp-gathered
3617 (lambda (h) (mail-header-number (car h)))
3620 (setq thread (cons (list (caar thread)
3623 (setq gnus-tmp-level -1
3624 gnus-tmp-false-parent t))
3625 ((eq gnus-summary-make-false-root 'empty)
3626 ;; We print adopted articles with empty subject fields.
3627 (setq gnus-tmp-gathered
3629 (lambda (h) (mail-header-number (car h)))
3632 (setq gnus-tmp-level -1))
3633 ((eq gnus-summary-make-false-root 'dummy)
3634 ;; We remember that we probably want to output a dummy
3636 (setq gnus-tmp-dummy-line gnus-tmp-header)
3637 (setq gnus-tmp-prev-subject gnus-tmp-header))
3639 ;; We do not make a root for the gathered
3640 ;; sub-threads at all.
3641 (setq gnus-tmp-level -1)))
3643 (setq number (mail-header-number gnus-tmp-header)
3644 subject (mail-header-subject gnus-tmp-header))
3647 ;; If the thread has changed subject, we might want to make
3648 ;; this subthread into a root.
3649 ((and (null gnus-thread-ignore-subject)
3650 (not (zerop gnus-tmp-level))
3651 gnus-tmp-prev-subject
3653 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3654 (setq new-roots (nconc new-roots (list (car thread)))
3656 gnus-tmp-header nil))
3657 ;; If the article lies outside the current limit,
3658 ;; then we do not display it.
3659 ((not (memq number gnus-newsgroup-limit))
3660 (setq gnus-tmp-gathered
3662 (lambda (h) (mail-header-number (car h)))
3665 (setq gnus-tmp-new-adopts (if (cdar thread)
3666 (append gnus-tmp-new-adopts
3668 gnus-tmp-new-adopts)
3670 gnus-tmp-header nil)
3671 (when (zerop gnus-tmp-level)
3672 (setq gnus-tmp-root-expunged t)))
3673 ;; Perhaps this article is to be marked as read?
3674 ((and gnus-summary-mark-below
3675 (< (or (cdr (assq number gnus-newsgroup-scored))
3677 gnus-summary-mark-below)
3678 ;; Don't touch sparse articles.
3679 (not (gnus-summary-article-sparse-p number))
3680 (not (gnus-summary-article-ancient-p number)))
3681 (setq gnus-newsgroup-unreads
3682 (delq number gnus-newsgroup-unreads))
3683 (if gnus-newsgroup-auto-expire
3684 (push number gnus-newsgroup-expirable)
3685 (push (cons number gnus-low-score-mark)
3686 gnus-newsgroup-reads))))
3688 (when gnus-tmp-header
3689 ;; We may have an old dummy line to output before this
3691 (when (and gnus-tmp-dummy-line
3694 (mail-header-subject gnus-tmp-header)))
3695 (gnus-summary-insert-dummy-line
3696 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3697 (setq gnus-tmp-dummy-line nil))
3699 ;; Compute the mark.
3700 (setq gnus-tmp-unread (gnus-article-mark number))
3702 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3703 gnus-tmp-header gnus-tmp-level)
3704 gnus-newsgroup-data)
3706 ;; Actually insert the line.
3708 gnus-tmp-subject-or-nil
3710 ((and gnus-thread-ignore-subject
3711 gnus-tmp-prev-subject
3712 (not (inline (gnus-subject-equal
3713 gnus-tmp-prev-subject subject))))
3715 ((zerop gnus-tmp-level)
3716 (if (and (eq gnus-summary-make-false-root 'empty)
3717 (memq number gnus-tmp-gathered)
3718 gnus-tmp-prev-subject
3719 (inline (gnus-subject-equal
3720 gnus-tmp-prev-subject subject)))
3721 gnus-summary-same-subject
3723 (t gnus-summary-same-subject)))
3724 (if (and (eq gnus-summary-make-false-root 'adopt)
3725 (= gnus-tmp-level 1)
3726 (memq number gnus-tmp-gathered))
3727 (setq gnus-tmp-opening-bracket ?\<
3728 gnus-tmp-closing-bracket ?\>)
3729 (setq gnus-tmp-opening-bracket ?\[
3730 gnus-tmp-closing-bracket ?\]))
3732 gnus-tmp-indentation
3733 (aref gnus-thread-indent-array gnus-tmp-level)
3734 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3735 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3736 gnus-summary-default-score 0)
3738 (if (or (null gnus-summary-default-score)
3739 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3740 gnus-summary-zcore-fuzz))
3742 (if (< gnus-tmp-score gnus-summary-default-score)
3743 gnus-score-below-mark gnus-score-over-mark))
3745 (cond ((memq number gnus-newsgroup-processable)
3747 ((memq number gnus-newsgroup-cached)
3749 ((memq number gnus-newsgroup-replied)
3751 ((memq number gnus-newsgroup-saved)
3753 (t gnus-unread-mark))
3754 gnus-tmp-from (mail-header-from gnus-tmp-header)
3757 ((string-match "<[^>]+> *$" gnus-tmp-from)
3758 (setq beg-match (match-beginning 0))
3759 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3760 (substring gnus-tmp-from (1+ (match-beginning 0))
3761 (1- (match-end 0))))
3762 (substring gnus-tmp-from 0 beg-match)))
3763 ((string-match "(.+)" gnus-tmp-from)
3764 (substring gnus-tmp-from
3765 (1+ (match-beginning 0)) (1- (match-end 0))))
3767 (when (string= gnus-tmp-name "")
3768 (setq gnus-tmp-name gnus-tmp-from))
3769 (unless (numberp gnus-tmp-lines)
3770 (setq gnus-tmp-lines 0))
3771 (gnus-put-text-property-excluding-characters-with-faces
3773 (progn (eval gnus-summary-line-format-spec) (point))
3774 'gnus-number number)
3777 (gnus-run-hooks 'gnus-summary-update-hook)
3780 (setq gnus-tmp-prev-subject subject)))
3782 (when (nth 1 thread)
3783 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3784 (incf gnus-tmp-level)
3785 (setq threads (if thread-end nil (cdar thread)))
3787 (setq gnus-tmp-level 0)))))
3788 (gnus-message 7 "Generating summary...done"))
3790 (defun gnus-summary-prepare-unthreaded (headers)
3791 "Generate an unthreaded summary buffer based on HEADERS."
3792 (let (header number mark)
3797 ;; We may have to root out some bad articles...
3798 (when (memq (setq number (mail-header-number
3799 (setq header (pop headers))))
3800 gnus-newsgroup-limit)
3801 ;; Mark article as read when it has a low score.
3802 (when (and gnus-summary-mark-below
3803 (< (or (cdr (assq number gnus-newsgroup-scored))
3804 gnus-summary-default-score 0)
3805 gnus-summary-mark-below)
3806 (not (gnus-summary-article-ancient-p number)))
3807 (setq gnus-newsgroup-unreads
3808 (delq number gnus-newsgroup-unreads))
3809 (if gnus-newsgroup-auto-expire
3810 (push number gnus-newsgroup-expirable)
3811 (push (cons number gnus-low-score-mark)
3812 gnus-newsgroup-reads)))
3814 (setq mark (gnus-article-mark number))
3815 (push (gnus-data-make number mark (1+ (point)) header 0)
3816 gnus-newsgroup-data)
3817 (gnus-summary-insert-line
3819 mark (memq number gnus-newsgroup-replied)
3820 (memq number gnus-newsgroup-expirable)
3821 (mail-header-subject header) nil
3822 (cdr (assq number gnus-newsgroup-scored))
3823 (memq number gnus-newsgroup-processable))))))
3825 (defun gnus-select-newsgroup (group &optional read-all select-articles)
3826 "Select newsgroup GROUP.
3827 If READ-ALL is non-nil, all articles in the group are selected.
3828 If SELECT-ARTICLES, only select those articles from GROUP."
3829 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3830 ;;!!! Dirty hack; should be removed.
3831 (gnus-summary-ignore-duplicates
3832 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
3834 gnus-summary-ignore-duplicates))
3835 (info (nth 2 entry))
3836 articles fetched-articles cached)
3838 (unless (gnus-check-server
3839 (setq gnus-current-select-method
3840 (gnus-find-method-for-group group)))
3841 (error "Couldn't open server"))
3843 (or (and entry (not (eq (car entry) t))) ; Either it's active...
3844 (gnus-activate-group group) ; Or we can activate it...
3845 (progn ; Or we bug out.
3846 (when (equal major-mode 'gnus-summary-mode)
3847 (kill-buffer (current-buffer)))
3848 (error "Couldn't request group %s: %s"
3849 group (gnus-status-message group))))
3851 (unless (gnus-request-group group t)
3852 (when (equal major-mode 'gnus-summary-mode)
3853 (kill-buffer (current-buffer)))
3854 (error "Couldn't request group %s: %s"
3855 group (gnus-status-message group)))
3857 (setq gnus-newsgroup-name group)
3858 (setq gnus-newsgroup-unselected nil)
3859 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
3861 ;; Adjust and set lists of article marks.
3863 (gnus-adjust-marked-articles info))
3865 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3866 (when (gnus-virtual-group-p group)
3867 (setq cached gnus-newsgroup-cached))
3869 (setq gnus-newsgroup-unreads
3870 (gnus-set-difference
3871 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
3872 gnus-newsgroup-dormant))
3874 (setq gnus-newsgroup-processable nil)
3876 (gnus-update-read-articles group gnus-newsgroup-unreads)
3878 (if (setq articles select-articles)
3879 (setq gnus-newsgroup-unselected
3880 (gnus-sorted-intersection
3881 gnus-newsgroup-unreads
3882 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
3883 (setq articles (gnus-articles-to-read group read-all)))
3887 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
3889 ((eq articles 0) nil)
3891 ;; Init the dependencies hash table.
3892 (setq gnus-newsgroup-dependencies
3893 (gnus-make-hashtable (length articles)))
3894 ;; Retrieve the headers and read them in.
3895 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
3896 (setq gnus-newsgroup-headers
3898 (setq gnus-headers-retrieved-by
3899 (gnus-retrieve-headers
3900 articles gnus-newsgroup-name
3901 ;; We might want to fetch old headers, but
3902 ;; not if there is only 1 article.
3904 (not (eq gnus-fetch-old-headers 'some))
3905 (not (numberp gnus-fetch-old-headers)))
3906 (> (length articles) 1))
3907 gnus-fetch-old-headers))))
3908 (gnus-get-newsgroup-headers-xover
3909 articles nil nil gnus-newsgroup-name t)
3910 (gnus-get-newsgroup-headers)))
3911 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
3913 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3915 (setq gnus-newsgroup-cached cached))
3917 ;; Suppress duplicates?
3918 (when gnus-suppress-duplicates
3919 (gnus-dup-suppress-articles))
3921 ;; Set the initial limit.
3922 (setq gnus-newsgroup-limit (copy-sequence articles))
3923 ;; Remove canceled articles from the list of unread articles.
3924 (setq gnus-newsgroup-unreads
3925 (gnus-set-sorted-intersection
3926 gnus-newsgroup-unreads
3927 (setq fetched-articles
3928 (mapcar (lambda (headers) (mail-header-number headers))
3929 gnus-newsgroup-headers))))
3930 ;; Removed marked articles that do not exist.
3931 (gnus-update-missing-marks
3932 (gnus-sorted-complement fetched-articles articles))
3933 ;; We might want to build some more threads first.
3934 (when (and gnus-fetch-old-headers
3935 (eq gnus-headers-retrieved-by 'nov))
3936 (if (eq gnus-fetch-old-headers 'invisible)
3937 (gnus-build-all-threads)
3938 (gnus-build-old-threads)))
3939 ;; Let the Gnus agent mark articles as read.
3941 (gnus-agent-get-undownloaded-list))
3942 ;; Check whether auto-expire is to be done in this group.
3943 (setq gnus-newsgroup-auto-expire
3944 (gnus-group-auto-expirable-p group))
3945 ;; Set up the article buffer now, if necessary.
3946 (unless gnus-single-article-buffer
3947 (gnus-article-setup-buffer))
3948 ;; First and last article in this newsgroup.
3949 (when gnus-newsgroup-headers
3950 (setq gnus-newsgroup-begin
3951 (mail-header-number (car gnus-newsgroup-headers))
3954 (gnus-last-element gnus-newsgroup-headers))))
3955 ;; GROUP is successfully selected.
3956 (or gnus-newsgroup-headers t)))))
3958 (defun gnus-articles-to-read (group &optional read-all)
3959 ;; Find out what articles the user wants to read.
3961 ;; Select all articles if `read-all' is non-nil, or if there
3962 ;; are no unread articles.
3964 (and (zerop (length gnus-newsgroup-marked))
3965 (zerop (length gnus-newsgroup-unreads)))
3966 (eq (gnus-group-find-parameter group 'display)
3968 (gnus-uncompress-range (gnus-active group))
3969 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
3970 (copy-sequence gnus-newsgroup-unreads))
3972 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
3973 (scored (length scored-list))
3974 (number (length articles))
3975 (marked (+ (length gnus-newsgroup-marked)
3976 (length gnus-newsgroup-dormant)))
3984 ((and (or (<= scored marked) (= scored number))
3985 (numberp gnus-large-newsgroup)
3986 (> number gnus-large-newsgroup))
3990 "How many articles from %s (default %d): "
3991 (gnus-limit-string gnus-newsgroup-name 35)
3993 (if (string-match "^[ \t]*$" input) number input)))
3994 ((and (> scored marked) (< scored number)
3995 (> (- scored number) 20))
3998 (format "%s %s (%d scored, %d total): "
3999 "How many articles from"
4000 group scored number))))
4001 (if (string-match "^[ \t]*$" input)
4005 (setq select (if (stringp select) (string-to-number select) select))
4006 (if (or (null select) (zerop select))
4008 (if (and (not (zerop scored)) (<= (abs select) scored))
4010 (setq articles (sort scored-list '<))
4011 (setq number (length articles)))
4012 (setq articles (copy-sequence articles)))
4014 (when (< (abs select) number)
4016 ;; Select the N oldest articles.
4017 (setcdr (nthcdr (1- (abs select)) articles) nil)
4018 ;; Select the N most recent articles.
4019 (setq articles (nthcdr (- number select) articles))))
4020 (setq gnus-newsgroup-unselected
4021 (gnus-sorted-intersection
4022 gnus-newsgroup-unreads
4023 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4026 (defun gnus-killed-articles (killed articles)
4029 (when (inline (gnus-member-of-range (car articles) killed))
4030 (push (car articles) out))
4031 (setq articles (cdr articles)))
4034 (defun gnus-uncompress-marks (marks)
4035 "Uncompress the mark ranges in MARKS."
4036 (let ((uncompressed '(score bookmark))
4039 (if (memq (caar marks) uncompressed)
4040 (push (car marks) out)
4041 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4042 (setq marks (cdr marks)))
4045 (defun gnus-adjust-marked-articles (info)
4046 "Set all article lists and remove all marks that are no longer legal."
4047 (let* ((marked-lists (gnus-info-marks info))
4048 (active (gnus-active (gnus-info-group info)))
4051 (types gnus-article-mark-lists)
4052 (uncompressed '(score bookmark killed))
4053 marks var articles article mark)
4056 (setq marks (pop marked-lists))
4057 (set (setq var (intern (format "gnus-newsgroup-%s"
4058 (car (rassq (setq mark (car marks))
4060 (if (memq (car marks) uncompressed) (cdr marks)
4061 (gnus-uncompress-range (cdr marks))))
4063 (setq articles (symbol-value var))
4065 ;; All articles have to be subsets of the active articles.
4067 ;; Adjust "simple" lists.
4068 ((memq mark '(tick dormant expire reply save))
4070 (when (or (< (setq article (pop articles)) min) (> article max))
4071 (set var (delq article (symbol-value var))))))
4073 ((memq mark uncompressed)
4074 (when (not (listp (cdr (symbol-value var))))
4075 (set var (list (symbol-value var))))
4076 (when (not (listp (cdr articles)))
4077 (setq articles (list articles)))
4079 (when (or (not (consp (setq article (pop articles))))
4080 (< (car article) min)
4081 (> (car article) max))
4082 (set var (delq article (symbol-value var))))))))))
4084 (defun gnus-update-missing-marks (missing)
4085 "Go through the list of MISSING articles and remove them from the mark lists."
4087 (let ((types gnus-article-mark-lists)
4089 ;; Go through all types.
4091 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4092 (when (symbol-value var)
4093 ;; This list has articles. So we delete all missing articles
4097 (set var (delq (pop m) (symbol-value var)))))))))
4099 (defun gnus-update-marks ()
4100 "Enter the various lists of marked articles into the newsgroup info list."
4101 (let ((types gnus-article-mark-lists)
4102 (info (gnus-get-info gnus-newsgroup-name))
4103 (uncompressed '(score bookmark killed))
4104 type list newmarked symbol)
4106 ;; Add all marks lists that are non-nil to the list of marks lists.
4107 (while (setq type (pop types))
4108 (when (setq list (symbol-value
4110 (intern (format "gnus-newsgroup-%s"
4113 ;; Get rid of the entries of the articles that have the
4115 (when (and (eq (cdr type) 'score)
4119 (prev (cons nil list))
4122 (if (or (not (consp (car arts)))
4123 (= (cdar arts) gnus-summary-default-score))
4124 (setcdr prev (cdr arts))
4126 (setq arts (cdr arts)))
4127 (setq list (cdr all))))
4129 (push (cons (cdr type)
4130 (if (memq (cdr type) uncompressed) list
4131 (gnus-compress-sequence
4132 (set symbol (sort list '<)) t)))
4135 ;; Enter these new marks into the info of the group.
4137 (setcar (nthcdr 3 info) newmarked)
4138 ;; Add the marks lists to the end of the info.
4140 (setcdr (nthcdr 2 info) (list newmarked))))
4142 ;; Cut off the end of the info if there's nothing else there.
4146 (when (nthcdr (decf i) info)
4147 (setcdr (nthcdr i info) nil)))))))
4149 (defun gnus-set-mode-line (where)
4150 "This function sets the mode line of the article or summary buffers.
4151 If WHERE is `summary', the summary mode line format will be used."
4152 ;; Is this mode line one we keep updated?
4153 (when (memq where gnus-updated-mode-lines)
4156 ;; We evaluate this in the summary buffer since these
4157 ;; variables are buffer-local to that buffer.
4158 (set-buffer gnus-summary-buffer)
4159 ;; We bind all these variables that are used in the `eval' form
4161 (let* ((mformat (symbol-value
4163 (format "gnus-%s-mode-line-format-spec" where))))
4164 (gnus-tmp-group-name gnus-newsgroup-name)
4165 (gnus-tmp-article-number (or gnus-current-article 0))
4166 (gnus-tmp-unread gnus-newsgroup-unreads)
4167 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4168 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4169 (gnus-tmp-unread-and-unselected
4170 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4171 (zerop gnus-tmp-unselected))
4173 ((zerop gnus-tmp-unselected)
4174 (format "{%d more}" gnus-tmp-unread-and-unticked))
4175 (t (format "{%d(+%d) more}"
4176 gnus-tmp-unread-and-unticked
4177 gnus-tmp-unselected))))
4179 (if (and gnus-current-headers
4180 (vectorp gnus-current-headers))
4181 (gnus-mode-string-quote
4182 (mail-header-subject gnus-current-headers))
4184 bufname-length max-len
4185 gnus-tmp-header);; passed as argument to any user-format-funcs
4186 (setq mode-string (eval mformat))
4187 (setq bufname-length (if (string-match "%b" mode-string)
4190 (if (eq where 'summary)
4192 (get-buffer gnus-article-buffer))))
4195 (setq max-len (max 4 (if gnus-mode-non-string-length
4197 gnus-mode-non-string-length
4199 (length mode-string))))
4200 ;; We might have to chop a bit of the string off...
4201 (when (> (length mode-string) max-len)
4203 (concat (truncate-string mode-string (- max-len 3))
4205 ;; Pad the mode string a bit.
4206 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4207 ;; Update the mode line.
4208 (setq mode-line-buffer-identification
4209 (gnus-mode-line-buffer-identification (list mode-string)))
4210 (set-buffer-modified-p t))))
4212 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4213 "Go through the HEADERS list and add all Xrefs to a hash table.
4214 The resulting hash table is returned, or nil if no Xrefs were found."
4215 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4216 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4217 (xref-hashtb (gnus-make-hashtable))
4218 start group entry number xrefs header)
4220 (setq header (pop headers))
4221 (when (and (setq xrefs (mail-header-xref header))
4222 (not (memq (setq number (mail-header-number header))
4225 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4226 (setq start (match-end 0))
4227 (setq group (if prefix
4228 (concat prefix (substring xrefs (match-beginning 1)
4230 (substring xrefs (match-beginning 1) (match-end 1))))
4232 (string-to-int (substring xrefs (match-beginning 2)
4234 (if (setq entry (gnus-gethash group xref-hashtb))
4235 (setcdr entry (cons number (cdr entry)))
4236 (gnus-sethash group (cons number nil) xref-hashtb)))))
4237 (and start xref-hashtb)))
4239 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4240 "Look through all the headers and mark the Xrefs as read."
4241 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4242 name entry info xref-hashtb idlist method nth4)
4244 (set-buffer gnus-group-buffer)
4245 (when (setq xref-hashtb
4246 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4249 (unless (string= from-newsgroup (setq name (symbol-name group)))
4250 (setq idlist (symbol-value group))
4251 ;; Dead groups are not updated.
4253 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4255 (when (stringp (setq nth4 (gnus-info-method info)))
4256 (setq nth4 (gnus-server-to-method nth4))))
4257 ;; Only do the xrefs if the group has the same
4258 ;; select method as the group we have just read.
4259 (or (gnus-methods-equal-p
4260 nth4 (gnus-find-method-for-group from-newsgroup))
4262 (equal nth4 (setq method (gnus-find-method-for-group
4264 (and (equal (car nth4) (car method))
4265 (equal (nth 1 nth4) (nth 1 method))))
4266 gnus-use-cross-reference
4267 (or (not (eq gnus-use-cross-reference t))
4269 ;; Only do cross-references on subscribed
4270 ;; groups, if that is what is wanted.
4271 (<= (gnus-info-level info) gnus-level-subscribed))
4272 (gnus-group-make-articles-read name idlist))))
4275 (defun gnus-compute-read-articles (group articles)
4276 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4277 (info (nth 2 entry))
4278 (active (gnus-active group))
4281 ;; First peel off all illegal article numbers.
4283 (let ((ids articles)
4285 (while (setq id (pop ids))
4286 (when (and first (> id (cdr active)))
4287 ;; We'll end up in this situation in one particular
4288 ;; obscure situation. If you re-scan a group and get
4289 ;; a new article that is cross-posted to a different
4290 ;; group that has not been re-scanned, you might get
4291 ;; crossposted article that has a higher number than
4292 ;; Gnus believes possible. So we re-activate this
4293 ;; group as well. This might mean doing the
4294 ;; crossposting thingy will *increase* the number
4295 ;; of articles in some groups. Tsk, tsk.
4296 (setq active (or (gnus-activate-group group) active)))
4297 (when (or (> id (cdr active))
4298 (< id (car active)))
4299 (setq articles (delq id articles))))))
4300 ;; If the read list is nil, we init it.
4302 (null (gnus-info-read info))
4304 (setq ninfo (cons 1 (1- (car active))))
4305 (setq ninfo (gnus-info-read info)))
4306 ;; Then we add the read articles to the range.
4308 ninfo (setq articles (sort articles '<))))))
4310 (defun gnus-group-make-articles-read (group articles)
4311 "Update the info of GROUP to say that ARTICLES are read."
4313 (entry (gnus-gethash group gnus-newsrc-hashtb))
4314 (info (nth 2 entry))
4315 (active (gnus-active group))
4318 (setq range (gnus-compute-read-articles group articles))
4320 (set-buffer gnus-group-buffer)
4323 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4324 (gnus-info-set-read ',info ',(gnus-info-read info))
4325 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4326 (gnus-group-update-group ,group t))))
4327 ;; Add the read articles to the range.
4328 (gnus-info-set-read info range)
4329 ;; Then we have to re-compute how many unread
4330 ;; articles there are in this group.
4334 (setq num (- (1+ (cdr active)) (car active))))
4335 ((not (listp (cdr range)))
4336 (setq num (- (cdr active) (- (1+ (cdr range))
4340 (if (numberp (car range))
4342 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4343 (setq range (cdr range)))
4344 (setq num (- (cdr active) num))))
4345 ;; Update the number of unread articles.
4347 ;; Update the group buffer.
4348 (gnus-group-update-group group t)))))
4350 (defun gnus-methods-equal-p (m1 m2)
4351 (let ((m1 (or m1 gnus-select-method))
4352 (m2 (or m2 gnus-select-method)))
4354 (and (eq (car m1) (car m2))
4355 (or (not (memq 'address (assoc (symbol-name (car m1))
4356 gnus-valid-select-methods)))
4357 (equal (nth 1 m1) (nth 1 m2)))))))
4359 (defvar gnus-newsgroup-none-id 0)
4361 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4362 (let ((cur nntp-server-buffer)
4365 (save-excursion (set-buffer gnus-summary-buffer)
4366 gnus-newsgroup-dependencies)))
4369 (set-buffer nntp-server-buffer)
4370 ;; Translate all TAB characters into SPACE characters.
4371 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4372 (gnus-run-hooks 'gnus-parse-headers-hook)
4373 (let ((case-fold-search t)
4374 in-reply-to header p lines chars)
4375 (goto-char (point-min))
4376 ;; Search to the beginning of the next header. Error messages
4377 ;; do not begin with 2 or 3.
4378 (while (re-search-forward "^[23][0-9]+ " nil t)
4381 ;; This implementation of this function, with nine
4382 ;; search-forwards instead of the one re-search-forward and
4383 ;; a case (which basically was the old function) is actually
4384 ;; about twice as fast, even though it looks messier. You
4385 ;; can't have everything, I guess. Speed and elegance
4386 ;; doesn't always go hand in hand.
4395 (narrow-to-region (point)
4396 (or (and (search-forward "\n.\n" nil t)
4402 (if (search-forward "\nsubject: " nil t)
4403 (rfc2047-decode-string (nnheader-header-value))
4408 (if (search-forward "\nfrom: " nil t)
4409 (rfc2047-decode-string (nnheader-header-value))
4414 (if (search-forward "\ndate: " nil t)
4415 (nnheader-header-value) ""))
4419 (setq id (if (re-search-forward
4420 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4421 ;; We do it this way to make sure the Message-ID
4422 ;; is (somewhat) syntactically valid.
4423 (buffer-substring (match-beginning 1)
4425 ;; If there was no message-id, we just fake one
4426 ;; to make subsequent routines simpler.
4427 (nnheader-generate-fake-message-id))))
4431 (if (search-forward "\nreferences: " nil t)
4435 (nnheader-header-value)
4440 (search-backward ">" end t)
4443 (search-backward "<" end t)
4445 ;; Get the references from the in-reply-to header if there
4446 ;; were no references and the in-reply-to header looks
4448 (if (and (search-forward "\nin-reply-to: " nil t)
4449 (setq in-reply-to (nnheader-header-value))
4450 (string-match "<[^>]+>" in-reply-to))
4452 (setq ref (substring in-reply-to (match-beginning 0)
4454 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4455 (setq ref2 (substring in-reply-to (match-beginning 0)
4457 (when (> (length ref2) (length ref))
4464 (if (search-forward "\nchars: " nil t)
4465 (if (numberp (setq chars (ignore-errors (read cur))))
4471 (if (search-forward "\nlines: " nil t)
4472 (if (numberp (setq lines (ignore-errors (read cur))))
4478 (and (search-forward "\nxref: " nil t)
4479 (nnheader-header-value)))))
4480 (when (equal id ref)
4483 (when gnus-alter-header-function
4484 (funcall gnus-alter-header-function header)
4485 (setq id (mail-header-id header)
4486 ref (gnus-parent-id (mail-header-references header))))
4489 (gnus-dependencies-add-header
4490 header dependencies force-new))
4491 (push header headers))
4492 (goto-char (point-max))
4494 (nreverse headers)))))
4496 ;; Goes through the xover lines and returns a list of vectors
4497 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4498 force-new dependencies
4499 group also-fetch-heads)
4500 "Parse the news overview data in the server buffer, and return a
4501 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4502 ;; Get the Xref when the users reads the articles since most/some
4503 ;; NNTP servers do not include Xrefs when using XOVER.
4504 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4505 (let ((cur nntp-server-buffer)
4506 (dependencies (or dependencies gnus-newsgroup-dependencies))
4507 number headers header)
4509 (set-buffer nntp-server-buffer)
4510 ;; Allow the user to mangle the headers before parsing them.
4511 (gnus-run-hooks 'gnus-parse-headers-hook)
4512 (goto-char (point-min))
4515 (while (and sequence (not (eobp)))
4516 (setq number (read cur))
4517 (while (and sequence
4518 (< (car sequence) number))
4519 (setq sequence (cdr sequence)))
4521 (eq number (car sequence))
4523 (setq sequence (cdr sequence))
4524 (setq header (inline
4525 (gnus-nov-parse-line
4526 number dependencies force-new))))
4527 (push header headers))
4530 ; (gnus-error 4 "Strange nov line (%d)"
4531 ; (count-lines (point-min) (point))))
4534 ;; A common bug in inn is that if you have posted an article and
4535 ;; then retrieves the active file, it will answer correctly --
4536 ;; the new article is included. However, a NOV entry for the
4537 ;; article may not have been generated yet, so this may fail.
4538 ;; We work around this problem by retrieving the last few
4539 ;; headers using HEAD.
4540 (if (or (not also-fetch-heads)
4542 ;; We (probably) got all the headers.
4544 (let ((gnus-nov-is-evil t))
4547 (when (gnus-retrieve-headers sequence group)
4548 (gnus-get-newsgroup-headers))))))))
4550 (defun gnus-article-get-xrefs ()
4551 "Fill in the Xref value in `gnus-current-headers', if necessary.
4552 This is meant to be called in `gnus-article-internal-prepare-hook'."
4553 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4554 gnus-current-headers)))
4555 (or (not gnus-use-cross-reference)
4557 (and (mail-header-xref headers)
4558 (not (string= (mail-header-xref headers) "")))
4559 (let ((case-fold-search t)
4562 (nnheader-narrow-to-headers)
4563 (goto-char (point-min))
4564 (when (or (and (eq (downcase (following-char)) ?x)
4565 (looking-at "Xref:"))
4566 (search-forward "\nXref:" nil t))
4567 (goto-char (1+ (match-end 0)))
4568 (setq xref (buffer-substring (point)
4569 (progn (end-of-line) (point))))
4570 (mail-header-set-xref headers xref)))))))
4572 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4573 "Find article ID and insert the summary line for that article.
4574 OLD-HEADER can either be a header or a line number to insert
4575 the subject line on."
4576 (let* ((line (and (numberp old-header) old-header))
4577 (old-header (and (vectorp old-header) old-header))
4578 (header (cond ((and old-header use-old-header)
4581 (gnus-number-to-header id))
4582 (gnus-number-to-header id))
4584 (gnus-read-header id))))
4585 (number (and (numberp id) id))
4588 ;; Rebuild the thread that this article is part of and go to the
4589 ;; article we have fetched.
4590 (when (and (not gnus-show-threads)
4593 (setq d (gnus-data-find (mail-header-number old-header))))
4594 (goto-char (gnus-data-pos d))
4597 (- (gnus-point-at-bol)
4599 (1+ (gnus-point-at-eol))
4600 (gnus-delete-line))))))
4602 (mail-header-set-number header (mail-header-number old-header)))
4603 (setq gnus-newsgroup-sparse
4604 (delq (setq number (mail-header-number header))
4605 gnus-newsgroup-sparse))
4606 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4607 (push number gnus-newsgroup-limit)
4608 (gnus-rebuild-thread (mail-header-id header) line)
4609 (gnus-summary-goto-subject number nil t))
4610 (when (and (numberp number)
4612 ;; We have to update the boundaries even if we can't fetch the
4613 ;; article if ID is a number -- so that the next `P' or `N'
4614 ;; command will fetch the previous (or next) article even
4615 ;; if the one we tried to fetch this time has been canceled.
4616 (when (> number gnus-newsgroup-end)
4617 (setq gnus-newsgroup-end number))
4618 (when (< number gnus-newsgroup-begin)
4619 (setq gnus-newsgroup-begin number))
4620 (setq gnus-newsgroup-unselected
4621 (delq number gnus-newsgroup-unselected)))
4622 ;; Report back a success?
4623 (and header (mail-header-number header))))
4625 ;;; Process/prefix in the summary buffer
4627 (defun gnus-summary-work-articles (n)
4628 "Return a list of articles to be worked upon.
4629 The prefix argument, the list of process marked articles, and the
4630 current article will be taken into consideration."
4632 (set-buffer gnus-summary-buffer)
4635 ;; A numerical prefix has been given.
4636 (setq n (prefix-numeric-value n))
4637 (let ((backward (< n 0))
4638 (n (abs (prefix-numeric-value n)))
4643 (push (setq article (gnus-summary-article-number))
4646 (gnus-summary-find-prev nil article)
4647 (gnus-summary-find-next nil article)))
4649 (nreverse articles)))
4650 ((and (gnus-region-active-p) (mark))
4651 (message "region active")
4652 ;; Work on the region between point and mark.
4653 (let ((max (max (point) (mark)))
4656 (goto-char (min (min (point) (mark))))
4659 (push (setq article (gnus-summary-article-number)) articles)
4660 (gnus-summary-find-next nil article)
4662 (nreverse articles))))
4663 (gnus-newsgroup-processable
4664 ;; There are process-marked articles present.
4665 ;; Save current state.
4666 (gnus-summary-save-process-mark)
4668 (reverse gnus-newsgroup-processable))
4670 ;; Just return the current article.
4671 (list (gnus-summary-article-number))))))
4673 (defmacro gnus-summary-iterate (arg &rest forms)
4674 "Iterate over the process/prefixed articles and do FORMS.
4675 ARG is the interactive prefix given to the command. FORMS will be
4676 executed with point over the summary line of the articles."
4677 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
4678 `(let ((,articles (gnus-summary-work-articles ,arg)))
4680 (gnus-summary-goto-subject (car ,articles))
4683 (put 'gnus-summary-iterate 'lisp-indent-function 1)
4684 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
4686 (defun gnus-summary-save-process-mark ()
4687 "Push the current set of process marked articles on the stack."
4689 (push (copy-sequence gnus-newsgroup-processable)
4690 gnus-newsgroup-process-stack))
4692 (defun gnus-summary-kill-process-mark ()
4693 "Push the current set of process marked articles on the stack and unmark."
4695 (gnus-summary-save-process-mark)
4696 (gnus-summary-unmark-all-processable))
4698 (defun gnus-summary-yank-process-mark ()
4699 "Pop the last process mark state off the stack and restore it."
4701 (unless gnus-newsgroup-process-stack
4702 (error "Empty mark stack"))
4703 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4705 (defun gnus-summary-process-mark-set (set)
4706 "Make SET into the current process marked articles."
4707 (gnus-summary-unmark-all-processable)
4709 (gnus-summary-set-process-mark (pop set))))
4711 ;;; Searching and stuff
4713 (defun gnus-summary-search-group (&optional backward use-level)
4714 "Search for next unread newsgroup.
4715 If optional argument BACKWARD is non-nil, search backward instead."
4717 (set-buffer gnus-group-buffer)
4718 (when (gnus-group-search-forward
4719 backward nil (if use-level (gnus-group-group-level) nil))
4720 (gnus-group-group-name))))
4722 (defun gnus-summary-best-group (&optional exclude-group)
4723 "Find the name of the best unread group.
4724 If EXCLUDE-GROUP, do not go to this group."
4726 (set-buffer gnus-group-buffer)
4728 (gnus-group-best-unread-group exclude-group))))
4730 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
4731 (if backward (gnus-summary-find-prev)
4732 (let* ((dummy (gnus-summary-article-intangible-p))
4733 (article (or article (gnus-summary-article-number)))
4734 (arts (gnus-data-find-list article))
4736 (when (and (not dummy)
4737 (or (not gnus-summary-check-current)
4739 (not (gnus-data-unread-p (car arts)))))
4740 (setq arts (cdr arts)))
4745 (when (or (and undownloaded
4746 (eq gnus-undownloaded-mark
4747 (gnus-data-mark (car arts))))
4748 (gnus-data-unread-p (car arts)))
4749 (setq result (car arts)
4751 (setq arts (cdr arts)))
4754 (goto-char (gnus-data-pos result))
4755 (gnus-data-number result)))))
4757 (defun gnus-summary-find-prev (&optional unread article)
4758 (let* ((eobp (eobp))
4759 (article (or article (gnus-summary-article-number)))
4760 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
4762 (when (and (not eobp)
4763 (or (not gnus-summary-check-current)
4765 (not (gnus-data-unread-p (car arts)))))
4766 (setq arts (cdr arts)))
4771 (when (gnus-data-unread-p (car arts))
4772 (setq result (car arts)
4774 (setq arts (cdr arts)))
4777 (goto-char (gnus-data-pos result))
4778 (gnus-data-number result))))
4780 (defun gnus-summary-find-subject (subject &optional unread backward article)
4781 (let* ((simp-subject (gnus-simplify-subject-fully subject))
4782 (article (or article (gnus-summary-article-number)))
4783 (articles (gnus-data-list backward))
4784 (arts (gnus-data-find-list article articles))
4786 (when (or (not gnus-summary-check-current)
4788 (not (gnus-data-unread-p (car arts))))
4789 (setq arts (cdr arts)))
4791 (and (or (not unread)
4792 (gnus-data-unread-p (car arts)))
4793 (vectorp (gnus-data-header (car arts)))
4795 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
4796 (setq result (car arts)
4798 (setq arts (cdr arts)))
4800 (goto-char (gnus-data-pos result))
4801 (gnus-data-number result))))
4803 (defun gnus-summary-search-forward (&optional unread subject backward)
4804 "Search forward for an article.
4805 If UNREAD, look for unread articles. If SUBJECT, look for
4806 articles with that subject. If BACKWARD, search backward instead."
4807 (cond (subject (gnus-summary-find-subject subject unread backward))
4808 (backward (gnus-summary-find-prev unread))
4809 (t (gnus-summary-find-next unread))))
4811 (defun gnus-recenter (&optional n)
4812 "Center point in window and redisplay frame.
4813 Also do horizontal recentering."
4815 (when (and gnus-auto-center-summary
4816 (not (eq gnus-auto-center-summary 'vertical)))
4817 (gnus-horizontal-recenter))
4820 (defun gnus-summary-recenter ()
4821 "Center point in the summary window.
4822 If `gnus-auto-center-summary' is nil, or the article buffer isn't
4823 displayed, no centering will be performed."
4824 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
4825 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
4826 (let* ((top (cond ((< (window-height) 4) 0)
4827 ((< (window-height) 7) 1)
4829 (height (1- (window-height)))
4830 (bottom (save-excursion (goto-char (point-max))
4831 (forward-line (- height))
4833 (window (get-buffer-window (current-buffer))))
4834 ;; The user has to want it.
4835 (when gnus-auto-center-summary
4836 (when (get-buffer-window gnus-article-buffer)
4837 ;; Only do recentering when the article buffer is displayed,
4838 ;; Set the window start to either `bottom', which is the biggest
4839 ;; possible valid number, or the second line from the top,
4840 ;; whichever is the least.
4842 window (min bottom (save-excursion
4843 (forward-line (- top)) (point)))))
4844 ;; Do horizontal recentering while we're at it.
4845 (when (and (get-buffer-window (current-buffer) t)
4846 (not (eq gnus-auto-center-summary 'vertical)))
4847 (let ((selected (selected-window)))
4848 (select-window (get-buffer-window (current-buffer) t))
4849 (gnus-summary-position-point)
4850 (gnus-horizontal-recenter)
4851 (select-window selected))))))
4853 (defun gnus-summary-jump-to-group (newsgroup)
4854 "Move point to NEWSGROUP in group mode buffer."
4855 ;; Keep update point of group mode buffer if visible.
4856 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
4857 (save-window-excursion
4858 ;; Take care of tree window mode.
4859 (when (get-buffer-window gnus-group-buffer)
4860 (pop-to-buffer gnus-group-buffer))
4861 (gnus-group-jump-to-group newsgroup))
4863 ;; Take care of tree window mode.
4864 (if (get-buffer-window gnus-group-buffer)
4865 (pop-to-buffer gnus-group-buffer)
4866 (set-buffer gnus-group-buffer))
4867 (gnus-group-jump-to-group newsgroup))))
4869 ;; This function returns a list of article numbers based on the
4870 ;; difference between the ranges of read articles in this group and
4871 ;; the range of active articles.
4872 (defun gnus-list-of-unread-articles (group)
4873 (let* ((read (gnus-info-read (gnus-get-info group)))
4874 (active (or (gnus-active group) (gnus-activate-group group)))
4877 ;; If none are read, then all are unread.
4879 (setq first (car active))
4880 ;; If the range of read articles is a single range, then the
4881 ;; first unread article is the article after the last read
4882 ;; article. Sounds logical, doesn't it?
4883 (if (not (listp (cdr read)))
4884 (setq first (max (car active) (1+ (cdr read))))
4885 ;; `read' is a list of ranges.
4886 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
4889 (setq first (car active)))
4892 (while (< first nlast)
4894 (setq first (1+ first))))
4895 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
4896 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
4897 (setq read (cdr read)))))
4898 ;; And add the last unread articles.
4899 (while (<= first last)
4901 (setq first (1+ first)))
4902 ;; Return the list of unread articles.
4903 (delq 0 (nreverse unread))))
4905 (defun gnus-list-of-read-articles (group)
4906 "Return a list of unread, unticked and non-dormant articles."
4907 (let* ((info (gnus-get-info group))
4908 (marked (gnus-info-marks info))
4909 (active (gnus-active group)))
4911 (gnus-set-difference
4912 (gnus-sorted-complement
4913 (gnus-uncompress-range active)
4914 (gnus-list-of-unread-articles group))
4916 (gnus-uncompress-range (cdr (assq 'dormant marked)))
4917 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
4919 ;; Various summary commands
4921 (defun gnus-summary-select-article-buffer ()
4922 "Reconfigure windows to show article buffer."
4924 (if (not (gnus-buffer-live-p gnus-article-buffer))
4925 (error "There is no article buffer for this summary buffer")
4926 (gnus-configure-windows 'article)
4927 (select-window (get-buffer-window gnus-article-buffer))))
4929 (defun gnus-summary-universal-argument (arg)
4930 "Perform any operation on all articles that are process/prefixed."
4932 (let ((articles (gnus-summary-work-articles arg))
4939 (substitute-command-keys
4940 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
4943 (gnus-error 1 "Undefined key")
4946 (gnus-summary-goto-subject (setq article (pop articles)))
4947 (let (gnus-newsgroup-processable)
4948 (command-execute func))
4949 (gnus-summary-remove-process-mark article)))))
4950 (gnus-summary-position-point))
4952 (defun gnus-summary-toggle-truncation (&optional arg)
4953 "Toggle truncation of summary lines.
4954 With arg, turn line truncation on iff arg is positive."
4956 (setq truncate-lines
4957 (if (null arg) (not truncate-lines)
4958 (> (prefix-numeric-value arg) 0)))
4961 (defun gnus-summary-reselect-current-group (&optional all rescan)
4962 "Exit and then reselect the current newsgroup.
4963 The prefix argument ALL means to select all articles."
4965 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
4966 (error "Ephemeral groups can't be reselected"))
4967 (let ((current-subject (gnus-summary-article-number))
4968 (group gnus-newsgroup-name))
4969 (setq gnus-newsgroup-begin nil)
4971 ;; We have to adjust the point of group mode buffer because
4972 ;; point was moved to the next unread newsgroup by exiting.
4973 (gnus-summary-jump-to-group group)
4976 (gnus-group-get-new-news-this-group 1)))
4977 (gnus-group-read-group all t)
4978 (gnus-summary-goto-subject current-subject nil t)))
4980 (defun gnus-summary-rescan-group (&optional all)
4981 "Exit the newsgroup, ask for new articles, and select the newsgroup."
4983 (gnus-summary-reselect-current-group all t))
4985 (defun gnus-summary-update-info (&optional non-destructive)
4987 (let ((group gnus-newsgroup-name))
4989 (when gnus-newsgroup-kill-headers
4990 (setq gnus-newsgroup-killed
4991 (gnus-compress-sequence
4993 (gnus-set-sorted-intersection
4994 (gnus-uncompress-range gnus-newsgroup-killed)
4995 (setq gnus-newsgroup-unselected
4996 (sort gnus-newsgroup-unselected '<)))
4997 (setq gnus-newsgroup-unreads
4998 (sort gnus-newsgroup-unreads '<)))
5000 (unless (listp (cdr gnus-newsgroup-killed))
5001 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5002 (let ((headers gnus-newsgroup-headers))
5003 ;; Set the new ranges of read articles.
5005 (set-buffer gnus-group-buffer)
5006 (gnus-undo-force-boundary))
5007 (gnus-update-read-articles
5008 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5009 ;; Set the current article marks.
5010 (let ((gnus-newsgroup-scored
5011 (if (and (not gnus-save-score)
5012 (not non-destructive))
5014 gnus-newsgroup-scored)))
5016 (gnus-update-marks)))
5017 ;; Do the cross-ref thing.
5018 (when gnus-use-cross-reference
5019 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5020 ;; Do not switch windows but change the buffer to work.
5021 (set-buffer gnus-group-buffer)
5022 (unless (gnus-ephemeral-group-p group)
5023 (gnus-group-update-group group)))))))
5025 (defun gnus-summary-save-newsrc (&optional force)
5026 "Save the current number of read/marked articles in the dribble buffer.
5027 The dribble buffer will then be saved.
5028 If FORCE (the prefix), also save the .newsrc file(s)."
5030 (gnus-summary-update-info t)
5032 (gnus-save-newsrc-file)
5033 (gnus-dribble-save)))
5035 (defun gnus-summary-exit (&optional temporary)
5036 "Exit reading current newsgroup, and then return to group selection mode.
5037 gnus-exit-group-hook is called with no arguments if that value is non-nil."
5039 (gnus-set-global-variables)
5040 (gnus-kill-save-kill-buffer)
5041 (gnus-async-halt-prefetch)
5042 (let* ((group gnus-newsgroup-name)
5043 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5046 (buf (current-buffer)))
5047 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5048 ;; If we have several article buffers, we kill them at exit.
5049 (unless gnus-single-article-buffer
5050 (gnus-kill-buffer gnus-original-article-buffer)
5051 (setq gnus-article-current nil))
5052 (when gnus-use-cache
5053 (gnus-cache-possibly-remove-articles)
5054 (gnus-cache-save-buffers))
5055 (gnus-async-prefetch-remove-group group)
5056 (when gnus-suppress-duplicates
5057 (gnus-dup-enter-articles))
5058 (when gnus-use-trees
5059 (gnus-tree-close group))
5060 ;; Remove entries for this group.
5061 (nnmail-purge-split-history (gnus-group-real-name group))
5062 ;; Make all changes in this group permanent.
5064 (gnus-run-hooks 'gnus-exit-group-hook)
5065 (gnus-summary-update-info)
5066 ;; Do adaptive scoring, and possibly save score files.
5067 (when gnus-newsgroup-adaptive
5068 (gnus-score-adaptive))
5069 (when gnus-use-scoring
5071 (gnus-close-group group)
5072 ;; Make sure where we were, and go to next newsgroup.
5073 (set-buffer gnus-group-buffer)
5075 (gnus-group-jump-to-group group))
5076 (gnus-run-hooks 'gnus-summary-exit-hook)
5077 (unless (or quit-config
5078 ;; If this group has disappeared from the summary
5079 ;; buffer, don't skip forwards.
5080 (not (string= group (gnus-group-group-name))))
5081 (gnus-group-next-unread-group 1))
5082 (setq group-point (point))
5085 ;; If we have several article buffers, we kill them at exit.
5086 (unless gnus-single-article-buffer
5087 (gnus-kill-buffer gnus-article-buffer)
5088 (gnus-kill-buffer gnus-original-article-buffer)
5089 (setq gnus-article-current nil))
5091 (if (not gnus-kill-summary-on-exit)
5092 (gnus-deaden-summary)
5093 ;; We set all buffer-local variables to nil. It is unclear why
5094 ;; this is needed, but if we don't, buffer-local variables are
5095 ;; not garbage-collected, it seems. This would the lead to en
5096 ;; ever-growing Emacs.
5097 (gnus-summary-clear-local-variables)
5098 (when (get-buffer gnus-article-buffer)
5099 (bury-buffer gnus-article-buffer))
5100 ;; We clear the global counterparts of the buffer-local
5101 ;; variables as well, just to be on the safe side.
5102 (set-buffer gnus-group-buffer)
5103 (gnus-summary-clear-local-variables)
5104 ;; Return to group mode buffer.
5105 (when (eq mode 'gnus-summary-mode)
5106 (gnus-kill-buffer buf)))
5107 (setq gnus-current-select-method gnus-select-method)
5108 (pop-to-buffer gnus-group-buffer)
5109 ;; Clear the current group name.
5110 (if (not quit-config)
5112 (goto-char group-point)
5113 (gnus-configure-windows 'group 'force))
5114 (gnus-handle-ephemeral-exit quit-config))
5116 (setq gnus-newsgroup-name nil)))))
5118 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5119 (defun gnus-summary-exit-no-update (&optional no-questions)
5120 "Quit reading current newsgroup without updating read article info."
5122 (let* ((group gnus-newsgroup-name)
5123 (quit-config (gnus-group-quit-config group)))
5124 (when (or no-questions
5126 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5127 (gnus-async-halt-prefetch)
5128 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5129 ;; If we have several article buffers, we kill them at exit.
5130 (unless gnus-single-article-buffer
5131 (gnus-kill-buffer gnus-article-buffer)
5132 (gnus-kill-buffer gnus-original-article-buffer)
5133 (setq gnus-article-current nil))
5134 (if (not gnus-kill-summary-on-exit)
5135 (gnus-deaden-summary)
5136 (gnus-close-group group)
5137 (gnus-summary-clear-local-variables)
5138 (set-buffer gnus-group-buffer)
5139 (gnus-summary-clear-local-variables)
5140 (when (get-buffer gnus-summary-buffer)
5141 (kill-buffer gnus-summary-buffer)))
5142 (unless gnus-single-article-buffer
5143 (setq gnus-article-current nil))
5144 (when gnus-use-trees
5145 (gnus-tree-close group))
5146 (gnus-async-prefetch-remove-group group)
5147 (when (get-buffer gnus-article-buffer)
5148 (bury-buffer gnus-article-buffer))
5149 ;; Return to the group buffer.
5150 (gnus-configure-windows 'group 'force)
5151 ;; Clear the current group name.
5152 (setq gnus-newsgroup-name nil)
5153 (when (equal (gnus-group-group-name) group)
5154 (gnus-group-next-unread-group 1))
5156 (gnus-handle-ephemeral-exit quit-config)))))
5158 (defun gnus-handle-ephemeral-exit (quit-config)
5159 "Handle movement when leaving an ephemeral group.
5160 The state which existed when entering the ephemeral is reset."
5161 (if (not (buffer-name (car quit-config)))
5162 (gnus-configure-windows 'group 'force)
5163 (set-buffer (car quit-config))
5164 (cond ((eq major-mode 'gnus-summary-mode)
5165 (gnus-set-global-variables))
5166 ((eq major-mode 'gnus-article-mode)
5168 ;; The `gnus-summary-buffer' variable may point
5169 ;; to the old summary buffer when using a single
5171 (unless (gnus-buffer-live-p gnus-summary-buffer)
5172 (set-buffer gnus-group-buffer))
5173 (set-buffer gnus-summary-buffer)
5174 (gnus-set-global-variables))))
5175 (if (or (eq (cdr quit-config) 'article)
5176 (eq (cdr quit-config) 'pick))
5178 ;; The current article may be from the ephemeral group
5179 ;; thus it is best that we reload this article
5180 (gnus-summary-show-article)
5181 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5182 (gnus-configure-windows 'pick 'force)
5183 (gnus-configure-windows (cdr quit-config) 'force)))
5184 (gnus-configure-windows (cdr quit-config) 'force))
5185 (when (eq major-mode 'gnus-summary-mode)
5186 (gnus-summary-next-subject 1 nil t)
5187 (gnus-summary-recenter)
5188 (gnus-summary-position-point))))
5192 (defvar gnus-dead-summary-mode-map nil)
5194 (unless gnus-dead-summary-mode-map
5195 (setq gnus-dead-summary-mode-map (make-keymap))
5196 (suppress-keymap gnus-dead-summary-mode-map)
5197 (substitute-key-definition
5198 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5199 (let ((keys '("\C-d" "\r" "\177" [delete])))
5201 (define-key gnus-dead-summary-mode-map
5202 (pop keys) 'gnus-summary-wake-up-the-dead))))
5204 (defvar gnus-dead-summary-mode nil
5205 "Minor mode for Gnus summary buffers.")
5207 (defun gnus-dead-summary-mode (&optional arg)
5208 "Minor mode for Gnus summary buffers."
5210 (when (eq major-mode 'gnus-summary-mode)
5211 (make-local-variable 'gnus-dead-summary-mode)
5212 (setq gnus-dead-summary-mode
5213 (if (null arg) (not gnus-dead-summary-mode)
5214 (> (prefix-numeric-value arg) 0)))
5215 (when gnus-dead-summary-mode
5216 (gnus-add-minor-mode
5217 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5219 (defun gnus-deaden-summary ()
5220 "Make the current summary buffer into a dead summary buffer."
5221 ;; Kill any previous dead summary buffer.
5222 (when (and gnus-dead-summary
5223 (buffer-name gnus-dead-summary))
5225 (set-buffer gnus-dead-summary)
5226 (when gnus-dead-summary-mode
5227 (kill-buffer (current-buffer)))))
5228 ;; Make this the current dead summary.
5229 (setq gnus-dead-summary (current-buffer))
5230 (gnus-dead-summary-mode 1)
5231 (let ((name (buffer-name)))
5232 (when (string-match "Summary" name)
5234 (concat (substring name 0 (match-beginning 0)) "Dead "
5235 (substring name (match-beginning 0)))
5238 (defun gnus-kill-or-deaden-summary (buffer)
5239 "Kill or deaden the summary BUFFER."
5241 (when (and (buffer-name buffer)
5242 (not gnus-single-article-buffer))
5245 (gnus-kill-buffer gnus-article-buffer)
5246 (gnus-kill-buffer gnus-original-article-buffer)))
5247 (cond (gnus-kill-summary-on-exit
5248 (when (and gnus-use-trees
5249 (gnus-buffer-exists-p buffer))
5252 (gnus-tree-close gnus-newsgroup-name)))
5253 (gnus-kill-buffer buffer))
5254 ((gnus-buffer-exists-p buffer)
5257 (gnus-deaden-summary))))))
5259 (defun gnus-summary-wake-up-the-dead (&rest args)
5260 "Wake up the dead summary buffer."
5262 (gnus-dead-summary-mode -1)
5263 (let ((name (buffer-name)))
5264 (when (string-match "Dead " name)
5266 (concat (substring name 0 (match-beginning 0))
5267 (substring name (match-end 0)))
5269 (gnus-message 3 "This dead summary is now alive again"))
5271 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5272 (defun gnus-summary-fetch-faq (&optional faq-dir)
5273 "Fetch the FAQ for the current group.
5274 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5278 (when current-prefix-arg
5280 "Faq dir: " (and (listp gnus-group-faq-directory)
5281 (mapcar (lambda (file) (list file))
5282 gnus-group-faq-directory))))))
5283 (let (gnus-faq-buffer)
5284 (when (setq gnus-faq-buffer
5285 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5286 (gnus-configure-windows 'summary-faq))))
5288 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5289 (defun gnus-summary-describe-group (&optional force)
5290 "Describe the current newsgroup."
5292 (gnus-group-describe-group force gnus-newsgroup-name))
5294 (defun gnus-summary-describe-briefly ()
5295 "Describe summary mode commands briefly."
5298 (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")))
5300 ;; Walking around group mode buffer from summary mode.
5302 (defun gnus-summary-next-group (&optional no-article target-group backward)
5303 "Exit current newsgroup and then select next unread newsgroup.
5304 If prefix argument NO-ARTICLE is non-nil, no article is selected
5305 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5306 previous group instead."
5308 ;; Stop pre-fetching.
5309 (gnus-async-halt-prefetch)
5310 (let ((current-group gnus-newsgroup-name)
5311 (current-buffer (current-buffer))
5313 ;; First we semi-exit this group to update Xrefs and all variables.
5314 ;; We can't do a real exit, because the window conf must remain
5315 ;; the same in case the user is prompted for info, and we don't
5316 ;; want the window conf to change before that...
5317 (gnus-summary-exit t)
5318 (while (not entered)
5319 ;; Then we find what group we are supposed to enter.
5320 (set-buffer gnus-group-buffer)
5321 (gnus-group-jump-to-group current-group)
5324 (if (eq gnus-keep-same-level 'best)
5325 (gnus-summary-best-group gnus-newsgroup-name)
5326 (gnus-summary-search-group backward gnus-keep-same-level))))
5327 (if (not target-group)
5328 ;; There are no further groups, so we return to the group
5331 (gnus-message 5 "Returning to the group buffer")
5333 (when (gnus-buffer-live-p current-buffer)
5334 (set-buffer current-buffer)
5335 (gnus-summary-exit))
5336 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5337 ;; We try to enter the target group.
5338 (gnus-group-jump-to-group target-group)
5339 (let ((unreads (gnus-group-group-unread)))
5340 (if (and (or (eq t unreads)
5341 (and unreads (not (zerop unreads))))
5342 (gnus-summary-read-group
5343 target-group nil no-article
5344 (and (buffer-name current-buffer) current-buffer)
5347 (setq current-group target-group
5348 target-group nil)))))))
5350 (defun gnus-summary-prev-group (&optional no-article)
5351 "Exit current newsgroup and then select previous unread newsgroup.
5352 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5354 (gnus-summary-next-group no-article nil t))
5356 ;; Walking around summary lines.
5358 (defun gnus-summary-first-subject (&optional unread undownloaded)
5359 "Go to the first unread subject.
5360 If UNREAD is non-nil, go to the first unread article.
5361 Returns the article selected or nil if there are no unread articles."
5366 ((null gnus-newsgroup-data)
5367 (gnus-message 3 "No articles in the group")
5369 ;; Pick the first article.
5371 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5372 (gnus-data-number (car gnus-newsgroup-data)))
5373 ;; No unread articles.
5374 ((null gnus-newsgroup-unreads)
5375 (gnus-message 3 "No more unread articles")
5377 ;; Find the first unread article.
5379 (let ((data gnus-newsgroup-data))
5381 (and (not (and undownloaded
5382 (eq gnus-undownloaded-mark
5383 (gnus-data-mark (car data)))))
5384 (not (gnus-data-unread-p (car data)))))
5385 (setq data (cdr data)))
5387 (goto-char (gnus-data-pos (car data)))
5388 (gnus-data-number (car data))))))
5389 (gnus-summary-position-point)))
5391 (defun gnus-summary-next-subject (n &optional unread dont-display)
5392 "Go to next N'th summary line.
5393 If N is negative, go to the previous N'th subject line.
5394 If UNREAD is non-nil, only unread articles are selected.
5395 The difference between N and the actual number of steps taken is
5398 (let ((backward (< n 0))
5402 (gnus-summary-find-prev unread)
5403 (gnus-summary-find-next unread)))
5404 (gnus-summary-show-thread)
5407 (gnus-message 7 "No more%s articles"
5408 (if unread " unread" "")))
5409 (unless dont-display
5410 (gnus-summary-recenter)
5411 (gnus-summary-position-point))
5414 (defun gnus-summary-next-unread-subject (n)
5415 "Go to next N'th unread summary line."
5417 (gnus-summary-next-subject n t))
5419 (defun gnus-summary-prev-subject (n &optional unread)
5420 "Go to previous N'th summary line.
5421 If optional argument UNREAD is non-nil, only unread article is selected."
5423 (gnus-summary-next-subject (- n) unread))
5425 (defun gnus-summary-prev-unread-subject (n)
5426 "Go to previous N'th unread summary line."
5428 (gnus-summary-next-subject (- n) t))
5430 (defun gnus-summary-goto-subject (article &optional force silent)
5431 "Go the subject line of ARTICLE.
5432 If FORCE, also allow jumping to articles not currently shown."
5433 (interactive "nArticle number: ")
5435 (data (gnus-data-find article)))
5436 ;; We read in the article if we have to.
5439 (gnus-summary-insert-subject
5441 (if (or (numberp force) (vectorp force)) force)
5443 (setq data (gnus-data-find article)))
5448 (gnus-message 3 "Can't find article %d" article))
5450 (goto-char (gnus-data-pos data))
5451 (gnus-summary-position-point)
5454 ;; Walking around summary lines with displaying articles.
5456 (defun gnus-summary-expand-window (&optional arg)
5457 "Make the summary buffer take up the entire Emacs frame.
5458 Given a prefix, will force an `article' buffer configuration."
5461 (gnus-configure-windows 'article 'force)
5462 (gnus-configure-windows 'summary 'force)))
5464 (defun gnus-summary-display-article (article &optional all-header)
5465 "Display ARTICLE in article buffer."
5466 (gnus-set-global-variables)
5470 (if gnus-summary-display-article-function
5471 (funcall gnus-summary-display-article-function article all-header)
5472 (gnus-article-prepare article all-header))
5473 (gnus-run-hooks 'gnus-select-article-hook)
5474 (when (and gnus-current-article
5475 (not (zerop gnus-current-article)))
5476 (gnus-summary-goto-subject gnus-current-article))
5477 (gnus-summary-recenter)
5478 (when (and gnus-use-trees gnus-show-threads)
5479 (gnus-possibly-generate-tree article)
5480 (gnus-highlight-selected-tree article))
5481 ;; Successfully display article.
5482 (gnus-article-set-window-start
5483 (cdr (assq article gnus-newsgroup-bookmarks))))))
5485 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5486 "Select the current article.
5487 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5488 non-nil, the article will be re-fetched even if it already present in
5489 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5491 ;; Make sure we are in the summary buffer to work around bbdb bug.
5492 (unless (eq major-mode 'gnus-summary-mode)
5493 (set-buffer gnus-summary-buffer))
5494 (let ((article (or article (gnus-summary-article-number)))
5495 (all-headers (not (not all-headers))) ;Must be T or NIL.
5496 gnus-summary-display-article-function
5499 (gnus-summary-article-pseudo-p article)
5500 (error "This is a pseudo-article"))
5503 (set-buffer gnus-summary-buffer)
5504 (if (or (and gnus-single-article-buffer
5505 (or (null gnus-current-article)
5506 (null gnus-article-current)
5507 (null (get-buffer gnus-article-buffer))
5508 (not (eq article (cdr gnus-article-current)))
5509 (not (equal (car gnus-article-current)
5510 gnus-newsgroup-name))))
5511 (and (not gnus-single-article-buffer)
5512 (or (null gnus-current-article)
5513 (not (eq gnus-current-article article))))
5515 ;; The requested article is different from the current article.
5517 (gnus-summary-display-article article all-headers)
5519 (when (or all-headers gnus-show-all-headers)
5520 (gnus-article-show-all-headers))
5523 (gnus-article-set-window-start
5524 (cdr (assq article gnus-newsgroup-bookmarks)))))))
5526 (defun gnus-summary-set-current-mark (&optional current-mark)
5527 "Obsolete function."
5530 (defun gnus-summary-next-article (&optional unread subject backward push)
5531 "Select the next article.
5532 If UNREAD, only unread articles are selected.
5533 If SUBJECT, only articles with SUBJECT are selected.
5534 If BACKWARD, the previous article is selected instead of the next."
5537 ;; Is there such an article?
5538 ((and (gnus-summary-search-forward unread subject backward)
5539 (or (gnus-summary-display-article (gnus-summary-article-number))
5540 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5541 (gnus-summary-position-point))
5542 ;; If not, we try the first unread, if that is wanted.
5544 gnus-auto-select-same
5545 (gnus-summary-first-unread-article))
5546 (gnus-summary-position-point)
5547 (gnus-message 6 "Wrapped"))
5548 ;; Try to get next/previous article not displayed in this group.
5549 ((and gnus-auto-extend-newsgroup
5550 (not unread) (not subject))
5551 (gnus-summary-goto-article
5552 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5553 nil (count-lines (point-min) (point))))
5554 ;; Go to next/previous group.
5556 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5557 (gnus-summary-jump-to-group gnus-newsgroup-name))
5558 (let ((cmd last-command-char)
5561 (set-buffer gnus-group-buffer)
5564 (if (eq gnus-keep-same-level 'best)
5565 (gnus-summary-best-group gnus-newsgroup-name)
5566 (gnus-summary-search-group backward gnus-keep-same-level))))
5567 ;; For some reason, the group window gets selected. We change
5569 (select-window (get-buffer-window (current-buffer)))
5570 ;; Select next unread newsgroup automagically.
5572 ((or (not gnus-auto-select-next)
5574 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5575 ((or (eq gnus-auto-select-next 'quietly)
5576 (and (eq gnus-auto-select-next 'slightly-quietly)
5578 (and (eq gnus-auto-select-next 'almost-quietly)
5579 (gnus-summary-last-article-p)))
5581 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5583 (gnus-message 7 "No more%s articles (%s)..."
5584 (if unread " unread" "")
5585 (if group (concat "selecting " group)
5587 (gnus-summary-next-group nil group backward)))
5589 (when (gnus-key-press-event-p last-input-event)
5590 (gnus-summary-walk-group-buffer
5591 gnus-newsgroup-name cmd unread backward point))))))))
5593 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5594 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5595 (?\C-p (gnus-group-prev-unread-group 1))))
5596 (cursor-in-echo-area t)
5597 keve key group ended)
5599 (set-buffer gnus-group-buffer)
5602 (if (eq gnus-keep-same-level 'best)
5603 (gnus-summary-best-group gnus-newsgroup-name)
5604 (gnus-summary-search-group backward gnus-keep-same-level))))
5607 5 "No more%s articles%s" (if unread " unread" "")
5609 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5610 (format " (Type %s for %s [%s])"
5611 (single-key-description cmd) group
5612 (car (gnus-gethash group gnus-newsrc-hashtb)))
5613 (format " (Type %s to exit %s)"
5614 (single-key-description cmd)
5615 gnus-newsgroup-name)))
5616 ;; Confirm auto selection.
5617 (setq key (car (setq keve (gnus-read-event-char))))
5620 ((assq key keystrokes)
5621 (let ((obuf (current-buffer)))
5622 (switch-to-buffer gnus-group-buffer)
5624 (gnus-group-jump-to-group group))
5625 (eval (cadr (assq key keystrokes)))
5626 (setq group (gnus-group-group-name))
5627 (switch-to-buffer obuf))
5631 (gnus-ephemeral-group-p gnus-newsgroup-name))
5633 (gnus-summary-next-group nil group backward)))
5635 (push (cdr keve) unread-command-events))))))
5637 (defun gnus-summary-next-unread-article ()
5638 "Select unread article after current one."
5640 (gnus-summary-next-article
5641 (or (not (eq gnus-summary-goto-unread 'never))
5642 (gnus-summary-last-article-p (gnus-summary-article-number)))
5643 (and gnus-auto-select-same
5644 (gnus-summary-article-subject))))
5646 (defun gnus-summary-prev-article (&optional unread subject)
5647 "Select the article after the current one.
5648 If UNREAD is non-nil, only unread articles are selected."
5650 (gnus-summary-next-article unread subject t))
5652 (defun gnus-summary-prev-unread-article ()
5653 "Select unread article before current one."
5655 (gnus-summary-prev-article
5656 (or (not (eq gnus-summary-goto-unread 'never))
5657 (gnus-summary-first-article-p (gnus-summary-article-number)))
5658 (and gnus-auto-select-same
5659 (gnus-summary-article-subject))))
5661 (defun gnus-summary-next-page (&optional lines circular)
5662 "Show next page of the selected article.
5663 If at the end of the current article, select the next article.
5664 LINES says how many lines should be scrolled up.
5666 If CIRCULAR is non-nil, go to the start of the article instead of
5667 selecting the next article when reaching the end of the current
5670 (setq gnus-summary-buffer (current-buffer))
5671 (gnus-set-global-variables)
5672 (let ((article (gnus-summary-article-number))
5673 (article-window (get-buffer-window gnus-article-buffer t))
5675 ;; If the buffer is empty, we have no article.
5677 (error "No article to select"))
5678 (gnus-configure-windows 'article)
5679 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
5680 (if (and (eq gnus-summary-goto-unread 'never)
5681 (not (gnus-summary-last-article-p article)))
5682 (gnus-summary-next-article)
5683 (gnus-summary-next-unread-article))
5684 (if (or (null gnus-current-article)
5685 (null gnus-article-current)
5686 (/= article (cdr gnus-article-current))
5687 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5688 ;; Selected subject is different from current article's.
5689 (gnus-summary-display-article article)
5690 (when article-window
5691 (gnus-eval-in-buffer-window gnus-article-buffer
5692 (setq endp (gnus-article-next-page lines)))
5695 (gnus-summary-beginning-of-article))
5697 (gnus-message 3 "End of message"))
5699 (if (and (eq gnus-summary-goto-unread 'never)
5700 (not (gnus-summary-last-article-p article)))
5701 (gnus-summary-next-article)
5702 (gnus-summary-next-unread-article))))))))
5703 (gnus-summary-recenter)
5704 (gnus-summary-position-point)))
5706 (defun gnus-summary-prev-page (&optional lines move)
5707 "Show previous page of selected article.
5708 Argument LINES specifies lines to be scrolled down.
5709 If MOVE, move to the previous unread article if point is at
5710 the beginning of the buffer."
5712 (let ((article (gnus-summary-article-number))
5713 (article-window (get-buffer-window gnus-article-buffer t))
5715 (gnus-configure-windows 'article)
5716 (if (or (null gnus-current-article)
5717 (null gnus-article-current)
5718 (/= article (cdr gnus-article-current))
5719 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5720 ;; Selected subject is different from current article's.
5721 (gnus-summary-display-article article)
5722 (gnus-summary-recenter)
5723 (when article-window
5724 (gnus-eval-in-buffer-window gnus-article-buffer
5725 (setq endp (gnus-article-prev-page lines)))
5726 (when (and move endp)
5728 (gnus-message 3 "Beginning of message"))
5730 (if (and (eq gnus-summary-goto-unread 'never)
5731 (not (gnus-summary-first-article-p article)))
5732 (gnus-summary-prev-article)
5733 (gnus-summary-prev-unread-article))))))))
5734 (gnus-summary-position-point))
5736 (defun gnus-summary-prev-page-or-article (&optional lines)
5737 "Show previous page of selected article.
5738 Argument LINES specifies lines to be scrolled down.
5739 If at the beginning of the article, go to the next article."
5741 (gnus-summary-prev-page lines t))
5743 (defun gnus-summary-scroll-up (lines)
5744 "Scroll up (or down) one line current article.
5745 Argument LINES specifies lines to be scrolled up (or down if negative)."
5747 (gnus-configure-windows 'article)
5748 (gnus-summary-show-thread)
5749 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
5750 (gnus-eval-in-buffer-window gnus-article-buffer
5752 (when (gnus-article-next-page lines)
5753 (gnus-message 3 "End of message")))
5755 (gnus-article-prev-page (- lines))))))
5756 (gnus-summary-recenter)
5757 (gnus-summary-position-point))
5759 (defun gnus-summary-scroll-down (lines)
5760 "Scroll down (or up) one line current article.
5761 Argument LINES specifies lines to be scrolled down (or up if negative)."
5763 (gnus-summary-scroll-up (- lines)))
5765 (defun gnus-summary-next-same-subject ()
5766 "Select next article which has the same subject as current one."
5768 (gnus-summary-next-article nil (gnus-summary-article-subject)))
5770 (defun gnus-summary-prev-same-subject ()
5771 "Select previous article which has the same subject as current one."
5773 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
5775 (defun gnus-summary-next-unread-same-subject ()
5776 "Select next unread article which has the same subject as current one."
5778 (gnus-summary-next-article t (gnus-summary-article-subject)))
5780 (defun gnus-summary-prev-unread-same-subject ()
5781 "Select previous unread article which has the same subject as current one."
5783 (gnus-summary-prev-article t (gnus-summary-article-subject)))
5785 (defun gnus-summary-first-unread-article ()
5786 "Select the first unread article.
5787 Return nil if there are no unread articles."
5790 (when (gnus-summary-first-subject t)
5791 (gnus-summary-show-thread)
5792 (gnus-summary-first-subject t)
5793 (gnus-summary-display-article (gnus-summary-article-number)))
5794 (gnus-summary-position-point)))
5796 (defun gnus-summary-first-article ()
5797 "Select the first article.
5798 Return nil if there are no articles."
5801 (when (gnus-summary-first-subject)
5802 (gnus-summary-show-thread)
5803 (gnus-summary-first-subject)
5804 (gnus-summary-display-article (gnus-summary-article-number)))
5805 (gnus-summary-position-point)))
5807 (defun gnus-summary-best-unread-article ()
5808 "Select the unread article with the highest score."
5810 (let ((best -1000000)
5811 (data gnus-newsgroup-data)
5814 (and (gnus-data-unread-p (car data))
5816 (gnus-summary-article-score (gnus-data-number (car data))))
5819 article (gnus-data-number (car data))))
5820 (setq data (cdr data)))
5823 (gnus-summary-goto-article article)
5824 (error "No unread articles"))
5825 (gnus-summary-position-point))))
5827 (defun gnus-summary-last-subject ()
5828 "Go to the last displayed subject line in the group."
5829 (let ((article (gnus-data-number (car (gnus-data-list t)))))
5831 (gnus-summary-goto-subject article))))
5833 (defun gnus-summary-goto-article (article &optional all-headers force)
5834 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
5835 If ALL-HEADERS is non-nil, no header lines are hidden.
5836 If FORCE, go to the article even if it isn't displayed. If FORCE
5837 is a number, it is the line the article is to be displayed on."
5841 "Article number or Message-ID: "
5842 (mapcar (lambda (number) (list (int-to-string number)))
5843 gnus-newsgroup-limit))
5847 (if (and (stringp article)
5848 (string-match "@" article))
5849 (gnus-summary-refer-article article)
5850 (when (stringp article)
5851 (setq article (string-to-number article)))
5852 (if (gnus-summary-goto-subject article force)
5853 (gnus-summary-display-article article all-headers)
5854 (gnus-message 4 "Couldn't go to article %s" article) nil))
5855 (gnus-summary-position-point)))
5857 (defun gnus-summary-goto-last-article ()
5858 "Go to the previously read article."
5861 (when gnus-last-article
5862 (gnus-summary-goto-article gnus-last-article nil t))
5863 (gnus-summary-position-point)))
5865 (defun gnus-summary-pop-article (number)
5866 "Pop one article off the history and go to the previous.
5867 NUMBER articles will be popped off."
5870 (setq gnus-newsgroup-history
5871 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
5873 (gnus-summary-goto-article (car to) nil t)
5874 (error "Article history empty")))
5875 (gnus-summary-position-point))
5877 ;; Summary commands and functions for limiting the summary buffer.
5879 (defun gnus-summary-limit-to-articles (n)
5880 "Limit the summary buffer to the next N articles.
5881 If not given a prefix, use the process marked articles instead."
5884 (let ((articles (gnus-summary-work-articles n)))
5885 (setq gnus-newsgroup-processable nil)
5886 (gnus-summary-limit articles))
5887 (gnus-summary-position-point)))
5889 (defun gnus-summary-pop-limit (&optional total)
5890 "Restore the previous limit.
5891 If given a prefix, remove all limits."
5894 (setq gnus-newsgroup-limits
5895 (list (mapcar (lambda (h) (mail-header-number h))
5896 gnus-newsgroup-headers))))
5897 (unless gnus-newsgroup-limits
5898 (error "No limit to pop"))
5900 (gnus-summary-limit nil 'pop)
5901 (gnus-summary-position-point)))
5903 (defun gnus-summary-limit-to-subject (subject &optional header)
5904 "Limit the summary buffer to articles that have subjects that match a regexp."
5905 (interactive "sLimit to subject (regexp): ")
5907 (setq header "subject"))
5908 (when (not (equal "" subject))
5910 (let ((articles (gnus-summary-find-matching
5911 (or header "subject") subject 'all)))
5913 (error "Found no matches for \"%s\"" subject))
5914 (gnus-summary-limit articles))
5915 (gnus-summary-position-point))))
5917 (defun gnus-summary-limit-to-author (from)
5918 "Limit the summary buffer to articles that have authors that match a regexp."
5919 (interactive "sLimit to author (regexp): ")
5920 (gnus-summary-limit-to-subject from "from"))
5922 (defun gnus-summary-limit-to-age (age &optional younger-p)
5923 "Limit the summary buffer to articles that are older than (or equal) AGE days.
5924 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
5925 articles that are younger than AGE days."
5926 (interactive "nTime in days: \nP")
5928 (let ((data gnus-newsgroup-data)
5929 (cutoff (nnmail-days-to-time age))
5930 articles d date is-younger)
5931 (while (setq d (pop data))
5932 (when (and (vectorp (gnus-data-header d))
5933 (setq date (mail-header-date (gnus-data-header d))))
5934 (setq is-younger (nnmail-time-less
5935 (nnmail-time-since (nnmail-date-to-time date))
5940 (push (gnus-data-number d) articles))))
5941 (gnus-summary-limit (nreverse articles)))
5942 (gnus-summary-position-point)))
5944 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5946 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5948 (defun gnus-summary-limit-to-unread (&optional all)
5949 "Limit the summary buffer to articles that are not marked as read.
5950 If ALL is non-nil, limit strictly to unread articles."
5953 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
5954 (gnus-summary-limit-to-marks
5955 ;; Concat all the marks that say that an article is read and have
5957 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
5958 gnus-killed-mark gnus-kill-file-mark
5959 gnus-low-score-mark gnus-expirable-mark
5960 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
5961 gnus-duplicate-mark gnus-souped-mark)
5964 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
5965 (make-obsolete 'gnus-summary-delete-marked-with
5966 'gnus-summary-limit-exlude-marks)
5968 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
5969 "Exclude articles that are marked with MARKS (e.g. \"DK\").
5970 If REVERSE, limit the summary buffer to articles that are marked
5971 with MARKS. MARKS can either be a string of marks or a list of marks.
5972 Returns how many articles were removed."
5973 (interactive "sMarks: ")
5974 (gnus-summary-limit-to-marks marks t))
5976 (defun gnus-summary-limit-to-marks (marks &optional reverse)
5977 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
5978 If REVERSE (the prefix), limit the summary buffer to articles that are
5979 not marked with MARKS. MARKS can either be a string of marks or a
5981 Returns how many articles were removed."
5982 (interactive "sMarks: \nP")
5984 (let ((data gnus-newsgroup-data)
5985 (marks (if (listp marks) marks
5986 (append marks nil))) ; Transform to list.
5989 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
5990 (memq (gnus-data-mark (car data)) marks))
5991 (push (gnus-data-number (car data)) articles))
5992 (setq data (cdr data)))
5993 (gnus-summary-limit articles))
5994 (gnus-summary-position-point)))
5996 (defun gnus-summary-limit-to-score (&optional score)
5997 "Limit to articles with score at or above SCORE."
5999 (setq score (if score
6000 (prefix-numeric-value score)
6001 (or gnus-summary-default-score 0)))
6002 (let ((data gnus-newsgroup-data)
6005 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6007 (push (gnus-data-number (car data)) articles))
6008 (setq data (cdr data)))
6010 (gnus-summary-limit articles)
6011 (gnus-summary-position-point))))
6013 (defun gnus-summary-limit-include-thread (id)
6014 "Display all the hidden articles that in the current thread."
6015 (interactive (list (mail-header-id (gnus-summary-article-header))))
6016 (let ((articles (gnus-articles-in-thread
6017 (gnus-id-to-thread (gnus-root-id id)))))
6019 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6020 (gnus-summary-position-point))))
6022 (defun gnus-summary-limit-include-dormant ()
6023 "Display all the hidden articles that are marked as dormant.
6024 Note that this command only works on a subset of the articles currently
6025 fetched for this group."
6027 (unless gnus-newsgroup-dormant
6028 (error "There are no dormant articles in this group"))
6030 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6031 (gnus-summary-position-point)))
6033 (defun gnus-summary-limit-exclude-dormant ()
6034 "Hide all dormant articles."
6037 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6038 (gnus-summary-position-point)))
6040 (defun gnus-summary-limit-exclude-childless-dormant ()
6041 "Hide all dormant articles that have no children."
6043 (let ((data (gnus-data-list t))
6044 articles d children)
6045 ;; Find all articles that are either not dormant or have
6047 (while (setq d (pop data))
6048 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6050 (gnus-article-children (gnus-data-number d)))
6053 (when (memq (car children) articles)
6058 (push (gnus-data-number d) articles)))
6061 (gnus-summary-limit articles)
6062 (gnus-summary-position-point))))
6064 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6065 "Mark all unread excluded articles as read.
6066 If ALL, mark even excluded ticked and dormants as read."
6068 (let ((articles (gnus-sorted-complement
6070 (mapcar (lambda (h) (mail-header-number h))
6071 gnus-newsgroup-headers)
6073 (sort gnus-newsgroup-limit '<)))
6075 (setq gnus-newsgroup-unreads
6076 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6078 (setq gnus-newsgroup-dormant nil
6079 gnus-newsgroup-marked nil
6080 gnus-newsgroup-reads
6082 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6083 gnus-newsgroup-reads))
6084 (while (setq article (pop articles))
6085 (unless (or (memq article gnus-newsgroup-dormant)
6086 (memq article gnus-newsgroup-marked))
6087 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6089 (defun gnus-summary-limit (articles &optional pop)
6091 ;; We pop the previous limit off the stack and use that.
6092 (setq articles (car gnus-newsgroup-limits)
6093 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6094 ;; We use the new limit, so we push the old limit on the stack.
6095 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6097 (setq gnus-newsgroup-limit articles)
6098 (let ((total (length gnus-newsgroup-data))
6099 (data (gnus-data-find-list (gnus-summary-article-number)))
6100 (gnus-summary-mark-below nil) ; Inhibit this.
6102 ;; This will do all the work of generating the new summary buffer
6103 ;; according to the new limit.
6104 (gnus-summary-prepare)
6105 ;; Hide any threads, possibly.
6106 (and gnus-show-threads
6107 gnus-thread-hide-subtree
6108 (gnus-summary-hide-all-threads))
6109 ;; Try to return to the article you were at, or one in the
6112 ;; We try to find some article after the current one.
6114 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6117 (setq data (cdr data))))
6119 ;; If there is no data, that means that we were after the last
6120 ;; article. The same goes when we can't find any articles
6121 ;; after the current one.
6122 (goto-char (point-max))
6123 (gnus-summary-find-prev))
6124 (gnus-set-mode-line 'summary)
6125 ;; We return how many articles were removed from the summary
6126 ;; buffer as a result of the new limit.
6127 (- total (length gnus-newsgroup-data))))
6129 (defsubst gnus-invisible-cut-children (threads)
6132 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6137 (defsubst gnus-cut-thread (thread)
6138 "Go forwards in the thread until we find an article that we want to display."
6139 (when (or (eq gnus-fetch-old-headers 'some)
6140 (eq gnus-fetch-old-headers 'invisible)
6141 (eq gnus-build-sparse-threads 'some)
6142 (eq gnus-build-sparse-threads 'more))
6143 ;; Deal with old-fetched headers and sparse threads.
6147 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6148 (gnus-summary-article-ancient-p
6149 (mail-header-number (car thread))))
6150 (if (or (<= (length (cdr thread)) 1)
6151 (eq gnus-fetch-old-headers 'invisible))
6152 (setq gnus-newsgroup-limit
6153 (delq (mail-header-number (car thread))
6154 gnus-newsgroup-limit)
6155 thread (cadr thread))
6156 (when (gnus-invisible-cut-children (cdr thread))
6157 (let ((th (cdr thread)))
6159 (if (memq (mail-header-number (caar th))
6160 gnus-newsgroup-limit)
6161 (setq thread (car th)
6163 (setq th (cdr th))))))))))
6166 (defun gnus-cut-threads (threads)
6167 "Cut off all uninteresting articles from the beginning of threads."
6168 (when (or (eq gnus-fetch-old-headers 'some)
6169 (eq gnus-fetch-old-headers 'invisible)
6170 (eq gnus-build-sparse-threads 'some)
6171 (eq gnus-build-sparse-threads 'more))
6174 (setcar th (gnus-cut-thread (car th)))
6175 (setq th (cdr th)))))
6176 ;; Remove nixed out threads.
6179 (defun gnus-summary-initial-limit (&optional show-if-empty)
6180 "Figure out what the initial limit is supposed to be on group entry.
6181 This entails weeding out unwanted dormants, low-scored articles,
6182 fetch-old-headers verbiage, and so on."
6183 ;; Most groups have nothing to remove.
6184 (if (or gnus-inhibit-limiting
6185 (and (null gnus-newsgroup-dormant)
6186 (not (eq gnus-fetch-old-headers 'some))
6187 (not (eq gnus-fetch-old-headers 'invisible))
6188 (null gnus-summary-expunge-below)
6189 (not (eq gnus-build-sparse-threads 'some))
6190 (not (eq gnus-build-sparse-threads 'more))
6191 (null gnus-thread-expunge-below)
6192 (not gnus-use-nocem)))
6194 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6195 (setq gnus-newsgroup-limit nil)
6198 (unless (car (symbol-value node))
6199 ;; These threads have no parents -- they are roots.
6200 (let ((nodes (cdr (symbol-value node)))
6203 (if (and gnus-thread-expunge-below
6204 (< (gnus-thread-total-score (car nodes))
6205 gnus-thread-expunge-below))
6206 (gnus-expunge-thread (pop nodes))
6207 (setq thread (pop nodes))
6208 (gnus-summary-limit-children thread))))))
6209 gnus-newsgroup-dependencies)
6210 ;; If this limitation resulted in an empty group, we might
6211 ;; pop the previous limit and use it instead.
6212 (when (and (not gnus-newsgroup-limit)
6214 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6215 gnus-newsgroup-limit))
6217 (defun gnus-summary-limit-children (thread)
6218 "Return 1 if this subthread is visible and 0 if it is not."
6219 ;; First we get the number of visible children to this thread. This
6220 ;; is done by recursing down the thread using this function, so this
6221 ;; will really go down to a leaf article first, before slowly
6222 ;; working its way up towards the root.
6226 (apply '+ (mapcar 'gnus-summary-limit-children
6229 (number (mail-header-number (car thread)))
6232 (not (memq number gnus-newsgroup-marked))
6234 ;; If this article is dormant and has absolutely no visible
6235 ;; children, then this article isn't visible.
6236 (and (memq number gnus-newsgroup-dormant)
6238 ;; If this is "fetch-old-headered" and there is no
6239 ;; visible children, then we don't want this article.
6240 (and (eq gnus-fetch-old-headers 'some)
6241 (gnus-summary-article-ancient-p number)
6243 ;; If this is "fetch-old-headered" and `invisible', then
6244 ;; we don't want this article.
6245 (and (eq gnus-fetch-old-headers 'invisible)
6246 (gnus-summary-article-ancient-p number))
6247 ;; If this is a sparsely inserted article with no children,
6248 ;; we don't want it.
6249 (and (eq gnus-build-sparse-threads 'some)
6250 (gnus-summary-article-sparse-p number)
6252 ;; If we use expunging, and this article is really
6253 ;; low-scored, then we don't want this article.
6254 (when (and gnus-summary-expunge-below
6256 (or (cdr (assq number gnus-newsgroup-scored))
6257 gnus-summary-default-score))
6258 gnus-summary-expunge-below))
6259 ;; We increase the expunge-tally here, but that has
6260 ;; nothing to do with the limits, really.
6261 (incf gnus-newsgroup-expunged-tally)
6262 ;; We also mark as read here, if that's wanted.
6263 (when (and gnus-summary-mark-below
6264 (< score gnus-summary-mark-below))
6265 (setq gnus-newsgroup-unreads
6266 (delq number gnus-newsgroup-unreads))
6267 (if gnus-newsgroup-auto-expire
6268 (push number gnus-newsgroup-expirable)
6269 (push (cons number gnus-low-score-mark)
6270 gnus-newsgroup-reads)))
6272 ;; Check NoCeM things.
6273 (if (and gnus-use-nocem
6274 (gnus-nocem-unwanted-article-p
6275 (mail-header-id (car thread))))
6277 (setq gnus-newsgroup-unreads
6278 (delq number gnus-newsgroup-unreads))
6280 ;; Nope, invisible article.
6282 ;; Ok, this article is to be visible, so we add it to the limit
6284 (push number gnus-newsgroup-limit)
6287 (defun gnus-expunge-thread (thread)
6288 "Mark all articles in THREAD as read."
6289 (let* ((number (mail-header-number (car thread))))
6290 (incf gnus-newsgroup-expunged-tally)
6291 ;; We also mark as read here, if that's wanted.
6292 (setq gnus-newsgroup-unreads
6293 (delq number gnus-newsgroup-unreads))
6294 (if gnus-newsgroup-auto-expire
6295 (push number gnus-newsgroup-expirable)
6296 (push (cons number gnus-low-score-mark)
6297 gnus-newsgroup-reads)))
6298 ;; Go recursively through all subthreads.
6299 (mapcar 'gnus-expunge-thread (cdr thread)))
6301 ;; Summary article oriented commands
6303 (defun gnus-summary-refer-parent-article (n)
6304 "Refer parent article N times.
6305 If N is negative, go to ancestor -N instead.
6306 The difference between N and the number of articles fetched is returned."
6310 (when (not (natnump n))
6315 (setq header (gnus-summary-article-header))
6316 (if (and (eq (mail-header-number header)
6317 (cdr gnus-article-current))
6318 (equal gnus-newsgroup-name
6319 (car gnus-article-current)))
6320 ;; If we try to find the parent of the currently
6321 ;; displayed article, then we take a look at the actual
6322 ;; References header, since this is slightly more
6323 ;; reliable than the References field we got from the
6326 (set-buffer gnus-original-article-buffer)
6327 (nnheader-narrow-to-headers)
6328 (unless (setq ref (message-fetch-field "references"))
6329 (setq ref (message-fetch-field "in-reply-to")))
6332 ;; It's not the current article, so we take a bet on
6333 ;; the value we got from the server.
6334 (mail-header-references header)))
6336 (not (equal ref "")))
6337 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6338 (gnus-message 1 "Couldn't find parent"))
6339 (gnus-message 1 "No references in article %d"
6340 (gnus-summary-article-number))
6343 (gnus-summary-position-point)
6346 (defun gnus-summary-refer-references ()
6347 "Fetch all articles mentioned in the References header.
6348 Return the number of articles fetched."
6350 (let ((ref (mail-header-references (gnus-summary-article-header)))
6351 (current (gnus-summary-article-number))
6355 (error "No References in the current article")
6356 ;; For each Message-ID in the References header...
6357 (while (string-match "<[^>]*>" ref)
6359 ;; ... fetch that article.
6360 (gnus-summary-refer-article
6361 (prog1 (match-string 0 ref)
6362 (setq ref (substring ref (match-end 0))))))
6363 (gnus-summary-goto-subject current)
6364 (gnus-summary-position-point)
6367 (defun gnus-summary-refer-thread (&optional limit)
6368 "Fetch all articles in the current thread.
6369 If LIMIT (the numerical prefix), fetch that many old headers instead
6370 of what's specified by the `gnus-refer-thread-limit' variable."
6372 (let ((id (mail-header-id (gnus-summary-article-header)))
6373 (limit (if limit (prefix-numeric-value limit)
6374 gnus-refer-thread-limit)))
6375 ;; We want to fetch LIMIT *old* headers, but we also have to
6376 ;; re-fetch all the headers in the current buffer, because many of
6377 ;; them may be undisplayed. So we adjust LIMIT.
6378 (when (numberp limit)
6379 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6380 (unless (eq gnus-fetch-old-headers 'invisible)
6381 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6382 ;; Retrieve the headers and read them in.
6383 (if (eq (gnus-retrieve-headers
6384 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6386 (gnus-build-all-threads)
6387 (error "Can't fetch thread from backends that don't support NOV"))
6388 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6389 (gnus-summary-limit-include-thread id)))
6391 (defun gnus-summary-refer-article (message-id &optional arg)
6392 "Fetch an article specified by MESSAGE-ID.
6393 If ARG (the prefix), fetch the article using `gnus-refer-article-method'
6394 or `gnus-select-method', no matter what backend the article comes from."
6395 (interactive "sMessage-ID: \nP")
6396 (when (and (stringp message-id)
6397 (not (zerop (length message-id))))
6398 ;; Construct the correct Message-ID if necessary.
6399 ;; Suggested by tale@pawl.rpi.edu.
6400 (unless (string-match "^<" message-id)
6401 (setq message-id (concat "<" message-id)))
6402 (unless (string-match ">$" message-id)
6403 (setq message-id (concat message-id ">")))
6404 (let* ((header (gnus-id-to-header message-id))
6406 (gnus-summary-article-sparse-p
6407 (mail-header-number header))
6408 (memq (mail-header-number header)
6409 gnus-newsgroup-limit))))
6411 ;; If the article is present in the buffer we just go to it.
6413 (or (not (gnus-summary-article-sparse-p
6414 (mail-header-number header)))
6417 (gnus-summary-goto-article
6418 (mail-header-number header) nil t)
6420 (gnus-summary-update-article (mail-header-number header)))))
6422 ;; We fetch the article
6423 (let ((gnus-override-method
6424 (cond ((gnus-news-group-p gnus-newsgroup-name)
6425 gnus-refer-article-method)
6427 (or gnus-refer-article-method gnus-select-method))
6430 ;; Start the special refer-article method, if necessary.
6431 (when (and gnus-refer-article-method
6432 (gnus-news-group-p gnus-newsgroup-name))
6433 (gnus-check-server gnus-refer-article-method))
6434 ;; Fetch the header, and display the article.
6435 (if (setq number (gnus-summary-insert-subject message-id))
6436 (gnus-summary-select-article nil nil nil number)
6437 (gnus-message 3 "Couldn't fetch article %s" message-id))))))))
6439 (defun gnus-summary-edit-parameters ()
6440 "Edit the group parameters of the current group."
6442 (gnus-group-edit-group gnus-newsgroup-name 'params))
6444 (defun gnus-summary-enter-digest-group (&optional force)
6445 "Enter an nndoc group based on the current article.
6446 If FORCE, force a digest interpretation. If not, try
6447 to guess what the document format is."
6449 (let ((conf gnus-current-window-configuration))
6451 (gnus-summary-select-article))
6452 (setq gnus-current-window-configuration conf)
6453 (let* ((name (format "%s-%d"
6454 (gnus-group-prefixed-name
6455 gnus-newsgroup-name (list 'nndoc ""))
6457 (set-buffer gnus-summary-buffer)
6458 gnus-current-article)))
6459 (ogroup gnus-newsgroup-name)
6460 (params (append (gnus-info-params (gnus-get-info ogroup))
6461 (list (cons 'to-group ogroup))
6462 (list (cons 'save-article-group ogroup))))
6463 (case-fold-search t)
6464 (buf (current-buffer))
6467 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6468 (insert-buffer-substring gnus-original-article-buffer)
6469 ;; Remove lines that may lead nndoc to misinterpret the
6472 (goto-char (point-min))
6473 (or (search-forward "\n\n" nil t) (point)))
6474 (goto-char (point-min))
6475 (delete-matching-lines "^\\(Path\\):\\|^From ")
6478 (if (gnus-group-read-ephemeral-group
6479 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6481 ,(if force 'digest 'guess))) t)
6482 ;; Make all postings to this group go to the parent group.
6483 (nconc (gnus-info-params (gnus-get-info name))
6485 ;; Couldn't select this doc group.
6486 (switch-to-buffer buf)
6487 (gnus-set-global-variables)
6488 (gnus-configure-windows 'summary)
6489 (gnus-message 3 "Article couldn't be entered?"))
6490 (kill-buffer dig)))))
6492 (defun gnus-summary-read-document (n)
6493 "Open a new group based on the current article(s).
6494 This will allow you to read digests and other similar
6495 documents as newsgroups.
6496 Obeys the standard process/prefix convention."
6498 (let* ((articles (gnus-summary-work-articles n))
6499 (ogroup gnus-newsgroup-name)
6500 (params (append (gnus-info-params (gnus-get-info ogroup))
6501 (list (cons 'to-group ogroup))))
6502 article group egroup groups vgroup)
6503 (while (setq article (pop articles))
6504 (setq group (format "%s-%d" gnus-newsgroup-name article))
6505 (gnus-summary-remove-process-mark article)
6506 (when (gnus-summary-display-article article)
6509 (insert-buffer-substring gnus-original-article-buffer)
6510 ;; Remove some headers that may lead nndoc to make
6512 (message-narrow-to-head)
6513 (goto-char (point-min))
6514 (delete-matching-lines "^\\(Path\\):\\|^From ")
6517 (gnus-group-read-ephemeral-group
6518 group `(nndoc ,group (nndoc-address ,(current-buffer))
6519 (nndoc-article-type guess))
6522 ;; Make all postings to this group go to the parent group.
6523 (nconc (gnus-info-params (gnus-get-info egroup))
6525 (push egroup groups))
6526 ;; Couldn't select this doc group.
6527 (gnus-error 3 "Article couldn't be entered"))))))
6528 ;; Now we have selected all the documents.
6531 (error "None of the articles could be interpreted as documents"))
6532 ((gnus-group-read-ephemeral-group
6533 (setq vgroup (format
6534 "nnvirtual:%s-%s" gnus-newsgroup-name
6535 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6536 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6538 (cons (current-buffer) 'summary)))
6540 (error "Couldn't select virtual nndoc group")))))
6542 (defun gnus-summary-isearch-article (&optional regexp-p)
6543 "Do incremental search forward on the current article.
6544 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6546 (gnus-summary-select-article)
6547 (gnus-configure-windows 'article)
6548 (gnus-eval-in-buffer-window gnus-article-buffer
6551 (isearch-forward regexp-p))))
6553 (defun gnus-summary-search-article-forward (regexp &optional backward)
6554 "Search for an article containing REGEXP forward.
6555 If BACKWARD, search backward instead."
6558 (format "Search article %s (regexp%s): "
6559 (if current-prefix-arg "backward" "forward")
6560 (if gnus-last-search-regexp
6561 (concat ", default " gnus-last-search-regexp)
6563 current-prefix-arg))
6564 (if (string-equal regexp "")
6565 (setq regexp (or gnus-last-search-regexp ""))
6566 (setq gnus-last-search-regexp regexp))
6567 (if (gnus-summary-search-article regexp backward)
6568 (gnus-summary-show-thread)
6569 (error "Search failed: \"%s\"" regexp)))
6571 (defun gnus-summary-search-article-backward (regexp)
6572 "Search for an article containing REGEXP backward."
6575 (format "Search article backward (regexp%s): "
6576 (if gnus-last-search-regexp
6577 (concat ", default " gnus-last-search-regexp)
6579 (gnus-summary-search-article-forward regexp 'backward))
6581 (defun gnus-summary-search-article (regexp &optional backward)
6582 "Search for an article containing REGEXP.
6583 Optional argument BACKWARD means do search for backward.
6584 `gnus-select-article-hook' is not called during the search."
6585 ;; We have to require this here to make sure that the following
6586 ;; dynamic binding isn't shadowed by autoloading.
6587 (require 'gnus-async)
6588 (let ((gnus-select-article-hook nil) ;Disable hook.
6589 (gnus-article-display-hook nil)
6590 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6591 (gnus-use-article-prefetch nil)
6592 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
6593 (gnus-use-trees nil) ;Inhibit updating tree buffer.
6594 (sum (current-buffer))
6597 (gnus-save-hidden-threads
6598 (gnus-summary-select-article)
6599 (set-buffer gnus-article-buffer)
6603 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
6605 (re-search-backward regexp nil t)
6606 (re-search-forward regexp nil t))
6607 ;; We found the regexp.
6612 (get-buffer-window (current-buffer))
6616 (setq point (point)))
6617 ;; We didn't find it, so we go to the next article.
6620 (while (eq found 'not)
6621 (if (not (if backward (gnus-summary-find-prev)
6622 (gnus-summary-find-next)))
6623 ;; No more articles.
6625 ;; Select the next article and adjust point.
6626 (unless (gnus-summary-article-sparse-p
6627 (gnus-summary-article-number))
6629 (gnus-summary-select-article)
6630 (set-buffer gnus-article-buffer)
6632 (goto-char (if backward (point-max) (point-min))))))))
6633 (gnus-message 7 ""))
6634 ;; Return whether we found the regexp.
6635 (when (eq found 'found)
6637 (gnus-summary-show-thread)
6638 (gnus-summary-goto-subject gnus-current-article)
6639 (gnus-summary-position-point)
6642 (defun gnus-summary-find-matching (header regexp &optional backward unread
6644 "Return a list of all articles that match REGEXP on HEADER.
6645 The search stars on the current article and goes forwards unless
6646 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
6647 If UNREAD is non-nil, only unread articles will
6648 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
6649 in the comparisons."
6650 (let ((data (if (eq backward 'all) gnus-newsgroup-data
6651 (gnus-data-find-list
6652 (gnus-summary-article-number) (gnus-data-list backward))))
6653 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
6654 (case-fold-search (not not-case-fold))
6656 (unless (fboundp (intern (concat "mail-header-" header)))
6657 (error "%s is not a valid header" header))
6660 (and (or (not unread) ; We want all articles...
6661 (gnus-data-unread-p d)) ; Or just unreads.
6662 (vectorp (gnus-data-header d)) ; It's not a pseudo.
6663 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
6664 (push (gnus-data-number d) articles)) ; Success!
6665 (setq data (cdr data)))
6666 (nreverse articles)))
6668 (defun gnus-summary-execute-command (header regexp command &optional backward)
6669 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
6670 If HEADER is an empty string (or nil), the match is done on the entire
6671 article. If BACKWARD (the prefix) is non-nil, search backward instead."
6673 (list (let ((completion-ignore-case t))
6676 (mapcar (lambda (string) (list string))
6677 '("Number" "Subject" "From" "Lines" "Date"
6678 "Message-ID" "Xref" "References" "Body"))
6679 nil 'require-match))
6680 (read-string "Regexp: ")
6681 (read-key-sequence "Command: ")
6682 current-prefix-arg))
6683 (when (equal header "Body")
6685 ;; Hidden thread subtrees must be searched as well.
6686 (gnus-summary-show-all-threads)
6687 ;; We don't want to change current point nor window configuration.
6689 (save-window-excursion
6690 (gnus-message 6 "Executing %s..." (key-description command))
6691 ;; We'd like to execute COMMAND interactively so as to give arguments.
6692 (gnus-execute header regexp
6693 `(call-interactively ',(key-binding command))
6695 (gnus-message 6 "Executing %s...done" (key-description command)))))
6697 (defun gnus-summary-beginning-of-article ()
6698 "Scroll the article back to the beginning."
6700 (gnus-summary-select-article)
6701 (gnus-configure-windows 'article)
6702 (gnus-eval-in-buffer-window gnus-article-buffer
6704 (goto-char (point-min))
6705 (when gnus-page-broken
6706 (gnus-narrow-to-page))))
6708 (defun gnus-summary-end-of-article ()
6709 "Scroll to the end of the article."
6711 (gnus-summary-select-article)
6712 (gnus-configure-windows 'article)
6713 (gnus-eval-in-buffer-window gnus-article-buffer
6715 (goto-char (point-max))
6717 (when gnus-page-broken
6718 (gnus-narrow-to-page))))
6720 (defun gnus-summary-print-article (&optional filename n)
6721 "Generate and print a PostScript image of the N next (mail) articles.
6723 If N is negative, print the N previous articles. If N is nil and articles
6724 have been marked with the process mark, print these instead.
6726 If the optional second argument FILENAME is nil, send the image to the
6727 printer. If FILENAME is a string, save the PostScript image in a file with
6728 that name. If FILENAME is a number, prompt the user for the name of the file
6730 (interactive (list (ps-print-preprint current-prefix-arg)
6731 current-prefix-arg))
6732 (dolist (article (gnus-summary-work-articles n))
6733 (gnus-summary-select-article nil nil 'pseudo article)
6734 (gnus-eval-in-buffer-window gnus-article-buffer
6735 (let ((buffer (generate-new-buffer " *print*")))
6738 (copy-to-buffer buffer (point-min) (point-max))
6740 (gnus-article-delete-invisible-text)
6741 (let ((ps-left-header
6744 (mail-header-subject gnus-current-headers) ")")
6746 (mail-header-from gnus-current-headers) ")")))
6749 "/pagenumberstring load"
6751 (mail-header-date gnus-current-headers) ")"))))
6752 (gnus-run-hooks 'gnus-ps-print-hook)
6754 (ps-print-buffer-with-faces filename))))
6755 (kill-buffer buffer))))))
6757 (defun gnus-summary-show-article (&optional arg)
6758 "Force re-fetching of the current article.
6759 If ARG (the prefix) is non-nil, show the raw article without any
6760 article massaging functions being run."
6763 ;; Select the article the normal way.
6764 (gnus-summary-select-article nil 'force)
6765 ;; Bind the article treatment functions to nil.
6766 (let ((gnus-have-all-headers t)
6767 gnus-article-display-hook
6768 gnus-article-prepare-hook
6772 (gnus-summary-select-article nil 'force)))
6773 (gnus-summary-goto-subject gnus-current-article)
6774 (gnus-summary-position-point))
6776 (defun gnus-summary-verbose-headers (&optional arg)
6777 "Toggle permanent full header display.
6778 If ARG is a positive number, turn header display on.
6779 If ARG is a negative number, turn header display off."
6781 (setq gnus-show-all-headers
6782 (cond ((or (not (numberp arg))
6784 (not gnus-show-all-headers))
6787 (gnus-summary-show-article))
6789 (defun gnus-summary-toggle-header (&optional arg)
6790 "Show the headers if they are hidden, or hide them if they are shown.
6791 If ARG is a positive number, show the entire header.
6792 If ARG is a negative number, hide the unwanted header lines."
6795 (set-buffer gnus-article-buffer)
6796 (let* ((buffer-read-only nil)
6797 (inhibit-point-motion-hooks t)
6798 (hidden (text-property-any
6799 (goto-char (point-min)) (search-forward "\n\n")
6802 (goto-char (point-min))
6803 (when (search-forward "\n\n" nil t)
6804 (delete-region (point-min) (1- (point))))
6805 (goto-char (point-min))
6807 (set-buffer gnus-original-article-buffer)
6808 (goto-char (point-min))
6809 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
6810 (insert-buffer-substring gnus-original-article-buffer 1 e)
6811 (let ((article-inhibit-hiding t))
6812 (gnus-run-hooks 'gnus-article-display-hook))
6813 (when (or (not hidden) (and (numberp arg) (< arg 0)))
6814 (gnus-article-hide-headers)))))
6816 (defun gnus-summary-show-all-headers ()
6817 "Make all header lines visible."
6819 (gnus-article-show-all-headers))
6821 (defun gnus-summary-toggle-mime (&optional arg)
6822 "Toggle MIME processing.
6823 If ARG is a positive number, turn MIME processing on."
6825 (setq gnus-show-mime
6826 (if (null arg) (not gnus-show-mime)
6827 (> (prefix-numeric-value arg) 0)))
6828 (gnus-summary-select-article t 'force))
6830 (defun gnus-summary-caesar-message (&optional arg)
6831 "Caesar rotate the current article by 13.
6832 The numerical prefix specifies how many places to rotate each letter
6835 (gnus-summary-select-article)
6836 (let ((mail-header-separator ""))
6837 (gnus-eval-in-buffer-window gnus-article-buffer
6840 (let ((start (window-start))
6842 (message-caesar-buffer-body arg)
6843 (set-window-start (get-buffer-window (current-buffer)) start))))))
6845 (defun gnus-summary-stop-page-breaking ()
6846 "Stop page breaking in the current article."
6848 (gnus-summary-select-article)
6849 (gnus-eval-in-buffer-window gnus-article-buffer
6851 (when (gnus-visual-p 'page-marker)
6852 (let ((buffer-read-only nil))
6853 (gnus-remove-text-with-property 'gnus-prev)
6854 (gnus-remove-text-with-property 'gnus-next))
6855 (setq gnus-page-broken nil))))
6857 (defun gnus-summary-move-article (&optional n to-newsgroup
6858 select-method action)
6859 "Move the current article to a different newsgroup.
6860 If N is a positive number, move the N next articles.
6861 If N is a negative number, move the N previous articles.
6862 If N is nil and any articles have been marked with the process mark,
6863 move those articles instead.
6864 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6865 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6866 re-spool using this method.
6868 For this function to work, both the current newsgroup and the
6869 newsgroup that you want to move to have to support the `request-move'
6870 and `request-accept' functions."
6873 (setq action 'move))
6874 ;; Disable marking as read.
6875 (let (gnus-mark-article-hook)
6876 (save-window-excursion
6877 (gnus-summary-select-article)))
6878 ;; Check whether the source group supports the required functions.
6879 (cond ((and (eq action 'move)
6880 (not (gnus-check-backend-function
6881 'request-move-article gnus-newsgroup-name)))
6882 (error "The current group does not support article moving"))
6883 ((and (eq action 'crosspost)
6884 (not (gnus-check-backend-function
6885 'request-replace-article gnus-newsgroup-name)))
6886 (error "The current group does not support article editing")))
6887 (let ((articles (gnus-summary-work-articles n))
6888 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
6889 (names '((move "Move" "Moving")
6890 (copy "Copy" "Copying")
6891 (crosspost "Crosspost" "Crossposting")))
6892 (copy-buf (save-excursion
6893 (nnheader-set-temp-buffer " *copy article*")))
6894 art-group to-method new-xref article to-groups)
6895 (unless (assq action names)
6896 (error "Unknown action %s" action))
6897 ;; Read the newsgroup name.
6898 (when (and (not to-newsgroup)
6899 (not select-method))
6901 (gnus-read-move-group-name
6902 (cadr (assq action names))
6903 (symbol-value (intern (format "gnus-current-%s-group" action)))
6905 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
6906 (setq to-method (or select-method
6907 (gnus-group-name-to-method to-newsgroup)))
6908 ;; Check the method we are to move this article to...
6909 (unless (gnus-check-backend-function
6910 'request-accept-article (car to-method))
6911 (error "%s does not support article copying" (car to-method)))
6912 (unless (gnus-check-server to-method)
6913 (error "Can't open server %s" (car to-method)))
6914 (gnus-message 6 "%s to %s: %s..."
6915 (caddr (assq action names))
6916 (or (car select-method) to-newsgroup) articles)
6918 (setq article (pop articles))
6922 ;; Move the article.
6924 ;; Remove this article from future suppression.
6925 (gnus-dup-unsuppress-article article)
6926 (gnus-request-move-article
6927 article ; Article to move
6928 gnus-newsgroup-name ; From newsgroup
6929 (nth 1 (gnus-find-method-for-group
6930 gnus-newsgroup-name)) ; Server
6931 (list 'gnus-request-accept-article
6932 to-newsgroup (list 'quote select-method)
6933 (not articles)) ; Accept form
6934 (not articles))) ; Only save nov last time
6935 ;; Copy the article.
6938 (set-buffer copy-buf)
6939 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
6940 (gnus-request-accept-article
6941 to-newsgroup select-method (not articles)))))
6942 ;; Crosspost the article.
6943 ((eq action 'crosspost)
6944 (let ((xref (message-tokenize-header
6945 (mail-header-xref (gnus-summary-article-header article))
6947 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
6950 (setq xref (list (system-name))))
6953 (mapconcat 'identity
6954 (delete "Xref:" (delete new-xref xref))
6958 (set-buffer copy-buf)
6959 ;; First put the article in the destination group.
6960 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6961 (when (consp (setq art-group
6962 (gnus-request-accept-article
6963 to-newsgroup select-method (not articles))))
6964 (setq new-xref (concat new-xref " " (car art-group)
6965 ":" (cdr art-group)))
6966 ;; Now we have the new Xrefs header, so we insert
6967 ;; it and replace the new article.
6968 (nnheader-replace-header "Xref" new-xref)
6969 (gnus-request-replace-article
6970 (cdr art-group) to-newsgroup (current-buffer))
6974 (gnus-message 1 "Couldn't %s article %s"
6975 (cadr (assq action names)) article))
6976 ((and (eq art-group 'junk)
6978 (gnus-summary-mark-article article gnus-canceled-mark)
6979 (gnus-message 4 "Deleted article %s" article))
6981 (let* ((pto-group (gnus-group-prefixed-name
6982 (car art-group) to-method))
6984 (gnus-gethash pto-group gnus-newsrc-hashtb))
6985 (info (nth 2 entry))
6986 (to-group (gnus-info-group info)))
6987 ;; Update the group that has been moved to.
6989 (memq action '(move copy)))
6990 (unless (member to-group to-groups)
6991 (push to-group to-groups))
6993 (unless (memq article gnus-newsgroup-unreads)
6995 info (gnus-add-to-range (gnus-info-read info)
6996 (list (cdr art-group)))))
6998 ;; Copy any marks over to the new group.
6999 (let ((marks gnus-article-mark-lists)
7000 (to-article (cdr art-group)))
7002 ;; See whether the article is to be put in the cache.
7003 (when gnus-use-cache
7004 (gnus-cache-possibly-enter-article
7006 (let ((header (copy-sequence
7007 (gnus-summary-article-header article))))
7008 (mail-header-set-number header to-article)
7010 (memq article gnus-newsgroup-marked)
7011 (memq article gnus-newsgroup-dormant)
7012 (memq article gnus-newsgroup-unreads)))
7014 (when (and (equal to-group gnus-newsgroup-name)
7015 (not (memq article gnus-newsgroup-unreads)))
7016 ;; Mark this article as read in this group.
7017 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7018 (setcdr (gnus-active to-group) to-article)
7019 (setcdr gnus-newsgroup-active to-article))
7022 (when (memq article (symbol-value
7023 (intern (format "gnus-newsgroup-%s"
7025 ;; If the other group is the same as this group,
7026 ;; then we have to add the mark to the list.
7027 (when (equal to-group gnus-newsgroup-name)
7028 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7031 (intern (format "gnus-newsgroup-%s"
7033 ;; Copy the marks to other group.
7034 (gnus-add-marked-articles
7035 to-group (cdar marks) (list to-article) info))
7036 (setq marks (cdr marks)))
7039 (concat "(gnus-group-set-info '"
7040 (gnus-prin1-to-string (gnus-get-info to-group))
7043 ;; Update the Xref header in this article to point to
7044 ;; the new crossposted article we have just created.
7045 (when (eq action 'crosspost)
7047 (set-buffer copy-buf)
7048 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7049 (nnheader-replace-header "Xref" new-xref)
7050 (gnus-request-replace-article
7051 article gnus-newsgroup-name (current-buffer)))))
7053 ;;;!!!Why is this necessary?
7054 (set-buffer gnus-summary-buffer)
7056 (gnus-summary-goto-subject article)
7057 (when (eq action 'move)
7058 (gnus-summary-mark-article article gnus-canceled-mark))))
7059 (gnus-summary-remove-process-mark article))
7060 ;; Re-activate all groups that have been moved to.
7063 (set-buffer gnus-group-buffer)
7064 (when (gnus-group-goto-group (car to-groups) t)
7065 (gnus-group-get-new-news-this-group 1 t))
7068 (gnus-kill-buffer copy-buf)
7069 (gnus-summary-position-point)
7070 (gnus-set-mode-line 'summary)))
7072 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7073 "Move the current article to a different newsgroup.
7074 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7075 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7076 re-spool using this method."
7078 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7080 (defun gnus-summary-crosspost-article (&optional n)
7081 "Crosspost the current article to some other group."
7083 (gnus-summary-move-article n nil nil 'crosspost))
7085 (defcustom gnus-summary-respool-default-method nil
7086 "Default method for respooling an article.
7087 If nil, use to the current newsgroup method."
7088 :type `(choice (gnus-select-method :value (nnml ""))
7090 :group 'gnus-summary-mail)
7092 (defun gnus-summary-respool-article (&optional n method)
7093 "Respool the current article.
7094 The article will be squeezed through the mail spooling process again,
7095 which means that it will be put in some mail newsgroup or other
7096 depending on `nnmail-split-methods'.
7097 If N is a positive number, respool the N next articles.
7098 If N is a negative number, respool the N previous articles.
7099 If N is nil and any articles have been marked with the process mark,
7100 respool those articles instead.
7102 Respooling can be done both from mail groups and \"real\" newsgroups.
7103 In the former case, the articles in question will be moved from the
7104 current group into whatever groups they are destined to. In the
7105 latter case, they will be copied into the relevant groups."
7107 (list current-prefix-arg
7108 (let* ((methods (gnus-methods-using 'respool))
7110 (symbol-name (or gnus-summary-respool-default-method
7111 (car (gnus-find-method-for-group
7112 gnus-newsgroup-name)))))
7114 (gnus-completing-read
7115 methname "What backend do you want to use when respooling?"
7116 methods nil t nil 'gnus-mail-method-history))
7119 ((zerop (length (setq ms (gnus-servers-using-backend
7121 (list (intern method) ""))
7125 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7126 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7129 (error "No method given for respooling"))
7130 (if (assoc (symbol-name
7131 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7132 (gnus-methods-using 'respool))
7133 (gnus-summary-move-article n nil method)
7134 (gnus-summary-copy-article n nil method)))
7136 (defun gnus-summary-import-article (file)
7137 "Import an arbitrary file into a mail newsgroup."
7138 (interactive "fImport file: ")
7139 (let ((group gnus-newsgroup-name)
7140 (now (current-time))
7142 (unless (gnus-check-backend-function 'request-accept-article group)
7143 (error "%s does not support article importing" group))
7144 (or (file-readable-p file)
7145 (not (file-regular-p file))
7146 (error "Can't read %s" file))
7148 (set-buffer (gnus-get-buffer-create " *import file*"))
7149 (buffer-disable-undo (current-buffer))
7151 (insert-file-contents file)
7152 (goto-char (point-min))
7153 (unless (nnheader-article-p)
7154 ;; This doesn't look like an article, so we fudge some headers.
7155 (setq atts (file-attributes file)
7156 lines (count-lines (point-min) (point-max)))
7157 (insert "From: " (read-string "From: ") "\n"
7158 "Subject: " (read-string "Subject: ") "\n"
7159 "Date: " (timezone-make-date-arpa-standard
7160 (current-time-string (nth 5 atts))
7161 (current-time-zone now)
7162 (current-time-zone now))
7164 "Message-ID: " (message-make-message-id) "\n"
7165 "Lines: " (int-to-string lines) "\n"
7166 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7167 (gnus-request-accept-article group nil t)
7168 (kill-buffer (current-buffer)))))
7170 (defun gnus-summary-article-posted-p ()
7171 "Say whether the current (mail) article is available from `gnus-select-method' as well.
7172 This will be the case if the article has both been mailed and posted."
7174 (let ((id (mail-header-references (gnus-summary-article-header)))
7175 (gnus-override-method
7176 (or gnus-refer-article-method gnus-select-method)))
7177 (if (gnus-request-head id "")
7178 (gnus-message 2 "The current message was found on %s"
7179 gnus-override-method)
7180 (gnus-message 2 "The current message couldn't be found on %s"
7181 gnus-override-method)
7184 (defun gnus-summary-expire-articles (&optional now)
7185 "Expire all articles that are marked as expirable in the current group."
7187 (when (gnus-check-backend-function
7188 'request-expire-articles gnus-newsgroup-name)
7189 ;; This backend supports expiry.
7190 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7191 (expirable (if total
7193 ;; We need to update the info for
7194 ;; this group for `gnus-list-of-read-articles'
7195 ;; to give us the right answer.
7196 (gnus-run-hooks 'gnus-exit-group-hook)
7197 (gnus-summary-update-info)
7198 (gnus-list-of-read-articles gnus-newsgroup-name))
7199 (setq gnus-newsgroup-expirable
7200 (sort gnus-newsgroup-expirable '<))))
7201 (expiry-wait (if now 'immediate
7202 (gnus-group-find-parameter
7203 gnus-newsgroup-name 'expiry-wait)))
7206 ;; There are expirable articles in this group, so we run them
7207 ;; through the expiry process.
7208 (gnus-message 6 "Expiring articles...")
7209 ;; The list of articles that weren't expired is returned.
7212 (let ((nnmail-expiry-wait-function nil)
7213 (nnmail-expiry-wait expiry-wait))
7214 (setq es (gnus-request-expire-articles
7215 expirable gnus-newsgroup-name)))
7216 (setq es (gnus-request-expire-articles
7217 expirable gnus-newsgroup-name))))
7219 (setq gnus-newsgroup-expirable es))
7220 ;; We go through the old list of expirable, and mark all
7221 ;; really expired articles as nonexistent.
7222 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7223 (let ((gnus-use-cache nil))
7225 (unless (memq (car expirable) es)
7226 (when (gnus-data-find (car expirable))
7227 (gnus-summary-mark-article
7228 (car expirable) gnus-canceled-mark)))
7229 (setq expirable (cdr expirable)))))
7230 (gnus-message 6 "Expiring articles...done")))))
7232 (defun gnus-summary-expire-articles-now ()
7233 "Expunge all expirable articles in the current group.
7234 This means that *all* articles that are marked as expirable will be
7235 deleted forever, right now."
7237 (or gnus-expert-user
7239 "Are you really, really, really sure you want to delete all these messages? ")
7241 (gnus-summary-expire-articles t))
7243 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7244 (defun gnus-summary-delete-article (&optional n)
7245 "Delete the N next (mail) articles.
7246 This command actually deletes articles. This is not a marking
7247 command. The article will disappear forever from your life, never to
7249 If N is negative, delete backwards.
7250 If N is nil and articles have been marked with the process mark,
7251 delete these instead."
7253 (unless (gnus-check-backend-function 'request-expire-articles
7254 gnus-newsgroup-name)
7255 (error "The current newsgroup does not support article deletion"))
7256 ;; Compute the list of articles to delete.
7257 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
7259 (if (and gnus-novice-user
7260 (not (gnus-yes-or-no-p
7261 (format "Do you really want to delete %s forever? "
7262 (if (> (length articles) 1)
7263 (format "these %s articles" (length articles))
7266 ;; Delete the articles.
7267 (setq not-deleted (gnus-request-expire-articles
7268 articles gnus-newsgroup-name 'force))
7270 (gnus-summary-remove-process-mark (car articles))
7271 ;; The backend might not have been able to delete the article
7273 (unless (memq (car articles) not-deleted)
7274 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7275 (setq articles (cdr articles)))
7277 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7278 (gnus-summary-position-point)
7279 (gnus-set-mode-line 'summary)
7282 (defun gnus-summary-edit-article (&optional force)
7283 "Edit the current article.
7284 This will have permanent effect only in mail groups.
7285 If FORCE is non-nil, allow editing of articles even in read-only
7289 (set-buffer gnus-summary-buffer)
7290 (gnus-set-global-variables)
7291 (when (and (not force)
7292 (gnus-group-read-only-p))
7293 (error "The current newsgroup does not support article editing"))
7294 ;; Select article if needed.
7295 (unless (eq (gnus-summary-article-number)
7296 gnus-current-article)
7297 (gnus-summary-select-article t))
7298 (gnus-article-date-original)
7299 (gnus-article-edit-article
7300 `(lambda (no-highlight)
7301 (gnus-summary-edit-article-done
7302 ,(or (mail-header-references gnus-current-headers) "")
7303 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))
7305 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7307 (defun gnus-summary-edit-article-done (&optional references read-only buffer
7309 "Make edits to the current article permanent."
7311 ;; Replace the article.
7312 (let ((buf (current-buffer)))
7315 (if (and (not read-only)
7316 (not (gnus-request-replace-article
7317 (cdr gnus-article-current) (car gnus-article-current)
7319 (error "Couldn't replace article")
7320 ;; Update the summary buffer.
7322 (equal (message-tokenize-header references " ")
7323 (message-tokenize-header
7324 (or (message-fetch-field "references") "") " ")))
7325 ;; We only have to update this line.
7328 (message-narrow-to-head)
7329 (let ((head (buffer-string))
7332 (insert (format "211 %d Article retrieved.\n"
7333 (cdr gnus-article-current)))
7336 (let ((nntp-server-buffer (current-buffer)))
7337 (setq header (car (gnus-get-newsgroup-headers
7339 (set-buffer gnus-summary-buffer)
7340 gnus-newsgroup-dependencies)
7343 (set-buffer gnus-summary-buffer)
7344 (gnus-data-set-header
7345 (gnus-data-find (cdr gnus-article-current))
7347 (gnus-summary-update-article-line
7348 (cdr gnus-article-current) header))))))
7350 (set-buffer (or buffer gnus-summary-buffer))
7351 (gnus-summary-update-article (cdr gnus-article-current)))
7352 ;; Prettify the article buffer again.
7353 (unless no-highlight
7355 (set-buffer gnus-article-buffer)
7356 (gnus-run-hooks 'gnus-article-display-hook)
7357 (set-buffer gnus-original-article-buffer)
7358 (gnus-request-article
7359 (cdr gnus-article-current)
7360 (car gnus-article-current) (current-buffer))))
7361 ;; Prettify the summary buffer line.
7362 (when (gnus-visual-p 'summary-highlight 'highlight)
7363 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
7365 (defun gnus-summary-edit-wash (key)
7366 "Perform editing command KEY in the article buffer."
7370 (message "%s" (concat (this-command-keys) "- "))
7373 (gnus-summary-edit-article)
7374 (execute-kbd-macro (concat (this-command-keys) key))
7375 (gnus-article-edit-done))
7379 (defun gnus-summary-respool-query (&optional silent trace)
7380 "Query where the respool algorithm would put this article."
7382 (let (gnus-mark-article-hook)
7383 (gnus-summary-select-article)
7385 (set-buffer gnus-original-article-buffer)
7387 (message-narrow-to-head)
7388 (let ((groups (nnmail-article-group 'identity trace)))
7391 (message "This message would go to %s"
7392 (mapconcat 'car groups ", "))
7393 (message "This message would go to no groups"))
7396 (defun gnus-summary-respool-trace ()
7397 "Trace where the respool algorithm would put this article.
7398 Display a buffer showing all fancy splitting patterns which matched."
7400 (gnus-summary-respool-query nil t))
7402 ;; Summary marking commands.
7404 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
7405 "Mark articles which has the same subject as read, and then select the next.
7406 If UNMARK is positive, remove any kind of mark.
7407 If UNMARK is negative, tick articles."
7410 (setq unmark (prefix-numeric-value unmark)))
7412 (gnus-summary-mark-same-subject
7413 (gnus-summary-article-subject) unmark)))
7414 ;; Select next unread article. If auto-select-same mode, should
7415 ;; select the first unread article.
7416 (gnus-summary-next-article t (and gnus-auto-select-same
7417 (gnus-summary-article-subject)))
7418 (gnus-message 7 "%d article%s marked as %s"
7419 count (if (= count 1) " is" "s are")
7420 (if unmark "unread" "read"))))
7422 (defun gnus-summary-kill-same-subject (&optional unmark)
7423 "Mark articles which has the same subject as read.
7424 If UNMARK is positive, remove any kind of mark.
7425 If UNMARK is negative, tick articles."
7428 (setq unmark (prefix-numeric-value unmark)))
7430 (gnus-summary-mark-same-subject
7431 (gnus-summary-article-subject) unmark)))
7432 ;; If marked as read, go to next unread subject.
7434 ;; Go to next unread subject.
7435 (gnus-summary-next-subject 1 t))
7436 (gnus-message 7 "%d articles are marked as %s"
7437 count (if unmark "unread" "read"))))
7439 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7440 "Mark articles with same SUBJECT as read, and return marked number.
7441 If optional argument UNMARK is positive, remove any kinds of marks.
7442 If optional argument UNMARK is negative, mark articles as unread instead."
7446 ((null unmark) ; Mark as read.
7449 (gnus-summary-mark-article-as-read gnus-killed-mark)
7450 (gnus-summary-show-thread) t)
7451 (gnus-summary-find-subject subject))
7452 (setq count (1+ count))))
7453 ((> unmark 0) ; Tick.
7456 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
7457 (gnus-summary-show-thread) t)
7458 (gnus-summary-find-subject subject))
7459 (setq count (1+ count))))
7460 (t ; Mark as unread.
7463 (gnus-summary-mark-article-as-unread gnus-unread-mark)
7464 (gnus-summary-show-thread) t)
7465 (gnus-summary-find-subject subject))
7466 (setq count (1+ count)))))
7467 (gnus-set-mode-line 'summary)
7468 ;; Return the number of marked articles.
7471 (defun gnus-summary-mark-as-processable (n &optional unmark)
7472 "Set the process mark on the next N articles.
7473 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7474 the process mark instead. The difference between N and the actual
7475 number of articles marked is returned."
7477 (let ((backward (< n 0))
7482 (gnus-summary-remove-process-mark
7483 (gnus-summary-article-number))
7484 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7485 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7488 (gnus-message 7 "No more articles"))
7489 (gnus-summary-recenter)
7490 (gnus-summary-position-point)
7493 (defun gnus-summary-unmark-as-processable (n)
7494 "Remove the process mark from the next N articles.
7495 If N is negative, unmark backward instead. The difference between N and
7496 the actual number of articles unmarked is returned."
7498 (gnus-summary-mark-as-processable n t))
7500 (defun gnus-summary-unmark-all-processable ()
7501 "Remove the process mark from all articles."
7504 (while gnus-newsgroup-processable
7505 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7506 (gnus-summary-position-point))
7508 (defun gnus-summary-mark-as-expirable (n)
7509 "Mark N articles forward as expirable.
7510 If N is negative, mark backward instead. The difference between N and
7511 the actual number of articles marked is returned."
7513 (gnus-summary-mark-forward n gnus-expirable-mark))
7515 (defun gnus-summary-mark-article-as-replied (article)
7516 "Mark ARTICLE replied and update the summary line."
7517 (push article gnus-newsgroup-replied)
7518 (let ((buffer-read-only nil))
7519 (when (gnus-summary-goto-subject article)
7520 (gnus-summary-update-secondary-mark article))))
7522 (defun gnus-summary-set-bookmark (article)
7523 "Set a bookmark in current article."
7524 (interactive (list (gnus-summary-article-number)))
7525 (when (or (not (get-buffer gnus-article-buffer))
7526 (not gnus-current-article)
7527 (not gnus-article-current)
7528 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7529 (error "No current article selected"))
7530 ;; Remove old bookmark, if one exists.
7531 (let ((old (assq article gnus-newsgroup-bookmarks)))
7533 (setq gnus-newsgroup-bookmarks
7534 (delq old gnus-newsgroup-bookmarks))))
7535 ;; Set the new bookmark, which is on the form
7536 ;; (article-number . line-number-in-body).
7540 (set-buffer gnus-article-buffer)
7544 (goto-char (point-min))
7545 (search-forward "\n\n" nil t)
7548 gnus-newsgroup-bookmarks)
7549 (gnus-message 6 "A bookmark has been added to the current article."))
7551 (defun gnus-summary-remove-bookmark (article)
7552 "Remove the bookmark from the current article."
7553 (interactive (list (gnus-summary-article-number)))
7554 ;; Remove old bookmark, if one exists.
7555 (let ((old (assq article gnus-newsgroup-bookmarks)))
7558 (setq gnus-newsgroup-bookmarks
7559 (delq old gnus-newsgroup-bookmarks))
7560 (gnus-message 6 "Removed bookmark."))
7561 (gnus-message 6 "No bookmark in current article."))))
7563 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7564 (defun gnus-summary-mark-as-dormant (n)
7565 "Mark N articles forward as dormant.
7566 If N is negative, mark backward instead. The difference between N and
7567 the actual number of articles marked is returned."
7569 (gnus-summary-mark-forward n gnus-dormant-mark))
7571 (defun gnus-summary-set-process-mark (article)
7572 "Set the process mark on ARTICLE and update the summary line."
7573 (setq gnus-newsgroup-processable
7575 (delq article gnus-newsgroup-processable)))
7576 (when (gnus-summary-goto-subject article)
7577 (gnus-summary-show-thread)
7578 (gnus-summary-goto-subject article)
7579 (gnus-summary-update-secondary-mark article)))
7581 (defun gnus-summary-remove-process-mark (article)
7582 "Remove the process mark from ARTICLE and update the summary line."
7583 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7584 (when (gnus-summary-goto-subject article)
7585 (gnus-summary-show-thread)
7586 (gnus-summary-goto-subject article)
7587 (gnus-summary-update-secondary-mark article)))
7589 (defun gnus-summary-set-saved-mark (article)
7590 "Set the process mark on ARTICLE and update the summary line."
7591 (push article gnus-newsgroup-saved)
7592 (when (gnus-summary-goto-subject article)
7593 (gnus-summary-update-secondary-mark article)))
7595 (defun gnus-summary-mark-forward (n &optional mark no-expire)
7596 "Mark N articles as read forwards.
7597 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
7598 The difference between N and the actual number of articles marked is
7601 (let ((backward (< n 0))
7602 (gnus-summary-goto-unread
7603 (and gnus-summary-goto-unread
7604 (not (eq gnus-summary-goto-unread 'never))
7605 (not (memq mark (list gnus-unread-mark
7606 gnus-ticked-mark gnus-dormant-mark)))))
7608 (mark (or mark gnus-del-mark)))
7610 (gnus-summary-mark-article nil mark no-expire)
7611 (zerop (gnus-summary-next-subject
7613 (and gnus-summary-goto-unread
7614 (not (eq gnus-summary-goto-unread 'never)))
7618 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
7619 (gnus-summary-recenter)
7620 (gnus-summary-position-point)
7621 (gnus-set-mode-line 'summary)
7624 (defun gnus-summary-mark-article-as-read (mark)
7625 "Mark the current article quickly as read with MARK."
7626 (let ((article (gnus-summary-article-number)))
7627 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7628 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7629 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7630 (push (cons article mark) gnus-newsgroup-reads)
7631 ;; Possibly remove from cache, if that is used.
7632 (when gnus-use-cache
7633 (gnus-cache-enter-remove-article article))
7634 ;; Allow the backend to change the mark.
7635 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7636 ;; Check for auto-expiry.
7637 (when (and gnus-newsgroup-auto-expire
7638 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7639 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7640 (= mark gnus-ancient-mark)
7641 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7642 (= mark gnus-duplicate-mark)))
7643 (setq mark gnus-expirable-mark)
7644 (push article gnus-newsgroup-expirable))
7645 ;; Set the mark in the buffer.
7646 (gnus-summary-update-mark mark 'unread)
7649 (defun gnus-summary-mark-article-as-unread (mark)
7650 "Mark the current article quickly as unread with MARK."
7651 (let* ((article (gnus-summary-article-number))
7652 (old-mark (gnus-summary-article-mark article)))
7653 (if (eq mark old-mark)
7657 (gnus-error 1 "Can't mark negative article numbers")
7659 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7660 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7661 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
7662 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
7663 (cond ((= mark gnus-ticked-mark)
7664 (push article gnus-newsgroup-marked))
7665 ((= mark gnus-dormant-mark)
7666 (push article gnus-newsgroup-dormant))
7668 (push article gnus-newsgroup-unreads)))
7669 (gnus-pull article gnus-newsgroup-reads)
7671 ;; See whether the article is to be put in the cache.
7673 (vectorp (gnus-summary-article-header article))
7675 (gnus-cache-possibly-enter-article
7676 gnus-newsgroup-name article
7677 (gnus-summary-article-header article)
7678 (= mark gnus-ticked-mark)
7679 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7682 (gnus-summary-update-mark mark 'unread)
7685 (defun gnus-summary-mark-article (&optional article mark no-expire)
7686 "Mark ARTICLE with MARK. MARK can be any character.
7687 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
7688 `??' (dormant) and `?E' (expirable).
7689 If MARK is nil, then the default character `?D' is used.
7690 If ARTICLE is nil, then the article on the current line will be
7692 ;; The mark might be a string.
7693 (when (stringp mark)
7694 (setq mark (aref mark 0)))
7695 ;; If no mark is given, then we check auto-expiring.
7696 (and (not no-expire)
7697 gnus-newsgroup-auto-expire
7699 (and (gnus-characterp mark)
7700 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7701 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7702 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7703 (= mark gnus-duplicate-mark))))
7704 (setq mark gnus-expirable-mark))
7705 (let* ((mark (or mark gnus-del-mark))
7706 (article (or article (gnus-summary-article-number)))
7707 (old-mark (gnus-summary-article-mark article)))
7708 (if (eq mark old-mark)
7711 (error "No article on current line"))
7712 (if (not (if (or (= mark gnus-unread-mark)
7713 (= mark gnus-ticked-mark)
7714 (= mark gnus-dormant-mark))
7715 (gnus-mark-article-as-unread article mark)
7716 (gnus-mark-article-as-read article mark)))
7718 ;; See whether the article is to be put in the cache.
7720 (not (= mark gnus-canceled-mark))
7721 (vectorp (gnus-summary-article-header article))
7723 (gnus-cache-possibly-enter-article
7724 gnus-newsgroup-name article
7725 (gnus-summary-article-header article)
7726 (= mark gnus-ticked-mark)
7727 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7729 (when (gnus-summary-goto-subject article nil t)
7730 (let ((buffer-read-only nil))
7731 (gnus-summary-show-thread)
7733 (gnus-summary-update-mark mark 'unread)
7736 (defun gnus-summary-update-secondary-mark (article)
7737 "Update the secondary (read, process, cache) mark."
7738 (gnus-summary-update-mark
7739 (cond ((memq article gnus-newsgroup-processable)
7741 ((memq article gnus-newsgroup-cached)
7743 ((memq article gnus-newsgroup-replied)
7745 ((memq article gnus-newsgroup-saved)
7747 (t gnus-unread-mark))
7749 (when (gnus-visual-p 'summary-highlight 'highlight)
7750 (gnus-run-hooks 'gnus-summary-update-hook))
7753 (defun gnus-summary-update-mark (mark type)
7754 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
7755 (buffer-read-only nil))
7756 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
7757 (when (looking-at "\r")
7760 (<= (+ forward (point)) (point-max)))
7761 ;; Go to the right position on the line.
7762 (goto-char (+ forward (point)))
7763 ;; Replace the old mark with the new mark.
7764 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
7765 ;; Optionally update the marks by some user rule.
7766 (when (eq type 'unread)
7768 (gnus-data-find (gnus-summary-article-number)) mark)
7769 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
7771 (defun gnus-mark-article-as-read (article &optional mark)
7772 "Enter ARTICLE in the pertinent lists and remove it from others."
7773 ;; Make the article expirable.
7774 (let ((mark (or mark gnus-del-mark)))
7775 (if (= mark gnus-expirable-mark)
7776 (push article gnus-newsgroup-expirable)
7777 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
7778 ;; Remove from unread and marked lists.
7779 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7780 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7781 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7782 (push (cons article mark) gnus-newsgroup-reads)
7783 ;; Possibly remove from cache, if that is used.
7784 (when gnus-use-cache
7785 (gnus-cache-enter-remove-article article))
7788 (defun gnus-mark-article-as-unread (article &optional mark)
7789 "Enter ARTICLE in the pertinent lists and remove it from others."
7790 (let ((mark (or mark gnus-ticked-mark)))
7793 (gnus-error 1 "Can't mark negative article numbers")
7795 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
7796 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
7797 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
7798 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7800 ;; Unsuppress duplicates?
7801 (when gnus-suppress-duplicates
7802 (gnus-dup-unsuppress-article article))
7804 (cond ((= mark gnus-ticked-mark)
7805 (push article gnus-newsgroup-marked))
7806 ((= mark gnus-dormant-mark)
7807 (push article gnus-newsgroup-dormant))
7809 (push article gnus-newsgroup-unreads)))
7810 (gnus-pull article gnus-newsgroup-reads)
7813 (defalias 'gnus-summary-mark-as-unread-forward
7814 'gnus-summary-tick-article-forward)
7815 (make-obsolete 'gnus-summary-mark-as-unread-forward
7816 'gnus-summary-tick-article-forward)
7817 (defun gnus-summary-tick-article-forward (n)
7818 "Tick N articles forwards.
7819 If N is negative, tick backwards instead.
7820 The difference between N and the number of articles ticked is returned."
7822 (gnus-summary-mark-forward n gnus-ticked-mark))
7824 (defalias 'gnus-summary-mark-as-unread-backward
7825 'gnus-summary-tick-article-backward)
7826 (make-obsolete 'gnus-summary-mark-as-unread-backward
7827 'gnus-summary-tick-article-backward)
7828 (defun gnus-summary-tick-article-backward (n)
7829 "Tick N articles backwards.
7830 The difference between N and the number of articles ticked is returned."
7832 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
7834 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7835 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7836 (defun gnus-summary-tick-article (&optional article clear-mark)
7837 "Mark current article as unread.
7838 Optional 1st argument ARTICLE specifies article number to be marked as unread.
7839 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
7841 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
7844 (defun gnus-summary-mark-as-read-forward (n)
7845 "Mark N articles as read forwards.
7846 If N is negative, mark backwards instead.
7847 The difference between N and the actual number of articles marked is
7850 (gnus-summary-mark-forward n gnus-del-mark t))
7852 (defun gnus-summary-mark-as-read-backward (n)
7853 "Mark the N articles as read backwards.
7854 The difference between N and the actual number of articles marked is
7857 (gnus-summary-mark-forward (- n) gnus-del-mark t))
7859 (defun gnus-summary-mark-as-read (&optional article mark)
7860 "Mark current article as read.
7861 ARTICLE specifies the article to be marked as read.
7862 MARK specifies a string to be inserted at the beginning of the line."
7863 (gnus-summary-mark-article article mark))
7865 (defun gnus-summary-clear-mark-forward (n)
7866 "Clear marks from N articles forward.
7867 If N is negative, clear backward instead.
7868 The difference between N and the number of marks cleared is returned."
7870 (gnus-summary-mark-forward n gnus-unread-mark))
7872 (defun gnus-summary-clear-mark-backward (n)
7873 "Clear marks from N articles backward.
7874 The difference between N and the number of marks cleared is returned."
7876 (gnus-summary-mark-forward (- n) gnus-unread-mark))
7878 (defun gnus-summary-mark-unread-as-read ()
7879 "Intended to be used by `gnus-summary-mark-article-hook'."
7880 (when (memq gnus-current-article gnus-newsgroup-unreads)
7881 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
7883 (defun gnus-summary-mark-read-and-unread-as-read ()
7884 "Intended to be used by `gnus-summary-mark-article-hook'."
7885 (let ((mark (gnus-summary-article-mark)))
7886 (when (or (gnus-unread-mark-p mark)
7887 (gnus-read-mark-p mark))
7888 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
7890 (defun gnus-summary-mark-region-as-read (point mark all)
7891 "Mark all unread articles between point and mark as read.
7892 If given a prefix, mark all articles between point and mark as read,
7893 even ticked and dormant ones."
7894 (interactive "r\nP")
7903 (memq (setq article (gnus-summary-article-number))
7904 gnus-newsgroup-unreads))
7905 (gnus-summary-mark-article article gnus-del-mark))
7907 (gnus-summary-find-next))))))
7909 (defun gnus-summary-mark-below (score mark)
7910 "Mark articles with score less than SCORE with MARK."
7911 (interactive "P\ncMark: ")
7912 (setq score (if score
7913 (prefix-numeric-value score)
7914 (or gnus-summary-default-score 0)))
7916 (set-buffer gnus-summary-buffer)
7917 (goto-char (point-min))
7920 (and (< (gnus-summary-article-score) score)
7921 (gnus-summary-mark-article nil mark))
7922 (gnus-summary-find-next)))))
7924 (defun gnus-summary-kill-below (&optional score)
7925 "Mark articles with score below SCORE as read."
7927 (gnus-summary-mark-below score gnus-killed-mark))
7929 (defun gnus-summary-clear-above (&optional score)
7930 "Clear all marks from articles with score above SCORE."
7932 (gnus-summary-mark-above score gnus-unread-mark))
7934 (defun gnus-summary-tick-above (&optional score)
7935 "Tick all articles with score above SCORE."
7937 (gnus-summary-mark-above score gnus-ticked-mark))
7939 (defun gnus-summary-mark-above (score mark)
7940 "Mark articles with score over SCORE with MARK."
7941 (interactive "P\ncMark: ")
7942 (setq score (if score
7943 (prefix-numeric-value score)
7944 (or gnus-summary-default-score 0)))
7946 (set-buffer gnus-summary-buffer)
7947 (goto-char (point-min))
7949 (when (> (gnus-summary-article-score) score)
7950 (gnus-summary-mark-article nil mark))
7952 (gnus-summary-find-next)))))
7954 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7955 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
7956 (defun gnus-summary-limit-include-expunged (&optional no-error)
7957 "Display all the hidden articles that were expunged for low scores."
7959 (let ((buffer-read-only nil))
7960 (let ((scored gnus-newsgroup-scored)
7963 (unless (gnus-summary-goto-subject (caar scored))
7964 (and (setq h (gnus-summary-article-header (caar scored)))
7965 (< (cdar scored) gnus-summary-expunge-below)
7967 (setq scored (cdr scored)))
7969 (when (not no-error)
7970 (error "No expunged articles hidden"))
7971 (goto-char (point-min))
7972 (gnus-summary-prepare-unthreaded (nreverse headers))
7973 (goto-char (point-min))
7974 (gnus-summary-position-point)
7977 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
7978 "Mark all unread articles in this newsgroup as read.
7979 If prefix argument ALL is non-nil, ticked and dormant articles will
7980 also be marked as read.
7981 If QUIETLY is non-nil, no questions will be asked.
7982 If TO-HERE is non-nil, it should be a point in the buffer. All
7983 articles before this point will be marked as read.
7984 Note that this function will only catch up the unread article
7985 in the current summary buffer limitation.
7986 The number of articles marked as read is returned."
7991 (not gnus-interactive-catchup) ;Without confirmation?
7995 "Mark absolutely all articles as read? "
7996 "Mark all unread articles as read? ")))
7998 (not gnus-newsgroup-adaptive)
7999 (not gnus-newsgroup-auto-expire)
8000 (not gnus-suppress-duplicates)
8001 (or (not gnus-use-cache)
8002 (eq gnus-use-cache 'passive)))
8005 (setq gnus-newsgroup-marked nil
8006 gnus-newsgroup-dormant nil))
8007 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8008 ;; We actually mark all articles as canceled, which we
8009 ;; have to do when using auto-expiry or adaptive scoring.
8010 (gnus-summary-show-all-threads)
8011 (when (gnus-summary-first-subject (not all) t)
8013 (if to-here (< (point) to-here) t)
8014 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8015 (gnus-summary-find-next (not all) nil nil t))))
8016 (gnus-set-mode-line 'summary))
8018 (gnus-summary-position-point)))
8020 (defun gnus-summary-catchup-to-here (&optional all)
8021 "Mark all unticked articles before the current one as read.
8022 If ALL is non-nil, also mark ticked and dormant articles as read."
8025 (gnus-save-hidden-threads
8026 (let ((beg (point)))
8027 ;; We check that there are unread articles.
8028 (when (or all (gnus-summary-find-prev))
8029 (gnus-summary-catchup all t beg)))))
8030 (gnus-summary-position-point))
8032 (defun gnus-summary-catchup-all (&optional quietly)
8033 "Mark all articles in this newsgroup as read."
8035 (gnus-summary-catchup t quietly))
8037 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8038 "Mark all articles not marked as unread in this newsgroup as read, then exit.
8039 If prefix argument ALL is non-nil, all articles are marked as read."
8041 (when (gnus-summary-catchup all quietly nil 'fast)
8042 ;; Select next newsgroup or exit.
8043 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
8044 (eq gnus-auto-select-next 'quietly))
8045 (gnus-summary-next-group nil)
8046 (gnus-summary-exit))))
8048 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8049 "Mark all articles in this newsgroup as read, and then exit."
8051 (gnus-summary-catchup-and-exit t quietly))
8053 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
8054 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8055 "Mark all articles in this group as read and select the next group.
8056 If given a prefix, mark all articles, unread as well as ticked, as
8060 (gnus-summary-catchup all))
8061 (gnus-summary-next-article t nil nil t))
8063 ;; Thread-based commands.
8065 (defun gnus-summary-articles-in-thread (&optional article)
8066 "Return a list of all articles in the current thread.
8067 If ARTICLE is non-nil, return all articles in the thread that starts
8069 (let* ((article (or article (gnus-summary-article-number)))
8070 (data (gnus-data-find-list article))
8071 (top-level (gnus-data-level (car data)))
8073 (cond ((null gnus-thread-operation-ignore-subject)
8074 (gnus-simplify-subject-re
8075 (mail-header-subject (gnus-data-header (car data)))))
8076 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8077 (gnus-simplify-subject-fuzzy
8078 (mail-header-subject (gnus-data-header (car data)))))
8080 (end-point (save-excursion
8081 (if (gnus-summary-go-to-next-thread)
8082 (point) (point-max))))
8085 (< (gnus-data-pos (car data)) end-point))
8086 (when (or (not top-subject)
8087 (string= top-subject
8088 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8089 (gnus-simplify-subject-fuzzy
8090 (mail-header-subject
8091 (gnus-data-header (car data))))
8092 (gnus-simplify-subject-re
8093 (mail-header-subject
8094 (gnus-data-header (car data)))))))
8095 (push (gnus-data-number (car data)) articles))
8096 (unless (and (setq data (cdr data))
8097 (> (gnus-data-level (car data)) top-level))
8099 ;; Return the list of articles.
8100 (nreverse articles)))
8102 (defun gnus-summary-rethread-current ()
8103 "Rethread the thread the current article is part of."
8105 (let* ((gnus-show-threads t)
8106 (article (gnus-summary-article-number))
8107 (id (mail-header-id (gnus-summary-article-header)))
8108 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8110 (error "No article on the current line"))
8111 (gnus-rebuild-thread id)
8112 (gnus-summary-goto-subject article)))
8114 (defun gnus-summary-reparent-thread ()
8115 "Make the current article child of the marked (or previous) article.
8117 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8118 is non-nil or the Subject: of both articles are the same."
8120 (unless (not (gnus-group-read-only-p))
8121 (error "The current newsgroup does not support article editing"))
8122 (unless (<= (length gnus-newsgroup-processable) 1)
8123 (error "No more than one article may be marked"))
8124 (save-window-excursion
8125 (let ((gnus-article-buffer " *reparent*")
8126 (current-article (gnus-summary-article-number))
8127 ;; First grab the marked article, otherwise one line up.
8128 (parent-article (if (not (null gnus-newsgroup-processable))
8129 (car gnus-newsgroup-processable)
8131 (if (eq (forward-line -1) 0)
8132 (gnus-summary-article-number)
8133 (error "Beginning of summary buffer"))))))
8134 (unless (not (eq current-article parent-article))
8135 (error "An article may not be self-referential"))
8136 (let ((message-id (mail-header-id
8137 (gnus-summary-article-header parent-article))))
8138 (unless (and message-id (not (equal message-id "")))
8139 (error "No message-id in desired parent"))
8140 ;; We don't want the article to be marked as read.
8141 (let (gnus-mark-article-hook)
8142 (gnus-summary-select-article t t nil current-article))
8143 (set-buffer gnus-original-article-buffer)
8144 (let ((buf (format "%s" (buffer-string))))
8147 (goto-char (point-min))
8148 (if (re-search-forward "^References: " nil t)
8150 (re-search-forward "^[^ \t]" nil t)
8153 (insert " " message-id))
8154 (insert "References: " message-id "\n"))
8155 (unless (gnus-request-replace-article
8156 current-article (car gnus-article-current)
8158 (error "Couldn't replace article"))))
8159 (set-buffer gnus-summary-buffer)
8160 (gnus-summary-unmark-all-processable)
8161 (gnus-summary-update-article current-article)
8162 (gnus-summary-rethread-current)
8163 (gnus-message 3 "Article %d is now the child of article %d"
8164 current-article parent-article)))))
8166 (defun gnus-summary-toggle-threads (&optional arg)
8167 "Toggle showing conversation threads.
8168 If ARG is positive number, turn showing conversation threads on."
8170 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8171 (setq gnus-show-threads
8172 (if (null arg) (not gnus-show-threads)
8173 (> (prefix-numeric-value arg) 0)))
8174 (gnus-summary-prepare)
8175 (gnus-summary-goto-subject current)
8176 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8177 (gnus-summary-position-point)))
8179 (defun gnus-summary-show-all-threads ()
8183 (let ((buffer-read-only nil))
8184 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8185 (gnus-summary-position-point))
8187 (defun gnus-summary-show-thread ()
8188 "Show thread subtrees.
8189 Returns nil if no thread was there to be shown."
8191 (let ((buffer-read-only nil)
8193 ;; first goto end then to beg, to have point at beg after let
8194 (end (progn (end-of-line) (point)))
8195 (beg (progn (beginning-of-line) (point))))
8197 ;; Any hidden lines here?
8198 (search-forward "\r" end t)
8199 (subst-char-in-region beg end ?\^M ?\n t)
8201 (gnus-summary-position-point))))
8203 (defun gnus-summary-hide-all-threads ()
8204 "Hide all thread subtrees."
8207 (goto-char (point-min))
8208 (gnus-summary-hide-thread)
8209 (while (zerop (gnus-summary-next-thread 1 t))
8210 (gnus-summary-hide-thread)))
8211 (gnus-summary-position-point))
8213 (defun gnus-summary-hide-thread ()
8214 "Hide thread subtrees.
8215 Returns nil if no threads were there to be hidden."
8217 (let ((buffer-read-only nil)
8219 (article (gnus-summary-article-number)))
8221 ;; Go forward until either the buffer ends or the subthread
8223 (when (and (not (eobp))
8224 (or (zerop (gnus-summary-next-thread 1 t))
8225 (goto-char (point-max))))
8227 (if (and (> (point) start)
8228 (search-backward "\n" start t))
8230 (subst-char-in-region start (point) ?\n ?\^M)
8231 (gnus-summary-goto-subject article))
8234 ;;(gnus-summary-position-point)
8237 (defun gnus-summary-go-to-next-thread (&optional previous)
8238 "Go to the same level (or less) next thread.
8239 If PREVIOUS is non-nil, go to previous thread instead.
8240 Return the article number moved to, or nil if moving was impossible."
8241 (let ((level (gnus-summary-thread-level))
8242 (way (if previous -1 1))
8245 (while (and (not (eobp))
8246 (< level (gnus-summary-thread-level)))
8254 (gnus-summary-article-number)
8257 (defun gnus-summary-next-thread (n &optional silent)
8258 "Go to the same level next N'th thread.
8259 If N is negative, search backward instead.
8260 Returns the difference between N and the number of skips actually
8263 If SILENT, don't output messages."
8265 (let ((backward (< n 0))
8268 (gnus-summary-go-to-next-thread backward))
8271 (gnus-summary-position-point))
8272 (when (and (not silent) (/= 0 n))
8273 (gnus-message 7 "No more threads"))
8276 (defun gnus-summary-prev-thread (n)
8277 "Go to the same level previous N'th thread.
8278 Returns the difference between N and the number of skips actually
8281 (gnus-summary-next-thread (- n)))
8283 (defun gnus-summary-go-down-thread ()
8284 "Go down one level in the current thread."
8285 (let ((children (gnus-summary-article-children)))
8287 (gnus-summary-goto-subject (car children)))))
8289 (defun gnus-summary-go-up-thread ()
8290 "Go up one level in the current thread."
8291 (let ((parent (gnus-summary-article-parent)))
8293 (gnus-summary-goto-subject parent))))
8295 (defun gnus-summary-down-thread (n)
8296 "Go down thread N steps.
8297 If N is negative, go up instead.
8298 Returns the difference between N and how many steps down that were
8304 (if up (gnus-summary-go-up-thread)
8305 (gnus-summary-go-down-thread)))
8307 (gnus-summary-position-point)
8309 (gnus-message 7 "Can't go further"))
8312 (defun gnus-summary-up-thread (n)
8313 "Go up thread N steps.
8314 If N is negative, go up instead.
8315 Returns the difference between N and how many steps down that were
8318 (gnus-summary-down-thread (- n)))
8320 (defun gnus-summary-top-thread ()
8321 "Go to the top of the thread."
8323 (while (gnus-summary-go-up-thread))
8324 (gnus-summary-article-number))
8326 (defun gnus-summary-kill-thread (&optional unmark)
8327 "Mark articles under current thread as read.
8328 If the prefix argument is positive, remove any kinds of marks.
8329 If the prefix argument is negative, tick articles instead."
8332 (setq unmark (prefix-numeric-value unmark)))
8333 (let ((articles (gnus-summary-articles-in-thread)))
8335 ;; Expand the thread.
8336 (gnus-summary-show-thread)
8337 ;; Mark all the articles.
8339 (gnus-summary-goto-subject (car articles))
8340 (cond ((null unmark)
8341 (gnus-summary-mark-article-as-read gnus-killed-mark))
8343 (gnus-summary-mark-article-as-unread gnus-unread-mark))
8345 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
8346 (setq articles (cdr articles))))
8347 ;; Hide killed subtrees.
8349 gnus-thread-hide-killed
8350 (gnus-summary-hide-thread))
8351 ;; If marked as read, go to next unread subject.
8353 ;; Go to next unread subject.
8354 (gnus-summary-next-subject 1 t)))
8355 (gnus-set-mode-line 'summary))
8357 ;; Summary sorting commands
8359 (defun gnus-summary-sort-by-number (&optional reverse)
8360 "Sort the summary buffer by article number.
8361 Argument REVERSE means reverse order."
8363 (gnus-summary-sort 'number reverse))
8365 (defun gnus-summary-sort-by-author (&optional reverse)
8366 "Sort the summary buffer by author name alphabetically.
8367 If case-fold-search is non-nil, case of letters is ignored.
8368 Argument REVERSE means reverse order."
8370 (gnus-summary-sort 'author reverse))
8372 (defun gnus-summary-sort-by-subject (&optional reverse)
8373 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8374 If case-fold-search is non-nil, case of letters is ignored.
8375 Argument REVERSE means reverse order."
8377 (gnus-summary-sort 'subject reverse))
8379 (defun gnus-summary-sort-by-date (&optional reverse)
8380 "Sort the summary buffer by date.
8381 Argument REVERSE means reverse order."
8383 (gnus-summary-sort 'date reverse))
8385 (defun gnus-summary-sort-by-score (&optional reverse)
8386 "Sort the summary buffer by score.
8387 Argument REVERSE means reverse order."
8389 (gnus-summary-sort 'score reverse))
8391 (defun gnus-summary-sort-by-lines (&optional reverse)
8392 "Sort the summary buffer by article length.
8393 Argument REVERSE means reverse order."
8395 (gnus-summary-sort 'lines reverse))
8397 (defun gnus-summary-sort (predicate reverse)
8398 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
8399 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
8400 (article (intern (format "gnus-article-sort-by-%s" predicate)))
8401 (gnus-thread-sort-functions
8407 (gnus-article-sort-functions
8412 (,article t2 t1)))))
8414 (gnus-summary-prepare-hook nil))
8415 ;; We do the sorting by regenerating the threads.
8416 (gnus-summary-prepare)
8417 ;; Hide subthreads if needed.
8418 (when (and gnus-show-threads gnus-thread-hide-subtree)
8419 (gnus-summary-hide-all-threads))))
8421 ;; Summary saving commands.
8423 (defun gnus-summary-save-article (&optional n not-saved)
8424 "Save the current article using the default saver function.
8425 If N is a positive number, save the N next articles.
8426 If N is a negative number, save the N previous articles.
8427 If N is nil and any articles have been marked with the process mark,
8428 save those articles instead.
8429 The variable `gnus-default-article-saver' specifies the saver function."
8431 (let* ((articles (gnus-summary-work-articles n))
8432 (save-buffer (save-excursion
8433 (nnheader-set-temp-buffer " *Gnus Save*")))
8434 (num (length articles))
8435 header article file)
8437 (setq header (gnus-summary-article-header
8438 (setq article (pop articles))))
8439 (if (not (vectorp header))
8440 ;; This is a pseudo-article.
8441 (if (assq 'name header)
8442 (gnus-copy-file (cdr (assq 'name header)))
8443 (gnus-message 1 "Article %d is unsaveable" article))
8444 ;; This is a real article.
8445 (save-window-excursion
8446 (gnus-summary-select-article t nil nil article))
8448 (set-buffer save-buffer)
8450 (insert-buffer-substring gnus-original-article-buffer))
8451 (setq file (gnus-article-save save-buffer file num))
8452 (gnus-summary-remove-process-mark article)
8454 (gnus-summary-set-saved-mark article))))
8455 (gnus-kill-buffer save-buffer)
8456 (gnus-summary-position-point)
8457 (gnus-set-mode-line 'summary)
8460 (defun gnus-summary-pipe-output (&optional arg)
8461 "Pipe the current article to a subprocess.
8462 If N is a positive number, pipe the N next articles.
8463 If N is a negative number, pipe the N previous articles.
8464 If N is nil and any articles have been marked with the process mark,
8465 pipe those articles instead."
8467 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8468 (gnus-summary-save-article arg t))
8469 (gnus-configure-windows 'pipe))
8471 (defun gnus-summary-save-article-mail (&optional arg)
8472 "Append the current article to an mail file.
8473 If N is a positive number, save the N next articles.
8474 If N is a negative number, save the N previous articles.
8475 If N is nil and any articles have been marked with the process mark,
8476 save those articles instead."
8478 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8479 (gnus-summary-save-article arg)))
8481 (defun gnus-summary-save-article-rmail (&optional arg)
8482 "Append the current article to an rmail file.
8483 If N is a positive number, save the N next articles.
8484 If N is a negative number, save the N previous articles.
8485 If N is nil and any articles have been marked with the process mark,
8486 save those articles instead."
8488 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
8489 (gnus-summary-save-article arg)))
8491 (defun gnus-summary-save-article-file (&optional arg)
8492 "Append the current article to a file.
8493 If N is a positive number, save the N next articles.
8494 If N is a negative number, save the N previous articles.
8495 If N is nil and any articles have been marked with the process mark,
8496 save those articles instead."
8498 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8499 (gnus-summary-save-article arg)))
8501 (defun gnus-summary-write-article-file (&optional arg)
8502 "Write the current article to a file, deleting the previous file.
8503 If N is a positive number, save the N next articles.
8504 If N is a negative number, save the N previous articles.
8505 If N is nil and any articles have been marked with the process mark,
8506 save those articles instead."
8508 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
8509 (gnus-summary-save-article arg)))
8511 (defun gnus-summary-save-article-body-file (&optional arg)
8512 "Append the current article body to a file.
8513 If N is a positive number, save the N next articles.
8514 If N is a negative number, save the N previous articles.
8515 If N is nil and any articles have been marked with the process mark,
8516 save those articles instead."
8518 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
8519 (gnus-summary-save-article arg)))
8521 (defun gnus-summary-pipe-message (program)
8522 "Pipe the current article through PROGRAM."
8523 (interactive "sProgram: ")
8524 (gnus-summary-select-article)
8525 (let ((mail-header-separator ""))
8526 (gnus-eval-in-buffer-window gnus-article-buffer
8529 (let ((start (window-start))
8531 (message-pipe-buffer-body program)
8532 (set-window-start (get-buffer-window (current-buffer)) start))))))
8534 (defun gnus-get-split-value (methods)
8535 "Return a value based on the split METHODS."
8536 (let (split-name method result match)
8539 (set-buffer gnus-original-article-buffer)
8541 (nnheader-narrow-to-headers)
8543 (goto-char (point-min))
8544 (setq method (pop methods))
8545 (setq match (car method))
8548 ;; Regular expression.
8550 (re-search-forward match nil t)))
8551 ((gnus-functionp match)
8555 (setq result (funcall match gnus-newsgroup-name))))
8560 (setq result (eval match)))))
8561 (setq split-name (append (cdr method) split-name))
8562 (cond ((stringp result)
8563 (push (expand-file-name
8564 result gnus-article-save-directory)
8567 (setq split-name (append result split-name)))))))))
8570 (defun gnus-valid-move-group-p (group)
8575 (car (gnus-find-method-for-group
8576 (symbol-name group))))
8577 gnus-valid-select-methods))))
8579 (defun gnus-read-move-group-name (prompt default articles prefix)
8580 "Read a group name."
8581 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
8582 (minibuffer-confirm-incomplete nil) ; XEmacs
8586 (if (> (length articles) 1)
8587 (format "these %d articles" (length articles))
8592 (gnus-completing-read default prom
8594 'gnus-valid-move-group-p
8596 'gnus-group-history))
8597 ((= 1 (length split-name))
8598 (gnus-completing-read (car split-name) prom
8600 'gnus-valid-move-group-p
8602 'gnus-group-history))
8604 (gnus-completing-read nil prom
8605 (mapcar (lambda (el) (list el))
8606 (nreverse split-name))
8608 'gnus-group-history)))))
8610 (if (or (string= to-newsgroup "")
8611 (string= to-newsgroup prefix))
8612 (setq to-newsgroup default))
8613 (unless to-newsgroup
8614 (error "No group name entered"))
8615 (or (gnus-active to-newsgroup)
8616 (gnus-activate-group to-newsgroup)
8617 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
8619 (or (and (gnus-request-create-group
8620 to-newsgroup (gnus-group-name-to-method to-newsgroup))
8621 (gnus-activate-group to-newsgroup nil nil
8622 (gnus-group-name-to-method
8624 (error "Couldn't create group %s" to-newsgroup)))
8625 (error "No such group: %s" to-newsgroup)))
8628 ;; Summary extract commands
8630 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
8631 (let ((buffer-read-only nil)
8632 (article (gnus-summary-article-number))
8634 (unless (gnus-summary-goto-subject article)
8635 (error "No such article: %d" article))
8636 (gnus-summary-position-point)
8637 ;; If all commands are to be bunched up on one line, we collect
8639 (unless gnus-view-pseudos-separately
8640 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
8643 (setq action (cdr (assq 'action (car ps))))
8644 (setq files (list (cdr (assq 'name (car ps)))))
8645 (while (and ps (cdr ps)
8646 (string= (or action "1")
8647 (or (cdr (assq 'action (cadr ps))) "2")))
8648 (push (cdr (assq 'name (cadr ps))) files)
8649 (setcdr ps (cddr ps)))
8651 (when (not (string-match "%s" action))
8654 (when (assq 'execute (car ps))
8655 (setcdr (assq 'execute (car ps))
8656 (funcall (if (string-match "%s" action)
8663 (gnus-quote-arg-for-sh-or-csh f)))
8665 (setq ps (cdr ps)))))
8666 (if (and gnus-view-pseudos (not not-view))
8668 (when (assq 'execute (car pslist))
8669 (gnus-execute-command (cdr (assq 'execute (car pslist)))
8670 (eq gnus-view-pseudos 'not-confirm)))
8671 (setq pslist (cdr pslist)))
8674 (setq after-article (or (cdr (assq 'article (car pslist)))
8675 (gnus-summary-article-number)))
8676 (gnus-summary-goto-subject after-article)
8679 (insert " " (file-name-nondirectory
8680 (cdr (assq 'name (car pslist))))
8681 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
8683 (forward-line -1) ; back to `b'
8684 (gnus-add-text-properties
8685 b (1- e) (list 'gnus-number gnus-reffed-article-number
8686 gnus-mouse-face-prop gnus-mouse-face))
8688 after-article gnus-reffed-article-number
8689 gnus-unread-mark b (car pslist) 0 (- e b))
8690 (push gnus-reffed-article-number gnus-newsgroup-unreads)
8691 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
8692 (setq pslist (cdr pslist)))))))
8694 (defun gnus-pseudos< (p1 p2)
8695 (let ((c1 (cdr (assq 'action p1)))
8696 (c2 (cdr (assq 'action p2))))
8697 (and c1 c2 (string< c1 c2))))
8699 (defun gnus-request-pseudo-article (props)
8700 (cond ((assq 'execute props)
8701 (gnus-execute-command (cdr (assq 'execute props)))))
8702 (let ((gnus-current-article (gnus-summary-article-number)))
8703 (gnus-run-hooks 'gnus-mark-article-hook)))
8705 (defun gnus-execute-command (command &optional automatic)
8707 (gnus-article-setup-buffer)
8708 (set-buffer gnus-article-buffer)
8709 (setq buffer-read-only nil)
8710 (let ((command (if automatic command
8711 (read-string "Command: " (cons command 0)))))
8713 (insert "$ " command "\n\n")
8714 (if gnus-view-pseudo-asynchronously
8715 (start-process "gnus-execute" (current-buffer) shell-file-name
8716 shell-command-switch command)
8717 (call-process shell-file-name nil t nil
8718 shell-command-switch command)))))
8720 ;; Summary kill commands.
8722 (defun gnus-summary-edit-global-kill (article)
8723 "Edit the \"global\" kill file."
8724 (interactive (list (gnus-summary-article-number)))
8725 (gnus-group-edit-global-kill article))
8727 (defun gnus-summary-edit-local-kill ()
8728 "Edit a local kill file applied to the current newsgroup."
8730 (setq gnus-current-headers (gnus-summary-article-header))
8731 (gnus-group-edit-local-kill
8732 (gnus-summary-article-number) gnus-newsgroup-name))
8736 (defun gnus-read-header (id &optional header)
8737 "Read the headers of article ID and enter them into the Gnus system."
8738 (let ((group gnus-newsgroup-name)
8739 (gnus-override-method
8740 (and (gnus-news-group-p gnus-newsgroup-name)
8741 gnus-refer-article-method))
8743 ;; First we check to see whether the header in question is already
8746 ;; This is a Message-ID.
8747 (setq header (or header (gnus-id-to-header id)))
8748 ;; This is an article number.
8749 (setq header (or header (gnus-summary-article-header id))))
8751 (not (gnus-summary-article-sparse-p (mail-header-number header))))
8752 ;; We have found the header.
8754 ;; If this is a sparse article, we have to nix out its
8755 ;; previous entry in the thread hashtb.
8757 (gnus-summary-article-sparse-p (mail-header-number header)))
8758 (let* ((parent (gnus-parent-id (mail-header-references header)))
8759 (thread (and parent (gnus-id-to-thread parent))))
8761 (delq (assq header thread) thread))))
8762 ;; We have to really fetch the header to this article.
8764 (set-buffer nntp-server-buffer)
8765 (when (setq where (gnus-request-head id group))
8766 (nnheader-fold-continuation-lines)
8767 (goto-char (point-max))
8769 (goto-char (point-min))
8773 ((cdr where) (cdr where))
8774 (header (mail-header-number header))
8775 (t gnus-reffed-article-number))
8777 (insert " Article retrieved.\n"))
8779 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
8780 () ; Malformed head.
8781 (unless (gnus-summary-article-sparse-p (mail-header-number header))
8782 (when (and (stringp id)
8783 (not (string= (gnus-group-real-name group)
8785 ;; If we fetched by Message-ID and the article came
8786 ;; from a different group, we fudge some bogus article
8787 ;; numbers for this article.
8788 (mail-header-set-number header gnus-reffed-article-number))
8790 (set-buffer gnus-summary-buffer)
8791 (decf gnus-reffed-article-number)
8792 (gnus-remove-header (mail-header-number header))
8793 (push header gnus-newsgroup-headers)
8794 (setq gnus-current-headers header)
8795 (push (mail-header-number header) gnus-newsgroup-limit)))
8798 (defun gnus-remove-header (number)
8799 "Remove header NUMBER from `gnus-newsgroup-headers'."
8800 (if (and gnus-newsgroup-headers
8801 (= number (mail-header-number (car gnus-newsgroup-headers))))
8802 (pop gnus-newsgroup-headers)
8803 (let ((headers gnus-newsgroup-headers))
8804 (while (and (cdr headers)
8805 (not (= number (mail-header-number (cadr headers)))))
8808 (setcdr headers (cddr headers))))))
8811 ;;; summary highlights
8814 (defun gnus-highlight-selected-summary ()
8815 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8816 ;; Highlight selected article in summary buffer
8817 (when gnus-summary-selected-face
8819 (let* ((beg (progn (beginning-of-line) (point)))
8820 (end (progn (end-of-line) (point)))
8821 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
8822 (from (if (get-text-property beg gnus-mouse-face-prop)
8824 (or (next-single-property-change
8825 beg gnus-mouse-face-prop nil end)
8830 (or (next-single-property-change
8831 from gnus-mouse-face-prop nil end)
8833 ;; If no mouse-face prop on line we will have to = from = end,
8834 ;; so we highlight the entire line instead.
8835 (when (= (+ to 2) from)
8838 (if gnus-newsgroup-selected-overlay
8839 ;; Move old overlay.
8841 gnus-newsgroup-selected-overlay from to (current-buffer))
8842 ;; Create new overlay.
8844 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
8845 'face gnus-summary-selected-face))))))
8847 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
8848 (defun gnus-summary-highlight-line ()
8849 "Highlight current line according to `gnus-summary-highlight'."
8850 (let* ((list gnus-summary-highlight)
8852 (end (progn (end-of-line) (point)))
8853 ;; now find out where the line starts and leave point there.
8854 (beg (progn (beginning-of-line) (point)))
8855 (article (gnus-summary-article-number))
8856 (score (or (cdr (assq (or article gnus-current-article)
8857 gnus-newsgroup-scored))
8858 gnus-summary-default-score 0))
8859 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
8860 (inhibit-read-only t))
8861 ;; Eval the cars of the lists until we find a match.
8862 (let ((default gnus-summary-default-score))
8864 (not (eval (caar list))))
8865 (setq list (cdr list))))
8866 (let ((face (cdar list)))
8867 (unless (eq face (get-text-property beg 'face))
8868 (gnus-put-text-property-excluding-characters-with-faces
8870 (setq face (if (boundp face) (symbol-value face) face)))
8871 (when gnus-summary-highlight-line-function
8872 (funcall gnus-summary-highlight-line-function article face))))
8875 (defun gnus-update-read-articles (group unread &optional compute)
8876 "Update the list of read articles in GROUP."
8877 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
8878 (entry (gnus-gethash group gnus-newsrc-hashtb))
8879 (info (nth 2 entry))
8881 (unread (sort (copy-sequence unread) '<))
8883 (if (or (not info) (not active))
8884 ;; There is no info on this group if it was, in fact,
8885 ;; killed. Gnus stores no information on killed groups, so
8886 ;; there's nothing to be done.
8887 ;; One could store the information somewhere temporarily,
8888 ;; perhaps... Hmmm...
8890 ;; Remove any negative articles numbers.
8891 (while (and unread (< (car unread) 0))
8892 (setq unread (cdr unread)))
8893 ;; Remove any expired article numbers
8894 (while (and unread (< (car unread) (car active)))
8895 (setq unread (cdr unread)))
8896 ;; Compute the ranges of read articles by looking at the list of
8899 (when (/= (car unread) prev)
8900 (push (if (= prev (1- (car unread))) prev
8901 (cons prev (1- (car unread))))
8903 (setq prev (1+ (car unread)))
8904 (setq unread (cdr unread)))
8905 (when (<= prev (cdr active))
8906 (push (cons prev (cdr active)) read))
8908 (if (> (length read) 1) (nreverse read) read)
8910 (set-buffer gnus-group-buffer)
8913 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
8914 (gnus-info-set-read ',info ',(gnus-info-read info))
8915 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
8916 (gnus-group-update-group ,group t))))
8917 ;; Enter this list into the group info.
8919 info (if (> (length read) 1) (nreverse read) read))
8920 ;; Set the number of unread articles in gnus-newsrc-hashtb.
8921 (gnus-get-unread-articles-in-group info (gnus-active group))
8924 (defun gnus-offer-save-summaries ()
8925 "Offer to save all active summary buffers."
8927 (let ((buflist (buffer-list))
8929 ;; Go through all buffers and find all summaries.
8931 (and (setq bufname (buffer-name (car buflist)))
8932 (string-match "Summary" bufname)
8934 (set-buffer bufname)
8935 ;; We check that this is, indeed, a summary buffer.
8936 (and (eq major-mode 'gnus-summary-mode)
8937 ;; Also make sure this isn't bogus.
8938 gnus-newsgroup-prepared
8939 ;; Also make sure that this isn't a dead summary buffer.
8940 (not gnus-dead-summary-mode)))
8941 (push bufname buffers))
8942 (setq buflist (cdr buflist)))
8943 ;; Go through all these summary buffers and offer to save them.
8946 "Update summary buffer %s? "
8948 (switch-to-buffer buf)
8949 (gnus-summary-exit))
8956 (run-hooks 'gnus-sum-load-hook)
8958 ;;; gnus-sum.el ends here