1 ;;; gnus-sum.el --- summary mode commands for Gnus
2 ;; Copyright (C) 1996 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
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.
35 (defgroup gnus-summary nil
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."
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.
54 This variable can also be a number. In that case, no more than that
55 number of old headers will be fetched.
57 The server has to support NOV for any of this to work."
59 :type '(choice (const :tag "off" nil)
62 (sexp :menu-tag "other" t)))
64 (defcustom gnus-summary-make-false-root 'adopt
65 "*nil means that Gnus won't gather loose threads.
66 If the root of a thread has expired or been read in a previous
67 session, the information necessary to build a complete thread has been
68 lost. Instead of having many small sub-threads from this original thread
69 scattered all over the summary buffer, Gnus can gather them.
71 If non-nil, Gnus will try to gather all loose sub-threads from an
72 original thread into one large thread.
74 If this variable is non-nil, it should be one of `none', `adopt',
77 If this variable is `none', Gnus will not make a false root, but just
78 present the sub-threads after another.
79 If this variable is `dummy', Gnus will create a dummy root that will
80 have all the sub-threads as children.
81 If this variable is `adopt', Gnus will make one of the \"children\"
82 the parent and mark all the step-children as such.
83 If this variable is `empty', the \"children\" are printed with empty
84 subject fields. (Or rather, they will be printed with a string
85 given by the `gnus-summary-same-subject' variable.)"
87 :type '(choice (const :tag "off" nil)
93 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
94 "*A regexp to match subjects to be excluded from loose thread gathering.
95 As loose thread gathering is done on subjects only, that means that
96 there can be many false gatherings performed. By rooting out certain
97 common subjects, gathering might become saner."
101 (defcustom gnus-summary-gather-subject-limit nil
102 "*Maximum length of subject comparisons when gathering loose threads.
103 Use nil to compare full subjects. Setting this variable to a low
104 number will help gather threads that have been corrupted by
105 newsreaders chopping off subject lines, but it might also mean that
106 unrelated articles that have subject that happen to begin with the
107 same few characters will be incorrectly gathered.
109 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
112 :type '(choice (const :tag "off" nil)
114 (sexp :menu-tag "on" t)))
116 (defcustom gnus-simplify-ignored-prefixes nil
117 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
119 :type '(choice (const :tag "off" nil)
122 (defcustom gnus-build-sparse-threads nil
123 "*If non-nil, fill in the gaps in threads.
124 If `some', only fill in the gaps that are needed to tie loose threads
125 together. If `more', fill in all leaf nodes that Gnus can find. If
126 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
128 :type '(choice (const :tag "off" nil)
131 (sexp :menu-tag "all" t)))
133 (defcustom gnus-summary-thread-gathering-function 'gnus-gather-threads-by-subject
134 "Function used for gathering loose threads.
135 There are two pre-defined functions: `gnus-gather-threads-by-subject',
136 which only takes Subjects into consideration; and
137 `gnus-gather-threads-by-references', which compared the References
138 headers of the articles to find matches."
140 :type '(set (function-item gnus-gather-threads-by-subject)
141 (function-item gnus-gather-threads-by-references)
142 (function :tag "other")))
144 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
145 (defcustom gnus-summary-same-subject ""
146 "*String indicating that the current article has the same subject as the previous.
147 This variable will only be used if the value of
148 `gnus-summary-make-false-root' is `empty'."
152 (defcustom gnus-summary-goto-unread t
153 "*If t, marking commands will go to the next unread article.
154 If `never', commands that usually go to the next unread article, will
155 go to the next article, whether it is read or not.
156 If nil, only the marking commands will go to the next (un)read article."
158 :type '(choice (const :tag "off" nil)
160 (sexp :menu-tag "on" t)))
162 (defcustom gnus-summary-default-score 0
163 "*Default article score level.
164 If this variable is nil, scoring will be disabled."
166 :type '(choice (const :tag "disable")
169 (defcustom gnus-summary-zcore-fuzz 0
170 "*Fuzziness factor for the zcore in the summary buffer.
171 Articles with scores closer than this to `gnus-summary-default-score'
176 (defcustom gnus-simplify-subject-fuzzy-regexp nil
177 "*Strings to be removed when doing fuzzy matches.
178 This can either be a regular expression or list of regular expressions
179 that will be removed from subject strings if fuzzy subject
180 simplification is selected."
182 :type '(repeat regexp))
184 (defcustom gnus-show-threads t
185 "*If non-nil, display threads in summary mode."
189 (defcustom gnus-thread-hide-subtree nil
190 "*If non-nil, hide all threads initially.
191 If threads are hidden, you have to run the command
192 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
193 to expose hidden threads."
197 (defcustom gnus-thread-hide-killed t
198 "*If non-nil, hide killed threads automatically."
202 (defcustom gnus-thread-ignore-subject nil
203 "*If non-nil, ignore subjects and do all threading based on the Reference header.
204 If nil, which is the default, articles that have different subjects
205 from their parents will start separate threads."
209 (defcustom gnus-thread-operation-ignore-subject t
210 "*If non-nil, subjects will be ignored when doing thread commands.
211 This affects commands like `gnus-summary-kill-thread' and
212 `gnus-summary-lower-thread'.
214 If this variable is nil, articles in the same thread with different
215 subjects will not be included in the operation in question. If this
216 variable is `fuzzy', only articles that have subjects that are fuzzily
217 equal will be included."
219 :type '(choice (const :tag "off" nil)
223 (defcustom gnus-thread-indent-level 4
224 "*Number that says how much each sub-thread should be indented."
228 (defcustom gnus-auto-extend-newsgroup t
229 "*If non-nil, extend newsgroup forward and backward when requested."
233 (defcustom gnus-auto-select-first t
234 "*If nil, don't select the first unread article when entering a group.
235 If this variable is `best', select the highest-scored unread article
236 in the group. If neither nil nor `best', select the first unread
239 If you want to prevent automatic selection of the first unread article
240 in some newsgroups, set the variable to nil in
241 `gnus-select-group-hook'."
243 :type '(choice (const :tag "none" nil)
245 (sexp :menu-tag "first" t)))
247 (defcustom gnus-auto-select-next t
248 "*If non-nil, offer to go to the next group from the end of the previous.
249 If the value is t and the next newsgroup is empty, Gnus will exit
250 summary mode and go back to group mode. If the value is neither nil
251 nor t, Gnus will select the following unread newsgroup. In
252 particular, if the value is the symbol `quietly', the next unread
253 newsgroup will be selected without any confirmation, and if it is
254 `almost-quietly', the next group will be selected without any
255 confirmation if you are located on the last article in the group.
256 Finally, if this variable is `slightly-quietly', the `Z n' command
257 will go to the next group without confirmation."
259 :type '(choice (const :tag "off" nil)
261 (const almost-quietly)
262 (const slightly-quietly)
263 (sexp :menu-tag "on" t)))
265 (defcustom gnus-auto-select-same nil
266 "*If non-nil, select the next article with the same subject."
270 (defcustom gnus-summary-check-current nil
271 "*If non-nil, consider the current article when moving.
272 The \"unread\" movement commands will stay on the same line if the
273 current article is unread."
277 (defcustom gnus-auto-center-summary t
278 "*If non-nil, always center the current summary buffer.
279 In particular, if `vertical' do only vertical recentering. If non-nil
280 and non-`vertical', do both horizontal and vertical recentering."
282 :type '(choice (const :tag "none" nil)
284 (sexp :menu-tag "both" t)))
286 (defcustom gnus-show-all-headers nil
287 "*If non-nil, don't hide any headers."
291 (defcustom gnus-single-article-buffer t
292 "*If non-nil, display all articles in the same buffer.
293 If nil, each group will get its own article buffer."
297 (defcustom gnus-break-pages t
298 "*If non-nil, do page breaking on articles.
299 The page delimiter is specified by the `gnus-page-delimiter'
304 (defcustom gnus-show-mime nil
305 "*If non-nil, do mime processing of articles.
306 The articles will simply be fed to the function given by
307 `gnus-show-mime-method'."
311 (defcustom gnus-move-split-methods nil
312 "*Variable used to suggest where articles are to be moved to.
313 It uses the same syntax as the `gnus-split-methods' variable."
315 :type '(repeat (choice (list function)
316 (cons regexp (repeat string))
319 ;; Mark variables suggested by Thomas Michanek
320 ;; <Thomas.Michanek@telelogic.se>.
322 (defgroup gnus-summary-marks nil
323 "Marks used in summary buffers."
324 :group 'gnus-summary)
326 (defcustom gnus-unread-mark ?
327 "*Mark used for unread articles."
328 :group 'gnus-summary-marks
331 (defcustom gnus-ticked-mark ?!
332 "*Mark used for ticked articles."
333 :group 'gnus-summary-marks
336 (defcustom gnus-dormant-mark ??
337 "*Mark used for dormant articles."
338 :group 'gnus-summary-marks
341 (defcustom gnus-del-mark ?r
342 "*Mark used for del'd articles."
343 :group 'gnus-summary-marks
346 (defcustom gnus-read-mark ?R
347 "*Mark used for read articles."
348 :group 'gnus-summary-marks
351 (defcustom gnus-expirable-mark ?E
352 "*Mark used for expirable articles."
353 :group 'gnus-summary-marks
356 (defcustom gnus-killed-mark ?K
357 "*Mark used for killed articles."
358 :group 'gnus-summary-marks
361 (defcustom gnus-souped-mark ?F
362 "*Mark used for killed articles."
363 :group 'gnus-summary-marks
366 (defcustom gnus-kill-file-mark ?X
367 "*Mark used for articles killed by kill files."
368 :group 'gnus-summary-marks
371 (defcustom gnus-low-score-mark ?Y
372 "*Mark used for articles with a low score."
373 :group 'gnus-summary-marks
376 (defcustom gnus-catchup-mark ?C
377 "*Mark used for articles that are caught up."
378 :group 'gnus-summary-marks
381 (defcustom gnus-replied-mark ?A
382 "*Mark used for articles that have been replied to."
383 :group 'gnus-summary-marks
386 (defcustom gnus-cached-mark ?*
387 "*Mark used for articles that are in the cache."
388 :group 'gnus-summary-marks
391 (defcustom gnus-saved-mark ?S
392 "*Mark used for articles that have been saved to."
393 :group 'gnus-summary-marks
396 (defcustom gnus-ancient-mark ?O
397 "*Mark used for ancient articles."
398 :group 'gnus-summary-marks
401 (defcustom gnus-sparse-mark ?Q
402 "*Mark used for sparsely reffed articles."
403 :group 'gnus-summary-marks
406 (defcustom gnus-canceled-mark ?G
407 "*Mark used for canceled articles."
408 :group 'gnus-summary-marks
411 (defcustom gnus-duplicate-mark ?M
412 "*Mark used for duplicate articles."
413 :group 'gnus-summary-marks
416 (defcustom gnus-score-over-mark ?+
417 "*Score mark used for articles with high scores."
418 :group 'gnus-summary-marks
421 (defcustom gnus-score-below-mark ?-
422 "*Score mark used for articles with low scores."
423 :group 'gnus-summary-marks
426 (defcustom gnus-empty-thread-mark ?
427 "*There is no thread under the article."
428 :group 'gnus-summary-marks
431 (defcustom gnus-not-empty-thread-mark ?=
432 "*There is a thread under the article."
433 :group 'gnus-summary-marks
436 (defcustom gnus-view-pseudo-asynchronously nil
437 "*If non-nil, Gnus will view pseudo-articles asynchronously."
441 (defcustom gnus-view-pseudos nil
442 "*If `automatic', pseudo-articles will be viewed automatically.
443 If `not-confirm', pseudos will be viewed automatically, and the user
444 will not be asked to confirm the command."
446 :type '(choice (const :tag "off" nil)
448 (const not-confirm)))
450 (defcustom gnus-view-pseudos-separately t
451 "*If non-nil, one pseudo-article will be created for each file to be viewed.
452 If nil, all files that use the same viewing command will be given as a
453 list of parameters to that command."
457 (defcustom gnus-insert-pseudo-articles t
458 "*If non-nil, insert pseudo-articles when decoding articles."
462 (defcustom gnus-summary-dummy-line-format
464 "*The format specification for the dummy roots in the summary buffer.
465 It works along the same lines as a normal formatting string,
466 with some simple extensions.
472 (defcustom gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
473 "*The format specification for the summary mode line.
474 It works along the same lines as a normal formatting string,
475 with some simple extensions:
478 %p Unprefixed group name
479 %A Current article number
481 %U Number of unread articles in the group
482 %e Number of unselected articles in the group
483 %Z A string with unread/unselected article counts
484 %g Shortish group name
485 %S Subject of the current article
487 %s Current score file name
488 %d Number of dormant articles
489 %r Number of articles that have been marked as read in this session
490 %E Number of articles expunged by the score files"
494 (defcustom gnus-summary-mark-below 0
495 "*Mark all articles with a score below this variable as read.
496 This variable is local to each summary buffer and usually set by the
501 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
502 "*List of functions used for sorting articles in the summary buffer.
503 This variable is only used when not using a threaded display."
505 :type '(repeat (choice (function-item gnus-article-sort-by-number)
506 (function-item gnus-article-sort-by-author)
507 (function-item gnus-article-sort-by-subject)
508 (function-item gnus-article-sort-by-date)
509 (function-item gnus-article-sort-by-score)
510 (function :tag "other"))))
512 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
513 "*List of functions used for sorting threads in the summary buffer.
514 By default, threads are sorted by article number.
516 Each function takes two threads and return non-nil if the first thread
517 should be sorted before the other. If you use more than one function,
518 the primary sort function should be the last. You should probably
519 always include `gnus-thread-sort-by-number' in the list of sorting
520 functions -- preferably first.
522 Ready-made functions include `gnus-thread-sort-by-number',
523 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
524 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
525 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
527 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
528 (function-item gnus-thread-sort-by-author)
529 (function-item gnus-thread-sort-by-subject)
530 (function-item gnus-thread-sort-by-date)
531 (function-item gnus-thread-sort-by-score)
532 (function-item gnus-thread-sort-by-total-score)
533 (function :tag "other"))))
535 (defcustom gnus-thread-score-function '+
536 "*Function used for calculating the total score of a thread.
538 The function is called with the scores of the article and each
539 subthread and should then return the score of the thread.
541 Some functions you can use are `+', `max', or `min'."
545 (defcustom gnus-summary-expunge-below nil
546 "All articles that have a score less than this variable will be expunged."
548 :type '(choice (const :tag "off" nil)
551 (defcustom gnus-thread-expunge-below nil
552 "All threads that have a total score less than this variable will be expunged.
553 See `gnus-thread-score-function' for en explanation of what a
554 \"thread score\" is."
556 :type '(choice (const :tag "off" nil)
559 (defcustom gnus-summary-mode-hook nil
560 "*A hook for Gnus summary mode.
561 This hook is run before any variables are set in the summary buffer."
565 (defcustom gnus-summary-menu-hook nil
566 "*Hook run after the creation of the summary mode menu."
570 (defcustom gnus-summary-exit-hook nil
571 "*A hook called on exit from the summary buffer."
575 (defcustom gnus-summary-prepare-hook nil
576 "*A hook called after the summary buffer has been generated.
577 If you want to modify the summary buffer, you can use this hook."
581 (defcustom gnus-summary-generate-hook nil
582 "*A hook run just before generating the summary buffer.
583 This hook is commonly used to customize threading variables and the
588 (defcustom gnus-select-group-hook nil
589 "*A hook called when a newsgroup is selected.
591 If you'd like to simplify subjects like the
592 `gnus-summary-next-same-subject' command does, you can use the
595 (setq gnus-select-group-hook
598 (mapcar (lambda (header)
599 (mail-header-set-subject
601 (gnus-simplify-subject
602 (mail-header-subject header) 're-only)))
603 gnus-newsgroup-headers))))"
607 (defcustom gnus-select-article-hook nil
608 "*A hook called when an article is selected."
612 (defcustom gnus-visual-mark-article-hook
613 (list 'gnus-highlight-selected-summary)
614 "*Hook run after selecting an article in the summary buffer.
615 It is meant to be used for highlighting the article in some way. It
616 is not run if `gnus-visual' is nil."
620 (defcustom gnus-parse-headers-hook
621 (list 'gnus-decode-rfc1522)
622 "*A hook called before parsing the headers."
626 (defcustom gnus-exit-group-hook nil
627 "*A hook called when exiting (not quitting) summary mode."
631 (defcustom gnus-summary-update-hook
632 (list 'gnus-summary-highlight-line)
633 "*A hook called when a summary line is changed.
634 The hook will not be called if `gnus-visual' is nil.
636 The default function `gnus-summary-highlight-line' will
637 highlight the line according to the `gnus-summary-highlight'
642 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
643 "*A hook called when an article is selected for the first time.
644 The hook is intended to mark an article as read (or unread)
645 automatically when it is selected."
649 (defcustom gnus-group-no-more-groups-hook nil
650 "*A hook run when returning to group mode having no more (unread) groups."
654 (defface gnus-summary-selected-face '((t
656 "Face used for selected articles.")
658 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
659 "Face used for highlighting the current article in the summary buffer."
663 (defface gnus-summary-cancelled-face
665 (:foreground "yellow" :background "black")))
666 "Face used for cancelled articles.")
668 (defface gnus-summary-high-ticked-face
671 (:foreground "pink" :bold t))
674 (:foreground "firebrick" :bold t))
677 "Face used for high interest ticked articles.")
679 (defface gnus-summary-low-ticked-face
682 (:foreground "pink" :italic t))
685 (:foreground "firebrick" :italic t))
688 "Face used for low interest ticked articles.")
690 (defface gnus-summary-normal-ticked-face
693 (:foreground "pink"))
696 (:foreground "firebrick"))
699 "Face used for normal interest ticked articles.")
701 (defface gnus-summary-high-ancient-face
704 (:foreground "SkyBlue" :bold t))
707 (:foreground "RoyalBlue" :bold t))
710 "Face used for high interest ancient articles.")
712 (defface gnus-summary-low-ancient-face
715 (:foreground "SkyBlue" :italic t))
718 (:foreground "RoyalBlue" :italic t))
721 "Face used for low interest ancient articles.")
723 (defface gnus-summary-normal-ancient-face
726 (:foreground "SkyBlue"))
729 (:foreground "RoyalBlue"))
732 "Face used for normal interest ancient articles.")
734 (defface gnus-summary-high-unread-face
737 "Face used for high interest unread articles.")
739 (defface gnus-summary-low-unread-face
742 "Face used for low interest unread articles.")
744 (defface gnus-summary-normal-unread-face
747 "Face used for normal interest unread articles.")
749 (defface gnus-summary-high-read-face
752 (:foreground "PaleGreen"
756 (:foreground "DarkGreen"
760 "Face used for high interest read articles.")
762 (defface gnus-summary-low-read-face
765 (:foreground "PaleGreen"
769 (:foreground "DarkGreen"
773 "Face used for low interest read articles.")
775 (defface gnus-summary-normal-read-face
778 (:foreground "PaleGreen"))
781 (:foreground "DarkGreen"))
784 "Face used for normal interest read articles.")
786 (defcustom gnus-summary-highlight
787 '(((= mark gnus-canceled-mark)
788 . gnus-summary-cancelled-face)
789 ((and (> score default)
790 (or (= mark gnus-dormant-mark)
791 (= mark gnus-ticked-mark)))
792 . gnus-summary-high-ticked-face)
793 ((and (< score default)
794 (or (= mark gnus-dormant-mark)
795 (= mark gnus-ticked-mark)))
796 . gnus-summary-low-ticked-face)
797 ((or (= mark gnus-dormant-mark)
798 (= mark gnus-ticked-mark))
799 . gnus-summary-normal-ticked-face)
800 ((and (> score default) (= mark gnus-ancient-mark))
801 . gnus-summary-high-ancient-face)
802 ((and (< score default) (= mark gnus-ancient-mark))
803 . gnus-summary-low-ancient-face)
804 ((= mark gnus-ancient-mark)
805 . gnus-summary-normal-ancient-face)
806 ((and (> score default) (= mark gnus-unread-mark))
807 . gnus-summary-high-unread-face)
808 ((and (< score default) (= mark gnus-unread-mark))
809 . gnus-summary-low-unread-face)
810 ((and (= mark gnus-unread-mark))
811 . gnus-summary-normal-unread-face)
813 . gnus-summary-high-read-face)
815 . gnus-summary-low-read-face)
817 . gnus-summary-normal-read-face))
818 "Controls the highlighting of summary buffer lines.
820 A list of (FORM . FACE) pairs. When deciding how a a particular
821 summary line should be displayed, each form is evaluated. The content
822 of the face field after the first true form is used. You can change
823 how those summary lines are displayed, by editing the face field.
825 You can use the following variables in the FORM field.
827 score: The articles score
828 default: The default article score.
829 below: The score below which articles are automatically marked as read.
830 mark: The articles mark."
832 :type '(repeat (cons (sexp :tag "Form" nil)
835 ;;; Internal variables
837 (defvar gnus-scores-exclude-files nil)
839 (defvar gnus-summary-display-table
840 ;; Change the display table. Odd characters have a tendency to mess
841 ;; up nicely formatted displays - we make all possible glyphs
842 ;; display only a single character.
844 ;; We start from the standard display table, if any.
845 (let ((table (or (copy-sequence standard-display-table)
846 (make-display-table)))
847 ;; Nix out all the control chars...
849 (while (>= (setq i (1- i)) 0)
851 ;; ... but not newline and cr, of course. (cr is necessary for the
852 ;; selective display).
855 ;; We nix out any glyphs over 126 that are not set already.
857 (while (>= (setq i (1- i)) 127)
858 ;; Only modify if the entry is nil.
860 (aset table i [??]))))
862 "Display table used in summary mode buffers.")
864 (defvar gnus-original-article nil)
865 (defvar gnus-article-internal-prepare-hook nil)
866 (defvar gnus-newsgroup-process-stack nil)
868 (defvar gnus-thread-indent-array nil)
869 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
871 ;; Avoid highlighting in kill files.
872 (defvar gnus-summary-inhibit-highlight nil)
873 (defvar gnus-newsgroup-selected-overlay nil)
874 (defvar gnus-inhibit-limiting nil)
875 (defvar gnus-newsgroup-adaptive-score-file nil)
876 (defvar gnus-current-score-file nil)
877 (defvar gnus-current-move-group nil)
878 (defvar gnus-current-copy-group nil)
879 (defvar gnus-current-crosspost-group nil)
881 (defvar gnus-newsgroup-dependencies nil)
882 (defvar gnus-newsgroup-adaptive nil)
883 (defvar gnus-summary-display-article-function nil)
884 (defvar gnus-summary-highlight-line-function nil
885 "Function called after highlighting a summary line.")
887 (defvar gnus-summary-line-format-alist
888 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
889 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
890 (?s gnus-tmp-subject-or-nil ?s)
891 (?n gnus-tmp-name ?s)
892 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
894 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
896 (?F gnus-tmp-from ?s)
897 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
898 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
899 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
900 (?o (gnus-date-iso8601 gnus-tmp-header) ?s)
901 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
902 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
903 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
904 (?L gnus-tmp-lines ?d)
905 (?I gnus-tmp-indentation ?s)
906 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
907 (?R gnus-tmp-replied ?c)
908 (?\[ gnus-tmp-opening-bracket ?c)
909 (?\] gnus-tmp-closing-bracket ?c)
910 (?\> (make-string gnus-tmp-level ? ) ?s)
911 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
912 (?i gnus-tmp-score ?d)
913 (?z gnus-tmp-score-char ?c)
914 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
915 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
916 (?U gnus-tmp-unread ?c)
917 (?t (gnus-summary-number-of-articles-in-thread
918 (and (boundp 'thread) (car thread)) gnus-tmp-level)
920 (?e (gnus-summary-number-of-articles-in-thread
921 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
923 (?u gnus-tmp-user-defined ?s)
924 (?P (gnus-pick-line-number) ?d))
925 "An alist of format specifications that can appear in summary lines,
926 and what variables they correspond with, along with the type of the
927 variable (string, integer, character, etc).")
929 (defvar gnus-summary-dummy-line-format-alist
930 `((?S gnus-tmp-subject ?s)
931 (?N gnus-tmp-number ?d)
932 (?u gnus-tmp-user-defined ?s)))
934 (defvar gnus-summary-mode-line-format-alist
935 `((?G gnus-tmp-group-name ?s)
936 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
937 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
938 (?A gnus-tmp-article-number ?d)
939 (?Z gnus-tmp-unread-and-unselected ?s)
941 (?U gnus-tmp-unread-and-unticked ?d)
942 (?S gnus-tmp-subject ?s)
943 (?e gnus-tmp-unselected ?d)
944 (?u gnus-tmp-user-defined ?s)
945 (?d (length gnus-newsgroup-dormant) ?d)
946 (?t (length gnus-newsgroup-marked) ?d)
947 (?r (length gnus-newsgroup-reads) ?d)
948 (?E gnus-newsgroup-expunged-tally ?d)
949 (?s (gnus-current-score-file-nondirectory) ?s)))
951 (defvar gnus-last-search-regexp nil
952 "Default regexp for article search command.")
954 (defvar gnus-last-shell-command nil
955 "Default shell command on article.")
957 (defvar gnus-newsgroup-begin nil)
958 (defvar gnus-newsgroup-end nil)
959 (defvar gnus-newsgroup-last-rmail nil)
960 (defvar gnus-newsgroup-last-mail nil)
961 (defvar gnus-newsgroup-last-folder nil)
962 (defvar gnus-newsgroup-last-file nil)
963 (defvar gnus-newsgroup-auto-expire nil)
964 (defvar gnus-newsgroup-active nil)
966 (defvar gnus-newsgroup-data nil)
967 (defvar gnus-newsgroup-data-reverse nil)
968 (defvar gnus-newsgroup-limit nil)
969 (defvar gnus-newsgroup-limits nil)
971 (defvar gnus-newsgroup-unreads nil
972 "List of unread articles in the current newsgroup.")
974 (defvar gnus-newsgroup-unselected nil
975 "List of unselected unread articles in the current newsgroup.")
977 (defvar gnus-newsgroup-reads nil
978 "Alist of read articles and article marks in the current newsgroup.")
980 (defvar gnus-newsgroup-expunged-tally nil)
982 (defvar gnus-newsgroup-marked nil
983 "List of ticked articles in the current newsgroup (a subset of unread art).")
985 (defvar gnus-newsgroup-killed nil
986 "List of ranges of articles that have been through the scoring process.")
988 (defvar gnus-newsgroup-cached nil
989 "List of articles that come from the article cache.")
991 (defvar gnus-newsgroup-saved nil
992 "List of articles that have been saved.")
994 (defvar gnus-newsgroup-kill-headers nil)
996 (defvar gnus-newsgroup-replied nil
997 "List of articles that have been replied to in the current newsgroup.")
999 (defvar gnus-newsgroup-expirable nil
1000 "List of articles in the current newsgroup that can be expired.")
1002 (defvar gnus-newsgroup-processable nil
1003 "List of articles in the current newsgroup that can be processed.")
1005 (defvar gnus-newsgroup-bookmarks nil
1006 "List of articles in the current newsgroup that have bookmarks.")
1008 (defvar gnus-newsgroup-dormant nil
1009 "List of dormant articles in the current newsgroup.")
1011 (defvar gnus-newsgroup-scored nil
1012 "List of scored articles in the current newsgroup.")
1014 (defvar gnus-newsgroup-headers nil
1015 "List of article headers in the current newsgroup.")
1017 (defvar gnus-newsgroup-threads nil)
1019 (defvar gnus-newsgroup-prepared nil
1020 "Whether the current group has been prepared properly.")
1022 (defvar gnus-newsgroup-ancient nil
1023 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1025 (defvar gnus-newsgroup-sparse nil)
1027 (defvar gnus-current-article nil)
1028 (defvar gnus-article-current nil)
1029 (defvar gnus-current-headers nil)
1030 (defvar gnus-have-all-headers nil)
1031 (defvar gnus-last-article nil)
1032 (defvar gnus-newsgroup-history nil)
1034 (defconst gnus-summary-local-variables
1035 '(gnus-newsgroup-name
1036 gnus-newsgroup-begin gnus-newsgroup-end
1037 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1038 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1039 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1040 gnus-newsgroup-unselected gnus-newsgroup-marked
1041 gnus-newsgroup-reads gnus-newsgroup-saved
1042 gnus-newsgroup-replied gnus-newsgroup-expirable
1043 gnus-newsgroup-processable gnus-newsgroup-killed
1044 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1045 gnus-newsgroup-headers gnus-newsgroup-threads
1046 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1047 gnus-current-article gnus-current-headers gnus-have-all-headers
1048 gnus-last-article gnus-article-internal-prepare-hook
1049 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1050 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1051 gnus-thread-expunge-below
1052 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1053 (gnus-summary-mark-below . global)
1054 gnus-newsgroup-active gnus-scores-exclude-files
1055 gnus-newsgroup-history gnus-newsgroup-ancient
1056 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1057 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1058 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1059 (gnus-newsgroup-expunged-tally . 0)
1060 gnus-cache-removable-articles gnus-newsgroup-cached
1061 gnus-newsgroup-data gnus-newsgroup-data-reverse
1062 gnus-newsgroup-limit gnus-newsgroup-limits)
1063 "Variables that are buffer-local to the summary buffers.")
1065 ;; Byte-compiler warning.
1066 (defvar gnus-article-mode-map)
1068 ;; Subject simplification.
1070 (defsubst gnus-simplify-subject-re (subject)
1071 "Remove \"Re:\" from subject lines."
1072 (if (string-match "^[Rr][Ee]: *" subject)
1073 (substring subject (match-end 0))
1076 (defun gnus-simplify-subject (subject &optional re-only)
1077 "Remove `Re:' and words in parentheses.
1078 If RE-ONLY is non-nil, strip leading `Re:'s only."
1079 (let ((case-fold-search t)) ;Ignore case.
1080 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1081 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1082 (setq subject (substring subject (match-end 0))))
1083 ;; Remove uninteresting prefixes.
1084 (when (and (not re-only)
1085 gnus-simplify-ignored-prefixes
1086 (string-match gnus-simplify-ignored-prefixes subject))
1087 (setq subject (substring subject (match-end 0))))
1088 ;; Remove words in parentheses from end.
1090 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1091 (setq subject (substring subject 0 (match-beginning 0)))))
1092 ;; Return subject string.
1095 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1097 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
1098 (defun gnus-simplify-buffer-fuzzy ()
1099 (let ((case-fold-search t))
1100 (goto-char (point-min))
1101 (while (search-forward "\t" nil t)
1102 (replace-match " " t t))
1103 (goto-char (point-min))
1104 (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *" nil t)
1105 (goto-char (match-beginning 0))
1107 (looking-at "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1108 (looking-at "^[[].*: .*[]]$"))
1109 (goto-char (point-min))
1110 (while (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *"
1112 (replace-match "" t t))
1113 (goto-char (point-min))
1114 (while (re-search-forward "^[[].*: .*[]]$" nil t)
1115 (goto-char (match-end 0))
1118 (progn (goto-char (match-beginning 0)))
1119 (re-search-forward ":"))))
1120 (goto-char (point-min))
1121 (while (re-search-forward " *[[{(][^()\n]*[]})] *$" nil t)
1122 (replace-match "" t t))
1123 (goto-char (point-min))
1124 (while (re-search-forward " +" nil t)
1125 (replace-match " " t t))
1126 (goto-char (point-min))
1127 (while (re-search-forward " $" nil t)
1128 (replace-match "" t t))
1129 (goto-char (point-min))
1130 (while (re-search-forward "^ +" nil t)
1131 (replace-match "" t t))
1132 (goto-char (point-min))
1133 (when gnus-simplify-subject-fuzzy-regexp
1134 (if (listp gnus-simplify-subject-fuzzy-regexp)
1135 (let ((list gnus-simplify-subject-fuzzy-regexp))
1137 (goto-char (point-min))
1138 (while (re-search-forward (car list) nil t)
1139 (replace-match "" t t))
1140 (setq list (cdr list))))
1141 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
1142 (replace-match "" t t))))))
1144 (defun gnus-simplify-subject-fuzzy (subject)
1145 "Simplify a subject string fuzzily."
1147 (gnus-set-work-buffer)
1148 (let ((case-fold-search t))
1150 (inline (gnus-simplify-buffer-fuzzy))
1153 (defsubst gnus-simplify-subject-fully (subject)
1154 "Simplify a subject string according to the user's wishes."
1156 ((null gnus-summary-gather-subject-limit)
1157 (gnus-simplify-subject-re subject))
1158 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1159 (gnus-simplify-subject-fuzzy subject))
1160 ((numberp gnus-summary-gather-subject-limit)
1161 (gnus-limit-string (gnus-simplify-subject-re subject)
1162 gnus-summary-gather-subject-limit))
1166 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1167 "Check whether two subjects are equal. If optional argument
1168 simple-first is t, first argument is already simplified."
1170 ((null simple-first)
1171 (equal (gnus-simplify-subject-fully s1)
1172 (gnus-simplify-subject-fully s2)))
1175 (gnus-simplify-subject-fully s2)))))
1177 (defun gnus-offer-save-summaries ()
1178 "Offer to save all active summary buffers."
1180 (let ((buflist (buffer-list))
1182 ;; Go through all buffers and find all summaries.
1184 (and (setq bufname (buffer-name (car buflist)))
1185 (string-match "Summary" bufname)
1187 (set-buffer bufname)
1188 ;; We check that this is, indeed, a summary buffer.
1189 (and (eq major-mode 'gnus-summary-mode)
1190 ;; Also make sure this isn't bogus.
1191 gnus-newsgroup-prepared))
1192 (push bufname buffers))
1193 (setq buflist (cdr buflist)))
1194 ;; Go through all these summary buffers and offer to save them.
1197 "Update summary buffer %s? "
1198 (lambda (buf) (set-buffer buf) (gnus-summary-exit))
1201 (defun gnus-summary-bubble-group ()
1202 "Increase the score of the current group.
1203 This is a handy function to add to `gnus-summary-exit-hook' to
1204 increase the score of each group you read."
1205 (gnus-group-add-score gnus-newsgroup-name))
1209 ;;; Gnus summary mode
1212 (put 'gnus-summary-mode 'mode-class 'special)
1215 ;; Non-orthogonal keys
1217 (gnus-define-keys gnus-summary-mode-map
1218 " " gnus-summary-next-page
1219 "\177" gnus-summary-prev-page
1220 [delete] gnus-summary-prev-page
1221 "\r" gnus-summary-scroll-up
1222 "n" gnus-summary-next-unread-article
1223 "p" gnus-summary-prev-unread-article
1224 "N" gnus-summary-next-article
1225 "P" gnus-summary-prev-article
1226 "\M-\C-n" gnus-summary-next-same-subject
1227 "\M-\C-p" gnus-summary-prev-same-subject
1228 "\M-n" gnus-summary-next-unread-subject
1229 "\M-p" gnus-summary-prev-unread-subject
1230 "." gnus-summary-first-unread-article
1231 "," gnus-summary-best-unread-article
1232 "\M-s" gnus-summary-search-article-forward
1233 "\M-r" gnus-summary-search-article-backward
1234 "<" gnus-summary-beginning-of-article
1235 ">" gnus-summary-end-of-article
1236 "j" gnus-summary-goto-article
1237 "^" gnus-summary-refer-parent-article
1238 "\M-^" gnus-summary-refer-article
1239 "u" gnus-summary-tick-article-forward
1240 "!" gnus-summary-tick-article-forward
1241 "U" gnus-summary-tick-article-backward
1242 "d" gnus-summary-mark-as-read-forward
1243 "D" gnus-summary-mark-as-read-backward
1244 "E" gnus-summary-mark-as-expirable
1245 "\M-u" gnus-summary-clear-mark-forward
1246 "\M-U" gnus-summary-clear-mark-backward
1247 "k" gnus-summary-kill-same-subject-and-select
1248 "\C-k" gnus-summary-kill-same-subject
1249 "\M-\C-k" gnus-summary-kill-thread
1250 "\M-\C-l" gnus-summary-lower-thread
1251 "e" gnus-summary-edit-article
1252 "#" gnus-summary-mark-as-processable
1253 "\M-#" gnus-summary-unmark-as-processable
1254 "\M-\C-t" gnus-summary-toggle-threads
1255 "\M-\C-s" gnus-summary-show-thread
1256 "\M-\C-h" gnus-summary-hide-thread
1257 "\M-\C-f" gnus-summary-next-thread
1258 "\M-\C-b" gnus-summary-prev-thread
1259 "\M-\C-u" gnus-summary-up-thread
1260 "\M-\C-d" gnus-summary-down-thread
1261 "&" gnus-summary-execute-command
1262 "c" gnus-summary-catchup-and-exit
1263 "\C-w" gnus-summary-mark-region-as-read
1264 "\C-t" gnus-summary-toggle-truncation
1265 "?" gnus-summary-mark-as-dormant
1266 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1267 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1268 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1269 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1270 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1271 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1272 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1273 "=" gnus-summary-expand-window
1274 "\C-x\C-s" gnus-summary-reselect-current-group
1275 "\M-g" gnus-summary-rescan-group
1276 "w" gnus-summary-stop-page-breaking
1277 "\C-c\C-r" gnus-summary-caesar-message
1278 "\M-t" gnus-summary-toggle-mime
1279 "f" gnus-summary-followup
1280 "F" gnus-summary-followup-with-original
1281 "C" gnus-summary-cancel-article
1282 "r" gnus-summary-reply
1283 "R" gnus-summary-reply-with-original
1284 "\C-c\C-f" gnus-summary-mail-forward
1285 "o" gnus-summary-save-article
1286 "\C-o" gnus-summary-save-article-mail
1287 "|" gnus-summary-pipe-output
1288 "\M-k" gnus-summary-edit-local-kill
1289 "\M-K" gnus-summary-edit-global-kill
1291 "\C-c\C-d" gnus-summary-describe-group
1292 "q" gnus-summary-exit
1293 "Q" gnus-summary-exit-no-update
1294 "\C-c\C-i" gnus-info-find-node
1295 gnus-mouse-2 gnus-mouse-pick-article
1296 "m" gnus-summary-mail-other-window
1297 "a" gnus-summary-post-news
1298 "x" gnus-summary-limit-to-unread
1299 "s" gnus-summary-isearch-article
1300 "t" gnus-article-hide-headers
1301 "g" gnus-summary-show-article
1302 "l" gnus-summary-goto-last-article
1303 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1304 "\C-d" gnus-summary-enter-digest-group
1305 "\M-\C-d" gnus-summary-read-document
1307 "*" gnus-cache-enter-article
1308 "\M-*" gnus-cache-remove-article
1309 "\M-&" gnus-summary-universal-argument
1310 "\C-l" gnus-recenter
1311 "I" gnus-summary-increase-score
1312 "L" gnus-summary-lower-score
1314 "V" gnus-summary-score-map
1315 "X" gnus-uu-extract-map
1316 "S" gnus-summary-send-map)
1318 ;; Sort of orthogonal keymap
1319 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1320 "t" gnus-summary-tick-article-forward
1321 "!" gnus-summary-tick-article-forward
1322 "d" gnus-summary-mark-as-read-forward
1323 "r" gnus-summary-mark-as-read-forward
1324 "c" gnus-summary-clear-mark-forward
1325 " " gnus-summary-clear-mark-forward
1326 "e" gnus-summary-mark-as-expirable
1327 "x" gnus-summary-mark-as-expirable
1328 "?" gnus-summary-mark-as-dormant
1329 "b" gnus-summary-set-bookmark
1330 "B" gnus-summary-remove-bookmark
1331 "#" gnus-summary-mark-as-processable
1332 "\M-#" gnus-summary-unmark-as-processable
1333 "S" gnus-summary-limit-include-expunged
1334 "C" gnus-summary-catchup
1335 "H" gnus-summary-catchup-to-here
1336 "\C-c" gnus-summary-catchup-all
1337 "k" gnus-summary-kill-same-subject-and-select
1338 "K" gnus-summary-kill-same-subject
1339 "P" gnus-uu-mark-map)
1341 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1342 "c" gnus-summary-clear-above
1343 "u" gnus-summary-tick-above
1344 "m" gnus-summary-mark-above
1345 "k" gnus-summary-kill-below)
1347 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1348 "/" gnus-summary-limit-to-subject
1349 "n" gnus-summary-limit-to-articles
1350 "w" gnus-summary-pop-limit
1351 "s" gnus-summary-limit-to-subject
1352 "a" gnus-summary-limit-to-author
1353 "u" gnus-summary-limit-to-unread
1354 "m" gnus-summary-limit-to-marks
1355 "v" gnus-summary-limit-to-score
1356 "D" gnus-summary-limit-include-dormant
1357 "d" gnus-summary-limit-exclude-dormant
1358 ;; "t" gnus-summary-limit-exclude-thread
1359 "E" gnus-summary-limit-include-expunged
1360 "c" gnus-summary-limit-exclude-childless-dormant
1361 "C" gnus-summary-limit-mark-excluded-as-read)
1363 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1364 "n" gnus-summary-next-unread-article
1365 "p" gnus-summary-prev-unread-article
1366 "N" gnus-summary-next-article
1367 "P" gnus-summary-prev-article
1368 "\C-n" gnus-summary-next-same-subject
1369 "\C-p" gnus-summary-prev-same-subject
1370 "\M-n" gnus-summary-next-unread-subject
1371 "\M-p" gnus-summary-prev-unread-subject
1372 "f" gnus-summary-first-unread-article
1373 "b" gnus-summary-best-unread-article
1374 "j" gnus-summary-goto-article
1375 "g" gnus-summary-goto-subject
1376 "l" gnus-summary-goto-last-article
1377 "p" gnus-summary-pop-article)
1379 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1380 "k" gnus-summary-kill-thread
1381 "l" gnus-summary-lower-thread
1382 "i" gnus-summary-raise-thread
1383 "T" gnus-summary-toggle-threads
1384 "t" gnus-summary-rethread-current
1385 "^" gnus-summary-reparent-thread
1386 "s" gnus-summary-show-thread
1387 "S" gnus-summary-show-all-threads
1388 "h" gnus-summary-hide-thread
1389 "H" gnus-summary-hide-all-threads
1390 "n" gnus-summary-next-thread
1391 "p" gnus-summary-prev-thread
1392 "u" gnus-summary-up-thread
1393 "o" gnus-summary-top-thread
1394 "d" gnus-summary-down-thread
1395 "#" gnus-uu-mark-thread
1396 "\M-#" gnus-uu-unmark-thread)
1398 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1399 "g" gnus-summary-prepare
1400 "c" gnus-summary-insert-cached-articles)
1402 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1403 "c" gnus-summary-catchup-and-exit
1404 "C" gnus-summary-catchup-all-and-exit
1405 "E" gnus-summary-exit-no-update
1406 "Q" gnus-summary-exit
1407 "Z" gnus-summary-exit
1408 "n" gnus-summary-catchup-and-goto-next-group
1409 "R" gnus-summary-reselect-current-group
1410 "G" gnus-summary-rescan-group
1411 "N" gnus-summary-next-group
1412 "P" gnus-summary-prev-group)
1414 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1415 " " gnus-summary-next-page
1416 "n" gnus-summary-next-page
1417 "\177" gnus-summary-prev-page
1418 [delete] gnus-summary-prev-page
1419 "p" gnus-summary-prev-page
1420 "\r" gnus-summary-scroll-up
1421 "<" gnus-summary-beginning-of-article
1422 ">" gnus-summary-end-of-article
1423 "b" gnus-summary-beginning-of-article
1424 "e" gnus-summary-end-of-article
1425 "^" gnus-summary-refer-parent-article
1426 "r" gnus-summary-refer-parent-article
1427 "R" gnus-summary-refer-references
1428 "g" gnus-summary-show-article
1429 "s" gnus-summary-isearch-article
1430 "P" gnus-summary-print-article)
1432 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1433 "b" gnus-article-add-buttons
1434 "B" gnus-article-add-buttons-to-head
1435 "o" gnus-article-treat-overstrike
1436 "e" gnus-article-emphasize
1437 "w" gnus-article-fill-cited-article
1438 "c" gnus-article-remove-cr
1439 "q" gnus-article-de-quoted-unreadable
1440 "f" gnus-article-display-x-face
1441 "l" gnus-summary-stop-page-breaking
1442 "r" gnus-summary-caesar-message
1443 "t" gnus-article-hide-headers
1444 "v" gnus-summary-verbose-headers
1445 "m" gnus-summary-toggle-mime)
1447 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1448 "a" gnus-article-hide
1449 "h" gnus-article-hide-headers
1450 "b" gnus-article-hide-boring-headers
1451 "s" gnus-article-hide-signature
1452 "c" gnus-article-hide-citation
1453 "p" gnus-article-hide-pgp
1454 "P" gnus-article-hide-pem
1455 "\C-c" gnus-article-hide-citation-maybe)
1457 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1458 "a" gnus-article-highlight
1459 "h" gnus-article-highlight-headers
1460 "c" gnus-article-highlight-citation
1461 "s" gnus-article-highlight-signature)
1463 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1464 "z" gnus-article-date-ut
1465 "u" gnus-article-date-ut
1466 "l" gnus-article-date-local
1467 "e" gnus-article-date-lapsed
1468 "o" gnus-article-date-original)
1470 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1471 "t" gnus-article-remove-trailing-blank-lines
1472 "l" gnus-article-strip-leading-blank-lines
1473 "m" gnus-article-strip-multiple-blank-lines
1474 "a" gnus-article-strip-blank-lines)
1476 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1478 "f" gnus-summary-fetch-faq
1479 "d" gnus-summary-describe-group
1480 "h" gnus-summary-describe-briefly
1481 "i" gnus-info-find-node)
1483 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1484 "e" gnus-summary-expire-articles
1485 "\M-\C-e" gnus-summary-expire-articles-now
1486 "\177" gnus-summary-delete-article
1487 [delete] gnus-summary-delete-article
1488 "m" gnus-summary-move-article
1489 "r" gnus-summary-respool-article
1490 "w" gnus-summary-edit-article
1491 "c" gnus-summary-copy-article
1492 "B" gnus-summary-crosspost-article
1493 "q" gnus-summary-respool-query
1494 "i" gnus-summary-import-article
1495 "p" gnus-summary-article-posted-p)
1497 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1498 "o" gnus-summary-save-article
1499 "m" gnus-summary-save-article-mail
1500 "F" gnus-summary-write-article-file
1501 "r" gnus-summary-save-article-rmail
1502 "f" gnus-summary-save-article-file
1503 "b" gnus-summary-save-article-body-file
1504 "h" gnus-summary-save-article-folder
1505 "v" gnus-summary-save-article-vm
1506 "p" gnus-summary-pipe-output
1507 "s" gnus-soup-add-article))
1509 (defun gnus-summary-make-menu-bar ()
1510 (gnus-turn-off-edit-menu 'summary)
1512 (unless (boundp 'gnus-summary-misc-menu)
1515 gnus-summary-kill-menu gnus-summary-mode-map ""
1520 ["Enter score..." gnus-summary-score-entry t]
1521 ["Customize" gnus-score-customize t])
1522 (gnus-make-score-map 'increase)
1523 (gnus-make-score-map 'lower)
1525 ["Kill below" gnus-summary-kill-below t]
1526 ["Mark above" gnus-summary-mark-above t]
1527 ["Tick above" gnus-summary-tick-above t]
1528 ["Clear above" gnus-summary-clear-above t])
1529 ["Current score" gnus-summary-current-score t]
1530 ["Set score" gnus-summary-set-score t]
1531 ["Switch current score file..." gnus-score-change-score-file t]
1532 ["Set mark below..." gnus-score-set-mark-below t]
1533 ["Set expunge below..." gnus-score-set-expunge-below t]
1534 ["Edit current score file" gnus-score-edit-current-scores t]
1535 ["Edit score file" gnus-score-edit-file t]
1536 ["Trace score" gnus-score-find-trace t]
1537 ["Find words" gnus-score-find-favourite-words t]
1538 ["Rescore buffer" gnus-summary-rescore t]
1539 ["Increase score..." gnus-summary-increase-score t]
1540 ["Lower score..." gnus-summary-lower-score t]))))
1543 ["Ask" (gnus-score-set-default 'gnus-score-default-header nil)
1545 :selected (null gnus-score-default-header)]
1546 ["From" (gnus-score-set-default 'gnus-score-default-header 'a)
1548 :selected (eq gnus-score-default-header 'a)]
1549 ["Subject" (gnus-score-set-default 'gnus-score-default-header 's)
1551 :selected (eq gnus-score-default-header 's)]
1553 (gnus-score-set-default 'gnus-score-default-header 'b)
1555 :selected (eq gnus-score-default-header 'b )]
1557 (gnus-score-set-default 'gnus-score-default-header 'h)
1559 :selected (eq gnus-score-default-header 'h )]
1560 ["Message-ID" (gnus-score-set-default 'gnus-score-default-header 'i)
1562 :selected (eq gnus-score-default-header 'i )]
1563 ["Thread" (gnus-score-set-default 'gnus-score-default-header 't)
1565 :selected (eq gnus-score-default-header 't )]
1567 (gnus-score-set-default 'gnus-score-default-header 'x)
1569 :selected (eq gnus-score-default-header 'x )]
1570 ["Lines" (gnus-score-set-default 'gnus-score-default-header 'l)
1572 :selected (eq gnus-score-default-header 'l )]
1573 ["Date" (gnus-score-set-default 'gnus-score-default-header 'd)
1575 :selected (eq gnus-score-default-header 'd )]
1576 ["Followups to author"
1577 (gnus-score-set-default 'gnus-score-default-header 'f)
1579 :selected (eq gnus-score-default-header 'f )])
1581 ["Ask" (gnus-score-set-default 'gnus-score-default-type nil)
1583 :selected (null gnus-score-default-type)]
1584 ;; The `:active' key is commented out in the following,
1585 ;; because the GNU Emacs hack to support radio buttons use
1586 ;; active to indicate which button is selected.
1587 ["Substring" (gnus-score-set-default 'gnus-score-default-type 's)
1589 ;; :active (not (memq gnus-score-default-header '(l d)))
1590 :selected (eq gnus-score-default-type 's)]
1591 ["Regexp" (gnus-score-set-default 'gnus-score-default-type 'r)
1593 ;; :active (not (memq gnus-score-default-header '(l d)))
1594 :selected (eq gnus-score-default-type 'r)]
1595 ["Exact" (gnus-score-set-default 'gnus-score-default-type 'e)
1597 ;; :active (not (memq gnus-score-default-header '(l d)))
1598 :selected (eq gnus-score-default-type 'e)]
1599 ["Fuzzy" (gnus-score-set-default 'gnus-score-default-type 'f)
1601 ;; :active (not (memq gnus-score-default-header '(l d)))
1602 :selected (eq gnus-score-default-type 'f)]
1603 ["Before date" (gnus-score-set-default 'gnus-score-default-type 'b)
1605 ;; :active (eq (gnus-score-default-header 'd))
1606 :selected (eq gnus-score-default-type 'b)]
1607 ["At date" (gnus-score-set-default 'gnus-score-default-type 'n)
1609 ;; :active (eq (gnus-score-default-header 'd))
1610 :selected (eq gnus-score-default-type 'n)]
1611 ["After date" (gnus-score-set-default 'gnus-score-default-type 'a)
1613 ;; :active (eq (gnus-score-default-header 'd))
1614 :selected (eq gnus-score-default-type 'a)]
1616 (gnus-score-set-default 'gnus-score-default-type '<)
1618 ;; :active (eq (gnus-score-default-header 'l))
1619 :selected (eq gnus-score-default-type '<)]
1621 (gnus-score-set-default 'gnus-score-default-type '=)
1623 ;; :active (eq (gnus-score-default-header 'l))
1624 :selected (eq gnus-score-default-type '=)]
1625 ["Greater than number"
1626 (gnus-score-set-default 'gnus-score-default-type '>)
1628 ;; :active (eq (gnus-score-default-header 'l))
1629 :selected (eq gnus-score-default-type '>)])
1630 ["Default fold" gnus-score-default-fold-toggle
1632 :selected gnus-score-default-fold]
1634 ["Ask" (gnus-score-set-default 'gnus-score-default-duration nil)
1636 :selected (null gnus-score-default-duration)]
1638 (gnus-score-set-default 'gnus-score-default-duration 'p)
1640 :selected (eq gnus-score-default-duration 'p)]
1642 (gnus-score-set-default 'gnus-score-default-duration 't)
1644 :selected (eq gnus-score-default-duration 't)]
1646 (gnus-score-set-default 'gnus-score-default-duration 'i)
1648 :selected (eq gnus-score-default-duration 'i)]))
1651 gnus-summary-article-menu gnus-summary-mode-map ""
1654 ["All" gnus-article-hide t]
1655 ["Headers" gnus-article-hide-headers t]
1656 ["Signature" gnus-article-hide-signature t]
1657 ["Citation" gnus-article-hide-citation t]
1658 ["PGP" gnus-article-hide-pgp t]
1659 ["Boring headers" gnus-article-hide-boring-headers t])
1661 ["All" gnus-article-highlight t]
1662 ["Headers" gnus-article-highlight-headers t]
1663 ["Signature" gnus-article-highlight-signature t]
1664 ["Citation" gnus-article-highlight-citation t])
1666 ["Local" gnus-article-date-local t]
1667 ["UT" gnus-article-date-ut t]
1668 ["Original" gnus-article-date-original t]
1669 ["Lapsed" gnus-article-date-lapsed t])
1672 ["Leading" gnus-article-strip-leading-blank-lines t]
1673 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1674 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1675 ["All of the above" gnus-article-strip-blank-lines t])
1676 ["Overstrike" gnus-article-treat-overstrike t]
1677 ["Emphasis" gnus-article-emphasize t]
1678 ["Word wrap" gnus-article-fill-cited-article t]
1679 ["CR" gnus-article-remove-cr t]
1680 ["Show X-Face" gnus-article-display-x-face t]
1681 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1682 ["Rot 13" gnus-summary-caesar-message t]
1683 ["Add buttons" gnus-article-add-buttons t]
1684 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1685 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1686 ["Toggle MIME" gnus-summary-toggle-mime t]
1687 ["Verbose header" gnus-summary-verbose-headers t]
1688 ["Toggle header" gnus-summary-toggle-header t])
1690 ["Save in default format" gnus-summary-save-article t]
1691 ["Save in file" gnus-summary-save-article-file t]
1692 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1693 ["Write to file" gnus-summary-write-article-mail t]
1694 ["Save in MH folder" gnus-summary-save-article-folder t]
1695 ["Save in VM folder" gnus-summary-save-article-vm t]
1696 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1697 ["Save body in file" gnus-summary-save-article-body-file t]
1698 ["Pipe through a filter" gnus-summary-pipe-output t]
1699 ["Add to SOUP packet" gnus-soup-add-article t]
1700 ["Print" gnus-summary-print-article t])
1702 ["Respool article..." gnus-summary-respool-article t]
1703 ["Move article..." gnus-summary-move-article
1704 (gnus-check-backend-function
1705 'request-move-article gnus-newsgroup-name)]
1706 ["Copy article..." gnus-summary-copy-article t]
1707 ["Crosspost article..." gnus-summary-crosspost-article
1708 (gnus-check-backend-function
1709 'request-replace-article gnus-newsgroup-name)]
1710 ["Import file..." gnus-summary-import-article t]
1711 ["Check if posted" gnus-summary-article-posted-p t]
1712 ["Edit article" gnus-summary-edit-article
1713 (not (gnus-group-read-only-p))]
1714 ["Delete article" gnus-summary-delete-article
1715 (gnus-check-backend-function
1716 'request-expire-articles gnus-newsgroup-name)]
1717 ["Query respool" gnus-summary-respool-query t]
1718 ["Delete expirable articles" gnus-summary-expire-articles-now
1719 (gnus-check-backend-function
1720 'request-expire-articles gnus-newsgroup-name)])
1722 ["Uudecode" gnus-uu-decode-uu t]
1723 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1724 ["Unshar" gnus-uu-decode-unshar t]
1725 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1726 ["Save" gnus-uu-decode-save t]
1727 ["Binhex" gnus-uu-decode-binhex t]
1728 ["Postscript" gnus-uu-decode-postscript t])
1729 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1730 ["Isearch article..." gnus-summary-isearch-article t]
1731 ["Search articles forward..." gnus-summary-search-article-forward t]
1732 ["Search articles backward..." gnus-summary-search-article-backward t]
1733 ["Beginning of the article" gnus-summary-beginning-of-article t]
1734 ["End of the article" gnus-summary-end-of-article t]
1735 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1736 ["Fetch referenced articles" gnus-summary-refer-references t]
1737 ["Fetch article with id..." gnus-summary-refer-article t]
1738 ["Redisplay" gnus-summary-show-article t]))
1741 gnus-summary-thread-menu gnus-summary-mode-map ""
1743 ["Toggle threading" gnus-summary-toggle-threads t]
1744 ["Hide threads" gnus-summary-hide-all-threads t]
1745 ["Show threads" gnus-summary-show-all-threads t]
1746 ["Hide thread" gnus-summary-hide-thread t]
1747 ["Show thread" gnus-summary-show-thread t]
1748 ["Go to next thread" gnus-summary-next-thread t]
1749 ["Go to previous thread" gnus-summary-prev-thread t]
1750 ["Go down thread" gnus-summary-down-thread t]
1751 ["Go up thread" gnus-summary-up-thread t]
1752 ["Top of thread" gnus-summary-top-thread t]
1753 ["Mark thread as read" gnus-summary-kill-thread t]
1754 ["Lower thread score" gnus-summary-lower-thread t]
1755 ["Raise thread score" gnus-summary-raise-thread t]
1756 ["Rethread current" gnus-summary-rethread-current t]
1760 gnus-summary-post-menu gnus-summary-mode-map ""
1762 ["Post an article" gnus-summary-post-news t]
1763 ["Followup" gnus-summary-followup t]
1764 ["Followup and yank" gnus-summary-followup-with-original t]
1765 ["Supersede article" gnus-summary-supersede-article t]
1766 ["Cancel article" gnus-summary-cancel-article t]
1767 ["Reply" gnus-summary-reply t]
1768 ["Reply and yank" gnus-summary-reply-with-original t]
1769 ["Mail forward" gnus-summary-mail-forward t]
1770 ["Post forward" gnus-summary-post-forward t]
1771 ["Digest and mail" gnus-uu-digest-mail-forward t]
1772 ["Digest and post" gnus-uu-digest-post-forward t]
1773 ["Resend message" gnus-summary-resend-message t]
1774 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1775 ["Send a mail" gnus-summary-mail-other-window t]
1776 ["Uuencode and post" gnus-uu-post-news t]
1777 ["Followup via news" gnus-summary-followup-to-mail t]
1778 ["Followup via news and yank"
1779 gnus-summary-followup-to-mail-with-original t]
1781 ;;["Send" gnus-summary-send-draft t]
1782 ;;["Send bounced" gnus-resend-bounced-mail t])
1786 gnus-summary-misc-menu gnus-summary-mode-map ""
1789 ["Mark as read" gnus-summary-mark-as-read-forward t]
1790 ["Mark same subject and select"
1791 gnus-summary-kill-same-subject-and-select t]
1792 ["Mark same subject" gnus-summary-kill-same-subject t]
1793 ["Catchup" gnus-summary-catchup t]
1794 ["Catchup all" gnus-summary-catchup-all t]
1795 ["Catchup to here" gnus-summary-catchup-to-here t]
1796 ["Catchup region" gnus-summary-mark-region-as-read t]
1797 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1799 ["Tick" gnus-summary-tick-article-forward t]
1800 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1801 ["Remove marks" gnus-summary-clear-mark-forward t]
1802 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1803 ["Set bookmark" gnus-summary-set-bookmark t]
1804 ["Remove bookmark" gnus-summary-remove-bookmark t])
1806 ["Marks..." gnus-summary-limit-to-marks t]
1807 ["Subject..." gnus-summary-limit-to-subject t]
1808 ["Author..." gnus-summary-limit-to-author t]
1809 ["Score" gnus-summary-limit-to-score t]
1810 ["Unread" gnus-summary-limit-to-unread t]
1811 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1812 ["Articles" gnus-summary-limit-to-articles t]
1813 ["Pop limit" gnus-summary-pop-limit t]
1814 ["Show dormant" gnus-summary-limit-include-dormant t]
1815 ["Hide childless dormant"
1816 gnus-summary-limit-exclude-childless-dormant t]
1817 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1818 ["Show expunged" gnus-summary-show-all-expunged t])
1820 ["Set mark" gnus-summary-mark-as-processable t]
1821 ["Remove mark" gnus-summary-unmark-as-processable t]
1822 ["Remove all marks" gnus-summary-unmark-all-processable t]
1823 ["Mark above" gnus-uu-mark-over t]
1824 ["Mark series" gnus-uu-mark-series t]
1825 ["Mark region" gnus-uu-mark-region t]
1826 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1827 ["Mark all" gnus-uu-mark-all t]
1828 ["Mark buffer" gnus-uu-mark-buffer t]
1829 ["Mark sparse" gnus-uu-mark-sparse t]
1830 ["Mark thread" gnus-uu-mark-thread t]
1831 ["Unmark thread" gnus-uu-unmark-thread t]
1832 ("Process Mark Sets"
1833 ["Kill" gnus-summary-kill-process-mark t]
1834 ["Yank" gnus-summary-yank-process-mark
1835 gnus-newsgroup-process-stack]
1836 ["Save" gnus-summary-save-process-mark t]))
1838 ["Page forward" gnus-summary-next-page t]
1839 ["Page backward" gnus-summary-prev-page t]
1840 ["Line forward" gnus-summary-scroll-up t])
1842 ["Next unread article" gnus-summary-next-unread-article t]
1843 ["Previous unread article" gnus-summary-prev-unread-article t]
1844 ["Next article" gnus-summary-next-article t]
1845 ["Previous article" gnus-summary-prev-article t]
1846 ["Next unread subject" gnus-summary-next-unread-subject t]
1847 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1848 ["Next article same subject" gnus-summary-next-same-subject t]
1849 ["Previous article same subject" gnus-summary-prev-same-subject t]
1850 ["First unread article" gnus-summary-first-unread-article t]
1851 ["Best unread article" gnus-summary-best-unread-article t]
1852 ["Go to subject number..." gnus-summary-goto-subject t]
1853 ["Go to article number..." gnus-summary-goto-article t]
1854 ["Go to the last article" gnus-summary-goto-last-article t]
1855 ["Pop article off history" gnus-summary-pop-article t])
1857 ["Sort by number" gnus-summary-sort-by-number t]
1858 ["Sort by author" gnus-summary-sort-by-author t]
1859 ["Sort by subject" gnus-summary-sort-by-subject t]
1860 ["Sort by date" gnus-summary-sort-by-date t]
1861 ["Sort by score" gnus-summary-sort-by-score t]
1862 ["Sort by lines" gnus-summary-sort-by-lines t])
1864 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1865 ["Describe group" gnus-summary-describe-group t]
1866 ["Read manual" gnus-info-find-node t])
1868 ["Enter article" gnus-cache-enter-article t]
1869 ["Remove article" gnus-cache-remove-article t])
1871 ["Pick and read" gnus-pick-mode t]
1872 ["Binary" gnus-binary-mode t])
1873 ["Filter articles..." gnus-summary-execute-command t]
1874 ["Run command on subjects..." gnus-summary-universal-argument t]
1875 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1876 ["Expand window" gnus-summary-expand-window t]
1877 ["Expire expirable articles" gnus-summary-expire-articles
1878 (gnus-check-backend-function
1879 'request-expire-articles gnus-newsgroup-name)]
1880 ["Regenerate buffer" gnus-summary-prepare t]
1881 ["Edit local kill file" gnus-summary-edit-local-kill t]
1882 ["Edit main kill file" gnus-summary-edit-global-kill t]
1884 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1885 ["Catchup all and exit" gnus-summary-catchup-and-exit t]
1886 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1887 ["Exit group" gnus-summary-exit t]
1888 ["Exit group without updating" gnus-summary-exit-no-update t]
1889 ["Exit and goto next group" gnus-summary-next-group t]
1890 ["Exit and goto prev group" gnus-summary-prev-group t]
1891 ["Reselect group" gnus-summary-reselect-current-group t]
1892 ["Rescan group" gnus-summary-rescan-group t])))
1894 (run-hooks 'gnus-summary-menu-hook)))
1896 (defun gnus-score-set-default (var value)
1897 "A version of set that updates the GNU Emacs menu-bar."
1899 ;; It is the message that forces the active status to be updated.
1902 (defun gnus-make-score-map (type)
1903 "Make a summary score map of type TYPE."
1906 (let ((headers '(("author" "from" string)
1907 ("subject" "subject" string)
1908 ("article body" "body" string)
1909 ("article head" "head" string)
1910 ("xref" "xref" string)
1911 ("lines" "lines" number)
1912 ("followups to author" "followup" string)))
1913 (types '((number ("less than" <)
1916 (string ("substring" s)
1920 (perms '(("temporary" (current-time-string))
1928 (if (eq type 'lower)
1933 (setq header (car headers))
1939 (let ((ts (cdr (assoc (nth 2 header) types)))
1955 'gnus-summary-score-entry
1957 (if (or (string= (nth 1 header)
1959 (string= (nth 1 header)
1962 (list 'gnus-summary-header
1964 (list 'quote (nth 1 (car ts)))
1965 (list 'gnus-score-default nil)
1971 (list (nreverse outp))))
1974 (list (nreverse outt))))
1976 (setq headers (cdr headers)))
1977 (list (nreverse outh))))))))
1981 (defun gnus-summary-mode (&optional group)
1982 "Major mode for reading articles.
1984 All normal editing commands are switched off.
1985 \\<gnus-summary-mode-map>
1986 Each line in this buffer represents one article. To read an
1987 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
1988 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
1991 You can also post articles and send mail from this buffer. To
1992 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
1993 of an article, type `\\[gnus-summary-reply]'.
1995 There are approx. one gazillion commands you can execute in this
1996 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
1998 The following commands are available:
2000 \\{gnus-summary-mode-map}"
2002 (when (gnus-visual-p 'summary-menu 'menu)
2003 (gnus-summary-make-menu-bar))
2004 (kill-all-local-variables)
2005 (gnus-summary-make-local-variables)
2006 (gnus-make-thread-indent-array)
2007 (gnus-simplify-mode-line)
2008 (setq major-mode 'gnus-summary-mode)
2009 (setq mode-name "Summary")
2010 (make-local-variable 'minor-mode-alist)
2011 (use-local-map gnus-summary-mode-map)
2012 (buffer-disable-undo (current-buffer))
2013 (setq buffer-read-only t) ;Disable modification
2014 (setq truncate-lines t)
2015 (setq selective-display t)
2016 (setq selective-display-ellipses t) ;Display `...'
2017 (setq buffer-display-table gnus-summary-display-table)
2018 (gnus-set-default-directory)
2019 (setq gnus-newsgroup-name group)
2020 (make-local-variable 'gnus-summary-line-format)
2021 (make-local-variable 'gnus-summary-line-format-spec)
2022 (make-local-variable 'gnus-summary-mark-positions)
2023 (gnus-make-local-hook 'post-command-hook)
2024 (gnus-add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
2025 (run-hooks 'gnus-summary-mode-hook)
2026 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2027 (gnus-update-summary-mark-positions))
2029 (defun gnus-summary-make-local-variables ()
2030 "Make all the local summary buffer variables."
2031 (let ((locals gnus-summary-local-variables)
2033 (while (setq local (pop locals))
2036 (if (eq (cdr local) 'global)
2037 ;; Copy the global value of the variable.
2038 (setq global (symbol-value (car local)))
2039 ;; Use the value from the list.
2040 (setq global (eval (cdr local))))
2041 (make-local-variable (car local))
2042 (set (car local) global))
2043 ;; Simple nil-valued local variable.
2044 (make-local-variable local)
2047 (defun gnus-summary-clear-local-variables ()
2048 (let ((locals gnus-summary-local-variables))
2050 (if (consp (car locals))
2051 (and (vectorp (caar locals))
2052 (set (caar locals) nil))
2053 (and (vectorp (car locals))
2054 (set (car locals) nil)))
2055 (setq locals (cdr locals)))))
2057 ;; Summary data functions.
2059 (defmacro gnus-data-number (data)
2062 (defmacro gnus-data-set-number (data number)
2063 `(setcar ,data ,number))
2065 (defmacro gnus-data-mark (data)
2068 (defmacro gnus-data-set-mark (data mark)
2069 `(setcar (nthcdr 1 ,data) ,mark))
2071 (defmacro gnus-data-pos (data)
2074 (defmacro gnus-data-set-pos (data pos)
2075 `(setcar (nthcdr 2 ,data) ,pos))
2077 (defmacro gnus-data-header (data)
2080 (defmacro gnus-data-level (data)
2083 (defmacro gnus-data-unread-p (data)
2084 `(= (nth 1 ,data) gnus-unread-mark))
2086 (defmacro gnus-data-read-p (data)
2087 `(/= (nth 1 ,data) gnus-unread-mark))
2089 (defmacro gnus-data-pseudo-p (data)
2090 `(consp (nth 3 ,data)))
2092 (defmacro gnus-data-find (number)
2093 `(assq ,number gnus-newsgroup-data))
2095 (defmacro gnus-data-find-list (number &optional data)
2096 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2097 (memq (assq ,number bdata)
2100 (defmacro gnus-data-make (number mark pos header level)
2101 `(list ,number ,mark ,pos ,header ,level))
2103 (defun gnus-data-enter (after-article number mark pos header level offset)
2104 (let ((data (gnus-data-find-list after-article)))
2106 (error "No such article: %d" after-article))
2107 (setcdr data (cons (gnus-data-make number mark pos header level)
2109 (setq gnus-newsgroup-data-reverse nil)
2110 (gnus-data-update-list (cddr data) offset)))
2112 (defun gnus-data-enter-list (after-article list &optional offset)
2114 (let ((data (and after-article (gnus-data-find-list after-article)))
2116 (or data (not after-article) (error "No such article: %d" after-article))
2117 ;; Find the last element in the list to be spliced into the main
2120 (setq list (cdr list)))
2123 (setcdr list gnus-newsgroup-data)
2124 (setq gnus-newsgroup-data ilist)
2126 (gnus-data-update-list (cdr list) offset)))
2127 (setcdr list (cdr data))
2130 (gnus-data-update-list (cdr list) offset)))
2131 (setq gnus-newsgroup-data-reverse nil))))
2133 (defun gnus-data-remove (article &optional offset)
2134 (let ((data gnus-newsgroup-data))
2135 (if (= (gnus-data-number (car data)) article)
2137 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2138 gnus-newsgroup-data-reverse nil)
2140 (gnus-data-update-list gnus-newsgroup-data offset)))
2142 (when (= (gnus-data-number (cadr data)) article)
2143 (setcdr data (cddr data))
2145 (gnus-data-update-list (cdr data) offset))
2147 gnus-newsgroup-data-reverse nil))
2148 (setq data (cdr data))))))
2150 (defmacro gnus-data-list (backward)
2152 (or gnus-newsgroup-data-reverse
2153 (setq gnus-newsgroup-data-reverse
2154 (reverse gnus-newsgroup-data)))
2155 gnus-newsgroup-data))
2157 (defun gnus-data-update-list (data offset)
2158 "Add OFFSET to the POS of all data entries in DATA."
2160 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2161 (setq data (cdr data))))
2163 (defun gnus-summary-article-pseudo-p (article)
2164 "Say whether this article is a pseudo article or not."
2165 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2167 (defmacro gnus-summary-article-sparse-p (article)
2168 "Say whether this article is a sparse article or not."
2169 ` (memq ,article gnus-newsgroup-sparse))
2171 (defmacro gnus-summary-article-ancient-p (article)
2172 "Say whether this article is a sparse article or not."
2173 `(memq ,article gnus-newsgroup-ancient))
2175 (defun gnus-article-parent-p (number)
2176 "Say whether this article is a parent or not."
2177 (let ((data (gnus-data-find-list number)))
2178 (and (cdr data) ; There has to be an article after...
2179 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2180 (gnus-data-level (nth 1 data))))))
2182 (defun gnus-article-children (number)
2183 "Return a list of all children to NUMBER."
2184 (let* ((data (gnus-data-find-list number))
2185 (level (gnus-data-level (car data)))
2187 (setq data (cdr data))
2189 (= (gnus-data-level (car data)) (1+ level)))
2190 (push (gnus-data-number (car data)) children)
2191 (setq data (cdr data)))
2194 (defmacro gnus-summary-skip-intangible ()
2195 "If the current article is intangible, then jump to a different article."
2196 '(let ((to (get-text-property (point) 'gnus-intangible)))
2197 (and to (gnus-summary-goto-subject to))))
2199 (defmacro gnus-summary-article-intangible-p ()
2200 "Say whether this article is intangible or not."
2201 '(get-text-property (point) 'gnus-intangible))
2203 (defun gnus-article-read-p (article)
2204 "Say whether ARTICLE is read or not."
2205 (not (or (memq article gnus-newsgroup-marked)
2206 (memq article gnus-newsgroup-unreads)
2207 (memq article gnus-newsgroup-unselected)
2208 (memq article gnus-newsgroup-dormant))))
2210 ;; Some summary mode macros.
2212 (defmacro gnus-summary-article-number ()
2213 "The article number of the article on the current line.
2214 If there isn's an article number here, then we return the current
2217 (gnus-summary-skip-intangible)
2218 (or (get-text-property (point) 'gnus-number)
2219 (gnus-summary-last-subject))))
2221 (defmacro gnus-summary-article-header (&optional number)
2222 `(gnus-data-header (gnus-data-find
2223 ,(or number '(gnus-summary-article-number)))))
2225 (defmacro gnus-summary-thread-level (&optional number)
2226 `(if (and (eq gnus-summary-make-false-root 'dummy)
2227 (get-text-property (point) 'gnus-intangible))
2229 (gnus-data-level (gnus-data-find
2230 ,(or number '(gnus-summary-article-number))))))
2232 (defmacro gnus-summary-article-mark (&optional number)
2233 `(gnus-data-mark (gnus-data-find
2234 ,(or number '(gnus-summary-article-number)))))
2236 (defmacro gnus-summary-article-pos (&optional number)
2237 `(gnus-data-pos (gnus-data-find
2238 ,(or number '(gnus-summary-article-number)))))
2240 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2241 (defmacro gnus-summary-article-subject (&optional number)
2242 "Return current subject string or nil if nothing."
2245 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2246 '(gnus-data-header (assq (gnus-summary-article-number)
2247 gnus-newsgroup-data)))))
2250 (mail-header-subject headers))))
2252 (defmacro gnus-summary-article-score (&optional number)
2253 "Return current article score."
2254 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2255 gnus-newsgroup-scored))
2256 gnus-summary-default-score 0))
2258 (defun gnus-summary-article-children (&optional number)
2259 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2260 (level (gnus-data-level (car data)))
2262 (while (and (setq data (cdr data))
2263 (> (setq l (gnus-data-level (car data))) level))
2264 (and (= (1+ level) l)
2265 (push (gnus-data-number (car data))
2267 (nreverse children)))
2269 (defun gnus-summary-article-parent (&optional number)
2270 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2271 (gnus-data-list t)))
2272 (level (gnus-data-level (car data))))
2274 () ; This is a root.
2275 ;; We search until we find an article with a level less than
2276 ;; this one. That function has to be the parent.
2277 (while (and (setq data (cdr data))
2278 (not (< (gnus-data-level (car data)) level))))
2279 (and data (gnus-data-number (car data))))))
2281 (defun gnus-unread-mark-p (mark)
2282 "Say whether MARK is the unread mark."
2283 (= mark gnus-unread-mark))
2285 (defun gnus-read-mark-p (mark)
2286 "Say whether MARK is one of the marks that mark as read.
2287 This is all marks except unread, ticked, dormant, and expirable."
2288 (not (or (= mark gnus-unread-mark)
2289 (= mark gnus-ticked-mark)
2290 (= mark gnus-dormant-mark)
2291 (= mark gnus-expirable-mark))))
2293 (defmacro gnus-article-mark (number)
2295 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2296 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2297 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2298 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2299 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2300 gnus-ancient-mark))))
2302 ;; Saving hidden threads.
2304 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2305 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2307 (defmacro gnus-save-hidden-threads (&rest forms)
2308 "Save hidden threads, eval FORMS, and restore the hidden threads."
2309 (let ((config (make-symbol "config")))
2310 `(let ((,config (gnus-hidden-threads-configuration)))
2314 (gnus-restore-hidden-threads-configuration ,config)))))
2316 (defun gnus-hidden-threads-configuration ()
2317 "Return the current hidden threads configuration."
2320 (goto-char (point-min))
2321 (while (search-forward "\r" nil t)
2322 (push (1- (point)) config))
2325 (defun gnus-restore-hidden-threads-configuration (config)
2326 "Restore hidden threads configuration from CONFIG."
2327 (let (point buffer-read-only)
2328 (while (setq point (pop config))
2329 (when (and (< point (point-max))
2331 (= (following-char) ?\n))
2332 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2334 ;; Various summary mode internalish functions.
2336 (defun gnus-mouse-pick-article (e)
2339 (gnus-summary-next-page nil t))
2341 (defun gnus-summary-setup-buffer (group)
2342 "Initialize summary buffer."
2343 (let ((buffer (concat "*Summary " group "*")))
2344 (if (get-buffer buffer)
2347 (setq gnus-summary-buffer (current-buffer))
2348 (not gnus-newsgroup-prepared))
2349 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2350 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
2351 (gnus-add-current-to-buffer-list)
2352 (gnus-summary-mode group)
2354 (gnus-carpal-setup-buffer 'summary))
2355 (unless gnus-single-article-buffer
2356 (make-local-variable 'gnus-article-buffer)
2357 (make-local-variable 'gnus-article-current)
2358 (make-local-variable 'gnus-original-article-buffer))
2359 (setq gnus-newsgroup-name group)
2362 (defun gnus-set-global-variables ()
2363 ;; Set the global equivalents of the summary buffer-local variables
2364 ;; to the latest values they had. These reflect the summary buffer
2365 ;; that was in action when the last article was fetched.
2366 (when (eq major-mode 'gnus-summary-mode)
2367 (setq gnus-summary-buffer (current-buffer))
2368 (let ((name gnus-newsgroup-name)
2369 (marked gnus-newsgroup-marked)
2370 (unread gnus-newsgroup-unreads)
2371 (headers gnus-current-headers)
2372 (data gnus-newsgroup-data)
2373 (summary gnus-summary-buffer)
2374 (article-buffer gnus-article-buffer)
2375 (original gnus-original-article-buffer)
2376 (gac gnus-article-current)
2377 (reffed gnus-reffed-article-number)
2378 (score-file gnus-current-score-file))
2380 (set-buffer gnus-group-buffer)
2381 (setq gnus-newsgroup-name name)
2382 (setq gnus-newsgroup-marked marked)
2383 (setq gnus-newsgroup-unreads unread)
2384 (setq gnus-current-headers headers)
2385 (setq gnus-newsgroup-data data)
2386 (setq gnus-article-current gac)
2387 (setq gnus-summary-buffer summary)
2388 (setq gnus-article-buffer article-buffer)
2389 (setq gnus-original-article-buffer original)
2390 (setq gnus-reffed-article-number reffed)
2391 (setq gnus-current-score-file score-file)
2392 ;; The article buffer also has local variables.
2393 (when (gnus-buffer-live-p gnus-article-buffer)
2394 (set-buffer gnus-article-buffer)
2395 (setq gnus-summary-buffer summary))))))
2397 (defun gnus-summary-article-unread-p (article)
2398 "Say whether ARTICLE is unread or not."
2399 (memq article gnus-newsgroup-unreads))
2401 (defun gnus-summary-first-article-p (&optional article)
2402 "Return whether ARTICLE is the first article in the buffer."
2403 (if (not (setq article (or article (gnus-summary-article-number))))
2405 (eq article (caar gnus-newsgroup-data))))
2407 (defun gnus-summary-last-article-p (&optional article)
2408 "Return whether ARTICLE is the last article in the buffer."
2409 (if (not (setq article (or article (gnus-summary-article-number))))
2410 t ; All non-existent numbers are the last article. :-)
2411 (not (cdr (gnus-data-find-list article)))))
2413 (defun gnus-make-thread-indent-array ()
2415 (unless (and gnus-thread-indent-array
2416 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2417 (setq gnus-thread-indent-array (make-vector 201 "")
2418 gnus-thread-indent-array-level gnus-thread-indent-level)
2420 (aset gnus-thread-indent-array n
2421 (make-string (* n gnus-thread-indent-level) ? ))
2424 (defun gnus-update-summary-mark-positions ()
2425 "Compute where the summary marks are to go."
2427 (when (and gnus-summary-buffer
2428 (get-buffer gnus-summary-buffer)
2429 (buffer-name (get-buffer gnus-summary-buffer)))
2430 (set-buffer gnus-summary-buffer))
2431 (let ((gnus-replied-mark 129)
2432 (gnus-score-below-mark 130)
2433 (gnus-score-over-mark 130)
2434 (spec gnus-summary-line-format-spec)
2435 thread gnus-visual pos)
2437 (gnus-set-work-buffer)
2438 (let ((gnus-summary-line-format-spec spec))
2439 (gnus-summary-insert-line
2440 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2441 (goto-char (point-min))
2442 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2444 (goto-char (point-min))
2445 (push (cons 'replied (and (search-forward "\201" nil t)
2448 (goto-char (point-min))
2449 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2451 (setq gnus-summary-mark-positions pos))))
2453 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2454 "Insert a dummy root in the summary buffer."
2456 (gnus-add-text-properties
2457 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2458 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2460 (defun gnus-summary-insert-line (gnus-tmp-header
2461 gnus-tmp-level gnus-tmp-current
2462 gnus-tmp-unread gnus-tmp-replied
2463 gnus-tmp-expirable gnus-tmp-subject-or-nil
2464 &optional gnus-tmp-dummy gnus-tmp-score
2466 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2467 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2468 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2469 (gnus-tmp-score-char
2470 (if (or (null gnus-summary-default-score)
2471 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2472 gnus-summary-zcore-fuzz))
2474 (if (< gnus-tmp-score gnus-summary-default-score)
2475 gnus-score-below-mark gnus-score-over-mark)))
2477 (cond (gnus-tmp-process gnus-process-mark)
2478 ((memq gnus-tmp-current gnus-newsgroup-cached)
2480 (gnus-tmp-replied gnus-replied-mark)
2481 ((memq gnus-tmp-current gnus-newsgroup-saved)
2483 (t gnus-unread-mark)))
2484 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2487 ((string-match "<[^>]+> *$" gnus-tmp-from)
2488 (let ((beg (match-beginning 0)))
2489 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2490 (substring gnus-tmp-from (1+ (match-beginning 0))
2491 (1- (match-end 0))))
2492 (substring gnus-tmp-from 0 beg))))
2493 ((string-match "(.+)" gnus-tmp-from)
2494 (substring gnus-tmp-from
2495 (1+ (match-beginning 0)) (1- (match-end 0))))
2497 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2498 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2499 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2500 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2501 (buffer-read-only nil))
2502 (when (string= gnus-tmp-name "")
2503 (setq gnus-tmp-name gnus-tmp-from))
2504 (unless (numberp gnus-tmp-lines)
2505 (setq gnus-tmp-lines 0))
2506 (gnus-put-text-property
2508 (progn (eval gnus-summary-line-format-spec) (point))
2509 'gnus-number gnus-tmp-number)
2510 (when (gnus-visual-p 'summary-highlight 'highlight)
2512 (run-hooks 'gnus-summary-update-hook)
2515 (defun gnus-summary-update-line (&optional dont-update)
2516 ;; Update summary line after change.
2517 (when (and gnus-summary-default-score
2518 (not gnus-summary-inhibit-highlight))
2519 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2520 (article (gnus-summary-article-number))
2521 (score (gnus-summary-article-score article)))
2523 (if (and gnus-summary-mark-below
2524 (< (gnus-summary-article-score)
2525 gnus-summary-mark-below))
2526 ;; This article has a low score, so we mark it as read.
2527 (when (memq article gnus-newsgroup-unreads)
2528 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2529 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2530 ;; This article was previously marked as read on account
2531 ;; of a low score, but now it has risen, so we mark it as
2533 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2534 (gnus-summary-update-mark
2535 (if (or (null gnus-summary-default-score)
2536 (<= (abs (- score gnus-summary-default-score))
2537 gnus-summary-zcore-fuzz))
2539 (if (< score gnus-summary-default-score)
2540 gnus-score-below-mark gnus-score-over-mark))
2542 ;; Do visual highlighting.
2543 (when (gnus-visual-p 'summary-highlight 'highlight)
2544 (run-hooks 'gnus-summary-update-hook)))))
2546 (defvar gnus-tmp-new-adopts nil)
2548 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2549 "Return the number of articles in THREAD.
2550 This may be 0 in some cases -- if none of the articles in
2551 the thread are to be displayed."
2553 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2555 ((not (listp thread))
2557 ((and (consp thread) (cdr thread))
2560 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2563 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2566 (when (and level (zerop level) gnus-tmp-new-adopts)
2569 'gnus-summary-number-of-articles-in-thread
2570 gnus-tmp-new-adopts))))
2572 (if (> number 1) gnus-not-empty-thread-mark
2573 gnus-empty-thread-mark)
2576 (defun gnus-summary-set-local-parameters (group)
2577 "Go through the local params of GROUP and set all variable specs in that list."
2578 (let ((params (gnus-group-find-parameter group))
2581 (setq elem (car params)
2582 params (cdr params))
2583 (and (consp elem) ; Has to be a cons.
2584 (consp (cdr elem)) ; The cdr has to be a list.
2585 (symbolp (car elem)) ; Has to be a symbol in there.
2586 (not (memq (car elem)
2587 '(quit-config to-address to-list to-group)))
2588 (progn ; So we set it.
2589 (make-local-variable (car elem))
2590 (set (car elem) (eval (nth 1 elem))))))))
2592 (defun gnus-summary-read-group (group &optional show-all no-article
2593 kill-buffer no-display)
2594 "Start reading news in newsgroup GROUP.
2595 If SHOW-ALL is non-nil, already read articles are also listed.
2596 If NO-ARTICLE is non-nil, no article is selected initially.
2597 If NO-DISPLAY, don't generate a summary buffer."
2598 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2599 (let* ((new-group (gnus-summary-setup-buffer group))
2600 (quit-config (gnus-group-quit-config group))
2601 (did-select (and new-group (gnus-select-newsgroup group show-all))))
2603 ;; This summary buffer exists already, so we just select it.
2605 (gnus-set-global-variables)
2607 (gnus-kill-or-deaden-summary kill-buffer))
2608 (gnus-configure-windows 'summary 'force)
2609 (gnus-set-mode-line 'summary)
2610 (gnus-summary-position-point)
2613 ;; We couldn't select this group.
2615 (when (and (eq major-mode 'gnus-summary-mode)
2616 (not (equal (current-buffer) kill-buffer)))
2617 (kill-buffer (current-buffer))
2618 (if (not quit-config)
2620 (set-buffer gnus-group-buffer)
2621 (gnus-group-jump-to-group group)
2622 (gnus-group-next-unread-group 1))
2623 (gnus-handle-ephemeral-exit quit-config)))
2624 (gnus-message 3 "Can't select group")
2626 ;; The user did a `C-g' while prompting for number of articles,
2627 ;; so we exit this group.
2628 ((eq did-select 'quit)
2629 (and (eq major-mode 'gnus-summary-mode)
2630 (not (equal (current-buffer) kill-buffer))
2631 (kill-buffer (current-buffer)))
2633 (gnus-kill-or-deaden-summary kill-buffer))
2634 (if (not quit-config)
2636 (set-buffer gnus-group-buffer)
2637 (gnus-group-jump-to-group group)
2638 (gnus-group-next-unread-group 1)
2639 (gnus-configure-windows 'group 'force))
2640 (gnus-handle-ephemeral-exit quit-config))
2641 ;; Finally signal the quit.
2643 ;; The group was successfully selected.
2645 (gnus-set-global-variables)
2646 ;; Save the active value in effect when the group was entered.
2647 (setq gnus-newsgroup-active
2649 (gnus-active gnus-newsgroup-name)))
2650 ;; You can change the summary buffer in some way with this hook.
2651 (run-hooks 'gnus-select-group-hook)
2652 ;; Set any local variables in the group parameters.
2653 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2654 (gnus-update-format-specifications
2655 nil 'summary 'summary-mode 'summary-dummy)
2656 ;; Do score processing.
2657 (when gnus-use-scoring
2658 (gnus-possibly-score-headers))
2659 ;; Check whether to fill in the gaps in the threads.
2660 (when gnus-build-sparse-threads
2661 (gnus-build-sparse-threads))
2662 ;; Find the initial limit.
2663 (if gnus-show-threads
2665 (let ((gnus-newsgroup-dormant nil))
2666 (gnus-summary-initial-limit show-all))
2667 (gnus-summary-initial-limit show-all))
2668 (setq gnus-newsgroup-limit
2670 (lambda (header) (mail-header-number header))
2671 gnus-newsgroup-headers)))
2672 ;; Generate the summary buffer.
2674 (gnus-summary-prepare))
2675 (when gnus-use-trees
2676 (gnus-tree-open group)
2677 (setq gnus-summary-highlight-line-function
2678 'gnus-tree-highlight-article))
2679 ;; If the summary buffer is empty, but there are some low-scored
2680 ;; articles or some excluded dormants, we include these in the
2682 (when (and (zerop (buffer-size))
2684 (cond (gnus-newsgroup-dormant
2685 (gnus-summary-limit-include-dormant))
2686 ((and gnus-newsgroup-scored show-all)
2687 (gnus-summary-limit-include-expunged t))))
2688 ;; Function `gnus-apply-kill-file' must be called in this hook.
2689 (run-hooks 'gnus-apply-kill-hook)
2690 (if (and (zerop (buffer-size))
2693 ;; This newsgroup is empty.
2694 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
2695 (gnus-message 6 "No unread news")
2697 (gnus-kill-or-deaden-summary kill-buffer))
2698 ;; Return nil from this function.
2700 ;; Hide conversation thread subtrees. We cannot do this in
2701 ;; gnus-summary-prepare-hook since kill processing may not
2702 ;; work with hidden articles.
2703 (and gnus-show-threads
2704 gnus-thread-hide-subtree
2705 (gnus-summary-hide-all-threads))
2706 ;; Show first unread article if requested.
2707 (if (and (not no-article)
2709 gnus-newsgroup-unreads
2710 gnus-auto-select-first)
2711 (unless (if (eq gnus-auto-select-first 'best)
2712 (gnus-summary-best-unread-article)
2713 (gnus-summary-first-unread-article))
2714 (gnus-configure-windows 'summary))
2715 ;; Don't select any articles, just move point to the first
2716 ;; article in the group.
2717 (goto-char (point-min))
2718 (gnus-summary-position-point)
2719 (gnus-set-mode-line 'summary)
2720 (gnus-configure-windows 'summary 'force))
2722 (gnus-kill-or-deaden-summary kill-buffer))
2723 (when (get-buffer-window gnus-group-buffer t)
2724 ;; Gotta use windows, because recenter does weird stuff if
2725 ;; the current buffer ain't the displayed window.
2726 (let ((owin (selected-window)))
2727 (select-window (get-buffer-window gnus-group-buffer t))
2728 (when (gnus-group-goto-group group)
2730 (select-window owin))))
2731 ;; Mark this buffer as "prepared".
2732 (setq gnus-newsgroup-prepared t)
2735 (defun gnus-summary-prepare ()
2736 "Generate the summary buffer."
2738 (let ((buffer-read-only nil))
2740 (setq gnus-newsgroup-data nil
2741 gnus-newsgroup-data-reverse nil)
2742 (run-hooks 'gnus-summary-generate-hook)
2743 ;; Generate the buffer, either with threads or without.
2744 (when gnus-newsgroup-headers
2745 (gnus-summary-prepare-threads
2746 (if gnus-show-threads
2747 (gnus-sort-gathered-threads
2748 (funcall gnus-summary-thread-gathering-function
2750 (gnus-cut-threads (gnus-make-threads)))))
2751 ;; Unthreaded display.
2752 (gnus-sort-articles gnus-newsgroup-headers))))
2753 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2754 ;; Call hooks for modifying summary buffer.
2755 (goto-char (point-min))
2756 (run-hooks 'gnus-summary-prepare-hook)))
2758 (defsubst gnus-general-simplify-subject (subject)
2759 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2762 ;; Truncate the subject.
2763 ((numberp gnus-summary-gather-subject-limit)
2764 (setq subject (gnus-simplify-subject-re subject))
2765 (if (> (length subject) gnus-summary-gather-subject-limit)
2766 (substring subject 0 gnus-summary-gather-subject-limit)
2768 ;; Fuzzily simplify it.
2769 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2770 (gnus-simplify-subject-fuzzy subject))
2771 ;; Just remove the leading "Re:".
2773 (gnus-simplify-subject-re subject))))
2775 (if (and gnus-summary-gather-exclude-subject
2776 (string-match gnus-summary-gather-exclude-subject subject))
2777 nil ; This article shouldn't be gathered
2780 (defun gnus-summary-simplify-subject-query ()
2781 "Query where the respool algorithm would put this article."
2783 (gnus-set-global-variables)
2784 (gnus-summary-select-article)
2785 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2787 (defun gnus-gather-threads-by-subject (threads)
2788 "Gather threads by looking at Subject headers."
2789 (if (not gnus-summary-make-false-root)
2791 (let ((hashtb (gnus-make-hashtable 1023))
2794 subject hthread whole-subject)
2796 (setq subject (gnus-general-simplify-subject
2797 (setq whole-subject (mail-header-subject
2800 (if (setq hthread (gnus-gethash subject hashtb))
2802 ;; We enter a dummy root into the thread, if we
2803 ;; haven't done that already.
2804 (unless (stringp (caar hthread))
2805 (setcar hthread (list whole-subject (car hthread))))
2806 ;; We add this new gathered thread to this gathered
2808 (setcdr (car hthread)
2809 (nconc (cdar hthread) (list (car threads))))
2810 ;; Remove it from the list of threads.
2811 (setcdr prev (cdr threads))
2812 (setq threads prev))
2813 ;; Enter this thread into the hash table.
2814 (gnus-sethash subject threads hashtb)))
2816 (setq threads (cdr threads)))
2819 (defun gnus-gather-threads-by-references (threads)
2820 "Gather threads by looking at References headers."
2821 (let ((idhashtb (gnus-make-hashtable 1023))
2822 (thhashtb (gnus-make-hashtable 1023))
2825 ids references id gthread gid entered ref)
2827 (when (setq references (mail-header-references (caar threads)))
2828 (setq id (mail-header-id (caar threads))
2829 ids (gnus-split-references references)
2831 (while (setq ref (pop ids))
2832 (setq ids (delete ref ids))
2833 (if (not (setq gid (gnus-gethash ref idhashtb)))
2835 (gnus-sethash ref id idhashtb)
2836 (gnus-sethash id threads thhashtb))
2837 (setq gthread (gnus-gethash gid thhashtb))
2839 ;; We enter a dummy root into the thread, if we
2840 ;; haven't done that already.
2841 (unless (stringp (caar gthread))
2842 (setcar gthread (list (mail-header-subject (caar gthread))
2844 ;; We add this new gathered thread to this gathered
2846 (setcdr (car gthread)
2847 (nconc (cdar gthread) (list (car threads)))))
2848 ;; Add it into the thread hash table.
2849 (gnus-sethash id gthread thhashtb)
2851 ;; Remove it from the list of threads.
2852 (setcdr prev (cdr threads))
2853 (setq threads prev))))
2855 (setq threads (cdr threads)))
2858 (defun gnus-sort-gathered-threads (threads)
2859 "Sort subtreads inside each gathered thread by article number."
2860 (let ((result threads))
2862 (when (stringp (caar threads))
2863 (setcdr (car threads)
2864 (sort (cdar threads) 'gnus-thread-sort-by-number)))
2865 (setq threads (cdr threads)))
2868 (defun gnus-thread-loop-p (root thread)
2869 "Say whether ROOT is in THREAD."
2870 (let ((th (cdr thread)))
2872 (not (eq (caar th) root)))
2875 ;; We have found a loop.
2877 (setcdr thread (delq (car th) (cdr thread)))
2878 (if (boundp (setq ref-dep (intern "none"
2879 gnus-newsgroup-dependencies)))
2880 (setcdr (symbol-value ref-dep)
2881 (nconc (cdr (symbol-value ref-dep))
2883 (set ref-dep (list nil (car th))))
2885 ;; Recurse down into the sub-threads and look for loops.
2888 (lambda (thread) (gnus-thread-loop-p root thread))
2891 (defun gnus-make-threads ()
2892 "Go through the dependency hashtb and find the roots. Return all threads."
2894 (while (catch 'infloop
2897 ;; Deal with self-referencing References loops.
2898 (when (and (car (symbol-value refs))
2905 (car (symbol-value refs)) thread))
2906 (cdr (symbol-value refs)))))))
2909 (unless (car (symbol-value refs))
2910 ;; These threads do not refer back to any other articles,
2911 ;; so they're roots.
2912 (setq threads (append (cdr (symbol-value refs)) threads))))
2913 gnus-newsgroup-dependencies)))
2916 (defun gnus-build-sparse-threads ()
2917 (let ((headers gnus-newsgroup-headers)
2918 (deps gnus-newsgroup-dependencies)
2919 header references generation relations
2920 cthread subject child end pthread relation)
2921 ;; First we create an alist of generations/relations, where
2922 ;; generations is how much we trust the relation, and the relation
2924 (gnus-message 7 "Making sparse threads...")
2926 (nnheader-set-temp-buffer " *gnus sparse threads*")
2927 (while (setq header (pop headers))
2928 (when (and (setq references (mail-header-references header))
2929 (not (string= references "")))
2931 (setq child (mail-header-id header)
2932 subject (mail-header-subject header))
2934 (while (search-backward ">" nil t)
2935 (setq end (1+ (point)))
2936 (when (search-backward "<" nil t)
2937 (push (list (incf generation)
2938 child (setq child (buffer-substring (point) end))
2941 (push (list (1+ generation) child nil subject) relations)
2943 (kill-buffer (current-buffer)))
2944 ;; Sort over trustworthiness.
2945 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
2946 (while (setq relation (pop relations))
2947 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
2948 (unless (car (symbol-value cthread))
2949 ;; Make this article the parent of these threads.
2950 (setcar (symbol-value cthread)
2951 (vector gnus-reffed-article-number
2955 (or (caddr relation) "") 0 0 "")))
2956 (set cthread (list (vector gnus-reffed-article-number
2958 "" "" (cadr relation)
2959 (or (caddr relation) "") 0 0 ""))))
2960 (push gnus-reffed-article-number gnus-newsgroup-limit)
2961 (push gnus-reffed-article-number gnus-newsgroup-sparse)
2962 (push (cons gnus-reffed-article-number gnus-sparse-mark)
2963 gnus-newsgroup-reads)
2964 (decf gnus-reffed-article-number)
2965 ;; Make this new thread the child of its parent.
2966 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
2967 (setcdr (symbol-value pthread)
2968 (nconc (cdr (symbol-value pthread))
2969 (list (symbol-value cthread))))
2970 (set pthread (list nil (symbol-value cthread))))))
2971 (gnus-message 7 "Making sparse threads...done")))
2973 (defun gnus-build-old-threads ()
2974 ;; Look at all the articles that refer back to old articles, and
2975 ;; fetch the headers for the articles that aren't there. This will
2976 ;; build complete threads - if the roots haven't been expired by the
2981 (when (not (car (symbol-value refs)))
2982 (setq heads (cdr (symbol-value refs)))
2984 (if (memq (mail-header-number (caar heads))
2985 gnus-newsgroup-dormant)
2986 (setq heads (cdr heads))
2987 (setq id (symbol-name refs))
2988 (while (and (setq id (gnus-build-get-header id))
2989 (not (car (gnus-gethash
2990 id gnus-newsgroup-dependencies)))))
2991 (setq heads nil)))))
2992 gnus-newsgroup-dependencies)))
2994 (defun gnus-build-get-header (id)
2995 ;; Look through the buffer of NOV lines and find the header to
2996 ;; ID. Enter this line into the dependencies hash table, and return
2997 ;; the id of the parent article (if any).
2998 (let ((deps gnus-newsgroup-dependencies)
3002 (set-buffer nntp-server-buffer)
3003 (goto-char (point-min))
3004 (while (and (not found) (search-forward id nil t))
3006 (setq found (looking-at
3007 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3008 (regexp-quote id))))
3009 (or found (beginning-of-line 2)))
3013 (setq header (gnus-nov-parse-line
3014 (read (current-buffer)) deps))
3015 (gnus-parent-id (mail-header-references header)))))
3017 (let ((number (mail-header-number header)))
3018 (push number gnus-newsgroup-limit)
3019 (push header gnus-newsgroup-headers)
3020 (if (memq number gnus-newsgroup-unselected)
3022 (push number gnus-newsgroup-unreads)
3023 (setq gnus-newsgroup-unselected
3024 (delq number gnus-newsgroup-unselected)))
3025 (push number gnus-newsgroup-ancient)))))))
3027 (defun gnus-summary-update-article-line (article header)
3028 "Update the line for ARTICLE using HEADERS."
3029 (let* ((id (mail-header-id header))
3030 (thread (gnus-id-to-thread id)))
3032 (error "Article in no thread"))
3033 ;; Update the thread.
3034 (setcar thread header)
3035 (gnus-summary-goto-subject article)
3036 (let* ((datal (gnus-data-find-list article))
3038 (length (when (cdr datal)
3039 (- (gnus-data-pos data)
3040 (gnus-data-pos (cadr datal)))))
3041 (buffer-read-only nil)
3042 (level (gnus-summary-thread-level)))
3044 (gnus-summary-insert-line
3045 header level nil (gnus-article-mark article)
3046 (memq article gnus-newsgroup-replied)
3047 (memq article gnus-newsgroup-expirable)
3048 (mail-header-subject header)
3049 nil (cdr (assq article gnus-newsgroup-scored))
3050 (memq article gnus-newsgroup-processable))
3052 (gnus-data-update-list
3053 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3055 (defun gnus-summary-update-article (article &optional iheader)
3056 "Update ARTICLE in the summary buffer."
3057 (set-buffer gnus-summary-buffer)
3058 (let* ((header (or iheader (gnus-summary-article-header article)))
3059 (id (mail-header-id header))
3060 (data (gnus-data-find article))
3061 (thread (gnus-id-to-thread id))
3062 (references (mail-header-references header))
3066 (when (and references
3067 (not (equal "" references)))
3070 (buffer-read-only nil)
3072 (number (mail-header-number header))
3075 ;; !!! Should this be in or not?
3077 (setcar thread nil))
3079 (delq thread parent))
3080 (if (gnus-summary-insert-subject id header iheader)
3081 ;; Set the (possibly) new article number in the data structure.
3082 (gnus-data-set-number data (gnus-id-to-article id))
3086 (defun gnus-rebuild-thread (id)
3087 "Rebuild the thread containing ID."
3088 (let ((buffer-read-only nil)
3089 old-pos current thread data)
3090 (if (not gnus-show-threads)
3091 (setq thread (list (car (gnus-id-to-thread id))))
3092 ;; Get the thread this article is part of.
3093 (setq thread (gnus-remove-thread id)))
3094 (setq old-pos (gnus-point-at-bol))
3095 (setq current (save-excursion
3096 (and (zerop (forward-line -1))
3097 (gnus-summary-article-number))))
3098 ;; If this is a gathered thread, we have to go some re-gathering.
3099 (when (stringp (car thread))
3100 (let ((subject (car thread))
3102 (setq thread (cdr thread))
3104 (unless (memq (setq thr (gnus-id-to-thread
3106 (mail-header-id (caar thread)))))
3109 (setq thread (cdr thread)))
3110 ;; We now have all (unique) roots.
3111 (if (= (length roots) 1)
3112 ;; All the loose roots are now one solid root.
3113 (setq thread (car roots))
3114 (setq thread (cons subject (gnus-sort-threads roots))))))
3116 ;; We then insert this thread into the summary buffer.
3117 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3118 (if gnus-show-threads
3119 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3120 (gnus-summary-prepare-unthreaded thread))
3121 (setq data (nreverse gnus-newsgroup-data))
3122 (setq threads gnus-newsgroup-threads))
3123 ;; We splice the new data into the data structure.
3124 (gnus-data-enter-list current data (- (point) old-pos))
3125 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
3127 (defun gnus-number-to-header (number)
3128 "Return the header for article NUMBER."
3129 (let ((headers gnus-newsgroup-headers))
3131 (not (= number (mail-header-number (car headers)))))
3136 (defun gnus-parent-headers (headers &optional generation)
3137 "Return the headers of the GENERATIONeth parent of HEADERS."
3139 (setq generation 1))
3140 (let (references parent)
3141 (while (and headers (not (zerop generation)))
3142 (setq references (mail-header-references headers))
3143 (when (and references
3144 (setq parent (gnus-parent-id references))
3145 (setq headers (car (gnus-id-to-thread parent))))
3149 (defun gnus-id-to-thread (id)
3150 "Return the (sub-)thread where ID appears."
3151 (gnus-gethash id gnus-newsgroup-dependencies))
3153 (defun gnus-id-to-article (id)
3154 "Return the article number of ID."
3155 (let ((thread (gnus-id-to-thread id)))
3158 (mail-header-number (car thread)))))
3160 (defun gnus-id-to-header (id)
3161 "Return the article headers of ID."
3162 (car (gnus-id-to-thread id)))
3164 (defun gnus-article-displayed-root-p (article)
3165 "Say whether ARTICLE is a root(ish) article."
3166 (let ((level (gnus-summary-thread-level article))
3167 (refs (mail-header-references (gnus-summary-article-header article)))
3173 ((null (gnus-parent-id refs)) t)
3175 (null (setq particle (gnus-id-to-article
3176 (gnus-parent-id refs))))
3177 (null (gnus-summary-thread-level particle)))))))
3179 (defun gnus-root-id (id)
3180 "Return the id of the root of the thread where ID appears."
3182 (while (and id (setq prev (car (gnus-gethash
3183 id gnus-newsgroup-dependencies))))
3185 id (gnus-parent-id (mail-header-references prev))))
3188 (defun gnus-remove-thread (id &optional dont-remove)
3189 "Remove the thread that has ID in it."
3190 (let ((dep gnus-newsgroup-dependencies)
3191 headers thread last-id)
3192 ;; First go up in this thread until we find the root.
3193 (setq last-id (gnus-root-id id))
3194 (setq headers (list (car (gnus-id-to-thread last-id))
3195 (caadr (gnus-id-to-thread last-id))))
3196 ;; We have now found the real root of this thread. It might have
3197 ;; been gathered into some loose thread, so we have to search
3198 ;; through the threads to find the thread we wanted.
3199 (let ((threads gnus-newsgroup-threads)
3202 (setq sub (car threads))
3203 (if (stringp (car sub))
3204 ;; This is a gathered thread, so we look at the roots
3205 ;; below it to find whether this article is in this
3208 (setq sub (cdr sub))
3210 (when (member (caar sub) headers)
3211 (setq thread (car threads)
3214 (setq sub (cdr sub))))
3215 ;; It's an ordinary thread, so we check it.
3216 (when (eq (car sub) (car headers))
3219 (setq threads (cdr threads)))
3220 ;; If this article is in no thread, then it's a root.
3223 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3224 (setq thread (gnus-gethash last-id dep)))
3227 thread ; We return this thread.
3229 (if (stringp (car thread))
3231 ;; If we use dummy roots, then we have to remove the
3232 ;; dummy root as well.
3233 (when (eq gnus-summary-make-false-root 'dummy)
3236 (setq thread (cdr thread))
3238 (gnus-remove-thread-1 (car thread))
3239 (setq thread (cdr thread))))
3240 (gnus-remove-thread-1 thread))))))))
3242 (defun gnus-remove-thread-1 (thread)
3243 "Remove the thread THREAD recursively."
3244 (let ((number (mail-header-number (pop thread)))
3246 (setq thread (reverse thread))
3248 (gnus-remove-thread-1 (pop thread)))
3249 (when (setq d (gnus-data-find number))
3250 (goto-char (gnus-data-pos d))
3253 (- (gnus-point-at-bol)
3255 (1+ (gnus-point-at-eol))
3256 (gnus-delete-line)))))))
3258 (defun gnus-sort-threads (threads)
3260 (if (not gnus-thread-sort-functions)
3262 (gnus-message 7 "Sorting threads...")
3264 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3265 (gnus-message 7 "Sorting threads...done"))))
3267 (defun gnus-sort-articles (articles)
3269 (when gnus-article-sort-functions
3270 (gnus-message 7 "Sorting articles...")
3272 (setq gnus-newsgroup-headers
3273 (sort articles (gnus-make-sort-function
3274 gnus-article-sort-functions)))
3275 (gnus-message 7 "Sorting articles...done"))))
3277 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3278 (defmacro gnus-thread-header (thread)
3279 ;; Return header of first article in THREAD.
3280 ;; Note that THREAD must never, ever be anything else than a variable -
3281 ;; using some other form will lead to serious barfage.
3282 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3283 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3284 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
3287 (defsubst gnus-article-sort-by-number (h1 h2)
3288 "Sort articles by article number."
3289 (< (mail-header-number h1)
3290 (mail-header-number h2)))
3292 (defun gnus-thread-sort-by-number (h1 h2)
3293 "Sort threads by root article number."
3294 (gnus-article-sort-by-number
3295 (gnus-thread-header h1) (gnus-thread-header h2)))
3297 (defsubst gnus-article-sort-by-lines (h1 h2)
3298 "Sort articles by article Lines header."
3299 (< (mail-header-lines h1)
3300 (mail-header-lines h2)))
3302 (defun gnus-thread-sort-by-lines (h1 h2)
3303 "Sort threads by root article Lines header."
3304 (gnus-article-sort-by-lines
3305 (gnus-thread-header h1) (gnus-thread-header h2)))
3307 (defsubst gnus-article-sort-by-author (h1 h2)
3308 "Sort articles by root author."
3310 (let ((extract (funcall
3311 gnus-extract-address-components
3312 (mail-header-from h1))))
3313 (or (car extract) (cdr extract)))
3314 (let ((extract (funcall
3315 gnus-extract-address-components
3316 (mail-header-from h2))))
3317 (or (car extract) (cdr extract)))))
3319 (defun gnus-thread-sort-by-author (h1 h2)
3320 "Sort threads by root author."
3321 (gnus-article-sort-by-author
3322 (gnus-thread-header h1) (gnus-thread-header h2)))
3324 (defsubst gnus-article-sort-by-subject (h1 h2)
3325 "Sort articles by root subject."
3327 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3328 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3330 (defun gnus-thread-sort-by-subject (h1 h2)
3331 "Sort threads by root subject."
3332 (gnus-article-sort-by-subject
3333 (gnus-thread-header h1) (gnus-thread-header h2)))
3335 (defsubst gnus-article-sort-by-date (h1 h2)
3336 "Sort articles by root article date."
3338 (gnus-date-get-time (mail-header-date h1))
3339 (gnus-date-get-time (mail-header-date h2))))
3341 (defun gnus-thread-sort-by-date (h1 h2)
3342 "Sort threads by root article date."
3343 (gnus-article-sort-by-date
3344 (gnus-thread-header h1) (gnus-thread-header h2)))
3346 (defsubst gnus-article-sort-by-score (h1 h2)
3347 "Sort articles by root article score.
3348 Unscored articles will be counted as having a score of zero."
3349 (> (or (cdr (assq (mail-header-number h1)
3350 gnus-newsgroup-scored))
3351 gnus-summary-default-score 0)
3352 (or (cdr (assq (mail-header-number h2)
3353 gnus-newsgroup-scored))
3354 gnus-summary-default-score 0)))
3356 (defun gnus-thread-sort-by-score (h1 h2)
3357 "Sort threads by root article score."
3358 (gnus-article-sort-by-score
3359 (gnus-thread-header h1) (gnus-thread-header h2)))
3361 (defun gnus-thread-sort-by-total-score (h1 h2)
3362 "Sort threads by the sum of all scores in the thread.
3363 Unscored articles will be counted as having a score of zero."
3364 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3366 (defun gnus-thread-total-score (thread)
3367 ;; This function find the total score of THREAD.
3368 (cond ((null thread)
3371 (if (stringp (car thread))
3372 (apply gnus-thread-score-function 0
3373 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3374 (gnus-thread-total-score-1 thread)))
3376 (gnus-thread-total-score-1 (list thread)))))
3378 (defun gnus-thread-total-score-1 (root)
3379 ;; This function find the total score of the thread below ROOT.
3380 (setq root (car root))
3381 (apply gnus-thread-score-function
3383 (mapcar 'gnus-thread-total-score
3384 (cdr (gnus-gethash (mail-header-id root)
3385 gnus-newsgroup-dependencies)))
3386 (when (> (mail-header-number root) 0)
3387 (list (or (cdr (assq (mail-header-number root)
3388 gnus-newsgroup-scored))
3389 gnus-summary-default-score 0))))
3390 (list gnus-summary-default-score)
3393 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3394 (defvar gnus-tmp-prev-subject nil)
3395 (defvar gnus-tmp-false-parent nil)
3396 (defvar gnus-tmp-root-expunged nil)
3397 (defvar gnus-tmp-dummy-line nil)
3399 (defun gnus-summary-prepare-threads (threads)
3400 "Prepare summary buffer from THREADS and indentation LEVEL.
3401 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3402 or a straight list of headers."
3403 (gnus-message 7 "Generating summary...")
3405 (setq gnus-newsgroup-threads threads)
3408 (let ((gnus-tmp-level 0)
3409 (default-score (or gnus-summary-default-score 0))
3410 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3411 thread number subject stack state gnus-tmp-gathered beg-match
3412 new-roots gnus-tmp-new-adopts thread-end
3413 gnus-tmp-header gnus-tmp-unread
3414 gnus-tmp-replied gnus-tmp-subject-or-nil
3415 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3416 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3417 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3419 (setq gnus-tmp-prev-subject nil)
3421 (if (vectorp (car threads))
3422 ;; If this is a straight (sic) list of headers, then a
3423 ;; threaded summary display isn't required, so we just create
3424 ;; an unthreaded one.
3425 (gnus-summary-prepare-unthreaded threads)
3427 ;; Do the threaded display.
3429 (while (or threads stack gnus-tmp-new-adopts new-roots)
3431 (if (and (= gnus-tmp-level 0)
3432 (not (setq gnus-tmp-dummy-line nil))
3435 (not gnus-tmp-false-parent)
3436 (or gnus-tmp-new-adopts new-roots))
3437 (if gnus-tmp-new-adopts
3438 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3439 thread (list (car gnus-tmp-new-adopts))
3440 gnus-tmp-header (caar thread)
3441 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3443 (setq thread (list (car new-roots))
3444 gnus-tmp-header (caar thread)
3445 new-roots (cdr new-roots))))
3448 ;; If there are some threads, we do them before the
3449 ;; threads on the stack.
3450 (setq thread threads
3451 gnus-tmp-header (caar thread))
3452 ;; There were no current threads, so we pop something off
3454 (setq state (car stack)
3455 gnus-tmp-level (car state)
3458 gnus-tmp-header (caar thread))))
3460 (setq gnus-tmp-false-parent nil)
3461 (setq gnus-tmp-root-expunged nil)
3462 (setq thread-end nil)
3464 (if (stringp gnus-tmp-header)
3465 ;; The header is a dummy root.
3467 ((eq gnus-summary-make-false-root 'adopt)
3468 ;; We let the first article adopt the rest.
3469 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3471 (setq gnus-tmp-gathered
3473 (lambda (h) (mail-header-number (car h)))
3476 (setq thread (cons (list (caar thread)
3479 (setq gnus-tmp-level -1
3480 gnus-tmp-false-parent t))
3481 ((eq gnus-summary-make-false-root 'empty)
3482 ;; We print adopted articles with empty subject fields.
3483 (setq gnus-tmp-gathered
3485 (lambda (h) (mail-header-number (car h)))
3488 (setq gnus-tmp-level -1))
3489 ((eq gnus-summary-make-false-root 'dummy)
3490 ;; We remember that we probably want to output a dummy
3492 (setq gnus-tmp-dummy-line gnus-tmp-header)
3493 (setq gnus-tmp-prev-subject gnus-tmp-header))
3495 ;; We do not make a root for the gathered
3496 ;; sub-threads at all.
3497 (setq gnus-tmp-level -1)))
3499 (setq number (mail-header-number gnus-tmp-header)
3500 subject (mail-header-subject gnus-tmp-header))
3503 ;; If the thread has changed subject, we might want to make
3504 ;; this subthread into a root.
3505 ((and (null gnus-thread-ignore-subject)
3506 (not (zerop gnus-tmp-level))
3507 gnus-tmp-prev-subject
3509 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3510 (setq new-roots (nconc new-roots (list (car thread)))
3512 gnus-tmp-header nil))
3513 ;; If the article lies outside the current limit,
3514 ;; then we do not display it.
3515 ((and (not (memq number gnus-newsgroup-limit))
3516 (not gnus-tmp-dummy-line))
3517 (setq gnus-tmp-gathered
3519 (lambda (h) (mail-header-number (car h)))
3522 (setq gnus-tmp-new-adopts (if (cdar thread)
3523 (append gnus-tmp-new-adopts
3525 gnus-tmp-new-adopts)
3527 gnus-tmp-header nil)
3528 (when (zerop gnus-tmp-level)
3529 (setq gnus-tmp-root-expunged t)))
3530 ;; Perhaps this article is to be marked as read?
3531 ((and gnus-summary-mark-below
3532 (< (or (cdr (assq number gnus-newsgroup-scored))
3534 gnus-summary-mark-below)
3535 ;; Don't touch sparse articles.
3536 (not (gnus-summary-article-sparse-p number))
3537 (not (gnus-summary-article-ancient-p number)))
3538 (setq gnus-newsgroup-unreads
3539 (delq number gnus-newsgroup-unreads))
3540 (if gnus-newsgroup-auto-expire
3541 (push number gnus-newsgroup-expirable)
3542 (push (cons number gnus-low-score-mark)
3543 gnus-newsgroup-reads))))
3545 (when gnus-tmp-header
3546 ;; We may have an old dummy line to output before this
3548 (when gnus-tmp-dummy-line
3549 (gnus-summary-insert-dummy-line
3550 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3551 (setq gnus-tmp-dummy-line nil))
3553 ;; Compute the mark.
3554 (setq gnus-tmp-unread (gnus-article-mark number))
3556 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3557 gnus-tmp-header gnus-tmp-level)
3558 gnus-newsgroup-data)
3560 ;; Actually insert the line.
3562 gnus-tmp-subject-or-nil
3564 ((and gnus-thread-ignore-subject
3565 gnus-tmp-prev-subject
3566 (not (inline (gnus-subject-equal
3567 gnus-tmp-prev-subject subject))))
3569 ((zerop gnus-tmp-level)
3570 (if (and (eq gnus-summary-make-false-root 'empty)
3571 (memq number gnus-tmp-gathered)
3572 gnus-tmp-prev-subject
3573 (inline (gnus-subject-equal
3574 gnus-tmp-prev-subject subject)))
3575 gnus-summary-same-subject
3577 (t gnus-summary-same-subject)))
3578 (if (and (eq gnus-summary-make-false-root 'adopt)
3579 (= gnus-tmp-level 1)
3580 (memq number gnus-tmp-gathered))
3581 (setq gnus-tmp-opening-bracket ?\<
3582 gnus-tmp-closing-bracket ?\>)
3583 (setq gnus-tmp-opening-bracket ?\[
3584 gnus-tmp-closing-bracket ?\]))
3586 gnus-tmp-indentation
3587 (aref gnus-thread-indent-array gnus-tmp-level)
3588 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3589 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3590 gnus-summary-default-score 0)
3592 (if (or (null gnus-summary-default-score)
3593 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3594 gnus-summary-zcore-fuzz))
3596 (if (< gnus-tmp-score gnus-summary-default-score)
3597 gnus-score-below-mark gnus-score-over-mark))
3599 (cond ((memq number gnus-newsgroup-processable)
3601 ((memq number gnus-newsgroup-cached)
3603 ((memq number gnus-newsgroup-replied)
3605 ((memq number gnus-newsgroup-saved)
3607 (t gnus-unread-mark))
3608 gnus-tmp-from (mail-header-from gnus-tmp-header)
3611 ((string-match "<[^>]+> *$" gnus-tmp-from)
3612 (setq beg-match (match-beginning 0))
3613 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3614 (substring gnus-tmp-from (1+ (match-beginning 0))
3615 (1- (match-end 0))))
3616 (substring gnus-tmp-from 0 beg-match)))
3617 ((string-match "(.+)" gnus-tmp-from)
3618 (substring gnus-tmp-from
3619 (1+ (match-beginning 0)) (1- (match-end 0))))
3621 (when (string= gnus-tmp-name "")
3622 (setq gnus-tmp-name gnus-tmp-from))
3623 (unless (numberp gnus-tmp-lines)
3624 (setq gnus-tmp-lines 0))
3625 (gnus-put-text-property
3627 (progn (eval gnus-summary-line-format-spec) (point))
3628 'gnus-number number)
3631 (run-hooks 'gnus-summary-update-hook)
3634 (setq gnus-tmp-prev-subject subject)))
3636 (when (nth 1 thread)
3637 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3638 (incf gnus-tmp-level)
3639 (setq threads (if thread-end nil (cdar thread)))
3641 (setq gnus-tmp-level 0)))))
3642 (gnus-message 7 "Generating summary...done"))
3644 (defun gnus-summary-prepare-unthreaded (headers)
3645 "Generate an unthreaded summary buffer based on HEADERS."
3646 (let (header number mark)
3649 ;; We may have to root out some bad articles...
3650 (when (memq (setq number (mail-header-number
3651 (setq header (pop headers))))
3652 gnus-newsgroup-limit)
3653 ;; Mark article as read when it has a low score.
3654 (when (and gnus-summary-mark-below
3655 (< (or (cdr (assq number gnus-newsgroup-scored))
3656 gnus-summary-default-score 0)
3657 gnus-summary-mark-below)
3658 (not (gnus-summary-article-ancient-p number)))
3659 (setq gnus-newsgroup-unreads
3660 (delq number gnus-newsgroup-unreads))
3661 (if gnus-newsgroup-auto-expire
3662 (push number gnus-newsgroup-expirable)
3663 (push (cons number gnus-low-score-mark)
3664 gnus-newsgroup-reads)))
3666 (setq mark (gnus-article-mark number))
3667 (push (gnus-data-make number mark (1+ (point)) header 0)
3668 gnus-newsgroup-data)
3669 (gnus-summary-insert-line
3671 mark (memq number gnus-newsgroup-replied)
3672 (memq number gnus-newsgroup-expirable)
3673 (mail-header-subject header) nil
3674 (cdr (assq number gnus-newsgroup-scored))
3675 (memq number gnus-newsgroup-processable))))))
3677 (defun gnus-select-newsgroup (group &optional read-all)
3678 "Select newsgroup GROUP.
3679 If READ-ALL is non-nil, all articles in the group are selected."
3680 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3681 (info (nth 2 entry))
3682 articles fetched-articles cached)
3684 (unless (gnus-check-server
3685 (setq gnus-current-select-method (gnus-find-method-for-group group)))
3686 (error "Couldn't open server"))
3688 (or (and entry (not (eq (car entry) t))) ; Either it's active...
3689 (gnus-activate-group group) ; Or we can activate it...
3690 (progn ; Or we bug out.
3691 (when (equal major-mode 'gnus-summary-mode)
3692 (kill-buffer (current-buffer)))
3693 (error "Couldn't request group %s: %s"
3694 group (gnus-status-message group))))
3696 (unless (gnus-request-group group t)
3697 (when (equal major-mode 'gnus-summary-mode)
3698 (kill-buffer (current-buffer)))
3699 (error "Couldn't request group %s: %s"
3700 group (gnus-status-message group)))
3702 (setq gnus-newsgroup-name group)
3703 (setq gnus-newsgroup-unselected nil)
3704 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
3706 ;; Adjust and set lists of article marks.
3708 (gnus-adjust-marked-articles info))
3710 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3711 (when (gnus-virtual-group-p group)
3712 (setq cached gnus-newsgroup-cached))
3714 (setq gnus-newsgroup-unreads
3715 (gnus-set-difference
3716 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
3717 gnus-newsgroup-dormant))
3719 (setq gnus-newsgroup-processable nil)
3721 (setq articles (gnus-articles-to-read group read-all))
3725 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
3727 ((eq articles 0) nil)
3729 ;; Init the dependencies hash table.
3730 (setq gnus-newsgroup-dependencies
3731 (gnus-make-hashtable (length articles)))
3732 ;; Retrieve the headers and read them in.
3733 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
3734 (setq gnus-newsgroup-headers
3736 (setq gnus-headers-retrieved-by
3737 (gnus-retrieve-headers
3738 articles gnus-newsgroup-name
3739 ;; We might want to fetch old headers, but
3740 ;; not if there is only 1 article.
3741 (and gnus-fetch-old-headers
3743 (not (eq gnus-fetch-old-headers 'some))
3744 (not (numberp gnus-fetch-old-headers)))
3745 (> (length articles) 1))))))
3746 (gnus-get-newsgroup-headers-xover articles)
3747 (gnus-get-newsgroup-headers)))
3748 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
3750 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3752 (setq gnus-newsgroup-cached cached))
3754 ;; Suppress duplicates?
3755 (when gnus-suppress-duplicates
3756 (gnus-dup-suppress-articles))
3758 ;; Set the initial limit.
3759 (setq gnus-newsgroup-limit (copy-sequence articles))
3760 ;; Remove canceled articles from the list of unread articles.
3761 (setq gnus-newsgroup-unreads
3762 (gnus-set-sorted-intersection
3763 gnus-newsgroup-unreads
3764 (setq fetched-articles
3765 (mapcar (lambda (headers) (mail-header-number headers))
3766 gnus-newsgroup-headers))))
3767 ;; Removed marked articles that do not exist.
3768 (gnus-update-missing-marks
3769 (gnus-sorted-complement fetched-articles articles))
3770 ;; We might want to build some more threads first.
3771 (and gnus-fetch-old-headers
3772 (eq gnus-headers-retrieved-by 'nov)
3773 (gnus-build-old-threads))
3774 ;; Check whether auto-expire is to be done in this group.
3775 (setq gnus-newsgroup-auto-expire
3776 (gnus-group-auto-expirable-p group))
3777 ;; Set up the article buffer now, if necessary.
3778 (unless gnus-single-article-buffer
3779 (gnus-article-setup-buffer))
3780 ;; First and last article in this newsgroup.
3781 (when gnus-newsgroup-headers
3782 (setq gnus-newsgroup-begin
3783 (mail-header-number (car gnus-newsgroup-headers))
3786 (gnus-last-element gnus-newsgroup-headers))))
3787 ;; GROUP is successfully selected.
3788 (or gnus-newsgroup-headers t)))))
3790 (defun gnus-articles-to-read (group &optional read-all)
3791 ;; Find out what articles the user wants to read.
3793 ;; Select all articles if `read-all' is non-nil, or if there
3794 ;; are no unread articles.
3796 (and (zerop (length gnus-newsgroup-marked))
3797 (zerop (length gnus-newsgroup-unreads)))
3798 (eq (gnus-group-find-parameter group 'display)
3800 (gnus-uncompress-range (gnus-active group))
3801 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
3802 (copy-sequence gnus-newsgroup-unreads))
3804 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
3805 (scored (length scored-list))
3806 (number (length articles))
3807 (marked (+ (length gnus-newsgroup-marked)
3808 (length gnus-newsgroup-dormant)))
3816 ((and (or (<= scored marked) (= scored number))
3817 (numberp gnus-large-newsgroup)
3818 (> number gnus-large-newsgroup))
3822 "How many articles from %s (default %d): "
3823 gnus-newsgroup-name number))))
3824 (if (string-match "^[ \t]*$" input) number input)))
3825 ((and (> scored marked) (< scored number)
3826 (> (- scored number) 20))
3829 (format "%s %s (%d scored, %d total): "
3830 "How many articles from"
3831 group scored number))))
3832 (if (string-match "^[ \t]*$" input)
3836 (setq select (if (stringp select) (string-to-number select) select))
3837 (if (or (null select) (zerop select))
3839 (if (and (not (zerop scored)) (<= (abs select) scored))
3841 (setq articles (sort scored-list '<))
3842 (setq number (length articles)))
3843 (setq articles (copy-sequence articles)))
3845 (when (< (abs select) number)
3847 ;; Select the N oldest articles.
3848 (setcdr (nthcdr (1- (abs select)) articles) nil)
3849 ;; Select the N most recent articles.
3850 (setq articles (nthcdr (- number select) articles))))
3851 (setq gnus-newsgroup-unselected
3852 (gnus-sorted-intersection
3853 gnus-newsgroup-unreads
3854 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
3857 (defun gnus-killed-articles (killed articles)
3860 (when (inline (gnus-member-of-range (car articles) killed))
3861 (push (car articles) out))
3862 (setq articles (cdr articles)))
3865 (defun gnus-uncompress-marks (marks)
3866 "Uncompress the mark ranges in MARKS."
3867 (let ((uncompressed '(score bookmark))
3870 (if (memq (caar marks) uncompressed)
3871 (push (car marks) out)
3872 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
3873 (setq marks (cdr marks)))
3876 (defun gnus-adjust-marked-articles (info)
3877 "Set all article lists and remove all marks that are no longer legal."
3878 (let* ((marked-lists (gnus-info-marks info))
3879 (active (gnus-active (gnus-info-group info)))
3882 (types gnus-article-mark-lists)
3883 (uncompressed '(score bookmark killed))
3884 marks var articles article mark)
3887 (setq marks (pop marked-lists))
3888 (set (setq var (intern (format "gnus-newsgroup-%s"
3889 (car (rassq (setq mark (car marks))
3891 (if (memq (car marks) uncompressed) (cdr marks)
3892 (gnus-uncompress-range (cdr marks))))
3894 (setq articles (symbol-value var))
3896 ;; All articles have to be subsets of the active articles.
3898 ;; Adjust "simple" lists.
3899 ((memq mark '(tick dormant expirable reply save))
3901 (when (or (< (setq article (pop articles)) min) (> article max))
3902 (set var (delq article (symbol-value var))))))
3904 ((memq mark uncompressed)
3906 (when (or (not (consp (setq article (pop articles))))
3907 (< (car article) min)
3908 (> (car article) max))
3909 (set var (delq article (symbol-value var))))))))))
3911 (defun gnus-update-missing-marks (missing)
3912 "Go through the list of MISSING articles and remove them mark lists."
3914 (let ((types gnus-article-mark-lists)
3916 ;; Go through all types.
3918 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
3919 (when (symbol-value var)
3920 ;; This list has articles. So we delete all missing articles
3924 (set var (delq (pop m) (symbol-value var)))))))))
3926 (defun gnus-update-marks ()
3927 "Enter the various lists of marked articles into the newsgroup info list."
3928 (let ((types gnus-article-mark-lists)
3929 (info (gnus-get-info gnus-newsgroup-name))
3930 (uncompressed '(score bookmark killed))
3931 type list newmarked symbol)
3933 ;; Add all marks lists that are non-nil to the list of marks lists.
3935 (setq type (pop types))
3936 (when (setq list (symbol-value
3938 (intern (format "gnus-newsgroup-%s"
3940 (push (cons (cdr type)
3941 (if (memq (cdr type) uncompressed) list
3942 (gnus-compress-sequence
3943 (set symbol (sort list '<)) t)))
3946 ;; Enter these new marks into the info of the group.
3948 (setcar (nthcdr 3 info) newmarked)
3949 ;; Add the marks lists to the end of the info.
3951 (setcdr (nthcdr 2 info) (list newmarked))))
3953 ;; Cut off the end of the info if there's nothing else there.
3957 (when (nthcdr (decf i) info)
3958 (setcdr (nthcdr i info) nil)))))))
3960 (defun gnus-set-mode-line (where)
3961 "This function sets the mode line of the article or summary buffers.
3962 If WHERE is `summary', the summary mode line format will be used."
3963 ;; Is this mode line one we keep updated?
3964 (when (memq where gnus-updated-mode-lines)
3967 ;; We evaluate this in the summary buffer since these
3968 ;; variables are buffer-local to that buffer.
3969 (set-buffer gnus-summary-buffer)
3970 ;; We bind all these variables that are used in the `eval' form
3972 (let* ((mformat (symbol-value
3974 (format "gnus-%s-mode-line-format-spec" where))))
3975 (gnus-tmp-group-name gnus-newsgroup-name)
3976 (gnus-tmp-article-number (or gnus-current-article 0))
3977 (gnus-tmp-unread gnus-newsgroup-unreads)
3978 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
3979 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
3980 (gnus-tmp-unread-and-unselected
3981 (cond ((and (zerop gnus-tmp-unread-and-unticked)
3982 (zerop gnus-tmp-unselected))
3984 ((zerop gnus-tmp-unselected)
3985 (format "{%d more}" gnus-tmp-unread-and-unticked))
3986 (t (format "{%d(+%d) more}"
3987 gnus-tmp-unread-and-unticked
3988 gnus-tmp-unselected))))
3990 (if (and gnus-current-headers
3991 (vectorp gnus-current-headers))
3992 (gnus-mode-string-quote
3993 (mail-header-subject gnus-current-headers))
3996 gnus-tmp-header);; passed as argument to any user-format-funcs
3997 (setq mode-string (eval mformat))
3998 (setq max-len (max 4 (if gnus-mode-non-string-length
4000 gnus-mode-non-string-length)
4001 (length mode-string))))
4002 ;; We might have to chop a bit of the string off...
4003 (when (> (length mode-string) max-len)
4005 (concat (gnus-truncate-string mode-string (- max-len 3))
4007 ;; Pad the mode string a bit.
4008 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4009 ;; Update the mode line.
4010 (setq mode-line-buffer-identification
4011 (gnus-mode-line-buffer-identification
4012 (list mode-string)))
4013 (set-buffer-modified-p t))))
4015 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4016 "Go through the HEADERS list and add all Xrefs to a hash table.
4017 The resulting hash table is returned, or nil if no Xrefs were found."
4018 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4019 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4020 (xref-hashtb (make-vector 63 0))
4021 start group entry number xrefs header)
4023 (setq header (pop headers))
4024 (when (and (setq xrefs (mail-header-xref header))
4025 (not (memq (setq number (mail-header-number header))
4028 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4029 (setq start (match-end 0))
4030 (setq group (if prefix
4031 (concat prefix (substring xrefs (match-beginning 1)
4033 (substring xrefs (match-beginning 1) (match-end 1))))
4035 (string-to-int (substring xrefs (match-beginning 2)
4037 (if (setq entry (gnus-gethash group xref-hashtb))
4038 (setcdr entry (cons number (cdr entry)))
4039 (gnus-sethash group (cons number nil) xref-hashtb)))))
4040 (and start xref-hashtb)))
4042 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4043 "Look through all the headers and mark the Xrefs as read."
4044 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4045 name entry info xref-hashtb idlist method nth4)
4047 (set-buffer gnus-group-buffer)
4048 (when (setq xref-hashtb
4049 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4052 (unless (string= from-newsgroup (setq name (symbol-name group)))
4053 (setq idlist (symbol-value group))
4054 ;; Dead groups are not updated.
4056 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4058 (when (stringp (setq nth4 (gnus-info-method info)))
4059 (setq nth4 (gnus-server-to-method nth4))))
4060 ;; Only do the xrefs if the group has the same
4061 ;; select method as the group we have just read.
4062 (or (gnus-methods-equal-p
4063 nth4 (gnus-find-method-for-group from-newsgroup))
4065 (equal nth4 (setq method (gnus-find-method-for-group
4067 (and (equal (car nth4) (car method))
4068 (equal (nth 1 nth4) (nth 1 method))))
4069 gnus-use-cross-reference
4070 (or (not (eq gnus-use-cross-reference t))
4072 ;; Only do cross-references on subscribed
4073 ;; groups, if that is what is wanted.
4074 (<= (gnus-info-level info) gnus-level-subscribed))
4075 (gnus-group-make-articles-read name idlist))))
4078 (defun gnus-group-make-articles-read (group articles)
4079 "Update the info of GROUP to say that only ARTICLES are unread."
4081 (entry (gnus-gethash group gnus-newsrc-hashtb))
4082 (info (nth 2 entry))
4083 (active (gnus-active group))
4085 ;; First peel off all illegal article numbers.
4087 (let ((ids articles)
4089 (while (setq id (pop ids))
4090 (when (and first (> id (cdr active)))
4091 ;; We'll end up in this situation in one particular
4092 ;; obscure situation. If you re-scan a group and get
4093 ;; a new article that is cross-posted to a different
4094 ;; group that has not been re-scanned, you might get
4095 ;; crossposted article that has a higher number than
4096 ;; Gnus believes possible. So we re-activate this
4097 ;; group as well. This might mean doing the
4098 ;; crossposting thingy will *increase* the number
4099 ;; of articles in some groups. Tsk, tsk.
4100 (setq active (or (gnus-activate-group group) active)))
4101 (when (or (> id (cdr active))
4102 (< id (car active)))
4103 (setq articles (delq id articles))))))
4105 (set-buffer gnus-group-buffer)
4108 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4109 (gnus-info-set-read ',info ',(gnus-info-read info))
4110 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4111 (gnus-group-update-group ,group t))))
4112 ;; If the read list is nil, we init it.
4114 (null (gnus-info-read info))
4116 (gnus-info-set-read info (cons 1 (1- (car active)))))
4117 ;; Then we add the read articles to the range.
4122 (gnus-info-read info) (setq articles (sort articles '<)))))
4123 ;; Then we have to re-compute how many unread
4124 ;; articles there are in this group.
4128 (setq num (- (1+ (cdr active)) (car active))))
4129 ((not (listp (cdr range)))
4130 (setq num (- (cdr active) (- (1+ (cdr range))
4134 (if (numberp (car range))
4136 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4137 (setq range (cdr range)))
4138 (setq num (- (cdr active) num))))
4139 ;; Update the number of unread articles.
4141 ;; Update the group buffer.
4142 (gnus-group-update-group group t))))
4144 (defun gnus-methods-equal-p (m1 m2)
4145 (let ((m1 (or m1 gnus-select-method))
4146 (m2 (or m2 gnus-select-method)))
4148 (and (eq (car m1) (car m2))
4149 (or (not (memq 'address (assoc (symbol-name (car m1))
4150 gnus-valid-select-methods)))
4151 (equal (nth 1 m1) (nth 1 m2)))))))
4153 (defvar gnus-newsgroup-none-id 0)
4155 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4156 (let ((cur nntp-server-buffer)
4159 (save-excursion (set-buffer gnus-summary-buffer)
4160 gnus-newsgroup-dependencies)))
4161 headers id id-dep ref-dep end ref)
4163 (set-buffer nntp-server-buffer)
4164 ;; Translate all TAB characters into SPACE characters.
4165 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4166 (run-hooks 'gnus-parse-headers-hook)
4167 (let ((case-fold-search t)
4168 in-reply-to header p lines)
4169 (goto-char (point-min))
4170 ;; Search to the beginning of the next header. Error messages
4171 ;; do not begin with 2 or 3.
4172 (while (re-search-forward "^[23][0-9]+ " nil t)
4175 ;; This implementation of this function, with nine
4176 ;; search-forwards instead of the one re-search-forward and
4177 ;; a case (which basically was the old function) is actually
4178 ;; about twice as fast, even though it looks messier. You
4179 ;; can't have everything, I guess. Speed and elegance
4180 ;; doesn't always go hand in hand.
4189 (narrow-to-region (point)
4190 (or (and (search-forward "\n.\n" nil t)
4196 (if (search-forward "\nsubject: " nil t)
4197 (nnheader-header-value) "(none)"))
4201 (if (search-forward "\nfrom: " nil t)
4202 (nnheader-header-value) "(nobody)"))
4206 (if (search-forward "\ndate: " nil t)
4207 (nnheader-header-value) ""))
4211 (setq id (if (search-forward "\nmessage-id: " nil t)
4212 (nnheader-header-value)
4213 ;; If there was no message-id, we just fake one
4214 ;; to make subsequent routines simpler.
4215 (nnheader-generate-fake-message-id))))
4219 (if (search-forward "\nreferences: " nil t)
4223 (nnheader-header-value)
4228 (search-backward ">" end t)
4231 (search-backward "<" end t)
4233 ;; Get the references from the in-reply-to header if there
4234 ;; were no references and the in-reply-to header looks
4236 (if (and (search-forward "\nin-reply-to: " nil t)
4237 (setq in-reply-to (nnheader-header-value))
4238 (string-match "<[^>]+>" in-reply-to))
4239 (setq ref (substring in-reply-to (match-beginning 0)
4247 (if (search-forward "\nlines: " nil t)
4248 (if (numberp (setq lines (read cur)))
4254 (and (search-forward "\nxref: " nil t)
4255 (nnheader-header-value)))))
4256 (when (equal id ref)
4258 ;; We do the threading while we read the headers. The
4259 ;; message-id and the last reference are both entered into
4260 ;; the same hash table. Some tippy-toeing around has to be
4261 ;; done in case an article has arrived before the article
4262 ;; which it refers to.
4263 (if (boundp (setq id-dep (intern id dependencies)))
4264 (if (and (car (symbol-value id-dep))
4266 ;; An article with this Message-ID has already
4267 ;; been seen, so we ignore this one, except we add
4268 ;; any additional Xrefs (in case the two articles
4269 ;; came from different servers).
4271 (mail-header-set-xref
4272 (car (symbol-value id-dep))
4273 (concat (or (mail-header-xref
4274 (car (symbol-value id-dep)))
4276 (or (mail-header-xref header) "")))
4278 (setcar (symbol-value id-dep) header))
4279 (set id-dep (list header)))
4281 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
4282 (setcdr (symbol-value ref-dep)
4283 (nconc (cdr (symbol-value ref-dep))
4284 (list (symbol-value id-dep))))
4285 (set ref-dep (list nil (symbol-value id-dep))))
4286 (push header headers))
4287 (goto-char (point-max))
4289 (nreverse headers)))))
4291 ;; The following macros and functions were written by Felix Lee
4292 ;; <flee@cse.psu.edu>.
4294 (defmacro gnus-nov-read-integer ()
4296 (if (= (following-char) ?\t)
4298 (let ((num (ignore-errors (read buffer))))
4299 (if (numberp num) num 0)))
4303 (defmacro gnus-nov-skip-field ()
4304 '(search-forward "\t" eol 'move))
4306 (defmacro gnus-nov-field ()
4307 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
4309 ;; (defvar gnus-nov-none-counter 0)
4311 ;; This function has to be called with point after the article number
4312 ;; on the beginning of the line.
4313 (defun gnus-nov-parse-line (number dependencies &optional force-new)
4314 (let ((eol (gnus-point-at-eol))
4315 (buffer (current-buffer))
4316 header ref id id-dep ref-dep)
4318 ;; overview: [num subject from date id refs chars lines misc]
4319 (narrow-to-region (point) eol)
4326 (gnus-nov-field) ; subject
4327 (gnus-nov-field) ; from
4328 (gnus-nov-field) ; date
4329 (setq id (or (gnus-nov-field)
4330 (nnheader-generate-fake-message-id))) ; id
4332 (let ((beg (point)))
4333 (search-forward "\t" eol)
4334 (if (search-backward ">" beg t)
4338 (search-backward "<" beg t)))
4341 (gnus-nov-field)) ; refs
4342 (gnus-nov-read-integer) ; chars
4343 (gnus-nov-read-integer) ; lines
4344 (if (= (following-char) ?\n)
4346 (gnus-nov-field)) ; misc
4351 ;; We build the thread tree.
4352 (when (equal id ref)
4353 ;; This article refers back to itself. Naughty, naughty.
4355 (if (boundp (setq id-dep (intern id dependencies)))
4356 (if (and (car (symbol-value id-dep))
4358 ;; An article with this Message-ID has already been seen,
4359 ;; so we ignore this one, except we add any additional
4360 ;; Xrefs (in case the two articles came from different
4363 (mail-header-set-xref
4364 (car (symbol-value id-dep))
4365 (concat (or (mail-header-xref
4366 (car (symbol-value id-dep)))
4368 (or (mail-header-xref header) "")))
4370 (setcar (symbol-value id-dep) header))
4371 (set id-dep (list header)))
4373 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
4374 (setcdr (symbol-value ref-dep)
4375 (nconc (cdr (symbol-value ref-dep))
4376 (list (symbol-value id-dep))))
4377 (set ref-dep (list nil (symbol-value id-dep)))))
4380 ;; Goes through the xover lines and returns a list of vectors
4381 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4382 force-new dependencies)
4383 "Parse the news overview data in the server buffer, and return a
4384 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4385 ;; Get the Xref when the users reads the articles since most/some
4386 ;; NNTP servers do not include Xrefs when using XOVER.
4387 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4388 (let ((cur nntp-server-buffer)
4389 (dependencies (or dependencies gnus-newsgroup-dependencies))
4390 number headers header)
4392 (set-buffer nntp-server-buffer)
4393 ;; Allow the user to mangle the headers before parsing them.
4394 (run-hooks 'gnus-parse-headers-hook)
4395 (goto-char (point-min))
4398 (while (and sequence (not (eobp)))
4399 (setq number (read cur))
4400 (while (and sequence
4401 (< (car sequence) number))
4402 (setq sequence (cdr sequence)))
4404 (eq number (car sequence))
4406 (setq sequence (cdr sequence))
4407 (setq header (inline
4408 (gnus-nov-parse-line
4409 number dependencies force-new))))
4410 (push header headers))
4413 (gnus-error 4 "Strange nov line")))
4415 (nreverse headers))))
4417 (defun gnus-article-get-xrefs ()
4418 "Fill in the Xref value in `gnus-current-headers', if necessary.
4419 This is meant to be called in `gnus-article-internal-prepare-hook'."
4420 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4421 gnus-current-headers)))
4422 (or (not gnus-use-cross-reference)
4424 (and (mail-header-xref headers)
4425 (not (string= (mail-header-xref headers) "")))
4426 (let ((case-fold-search t)
4429 (nnheader-narrow-to-headers)
4430 (goto-char (point-min))
4431 (when (or (and (eq (downcase (following-char)) ?x)
4432 (looking-at "Xref:"))
4433 (search-forward "\nXref:" nil t))
4434 (goto-char (1+ (match-end 0)))
4435 (setq xref (buffer-substring (point)
4436 (progn (end-of-line) (point))))
4437 (mail-header-set-xref headers xref)))))))
4439 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4440 "Find article ID and insert the summary line for that article."
4441 (let ((header (if (and old-header use-old-header)
4442 old-header (gnus-read-header id)))
4443 (number (and (numberp id) id))
4446 ;; Rebuild the thread that this article is part of and go to the
4447 ;; article we have fetched.
4448 (when (and (not gnus-show-threads)
4450 (when (setq d (gnus-data-find (mail-header-number old-header)))
4451 (goto-char (gnus-data-pos d))
4454 (- (gnus-point-at-bol)
4456 (1+ (gnus-point-at-eol))
4457 (gnus-delete-line))))))
4459 (mail-header-set-number header (mail-header-number old-header)))
4460 (setq gnus-newsgroup-sparse
4461 (delq (setq number (mail-header-number header))
4462 gnus-newsgroup-sparse))
4463 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4464 (gnus-rebuild-thread (mail-header-id header))
4465 (gnus-summary-goto-subject number nil t))
4466 (when (and (numberp number)
4468 ;; We have to update the boundaries even if we can't fetch the
4469 ;; article if ID is a number -- so that the next `P' or `N'
4470 ;; command will fetch the previous (or next) article even
4471 ;; if the one we tried to fetch this time has been canceled.
4472 (when (> number gnus-newsgroup-end)
4473 (setq gnus-newsgroup-end number))
4474 (when (< number gnus-newsgroup-begin)
4475 (setq gnus-newsgroup-begin number))
4476 (setq gnus-newsgroup-unselected
4477 (delq number gnus-newsgroup-unselected)))
4478 ;; Report back a success?
4479 (and header (mail-header-number header))))
4481 ;;; Process/prefix in the summary buffer
4483 (defun gnus-summary-work-articles (n)
4484 "Return a list of articles to be worked upon. The prefix argument,
4485 the list of process marked articles, and the current article will be
4486 taken into consideration."
4489 ;; A numerical prefix has been given.
4490 (let ((backward (< n 0))
4491 (n (abs (prefix-numeric-value n)))
4496 (push (setq article (gnus-summary-article-number))
4499 (gnus-summary-find-prev nil article)
4500 (gnus-summary-find-next nil article)))
4502 (nreverse articles)))
4503 ((and (boundp 'transient-mark-mode)
4506 ;; Work on the region between point and mark.
4507 (let ((max (max (point) (mark)))
4510 (goto-char (min (point) (mark)))
4513 (push (setq article (gnus-summary-article-number)) articles)
4514 (gnus-summary-find-next nil article)
4516 (nreverse articles))))
4517 (gnus-newsgroup-processable
4518 ;; There are process-marked articles present.
4519 ;; Save current state.
4520 (gnus-summary-save-process-mark)
4522 (reverse gnus-newsgroup-processable))
4524 ;; Just return the current article.
4525 (list (gnus-summary-article-number)))))
4527 (defun gnus-summary-save-process-mark ()
4528 "Push the current set of process marked articles on the stack."
4530 (push (copy-sequence gnus-newsgroup-processable)
4531 gnus-newsgroup-process-stack))
4533 (defun gnus-summary-kill-process-mark ()
4534 "Push the current set of process marked articles on the stack and unmark."
4536 (gnus-summary-save-process-mark)
4537 (gnus-summary-unmark-all-processable))
4539 (defun gnus-summary-yank-process-mark ()
4540 "Pop the last process mark state off the stack and restore it."
4542 (unless gnus-newsgroup-process-stack
4543 (error "Empty mark stack"))
4544 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4546 (defun gnus-summary-process-mark-set (set)
4547 "Make SET into the current process marked articles."
4548 (gnus-summary-unmark-all-processable)
4550 (gnus-summary-set-process-mark (pop set))))
4552 ;;; Searching and stuff
4554 (defun gnus-summary-search-group (&optional backward use-level)
4555 "Search for next unread newsgroup.
4556 If optional argument BACKWARD is non-nil, search backward instead."
4558 (set-buffer gnus-group-buffer)
4559 (when (gnus-group-search-forward
4560 backward nil (if use-level (gnus-group-group-level) nil))
4561 (gnus-group-group-name))))
4563 (defun gnus-summary-best-group (&optional exclude-group)
4564 "Find the name of the best unread group.
4565 If EXCLUDE-GROUP, do not go to this group."
4567 (set-buffer gnus-group-buffer)
4569 (gnus-group-best-unread-group exclude-group))))
4571 (defun gnus-summary-find-next (&optional unread article backward)
4572 (if backward (gnus-summary-find-prev)
4573 (let* ((dummy (gnus-summary-article-intangible-p))
4574 (article (or article (gnus-summary-article-number)))
4575 (arts (gnus-data-find-list article))
4577 (when (and (not dummy)
4578 (or (not gnus-summary-check-current)
4580 (not (gnus-data-unread-p (car arts)))))
4581 (setq arts (cdr arts)))
4586 (when (gnus-data-unread-p (car arts))
4587 (setq result (car arts)
4589 (setq arts (cdr arts)))
4592 (goto-char (gnus-data-pos result))
4593 (gnus-data-number result)))))
4595 (defun gnus-summary-find-prev (&optional unread article)
4596 (let* ((eobp (eobp))
4597 (article (or article (gnus-summary-article-number)))
4598 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
4600 (when (and (not eobp)
4601 (or (not gnus-summary-check-current)
4603 (not (gnus-data-unread-p (car arts)))))
4604 (setq arts (cdr arts)))
4609 (when (gnus-data-unread-p (car arts))
4610 (setq result (car arts)
4612 (setq arts (cdr arts)))
4615 (goto-char (gnus-data-pos result))
4616 (gnus-data-number result))))
4618 (defun gnus-summary-find-subject (subject &optional unread backward article)
4619 (let* ((simp-subject (gnus-simplify-subject-fully subject))
4620 (article (or article (gnus-summary-article-number)))
4621 (articles (gnus-data-list backward))
4622 (arts (gnus-data-find-list article articles))
4624 (when (or (not gnus-summary-check-current)
4626 (not (gnus-data-unread-p (car arts))))
4627 (setq arts (cdr arts)))
4629 (and (or (not unread)
4630 (gnus-data-unread-p (car arts)))
4631 (vectorp (gnus-data-header (car arts)))
4633 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
4634 (setq result (car arts)
4636 (setq arts (cdr arts)))
4638 (goto-char (gnus-data-pos result))
4639 (gnus-data-number result))))
4641 (defun gnus-summary-search-forward (&optional unread subject backward)
4642 "Search forward for an article.
4643 If UNREAD, look for unread articles. If SUBJECT, look for
4644 articles with that subject. If BACKWARD, search backward instead."
4645 (cond (subject (gnus-summary-find-subject subject unread backward))
4646 (backward (gnus-summary-find-prev unread))
4647 (t (gnus-summary-find-next unread))))
4649 (defun gnus-recenter (&optional n)
4650 "Center point in window and redisplay frame.
4651 Also do horizontal recentering."
4653 (when (and gnus-auto-center-summary
4654 (not (eq gnus-auto-center-summary 'vertical)))
4655 (gnus-horizontal-recenter))
4658 (defun gnus-summary-recenter ()
4659 "Center point in the summary window.
4660 If `gnus-auto-center-summary' is nil, or the article buffer isn't
4661 displayed, no centering will be performed."
4662 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
4663 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
4664 (let* ((top (cond ((< (window-height) 4) 0)
4665 ((< (window-height) 7) 1)
4667 (height (1- (window-height)))
4668 (bottom (save-excursion (goto-char (point-max))
4669 (forward-line (- height))
4671 (window (get-buffer-window (current-buffer))))
4672 ;; The user has to want it.
4673 (when gnus-auto-center-summary
4674 (when (get-buffer-window gnus-article-buffer)
4675 ;; Only do recentering when the article buffer is displayed,
4676 ;; Set the window start to either `bottom', which is the biggest
4677 ;; possible valid number, or the second line from the top,
4678 ;; whichever is the least.
4680 window (min bottom (save-excursion
4681 (forward-line (- top)) (point)))))
4682 ;; Do horizontal recentering while we're at it.
4683 (when (and (get-buffer-window (current-buffer) t)
4684 (not (eq gnus-auto-center-summary 'vertical)))
4685 (let ((selected (selected-window)))
4686 (select-window (get-buffer-window (current-buffer) t))
4687 (gnus-summary-position-point)
4688 (gnus-horizontal-recenter)
4689 (select-window selected))))))
4691 (defun gnus-summary-jump-to-group (newsgroup)
4692 "Move point to NEWSGROUP in group mode buffer."
4693 ;; Keep update point of group mode buffer if visible.
4694 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
4695 (save-window-excursion
4696 ;; Take care of tree window mode.
4697 (when (get-buffer-window gnus-group-buffer)
4698 (pop-to-buffer gnus-group-buffer))
4699 (gnus-group-jump-to-group newsgroup))
4701 ;; Take care of tree window mode.
4702 (if (get-buffer-window gnus-group-buffer)
4703 (pop-to-buffer gnus-group-buffer)
4704 (set-buffer gnus-group-buffer))
4705 (gnus-group-jump-to-group newsgroup))))
4707 ;; This function returns a list of article numbers based on the
4708 ;; difference between the ranges of read articles in this group and
4709 ;; the range of active articles.
4710 (defun gnus-list-of-unread-articles (group)
4711 (let* ((read (gnus-info-read (gnus-get-info group)))
4712 (active (or (gnus-active group) (gnus-activate-group group)))
4715 ;; If none are read, then all are unread.
4717 (setq first (car active))
4718 ;; If the range of read articles is a single range, then the
4719 ;; first unread article is the article after the last read
4720 ;; article. Sounds logical, doesn't it?
4721 (if (not (listp (cdr read)))
4722 (setq first (1+ (cdr read)))
4723 ;; `read' is a list of ranges.
4724 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
4730 (while (< first nlast)
4732 (setq first (1+ first))))
4733 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
4734 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
4735 (setq read (cdr read)))))
4736 ;; And add the last unread articles.
4737 (while (<= first last)
4739 (setq first (1+ first)))
4740 ;; Return the list of unread articles.
4743 (defun gnus-list-of-read-articles (group)
4744 "Return a list of unread, unticked and non-dormant articles."
4745 (let* ((info (gnus-get-info group))
4746 (marked (gnus-info-marks info))
4747 (active (gnus-active group)))
4749 (gnus-set-difference
4750 (gnus-sorted-complement
4751 (gnus-uncompress-range active)
4752 (gnus-list-of-unread-articles group))
4754 (gnus-uncompress-range (cdr (assq 'dormant marked)))
4755 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
4757 ;; Various summary commands
4759 (defun gnus-summary-universal-argument (arg)
4760 "Perform any operation on all articles that are process/prefixed."
4762 (gnus-set-global-variables)
4763 (let ((articles (gnus-summary-work-articles arg))
4770 (substitute-command-keys
4771 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
4774 (gnus-error 1 "Undefined key")
4777 (gnus-summary-goto-subject (setq article (pop articles)))
4778 (let (gnus-newsgroup-processable)
4779 (command-execute func))
4780 (gnus-summary-remove-process-mark article)))))
4781 (gnus-summary-position-point))
4783 (defun gnus-summary-toggle-truncation (&optional arg)
4784 "Toggle truncation of summary lines.
4785 With arg, turn line truncation on iff arg is positive."
4787 (setq truncate-lines
4788 (if (null arg) (not truncate-lines)
4789 (> (prefix-numeric-value arg) 0)))
4792 (defun gnus-summary-reselect-current-group (&optional all rescan)
4793 "Exit and then reselect the current newsgroup.
4794 The prefix argument ALL means to select all articles."
4796 (gnus-set-global-variables)
4797 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
4798 (error "Ephemeral groups can't be reselected"))
4799 (let ((current-subject (gnus-summary-article-number))
4800 (group gnus-newsgroup-name))
4801 (setq gnus-newsgroup-begin nil)
4803 ;; We have to adjust the point of group mode buffer because the
4804 ;; current point was moved to the next unread newsgroup by
4806 (gnus-summary-jump-to-group group)
4809 (gnus-group-get-new-news-this-group 1)))
4810 (gnus-group-read-group all t)
4811 (gnus-summary-goto-subject current-subject nil t)))
4813 (defun gnus-summary-rescan-group (&optional all)
4814 "Exit the newsgroup, ask for new articles, and select the newsgroup."
4816 (gnus-summary-reselect-current-group all t))
4818 (defun gnus-summary-update-info ()
4820 (let ((group gnus-newsgroup-name))
4821 (when gnus-newsgroup-kill-headers
4822 (setq gnus-newsgroup-killed
4823 (gnus-compress-sequence
4825 (gnus-set-sorted-intersection
4826 (gnus-uncompress-range gnus-newsgroup-killed)
4827 (setq gnus-newsgroup-unselected
4828 (sort gnus-newsgroup-unselected '<)))
4829 (setq gnus-newsgroup-unreads
4830 (sort gnus-newsgroup-unreads '<)))
4832 (unless (listp (cdr gnus-newsgroup-killed))
4833 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
4834 (let ((headers gnus-newsgroup-headers))
4835 (run-hooks 'gnus-exit-group-hook)
4836 (unless gnus-save-score
4837 (setq gnus-newsgroup-scored nil))
4838 ;; Set the new ranges of read articles.
4839 (gnus-update-read-articles
4840 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
4841 ;; Set the current article marks.
4843 ;; Do the cross-ref thing.
4844 (when gnus-use-cross-reference
4845 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
4846 ;; Do adaptive scoring, and possibly save score files.
4847 (when gnus-newsgroup-adaptive
4848 (gnus-score-adaptive))
4849 (when gnus-use-scoring
4851 ;; Do not switch windows but change the buffer to work.
4852 (set-buffer gnus-group-buffer)
4853 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
4854 (gnus-group-update-group group))))))
4856 (defun gnus-summary-exit (&optional temporary)
4857 "Exit reading current newsgroup, and then return to group selection mode.
4858 gnus-exit-group-hook is called with no arguments if that value is non-nil."
4860 (gnus-set-global-variables)
4861 (gnus-kill-save-kill-buffer)
4862 (let* ((group gnus-newsgroup-name)
4863 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
4865 (buf (current-buffer)))
4866 (run-hooks 'gnus-summary-prepare-exit-hook)
4867 ;; If we have several article buffers, we kill them at exit.
4868 (unless gnus-single-article-buffer
4869 (gnus-kill-buffer gnus-original-article-buffer)
4870 (setq gnus-article-current nil))
4871 (when gnus-use-cache
4872 (gnus-cache-possibly-remove-articles)
4873 (gnus-cache-save-buffers))
4874 (gnus-async-prefetch-remove-group group)
4875 (when gnus-suppress-duplicates
4876 (gnus-dup-enter-articles))
4877 (when gnus-use-trees
4878 (gnus-tree-close group))
4879 ;; Make all changes in this group permanent.
4881 (gnus-summary-update-info))
4882 (gnus-close-group group)
4883 ;; Make sure where I was, and go to next newsgroup.
4884 (set-buffer gnus-group-buffer)
4886 (gnus-group-jump-to-group group))
4887 (run-hooks 'gnus-summary-exit-hook)
4889 (gnus-group-next-unread-group 1))
4892 ;; If we have several article buffers, we kill them at exit.
4893 (unless gnus-single-article-buffer
4894 (gnus-kill-buffer gnus-article-buffer)
4895 (gnus-kill-buffer gnus-original-article-buffer)
4896 (setq gnus-article-current nil))
4898 (if (not gnus-kill-summary-on-exit)
4899 (gnus-deaden-summary)
4900 ;; We set all buffer-local variables to nil. It is unclear why
4901 ;; this is needed, but if we don't, buffer-local variables are
4902 ;; not garbage-collected, it seems. This would the lead to en
4903 ;; ever-growing Emacs.
4904 (gnus-summary-clear-local-variables)
4905 (when (get-buffer gnus-article-buffer)
4906 (bury-buffer gnus-article-buffer))
4907 ;; We clear the global counterparts of the buffer-local
4908 ;; variables as well, just to be on the safe side.
4909 (set-buffer gnus-group-buffer)
4910 (gnus-summary-clear-local-variables)
4911 ;; Return to group mode buffer.
4912 (when (eq mode 'gnus-summary-mode)
4913 (gnus-kill-buffer buf)))
4914 (setq gnus-current-select-method gnus-select-method)
4915 (pop-to-buffer gnus-group-buffer)
4916 ;; Clear the current group name.
4917 (if (not quit-config)
4919 (gnus-group-jump-to-group group)
4920 (gnus-group-next-unread-group 1)
4921 (gnus-configure-windows 'group 'force))
4922 (gnus-handle-ephemeral-exit quit-config))
4924 (setq gnus-newsgroup-name nil)))))
4926 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
4927 (defun gnus-summary-exit-no-update (&optional no-questions)
4928 "Quit reading current newsgroup without updating read article info."
4930 (gnus-set-global-variables)
4931 (let* ((group gnus-newsgroup-name)
4932 (quit-config (gnus-group-quit-config group)))
4933 (when (or no-questions
4935 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
4936 ;; If we have several article buffers, we kill them at exit.
4937 (unless gnus-single-article-buffer
4938 (gnus-kill-buffer gnus-article-buffer)
4939 (gnus-kill-buffer gnus-original-article-buffer)
4940 (setq gnus-article-current nil))
4941 (if (not gnus-kill-summary-on-exit)
4942 (gnus-deaden-summary)
4943 (gnus-close-group group)
4944 (gnus-summary-clear-local-variables)
4945 (set-buffer gnus-group-buffer)
4946 (gnus-summary-clear-local-variables)
4947 (when (get-buffer gnus-summary-buffer)
4948 (kill-buffer gnus-summary-buffer)))
4949 (unless gnus-single-article-buffer
4950 (setq gnus-article-current nil))
4951 (when gnus-use-trees
4952 (gnus-tree-close group))
4953 (gnus-async-prefetch-remove-group group)
4954 (when (get-buffer gnus-article-buffer)
4955 (bury-buffer gnus-article-buffer))
4956 ;; Return to the group buffer.
4957 (gnus-configure-windows 'group 'force)
4958 ;; Clear the current group name.
4959 (setq gnus-newsgroup-name nil)
4960 (when (equal (gnus-group-group-name) group)
4961 (gnus-group-next-unread-group 1))
4963 (gnus-handle-ephemeral-exit quit-config)))))
4965 (defun gnus-handle-ephemeral-exit (quit-config)
4966 "Handle movement when leaving an ephemeral group. The state
4967 which existed when entering the ephemeral is reset."
4968 (if (not (buffer-name (car quit-config)))
4969 (gnus-configure-windows 'group 'force)
4970 (set-buffer (car quit-config))
4971 (cond ((eq major-mode 'gnus-summary-mode)
4972 (gnus-set-global-variables))
4973 ((eq major-mode 'gnus-article-mode)
4975 ;; The `gnus-summary-buffer' variable may point
4976 ;; to the old summary buffer when using a single
4978 (unless (gnus-buffer-live-p gnus-summary-buffer)
4979 (set-buffer gnus-group-buffer))
4980 (set-buffer gnus-summary-buffer)
4981 (gnus-set-global-variables))))
4982 (if (or (eq (cdr quit-config) 'article)
4983 (eq (cdr quit-config) 'pick))
4985 ;; The current article may be from the ephemeral group
4986 ;; thus it is best that we reload this article
4987 (gnus-summary-show-article)
4988 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
4989 (gnus-configure-windows 'pick 'force)
4990 (gnus-configure-windows (cdr quit-config) 'force)))
4991 (gnus-configure-windows (cdr quit-config) 'force))
4992 (when (eq major-mode 'gnus-summary-mode)
4993 (gnus-summary-next-subject 1 nil t)
4994 (gnus-summary-recenter)
4995 (gnus-summary-position-point))))
4999 (defvar gnus-dead-summary-mode-map nil)
5001 (unless gnus-dead-summary-mode-map
5002 (setq gnus-dead-summary-mode-map (make-keymap))
5003 (suppress-keymap gnus-dead-summary-mode-map)
5004 (substitute-key-definition
5005 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5006 (let ((keys '("\C-d" "\r" "\177")))
5008 (define-key gnus-dead-summary-mode-map
5009 (pop keys) 'gnus-summary-wake-up-the-dead))))
5011 (defvar gnus-dead-summary-mode nil
5012 "Minor mode for Gnus summary buffers.")
5014 (defun gnus-dead-summary-mode (&optional arg)
5015 "Minor mode for Gnus summary buffers."
5017 (when (eq major-mode 'gnus-summary-mode)
5018 (make-local-variable 'gnus-dead-summary-mode)
5019 (setq gnus-dead-summary-mode
5020 (if (null arg) (not gnus-dead-summary-mode)
5021 (> (prefix-numeric-value arg) 0)))
5022 (when gnus-dead-summary-mode
5023 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
5024 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
5025 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
5026 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
5027 minor-mode-map-alist)))))
5029 (defun gnus-deaden-summary ()
5030 "Make the current summary buffer into a dead summary buffer."
5031 ;; Kill any previous dead summary buffer.
5032 (when (and gnus-dead-summary
5033 (buffer-name gnus-dead-summary))
5035 (set-buffer gnus-dead-summary)
5036 (when gnus-dead-summary-mode
5037 (kill-buffer (current-buffer)))))
5038 ;; Make this the current dead summary.
5039 (setq gnus-dead-summary (current-buffer))
5040 (gnus-dead-summary-mode 1)
5041 (let ((name (buffer-name)))
5042 (when (string-match "Summary" name)
5044 (concat (substring name 0 (match-beginning 0)) "Dead "
5045 (substring name (match-beginning 0)))
5048 (defun gnus-kill-or-deaden-summary (buffer)
5049 "Kill or deaden the summary BUFFER."
5050 (when (and (buffer-name buffer)
5051 (not gnus-single-article-buffer))
5054 (gnus-kill-buffer gnus-article-buffer)
5055 (gnus-kill-buffer gnus-original-article-buffer)))
5056 (cond (gnus-kill-summary-on-exit
5057 (when (and gnus-use-trees
5058 (and (get-buffer buffer)
5059 (buffer-name (get-buffer buffer))))
5061 (set-buffer (get-buffer buffer))
5062 (gnus-tree-close gnus-newsgroup-name)))
5063 (gnus-kill-buffer buffer))
5064 ((and (get-buffer buffer)
5065 (buffer-name (get-buffer buffer)))
5068 (gnus-deaden-summary)))))
5070 (defun gnus-summary-wake-up-the-dead (&rest args)
5071 "Wake up the dead summary buffer."
5073 (gnus-dead-summary-mode -1)
5074 (let ((name (buffer-name)))
5075 (when (string-match "Dead " name)
5077 (concat (substring name 0 (match-beginning 0))
5078 (substring name (match-end 0)))
5080 (gnus-message 3 "This dead summary is now alive again"))
5082 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5083 (defun gnus-summary-fetch-faq (&optional faq-dir)
5084 "Fetch the FAQ for the current group.
5085 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5089 (when current-prefix-arg
5091 "Faq dir: " (and (listp gnus-group-faq-directory)
5092 gnus-group-faq-directory)))))
5093 (let (gnus-faq-buffer)
5094 (when (setq gnus-faq-buffer
5095 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5096 (gnus-configure-windows 'summary-faq))))
5098 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5099 (defun gnus-summary-describe-group (&optional force)
5100 "Describe the current newsgroup."
5102 (gnus-group-describe-group force gnus-newsgroup-name))
5104 (defun gnus-summary-describe-briefly ()
5105 "Describe summary mode commands briefly."
5108 (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")))
5110 ;; Walking around group mode buffer from summary mode.
5112 (defun gnus-summary-next-group (&optional no-article target-group backward)
5113 "Exit current newsgroup and then select next unread newsgroup.
5114 If prefix argument NO-ARTICLE is non-nil, no article is selected
5115 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5116 previous group instead."
5118 (gnus-set-global-variables)
5119 ;; Stop pre-fetching.
5120 (gnus-async-halt-prefetch)
5121 (let ((current-group gnus-newsgroup-name)
5122 (current-buffer (current-buffer))
5124 ;; First we semi-exit this group to update Xrefs and all variables.
5125 ;; We can't do a real exit, because the window conf must remain
5126 ;; the same in case the user is prompted for info, and we don't
5127 ;; want the window conf to change before that...
5128 (gnus-summary-exit t)
5129 (while (not entered)
5130 ;; Then we find what group we are supposed to enter.
5131 (set-buffer gnus-group-buffer)
5132 (gnus-group-jump-to-group current-group)
5135 (if (eq gnus-keep-same-level 'best)
5136 (gnus-summary-best-group gnus-newsgroup-name)
5137 (gnus-summary-search-group backward gnus-keep-same-level))))
5138 (if (not target-group)
5139 ;; There are no further groups, so we return to the group
5142 (gnus-message 5 "Returning to the group buffer")
5144 (set-buffer current-buffer)
5146 (run-hooks 'gnus-group-no-more-groups-hook))
5147 ;; We try to enter the target group.
5148 (gnus-group-jump-to-group target-group)
5149 (let ((unreads (gnus-group-group-unread)))
5150 (if (and (or (eq t unreads)
5151 (and unreads (not (zerop unreads))))
5152 (gnus-summary-read-group
5153 target-group nil no-article current-buffer))
5155 (setq current-group target-group
5156 target-group nil)))))))
5158 (defun gnus-summary-prev-group (&optional no-article)
5159 "Exit current newsgroup and then select previous unread newsgroup.
5160 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5162 (gnus-summary-next-group no-article nil t))
5164 ;; Walking around summary lines.
5166 (defun gnus-summary-first-subject (&optional unread)
5167 "Go to the first unread subject.
5168 If UNREAD is non-nil, go to the first unread article.
5169 Returns the article selected or nil if there are no unread articles."
5174 ((null gnus-newsgroup-data)
5175 (gnus-message 3 "No articles in the group")
5177 ;; Pick the first article.
5179 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5180 (gnus-data-number (car gnus-newsgroup-data)))
5181 ;; No unread articles.
5182 ((null gnus-newsgroup-unreads)
5183 (gnus-message 3 "No more unread articles")
5185 ;; Find the first unread article.
5187 (let ((data gnus-newsgroup-data))
5189 (not (gnus-data-unread-p (car data))))
5190 (setq data (cdr data)))
5192 (goto-char (gnus-data-pos (car data)))
5193 (gnus-data-number (car data))))))
5194 (gnus-summary-position-point)))
5196 (defun gnus-summary-next-subject (n &optional unread dont-display)
5197 "Go to next N'th summary line.
5198 If N is negative, go to the previous N'th subject line.
5199 If UNREAD is non-nil, only unread articles are selected.
5200 The difference between N and the actual number of steps taken is
5203 (let ((backward (< n 0))
5207 (gnus-summary-find-prev unread)
5208 (gnus-summary-find-next unread)))
5211 (gnus-message 7 "No more%s articles"
5212 (if unread " unread" "")))
5213 (unless dont-display
5214 (gnus-summary-recenter)
5215 (gnus-summary-position-point))
5218 (defun gnus-summary-next-unread-subject (n)
5219 "Go to next N'th unread summary line."
5221 (gnus-summary-next-subject n t))
5223 (defun gnus-summary-prev-subject (n &optional unread)
5224 "Go to previous N'th summary line.
5225 If optional argument UNREAD is non-nil, only unread article is selected."
5227 (gnus-summary-next-subject (- n) unread))
5229 (defun gnus-summary-prev-unread-subject (n)
5230 "Go to previous N'th unread summary line."
5232 (gnus-summary-next-subject (- n) t))
5234 (defun gnus-summary-goto-subject (article &optional force silent)
5235 "Go the subject line of ARTICLE.
5236 If FORCE, also allow jumping to articles not currently shown."
5237 (interactive "nArticle number: ")
5239 (data (gnus-data-find article)))
5240 ;; We read in the article if we have to.
5243 (gnus-summary-insert-subject article (and (vectorp force) force) t)
5244 (setq data (gnus-data-find article)))
5249 (gnus-message 3 "Can't find article %d" article))
5251 (goto-char (gnus-data-pos data))
5254 ;; Walking around summary lines with displaying articles.
5256 (defun gnus-summary-expand-window (&optional arg)
5257 "Make the summary buffer take up the entire Emacs frame.
5258 Given a prefix, will force an `article' buffer configuration."
5260 (gnus-set-global-variables)
5262 (gnus-configure-windows 'article 'force)
5263 (gnus-configure-windows 'summary 'force)))
5265 (defun gnus-summary-display-article (article &optional all-header)
5266 "Display ARTICLE in article buffer."
5267 (gnus-set-global-variables)
5271 (if gnus-summary-display-article-function
5272 (funcall gnus-summary-display-article-function article all-header)
5273 (gnus-article-prepare article all-header))
5274 (run-hooks 'gnus-select-article-hook)
5275 (when (and gnus-current-article
5276 (not (zerop gnus-current-article)))
5277 (gnus-summary-goto-subject gnus-current-article))
5278 (gnus-summary-recenter)
5279 (when (and gnus-use-trees gnus-show-threads)
5280 (gnus-possibly-generate-tree article)
5281 (gnus-highlight-selected-tree article))
5282 ;; Successfully display article.
5283 (gnus-article-set-window-start
5284 (cdr (assq article gnus-newsgroup-bookmarks))))))
5286 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5287 "Select the current article.
5288 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5289 non-nil, the article will be re-fetched even if it already present in
5290 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5292 ;; Make sure we are in the summary buffer to work around bbdb bug.
5293 (unless (eq major-mode 'gnus-summary-mode)
5294 (set-buffer gnus-summary-buffer))
5295 (let ((article (or article (gnus-summary-article-number)))
5296 (all-headers (not (not all-headers))) ;Must be T or NIL.
5297 gnus-summary-display-article-function
5300 (gnus-summary-article-pseudo-p article)
5301 (error "This is a pseudo-article."))
5304 (set-buffer gnus-summary-buffer)
5305 (if (or (and gnus-single-article-buffer
5306 (or (null gnus-current-article)
5307 (null gnus-article-current)
5308 (null (get-buffer gnus-article-buffer))
5309 (not (eq article (cdr gnus-article-current)))
5310 (not (equal (car gnus-article-current)
5311 gnus-newsgroup-name))))
5312 (and (not gnus-single-article-buffer)
5313 (or (null gnus-current-article)
5314 (not (eq gnus-current-article article))))
5316 ;; The requested article is different from the current article.
5318 (gnus-summary-display-article article all-headers)
5320 (when (or all-headers gnus-show-all-headers)
5321 (gnus-article-show-all-headers))
5324 (gnus-article-set-window-start
5325 (cdr (assq article gnus-newsgroup-bookmarks)))))))
5327 (defun gnus-summary-set-current-mark (&optional current-mark)
5328 "Obsolete function."
5331 (defun gnus-summary-next-article (&optional unread subject backward push)
5332 "Select the next article.
5333 If UNREAD, only unread articles are selected.
5334 If SUBJECT, only articles with SUBJECT are selected.
5335 If BACKWARD, the previous article is selected instead of the next."
5337 (gnus-set-global-variables)
5339 ;; Is there such an article?
5340 ((and (gnus-summary-search-forward unread subject backward)
5341 (or (gnus-summary-display-article (gnus-summary-article-number))
5342 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5343 (gnus-summary-position-point))
5344 ;; If not, we try the first unread, if that is wanted.
5346 gnus-auto-select-same
5347 ;; Make sure that we don't select the current article.
5348 (not (eq (gnus-summary-article-number)
5350 (gnus-summary-first-subject t)
5351 (gnus-summary-article-number))))
5352 (gnus-summary-first-unread-article))
5353 (gnus-summary-position-point)
5354 (gnus-message 6 "Wrapped"))
5355 ;; Try to get next/previous article not displayed in this group.
5356 ((and gnus-auto-extend-newsgroup
5357 (not unread) (not subject))
5358 (gnus-summary-goto-article
5359 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5361 ;; Go to next/previous group.
5363 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5364 (gnus-summary-jump-to-group gnus-newsgroup-name))
5365 (let ((cmd last-command-char)
5367 (if (eq gnus-keep-same-level 'best)
5368 (gnus-summary-best-group gnus-newsgroup-name)
5369 (gnus-summary-search-group backward gnus-keep-same-level))))
5370 ;; For some reason, the group window gets selected. We change
5372 (select-window (get-buffer-window (current-buffer)))
5373 ;; Select next unread newsgroup automagically.
5375 ((or (not gnus-auto-select-next)
5377 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5378 ((or (eq gnus-auto-select-next 'quietly)
5379 (and (eq gnus-auto-select-next 'slightly-quietly)
5381 (and (eq gnus-auto-select-next 'almost-quietly)
5382 (gnus-summary-last-article-p)))
5384 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5386 (gnus-message 7 "No more%s articles (%s)..."
5387 (if unread " unread" "")
5388 (if group (concat "selecting " group)
5390 (gnus-summary-next-group nil group backward)))
5392 (when (gnus-key-press-event-p last-input-event)
5393 (gnus-summary-walk-group-buffer
5394 gnus-newsgroup-name cmd unread backward))))))))
5396 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
5397 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5398 (?\C-p (gnus-group-prev-unread-group 1))))
5399 (cursor-in-echo-area t)
5400 keve key group ended)
5402 (set-buffer gnus-group-buffer)
5403 (gnus-summary-jump-to-group from-group)
5405 (if (eq gnus-keep-same-level 'best)
5406 (gnus-summary-best-group gnus-newsgroup-name)
5407 (gnus-summary-search-group backward gnus-keep-same-level))))
5410 5 "No more%s articles%s" (if unread " unread" "")
5412 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5413 (format " (Type %s for %s [%s])"
5414 (single-key-description cmd) group
5415 (car (gnus-gethash group gnus-newsrc-hashtb)))
5416 (format " (Type %s to exit %s)"
5417 (single-key-description cmd)
5418 gnus-newsgroup-name)))
5419 ;; Confirm auto selection.
5420 (setq key (car (setq keve (gnus-read-event-char))))
5423 ((assq key keystrokes)
5424 (let ((obuf (current-buffer)))
5425 (switch-to-buffer gnus-group-buffer)
5427 (gnus-group-jump-to-group group))
5428 (eval (cadr (assq key keystrokes)))
5429 (setq group (gnus-group-group-name))
5430 (switch-to-buffer obuf))
5434 (gnus-ephemeral-group-p gnus-newsgroup-name))
5436 (gnus-summary-next-group nil group backward)))
5438 (push (cdr keve) unread-command-events))))))
5440 (defun gnus-summary-next-unread-article ()
5441 "Select unread article after current one."
5443 (gnus-summary-next-article
5444 (or (not (eq gnus-summary-goto-unread 'never))
5445 (gnus-summary-last-article-p (gnus-summary-article-number)))
5446 (and gnus-auto-select-same
5447 (gnus-summary-article-subject))))
5449 (defun gnus-summary-prev-article (&optional unread subject)
5450 "Select the article after the current one.
5451 If UNREAD is non-nil, only unread articles are selected."
5453 (gnus-summary-next-article unread subject t))
5455 (defun gnus-summary-prev-unread-article ()
5456 "Select unread article before current one."
5458 (gnus-summary-prev-article
5459 (or (not (eq gnus-summary-goto-unread 'never))
5460 (gnus-summary-first-article-p (gnus-summary-article-number)))
5461 (and gnus-auto-select-same
5462 (gnus-summary-article-subject))))
5464 (defun gnus-summary-next-page (&optional lines circular)
5465 "Show next page of the selected article.
5466 If at the end of the current article, select the next article.
5467 LINES says how many lines should be scrolled up.
5469 If CIRCULAR is non-nil, go to the start of the article instead of
5470 selecting the next article when reaching the end of the current
5473 (setq gnus-summary-buffer (current-buffer))
5474 (gnus-set-global-variables)
5475 (let ((article (gnus-summary-article-number))
5477 (gnus-configure-windows 'article)
5478 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
5479 (if (and (eq gnus-summary-goto-unread 'never)
5480 (not (gnus-summary-last-article-p article)))
5481 (gnus-summary-next-article)
5482 (gnus-summary-next-unread-article))
5483 (if (or (null gnus-current-article)
5484 (null gnus-article-current)
5485 (/= article (cdr gnus-article-current))
5486 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5487 ;; Selected subject is different from current article's.
5488 (gnus-summary-display-article article)
5489 (gnus-eval-in-buffer-window gnus-article-buffer
5490 (setq endp (gnus-article-next-page lines)))
5493 (gnus-summary-beginning-of-article))
5495 (gnus-message 3 "End of message"))
5497 (if (and (eq gnus-summary-goto-unread 'never)
5498 (not (gnus-summary-last-article-p article)))
5499 (gnus-summary-next-article)
5500 (gnus-summary-next-unread-article)))))))
5501 (gnus-summary-recenter)
5502 (gnus-summary-position-point)))
5504 (defun gnus-summary-prev-page (&optional lines)
5505 "Show previous page of selected article.
5506 Argument LINES specifies lines to be scrolled down."
5508 (gnus-set-global-variables)
5509 (let ((article (gnus-summary-article-number)))
5510 (gnus-configure-windows 'article)
5511 (if (or (null gnus-current-article)
5512 (null gnus-article-current)
5513 (/= article (cdr gnus-article-current))
5514 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5515 ;; Selected subject is different from current article's.
5516 (gnus-summary-display-article article)
5517 (gnus-summary-recenter)
5518 (gnus-eval-in-buffer-window gnus-article-buffer
5519 (gnus-article-prev-page lines))))
5520 (gnus-summary-position-point))
5522 (defun gnus-summary-scroll-up (lines)
5523 "Scroll up (or down) one line current article.
5524 Argument LINES specifies lines to be scrolled up (or down if negative)."
5526 (gnus-set-global-variables)
5527 (gnus-configure-windows 'article)
5528 (gnus-summary-show-thread)
5529 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
5530 (gnus-eval-in-buffer-window gnus-article-buffer
5532 (when (gnus-article-next-page lines)
5533 (gnus-message 3 "End of message")))
5535 (gnus-article-prev-page (- lines))))))
5536 (gnus-summary-recenter)
5537 (gnus-summary-position-point))
5539 (defun gnus-summary-next-same-subject ()
5540 "Select next article which has the same subject as current one."
5542 (gnus-set-global-variables)
5543 (gnus-summary-next-article nil (gnus-summary-article-subject)))
5545 (defun gnus-summary-prev-same-subject ()
5546 "Select previous article which has the same subject as current one."
5548 (gnus-set-global-variables)
5549 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
5551 (defun gnus-summary-next-unread-same-subject ()
5552 "Select next unread article which has the same subject as current one."
5554 (gnus-set-global-variables)
5555 (gnus-summary-next-article t (gnus-summary-article-subject)))
5557 (defun gnus-summary-prev-unread-same-subject ()
5558 "Select previous unread article which has the same subject as current one."
5560 (gnus-set-global-variables)
5561 (gnus-summary-prev-article t (gnus-summary-article-subject)))
5563 (defun gnus-summary-first-unread-article ()
5564 "Select the first unread article.
5565 Return nil if there are no unread articles."
5567 (gnus-set-global-variables)
5569 (when (gnus-summary-first-subject t)
5570 (gnus-summary-show-thread)
5571 (gnus-summary-first-subject t)
5572 (gnus-summary-display-article (gnus-summary-article-number)))
5573 (gnus-summary-position-point)))
5575 (defun gnus-summary-first-article ()
5576 "Select the first article.
5577 Return nil if there are no articles."
5579 (gnus-set-global-variables)
5581 (when (gnus-summary-first-subject)
5582 (gnus-summary-show-thread)
5583 (gnus-summary-first-subject)
5584 (gnus-summary-display-article (gnus-summary-article-number)))
5585 (gnus-summary-position-point)))
5587 (defun gnus-summary-best-unread-article ()
5588 "Select the unread article with the highest score."
5590 (gnus-set-global-variables)
5591 (let ((best -1000000)
5592 (data gnus-newsgroup-data)
5595 (and (gnus-data-unread-p (car data))
5597 (gnus-summary-article-score (gnus-data-number (car data))))
5600 article (gnus-data-number (car data))))
5601 (setq data (cdr data)))
5604 (gnus-summary-goto-article article)
5605 (error "No unread articles"))
5606 (gnus-summary-position-point))))
5608 (defun gnus-summary-last-subject ()
5609 "Go to the last displayed subject line in the group."
5610 (let ((article (gnus-data-number (car (gnus-data-list t)))))
5612 (gnus-summary-goto-subject article))))
5614 (defun gnus-summary-goto-article (article &optional all-headers force)
5615 "Fetch ARTICLE and display it if it exists.
5616 If ALL-HEADERS is non-nil, no header lines are hidden."
5622 (mapcar (lambda (number) (list (int-to-string number)))
5623 gnus-newsgroup-limit)))
5627 (if (gnus-summary-goto-subject article force)
5628 (gnus-summary-display-article article all-headers)
5629 (gnus-message 4 "Couldn't go to article %s" article) nil)
5630 (gnus-summary-position-point)))
5632 (defun gnus-summary-goto-last-article ()
5633 "Go to the previously read article."
5636 (when gnus-last-article
5637 (gnus-summary-goto-article gnus-last-article))
5638 (gnus-summary-position-point)))
5640 (defun gnus-summary-pop-article (number)
5641 "Pop one article off the history and go to the previous.
5642 NUMBER articles will be popped off."
5645 (setq gnus-newsgroup-history
5646 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
5648 (gnus-summary-goto-article (car to))
5649 (error "Article history empty")))
5650 (gnus-summary-position-point))
5652 ;; Summary commands and functions for limiting the summary buffer.
5654 (defun gnus-summary-limit-to-articles (n)
5655 "Limit the summary buffer to the next N articles.
5656 If not given a prefix, use the process marked articles instead."
5658 (gnus-set-global-variables)
5660 (let ((articles (gnus-summary-work-articles n)))
5661 (setq gnus-newsgroup-processable nil)
5662 (gnus-summary-limit articles))
5663 (gnus-summary-position-point)))
5665 (defun gnus-summary-pop-limit (&optional total)
5666 "Restore the previous limit.
5667 If given a prefix, remove all limits."
5669 (gnus-set-global-variables)
5671 (setq gnus-newsgroup-limits
5672 (list (mapcar (lambda (h) (mail-header-number h))
5673 gnus-newsgroup-headers))))
5674 (unless gnus-newsgroup-limits
5675 (error "No limit to pop"))
5677 (gnus-summary-limit nil 'pop)
5678 (gnus-summary-position-point)))
5680 (defun gnus-summary-limit-to-subject (subject &optional header)
5681 "Limit the summary buffer to articles that have subjects that match a regexp."
5682 (interactive "sRegexp: ")
5684 (setq header "subject"))
5685 (when (not (equal "" subject))
5687 (let ((articles (gnus-summary-find-matching
5688 (or header "subject") subject 'all)))
5690 (error "Found no matches for \"%s\"" subject))
5691 (gnus-summary-limit articles))
5692 (gnus-summary-position-point))))
5694 (defun gnus-summary-limit-to-author (from)
5695 "Limit the summary buffer to articles that have authors that match a regexp."
5696 (interactive "sRegexp: ")
5697 (gnus-summary-limit-to-subject from "from"))
5699 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5701 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5703 (defun gnus-summary-limit-to-unread (&optional all)
5704 "Limit the summary buffer to articles that are not marked as read.
5705 If ALL is non-nil, limit strictly to unread articles."
5708 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
5709 (gnus-summary-limit-to-marks
5710 ;; Concat all the marks that say that an article is read and have
5712 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
5713 gnus-killed-mark gnus-kill-file-mark
5714 gnus-low-score-mark gnus-expirable-mark
5715 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
5716 gnus-duplicate-mark)
5719 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
5720 (make-obsolete 'gnus-summary-delete-marked-with
5721 'gnus-summary-limit-exlude-marks)
5723 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
5724 "Exclude articles that are marked with MARKS (e.g. \"DK\").
5725 If REVERSE, limit the summary buffer to articles that are marked
5726 with MARKS. MARKS can either be a string of marks or a list of marks.
5727 Returns how many articles were removed."
5728 (interactive "sMarks: ")
5729 (gnus-summary-limit-to-marks marks t))
5731 (defun gnus-summary-limit-to-marks (marks &optional reverse)
5732 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
5733 If REVERSE (the prefix), limit the summary buffer to articles that are
5734 not marked with MARKS. MARKS can either be a string of marks or a
5736 Returns how many articles were removed."
5737 (interactive (list (read-string "Marks: ") current-prefix-arg))
5738 (gnus-set-global-variables)
5740 (let ((data gnus-newsgroup-data)
5741 (marks (if (listp marks) marks
5742 (append marks nil))) ; Transform to list.
5745 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
5746 (memq (gnus-data-mark (car data)) marks))
5747 (push (gnus-data-number (car data)) articles))
5748 (setq data (cdr data)))
5749 (gnus-summary-limit articles))
5750 (gnus-summary-position-point)))
5752 (defun gnus-summary-limit-to-score (&optional score)
5753 "Limit to articles with score at or above SCORE."
5755 (gnus-set-global-variables)
5756 (setq score (if score
5757 (prefix-numeric-value score)
5758 (or gnus-summary-default-score 0)))
5759 (let ((data gnus-newsgroup-data)
5762 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
5764 (push (gnus-data-number (car data)) articles))
5765 (setq data (cdr data)))
5767 (gnus-summary-limit articles)
5768 (gnus-summary-position-point))))
5770 (defun gnus-summary-limit-include-dormant ()
5771 "Display all the hidden articles that are marked as dormant."
5773 (gnus-set-global-variables)
5774 (unless gnus-newsgroup-dormant
5775 (error "There are no dormant articles in this group"))
5777 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
5778 (gnus-summary-position-point)))
5780 (defun gnus-summary-limit-exclude-dormant ()
5781 "Hide all dormant articles."
5783 (gnus-set-global-variables)
5785 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
5786 (gnus-summary-position-point)))
5788 (defun gnus-summary-limit-exclude-childless-dormant ()
5789 "Hide all dormant articles that have no children."
5791 (gnus-set-global-variables)
5792 (let ((data (gnus-data-list t))
5793 articles d children)
5794 ;; Find all articles that are either not dormant or have
5796 (while (setq d (pop data))
5797 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
5799 (gnus-article-children (gnus-data-number d)))
5802 (when (memq (car children) articles)
5807 (push (gnus-data-number d) articles)))
5810 (gnus-summary-limit articles)
5811 (gnus-summary-position-point))))
5813 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
5814 "Mark all unread excluded articles as read.
5815 If ALL, mark even excluded ticked and dormants as read."
5817 (let ((articles (gnus-sorted-complement
5819 (mapcar (lambda (h) (mail-header-number h))
5820 gnus-newsgroup-headers)
5822 (sort gnus-newsgroup-limit '<)))
5824 (setq gnus-newsgroup-unreads nil)
5826 (setq gnus-newsgroup-dormant nil
5827 gnus-newsgroup-marked nil
5828 gnus-newsgroup-reads
5830 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
5831 gnus-newsgroup-reads))
5832 (while (setq article (pop articles))
5833 (unless (or (memq article gnus-newsgroup-dormant)
5834 (memq article gnus-newsgroup-marked))
5835 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
5837 (defun gnus-summary-limit (articles &optional pop)
5839 ;; We pop the previous limit off the stack and use that.
5840 (setq articles (car gnus-newsgroup-limits)
5841 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
5842 ;; We use the new limit, so we push the old limit on the stack.
5843 (push gnus-newsgroup-limit gnus-newsgroup-limits))
5845 (setq gnus-newsgroup-limit articles)
5846 (let ((total (length gnus-newsgroup-data))
5847 (data (gnus-data-find-list (gnus-summary-article-number)))
5848 (gnus-summary-mark-below nil) ; Inhibit this.
5850 ;; This will do all the work of generating the new summary buffer
5851 ;; according to the new limit.
5852 (gnus-summary-prepare)
5853 ;; Hide any threads, possibly.
5854 (and gnus-show-threads
5855 gnus-thread-hide-subtree
5856 (gnus-summary-hide-all-threads))
5857 ;; Try to return to the article you were at, or one in the
5860 ;; We try to find some article after the current one.
5862 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
5865 (setq data (cdr data))))
5867 ;; If there is no data, that means that we were after the last
5868 ;; article. The same goes when we can't find any articles
5869 ;; after the current one.
5870 (goto-char (point-max))
5871 (gnus-summary-find-prev))
5872 ;; We return how many articles were removed from the summary
5873 ;; buffer as a result of the new limit.
5874 (- total (length gnus-newsgroup-data))))
5876 (defsubst gnus-invisible-cut-children (threads)
5879 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
5884 (defsubst gnus-cut-thread (thread)
5885 "Go forwards in the thread until we find an article that we want to display."
5886 (when (or (eq gnus-fetch-old-headers 'some)
5887 (eq gnus-build-sparse-threads 'some)
5888 (eq gnus-build-sparse-threads 'more))
5889 ;; Deal with old-fetched headers and sparse threads.
5893 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
5894 (gnus-summary-article-ancient-p
5895 (mail-header-number (car thread))))
5897 (if (<= (length (cdr thread)) 1)
5898 (setq thread (cadr thread))
5899 (when (gnus-invisible-cut-children (cdr thread))
5900 (let ((th (cdr thread)))
5902 (if (memq (mail-header-number (caar th))
5903 gnus-newsgroup-limit)
5904 (setq thread (car th)
5906 (setq th (cdr th)))))))))
5910 (defun gnus-cut-threads (threads)
5911 "Cut off all uninteresting articles from the beginning of threads."
5912 (when (or (eq gnus-fetch-old-headers 'some)
5913 (eq gnus-build-sparse-threads 'some)
5914 (eq gnus-build-sparse-threads 'more))
5917 (setcar th (gnus-cut-thread (car th)))
5918 (setq th (cdr th)))))
5919 ;; Remove nixed out threads.
5922 (defun gnus-summary-initial-limit (&optional show-if-empty)
5923 "Figure out what the initial limit is supposed to be on group entry.
5924 This entails weeding out unwanted dormants, low-scored articles,
5925 fetch-old-headers verbiage, and so on."
5926 ;; Most groups have nothing to remove.
5927 (if (or gnus-inhibit-limiting
5928 (and (null gnus-newsgroup-dormant)
5929 (not (eq gnus-fetch-old-headers 'some))
5930 (null gnus-summary-expunge-below)
5931 (not (eq gnus-build-sparse-threads 'some))
5932 (not (eq gnus-build-sparse-threads 'more))
5933 (null gnus-thread-expunge-below)
5934 (not gnus-use-nocem)))
5936 (push gnus-newsgroup-limit gnus-newsgroup-limits)
5937 (setq gnus-newsgroup-limit nil)
5940 (unless (car (symbol-value node))
5941 ;; These threads have no parents -- they are roots.
5942 (let ((nodes (cdr (symbol-value node)))
5945 (if (and gnus-thread-expunge-below
5946 (< (gnus-thread-total-score (car nodes))
5947 gnus-thread-expunge-below))
5948 (gnus-expunge-thread (pop nodes))
5949 (setq thread (pop nodes))
5950 (gnus-summary-limit-children thread))))))
5951 gnus-newsgroup-dependencies)
5952 ;; If this limitation resulted in an empty group, we might
5953 ;; pop the previous limit and use it instead.
5954 (when (and (not gnus-newsgroup-limit)
5956 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
5957 gnus-newsgroup-limit))
5959 (defun gnus-summary-limit-children (thread)
5960 "Return 1 if this subthread is visible and 0 if it is not."
5961 ;; First we get the number of visible children to this thread. This
5962 ;; is done by recursing down the thread using this function, so this
5963 ;; will really go down to a leaf article first, before slowly
5964 ;; working its way up towards the root.
5968 (apply '+ (mapcar 'gnus-summary-limit-children
5971 (number (mail-header-number (car thread)))
5974 (not (memq number gnus-newsgroup-marked))
5976 ;; If this article is dormant and has absolutely no visible
5977 ;; children, then this article isn't visible.
5978 (and (memq number gnus-newsgroup-dormant)
5980 ;; If this is "fetch-old-headered" and there is no
5981 ;; visible children, then we don't want this article.
5982 (and (eq gnus-fetch-old-headers 'some)
5983 (gnus-summary-article-ancient-p number)
5985 ;; If this is a sparsely inserted article with no children,
5986 ;; we don't want it.
5987 (and (eq gnus-build-sparse-threads 'some)
5988 (gnus-summary-article-sparse-p number)
5990 ;; If we use expunging, and this article is really
5991 ;; low-scored, then we don't want this article.
5992 (when (and gnus-summary-expunge-below
5994 (or (cdr (assq number gnus-newsgroup-scored))
5995 gnus-summary-default-score))
5996 gnus-summary-expunge-below))
5997 ;; We increase the expunge-tally here, but that has
5998 ;; nothing to do with the limits, really.
5999 (incf gnus-newsgroup-expunged-tally)
6000 ;; We also mark as read here, if that's wanted.
6001 (when (and gnus-summary-mark-below
6002 (< score gnus-summary-mark-below))
6003 (setq gnus-newsgroup-unreads
6004 (delq number gnus-newsgroup-unreads))
6005 (if gnus-newsgroup-auto-expire
6006 (push number gnus-newsgroup-expirable)
6007 (push (cons number gnus-low-score-mark)
6008 gnus-newsgroup-reads)))
6010 ;; Check NoCeM things.
6012 (gnus-nocem-unwanted-article-p
6013 (mail-header-id (car thread))))))
6014 ;; Nope, invisible article.
6016 ;; Ok, this article is to be visible, so we add it to the limit
6018 (push number gnus-newsgroup-limit)
6021 (defun gnus-expunge-thread (thread)
6022 "Mark all articles in THREAD as read."
6023 (let* ((number (mail-header-number (car thread))))
6024 (incf gnus-newsgroup-expunged-tally)
6025 ;; We also mark as read here, if that's wanted.
6026 (setq gnus-newsgroup-unreads
6027 (delq number gnus-newsgroup-unreads))
6028 (if gnus-newsgroup-auto-expire
6029 (push number gnus-newsgroup-expirable)
6030 (push (cons number gnus-low-score-mark)
6031 gnus-newsgroup-reads)))
6032 ;; Go recursively through all subthreads.
6033 (mapcar 'gnus-expunge-thread (cdr thread)))
6035 ;; Summary article oriented commands
6037 (defun gnus-summary-refer-parent-article (n)
6038 "Refer parent article N times.
6039 If N is negative, go to ancestor -N instead.
6040 The difference between N and the number of articles fetched is returned."
6042 (gnus-set-global-variables)
6045 (when (not (natnump n))
6050 (setq header (gnus-summary-article-header))
6052 ;; If we try to find the parent of the currently
6053 ;; displayed article, then we take a look at the actual
6054 ;; References header, since this is slightly more
6055 ;; reliable than the References field we got from the
6057 (if (and (eq (mail-header-number header)
6058 (cdr gnus-article-current))
6059 (equal gnus-newsgroup-name
6060 (car gnus-article-current)))
6062 (set-buffer gnus-original-article-buffer)
6063 (nnheader-narrow-to-headers)
6065 (message-fetch-field "references")
6067 ;; It's not the current article, so we take a bet on
6068 ;; the value we got from the server.
6069 (mail-header-references header)))
6071 (not (equal ref "")))
6072 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6073 (gnus-message 1 "Couldn't find parent"))
6074 (gnus-message 1 "No references in article %d"
6075 (gnus-summary-article-number))
6078 (gnus-summary-position-point)
6081 (defun gnus-summary-refer-references ()
6082 "Fetch all articles mentioned in the References header.
6083 Return how many articles were fetched."
6085 (gnus-set-global-variables)
6086 (let ((ref (mail-header-references (gnus-summary-article-header)))
6087 (current (gnus-summary-article-number))
6091 (error "No References in the current article")
6092 ;; For each Message-ID in the References header...
6093 (while (string-match "<[^>]*>" ref)
6095 ;; ... fetch that article.
6096 (gnus-summary-refer-article
6097 (prog1 (match-string 0 ref)
6098 (setq ref (substring ref (match-end 0))))))
6099 (gnus-summary-goto-subject current)
6100 (gnus-summary-position-point)
6103 (defun gnus-summary-refer-article (message-id)
6104 "Fetch an article specified by MESSAGE-ID."
6105 (interactive "sMessage-ID: ")
6106 (when (and (stringp message-id)
6107 (not (zerop (length message-id))))
6108 ;; Construct the correct Message-ID if necessary.
6109 ;; Suggested by tale@pawl.rpi.edu.
6110 (unless (string-match "^<" message-id)
6111 (setq message-id (concat "<" message-id)))
6112 (unless (string-match ">$" message-id)
6113 (setq message-id (concat message-id ">")))
6114 (let* ((header (gnus-id-to-header message-id))
6116 (gnus-summary-article-sparse-p
6117 (mail-header-number header)))))
6120 ;; The article is present in the buffer, to we just go to it.
6121 (gnus-summary-goto-article
6122 (mail-header-number header) nil header)
6124 (gnus-summary-update-article (mail-header-number header))))
6125 ;; We fetch the article
6126 (let ((gnus-override-method
6127 (and (gnus-news-group-p gnus-newsgroup-name)
6128 gnus-refer-article-method))
6130 ;; Start the special refer-article method, if necessary.
6131 (when (and gnus-refer-article-method
6132 (gnus-news-group-p gnus-newsgroup-name))
6133 (gnus-check-server gnus-refer-article-method))
6134 ;; Fetch the header, and display the article.
6135 (if (setq number (gnus-summary-insert-subject message-id))
6136 (gnus-summary-select-article nil nil nil number)
6137 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
6139 (defun gnus-summary-enter-digest-group (&optional force)
6140 "Enter an nndoc group based on the current article.
6141 If FORCE, force a digest interpretation. If not, try
6142 to guess what the document format is."
6144 (gnus-set-global-variables)
6145 (let ((conf gnus-current-window-configuration))
6147 (gnus-summary-select-article))
6148 (setq gnus-current-window-configuration conf)
6149 (let* ((name (format "%s-%d"
6150 (gnus-group-prefixed-name
6151 gnus-newsgroup-name (list 'nndoc ""))
6153 (set-buffer gnus-summary-buffer)
6154 gnus-current-article)))
6155 (ogroup gnus-newsgroup-name)
6156 (params (append (gnus-info-params (gnus-get-info ogroup))
6157 (list (cons 'to-group ogroup))))
6158 (case-fold-search t)
6159 (buf (current-buffer))
6162 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6163 (insert-buffer-substring gnus-original-article-buffer)
6164 ;; Remove lines that may lead nndoc to misinterpret the
6167 (goto-char (point-min))
6168 (or (search-forward "\n\n" nil t) (point)))
6169 (goto-char (point-min))
6170 (delete-matching-lines "^\\(Path\\):\\|^From ")
6173 (if (gnus-group-read-ephemeral-group
6174 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6176 ,(if force 'digest 'guess))) t)
6177 ;; Make all postings to this group go to the parent group.
6178 (nconc (gnus-info-params (gnus-get-info name))
6180 ;; Couldn't select this doc group.
6181 (switch-to-buffer buf)
6182 (gnus-set-global-variables)
6183 (gnus-configure-windows 'summary)
6184 (gnus-message 3 "Article couldn't be entered?"))
6185 (kill-buffer dig)))))
6187 (defun gnus-summary-read-document (n)
6188 "Open a new group based on the current article(s).
6189 This will allow you to read digests and other similar
6190 documents as newsgroups.
6191 Obeys the standard process/prefix convention."
6193 (let* ((articles (gnus-summary-work-articles n))
6194 (ogroup gnus-newsgroup-name)
6195 (params (append (gnus-info-params (gnus-get-info ogroup))
6196 (list (cons 'to-group ogroup))))
6197 article group egroup groups vgroup)
6198 (while (setq article (pop articles))
6199 (setq group (format "%s-%d" gnus-newsgroup-name article))
6200 (gnus-summary-remove-process-mark article)
6201 (when (gnus-summary-display-article article)
6203 (nnheader-temp-write nil
6204 (insert-buffer-substring gnus-original-article-buffer)
6205 ;; Remove some headers that may lead nndoc to make
6207 (message-narrow-to-head)
6208 (goto-char (point-min))
6209 (delete-matching-lines "^\\(Path\\):\\|^From ")
6212 (gnus-group-read-ephemeral-group
6213 group `(nndoc ,group (nndoc-address ,(current-buffer))
6214 (nndoc-article-type guess))
6217 ;; Make all postings to this group go to the parent group.
6218 (nconc (gnus-info-params (gnus-get-info egroup))
6220 (push egroup groups))
6221 ;; Couldn't select this doc group.
6222 (gnus-error 3 "Article couldn't be entered"))))))
6223 ;; Now we have selected all the documents.
6226 (error "None of the articles could be interpreted as documents"))
6227 ((gnus-group-read-ephemeral-group
6228 (setq vgroup (format
6229 "nnvirtual:%s-%s" gnus-newsgroup-name
6230 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6231 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6233 (cons (current-buffer) 'summary)))
6235 (error "Couldn't select virtual nndoc group")))))
6237 (defun gnus-summary-isearch-article (&optional regexp-p)
6238 "Do incremental search forward on the current article.
6239 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6241 (gnus-set-global-variables)
6242 (gnus-summary-select-article)
6243 (gnus-configure-windows 'article)
6244 (gnus-eval-in-buffer-window gnus-article-buffer
6245 ;;(goto-char (point-min))
6246 (isearch-forward regexp-p)))
6248 (defun gnus-summary-search-article-forward (regexp &optional backward)
6249 "Search for an article containing REGEXP forward.
6250 If BACKWARD, search backward instead."
6253 (format "Search article %s (regexp%s): "
6254 (if current-prefix-arg "backward" "forward")
6255 (if gnus-last-search-regexp
6256 (concat ", default " gnus-last-search-regexp)
6258 current-prefix-arg))
6259 (gnus-set-global-variables)
6260 (if (string-equal regexp "")
6261 (setq regexp (or gnus-last-search-regexp ""))
6262 (setq gnus-last-search-regexp regexp))
6263 (if (gnus-summary-search-article regexp backward)
6264 (gnus-summary-show-thread)
6265 (error "Search failed: \"%s\"" regexp)))
6267 (defun gnus-summary-search-article-backward (regexp)
6268 "Search for an article containing REGEXP backward."
6271 (format "Search article backward (regexp%s): "
6272 (if gnus-last-search-regexp
6273 (concat ", default " gnus-last-search-regexp)
6275 (gnus-summary-search-article-forward regexp 'backward))
6277 (defun gnus-summary-search-article (regexp &optional backward)
6278 "Search for an article containing REGEXP.
6279 Optional argument BACKWARD means do search for backward.
6280 `gnus-select-article-hook' is not called during the search."
6281 (let ((gnus-select-article-hook nil) ;Disable hook.
6282 (gnus-article-display-hook nil)
6283 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6284 (gnus-use-article-prefetch nil)
6285 (sum (current-buffer))
6288 (gnus-save-hidden-threads
6289 (gnus-summary-select-article)
6290 (set-buffer gnus-article-buffer)
6294 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
6296 (re-search-backward regexp nil t)
6297 (re-search-forward regexp nil t))
6298 ;; We found the regexp.
6303 (get-buffer-window (current-buffer))
6307 (setq point (point)))
6308 ;; We didn't find it, so we go to the next article.
6311 (while (eq found 'not)
6312 (if (not (if backward (gnus-summary-find-prev)
6313 (gnus-summary-find-next)))
6314 ;; No more articles.
6316 ;; Select the next article and adjust point.
6317 (unless (gnus-summary-article-sparse-p
6318 (gnus-summary-article-number))
6320 (gnus-summary-select-article)
6321 (set-buffer gnus-article-buffer)
6323 (goto-char (if backward (point-max) (point-min))))))))
6324 (gnus-message 7 ""))
6325 ;; Return whether we found the regexp.
6326 (when (eq found 'found)
6328 (gnus-summary-show-thread)
6329 (gnus-summary-goto-subject gnus-current-article)
6330 (gnus-summary-position-point)
6333 (defun gnus-summary-find-matching (header regexp &optional backward unread
6335 "Return a list of all articles that match REGEXP on HEADER.
6336 The search stars on the current article and goes forwards unless
6337 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
6338 If UNREAD is non-nil, only unread articles will
6339 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
6340 in the comparisons."
6341 (let ((data (if (eq backward 'all) gnus-newsgroup-data
6342 (gnus-data-find-list
6343 (gnus-summary-article-number) (gnus-data-list backward))))
6344 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
6345 (case-fold-search (not not-case-fold))
6347 (unless (fboundp (intern (concat "mail-header-" header)))
6348 (error "%s is not a valid header" header))
6351 (and (or (not unread) ; We want all articles...
6352 (gnus-data-unread-p d)) ; Or just unreads.
6353 (vectorp (gnus-data-header d)) ; It's not a pseudo.
6354 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
6355 (push (gnus-data-number d) articles)) ; Success!
6356 (setq data (cdr data)))
6357 (nreverse articles)))
6359 (defun gnus-summary-execute-command (header regexp command &optional backward)
6360 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
6361 If HEADER is an empty string (or nil), the match is done on the entire
6362 article. If BACKWARD (the prefix) is non-nil, search backward instead."
6364 (list (let ((completion-ignore-case t))
6367 (mapcar (lambda (string) (list string))
6368 '("Number" "Subject" "From" "Lines" "Date"
6369 "Message-ID" "Xref" "References" "Body"))
6370 nil 'require-match))
6371 (read-string "Regexp: ")
6372 (read-key-sequence "Command: ")
6373 current-prefix-arg))
6374 (when (equal header "Body")
6376 (gnus-set-global-variables)
6377 ;; Hidden thread subtrees must be searched as well.
6378 (gnus-summary-show-all-threads)
6379 ;; We don't want to change current point nor window configuration.
6381 (save-window-excursion
6382 (gnus-message 6 "Executing %s..." (key-description command))
6383 ;; We'd like to execute COMMAND interactively so as to give arguments.
6384 (gnus-execute header regexp
6385 `(call-interactively ',(key-binding command))
6387 (gnus-message 6 "Executing %s...done" (key-description command)))))
6389 (defun gnus-summary-beginning-of-article ()
6390 "Scroll the article back to the beginning."
6392 (gnus-set-global-variables)
6393 (gnus-summary-select-article)
6394 (gnus-configure-windows 'article)
6395 (gnus-eval-in-buffer-window gnus-article-buffer
6397 (goto-char (point-min))
6398 (when gnus-break-pages
6399 (gnus-narrow-to-page))))
6401 (defun gnus-summary-end-of-article ()
6402 "Scroll to the end of the article."
6404 (gnus-set-global-variables)
6405 (gnus-summary-select-article)
6406 (gnus-configure-windows 'article)
6407 (gnus-eval-in-buffer-window gnus-article-buffer
6409 (goto-char (point-max))
6411 (when gnus-break-pages
6412 (gnus-narrow-to-page))))
6414 (defun gnus-summary-print-article (&optional filename)
6415 "Generate and print a PostScript image of the article buffer.
6417 If the optional argument FILENAME is nil, send the image to the printer.
6418 If FILENAME is a string, save the PostScript image in a file with that
6419 name. If FILENAME is a number, prompt the user for the name of the file
6421 (interactive (list (ps-print-preprint current-prefix-arg)))
6422 (gnus-summary-select-article)
6423 (gnus-eval-in-buffer-window gnus-article-buffer
6424 (let ((buffer (generate-new-buffer " *print*")))
6427 (copy-to-buffer buffer (point-min) (point-max))
6429 (article-delete-invisible-text)
6430 (ps-print-buffer-with-faces filename))
6431 (kill-buffer buffer)))))
6433 (defun gnus-summary-show-article (&optional arg)
6434 "Force re-fetching of the current article.
6435 If ARG (the prefix) is non-nil, show the raw article without any
6436 article massaging functions being run."
6438 (gnus-set-global-variables)
6440 ;; Select the article the normal way.
6441 (gnus-summary-select-article nil 'force)
6442 ;; Bind the article treatment functions to nil.
6443 (let ((gnus-have-all-headers t)
6444 gnus-article-display-hook
6445 gnus-article-prepare-hook
6448 (gnus-summary-select-article nil 'force)))
6449 (gnus-summary-goto-subject gnus-current-article)
6450 ; (gnus-configure-windows 'article)
6451 (gnus-summary-position-point))
6453 (defun gnus-summary-verbose-headers (&optional arg)
6454 "Toggle permanent full header display.
6455 If ARG is a positive number, turn header display on.
6456 If ARG is a negative number, turn header display off."
6458 (gnus-set-global-variables)
6459 (setq gnus-show-all-headers
6460 (cond ((or (not (numberp arg))
6462 (not gnus-show-all-headers))
6465 (gnus-summary-show-article))
6467 (defun gnus-summary-toggle-header (&optional arg)
6468 "Show the headers if they are hidden, or hide them if they are shown.
6469 If ARG is a positive number, show the entire header.
6470 If ARG is a negative number, hide the unwanted header lines."
6472 (gnus-set-global-variables)
6474 (set-buffer gnus-article-buffer)
6475 (let* ((buffer-read-only nil)
6476 (inhibit-point-motion-hooks t)
6477 (hidden (text-property-any
6478 (goto-char (point-min)) (search-forward "\n\n")
6481 (goto-char (point-min))
6482 (when (search-forward "\n\n" nil t)
6483 (delete-region (point-min) (1- (point))))
6484 (goto-char (point-min))
6486 (set-buffer gnus-original-article-buffer)
6487 (goto-char (point-min))
6488 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
6489 (insert-buffer-substring gnus-original-article-buffer 1 e)
6490 (let ((article-inhibit-hiding t))
6491 (run-hooks 'gnus-article-display-hook))
6492 (when (or (not hidden) (and (numberp arg) (< arg 0)))
6493 (gnus-article-hide-headers)))))
6495 (defun gnus-summary-show-all-headers ()
6496 "Make all header lines visible."
6498 (gnus-set-global-variables)
6499 (gnus-article-show-all-headers))
6501 (defun gnus-summary-toggle-mime (&optional arg)
6502 "Toggle MIME processing.
6503 If ARG is a positive number, turn MIME processing on."
6505 (gnus-set-global-variables)
6506 (setq gnus-show-mime
6507 (if (null arg) (not gnus-show-mime)
6508 (> (prefix-numeric-value arg) 0)))
6509 (gnus-summary-select-article t 'force))
6511 (defun gnus-summary-caesar-message (&optional arg)
6512 "Caesar rotate the current article by 13.
6513 The numerical prefix specifies how manu places to rotate each letter
6516 (gnus-set-global-variables)
6517 (gnus-summary-select-article)
6518 (let ((mail-header-separator ""))
6519 (gnus-eval-in-buffer-window gnus-article-buffer
6522 (let ((start (window-start))
6524 (message-caesar-buffer-body arg)
6525 (set-window-start (get-buffer-window (current-buffer)) start))))))
6527 (defun gnus-summary-stop-page-breaking ()
6528 "Stop page breaking in the current article."
6530 (gnus-set-global-variables)
6531 (gnus-summary-select-article)
6532 (gnus-eval-in-buffer-window gnus-article-buffer
6534 (when (gnus-visual-p 'page-marker)
6535 (let ((buffer-read-only nil))
6536 (gnus-remove-text-with-property 'gnus-prev)
6537 (gnus-remove-text-with-property 'gnus-next)))))
6539 (defun gnus-summary-move-article (&optional n to-newsgroup
6540 select-method action)
6541 "Move the current article to a different newsgroup.
6542 If N is a positive number, move the N next articles.
6543 If N is a negative number, move the N previous articles.
6544 If N is nil and any articles have been marked with the process mark,
6545 move those articles instead.
6546 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6547 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6548 re-spool using this method.
6550 For this function to work, both the current newsgroup and the
6551 newsgroup that you want to move to have to support the `request-move'
6552 and `request-accept' functions."
6555 (setq action 'move))
6556 (gnus-set-global-variables)
6557 ;; Disable marking as read.
6558 (let (gnus-mark-article-hook)
6559 (save-window-excursion
6560 (gnus-summary-select-article)))
6561 ;; Check whether the source group supports the required functions.
6562 (cond ((and (eq action 'move)
6563 (not (gnus-check-backend-function
6564 'request-move-article gnus-newsgroup-name)))
6565 (error "The current group does not support article moving"))
6566 ((and (eq action 'crosspost)
6567 (not (gnus-check-backend-function
6568 'request-replace-article gnus-newsgroup-name)))
6569 (error "The current group does not support article editing")))
6570 (let ((articles (gnus-summary-work-articles n))
6571 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
6572 (names '((move "Move" "Moving")
6573 (copy "Copy" "Copying")
6574 (crosspost "Crosspost" "Crossposting")))
6575 (copy-buf (save-excursion
6576 (nnheader-set-temp-buffer " *copy article*")))
6577 art-group to-method new-xref article to-groups)
6578 (unless (assq action names)
6579 (error "Unknown action %s" action))
6580 ;; Read the newsgroup name.
6581 (when (and (not to-newsgroup)
6582 (not select-method))
6584 (gnus-read-move-group-name
6585 (cadr (assq action names))
6586 (symbol-value (intern (format "gnus-current-%s-group" action)))
6588 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
6589 (setq to-method (or select-method
6590 (gnus-group-name-to-method to-newsgroup)))
6591 ;; Check the method we are to move this article to...
6592 (unless (gnus-check-backend-function
6593 'request-accept-article (car to-method))
6594 (error "%s does not support article copying" (car to-method)))
6595 (unless (gnus-check-server to-method)
6596 (error "Can't open server %s" (car to-method)))
6597 (gnus-message 6 "%s to %s: %s..."
6598 (caddr (assq action names))
6599 (or (car select-method) to-newsgroup) articles)
6601 (setq article (pop articles))
6605 ;; Move the article.
6607 (gnus-request-move-article
6608 article ; Article to move
6609 gnus-newsgroup-name ; From newsgroup
6610 (nth 1 (gnus-find-method-for-group
6611 gnus-newsgroup-name)) ; Server
6612 (list 'gnus-request-accept-article
6613 to-newsgroup (list 'quote select-method)
6614 (not articles)) ; Accept form
6615 (not articles))) ; Only save nov last time
6616 ;; Copy the article.
6619 (set-buffer copy-buf)
6620 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6621 (gnus-request-accept-article
6622 to-newsgroup select-method (not articles))))
6623 ;; Crosspost the article.
6624 ((eq action 'crosspost)
6625 (let ((xref (message-tokenize-header
6626 (mail-header-xref (gnus-summary-article-header article))
6628 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
6631 (setq xref (list (system-name))))
6634 (mapconcat 'identity
6635 (delete "Xref:" (delete new-xref xref))
6639 (set-buffer copy-buf)
6640 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6641 (nnheader-replace-header "xref" new-xref)
6642 (gnus-request-accept-article
6643 to-newsgroup select-method (not articles)))))))
6645 (gnus-message 1 "Couldn't %s article %s"
6646 (cadr (assq action names)) article)
6649 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
6651 (gnus-group-prefixed-name
6654 (gnus-find-method-for-group to-newsgroup)))
6655 gnus-newsrc-hashtb)))
6656 (info (nth 2 entry))
6657 (to-group (gnus-info-group info)))
6658 ;; Update the group that has been moved to.
6660 (memq action '(move copy)))
6661 (unless (member to-group to-groups)
6662 (push to-group to-groups))
6664 (unless (memq article gnus-newsgroup-unreads)
6666 info (gnus-add-to-range (gnus-info-read info)
6667 (list (cdr art-group)))))
6669 ;; Copy any marks over to the new group.
6670 (let ((marks gnus-article-mark-lists)
6671 (to-article (cdr art-group)))
6673 ;; See whether the article is to be put in the cache.
6674 (when gnus-use-cache
6675 (gnus-cache-possibly-enter-article
6677 (let ((header (copy-sequence
6678 (gnus-summary-article-header article))))
6679 (mail-header-set-number header to-article)
6681 (memq article gnus-newsgroup-marked)
6682 (memq article gnus-newsgroup-dormant)
6683 (memq article gnus-newsgroup-unreads)))
6686 (when (memq article (symbol-value
6687 (intern (format "gnus-newsgroup-%s"
6689 ;; If the other group is the same as this group,
6690 ;; then we have to add the mark to the list.
6691 (when (equal to-group gnus-newsgroup-name)
6692 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
6695 (intern (format "gnus-newsgroup-%s"
6697 ;; Copy mark to other group.
6698 (gnus-add-marked-articles
6699 to-group (cdar marks) (list to-article) info))
6700 (setq marks (cdr marks)))))
6702 ;; Update the Xref header in this article to point to
6703 ;; the new crossposted article we have just created.
6704 (when (eq action 'crosspost)
6706 (set-buffer copy-buf)
6707 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6708 (nnheader-replace-header
6709 "xref" (concat new-xref " " (car art-group)
6710 ":" (cdr art-group)))
6711 (gnus-request-replace-article
6712 article gnus-newsgroup-name (current-buffer)))))
6714 (gnus-summary-goto-subject article)
6715 (when (eq action 'move)
6716 (gnus-summary-mark-article article gnus-canceled-mark)))
6717 (gnus-summary-remove-process-mark article))
6718 ;; Re-activate all groups that have been moved to.
6720 (gnus-activate-group (pop to-groups)))
6722 (gnus-kill-buffer copy-buf)
6723 (gnus-summary-position-point)
6724 (gnus-set-mode-line 'summary)))
6726 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
6727 "Move the current article to a different newsgroup.
6728 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6729 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6730 re-spool using this method."
6732 (gnus-summary-move-article n nil select-method 'copy))
6734 (defun gnus-summary-crosspost-article (&optional n)
6735 "Crosspost the current article to some other group."
6737 (gnus-summary-move-article n nil nil 'crosspost))
6739 (defcustom gnus-summary-respool-default-method nil
6740 "Default method for respooling an article.
6741 If nil, use to the current newsgroup method."
6742 :type 'gnus-select-method-name
6743 :group 'gnus-summary)
6745 (defun gnus-summary-respool-article (&optional n method)
6746 "Respool the current article.
6747 The article will be squeezed through the mail spooling process again,
6748 which means that it will be put in some mail newsgroup or other
6749 depending on `nnmail-split-methods'.
6750 If N is a positive number, respool the N next articles.
6751 If N is a negative number, respool the N previous articles.
6752 If N is nil and any articles have been marked with the process mark,
6753 respool those articles instead.
6755 Respooling can be done both from mail groups and \"real\" newsgroups.
6756 In the former case, the articles in question will be moved from the
6757 current group into whatever groups they are destined to. In the
6758 latter case, they will be copied into the relevant groups."
6760 (list current-prefix-arg
6761 (let* ((methods (gnus-methods-using 'respool))
6763 (symbol-name (or gnus-summary-respool-default-method
6764 (car (gnus-find-method-for-group
6765 gnus-newsgroup-name)))))
6767 (gnus-completing-read
6768 methname "What backend do you want to use when respooling?"
6769 methods nil t nil 'gnus-mail-method-history))
6772 ((zerop (length (setq ms (gnus-servers-using-backend
6774 (list (intern method) ""))
6778 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
6779 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
6781 (gnus-set-global-variables)
6783 (error "No method given for respooling"))
6784 (if (assoc (symbol-name
6785 (car (gnus-find-method-for-group gnus-newsgroup-name)))
6786 (gnus-methods-using 'respool))
6787 (gnus-summary-move-article n nil method)
6788 (gnus-summary-copy-article n nil method)))
6790 (defun gnus-summary-import-article (file)
6791 "Import a random file into a mail newsgroup."
6792 (interactive "fImport file: ")
6793 (gnus-set-global-variables)
6794 (let ((group gnus-newsgroup-name)
6795 (now (current-time))
6797 (unless (gnus-check-backend-function 'request-accept-article group)
6798 (error "%s does not support article importing" group))
6799 (or (file-readable-p file)
6800 (not (file-regular-p file))
6801 (error "Can't read %s" file))
6803 (set-buffer (get-buffer-create " *import file*"))
6804 (buffer-disable-undo (current-buffer))
6806 (insert-file-contents file)
6807 (goto-char (point-min))
6808 (unless (nnheader-article-p)
6809 ;; This doesn't look like an article, so we fudge some headers.
6810 (setq atts (file-attributes file)
6811 lines (count-lines (point-min) (point-max)))
6812 (insert "From: " (read-string "From: ") "\n"
6813 "Subject: " (read-string "Subject: ") "\n"
6814 "Date: " (timezone-make-date-arpa-standard
6815 (current-time-string (nth 5 atts))
6816 (current-time-zone now)
6817 (current-time-zone now))
6819 "Message-ID: " (message-make-message-id) "\n"
6820 "Lines: " (int-to-string lines) "\n"
6821 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
6822 (gnus-request-accept-article group nil t)
6823 (kill-buffer (current-buffer)))))
6825 (defun gnus-summary-article-posted-p ()
6826 "Say whether the current (mail) article is available from `gnus-select-method' as well.
6827 This will be the case if the article has both been mailed and posted."
6829 (let ((id (mail-header-references (gnus-summary-article-header)))
6830 (gnus-override-method
6831 (or gnus-refer-article-method gnus-select-method)))
6832 (if (gnus-request-head id "")
6833 (gnus-message 2 "The current message was found on %s"
6834 gnus-override-method)
6835 (gnus-message 2 "The current message couldn't be found on %s"
6836 gnus-override-method)
6839 (defun gnus-summary-expire-articles (&optional now)
6840 "Expire all articles that are marked as expirable in the current group."
6842 (gnus-set-global-variables)
6843 (when (gnus-check-backend-function
6844 'request-expire-articles gnus-newsgroup-name)
6845 ;; This backend supports expiry.
6846 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
6847 (expirable (if total
6849 ;; We need to update the info for
6850 ;; this group for `gnus-list-of-read-articles'
6851 ;; to give us the right answer.
6852 (gnus-summary-update-info)
6853 (gnus-list-of-read-articles gnus-newsgroup-name))
6854 (setq gnus-newsgroup-expirable
6855 (sort gnus-newsgroup-expirable '<))))
6856 (expiry-wait (if now 'immediate
6857 (gnus-group-find-parameter
6858 gnus-newsgroup-name 'expiry-wait)))
6861 ;; There are expirable articles in this group, so we run them
6862 ;; through the expiry process.
6863 (gnus-message 6 "Expiring articles...")
6864 ;; The list of articles that weren't expired is returned.
6866 (let ((nnmail-expiry-wait-function nil)
6867 (nnmail-expiry-wait expiry-wait))
6868 (setq es (gnus-request-expire-articles
6869 expirable gnus-newsgroup-name)))
6870 (setq es (gnus-request-expire-articles
6871 expirable gnus-newsgroup-name)))
6873 (setq gnus-newsgroup-expirable es))
6874 ;; We go through the old list of expirable, and mark all
6875 ;; really expired articles as nonexistent.
6876 (unless (eq es expirable) ;If nothing was expired, we don't mark.
6877 (let ((gnus-use-cache nil))
6879 (unless (memq (car expirable) es)
6880 (when (gnus-data-find (car expirable))
6881 (gnus-summary-mark-article
6882 (car expirable) gnus-canceled-mark)))
6883 (setq expirable (cdr expirable)))))
6884 (gnus-message 6 "Expiring articles...done")))))
6886 (defun gnus-summary-expire-articles-now ()
6887 "Expunge all expirable articles in the current group.
6888 This means that *all* articles that are marked as expirable will be
6889 deleted forever, right now."
6891 (gnus-set-global-variables)
6892 (or gnus-expert-user
6894 "Are you really, really, really sure you want to delete all these messages? ")
6896 (gnus-summary-expire-articles t))
6898 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6899 (defun gnus-summary-delete-article (&optional n)
6900 "Delete the N next (mail) articles.
6901 This command actually deletes articles. This is not a marking
6902 command. The article will disappear forever from your life, never to
6904 If N is negative, delete backwards.
6905 If N is nil and articles have been marked with the process mark,
6906 delete these instead."
6908 (gnus-set-global-variables)
6909 (unless (gnus-check-backend-function 'request-expire-articles
6910 gnus-newsgroup-name)
6911 (error "The current newsgroup does not support article deletion."))
6912 ;; Compute the list of articles to delete.
6913 (let ((articles (gnus-summary-work-articles n))
6915 (if (and gnus-novice-user
6917 (format "Do you really want to delete %s forever? "
6918 (if (> (length articles) 1)
6919 (format "these %s articles" (length articles))
6922 ;; Delete the articles.
6923 (setq not-deleted (gnus-request-expire-articles
6924 articles gnus-newsgroup-name 'force))
6926 (gnus-summary-remove-process-mark (car articles))
6927 ;; The backend might not have been able to delete the article
6929 (unless (memq (car articles) not-deleted)
6930 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
6931 (setq articles (cdr articles))))
6932 (gnus-summary-position-point)
6933 (gnus-set-mode-line 'summary)
6936 (defun gnus-summary-edit-article (&optional force)
6937 "Edit the current article.
6938 This will have permanent effect only in mail groups.
6939 If FORCE is non-nil, allow editing of articles even in read-only
6943 (set-buffer gnus-summary-buffer)
6944 (gnus-set-global-variables)
6945 (when (and (not force)
6946 (gnus-group-read-only-p))
6947 (error "The current newsgroup does not support article editing."))
6948 ;; Select article if needed.
6949 (unless (eq (gnus-summary-article-number)
6950 gnus-current-article)
6951 (gnus-summary-select-article t))
6952 (gnus-article-edit-article
6954 (gnus-summary-edit-article-done
6955 ,(or (mail-header-references gnus-current-headers) "")
6956 ,(gnus-group-read-only-p) ,gnus-summary-buffer)))))
6958 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
6960 (defun gnus-summary-edit-article-done (&optional references read-only buffer)
6961 "Make edits to the current article permanent."
6963 ;; Replace the article.
6964 (if (and (not read-only)
6965 (not (gnus-request-replace-article
6966 (cdr gnus-article-current) (car gnus-article-current)
6968 (error "Couldn't replace article.")
6969 ;; Update the summary buffer.
6971 (equal (message-tokenize-header references " ")
6972 (message-tokenize-header
6973 (or (message-fetch-field "references") "") " ")))
6974 ;; We only have to update this line.
6977 (message-narrow-to-head)
6978 (let ((header (nnheader-parse-head t)))
6980 (mail-header-set-number header (cdr gnus-article-current))
6981 (gnus-summary-update-article-line
6982 (cdr gnus-article-current) header))))
6984 (set-buffer (or buffer gnus-summary-buffer))
6985 (gnus-summary-update-article (cdr gnus-article-current)))
6986 ;; Prettify the article buffer again.
6988 (set-buffer gnus-article-buffer)
6989 (run-hooks 'gnus-article-display-hook))
6990 ;; Prettify the summary buffer line.
6991 (when (gnus-visual-p 'summary-highlight 'highlight)
6992 (run-hooks 'gnus-visual-mark-article-hook))))
6994 (defun gnus-summary-edit-wash (key)
6995 "Perform editing command in the article buffer."
6999 (message "%s" (concat (this-command-keys) "- "))
7002 (gnus-summary-edit-article)
7003 (execute-kbd-macro (concat (this-command-keys) key))
7004 (gnus-article-edit-done))
7008 (defun gnus-summary-respool-query ()
7009 "Query where the respool algorithm would put this article."
7011 (gnus-set-global-variables)
7012 (gnus-summary-select-article)
7014 (set-buffer gnus-article-buffer)
7016 (goto-char (point-min))
7017 (search-forward "\n\n")
7018 (narrow-to-region (point-min) (point))
7019 (message "This message would go to %s"
7020 (mapconcat 'car (nnmail-article-group 'identity) ", ")))))
7022 ;; Summary marking commands.
7024 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
7025 "Mark articles which has the same subject as read, and then select the next.
7026 If UNMARK is positive, remove any kind of mark.
7027 If UNMARK is negative, tick articles."
7029 (gnus-set-global-variables)
7031 (setq unmark (prefix-numeric-value unmark)))
7033 (gnus-summary-mark-same-subject
7034 (gnus-summary-article-subject) unmark)))
7035 ;; Select next unread article. If auto-select-same mode, should
7036 ;; select the first unread article.
7037 (gnus-summary-next-article t (and gnus-auto-select-same
7038 (gnus-summary-article-subject)))
7039 (gnus-message 7 "%d article%s marked as %s"
7040 count (if (= count 1) " is" "s are")
7041 (if unmark "unread" "read"))))
7043 (defun gnus-summary-kill-same-subject (&optional unmark)
7044 "Mark articles which has the same subject as read.
7045 If UNMARK is positive, remove any kind of mark.
7046 If UNMARK is negative, tick articles."
7048 (gnus-set-global-variables)
7050 (setq unmark (prefix-numeric-value unmark)))
7052 (gnus-summary-mark-same-subject
7053 (gnus-summary-article-subject) unmark)))
7054 ;; If marked as read, go to next unread subject.
7056 ;; Go to next unread subject.
7057 (gnus-summary-next-subject 1 t))
7058 (gnus-message 7 "%d articles are marked as %s"
7059 count (if unmark "unread" "read"))))
7061 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7062 "Mark articles with same SUBJECT as read, and return marked number.
7063 If optional argument UNMARK is positive, remove any kinds of marks.
7064 If optional argument UNMARK is negative, mark articles as unread instead."
7068 ((null unmark) ; Mark as read.
7071 (gnus-summary-mark-article-as-read gnus-killed-mark)
7072 (gnus-summary-show-thread) t)
7073 (gnus-summary-find-subject subject))
7074 (setq count (1+ count))))
7075 ((> unmark 0) ; Tick.
7078 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
7079 (gnus-summary-show-thread) t)
7080 (gnus-summary-find-subject subject))
7081 (setq count (1+ count))))
7082 (t ; Mark as unread.
7085 (gnus-summary-mark-article-as-unread gnus-unread-mark)
7086 (gnus-summary-show-thread) t)
7087 (gnus-summary-find-subject subject))
7088 (setq count (1+ count)))))
7089 (gnus-set-mode-line 'summary)
7090 ;; Return the number of marked articles.
7093 (defun gnus-summary-mark-as-processable (n &optional unmark)
7094 "Set the process mark on the next N articles.
7095 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7096 the process mark instead. The difference between N and the actual
7097 number of articles marked is returned."
7099 (gnus-set-global-variables)
7100 (let ((backward (< n 0))
7105 (gnus-summary-remove-process-mark
7106 (gnus-summary-article-number))
7107 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7108 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7111 (gnus-message 7 "No more articles"))
7112 (gnus-summary-recenter)
7113 (gnus-summary-position-point)
7116 (defun gnus-summary-unmark-as-processable (n)
7117 "Remove the process mark from the next N articles.
7118 If N is negative, mark backward instead. The difference between N and
7119 the actual number of articles marked is returned."
7121 (gnus-set-global-variables)
7122 (gnus-summary-mark-as-processable n t))
7124 (defun gnus-summary-unmark-all-processable ()
7125 "Remove the process mark from all articles."
7127 (gnus-set-global-variables)
7129 (while gnus-newsgroup-processable
7130 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7131 (gnus-summary-position-point))
7133 (defun gnus-summary-mark-as-expirable (n)
7134 "Mark N articles forward as expirable.
7135 If N is negative, mark backward instead. The difference between N and
7136 the actual number of articles marked is returned."
7138 (gnus-set-global-variables)
7139 (gnus-summary-mark-forward n gnus-expirable-mark))
7141 (defun gnus-summary-mark-article-as-replied (article)
7142 "Mark ARTICLE replied and update the summary line."
7143 (push article gnus-newsgroup-replied)
7144 (let ((buffer-read-only nil))
7145 (when (gnus-summary-goto-subject article)
7146 (gnus-summary-update-secondary-mark article))))
7148 (defun gnus-summary-set-bookmark (article)
7149 "Set a bookmark in current article."
7150 (interactive (list (gnus-summary-article-number)))
7151 (gnus-set-global-variables)
7152 (when (or (not (get-buffer gnus-article-buffer))
7153 (not gnus-current-article)
7154 (not gnus-article-current)
7155 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7156 (error "No current article selected"))
7157 ;; Remove old bookmark, if one exists.
7158 (let ((old (assq article gnus-newsgroup-bookmarks)))
7160 (setq gnus-newsgroup-bookmarks
7161 (delq old gnus-newsgroup-bookmarks))))
7162 ;; Set the new bookmark, which is on the form
7163 ;; (article-number . line-number-in-body).
7167 (set-buffer gnus-article-buffer)
7171 (goto-char (point-min))
7172 (search-forward "\n\n" nil t)
7175 gnus-newsgroup-bookmarks)
7176 (gnus-message 6 "A bookmark has been added to the current article."))
7178 (defun gnus-summary-remove-bookmark (article)
7179 "Remove the bookmark from the current article."
7180 (interactive (list (gnus-summary-article-number)))
7181 (gnus-set-global-variables)
7182 ;; Remove old bookmark, if one exists.
7183 (let ((old (assq article gnus-newsgroup-bookmarks)))
7186 (setq gnus-newsgroup-bookmarks
7187 (delq old gnus-newsgroup-bookmarks))
7188 (gnus-message 6 "Removed bookmark."))
7189 (gnus-message 6 "No bookmark in current article."))))
7191 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7192 (defun gnus-summary-mark-as-dormant (n)
7193 "Mark N articles forward as dormant.
7194 If N is negative, mark backward instead. The difference between N and
7195 the actual number of articles marked is returned."
7197 (gnus-set-global-variables)
7198 (gnus-summary-mark-forward n gnus-dormant-mark))
7200 (defun gnus-summary-set-process-mark (article)
7201 "Set the process mark on ARTICLE and update the summary line."
7202 (setq gnus-newsgroup-processable
7204 (delq article gnus-newsgroup-processable)))
7205 (when (gnus-summary-goto-subject article)
7206 (gnus-summary-show-thread)
7207 (gnus-summary-update-secondary-mark article)))
7209 (defun gnus-summary-remove-process-mark (article)
7210 "Remove the process mark from ARTICLE and update the summary line."
7211 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7212 (when (gnus-summary-goto-subject article)
7213 (gnus-summary-show-thread)
7214 (gnus-summary-update-secondary-mark article)))
7216 (defun gnus-summary-set-saved-mark (article)
7217 "Set the process mark on ARTICLE and update the summary line."
7218 (push article gnus-newsgroup-saved)
7219 (when (gnus-summary-goto-subject article)
7220 (gnus-summary-update-secondary-mark article)))
7222 (defun gnus-summary-mark-forward (n &optional mark no-expire)
7223 "Mark N articles as read forwards.
7224 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
7225 The difference between N and the actual number of articles marked is
7228 (gnus-set-global-variables)
7229 (let ((backward (< n 0))
7230 (gnus-summary-goto-unread
7231 (and gnus-summary-goto-unread
7232 (not (eq gnus-summary-goto-unread 'never))
7233 (not (memq mark (list gnus-unread-mark
7234 gnus-ticked-mark gnus-dormant-mark)))))
7236 (mark (or mark gnus-del-mark)))
7238 (gnus-summary-mark-article nil mark no-expire)
7239 (zerop (gnus-summary-next-subject
7241 (and gnus-summary-goto-unread
7242 (not (eq gnus-summary-goto-unread 'never)))
7246 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
7247 (gnus-summary-recenter)
7248 (gnus-summary-position-point)
7249 (gnus-set-mode-line 'summary)
7252 (defun gnus-summary-mark-article-as-read (mark)
7253 "Mark the current article quickly as read with MARK."
7254 (let ((article (gnus-summary-article-number)))
7255 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7256 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7257 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7258 (push (cons article mark) gnus-newsgroup-reads)
7259 ;; Possibly remove from cache, if that is used.
7260 (when gnus-use-cache
7261 (gnus-cache-enter-remove-article article))
7262 ;; Allow the backend to change the mark.
7263 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7264 ;; Check for auto-expiry.
7265 (when (and gnus-newsgroup-auto-expire
7266 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7267 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7268 (= mark gnus-ancient-mark)
7269 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7270 (= mark gnus-duplicate-mark)))
7271 (setq mark gnus-expirable-mark)
7272 (push article gnus-newsgroup-expirable))
7273 ;; Set the mark in the buffer.
7274 (gnus-summary-update-mark mark 'unread)
7277 (defun gnus-summary-mark-article-as-unread (mark)
7278 "Mark the current article quickly as unread with MARK."
7279 (let ((article (gnus-summary-article-number)))
7281 (gnus-error 1 "Unmarkable article")
7282 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7283 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7284 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
7285 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
7286 (cond ((= mark gnus-ticked-mark)
7287 (push article gnus-newsgroup-marked))
7288 ((= mark gnus-dormant-mark)
7289 (push article gnus-newsgroup-dormant))
7291 (push article gnus-newsgroup-unreads)))
7292 (setq gnus-newsgroup-reads
7293 (delq (assq article gnus-newsgroup-reads)
7294 gnus-newsgroup-reads))
7296 ;; See whether the article is to be put in the cache.
7298 (vectorp (gnus-summary-article-header article))
7300 (gnus-cache-possibly-enter-article
7301 gnus-newsgroup-name article
7302 (gnus-summary-article-header article)
7303 (= mark gnus-ticked-mark)
7304 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7307 (gnus-summary-update-mark mark 'unread))
7310 (defun gnus-summary-mark-article (&optional article mark no-expire)
7311 "Mark ARTICLE with MARK. MARK can be any character.
7312 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
7313 `??' (dormant) and `?E' (expirable).
7314 If MARK is nil, then the default character `?D' is used.
7315 If ARTICLE is nil, then the article on the current line will be
7317 ;; The mark might be a string.
7318 (when (stringp mark)
7319 (setq mark (aref mark 0)))
7320 ;; If no mark is given, then we check auto-expiring.
7321 (and (not no-expire)
7322 gnus-newsgroup-auto-expire
7325 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7326 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7327 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7328 (= mark gnus-duplicate-mark))))
7329 (setq mark gnus-expirable-mark))
7330 (let* ((mark (or mark gnus-del-mark))
7331 (article (or article (gnus-summary-article-number))))
7333 (error "No article on current line"))
7334 (if (or (= mark gnus-unread-mark)
7335 (= mark gnus-ticked-mark)
7336 (= mark gnus-dormant-mark))
7337 (gnus-mark-article-as-unread article mark)
7338 (gnus-mark-article-as-read article mark))
7340 ;; See whether the article is to be put in the cache.
7342 (not (= mark gnus-canceled-mark))
7343 (vectorp (gnus-summary-article-header article))
7345 (gnus-cache-possibly-enter-article
7346 gnus-newsgroup-name article
7347 (gnus-summary-article-header article)
7348 (= mark gnus-ticked-mark)
7349 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7351 (when (gnus-summary-goto-subject article nil t)
7352 (let ((buffer-read-only nil))
7353 (gnus-summary-show-thread)
7355 (gnus-summary-update-mark mark 'unread)
7358 (defun gnus-summary-update-secondary-mark (article)
7359 "Update the secondary (read, process, cache) mark."
7360 (gnus-summary-update-mark
7361 (cond ((memq article gnus-newsgroup-processable)
7363 ((memq article gnus-newsgroup-cached)
7365 ((memq article gnus-newsgroup-replied)
7367 ((memq article gnus-newsgroup-saved)
7369 (t gnus-unread-mark))
7371 (when (gnus-visual-p 'summary-highlight 'highlight)
7372 (run-hooks 'gnus-summary-update-hook))
7375 (defun gnus-summary-update-mark (mark type)
7376 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
7377 (buffer-read-only nil))
7378 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
7379 (when (looking-at "\r")
7382 (<= (+ forward (point)) (point-max)))
7383 ;; Go to the right position on the line.
7384 (goto-char (+ forward (point)))
7385 ;; Replace the old mark with the new mark.
7386 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
7387 ;; Optionally update the marks by some user rule.
7388 (when (eq type 'unread)
7390 (gnus-data-find (gnus-summary-article-number)) mark)
7391 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
7393 (defun gnus-mark-article-as-read (article &optional mark)
7394 "Enter ARTICLE in the pertinent lists and remove it from others."
7395 ;; Make the article expirable.
7396 (let ((mark (or mark gnus-del-mark)))
7397 (if (= mark gnus-expirable-mark)
7398 (push article gnus-newsgroup-expirable)
7399 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
7400 ;; Remove from unread and marked lists.
7401 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7402 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7403 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7404 (push (cons article mark) gnus-newsgroup-reads)
7405 ;; Possibly remove from cache, if that is used.
7406 (when gnus-use-cache
7407 (gnus-cache-enter-remove-article article))))
7409 (defun gnus-mark-article-as-unread (article &optional mark)
7410 "Enter ARTICLE in the pertinent lists and remove it from others."
7411 (let ((mark (or mark gnus-ticked-mark)))
7412 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
7413 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
7414 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
7415 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7417 ;; Unsuppress duplicates?
7418 (when gnus-suppress-duplicates
7419 (gnus-dup-unsuppress-article article))
7421 (cond ((= mark gnus-ticked-mark)
7422 (push article gnus-newsgroup-marked))
7423 ((= mark gnus-dormant-mark)
7424 (push article gnus-newsgroup-dormant))
7426 (push article gnus-newsgroup-unreads)))
7427 (setq gnus-newsgroup-reads
7428 (delq (assq article gnus-newsgroup-reads)
7429 gnus-newsgroup-reads))))
7431 (defalias 'gnus-summary-mark-as-unread-forward
7432 'gnus-summary-tick-article-forward)
7433 (make-obsolete 'gnus-summary-mark-as-unread-forward
7434 'gnus-summary-tick-article-forward)
7435 (defun gnus-summary-tick-article-forward (n)
7436 "Tick N articles forwards.
7437 If N is negative, tick backwards instead.
7438 The difference between N and the number of articles ticked is returned."
7440 (gnus-summary-mark-forward n gnus-ticked-mark))
7442 (defalias 'gnus-summary-mark-as-unread-backward
7443 'gnus-summary-tick-article-backward)
7444 (make-obsolete 'gnus-summary-mark-as-unread-backward
7445 'gnus-summary-tick-article-backward)
7446 (defun gnus-summary-tick-article-backward (n)
7447 "Tick N articles backwards.
7448 The difference between N and the number of articles ticked is returned."
7450 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
7452 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7453 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7454 (defun gnus-summary-tick-article (&optional article clear-mark)
7455 "Mark current article as unread.
7456 Optional 1st argument ARTICLE specifies article number to be marked as unread.
7457 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
7459 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
7462 (defun gnus-summary-mark-as-read-forward (n)
7463 "Mark N articles as read forwards.
7464 If N is negative, mark backwards instead.
7465 The difference between N and the actual number of articles marked is
7468 (gnus-summary-mark-forward n gnus-del-mark t))
7470 (defun gnus-summary-mark-as-read-backward (n)
7471 "Mark the N articles as read backwards.
7472 The difference between N and the actual number of articles marked is
7475 (gnus-summary-mark-forward (- n) gnus-del-mark t))
7477 (defun gnus-summary-mark-as-read (&optional article mark)
7478 "Mark current article as read.
7479 ARTICLE specifies the article to be marked as read.
7480 MARK specifies a string to be inserted at the beginning of the line."
7481 (gnus-summary-mark-article article mark))
7483 (defun gnus-summary-clear-mark-forward (n)
7484 "Clear marks from N articles forward.
7485 If N is negative, clear backward instead.
7486 The difference between N and the number of marks cleared is returned."
7488 (gnus-summary-mark-forward n gnus-unread-mark))
7490 (defun gnus-summary-clear-mark-backward (n)
7491 "Clear marks from N articles backward.
7492 The difference between N and the number of marks cleared is returned."
7494 (gnus-summary-mark-forward (- n) gnus-unread-mark))
7496 (defun gnus-summary-mark-unread-as-read ()
7497 "Intended to be used by `gnus-summary-mark-article-hook'."
7498 (when (memq gnus-current-article gnus-newsgroup-unreads)
7499 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
7501 (defun gnus-summary-mark-read-and-unread-as-read ()
7502 "Intended to be used by `gnus-summary-mark-article-hook'."
7503 (let ((mark (gnus-summary-article-mark)))
7504 (when (or (gnus-unread-mark-p mark)
7505 (gnus-read-mark-p mark))
7506 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
7508 (defun gnus-summary-mark-region-as-read (point mark all)
7509 "Mark all unread articles between point and mark as read.
7510 If given a prefix, mark all articles between point and mark as read,
7511 even ticked and dormant ones."
7512 (interactive "r\nP")
7521 (memq (setq article (gnus-summary-article-number))
7522 gnus-newsgroup-unreads))
7523 (gnus-summary-mark-article article gnus-del-mark))
7525 (gnus-summary-find-next))))))
7527 (defun gnus-summary-mark-below (score mark)
7528 "Mark articles with score less than SCORE with MARK."
7529 (interactive "P\ncMark: ")
7530 (gnus-set-global-variables)
7531 (setq score (if score
7532 (prefix-numeric-value score)
7533 (or gnus-summary-default-score 0)))
7535 (set-buffer gnus-summary-buffer)
7536 (goto-char (point-min))
7539 (and (< (gnus-summary-article-score) score)
7540 (gnus-summary-mark-article nil mark))
7541 (gnus-summary-find-next)))))
7543 (defun gnus-summary-kill-below (&optional score)
7544 "Mark articles with score below SCORE as read."
7546 (gnus-set-global-variables)
7547 (gnus-summary-mark-below score gnus-killed-mark))
7549 (defun gnus-summary-clear-above (&optional score)
7550 "Clear all marks from articles with score above SCORE."
7552 (gnus-set-global-variables)
7553 (gnus-summary-mark-above score gnus-unread-mark))
7555 (defun gnus-summary-tick-above (&optional score)
7556 "Tick all articles with score above SCORE."
7558 (gnus-set-global-variables)
7559 (gnus-summary-mark-above score gnus-ticked-mark))
7561 (defun gnus-summary-mark-above (score mark)
7562 "Mark articles with score over SCORE with MARK."
7563 (interactive "P\ncMark: ")
7564 (gnus-set-global-variables)
7565 (setq score (if score
7566 (prefix-numeric-value score)
7567 (or gnus-summary-default-score 0)))
7569 (set-buffer gnus-summary-buffer)
7570 (goto-char (point-min))
7572 (when (> (gnus-summary-article-score) score)
7573 (gnus-summary-mark-article nil mark))
7575 (gnus-summary-find-next)))))
7577 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7578 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
7579 (defun gnus-summary-limit-include-expunged (&optional no-error)
7580 "Display all the hidden articles that were expunged for low scores."
7582 (gnus-set-global-variables)
7583 (let ((buffer-read-only nil))
7584 (let ((scored gnus-newsgroup-scored)
7587 (unless (gnus-summary-goto-subject (caar scored))
7588 (and (setq h (gnus-summary-article-header (caar scored)))
7589 (< (cdar scored) gnus-summary-expunge-below)
7591 (setq scored (cdr scored)))
7593 (when (not no-error)
7594 (error "No expunged articles hidden."))
7595 (goto-char (point-min))
7596 (gnus-summary-prepare-unthreaded (nreverse headers))
7597 (goto-char (point-min))
7598 (gnus-summary-position-point)
7601 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
7602 "Mark all articles not marked as unread in this newsgroup as read.
7603 If prefix argument ALL is non-nil, all articles are marked as read.
7604 If QUIETLY is non-nil, no questions will be asked.
7605 If TO-HERE is non-nil, it should be a point in the buffer. All
7606 articles before this point will be marked as read.
7607 The number of articles marked as read is returned."
7609 (gnus-set-global-variables)
7613 (not gnus-interactive-catchup) ;Without confirmation?
7617 "Mark absolutely all articles as read? "
7618 "Mark all unread articles as read? ")))
7620 (not gnus-newsgroup-adaptive)
7621 (not gnus-newsgroup-auto-expire)
7622 (not gnus-suppress-duplicates))
7625 (setq gnus-newsgroup-marked nil
7626 gnus-newsgroup-dormant nil))
7627 (setq gnus-newsgroup-unreads nil))
7628 ;; We actually mark all articles as canceled, which we
7629 ;; have to do when using auto-expiry or adaptive scoring.
7630 (gnus-summary-show-all-threads)
7631 (when (gnus-summary-first-subject (not all))
7633 (if to-here (< (point) to-here) t)
7634 (gnus-summary-mark-article-as-read gnus-catchup-mark)
7635 (gnus-summary-find-next (not all)))))
7637 (setq gnus-newsgroup-unreads nil))
7638 (gnus-set-mode-line 'summary))
7639 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
7640 (when (and (not to-here) (eq 'nnvirtual (car method)))
7641 (nnvirtual-catchup-group
7642 (gnus-group-real-name gnus-newsgroup-name)
7643 (nth 1 method) all)))
7645 (gnus-summary-position-point)))
7647 (defun gnus-summary-catchup-to-here (&optional all)
7648 "Mark all unticked articles before the current one as read.
7649 If ALL is non-nil, also mark ticked and dormant articles as read."
7651 (gnus-set-global-variables)
7653 (gnus-save-hidden-threads
7654 (let ((beg (point)))
7655 ;; We check that there are unread articles.
7656 (when (or all (gnus-summary-find-prev))
7657 (gnus-summary-catchup all t beg)))))
7658 (gnus-summary-position-point))
7660 (defun gnus-summary-catchup-all (&optional quietly)
7661 "Mark all articles in this newsgroup as read."
7663 (gnus-set-global-variables)
7664 (gnus-summary-catchup t quietly))
7666 (defun gnus-summary-catchup-and-exit (&optional all quietly)
7667 "Mark all articles not marked as unread in this newsgroup as read, then exit.
7668 If prefix argument ALL is non-nil, all articles are marked as read."
7670 (gnus-set-global-variables)
7671 (when (gnus-summary-catchup all quietly nil 'fast)
7672 ;; Select next newsgroup or exit.
7673 (if (eq gnus-auto-select-next 'quietly)
7674 (gnus-summary-next-group nil)
7675 (gnus-summary-exit))))
7677 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
7678 "Mark all articles in this newsgroup as read, and then exit."
7680 (gnus-set-global-variables)
7681 (gnus-summary-catchup-and-exit t quietly))
7683 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
7684 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
7685 "Mark all articles in this group as read and select the next group.
7686 If given a prefix, mark all articles, unread as well as ticked, as
7689 (gnus-set-global-variables)
7691 (gnus-summary-catchup all))
7692 (gnus-summary-next-article t nil nil t))
7694 ;; Thread-based commands.
7696 (defun gnus-summary-articles-in-thread (&optional article)
7697 "Return a list of all articles in the current thread.
7698 If ARTICLE is non-nil, return all articles in the thread that starts
7700 (let* ((article (or article (gnus-summary-article-number)))
7701 (data (gnus-data-find-list article))
7702 (top-level (gnus-data-level (car data)))
7704 (cond ((null gnus-thread-operation-ignore-subject)
7705 (gnus-simplify-subject-re
7706 (mail-header-subject (gnus-data-header (car data)))))
7707 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
7708 (gnus-simplify-subject-fuzzy
7709 (mail-header-subject (gnus-data-header (car data)))))
7711 (end-point (save-excursion
7712 (if (gnus-summary-go-to-next-thread)
7713 (point) (point-max))))
7716 (< (gnus-data-pos (car data)) end-point))
7717 (when (or (not top-subject)
7718 (string= top-subject
7719 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
7720 (gnus-simplify-subject-fuzzy
7721 (mail-header-subject
7722 (gnus-data-header (car data))))
7723 (gnus-simplify-subject-re
7724 (mail-header-subject
7725 (gnus-data-header (car data)))))))
7726 (push (gnus-data-number (car data)) articles))
7727 (unless (and (setq data (cdr data))
7728 (> (gnus-data-level (car data)) top-level))
7730 ;; Return the list of articles.
7731 (nreverse articles)))
7733 (defun gnus-summary-rethread-current ()
7734 "Rethread the thread the current article is part of."
7736 (gnus-set-global-variables)
7737 (let* ((gnus-show-threads t)
7738 (article (gnus-summary-article-number))
7739 (id (mail-header-id (gnus-summary-article-header)))
7740 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
7742 (error "No article on the current line"))
7743 (gnus-rebuild-thread id)
7744 (gnus-summary-goto-subject article)))
7746 (defun gnus-summary-reparent-thread ()
7747 "Make current article child of the marked (or previous) article.
7749 Note that the re-threading will only work if `gnus-thread-ignore-subject'
7750 is non-nil or the Subject: of both articles are the same."
7752 (unless (not (gnus-group-read-only-p))
7753 (error "The current newsgroup does not support article editing."))
7754 (unless (<= (length gnus-newsgroup-processable) 1)
7755 (error "No more than one article may be marked."))
7756 (save-window-excursion
7757 (let ((gnus-article-buffer " *reparent*")
7758 (current-article (gnus-summary-article-number))
7759 ; first grab the marked article, otherwise one line up.
7760 (parent-article (if (not (null gnus-newsgroup-processable))
7761 (car gnus-newsgroup-processable)
7763 (if (eq (forward-line -1) 0)
7764 (gnus-summary-article-number)
7765 (error "Beginning of summary buffer."))))))
7766 (unless (not (eq current-article parent-article))
7767 (error "An article may not be self-referential."))
7768 (let ((message-id (mail-header-id
7769 (gnus-summary-article-header parent-article))))
7770 (unless (and message-id (not (equal message-id "")))
7771 (error "No message-id in desired parent."))
7772 (gnus-summary-select-article t t nil current-article)
7773 (set-buffer gnus-article-buffer)
7774 (setq buffer-read-only nil)
7775 (let ((buf (format "%s" (buffer-string))))
7778 (goto-char (point-min))
7779 (if (search-forward-regexp "^References: " nil t)
7780 (insert message-id " " )
7781 (insert "References: " message-id "\n"))
7782 (unless (gnus-request-replace-article current-article
7783 (car gnus-article-current)
7784 gnus-article-buffer)
7785 (error "Couldn't replace article."))
7786 (set-buffer gnus-summary-buffer)
7787 (gnus-summary-unmark-all-processable)
7788 (gnus-summary-rethread-current)
7789 (gnus-message 3 "Article %d is now the child of article %d."
7790 current-article parent-article)))))
7792 (defun gnus-summary-toggle-threads (&optional arg)
7793 "Toggle showing conversation threads.
7794 If ARG is positive number, turn showing conversation threads on."
7796 (gnus-set-global-variables)
7797 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
7798 (setq gnus-show-threads
7799 (if (null arg) (not gnus-show-threads)
7800 (> (prefix-numeric-value arg) 0)))
7801 (gnus-summary-prepare)
7802 (gnus-summary-goto-subject current)
7803 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
7804 (gnus-summary-position-point)))
7806 (defun gnus-summary-show-all-threads ()
7809 (gnus-set-global-variables)
7811 (let ((buffer-read-only nil))
7812 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
7813 (gnus-summary-position-point))
7815 (defun gnus-summary-show-thread ()
7816 "Show thread subtrees.
7817 Returns nil if no thread was there to be shown."
7819 (gnus-set-global-variables)
7820 (let ((buffer-read-only nil)
7822 ;; first goto end then to beg, to have point at beg after let
7823 (end (progn (end-of-line) (point)))
7824 (beg (progn (beginning-of-line) (point))))
7826 ;; Any hidden lines here?
7827 (search-forward "\r" end t)
7828 (subst-char-in-region beg end ?\^M ?\n t)
7830 (gnus-summary-position-point))))
7832 (defun gnus-summary-hide-all-threads ()
7833 "Hide all thread subtrees."
7835 (gnus-set-global-variables)
7837 (goto-char (point-min))
7838 (gnus-summary-hide-thread)
7839 (while (zerop (gnus-summary-next-thread 1 t))
7840 (gnus-summary-hide-thread)))
7841 (gnus-summary-position-point))
7843 (defun gnus-summary-hide-thread ()
7844 "Hide thread subtrees.
7845 Returns nil if no threads were there to be hidden."
7847 (gnus-set-global-variables)
7848 (let ((buffer-read-only nil)
7850 (article (gnus-summary-article-number)))
7852 ;; Go forward until either the buffer ends or the subthread
7854 (when (and (not (eobp))
7855 (or (zerop (gnus-summary-next-thread 1 t))
7856 (goto-char (point-max))))
7858 (if (and (> (point) start)
7859 (search-backward "\n" start t))
7861 (subst-char-in-region start (point) ?\n ?\^M)
7862 (gnus-summary-goto-subject article))
7865 ;;(gnus-summary-position-point)
7868 (defun gnus-summary-go-to-next-thread (&optional previous)
7869 "Go to the same level (or less) next thread.
7870 If PREVIOUS is non-nil, go to previous thread instead.
7871 Return the article number moved to, or nil if moving was impossible."
7872 (let ((level (gnus-summary-thread-level))
7873 (way (if previous -1 1))
7876 (while (and (not (eobp))
7877 (< level (gnus-summary-thread-level)))
7885 (gnus-summary-article-number)
7888 (defun gnus-summary-next-thread (n &optional silent)
7889 "Go to the same level next N'th thread.
7890 If N is negative, search backward instead.
7891 Returns the difference between N and the number of skips actually
7894 If SILENT, don't output messages."
7896 (gnus-set-global-variables)
7897 (let ((backward (< n 0))
7900 (gnus-summary-go-to-next-thread backward))
7903 (gnus-summary-position-point))
7904 (when (and (not silent) (/= 0 n))
7905 (gnus-message 7 "No more threads"))
7908 (defun gnus-summary-prev-thread (n)
7909 "Go to the same level previous N'th thread.
7910 Returns the difference between N and the number of skips actually
7913 (gnus-set-global-variables)
7914 (gnus-summary-next-thread (- n)))
7916 (defun gnus-summary-go-down-thread ()
7917 "Go down one level in the current thread."
7918 (let ((children (gnus-summary-article-children)))
7920 (gnus-summary-goto-subject (car children)))))
7922 (defun gnus-summary-go-up-thread ()
7923 "Go up one level in the current thread."
7924 (let ((parent (gnus-summary-article-parent)))
7926 (gnus-summary-goto-subject parent))))
7928 (defun gnus-summary-down-thread (n)
7929 "Go down thread N steps.
7930 If N is negative, go up instead.
7931 Returns the difference between N and how many steps down that were
7934 (gnus-set-global-variables)
7938 (if up (gnus-summary-go-up-thread)
7939 (gnus-summary-go-down-thread)))
7941 (gnus-summary-position-point)
7943 (gnus-message 7 "Can't go further"))
7946 (defun gnus-summary-up-thread (n)
7947 "Go up thread N steps.
7948 If N is negative, go up instead.
7949 Returns the difference between N and how many steps down that were
7952 (gnus-set-global-variables)
7953 (gnus-summary-down-thread (- n)))
7955 (defun gnus-summary-top-thread ()
7956 "Go to the top of the thread."
7958 (gnus-set-global-variables)
7959 (while (gnus-summary-go-up-thread))
7960 (gnus-summary-article-number))
7962 (defun gnus-summary-kill-thread (&optional unmark)
7963 "Mark articles under current thread as read.
7964 If the prefix argument is positive, remove any kinds of marks.
7965 If the prefix argument is negative, tick articles instead."
7967 (gnus-set-global-variables)
7969 (setq unmark (prefix-numeric-value unmark)))
7970 (let ((articles (gnus-summary-articles-in-thread)))
7972 ;; Expand the thread.
7973 (gnus-summary-show-thread)
7974 ;; Mark all the articles.
7976 (gnus-summary-goto-subject (car articles))
7977 (cond ((null unmark)
7978 (gnus-summary-mark-article-as-read gnus-killed-mark))
7980 (gnus-summary-mark-article-as-unread gnus-unread-mark))
7982 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
7983 (setq articles (cdr articles))))
7984 ;; Hide killed subtrees.
7986 gnus-thread-hide-killed
7987 (gnus-summary-hide-thread))
7988 ;; If marked as read, go to next unread subject.
7990 ;; Go to next unread subject.
7991 (gnus-summary-next-subject 1 t)))
7992 (gnus-set-mode-line 'summary))
7994 ;; Summary sorting commands
7996 (defun gnus-summary-sort-by-number (&optional reverse)
7997 "Sort the summary buffer by article number.
7998 Argument REVERSE means reverse order."
8000 (gnus-summary-sort 'number reverse))
8002 (defun gnus-summary-sort-by-author (&optional reverse)
8003 "Sort the summary buffer by author name alphabetically.
8004 If case-fold-search is non-nil, case of letters is ignored.
8005 Argument REVERSE means reverse order."
8007 (gnus-summary-sort 'author reverse))
8009 (defun gnus-summary-sort-by-subject (&optional reverse)
8010 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8011 If case-fold-search is non-nil, case of letters is ignored.
8012 Argument REVERSE means reverse order."
8014 (gnus-summary-sort 'subject reverse))
8016 (defun gnus-summary-sort-by-date (&optional reverse)
8017 "Sort the summary buffer by date.
8018 Argument REVERSE means reverse order."
8020 (gnus-summary-sort 'date reverse))
8022 (defun gnus-summary-sort-by-score (&optional reverse)
8023 "Sort the summary buffer by score.
8024 Argument REVERSE means reverse order."
8026 (gnus-summary-sort 'score reverse))
8028 (defun gnus-summary-sort-by-lines (&optional reverse)
8029 "Sort the summary buffer by article length.
8030 Argument REVERSE means reverse order."
8032 (gnus-summary-sort 'lines reverse))
8034 (defun gnus-summary-sort (predicate reverse)
8035 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
8036 (gnus-set-global-variables)
8037 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
8038 (article (intern (format "gnus-article-sort-by-%s" predicate)))
8039 (gnus-thread-sort-functions
8045 (gnus-article-sort-functions
8050 (,article t2 t1)))))
8052 (gnus-summary-prepare-hook nil))
8053 ;; We do the sorting by regenerating the threads.
8054 (gnus-summary-prepare)
8055 ;; Hide subthreads if needed.
8056 (when (and gnus-show-threads gnus-thread-hide-subtree)
8057 (gnus-summary-hide-all-threads))))
8059 ;; Summary saving commands.
8061 (defun gnus-summary-save-article (&optional n not-saved)
8062 "Save the current article using the default saver function.
8063 If N is a positive number, save the N next articles.
8064 If N is a negative number, save the N previous articles.
8065 If N is nil and any articles have been marked with the process mark,
8066 save those articles instead.
8067 The variable `gnus-default-article-saver' specifies the saver function."
8069 (gnus-set-global-variables)
8070 (let* ((articles (gnus-summary-work-articles n))
8071 (save-buffer (save-excursion
8072 (nnheader-set-temp-buffer " *Gnus Save*")))
8073 (num (length articles))
8074 header article file)
8076 (setq header (gnus-summary-article-header
8077 (setq article (pop articles))))
8078 (if (not (vectorp header))
8079 ;; This is a pseudo-article.
8080 (if (assq 'name header)
8081 (gnus-copy-file (cdr (assq 'name header)))
8082 (gnus-message 1 "Article %d is unsaveable" article))
8083 ;; This is a real article.
8084 (save-window-excursion
8085 (gnus-summary-select-article t nil nil article))
8087 (set-buffer save-buffer)
8089 (insert-buffer-substring gnus-original-article-buffer))
8090 (setq file (gnus-article-save save-buffer file num))
8091 (gnus-summary-remove-process-mark article)
8093 (gnus-summary-set-saved-mark article))))
8094 (gnus-kill-buffer save-buffer)
8095 (gnus-summary-position-point)
8098 (defun gnus-summary-pipe-output (&optional arg)
8099 "Pipe the current article to a subprocess.
8100 If N is a positive number, pipe the N next articles.
8101 If N is a negative number, pipe the N previous articles.
8102 If N is nil and any articles have been marked with the process mark,
8103 pipe those articles instead."
8105 (gnus-set-global-variables)
8106 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8107 (gnus-summary-save-article arg t))
8108 (gnus-configure-windows 'pipe))
8110 (defun gnus-summary-save-article-mail (&optional arg)
8111 "Append the current article to an mail file.
8112 If N is a positive number, save the N next articles.
8113 If N is a negative number, save the N previous articles.
8114 If N is nil and any articles have been marked with the process mark,
8115 save those articles instead."
8117 (gnus-set-global-variables)
8118 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8119 (gnus-summary-save-article arg)))
8121 (defun gnus-summary-save-article-rmail (&optional arg)
8122 "Append the current article to an rmail file.
8123 If N is a positive number, save the N next articles.
8124 If N is a negative number, save the N previous articles.
8125 If N is nil and any articles have been marked with the process mark,
8126 save those articles instead."
8128 (gnus-set-global-variables)
8129 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
8130 (gnus-summary-save-article arg)))
8132 (defun gnus-summary-save-article-file (&optional arg)
8133 "Append the current article to a file.
8134 If N is a positive number, save the N next articles.
8135 If N is a negative number, save the N previous articles.
8136 If N is nil and any articles have been marked with the process mark,
8137 save those articles instead."
8139 (gnus-set-global-variables)
8140 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8141 (gnus-summary-save-article arg)))
8143 (defun gnus-summary-write-article-file (&optional arg)
8144 "Write the current article to a file, deleting the previous file.
8145 If N is a positive number, save the N next articles.
8146 If N is a negative number, save the N previous articles.
8147 If N is nil and any articles have been marked with the process mark,
8148 save those articles instead."
8150 (gnus-set-global-variables)
8151 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
8152 (gnus-summary-save-article arg)))
8154 (defun gnus-summary-save-article-body-file (&optional arg)
8155 "Append the current article body to a file.
8156 If N is a positive number, save the N next articles.
8157 If N is a negative number, save the N previous articles.
8158 If N is nil and any articles have been marked with the process mark,
8159 save those articles instead."
8161 (gnus-set-global-variables)
8162 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
8163 (gnus-summary-save-article arg)))
8165 (defun gnus-get-split-value (methods)
8166 "Return a value based on the split METHODS."
8167 (let (split-name method result match)
8170 (set-buffer gnus-original-article-buffer)
8172 (nnheader-narrow-to-headers)
8174 (goto-char (point-min))
8175 (setq method (pop methods))
8176 (setq match (car method))
8179 ;; Regular expression.
8181 (re-search-forward match nil t)))
8182 ((gnus-functionp match)
8186 (setq result (funcall match gnus-newsgroup-name))))
8191 (setq result (eval match)))))
8192 (setq split-name (append (cdr method) split-name))
8193 (cond ((stringp result)
8194 (push (expand-file-name
8195 result gnus-article-save-directory)
8198 (setq split-name (append result split-name)))))))))
8201 (defun gnus-valid-move-group-p (group)
8206 (car (gnus-find-method-for-group
8207 (symbol-name group))))
8208 gnus-valid-select-methods))))
8210 (defun gnus-read-move-group-name (prompt default articles prefix)
8211 "Read a group name."
8212 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
8213 (minibuffer-confirm-incomplete nil) ; XEmacs
8217 (if (> (length articles) 1)
8218 (format "these %d articles" (length articles))
8223 (gnus-completing-read default prom
8225 'gnus-valid-move-group-p
8227 'gnus-group-history))
8228 ((= 1 (length split-name))
8229 (gnus-completing-read (car split-name) prom
8231 'gnus-valid-move-group-p
8233 'gnus-group-history))
8235 (gnus-completing-read nil prom
8236 (mapcar (lambda (el) (list el))
8237 (nreverse split-name))
8239 'gnus-group-history)))))
8241 (if (or (string= to-newsgroup "")
8242 (string= to-newsgroup prefix))
8243 (setq to-newsgroup (or default "")))
8244 (or (gnus-active to-newsgroup)
8245 (gnus-activate-group to-newsgroup)
8246 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
8248 (or (and (gnus-request-create-group
8249 to-newsgroup (gnus-group-name-to-method to-newsgroup))
8250 (gnus-activate-group to-newsgroup nil nil
8251 (gnus-group-name-to-method
8253 (error "Couldn't create group %s" to-newsgroup)))
8254 (error "No such group: %s" to-newsgroup)))
8257 ;; Summary extract commands
8259 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
8260 (let ((buffer-read-only nil)
8261 (article (gnus-summary-article-number))
8263 (unless (gnus-summary-goto-subject article)
8264 (error "No such article: %d" article))
8265 (gnus-summary-position-point)
8266 ;; If all commands are to be bunched up on one line, we collect
8268 (unless gnus-view-pseudos-separately
8269 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
8272 (setq action (cdr (assq 'action (car ps))))
8273 (setq files (list (cdr (assq 'name (car ps)))))
8274 (while (and ps (cdr ps)
8275 (string= (or action "1")
8276 (or (cdr (assq 'action (cadr ps))) "2")))
8277 (push (cdr (assq 'name (cadr ps))) files)
8278 (setcdr ps (cddr ps)))
8280 (when (not (string-match "%s" action))
8283 (when (assq 'execute (car ps))
8284 (setcdr (assq 'execute (car ps))
8285 (funcall (if (string-match "%s" action)
8288 (mapconcat (lambda (f) f) files " ")))))
8289 (setq ps (cdr ps)))))
8290 (if (and gnus-view-pseudos (not not-view))
8292 (when (assq 'execute (car pslist))
8293 (gnus-execute-command (cdr (assq 'execute (car pslist)))
8294 (eq gnus-view-pseudos 'not-confirm)))
8295 (setq pslist (cdr pslist)))
8298 (setq after-article (or (cdr (assq 'article (car pslist)))
8299 (gnus-summary-article-number)))
8300 (gnus-summary-goto-subject after-article)
8303 (insert " " (file-name-nondirectory
8304 (cdr (assq 'name (car pslist))))
8305 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
8307 (forward-line -1) ; back to `b'
8308 (gnus-add-text-properties
8309 b (1- e) (list 'gnus-number gnus-reffed-article-number
8310 gnus-mouse-face-prop gnus-mouse-face))
8312 after-article gnus-reffed-article-number
8313 gnus-unread-mark b (car pslist) 0 (- e b))
8314 (push gnus-reffed-article-number gnus-newsgroup-unreads)
8315 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
8316 (setq pslist (cdr pslist)))))))
8318 (defun gnus-pseudos< (p1 p2)
8319 (let ((c1 (cdr (assq 'action p1)))
8320 (c2 (cdr (assq 'action p2))))
8321 (and c1 c2 (string< c1 c2))))
8323 (defun gnus-request-pseudo-article (props)
8324 (cond ((assq 'execute props)
8325 (gnus-execute-command (cdr (assq 'execute props)))))
8326 (let ((gnus-current-article (gnus-summary-article-number)))
8327 (run-hooks 'gnus-mark-article-hook)))
8329 (defun gnus-execute-command (command &optional automatic)
8331 (gnus-article-setup-buffer)
8332 (set-buffer gnus-article-buffer)
8333 (setq buffer-read-only nil)
8334 (let ((command (if automatic command (read-string "Command: " command)))
8335 ;; Just binding this here doesn't help, because there might
8336 ;; be output from the process after exiting the scope of
8338 ;; (buffer-read-only nil)
8341 (insert "$ " command "\n\n")
8342 (if gnus-view-pseudo-asynchronously
8343 (start-process "gnus-execute" nil shell-file-name
8344 shell-command-switch command)
8345 (call-process shell-file-name nil t nil
8346 shell-command-switch command)))))
8348 ;; Summary kill commands.
8350 (defun gnus-summary-edit-global-kill (article)
8351 "Edit the \"global\" kill file."
8352 (interactive (list (gnus-summary-article-number)))
8353 (gnus-set-global-variables)
8354 (gnus-group-edit-global-kill article))
8356 (defun gnus-summary-edit-local-kill ()
8357 "Edit a local kill file applied to the current newsgroup."
8359 (gnus-set-global-variables)
8360 (setq gnus-current-headers (gnus-summary-article-header))
8361 (gnus-set-global-variables)
8362 (gnus-group-edit-local-kill
8363 (gnus-summary-article-number) gnus-newsgroup-name))
8367 (defun gnus-read-header (id &optional header)
8368 "Read the headers of article ID and enter them into the Gnus system."
8369 (let ((group gnus-newsgroup-name)
8370 (gnus-override-method
8371 (and (gnus-news-group-p gnus-newsgroup-name)
8372 gnus-refer-article-method))
8374 ;; First we check to see whether the header in question is already
8377 ;; This is a Message-ID.
8378 (setq header (or header (gnus-id-to-header id)))
8379 ;; This is an article number.
8380 (setq header (or header (gnus-summary-article-header id))))
8382 (not (gnus-summary-article-sparse-p (mail-header-number header))))
8383 ;; We have found the header.
8385 ;; We have to really fetch the header to this article.
8387 (set-buffer nntp-server-buffer)
8388 (when (setq where (gnus-request-head id group))
8389 (nnheader-fold-continuation-lines)
8390 (goto-char (point-max))
8392 (goto-char (point-min))
8396 ((cdr where) (cdr where))
8397 (header (mail-header-number header))
8398 (t gnus-reffed-article-number))
8400 (insert " Article retrieved.\n"))
8401 (if (not (setq header (car (gnus-get-newsgroup-headers nil t))))
8402 () ; Malformed head.
8403 (unless (gnus-summary-article-sparse-p (mail-header-number header))
8404 (when (and (stringp id)
8405 (not (string= (gnus-group-real-name group)
8407 ;; If we fetched by Message-ID and the article came
8408 ;; from a different group, we fudge some bogus article
8409 ;; numbers for this article.
8410 (mail-header-set-number header gnus-reffed-article-number))
8412 (set-buffer gnus-summary-buffer)
8413 (decf gnus-reffed-article-number)
8414 (gnus-remove-header (mail-header-number header))
8415 (push header gnus-newsgroup-headers)
8416 (setq gnus-current-headers header)
8417 (push (mail-header-number header) gnus-newsgroup-limit)))
8420 (defun gnus-remove-header (number)
8421 "Remove header NUMBER from `gnus-newsgroup-headers'."
8422 (if (and gnus-newsgroup-headers
8423 (= number (mail-header-number (car gnus-newsgroup-headers))))
8424 (pop gnus-newsgroup-headers)
8425 (let ((headers gnus-newsgroup-headers))
8426 (while (and (cdr headers)
8427 (not (= number (mail-header-number (cadr headers)))))
8430 (setcdr headers (cddr headers))))))
8433 ;;; summary highlights
8436 (defun gnus-highlight-selected-summary ()
8437 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8438 ;; Highlight selected article in summary buffer
8439 (when gnus-summary-selected-face
8441 (let* ((beg (progn (beginning-of-line) (point)))
8442 (end (progn (end-of-line) (point)))
8443 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
8444 (from (if (get-text-property beg gnus-mouse-face-prop)
8446 (or (next-single-property-change
8447 beg gnus-mouse-face-prop nil end)
8452 (or (next-single-property-change
8453 from gnus-mouse-face-prop nil end)
8455 ;; If no mouse-face prop on line we will have to = from = end,
8456 ;; so we highlight the entire line instead.
8457 (when (= (+ to 2) from)
8460 (if gnus-newsgroup-selected-overlay
8461 ;; Move old overlay.
8463 gnus-newsgroup-selected-overlay from to (current-buffer))
8464 ;; Create new overlay.
8466 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
8467 'face gnus-summary-selected-face))))))
8469 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
8470 (defun gnus-summary-highlight-line ()
8471 "Highlight current line according to `gnus-summary-highlight'."
8472 (let* ((list gnus-summary-highlight)
8474 (end (progn (end-of-line) (point)))
8475 ;; now find out where the line starts and leave point there.
8476 (beg (progn (beginning-of-line) (point)))
8477 (article (gnus-summary-article-number))
8478 (score (or (cdr (assq (or article gnus-current-article)
8479 gnus-newsgroup-scored))
8480 gnus-summary-default-score 0))
8481 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
8482 (inhibit-read-only t))
8483 ;; Eval the cars of the lists until we find a match.
8484 (let ((default gnus-summary-default-score))
8486 (not (eval (caar list))))
8487 (setq list (cdr list))))
8488 (let ((face (cdar list)))
8489 (unless (eq face (get-text-property beg 'face))
8490 (gnus-put-text-property
8492 (setq face (if (boundp face) (symbol-value face) face)))
8493 (when gnus-summary-highlight-line-function
8494 (funcall gnus-summary-highlight-line-function article face))))
8497 (defun gnus-update-read-articles (group unread)
8498 "Update the list of read articles in GROUP."
8499 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
8500 (entry (gnus-gethash group gnus-newsrc-hashtb))
8501 (info (nth 2 entry))
8503 (unread (sort (copy-sequence unread) '<))
8505 (if (or (not info) (not active))
8506 ;; There is no info on this group if it was, in fact,
8507 ;; killed. Gnus stores no information on killed groups, so
8508 ;; there's nothing to be done.
8509 ;; One could store the information somewhere temporarily,
8510 ;; perhaps... Hmmm...
8512 ;; Remove any negative articles numbers.
8513 (while (and unread (< (car unread) 0))
8514 (setq unread (cdr unread)))
8515 ;; Remove any expired article numbers
8516 (while (and unread (< (car unread) (car active)))
8517 (setq unread (cdr unread)))
8518 ;; Compute the ranges of read articles by looking at the list of
8521 (when (/= (car unread) prev)
8522 (push (if (= prev (1- (car unread))) prev
8523 (cons prev (1- (car unread))))
8525 (setq prev (1+ (car unread)))
8526 (setq unread (cdr unread)))
8527 (when (<= prev (cdr active))
8528 (push (cons prev (cdr active)) read))
8530 (set-buffer gnus-group-buffer)
8533 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
8534 (gnus-info-set-read ',info ',(gnus-info-read info))
8535 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
8536 (gnus-group-update-group ,group t))))
8537 ;; Enter this list into the group info.
8539 info (if (> (length read) 1) (nreverse read) read))
8540 ;; Set the number of unread articles in gnus-newsrc-hashtb.
8541 (gnus-get-unread-articles-in-group info (gnus-active group))
8546 (run-hooks 'gnus-sum-load-hook)
8548 ;;; gnus-sum.el ends here