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.
36 (defgroup gnus-summary nil
40 (defcustom gnus-kill-summary-on-exit t
41 "*If non-nil, kill the summary buffer when you exit from it.
42 If nil, the summary will become a \"*Dead Summary*\" buffer, and
43 it will be killed sometime later."
47 (defcustom gnus-fetch-old-headers nil
48 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
49 If an unread article in the group refers to an older, already read (or
50 just marked as read) article, the old article will not normally be
51 displayed in the Summary buffer. If this variable is non-nil, Gnus
52 will attempt to grab the headers to the old articles, and thereby
53 build complete threads. If it has the value `some', only enough
54 headers to connect otherwise loose threads will be displayed.
55 This variable can also be a number. In that case, no more than that
56 number of old headers will be fetched.
58 The server has to support NOV for any of this to work."
60 :type '(choice (const :tag "off" nil)
63 (sexp :menu-tag "other" t)))
65 (defcustom gnus-summary-make-false-root 'adopt
66 "*nil means that Gnus won't gather loose threads.
67 If the root of a thread has expired or been read in a previous
68 session, the information necessary to build a complete thread has been
69 lost. Instead of having many small sub-threads from this original thread
70 scattered all over the summary buffer, Gnus can gather them.
72 If non-nil, Gnus will try to gather all loose sub-threads from an
73 original thread into one large thread.
75 If this variable is non-nil, it should be one of `none', `adopt',
78 If this variable is `none', Gnus will not make a false root, but just
79 present the sub-threads after another.
80 If this variable is `dummy', Gnus will create a dummy root that will
81 have all the sub-threads as children.
82 If this variable is `adopt', Gnus will make one of the \"children\"
83 the parent and mark all the step-children as such.
84 If this variable is `empty', the \"children\" are printed with empty
85 subject fields. (Or rather, they will be printed with a string
86 given by the `gnus-summary-same-subject' variable.)"
88 :type '(choice (const :tag "off" nil)
94 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
95 "*A regexp to match subjects to be excluded from loose thread gathering.
96 As loose thread gathering is done on subjects only, that means that
97 there can be many false gatherings performed. By rooting out certain
98 common subjects, gathering might become saner."
102 (defcustom gnus-summary-gather-subject-limit nil
103 "*Maximum length of subject comparisons when gathering loose threads.
104 Use nil to compare full subjects. Setting this variable to a low
105 number will help gather threads that have been corrupted by
106 newsreaders chopping off subject lines, but it might also mean that
107 unrelated articles that have subject that happen to begin with the
108 same few characters will be incorrectly gathered.
110 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
113 :type '(choice (const :tag "off" nil)
115 (sexp :menu-tag "on" t)))
117 (defcustom gnus-simplify-ignored-prefixes nil
118 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
120 :type '(choice (const :tag "off" nil)
123 (defcustom gnus-build-sparse-threads nil
124 "*If non-nil, fill in the gaps in threads.
125 If `some', only fill in the gaps that are needed to tie loose threads
126 together. If `more', fill in all leaf nodes that Gnus can find. If
127 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
129 :type '(choice (const :tag "off" nil)
132 (sexp :menu-tag "all" t)))
134 (defcustom gnus-summary-thread-gathering-function 'gnus-gather-threads-by-subject
135 "Function used for gathering loose threads.
136 There are two pre-defined functions: `gnus-gather-threads-by-subject',
137 which only takes Subjects into consideration; and
138 `gnus-gather-threads-by-references', which compared the References
139 headers of the articles to find matches."
141 :type '(set (function-item gnus-gather-threads-by-subject)
142 (function-item gnus-gather-threads-by-references)
143 (function :tag "other")))
145 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
146 (defcustom gnus-summary-same-subject ""
147 "*String indicating that the current article has the same subject as the previous.
148 This variable will only be used if the value of
149 `gnus-summary-make-false-root' is `empty'."
153 (defcustom gnus-summary-goto-unread t
154 "*If non-nil, marking commands will go to the next unread article.
155 If `never', \\<gnus-summary-mode-map>\\[gnus-summary-next-page] will go to the next article,
156 whether it is read or not."
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 "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 (:foreground "PaleGreen" :bold t))
740 (:foreground "DarkGreen" :bold t))
743 "Face used for high interest unread articles.")
745 (defface gnus-summary-low-unread-face
748 (:foreground "PaleGreen" :italic t))
751 (:foreground "DarkGreen" :italic t))
754 "Face used for low interest unread articles.")
756 (defface gnus-summary-normal-unread-face
759 (:foreground "PaleGreen"))
762 (:foreground "DarkGreen"))
765 "Face used for normal interest unread articles.")
767 (defface gnus-summary-high-read-face
770 "Face used for high interest read articles.")
772 (defface gnus-summary-low-read-face
775 "Face used for low interest read articles.")
777 (defface gnus-summary-normal-read-face
780 "Face used for normal interest read articles.")
782 (defcustom gnus-summary-highlight
783 '(((= mark gnus-canceled-mark)
784 . gnus-summary-cancelled-face)
785 ((and (> score default)
786 (or (= mark gnus-dormant-mark)
787 (= mark gnus-ticked-mark)))
788 . gnus-summary-high-ticked-face)
789 ((and (< score default)
790 (or (= mark gnus-dormant-mark)
791 (= mark gnus-ticked-mark)))
792 . gnus-summary-low-ticked-face)
793 ((or (= mark gnus-dormant-mark)
794 (= mark gnus-ticked-mark))
795 . gnus-summary-normal-ticked-face)
796 ((and (> score default) (= mark gnus-ancient-mark))
797 . gnus-summary-high-ancient-face)
798 ((and (< score default) (= mark gnus-ancient-mark))
799 . gnus-summary-low-ancient-face)
800 ((= mark gnus-ancient-mark)
801 . gnus-summary-normal-ancient-face)
802 ((and (> score default) (= mark gnus-unread-mark))
803 . gnus-summary-high-unread-face)
804 ((and (< score default) (= mark gnus-unread-mark))
805 . gnus-summary-low-unread-face)
806 ((and (= mark gnus-unread-mark))
807 . gnus-summary-normal-unread-face)
809 . gnus-summary-high-read-face)
811 . gnus-summary-low-read-face)
813 . gnus-summary-normal-read-face))
814 "Controls the highlighting of summary buffer lines.
816 A list of (FORM . FACE) pairs. When deciding how a a particular
817 summary line should be displayed, each form is evaluated. The content
818 of the face field after the first true form is used. You can change
819 how those summary lines are displayed, by editing the face field.
821 You can use the following variables in the FORM field.
823 score: The articles score
824 default: The default article score.
825 below: The score below which articles are automatically marked as read.
826 mark: The articles mark."
828 :type '(repeat (cons (sexp :tag "Form" nil)
831 ;;; Internal variables
833 (defvar gnus-scores-exclude-files nil)
835 (defvar gnus-summary-display-table
836 ;; Change the display table. Odd characters have a tendency to mess
837 ;; up nicely formatted displays - we make all possible glyphs
838 ;; display only a single character.
840 ;; We start from the standard display table, if any.
841 (let ((table (or (copy-sequence standard-display-table)
842 (make-display-table)))
843 ;; Nix out all the control chars...
845 (while (>= (setq i (1- i)) 0)
847 ;; ... but not newline and cr, of course. (cr is necessary for the
848 ;; selective display).
851 ;; We nix out any glyphs over 126 that are not set already.
853 (while (>= (setq i (1- i)) 127)
854 ;; Only modify if the entry is nil.
856 (aset table i [??]))))
858 "Display table used in summary mode buffers.")
860 (defvar gnus-original-article nil)
861 (defvar gnus-article-internal-prepare-hook nil)
862 (defvar gnus-newsgroup-process-stack nil)
864 (defvar gnus-thread-indent-array nil)
865 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
867 ;; Avoid highlighting in kill files.
868 (defvar gnus-summary-inhibit-highlight nil)
869 (defvar gnus-newsgroup-selected-overlay nil)
870 (defvar gnus-inhibit-limiting nil)
871 (defvar gnus-newsgroup-adaptive-score-file nil)
872 (defvar gnus-current-score-file nil)
873 (defvar gnus-current-move-group nil)
874 (defvar gnus-current-copy-group nil)
875 (defvar gnus-current-crosspost-group nil)
877 (defvar gnus-newsgroup-dependencies nil)
878 (defvar gnus-newsgroup-adaptive nil)
879 (defvar gnus-summary-display-article-function nil)
880 (defvar gnus-summary-highlight-line-function nil
881 "Function called after highlighting a summary line.")
883 (defvar gnus-summary-line-format-alist
884 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
885 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
886 (?s gnus-tmp-subject-or-nil ?s)
887 (?n gnus-tmp-name ?s)
888 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
890 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
892 (?F gnus-tmp-from ?s)
893 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
894 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
895 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
896 (?o (gnus-date-iso8601 gnus-tmp-header) ?s)
897 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
898 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
899 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
900 (?L gnus-tmp-lines ?d)
901 (?I gnus-tmp-indentation ?s)
902 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
903 (?R gnus-tmp-replied ?c)
904 (?\[ gnus-tmp-opening-bracket ?c)
905 (?\] gnus-tmp-closing-bracket ?c)
906 (?\> (make-string gnus-tmp-level ? ) ?s)
907 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
908 (?i gnus-tmp-score ?d)
909 (?z gnus-tmp-score-char ?c)
910 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
911 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
912 (?U gnus-tmp-unread ?c)
913 (?t (gnus-summary-number-of-articles-in-thread
914 (and (boundp 'thread) (car thread)) gnus-tmp-level)
916 (?e (gnus-summary-number-of-articles-in-thread
917 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
919 (?u gnus-tmp-user-defined ?s)
920 (?P (gnus-pick-line-number) ?d))
921 "An alist of format specifications that can appear in summary lines,
922 and what variables they correspond with, along with the type of the
923 variable (string, integer, character, etc).")
925 (defvar gnus-summary-dummy-line-format-alist
926 `((?S gnus-tmp-subject ?s)
927 (?N gnus-tmp-number ?d)
928 (?u gnus-tmp-user-defined ?s)))
930 (defvar gnus-summary-mode-line-format-alist
931 `((?G gnus-tmp-group-name ?s)
932 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
933 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
934 (?A gnus-tmp-article-number ?d)
935 (?Z gnus-tmp-unread-and-unselected ?s)
937 (?U gnus-tmp-unread-and-unticked ?d)
938 (?S gnus-tmp-subject ?s)
939 (?e gnus-tmp-unselected ?d)
940 (?u gnus-tmp-user-defined ?s)
941 (?d (length gnus-newsgroup-dormant) ?d)
942 (?t (length gnus-newsgroup-marked) ?d)
943 (?r (length gnus-newsgroup-reads) ?d)
944 (?E gnus-newsgroup-expunged-tally ?d)
945 (?s (gnus-current-score-file-nondirectory) ?s)))
947 (defvar gnus-last-search-regexp nil
948 "Default regexp for article search command.")
950 (defvar gnus-last-shell-command nil
951 "Default shell command on article.")
953 (defvar gnus-newsgroup-begin nil)
954 (defvar gnus-newsgroup-end nil)
955 (defvar gnus-newsgroup-last-rmail nil)
956 (defvar gnus-newsgroup-last-mail nil)
957 (defvar gnus-newsgroup-last-folder nil)
958 (defvar gnus-newsgroup-last-file nil)
959 (defvar gnus-newsgroup-auto-expire nil)
960 (defvar gnus-newsgroup-active nil)
962 (defvar gnus-newsgroup-data nil)
963 (defvar gnus-newsgroup-data-reverse nil)
964 (defvar gnus-newsgroup-limit nil)
965 (defvar gnus-newsgroup-limits nil)
967 (defvar gnus-newsgroup-unreads nil
968 "List of unread articles in the current newsgroup.")
970 (defvar gnus-newsgroup-unselected nil
971 "List of unselected unread articles in the current newsgroup.")
973 (defvar gnus-newsgroup-reads nil
974 "Alist of read articles and article marks in the current newsgroup.")
976 (defvar gnus-newsgroup-expunged-tally nil)
978 (defvar gnus-newsgroup-marked nil
979 "List of ticked articles in the current newsgroup (a subset of unread art).")
981 (defvar gnus-newsgroup-killed nil
982 "List of ranges of articles that have been through the scoring process.")
984 (defvar gnus-newsgroup-cached nil
985 "List of articles that come from the article cache.")
987 (defvar gnus-newsgroup-saved nil
988 "List of articles that have been saved.")
990 (defvar gnus-newsgroup-kill-headers nil)
992 (defvar gnus-newsgroup-replied nil
993 "List of articles that have been replied to in the current newsgroup.")
995 (defvar gnus-newsgroup-expirable nil
996 "List of articles in the current newsgroup that can be expired.")
998 (defvar gnus-newsgroup-processable nil
999 "List of articles in the current newsgroup that can be processed.")
1001 (defvar gnus-newsgroup-bookmarks nil
1002 "List of articles in the current newsgroup that have bookmarks.")
1004 (defvar gnus-newsgroup-dormant nil
1005 "List of dormant articles in the current newsgroup.")
1007 (defvar gnus-newsgroup-scored nil
1008 "List of scored articles in the current newsgroup.")
1010 (defvar gnus-newsgroup-headers nil
1011 "List of article headers in the current newsgroup.")
1013 (defvar gnus-newsgroup-threads nil)
1015 (defvar gnus-newsgroup-prepared nil
1016 "Whether the current group has been prepared properly.")
1018 (defvar gnus-newsgroup-ancient nil
1019 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1021 (defvar gnus-newsgroup-sparse nil)
1023 (defvar gnus-current-article nil)
1024 (defvar gnus-article-current nil)
1025 (defvar gnus-current-headers nil)
1026 (defvar gnus-have-all-headers nil)
1027 (defvar gnus-last-article nil)
1028 (defvar gnus-newsgroup-history nil)
1030 (defconst gnus-summary-local-variables
1031 '(gnus-newsgroup-name
1032 gnus-newsgroup-begin gnus-newsgroup-end
1033 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1034 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1035 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1036 gnus-newsgroup-unselected gnus-newsgroup-marked
1037 gnus-newsgroup-reads gnus-newsgroup-saved
1038 gnus-newsgroup-replied gnus-newsgroup-expirable
1039 gnus-newsgroup-processable gnus-newsgroup-killed
1040 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1041 gnus-newsgroup-headers gnus-newsgroup-threads
1042 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1043 gnus-current-article gnus-current-headers gnus-have-all-headers
1044 gnus-last-article gnus-article-internal-prepare-hook
1045 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1046 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1047 gnus-thread-expunge-below
1048 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1049 (gnus-summary-mark-below . global)
1050 gnus-newsgroup-active gnus-scores-exclude-files
1051 gnus-newsgroup-history gnus-newsgroup-ancient
1052 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1053 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1054 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1055 (gnus-newsgroup-expunged-tally . 0)
1056 gnus-cache-removable-articles gnus-newsgroup-cached
1057 gnus-newsgroup-data gnus-newsgroup-data-reverse
1058 gnus-newsgroup-limit gnus-newsgroup-limits)
1059 "Variables that are buffer-local to the summary buffers.")
1061 ;; Byte-compiler warning.
1062 (defvar gnus-article-mode-map)
1064 ;; Subject simplification.
1066 (defsubst gnus-simplify-subject-re (subject)
1067 "Remove \"Re:\" from subject lines."
1068 (if (string-match "^[Rr][Ee]: *" subject)
1069 (substring subject (match-end 0))
1072 (defun gnus-simplify-subject (subject &optional re-only)
1073 "Remove `Re:' and words in parentheses.
1074 If RE-ONLY is non-nil, strip leading `Re:'s only."
1075 (let ((case-fold-search t)) ;Ignore case.
1076 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1077 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1078 (setq subject (substring subject (match-end 0))))
1079 ;; Remove uninteresting prefixes.
1080 (when (and (not re-only)
1081 gnus-simplify-ignored-prefixes
1082 (string-match gnus-simplify-ignored-prefixes subject))
1083 (setq subject (substring subject (match-end 0))))
1084 ;; Remove words in parentheses from end.
1086 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1087 (setq subject (substring subject 0 (match-beginning 0)))))
1088 ;; Return subject string.
1091 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1093 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
1094 (defun gnus-simplify-buffer-fuzzy ()
1095 (let ((case-fold-search t))
1096 (goto-char (point-min))
1097 (while (search-forward "\t" nil t)
1098 (replace-match " " t t))
1099 (goto-char (point-min))
1100 (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *" nil t)
1101 (goto-char (match-beginning 0))
1103 (looking-at "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1104 (looking-at "^[[].*: .*[]]$"))
1105 (goto-char (point-min))
1106 (while (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *"
1108 (replace-match "" t t))
1109 (goto-char (point-min))
1110 (while (re-search-forward "^[[].*: .*[]]$" nil t)
1111 (goto-char (match-end 0))
1114 (progn (goto-char (match-beginning 0)))
1115 (re-search-forward ":"))))
1116 (goto-char (point-min))
1117 (while (re-search-forward " *[[{(][^()\n]*[]})] *$" nil t)
1118 (replace-match "" t t))
1119 (goto-char (point-min))
1120 (while (re-search-forward " +" nil t)
1121 (replace-match " " t t))
1122 (goto-char (point-min))
1123 (while (re-search-forward " $" nil t)
1124 (replace-match "" t t))
1125 (goto-char (point-min))
1126 (while (re-search-forward "^ +" nil t)
1127 (replace-match "" t t))
1128 (goto-char (point-min))
1129 (when gnus-simplify-subject-fuzzy-regexp
1130 (if (listp gnus-simplify-subject-fuzzy-regexp)
1131 (let ((list gnus-simplify-subject-fuzzy-regexp))
1133 (goto-char (point-min))
1134 (while (re-search-forward (car list) nil t)
1135 (replace-match "" t t))
1136 (setq list (cdr list))))
1137 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
1138 (replace-match "" t t))))))
1140 (defun gnus-simplify-subject-fuzzy (subject)
1141 "Simplify a subject string fuzzily."
1143 (gnus-set-work-buffer)
1144 (let ((case-fold-search t))
1146 (inline (gnus-simplify-buffer-fuzzy))
1149 (defsubst gnus-simplify-subject-fully (subject)
1150 "Simplify a subject string according to the user's wishes."
1152 ((null gnus-summary-gather-subject-limit)
1153 (gnus-simplify-subject-re subject))
1154 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1155 (gnus-simplify-subject-fuzzy subject))
1156 ((numberp gnus-summary-gather-subject-limit)
1157 (gnus-limit-string (gnus-simplify-subject-re subject)
1158 gnus-summary-gather-subject-limit))
1162 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1163 "Check whether two subjects are equal. If optional argument
1164 simple-first is t, first argument is already simplified."
1166 ((null simple-first)
1167 (equal (gnus-simplify-subject-fully s1)
1168 (gnus-simplify-subject-fully s2)))
1171 (gnus-simplify-subject-fully s2)))))
1173 (defun gnus-offer-save-summaries ()
1174 "Offer to save all active summary buffers."
1176 (let ((buflist (buffer-list))
1178 ;; Go through all buffers and find all summaries.
1180 (and (setq bufname (buffer-name (car buflist)))
1181 (string-match "Summary" bufname)
1183 (set-buffer bufname)
1184 ;; We check that this is, indeed, a summary buffer.
1185 (and (eq major-mode 'gnus-summary-mode)
1186 ;; Also make sure this isn't bogus.
1187 gnus-newsgroup-prepared))
1188 (push bufname buffers))
1189 (setq buflist (cdr buflist)))
1190 ;; Go through all these summary buffers and offer to save them.
1193 "Update summary buffer %s? "
1194 (lambda (buf) (set-buffer buf) (gnus-summary-exit))
1197 (defun gnus-summary-bubble-group ()
1198 "Increase the score of the current group.
1199 This is a handy function to add to `gnus-summary-exit-hook' to
1200 increase the score of each group you read."
1201 (gnus-group-add-score gnus-newsgroup-name))
1205 ;;; Gnus summary mode
1208 (put 'gnus-summary-mode 'mode-class 'special)
1211 ;; Non-orthogonal keys
1213 (gnus-define-keys gnus-summary-mode-map
1214 " " gnus-summary-next-page
1215 "\177" gnus-summary-prev-page
1216 [delete] gnus-summary-prev-page
1217 "\r" gnus-summary-scroll-up
1218 "n" gnus-summary-next-unread-article
1219 "p" gnus-summary-prev-unread-article
1220 "N" gnus-summary-next-article
1221 "P" gnus-summary-prev-article
1222 "\M-\C-n" gnus-summary-next-same-subject
1223 "\M-\C-p" gnus-summary-prev-same-subject
1224 "\M-n" gnus-summary-next-unread-subject
1225 "\M-p" gnus-summary-prev-unread-subject
1226 "." gnus-summary-first-unread-article
1227 "," gnus-summary-best-unread-article
1228 "\M-s" gnus-summary-search-article-forward
1229 "\M-r" gnus-summary-search-article-backward
1230 "<" gnus-summary-beginning-of-article
1231 ">" gnus-summary-end-of-article
1232 "j" gnus-summary-goto-article
1233 "^" gnus-summary-refer-parent-article
1234 "\M-^" gnus-summary-refer-article
1235 "u" gnus-summary-tick-article-forward
1236 "!" gnus-summary-tick-article-forward
1237 "U" gnus-summary-tick-article-backward
1238 "d" gnus-summary-mark-as-read-forward
1239 "D" gnus-summary-mark-as-read-backward
1240 "E" gnus-summary-mark-as-expirable
1241 "\M-u" gnus-summary-clear-mark-forward
1242 "\M-U" gnus-summary-clear-mark-backward
1243 "k" gnus-summary-kill-same-subject-and-select
1244 "\C-k" gnus-summary-kill-same-subject
1245 "\M-\C-k" gnus-summary-kill-thread
1246 "\M-\C-l" gnus-summary-lower-thread
1247 "e" gnus-summary-edit-article
1248 "#" gnus-summary-mark-as-processable
1249 "\M-#" gnus-summary-unmark-as-processable
1250 "\M-\C-t" gnus-summary-toggle-threads
1251 "\M-\C-s" gnus-summary-show-thread
1252 "\M-\C-h" gnus-summary-hide-thread
1253 "\M-\C-f" gnus-summary-next-thread
1254 "\M-\C-b" gnus-summary-prev-thread
1255 "\M-\C-u" gnus-summary-up-thread
1256 "\M-\C-d" gnus-summary-down-thread
1257 "&" gnus-summary-execute-command
1258 "c" gnus-summary-catchup-and-exit
1259 "\C-w" gnus-summary-mark-region-as-read
1260 "\C-t" gnus-summary-toggle-truncation
1261 "?" gnus-summary-mark-as-dormant
1262 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1263 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1264 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1265 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1266 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1267 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1268 "=" gnus-summary-expand-window
1269 "\C-x\C-s" gnus-summary-reselect-current-group
1270 "\M-g" gnus-summary-rescan-group
1271 "w" gnus-summary-stop-page-breaking
1272 "\C-c\C-r" gnus-summary-caesar-message
1273 "\M-t" gnus-summary-toggle-mime
1274 "f" gnus-summary-followup
1275 "F" gnus-summary-followup-with-original
1276 "C" gnus-summary-cancel-article
1277 "r" gnus-summary-reply
1278 "R" gnus-summary-reply-with-original
1279 "\C-c\C-f" gnus-summary-mail-forward
1280 "o" gnus-summary-save-article
1281 "\C-o" gnus-summary-save-article-mail
1282 "|" gnus-summary-pipe-output
1283 "\M-k" gnus-summary-edit-local-kill
1284 "\M-K" gnus-summary-edit-global-kill
1286 "\C-c\C-d" gnus-summary-describe-group
1287 "q" gnus-summary-exit
1288 "Q" gnus-summary-exit-no-update
1289 "\C-c\C-i" gnus-info-find-node
1290 gnus-mouse-2 gnus-mouse-pick-article
1291 "m" gnus-summary-mail-other-window
1292 "a" gnus-summary-post-news
1293 "x" gnus-summary-limit-to-unread
1294 "s" gnus-summary-isearch-article
1295 "t" gnus-article-hide-headers
1296 "g" gnus-summary-show-article
1297 "l" gnus-summary-goto-last-article
1298 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1299 "\C-d" gnus-summary-enter-digest-group
1300 "\M-\C-d" gnus-summary-read-document
1302 "*" gnus-cache-enter-article
1303 "\M-*" gnus-cache-remove-article
1304 "\M-&" gnus-summary-universal-argument
1305 "\C-l" gnus-recenter
1306 "I" gnus-summary-increase-score
1307 "L" gnus-summary-lower-score
1309 "V" gnus-summary-score-map
1310 "X" gnus-uu-extract-map
1311 "S" gnus-summary-send-map)
1313 ;; Sort of orthogonal keymap
1314 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1315 "t" gnus-summary-tick-article-forward
1316 "!" gnus-summary-tick-article-forward
1317 "d" gnus-summary-mark-as-read-forward
1318 "r" gnus-summary-mark-as-read-forward
1319 "c" gnus-summary-clear-mark-forward
1320 " " gnus-summary-clear-mark-forward
1321 "e" gnus-summary-mark-as-expirable
1322 "x" gnus-summary-mark-as-expirable
1323 "?" gnus-summary-mark-as-dormant
1324 "b" gnus-summary-set-bookmark
1325 "B" gnus-summary-remove-bookmark
1326 "#" gnus-summary-mark-as-processable
1327 "\M-#" gnus-summary-unmark-as-processable
1328 "S" gnus-summary-limit-include-expunged
1329 "C" gnus-summary-catchup
1330 "H" gnus-summary-catchup-to-here
1331 "\C-c" gnus-summary-catchup-all
1332 "k" gnus-summary-kill-same-subject-and-select
1333 "K" gnus-summary-kill-same-subject
1334 "P" gnus-uu-mark-map)
1336 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1337 "c" gnus-summary-clear-above
1338 "u" gnus-summary-tick-above
1339 "m" gnus-summary-mark-above
1340 "k" gnus-summary-kill-below)
1342 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1343 "/" gnus-summary-limit-to-subject
1344 "n" gnus-summary-limit-to-articles
1345 "w" gnus-summary-pop-limit
1346 "s" gnus-summary-limit-to-subject
1347 "a" gnus-summary-limit-to-author
1348 "u" gnus-summary-limit-to-unread
1349 "m" gnus-summary-limit-to-marks
1350 "v" gnus-summary-limit-to-score
1351 "D" gnus-summary-limit-include-dormant
1352 "d" gnus-summary-limit-exclude-dormant
1353 ;; "t" gnus-summary-limit-exclude-thread
1354 "E" gnus-summary-limit-include-expunged
1355 "c" gnus-summary-limit-exclude-childless-dormant
1356 "C" gnus-summary-limit-mark-excluded-as-read)
1358 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1359 "n" gnus-summary-next-unread-article
1360 "p" gnus-summary-prev-unread-article
1361 "N" gnus-summary-next-article
1362 "P" gnus-summary-prev-article
1363 "\C-n" gnus-summary-next-same-subject
1364 "\C-p" gnus-summary-prev-same-subject
1365 "\M-n" gnus-summary-next-unread-subject
1366 "\M-p" gnus-summary-prev-unread-subject
1367 "f" gnus-summary-first-unread-article
1368 "b" gnus-summary-best-unread-article
1369 "j" gnus-summary-goto-article
1370 "g" gnus-summary-goto-subject
1371 "l" gnus-summary-goto-last-article
1372 "p" gnus-summary-pop-article)
1374 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1375 "k" gnus-summary-kill-thread
1376 "l" gnus-summary-lower-thread
1377 "i" gnus-summary-raise-thread
1378 "T" gnus-summary-toggle-threads
1379 "t" gnus-summary-rethread-current
1380 "^" gnus-summary-reparent-thread
1381 "s" gnus-summary-show-thread
1382 "S" gnus-summary-show-all-threads
1383 "h" gnus-summary-hide-thread
1384 "H" gnus-summary-hide-all-threads
1385 "n" gnus-summary-next-thread
1386 "p" gnus-summary-prev-thread
1387 "u" gnus-summary-up-thread
1388 "o" gnus-summary-top-thread
1389 "d" gnus-summary-down-thread
1390 "#" gnus-uu-mark-thread
1391 "\M-#" gnus-uu-unmark-thread)
1393 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1394 "g" gnus-summary-prepare
1395 "c" gnus-summary-insert-cached-articles)
1397 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1398 "c" gnus-summary-catchup-and-exit
1399 "C" gnus-summary-catchup-all-and-exit
1400 "E" gnus-summary-exit-no-update
1401 "Q" gnus-summary-exit
1402 "Z" gnus-summary-exit
1403 "n" gnus-summary-catchup-and-goto-next-group
1404 "R" gnus-summary-reselect-current-group
1405 "G" gnus-summary-rescan-group
1406 "N" gnus-summary-next-group
1407 "P" gnus-summary-prev-group)
1409 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1410 " " gnus-summary-next-page
1411 "n" gnus-summary-next-page
1412 "\177" gnus-summary-prev-page
1413 [delete] gnus-summary-prev-page
1414 "p" gnus-summary-prev-page
1415 "\r" gnus-summary-scroll-up
1416 "<" gnus-summary-beginning-of-article
1417 ">" gnus-summary-end-of-article
1418 "b" gnus-summary-beginning-of-article
1419 "e" gnus-summary-end-of-article
1420 "^" gnus-summary-refer-parent-article
1421 "r" gnus-summary-refer-parent-article
1422 "R" gnus-summary-refer-references
1423 "g" gnus-summary-show-article
1424 "s" gnus-summary-isearch-article)
1426 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1427 "b" gnus-article-add-buttons
1428 "B" gnus-article-add-buttons-to-head
1429 "o" gnus-article-treat-overstrike
1430 "e" gnus-article-emphasize
1431 "w" gnus-article-fill-cited-article
1432 "c" gnus-article-remove-cr
1433 "q" gnus-article-de-quoted-unreadable
1434 "f" gnus-article-display-x-face
1435 "l" gnus-summary-stop-page-breaking
1436 "r" gnus-summary-caesar-message
1437 "t" gnus-article-hide-headers
1438 "v" gnus-summary-verbose-headers
1439 "m" gnus-summary-toggle-mime)
1441 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1442 "a" gnus-article-hide
1443 "h" gnus-article-hide-headers
1444 "b" gnus-article-hide-boring-headers
1445 "s" gnus-article-hide-signature
1446 "c" gnus-article-hide-citation
1447 "p" gnus-article-hide-pgp
1448 "P" gnus-article-hide-pem
1449 "\C-c" gnus-article-hide-citation-maybe)
1451 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1452 "a" gnus-article-highlight
1453 "h" gnus-article-highlight-headers
1454 "c" gnus-article-highlight-citation
1455 "s" gnus-article-highlight-signature)
1457 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1458 "z" gnus-article-date-ut
1459 "u" gnus-article-date-ut
1460 "l" gnus-article-date-local
1461 "e" gnus-article-date-lapsed
1462 "o" gnus-article-date-original)
1464 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1465 "t" gnus-article-remove-trailing-blank-lines
1466 "l" gnus-article-strip-leading-blank-lines
1467 "m" gnus-article-strip-multiple-blank-lines
1468 "a" gnus-article-strip-blank-lines)
1470 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1472 "f" gnus-summary-fetch-faq
1473 "d" gnus-summary-describe-group
1474 "h" gnus-summary-describe-briefly
1475 "i" gnus-info-find-node)
1477 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1478 "e" gnus-summary-expire-articles
1479 "\M-\C-e" gnus-summary-expire-articles-now
1480 "\177" gnus-summary-delete-article
1481 [delete] gnus-summary-delete-article
1482 "m" gnus-summary-move-article
1483 "r" gnus-summary-respool-article
1484 "w" gnus-summary-edit-article
1485 "c" gnus-summary-copy-article
1486 "B" gnus-summary-crosspost-article
1487 "q" gnus-summary-respool-query
1488 "i" gnus-summary-import-article
1489 "p" gnus-summary-article-posted-p)
1491 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1492 "o" gnus-summary-save-article
1493 "m" gnus-summary-save-article-mail
1494 "r" gnus-summary-save-article-rmail
1495 "f" gnus-summary-save-article-file
1496 "b" gnus-summary-save-article-body-file
1497 "h" gnus-summary-save-article-folder
1498 "v" gnus-summary-save-article-vm
1499 "p" gnus-summary-pipe-output
1500 "s" gnus-soup-add-article))
1502 (defun gnus-summary-make-menu-bar ()
1503 (gnus-turn-off-edit-menu 'summary)
1505 (unless (boundp 'gnus-summary-misc-menu)
1508 gnus-summary-kill-menu gnus-summary-mode-map ""
1513 ["Enter score..." gnus-summary-score-entry t])
1514 (gnus-make-score-map 'increase)
1515 (gnus-make-score-map 'lower)
1517 ["Kill below" gnus-summary-kill-below t]
1518 ["Mark above" gnus-summary-mark-above t]
1519 ["Tick above" gnus-summary-tick-above t]
1520 ["Clear above" gnus-summary-clear-above t])
1521 ["Current score" gnus-summary-current-score t]
1522 ["Set score" gnus-summary-set-score t]
1523 ["Switch current score file..." gnus-score-change-score-file t]
1524 ["Set mark below..." gnus-score-set-mark-below t]
1525 ["Set expunge below..." gnus-score-set-expunge-below t]
1526 ["Edit current score file" gnus-score-edit-current-scores t]
1527 ["Edit score file" gnus-score-edit-file t]
1528 ["Trace score" gnus-score-find-trace t]
1529 ["Find words" gnus-score-find-favourite-words t]
1530 ["Rescore buffer" gnus-summary-rescore t]
1531 ["Increase score..." gnus-summary-increase-score t]
1532 ["Lower score..." gnus-summary-lower-score t]))))
1535 ["Ask" (gnus-score-set-default 'gnus-score-default-header nil)
1537 :selected (null gnus-score-default-header)]
1538 ["From" (gnus-score-set-default 'gnus-score-default-header 'a)
1540 :selected (eq gnus-score-default-header 'a)]
1541 ["Subject" (gnus-score-set-default 'gnus-score-default-header 's)
1543 :selected (eq gnus-score-default-header 's)]
1545 (gnus-score-set-default 'gnus-score-default-header 'b)
1547 :selected (eq gnus-score-default-header 'b )]
1549 (gnus-score-set-default 'gnus-score-default-header 'h)
1551 :selected (eq gnus-score-default-header 'h )]
1552 ["Message-ID" (gnus-score-set-default 'gnus-score-default-header 'i)
1554 :selected (eq gnus-score-default-header 'i )]
1555 ["Thread" (gnus-score-set-default 'gnus-score-default-header 't)
1557 :selected (eq gnus-score-default-header 't )]
1559 (gnus-score-set-default 'gnus-score-default-header 'x)
1561 :selected (eq gnus-score-default-header 'x )]
1562 ["Lines" (gnus-score-set-default 'gnus-score-default-header 'l)
1564 :selected (eq gnus-score-default-header 'l )]
1565 ["Date" (gnus-score-set-default 'gnus-score-default-header 'd)
1567 :selected (eq gnus-score-default-header 'd )]
1568 ["Followups to author"
1569 (gnus-score-set-default 'gnus-score-default-header 'f)
1571 :selected (eq gnus-score-default-header 'f )])
1573 ["Ask" (gnus-score-set-default 'gnus-score-default-type nil)
1575 :selected (null gnus-score-default-type)]
1576 ;; The `:active' key is commented out in the following,
1577 ;; because the GNU Emacs hack to support radio buttons use
1578 ;; active to indicate which button is selected.
1579 ["Substring" (gnus-score-set-default 'gnus-score-default-type 's)
1581 ;; :active (not (memq gnus-score-default-header '(l d)))
1582 :selected (eq gnus-score-default-type 's)]
1583 ["Regexp" (gnus-score-set-default 'gnus-score-default-type 'r)
1585 ;; :active (not (memq gnus-score-default-header '(l d)))
1586 :selected (eq gnus-score-default-type 'r)]
1587 ["Exact" (gnus-score-set-default 'gnus-score-default-type 'e)
1589 ;; :active (not (memq gnus-score-default-header '(l d)))
1590 :selected (eq gnus-score-default-type 'e)]
1591 ["Fuzzy" (gnus-score-set-default 'gnus-score-default-type 'f)
1593 ;; :active (not (memq gnus-score-default-header '(l d)))
1594 :selected (eq gnus-score-default-type 'f)]
1595 ["Before date" (gnus-score-set-default 'gnus-score-default-type 'b)
1597 ;; :active (eq (gnus-score-default-header 'd))
1598 :selected (eq gnus-score-default-type 'b)]
1599 ["At date" (gnus-score-set-default 'gnus-score-default-type 'n)
1601 ;; :active (eq (gnus-score-default-header 'd))
1602 :selected (eq gnus-score-default-type 'n)]
1603 ["After date" (gnus-score-set-default 'gnus-score-default-type 'a)
1605 ;; :active (eq (gnus-score-default-header 'd))
1606 :selected (eq gnus-score-default-type 'a)]
1608 (gnus-score-set-default 'gnus-score-default-type '<)
1610 ;; :active (eq (gnus-score-default-header 'l))
1611 :selected (eq gnus-score-default-type '<)]
1613 (gnus-score-set-default 'gnus-score-default-type '=)
1615 ;; :active (eq (gnus-score-default-header 'l))
1616 :selected (eq gnus-score-default-type '=)]
1617 ["Greater than number"
1618 (gnus-score-set-default 'gnus-score-default-type '>)
1620 ;; :active (eq (gnus-score-default-header 'l))
1621 :selected (eq gnus-score-default-type '>)])
1622 ["Default fold" gnus-score-default-fold-toggle
1624 :selected gnus-score-default-fold]
1626 ["Ask" (gnus-score-set-default 'gnus-score-default-duration nil)
1628 :selected (null gnus-score-default-duration)]
1630 (gnus-score-set-default 'gnus-score-default-duration 'p)
1632 :selected (eq gnus-score-default-duration 'p)]
1634 (gnus-score-set-default 'gnus-score-default-duration 't)
1636 :selected (eq gnus-score-default-duration 't)]
1638 (gnus-score-set-default 'gnus-score-default-duration 'i)
1640 :selected (eq gnus-score-default-duration 'i)]))
1643 gnus-summary-article-menu gnus-summary-mode-map ""
1646 ["All" gnus-article-hide t]
1647 ["Headers" gnus-article-hide-headers t]
1648 ["Signature" gnus-article-hide-signature t]
1649 ["Citation" gnus-article-hide-citation t]
1650 ["PGP" gnus-article-hide-pgp t]
1651 ["Boring headers" gnus-article-hide-boring-headers t])
1653 ["All" gnus-article-highlight t]
1654 ["Headers" gnus-article-highlight-headers t]
1655 ["Signature" gnus-article-highlight-signature t]
1656 ["Citation" gnus-article-highlight-citation t])
1658 ["Local" gnus-article-date-local t]
1659 ["UT" gnus-article-date-ut t]
1660 ["Original" gnus-article-date-original t]
1661 ["Lapsed" gnus-article-date-lapsed t])
1664 ["Leading" gnus-article-strip-leading-blank-lines t]
1665 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1666 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1667 ["All of the above" gnus-article-strip-blank-lines t])
1668 ["Overstrike" gnus-article-treat-overstrike t]
1669 ["Emphasis" gnus-article-emphasize t]
1670 ["Word wrap" gnus-article-fill-cited-article t]
1671 ["CR" gnus-article-remove-cr t]
1672 ["Show X-Face" gnus-article-display-x-face t]
1673 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1674 ["Rot 13" gnus-summary-caesar-message t]
1675 ["Add buttons" gnus-article-add-buttons t]
1676 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1677 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1678 ["Toggle MIME" gnus-summary-toggle-mime t]
1679 ["Verbose header" gnus-summary-verbose-headers t]
1680 ["Toggle header" gnus-summary-toggle-header t])
1682 ["Save in default format" gnus-summary-save-article t]
1683 ["Save in file" gnus-summary-save-article-file t]
1684 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1685 ["Save in MH folder" gnus-summary-save-article-folder t]
1686 ["Save in VM folder" gnus-summary-save-article-vm t]
1687 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1688 ["Save body in file" gnus-summary-save-article-body-file t]
1689 ["Pipe through a filter" gnus-summary-pipe-output t]
1690 ["Add to SOUP packet" gnus-soup-add-article t])
1692 ["Respool article..." gnus-summary-respool-article t]
1693 ["Move article..." gnus-summary-move-article
1694 (gnus-check-backend-function
1695 'request-move-article gnus-newsgroup-name)]
1696 ["Copy article..." gnus-summary-copy-article t]
1697 ["Crosspost article..." gnus-summary-crosspost-article
1698 (gnus-check-backend-function
1699 'request-replace-article gnus-newsgroup-name)]
1700 ["Import file..." gnus-summary-import-article t]
1701 ["Check if posted" gnus-summary-article-posted-p t]
1702 ["Edit article" gnus-summary-edit-article
1703 (not (gnus-group-read-only-p))]
1704 ["Delete article" gnus-summary-delete-article
1705 (gnus-check-backend-function
1706 'request-expire-articles gnus-newsgroup-name)]
1707 ["Query respool" gnus-summary-respool-query t]
1708 ["Delete expirable articles" gnus-summary-expire-articles-now
1709 (gnus-check-backend-function
1710 'request-expire-articles gnus-newsgroup-name)])
1712 ["Uudecode" gnus-uu-decode-uu t]
1713 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1714 ["Unshar" gnus-uu-decode-unshar t]
1715 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1716 ["Save" gnus-uu-decode-save t]
1717 ["Binhex" gnus-uu-decode-binhex t]
1718 ["Postscript" gnus-uu-decode-postscript t])
1719 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1720 ["Isearch article..." gnus-summary-isearch-article t]
1721 ["Search articles forward..." gnus-summary-search-article-forward t]
1722 ["Search articles backward..." gnus-summary-search-article-backward t]
1723 ["Beginning of the article" gnus-summary-beginning-of-article t]
1724 ["End of the article" gnus-summary-end-of-article t]
1725 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1726 ["Fetch referenced articles" gnus-summary-refer-references t]
1727 ["Fetch article with id..." gnus-summary-refer-article t]
1728 ["Redisplay" gnus-summary-show-article t]))
1731 gnus-summary-thread-menu gnus-summary-mode-map ""
1733 ["Toggle threading" gnus-summary-toggle-threads t]
1734 ["Hide threads" gnus-summary-hide-all-threads t]
1735 ["Show threads" gnus-summary-show-all-threads t]
1736 ["Hide thread" gnus-summary-hide-thread t]
1737 ["Show thread" gnus-summary-show-thread t]
1738 ["Go to next thread" gnus-summary-next-thread t]
1739 ["Go to previous thread" gnus-summary-prev-thread t]
1740 ["Go down thread" gnus-summary-down-thread t]
1741 ["Go up thread" gnus-summary-up-thread t]
1742 ["Top of thread" gnus-summary-top-thread t]
1743 ["Mark thread as read" gnus-summary-kill-thread t]
1744 ["Lower thread score" gnus-summary-lower-thread t]
1745 ["Raise thread score" gnus-summary-raise-thread t]
1746 ["Rethread current" gnus-summary-rethread-current t]
1750 gnus-summary-post-menu gnus-summary-mode-map ""
1752 ["Post an article" gnus-summary-post-news t]
1753 ["Followup" gnus-summary-followup t]
1754 ["Followup and yank" gnus-summary-followup-with-original t]
1755 ["Supersede article" gnus-summary-supersede-article t]
1756 ["Cancel article" gnus-summary-cancel-article t]
1757 ["Reply" gnus-summary-reply t]
1758 ["Reply and yank" gnus-summary-reply-with-original t]
1759 ["Mail forward" gnus-summary-mail-forward t]
1760 ["Post forward" gnus-summary-post-forward t]
1761 ["Digest and mail" gnus-uu-digest-mail-forward t]
1762 ["Digest and post" gnus-uu-digest-post-forward t]
1763 ["Resend message" gnus-summary-resend-message t]
1764 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1765 ["Send a mail" gnus-summary-mail-other-window t]
1766 ["Uuencode and post" gnus-uu-post-news t]
1768 ;;["Send" gnus-summary-send-draft t]
1769 ;;["Send bounced" gnus-resend-bounced-mail t])
1773 gnus-summary-misc-menu gnus-summary-mode-map ""
1777 ["Mark as read" gnus-summary-mark-as-read-forward t]
1778 ["Mark same subject and select"
1779 gnus-summary-kill-same-subject-and-select t]
1780 ["Mark same subject" gnus-summary-kill-same-subject t]
1781 ["Catchup" gnus-summary-catchup t]
1782 ["Catchup all" gnus-summary-catchup-all t]
1783 ["Catchup to here" gnus-summary-catchup-to-here t]
1784 ["Catchup region" gnus-summary-mark-region-as-read t]
1785 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1787 ["Tick" gnus-summary-tick-article-forward t]
1788 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1789 ["Remove marks" gnus-summary-clear-mark-forward t]
1790 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1791 ["Set bookmark" gnus-summary-set-bookmark t]
1792 ["Remove bookmark" gnus-summary-remove-bookmark t])
1794 ["Marks..." gnus-summary-limit-to-marks t]
1795 ["Subject..." gnus-summary-limit-to-subject t]
1796 ["Author..." gnus-summary-limit-to-author t]
1797 ["Score" gnus-summary-limit-to-score t]
1798 ["Unread" gnus-summary-limit-to-unread t]
1799 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1800 ["Articles" gnus-summary-limit-to-articles t]
1801 ["Pop limit" gnus-summary-pop-limit t]
1802 ["Show dormant" gnus-summary-limit-include-dormant t]
1803 ["Hide childless dormant"
1804 gnus-summary-limit-exclude-childless-dormant t]
1805 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1806 ["Show expunged" gnus-summary-show-all-expunged t])
1808 ["Set mark" gnus-summary-mark-as-processable t]
1809 ["Remove mark" gnus-summary-unmark-as-processable t]
1810 ["Remove all marks" gnus-summary-unmark-all-processable t]
1811 ["Mark above" gnus-uu-mark-over t]
1812 ["Mark series" gnus-uu-mark-series t]
1813 ["Mark region" gnus-uu-mark-region t]
1814 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1815 ["Mark all" gnus-uu-mark-all t]
1816 ["Mark buffer" gnus-uu-mark-buffer t]
1817 ["Mark sparse" gnus-uu-mark-sparse t]
1818 ["Mark thread" gnus-uu-mark-thread t]
1819 ["Unmark thread" gnus-uu-unmark-thread t]
1820 ("Process Mark Sets"
1821 ["Kill" gnus-summary-kill-process-mark t]
1822 ["Yank" gnus-summary-yank-process-mark
1823 gnus-newsgroup-process-stack]
1824 ["Save" gnus-summary-save-process-mark t])))
1826 ["Page forward" gnus-summary-next-page t]
1827 ["Page backward" gnus-summary-prev-page t]
1828 ["Line forward" gnus-summary-scroll-up t])
1830 ["Next unread article" gnus-summary-next-unread-article t]
1831 ["Previous unread article" gnus-summary-prev-unread-article t]
1832 ["Next article" gnus-summary-next-article t]
1833 ["Previous article" gnus-summary-prev-article t]
1834 ["Next unread subject" gnus-summary-next-unread-subject t]
1835 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1836 ["Next article same subject" gnus-summary-next-same-subject t]
1837 ["Previous article same subject" gnus-summary-prev-same-subject t]
1838 ["First unread article" gnus-summary-first-unread-article t]
1839 ["Best unread article" gnus-summary-best-unread-article t]
1840 ["Go to subject number..." gnus-summary-goto-subject t]
1841 ["Go to article number..." gnus-summary-goto-article t]
1842 ["Go to the last article" gnus-summary-goto-last-article t]
1843 ["Pop article off history" gnus-summary-pop-article t])
1845 ["Sort by number" gnus-summary-sort-by-number t]
1846 ["Sort by author" gnus-summary-sort-by-author t]
1847 ["Sort by subject" gnus-summary-sort-by-subject t]
1848 ["Sort by date" gnus-summary-sort-by-date t]
1849 ["Sort by score" gnus-summary-sort-by-score t])
1851 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1852 ["Describe group" gnus-summary-describe-group t]
1853 ["Read manual" gnus-info-find-node t])
1855 ["Enter article" gnus-cache-enter-article t]
1856 ["Remove article" gnus-cache-remove-article t])
1858 ["Pick and read" gnus-pick-mode t]
1859 ["Binary" gnus-binary-mode t])
1860 ["Filter articles..." gnus-summary-execute-command t]
1861 ["Run command on subjects..." gnus-summary-universal-argument t]
1862 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1863 ["Expand window" gnus-summary-expand-window t]
1864 ["Expire expirable articles" gnus-summary-expire-articles
1865 (gnus-check-backend-function
1866 'request-expire-articles gnus-newsgroup-name)]
1867 ["Regenerate buffer" gnus-summary-prepare t]
1868 ["Edit local kill file" gnus-summary-edit-local-kill t]
1869 ["Edit main kill file" gnus-summary-edit-global-kill t]
1871 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1872 ["Catchup all and exit" gnus-summary-catchup-and-exit t]
1873 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1874 ["Exit group" gnus-summary-exit t]
1875 ["Exit group without updating" gnus-summary-exit-no-update t]
1876 ["Exit and goto next group" gnus-summary-next-group t]
1877 ["Exit and goto prev group" gnus-summary-prev-group t]
1878 ["Reselect group" gnus-summary-reselect-current-group t]
1879 ["Rescan group" gnus-summary-rescan-group t])))
1881 (run-hooks 'gnus-summary-menu-hook)))
1883 (defun gnus-score-set-default (var value)
1884 "A version of set that updates the GNU Emacs menu-bar."
1886 ;; It is the message that forces the active status to be updated.
1889 (defun gnus-make-score-map (type)
1890 "Make a summary score map of type TYPE."
1893 (let ((headers '(("author" "from" string)
1894 ("subject" "subject" string)
1895 ("article body" "body" string)
1896 ("article head" "head" string)
1897 ("xref" "xref" string)
1898 ("lines" "lines" number)
1899 ("followups to author" "followup" string)))
1900 (types '((number ("less than" <)
1903 (string ("substring" s)
1907 (perms '(("temporary" (current-time-string))
1915 (if (eq type 'lower)
1920 (setq header (car headers))
1926 (let ((ts (cdr (assoc (nth 2 header) types)))
1942 'gnus-summary-score-entry
1944 (if (or (string= (nth 1 header)
1946 (string= (nth 1 header)
1949 (list 'gnus-summary-header
1951 (list 'quote (nth 1 (car ts)))
1952 (list 'gnus-score-default nil)
1958 (list (nreverse outp))))
1961 (list (nreverse outt))))
1963 (setq headers (cdr headers)))
1964 (list (nreverse outh))))))))
1968 (defun gnus-summary-mode (&optional group)
1969 "Major mode for reading articles.
1971 All normal editing commands are switched off.
1972 \\<gnus-summary-mode-map>
1973 Each line in this buffer represents one article. To read an
1974 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
1975 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
1978 You can also post articles and send mail from this buffer. To
1979 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
1980 of an article, type `\\[gnus-summary-reply]'.
1982 There are approx. one gazillion commands you can execute in this
1983 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
1985 The following commands are available:
1987 \\{gnus-summary-mode-map}"
1989 (when (and menu-bar-mode
1990 (gnus-visual-p 'summary-menu 'menu))
1991 (gnus-summary-make-menu-bar))
1992 (kill-all-local-variables)
1993 (gnus-summary-make-local-variables)
1994 (gnus-make-thread-indent-array)
1995 (gnus-simplify-mode-line)
1996 (setq major-mode 'gnus-summary-mode)
1997 (setq mode-name "Summary")
1998 (make-local-variable 'minor-mode-alist)
1999 (use-local-map gnus-summary-mode-map)
2000 (buffer-disable-undo (current-buffer))
2001 (setq buffer-read-only t) ;Disable modification
2002 (setq truncate-lines t)
2003 (setq selective-display t)
2004 (setq selective-display-ellipses t) ;Display `...'
2005 (setq buffer-display-table gnus-summary-display-table)
2006 (gnus-set-default-directory)
2007 (setq gnus-newsgroup-name group)
2008 (make-local-variable 'gnus-summary-line-format)
2009 (make-local-variable 'gnus-summary-line-format-spec)
2010 (make-local-variable 'gnus-summary-mark-positions)
2011 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2012 (gnus-update-summary-mark-positions)
2013 (gnus-make-local-hook 'post-command-hook)
2014 (gnus-add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
2015 (run-hooks 'gnus-summary-mode-hook))
2017 (defun gnus-summary-make-local-variables ()
2018 "Make all the local summary buffer variables."
2019 (let ((locals gnus-summary-local-variables)
2021 (while (setq local (pop locals))
2024 (if (eq (cdr local) 'global)
2025 ;; Copy the global value of the variable.
2026 (setq global (symbol-value (car local)))
2027 ;; Use the value from the list.
2028 (setq global (eval (cdr local))))
2029 (make-local-variable (car local))
2030 (set (car local) global))
2031 ;; Simple nil-valued local variable.
2032 (make-local-variable local)
2035 (defun gnus-summary-clear-local-variables ()
2036 (let ((locals gnus-summary-local-variables))
2038 (if (consp (car locals))
2039 (and (vectorp (caar locals))
2040 (set (caar locals) nil))
2041 (and (vectorp (car locals))
2042 (set (car locals) nil)))
2043 (setq locals (cdr locals)))))
2045 ;; Summary data functions.
2047 (defmacro gnus-data-number (data)
2050 (defmacro gnus-data-set-number (data number)
2051 `(setcar ,data ,number))
2053 (defmacro gnus-data-mark (data)
2056 (defmacro gnus-data-set-mark (data mark)
2057 `(setcar (nthcdr 1 ,data) ,mark))
2059 (defmacro gnus-data-pos (data)
2062 (defmacro gnus-data-set-pos (data pos)
2063 `(setcar (nthcdr 2 ,data) ,pos))
2065 (defmacro gnus-data-header (data)
2068 (defmacro gnus-data-level (data)
2071 (defmacro gnus-data-unread-p (data)
2072 `(= (nth 1 ,data) gnus-unread-mark))
2074 (defmacro gnus-data-read-p (data)
2075 `(/= (nth 1 ,data) gnus-unread-mark))
2077 (defmacro gnus-data-pseudo-p (data)
2078 `(consp (nth 3 ,data)))
2080 (defmacro gnus-data-find (number)
2081 `(assq ,number gnus-newsgroup-data))
2083 (defmacro gnus-data-find-list (number &optional data)
2084 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2085 (memq (assq ,number bdata)
2088 (defmacro gnus-data-make (number mark pos header level)
2089 `(list ,number ,mark ,pos ,header ,level))
2091 (defun gnus-data-enter (after-article number mark pos header level offset)
2092 (let ((data (gnus-data-find-list after-article)))
2094 (error "No such article: %d" after-article))
2095 (setcdr data (cons (gnus-data-make number mark pos header level)
2097 (setq gnus-newsgroup-data-reverse nil)
2098 (gnus-data-update-list (cddr data) offset)))
2100 (defun gnus-data-enter-list (after-article list &optional offset)
2102 (let ((data (and after-article (gnus-data-find-list after-article)))
2104 (or data (not after-article) (error "No such article: %d" after-article))
2105 ;; Find the last element in the list to be spliced into the main
2108 (setq list (cdr list)))
2111 (setcdr list gnus-newsgroup-data)
2112 (setq gnus-newsgroup-data ilist)
2114 (gnus-data-update-list (cdr list) offset)))
2115 (setcdr list (cdr data))
2118 (gnus-data-update-list (cdr data) offset)))
2119 (setq gnus-newsgroup-data-reverse nil))))
2121 (defun gnus-data-remove (article &optional offset)
2122 (let ((data gnus-newsgroup-data))
2123 (if (= (gnus-data-number (car data)) article)
2124 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2125 gnus-newsgroup-data-reverse nil)
2127 (when (= (gnus-data-number (cadr data)) article)
2128 (setcdr data (cddr data))
2130 (gnus-data-update-list (cdr data) offset))
2132 gnus-newsgroup-data-reverse nil))
2133 (setq data (cdr data))))))
2135 (defmacro gnus-data-list (backward)
2137 (or gnus-newsgroup-data-reverse
2138 (setq gnus-newsgroup-data-reverse
2139 (reverse gnus-newsgroup-data)))
2140 gnus-newsgroup-data))
2142 (defun gnus-data-update-list (data offset)
2143 "Add OFFSET to the POS of all data entries in DATA."
2145 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2146 (setq data (cdr data))))
2148 (defun gnus-data-compute-positions ()
2149 "Compute the positions of all articles."
2150 (let ((data gnus-newsgroup-data)
2153 (when (setq pos (text-property-any
2154 (point-min) (point-max)
2155 'gnus-number (gnus-data-number (car data))))
2156 (gnus-data-set-pos (car data) (+ pos 3)))
2157 (setq data (cdr data)))))
2159 (defun gnus-summary-article-pseudo-p (article)
2160 "Say whether this article is a pseudo article or not."
2161 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2163 (defun gnus-article-parent-p (number)
2164 "Say whether this article is a parent or not."
2165 (let ((data (gnus-data-find-list number)))
2166 (and (cdr data) ; There has to be an article after...
2167 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2168 (gnus-data-level (nth 1 data))))))
2170 (defun gnus-article-children (number)
2171 "Return a list of all children to NUMBER."
2172 (let* ((data (gnus-data-find-list number))
2173 (level (gnus-data-level (car data)))
2175 (setq data (cdr data))
2177 (= (gnus-data-level (car data)) (1+ level)))
2178 (push (gnus-data-number (car data)) children)
2179 (setq data (cdr data)))
2182 (defmacro gnus-summary-skip-intangible ()
2183 "If the current article is intangible, then jump to a different article."
2184 '(let ((to (get-text-property (point) 'gnus-intangible)))
2185 (and to (gnus-summary-goto-subject to))))
2187 (defmacro gnus-summary-article-intangible-p ()
2188 "Say whether this article is intangible or not."
2189 '(get-text-property (point) 'gnus-intangible))
2191 (defun gnus-article-read-p (article)
2192 "Say whether ARTICLE is read or not."
2193 (not (or (memq article gnus-newsgroup-marked)
2194 (memq article gnus-newsgroup-unreads)
2195 (memq article gnus-newsgroup-unselected)
2196 (memq article gnus-newsgroup-dormant))))
2198 ;; Some summary mode macros.
2200 (defmacro gnus-summary-article-number ()
2201 "The article number of the article on the current line.
2202 If there isn's an article number here, then we return the current
2205 (gnus-summary-skip-intangible)
2206 (or (get-text-property (point) 'gnus-number)
2207 (gnus-summary-last-subject))))
2209 (defmacro gnus-summary-article-header (&optional number)
2210 `(gnus-data-header (gnus-data-find
2211 ,(or number '(gnus-summary-article-number)))))
2213 (defmacro gnus-summary-thread-level (&optional number)
2214 `(if (and (eq gnus-summary-make-false-root 'dummy)
2215 (get-text-property (point) 'gnus-intangible))
2217 (gnus-data-level (gnus-data-find
2218 ,(or number '(gnus-summary-article-number))))))
2220 (defmacro gnus-summary-article-mark (&optional number)
2221 `(gnus-data-mark (gnus-data-find
2222 ,(or number '(gnus-summary-article-number)))))
2224 (defmacro gnus-summary-article-pos (&optional number)
2225 `(gnus-data-pos (gnus-data-find
2226 ,(or number '(gnus-summary-article-number)))))
2228 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2229 (defmacro gnus-summary-article-subject (&optional number)
2230 "Return current subject string or nil if nothing."
2233 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2234 '(gnus-data-header (assq (gnus-summary-article-number)
2235 gnus-newsgroup-data)))))
2238 (mail-header-subject headers))))
2240 (defmacro gnus-summary-article-score (&optional number)
2241 "Return current article score."
2242 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2243 gnus-newsgroup-scored))
2244 gnus-summary-default-score 0))
2246 (defun gnus-summary-article-children (&optional number)
2247 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2248 (level (gnus-data-level (car data)))
2250 (while (and (setq data (cdr data))
2251 (> (setq l (gnus-data-level (car data))) level))
2252 (and (= (1+ level) l)
2253 (push (gnus-data-number (car data))
2255 (nreverse children)))
2257 (defun gnus-summary-article-parent (&optional number)
2258 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2259 (gnus-data-list t)))
2260 (level (gnus-data-level (car data))))
2262 () ; This is a root.
2263 ;; We search until we find an article with a level less than
2264 ;; this one. That function has to be the parent.
2265 (while (and (setq data (cdr data))
2266 (not (< (gnus-data-level (car data)) level))))
2267 (and data (gnus-data-number (car data))))))
2269 (defun gnus-unread-mark-p (mark)
2270 "Say whether MARK is the unread mark."
2271 (= mark gnus-unread-mark))
2273 (defun gnus-read-mark-p (mark)
2274 "Say whether MARK is one of the marks that mark as read.
2275 This is all marks except unread, ticked, dormant, and expirable."
2276 (not (or (= mark gnus-unread-mark)
2277 (= mark gnus-ticked-mark)
2278 (= mark gnus-dormant-mark)
2279 (= mark gnus-expirable-mark))))
2281 (defmacro gnus-article-mark (number)
2283 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2284 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2285 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2286 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2287 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2288 gnus-ancient-mark))))
2290 ;; Saving hidden threads.
2292 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2293 (put 'gnus-save-hidden-threads 'lisp-indent-hook 0)
2294 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2296 (defmacro gnus-save-hidden-threads (&rest forms)
2297 "Save hidden threads, eval FORMS, and restore the hidden threads."
2298 (let ((config (make-symbol "config")))
2299 `(let ((,config (gnus-hidden-threads-configuration)))
2303 (gnus-restore-hidden-threads-configuration ,config)))))
2305 (defun gnus-hidden-threads-configuration ()
2306 "Return the current hidden threads configuration."
2309 (goto-char (point-min))
2310 (while (search-forward "\r" nil t)
2311 (push (1- (point)) config))
2314 (defun gnus-restore-hidden-threads-configuration (config)
2315 "Restore hidden threads configuration from CONFIG."
2316 (let (point buffer-read-only)
2317 (while (setq point (pop config))
2318 (when (and (< point (point-max))
2320 (= (following-char) ?\n))
2321 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2323 ;; Various summary mode internalish functions.
2325 (defun gnus-mouse-pick-article (e)
2328 (gnus-summary-next-page nil t))
2330 (defun gnus-summary-setup-buffer (group)
2331 "Initialize summary buffer."
2332 (let ((buffer (concat "*Summary " group "*")))
2333 (if (get-buffer buffer)
2336 (setq gnus-summary-buffer (current-buffer))
2337 (not gnus-newsgroup-prepared))
2338 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2339 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
2340 (gnus-add-current-to-buffer-list)
2341 (gnus-summary-mode group)
2343 (gnus-carpal-setup-buffer 'summary))
2344 (unless gnus-single-article-buffer
2345 (make-local-variable 'gnus-article-buffer)
2346 (make-local-variable 'gnus-article-current)
2347 (make-local-variable 'gnus-original-article-buffer))
2348 (setq gnus-newsgroup-name group)
2351 (defun gnus-set-global-variables ()
2352 ;; Set the global equivalents of the summary buffer-local variables
2353 ;; to the latest values they had. These reflect the summary buffer
2354 ;; that was in action when the last article was fetched.
2355 (when (eq major-mode 'gnus-summary-mode)
2356 (setq gnus-summary-buffer (current-buffer))
2357 (let ((name gnus-newsgroup-name)
2358 (marked gnus-newsgroup-marked)
2359 (unread gnus-newsgroup-unreads)
2360 (headers gnus-current-headers)
2361 (data gnus-newsgroup-data)
2362 (summary gnus-summary-buffer)
2363 (article-buffer gnus-article-buffer)
2364 (original gnus-original-article-buffer)
2365 (gac gnus-article-current)
2366 (reffed gnus-reffed-article-number)
2367 (score-file gnus-current-score-file))
2369 (set-buffer gnus-group-buffer)
2370 (setq gnus-newsgroup-name name)
2371 (setq gnus-newsgroup-marked marked)
2372 (setq gnus-newsgroup-unreads unread)
2373 (setq gnus-current-headers headers)
2374 (setq gnus-newsgroup-data data)
2375 (setq gnus-article-current gac)
2376 (setq gnus-summary-buffer summary)
2377 (setq gnus-article-buffer article-buffer)
2378 (setq gnus-original-article-buffer original)
2379 (setq gnus-reffed-article-number reffed)
2380 (setq gnus-current-score-file score-file)
2381 ;; The article buffer also has local variables.
2382 (when (gnus-buffer-live-p gnus-article-buffer)
2383 (set-buffer gnus-article-buffer)
2384 (setq gnus-summary-buffer summary))))))
2386 (defun gnus-summary-last-article-p (&optional article)
2387 "Return whether ARTICLE is the last article in the buffer."
2388 (if (not (setq article (or article (gnus-summary-article-number))))
2389 t ; All non-existent numbers are the last article. :-)
2390 (not (cdr (gnus-data-find-list article)))))
2392 (defun gnus-make-thread-indent-array ()
2394 (unless (and gnus-thread-indent-array
2395 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2396 (setq gnus-thread-indent-array (make-vector 201 "")
2397 gnus-thread-indent-array-level gnus-thread-indent-level)
2399 (aset gnus-thread-indent-array n
2400 (make-string (* n gnus-thread-indent-level) ? ))
2403 (defun gnus-update-summary-mark-positions ()
2404 "Compute where the summary marks are to go."
2406 (when (and gnus-summary-buffer
2407 (get-buffer gnus-summary-buffer)
2408 (buffer-name (get-buffer gnus-summary-buffer)))
2409 (set-buffer gnus-summary-buffer))
2410 (let ((gnus-replied-mark 129)
2411 (gnus-score-below-mark 130)
2412 (gnus-score-over-mark 130)
2415 (spec gnus-summary-line-format-spec)
2418 (gnus-set-work-buffer)
2419 (let ((gnus-summary-line-format-spec spec))
2420 (gnus-summary-insert-line
2421 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2422 (goto-char (point-min))
2423 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2425 (goto-char (point-min))
2426 (push (cons 'replied (and (search-forward "\201" nil t)
2429 (goto-char (point-min))
2430 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2432 (setq gnus-summary-mark-positions pos))))
2434 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2435 "Insert a dummy root in the summary buffer."
2437 (gnus-add-text-properties
2438 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2439 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2441 (defun gnus-summary-insert-line (gnus-tmp-header
2442 gnus-tmp-level gnus-tmp-current
2443 gnus-tmp-unread gnus-tmp-replied
2444 gnus-tmp-expirable gnus-tmp-subject-or-nil
2445 &optional gnus-tmp-dummy gnus-tmp-score
2447 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2448 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2449 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2450 (gnus-tmp-score-char
2451 (if (or (null gnus-summary-default-score)
2452 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2453 gnus-summary-zcore-fuzz))
2455 (if (< gnus-tmp-score gnus-summary-default-score)
2456 gnus-score-below-mark gnus-score-over-mark)))
2458 (cond (gnus-tmp-process gnus-process-mark)
2459 ((memq gnus-tmp-current gnus-newsgroup-cached)
2461 (gnus-tmp-replied gnus-replied-mark)
2462 ((memq gnus-tmp-current gnus-newsgroup-saved)
2464 (t gnus-unread-mark)))
2465 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2468 ((string-match "(.+)" gnus-tmp-from)
2469 (substring gnus-tmp-from
2470 (1+ (match-beginning 0)) (1- (match-end 0))))
2471 ((string-match "<[^>]+> *$" gnus-tmp-from)
2472 (let ((beg (match-beginning 0)))
2473 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2474 (substring gnus-tmp-from (1+ (match-beginning 0))
2475 (1- (match-end 0))))
2476 (substring gnus-tmp-from 0 beg))))
2478 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2479 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2480 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2481 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2482 (buffer-read-only nil))
2483 (when (string= gnus-tmp-name "")
2484 (setq gnus-tmp-name gnus-tmp-from))
2485 (unless (numberp gnus-tmp-lines)
2486 (setq gnus-tmp-lines 0))
2487 (gnus-put-text-property
2489 (progn (eval gnus-summary-line-format-spec) (point))
2490 'gnus-number gnus-tmp-number)
2491 (when (gnus-visual-p 'summary-highlight 'highlight)
2493 (run-hooks 'gnus-summary-update-hook)
2496 (defun gnus-summary-update-line (&optional dont-update)
2497 ;; Update summary line after change.
2498 (when (and gnus-summary-default-score
2499 (not gnus-summary-inhibit-highlight))
2500 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2501 (article (gnus-summary-article-number))
2502 (score (gnus-summary-article-score article)))
2504 (if (and gnus-summary-mark-below
2505 (< (gnus-summary-article-score)
2506 gnus-summary-mark-below))
2507 ;; This article has a low score, so we mark it as read.
2508 (when (memq article gnus-newsgroup-unreads)
2509 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2510 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2511 ;; This article was previously marked as read on account
2512 ;; of a low score, but now it has risen, so we mark it as
2514 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2515 (gnus-summary-update-mark
2516 (if (or (null gnus-summary-default-score)
2517 (<= (abs (- score gnus-summary-default-score))
2518 gnus-summary-zcore-fuzz))
2520 (if (< score gnus-summary-default-score)
2521 gnus-score-below-mark gnus-score-over-mark))
2523 ;; Do visual highlighting.
2524 (when (gnus-visual-p 'summary-highlight 'highlight)
2525 (run-hooks 'gnus-summary-update-hook)))))
2527 (defvar gnus-tmp-new-adopts nil)
2529 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2530 "Return the number of articles in THREAD.
2531 This may be 0 in some cases -- if none of the articles in
2532 the thread are to be displayed."
2534 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2536 ((not (listp thread))
2538 ((and (consp thread) (cdr thread))
2541 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2544 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2547 (when (and level (zerop level) gnus-tmp-new-adopts)
2550 'gnus-summary-number-of-articles-in-thread
2551 gnus-tmp-new-adopts))))
2553 (if (> number 1) gnus-not-empty-thread-mark
2554 gnus-empty-thread-mark)
2557 (defun gnus-summary-set-local-parameters (group)
2558 "Go through the local params of GROUP and set all variable specs in that list."
2559 (let ((params (gnus-group-find-parameter group))
2562 (setq elem (car params)
2563 params (cdr params))
2564 (and (consp elem) ; Has to be a cons.
2565 (consp (cdr elem)) ; The cdr has to be a list.
2566 (symbolp (car elem)) ; Has to be a symbol in there.
2567 (not (memq (car elem)
2568 '(quit-config to-address to-list to-group)))
2569 (progn ; So we set it.
2570 (make-local-variable (car elem))
2571 (set (car elem) (eval (nth 1 elem))))))))
2573 (defun gnus-summary-read-group (group &optional show-all no-article
2574 kill-buffer no-display)
2575 "Start reading news in newsgroup GROUP.
2576 If SHOW-ALL is non-nil, already read articles are also listed.
2577 If NO-ARTICLE is non-nil, no article is selected initially.
2578 If NO-DISPLAY, don't generate a summary buffer."
2579 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2580 (let* ((new-group (gnus-summary-setup-buffer group))
2581 (quit-config (gnus-group-quit-config group))
2582 (did-select (and new-group (gnus-select-newsgroup group show-all))))
2584 ;; This summary buffer exists already, so we just select it.
2586 (gnus-set-global-variables)
2588 (gnus-kill-or-deaden-summary kill-buffer))
2589 (gnus-configure-windows 'summary 'force)
2590 (gnus-set-mode-line 'summary)
2591 (gnus-summary-position-point)
2594 ;; We couldn't select this group.
2596 (when (and (eq major-mode 'gnus-summary-mode)
2597 (not (equal (current-buffer) kill-buffer)))
2598 (kill-buffer (current-buffer))
2599 (if (not quit-config)
2601 (set-buffer gnus-group-buffer)
2602 (gnus-group-jump-to-group group)
2603 (gnus-group-next-unread-group 1))
2604 (gnus-handle-ephemeral-exit quit-config)))
2605 (gnus-message 3 "Can't select group")
2607 ;; The user did a `C-g' while prompting for number of articles,
2608 ;; so we exit this group.
2609 ((eq did-select 'quit)
2610 (and (eq major-mode 'gnus-summary-mode)
2611 (not (equal (current-buffer) kill-buffer))
2612 (kill-buffer (current-buffer)))
2614 (gnus-kill-or-deaden-summary kill-buffer))
2615 (if (not quit-config)
2617 (set-buffer gnus-group-buffer)
2618 (gnus-group-jump-to-group group)
2619 (gnus-group-next-unread-group 1)
2620 (gnus-configure-windows 'group 'force))
2621 (gnus-handle-ephemeral-exit quit-config))
2622 ;; Finally signal the quit.
2624 ;; The group was successfully selected.
2626 (gnus-set-global-variables)
2627 ;; Save the active value in effect when the group was entered.
2628 (setq gnus-newsgroup-active
2630 (gnus-active gnus-newsgroup-name)))
2631 ;; You can change the summary buffer in some way with this hook.
2632 (run-hooks 'gnus-select-group-hook)
2633 ;; Set any local variables in the group parameters.
2634 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2635 (gnus-update-format-specifications
2636 nil 'summary 'summary-mode 'summary-dummy)
2637 ;; Do score processing.
2638 (when gnus-use-scoring
2639 (gnus-possibly-score-headers))
2640 ;; Check whether to fill in the gaps in the threads.
2641 (when gnus-build-sparse-threads
2642 (gnus-build-sparse-threads))
2643 ;; Find the initial limit.
2644 (if gnus-show-threads
2646 (let ((gnus-newsgroup-dormant nil))
2647 (gnus-summary-initial-limit show-all))
2648 (gnus-summary-initial-limit show-all))
2649 (setq gnus-newsgroup-limit
2651 (lambda (header) (mail-header-number header))
2652 gnus-newsgroup-headers)))
2653 ;; Generate the summary buffer.
2655 (gnus-summary-prepare))
2656 (when gnus-use-trees
2657 (gnus-tree-open group)
2658 (setq gnus-summary-highlight-line-function
2659 'gnus-tree-highlight-article))
2660 ;; If the summary buffer is empty, but there are some low-scored
2661 ;; articles or some excluded dormants, we include these in the
2663 (when (and (zerop (buffer-size))
2665 (cond (gnus-newsgroup-dormant
2666 (gnus-summary-limit-include-dormant))
2667 ((and gnus-newsgroup-scored show-all)
2668 (gnus-summary-limit-include-expunged t))))
2669 ;; Function `gnus-apply-kill-file' must be called in this hook.
2670 (run-hooks 'gnus-apply-kill-hook)
2671 (if (and (zerop (buffer-size))
2674 ;; This newsgroup is empty.
2675 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
2676 (gnus-message 6 "No unread news")
2678 (gnus-kill-or-deaden-summary kill-buffer))
2679 ;; Return nil from this function.
2681 ;; Hide conversation thread subtrees. We cannot do this in
2682 ;; gnus-summary-prepare-hook since kill processing may not
2683 ;; work with hidden articles.
2684 (and gnus-show-threads
2685 gnus-thread-hide-subtree
2686 (gnus-summary-hide-all-threads))
2687 ;; Show first unread article if requested.
2688 (if (and (not no-article)
2690 gnus-newsgroup-unreads
2691 gnus-auto-select-first)
2692 (unless (if (eq gnus-auto-select-first 'best)
2693 (gnus-summary-best-unread-article)
2694 (gnus-summary-first-unread-article))
2695 (gnus-configure-windows 'summary))
2696 ;; Don't select any articles, just move point to the first
2697 ;; article in the group.
2698 (goto-char (point-min))
2699 (gnus-summary-position-point)
2700 (gnus-set-mode-line 'summary)
2701 (gnus-configure-windows 'summary 'force))
2703 (gnus-kill-or-deaden-summary kill-buffer))
2704 (when (get-buffer-window gnus-group-buffer t)
2705 ;; Gotta use windows, because recenter does weird stuff if
2706 ;; the current buffer ain't the displayed window.
2707 (let ((owin (selected-window)))
2708 (select-window (get-buffer-window gnus-group-buffer t))
2709 (when (gnus-group-goto-group group)
2711 (select-window owin))))
2712 ;; Mark this buffer as "prepared".
2713 (setq gnus-newsgroup-prepared t)
2716 (defun gnus-summary-prepare ()
2717 "Generate the summary buffer."
2719 (let ((buffer-read-only nil))
2721 (setq gnus-newsgroup-data nil
2722 gnus-newsgroup-data-reverse nil)
2723 (run-hooks 'gnus-summary-generate-hook)
2724 ;; Generate the buffer, either with threads or without.
2725 (when gnus-newsgroup-headers
2726 (gnus-summary-prepare-threads
2727 (if gnus-show-threads
2728 (gnus-sort-gathered-threads
2729 (funcall gnus-summary-thread-gathering-function
2731 (gnus-cut-threads (gnus-make-threads)))))
2732 ;; Unthreaded display.
2733 (gnus-sort-articles gnus-newsgroup-headers))))
2734 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2735 ;; Call hooks for modifying summary buffer.
2736 (goto-char (point-min))
2737 (run-hooks 'gnus-summary-prepare-hook)))
2739 (defsubst gnus-general-simplify-subject (subject)
2740 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2743 ;; Truncate the subject.
2744 ((numberp gnus-summary-gather-subject-limit)
2745 (setq subject (gnus-simplify-subject-re subject))
2746 (if (> (length subject) gnus-summary-gather-subject-limit)
2747 (substring subject 0 gnus-summary-gather-subject-limit)
2749 ;; Fuzzily simplify it.
2750 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2751 (gnus-simplify-subject-fuzzy subject))
2752 ;; Just remove the leading "Re:".
2754 (gnus-simplify-subject-re subject))))
2756 (if (and gnus-summary-gather-exclude-subject
2757 (string-match gnus-summary-gather-exclude-subject subject))
2758 nil ; This article shouldn't be gathered
2761 (defun gnus-summary-simplify-subject-query ()
2762 "Query where the respool algorithm would put this article."
2764 (gnus-set-global-variables)
2765 (gnus-summary-select-article)
2766 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2768 (defun gnus-gather-threads-by-subject (threads)
2769 "Gather threads by looking at Subject headers."
2770 (if (not gnus-summary-make-false-root)
2772 (let ((hashtb (gnus-make-hashtable 1023))
2775 subject hthread whole-subject)
2777 (setq subject (gnus-general-simplify-subject
2778 (setq whole-subject (mail-header-subject
2781 (if (setq hthread (gnus-gethash subject hashtb))
2783 ;; We enter a dummy root into the thread, if we
2784 ;; haven't done that already.
2785 (unless (stringp (caar hthread))
2786 (setcar hthread (list whole-subject (car hthread))))
2787 ;; We add this new gathered thread to this gathered
2789 (setcdr (car hthread)
2790 (nconc (cdar hthread) (list (car threads))))
2791 ;; Remove it from the list of threads.
2792 (setcdr prev (cdr threads))
2793 (setq threads prev))
2794 ;; Enter this thread into the hash table.
2795 (gnus-sethash subject threads hashtb)))
2797 (setq threads (cdr threads)))
2800 (defun gnus-gather-threads-by-references (threads)
2801 "Gather threads by looking at References headers."
2802 (let ((idhashtb (gnus-make-hashtable 1023))
2803 (thhashtb (gnus-make-hashtable 1023))
2806 ids references id gthread gid entered ref)
2808 (when (setq references (mail-header-references (caar threads)))
2809 (setq id (mail-header-id (caar threads))
2810 ids (gnus-split-references references)
2812 (while (setq ref (pop ids))
2813 (setq ids (delete ref ids))
2814 (if (not (setq gid (gnus-gethash ref idhashtb)))
2816 (gnus-sethash ref id idhashtb)
2817 (gnus-sethash id threads thhashtb))
2818 (setq gthread (gnus-gethash gid thhashtb))
2820 ;; We enter a dummy root into the thread, if we
2821 ;; haven't done that already.
2822 (unless (stringp (caar gthread))
2823 (setcar gthread (list (mail-header-subject (caar gthread))
2825 ;; We add this new gathered thread to this gathered
2827 (setcdr (car gthread)
2828 (nconc (cdar gthread) (list (car threads)))))
2829 ;; Add it into the thread hash table.
2830 (gnus-sethash id gthread thhashtb)
2832 ;; Remove it from the list of threads.
2833 (setcdr prev (cdr threads))
2834 (setq threads prev))))
2836 (setq threads (cdr threads)))
2839 (defun gnus-sort-gathered-threads (threads)
2840 "Sort subtreads inside each gathered thread by article number."
2841 (let ((result threads))
2843 (when (stringp (caar threads))
2844 (setcdr (car threads)
2845 (sort (cdar threads) 'gnus-thread-sort-by-number)))
2846 (setq threads (cdr threads)))
2849 (defun gnus-make-threads ()
2850 "Go through the dependency hashtb and find the roots. Return all threads."
2854 (unless (car (symbol-value refs))
2855 ;; These threads do not refer back to any other articles,
2856 ;; so they're roots.
2857 (setq threads (append (cdr (symbol-value refs)) threads))))
2858 gnus-newsgroup-dependencies)
2861 (defun gnus-build-sparse-threads ()
2862 (let ((headers gnus-newsgroup-headers)
2863 (deps gnus-newsgroup-dependencies)
2864 header references generation relations
2865 cthread subject child end pthread relation)
2866 ;; First we create an alist of generations/relations, where
2867 ;; generations is how much we trust the relation, and the relation
2869 (gnus-message 7 "Making sparse threads...")
2871 (nnheader-set-temp-buffer " *gnus sparse threads*")
2872 (while (setq header (pop headers))
2873 (when (and (setq references (mail-header-references header))
2874 (not (string= references "")))
2876 (setq child (mail-header-id header)
2877 subject (mail-header-subject header))
2879 (while (search-backward ">" nil t)
2880 (setq end (1+ (point)))
2881 (when (search-backward "<" nil t)
2882 (push (list (incf generation)
2883 child (setq child (buffer-substring (point) end))
2886 (push (list (1+ generation) child nil subject) relations)
2888 (kill-buffer (current-buffer)))
2889 ;; Sort over trustworthiness.
2890 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
2891 (while (setq relation (pop relations))
2892 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
2893 (unless (car (symbol-value cthread))
2894 ;; Make this article the parent of these threads.
2895 (setcar (symbol-value cthread)
2896 (vector gnus-reffed-article-number
2900 (or (caddr relation) "") 0 0 "")))
2901 (set cthread (list (vector gnus-reffed-article-number
2903 "" "" (cadr relation)
2904 (or (caddr relation) "") 0 0 ""))))
2905 (push gnus-reffed-article-number gnus-newsgroup-limit)
2906 (push gnus-reffed-article-number gnus-newsgroup-sparse)
2907 (push (cons gnus-reffed-article-number gnus-sparse-mark)
2908 gnus-newsgroup-reads)
2909 (decf gnus-reffed-article-number)
2910 ;; Make this new thread the child of its parent.
2911 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
2912 (setcdr (symbol-value pthread)
2913 (nconc (cdr (symbol-value pthread))
2914 (list (symbol-value cthread))))
2915 (set pthread (list nil (symbol-value cthread))))))
2916 (gnus-message 7 "Making sparse threads...done")))
2918 (defun gnus-build-old-threads ()
2919 ;; Look at all the articles that refer back to old articles, and
2920 ;; fetch the headers for the articles that aren't there. This will
2921 ;; build complete threads - if the roots haven't been expired by the
2926 (when (not (car (symbol-value refs)))
2927 (setq heads (cdr (symbol-value refs)))
2929 (if (memq (mail-header-number (caar heads))
2930 gnus-newsgroup-dormant)
2931 (setq heads (cdr heads))
2932 (setq id (symbol-name refs))
2933 (while (and (setq id (gnus-build-get-header id))
2934 (not (car (gnus-gethash
2935 id gnus-newsgroup-dependencies)))))
2936 (setq heads nil)))))
2937 gnus-newsgroup-dependencies)))
2939 (defun gnus-build-get-header (id)
2940 ;; Look through the buffer of NOV lines and find the header to
2941 ;; ID. Enter this line into the dependencies hash table, and return
2942 ;; the id of the parent article (if any).
2943 (let ((deps gnus-newsgroup-dependencies)
2947 (set-buffer nntp-server-buffer)
2948 (goto-char (point-min))
2949 (while (and (not found) (search-forward id nil t))
2951 (setq found (looking-at
2952 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
2953 (regexp-quote id))))
2954 (or found (beginning-of-line 2)))
2958 (setq header (gnus-nov-parse-line
2959 (read (current-buffer)) deps))
2960 (gnus-parent-id (mail-header-references header)))))
2962 (let ((number (mail-header-number header)))
2963 (push number gnus-newsgroup-limit)
2964 (push header gnus-newsgroup-headers)
2965 (if (memq number gnus-newsgroup-unselected)
2967 (push number gnus-newsgroup-unreads)
2968 (setq gnus-newsgroup-unselected
2969 (delq number gnus-newsgroup-unselected)))
2970 (push number gnus-newsgroup-ancient)))))))
2972 (defun gnus-summary-update-article-line (article header)
2973 "Update the line for ARTICLE using HEADERS."
2974 (let* ((id (mail-header-id header))
2975 (thread (gnus-id-to-thread id)))
2977 (error "Article in no thread"))
2978 ;; Update the thread.
2979 (setcar thread header)
2980 (gnus-summary-goto-subject article)
2981 (let* ((datal (gnus-data-find-list article))
2983 (length (when (cdr datal)
2984 (- (gnus-data-pos data)
2985 (gnus-data-pos (cadr datal)))))
2986 (buffer-read-only nil)
2987 (level (gnus-summary-thread-level)))
2989 (gnus-summary-insert-line
2990 header level nil (gnus-article-mark article)
2991 (memq article gnus-newsgroup-replied)
2992 (memq article gnus-newsgroup-expirable)
2993 (mail-header-subject header)
2994 nil (cdr (assq article gnus-newsgroup-scored))
2995 (memq article gnus-newsgroup-processable))
2997 (gnus-data-update-list
2998 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3000 (defun gnus-summary-update-article (article &optional iheader)
3001 "Update ARTICLE in the summary buffer."
3002 (set-buffer gnus-summary-buffer)
3003 (let* ((header (or iheader (gnus-summary-article-header article)))
3004 (id (mail-header-id header))
3005 (data (gnus-data-find article))
3006 (thread (gnus-id-to-thread id))
3007 (references (mail-header-references header))
3011 (when (and references
3012 (not (equal "" references)))
3015 (buffer-read-only nil)
3017 (number (mail-header-number header))
3020 ;; !!! Should this be in or not?
3022 (setcar thread nil))
3024 (delq thread parent))
3025 (if (gnus-summary-insert-subject id header iheader)
3026 ;; Set the (possibly) new article number in the data structure.
3027 (gnus-data-set-number data (gnus-id-to-article id))
3031 (defun gnus-rebuild-thread (id)
3032 "Rebuild the thread containing ID."
3033 (let ((buffer-read-only nil)
3034 current thread data)
3035 (if (not gnus-show-threads)
3036 (setq thread (list (car (gnus-id-to-thread id))))
3037 ;; Get the thread this article is part of.
3038 (setq thread (gnus-remove-thread id)))
3039 (setq current (save-excursion
3040 (and (zerop (forward-line -1))
3041 (gnus-summary-article-number))))
3042 ;; If this is a gathered thread, we have to go some re-gathering.
3043 (when (stringp (car thread))
3044 (let ((subject (car thread))
3046 (setq thread (cdr thread))
3048 (unless (memq (setq thr (gnus-id-to-thread
3050 (mail-header-id (caar thread)))))
3053 (setq thread (cdr thread)))
3054 ;; We now have all (unique) roots.
3055 (if (= (length roots) 1)
3056 ;; All the loose roots are now one solid root.
3057 (setq thread (car roots))
3058 (setq thread (cons subject (gnus-sort-threads roots))))))
3060 ;; We then insert this thread into the summary buffer.
3061 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3062 (if gnus-show-threads
3063 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3064 (gnus-summary-prepare-unthreaded thread))
3065 (setq data (nreverse gnus-newsgroup-data))
3066 (setq threads gnus-newsgroup-threads))
3067 ;; We splice the new data into the data structure.
3068 (gnus-data-enter-list current data)
3069 (gnus-data-compute-positions)
3070 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
3072 (defun gnus-number-to-header (number)
3073 "Return the header for article NUMBER."
3074 (let ((headers gnus-newsgroup-headers))
3076 (not (= number (mail-header-number (car headers)))))
3081 (defun gnus-parent-headers (headers &optional generation)
3082 "Return the headers of the GENERATIONeth parent of HEADERS."
3084 (setq generation 1))
3085 (let (references parent)
3086 (while (and headers (not (zerop generation)))
3087 (setq references (mail-header-references headers))
3088 (when (and references
3089 (setq parent (gnus-parent-id references))
3090 (setq headers (car (gnus-id-to-thread parent))))
3094 (defun gnus-id-to-thread (id)
3095 "Return the (sub-)thread where ID appears."
3096 (gnus-gethash id gnus-newsgroup-dependencies))
3098 (defun gnus-id-to-article (id)
3099 "Return the article number of ID."
3100 (let ((thread (gnus-id-to-thread id)))
3103 (mail-header-number (car thread)))))
3105 (defun gnus-id-to-header (id)
3106 "Return the article headers of ID."
3107 (car (gnus-id-to-thread id)))
3109 (defun gnus-article-displayed-root-p (article)
3110 "Say whether ARTICLE is a root(ish) article."
3111 (let ((level (gnus-summary-thread-level article))
3112 (refs (mail-header-references (gnus-summary-article-header article)))
3118 ((null (gnus-parent-id refs)) t)
3120 (null (setq particle (gnus-id-to-article
3121 (gnus-parent-id refs))))
3122 (null (gnus-summary-thread-level particle)))))))
3124 (defun gnus-root-id (id)
3125 "Return the id of the root of the thread where ID appears."
3127 (while (and id (setq prev (car (gnus-gethash
3128 id gnus-newsgroup-dependencies))))
3130 id (gnus-parent-id (mail-header-references prev))))
3133 (defun gnus-remove-thread (id &optional dont-remove)
3134 "Remove the thread that has ID in it."
3135 (let ((dep gnus-newsgroup-dependencies)
3136 headers thread last-id)
3137 ;; First go up in this thread until we find the root.
3138 (setq last-id (gnus-root-id id))
3139 (setq headers (list (car (gnus-id-to-thread last-id))
3140 (caadr (gnus-id-to-thread last-id))))
3141 ;; We have now found the real root of this thread. It might have
3142 ;; been gathered into some loose thread, so we have to search
3143 ;; through the threads to find the thread we wanted.
3144 (let ((threads gnus-newsgroup-threads)
3147 (setq sub (car threads))
3148 (if (stringp (car sub))
3149 ;; This is a gathered thread, so we look at the roots
3150 ;; below it to find whether this article is in this
3153 (setq sub (cdr sub))
3155 (when (member (caar sub) headers)
3156 (setq thread (car threads)
3159 (setq sub (cdr sub))))
3160 ;; It's an ordinary thread, so we check it.
3161 (when (eq (car sub) (car headers))
3164 (setq threads (cdr threads)))
3165 ;; If this article is in no thread, then it's a root.
3168 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3169 (setq thread (gnus-gethash last-id dep)))
3172 thread ; We return this thread.
3174 (if (stringp (car thread))
3176 ;; If we use dummy roots, then we have to remove the
3177 ;; dummy root as well.
3178 (when (eq gnus-summary-make-false-root 'dummy)
3181 (setq thread (cdr thread))
3183 (gnus-remove-thread-1 (car thread))
3184 (setq thread (cdr thread))))
3185 (gnus-remove-thread-1 thread))))))))
3187 (defun gnus-remove-thread-1 (thread)
3188 "Remove the thread THREAD recursively."
3189 (let ((number (mail-header-number (car thread)))
3191 (when (setq pos (text-property-any
3192 (point-min) (point-max) 'gnus-number number))
3195 (gnus-data-remove number))
3196 (setq thread (cdr thread))
3198 (gnus-remove-thread-1 (pop thread)))))
3200 (defun gnus-sort-threads (threads)
3202 (if (not gnus-thread-sort-functions)
3204 (gnus-message 7 "Sorting threads...")
3206 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3207 (gnus-message 7 "Sorting threads...done"))))
3209 (defun gnus-sort-articles (articles)
3211 (when gnus-article-sort-functions
3212 (gnus-message 7 "Sorting articles...")
3214 (setq gnus-newsgroup-headers
3215 (sort articles (gnus-make-sort-function
3216 gnus-article-sort-functions)))
3217 (gnus-message 7 "Sorting articles...done"))))
3219 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3220 (defmacro gnus-thread-header (thread)
3221 ;; Return header of first article in THREAD.
3222 ;; Note that THREAD must never, ever be anything else than a variable -
3223 ;; using some other form will lead to serious barfage.
3224 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3225 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3226 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
3229 (defsubst gnus-article-sort-by-number (h1 h2)
3230 "Sort articles by article number."
3231 (< (mail-header-number h1)
3232 (mail-header-number h2)))
3234 (defun gnus-thread-sort-by-number (h1 h2)
3235 "Sort threads by root article number."
3236 (gnus-article-sort-by-number
3237 (gnus-thread-header h1) (gnus-thread-header h2)))
3239 (defsubst gnus-article-sort-by-author (h1 h2)
3240 "Sort articles by root author."
3242 (let ((extract (funcall
3243 gnus-extract-address-components
3244 (mail-header-from h1))))
3245 (or (car extract) (cdr extract)))
3246 (let ((extract (funcall
3247 gnus-extract-address-components
3248 (mail-header-from h2))))
3249 (or (car extract) (cdr extract)))))
3251 (defun gnus-thread-sort-by-author (h1 h2)
3252 "Sort threads by root author."
3253 (gnus-article-sort-by-author
3254 (gnus-thread-header h1) (gnus-thread-header h2)))
3256 (defsubst gnus-article-sort-by-subject (h1 h2)
3257 "Sort articles by root subject."
3259 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3260 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3262 (defun gnus-thread-sort-by-subject (h1 h2)
3263 "Sort threads by root subject."
3264 (gnus-article-sort-by-subject
3265 (gnus-thread-header h1) (gnus-thread-header h2)))
3267 (defsubst gnus-article-sort-by-date (h1 h2)
3268 "Sort articles by root article date."
3270 (inline (gnus-sortable-date (mail-header-date h1)))
3271 (inline (gnus-sortable-date (mail-header-date h2)))))
3273 (defun gnus-thread-sort-by-date (h1 h2)
3274 "Sort threads by root article date."
3275 (gnus-article-sort-by-date
3276 (gnus-thread-header h1) (gnus-thread-header h2)))
3278 (defsubst gnus-article-sort-by-score (h1 h2)
3279 "Sort articles by root article score.
3280 Unscored articles will be counted as having a score of zero."
3281 (> (or (cdr (assq (mail-header-number h1)
3282 gnus-newsgroup-scored))
3283 gnus-summary-default-score 0)
3284 (or (cdr (assq (mail-header-number h2)
3285 gnus-newsgroup-scored))
3286 gnus-summary-default-score 0)))
3288 (defun gnus-thread-sort-by-score (h1 h2)
3289 "Sort threads by root article score."
3290 (gnus-article-sort-by-score
3291 (gnus-thread-header h1) (gnus-thread-header h2)))
3293 (defun gnus-thread-sort-by-total-score (h1 h2)
3294 "Sort threads by the sum of all scores in the thread.
3295 Unscored articles will be counted as having a score of zero."
3296 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3298 (defun gnus-thread-total-score (thread)
3299 ;; This function find the total score of THREAD.
3300 (cond ((null thread)
3303 (if (stringp (car thread))
3304 (apply gnus-thread-score-function 0
3305 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3306 (gnus-thread-total-score-1 thread)))
3308 (gnus-thread-total-score-1 (list thread)))))
3310 (defun gnus-thread-total-score-1 (root)
3311 ;; This function find the total score of the thread below ROOT.
3312 (setq root (car root))
3313 (apply gnus-thread-score-function
3315 (mapcar 'gnus-thread-total-score
3316 (cdr (gnus-gethash (mail-header-id root)
3317 gnus-newsgroup-dependencies)))
3318 (when (> (mail-header-number root) 0)
3319 (list (or (cdr (assq (mail-header-number root)
3320 gnus-newsgroup-scored))
3321 gnus-summary-default-score 0))))
3322 (list gnus-summary-default-score)
3325 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3326 (defvar gnus-tmp-prev-subject nil)
3327 (defvar gnus-tmp-false-parent nil)
3328 (defvar gnus-tmp-root-expunged nil)
3329 (defvar gnus-tmp-dummy-line nil)
3331 (defun gnus-summary-prepare-threads (threads)
3332 "Prepare summary buffer from THREADS and indentation LEVEL.
3333 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3334 or a straight list of headers."
3335 (gnus-message 7 "Generating summary...")
3337 (setq gnus-newsgroup-threads threads)
3340 (let ((gnus-tmp-level 0)
3341 (default-score (or gnus-summary-default-score 0))
3342 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3343 thread number subject stack state gnus-tmp-gathered beg-match
3344 new-roots gnus-tmp-new-adopts thread-end
3345 gnus-tmp-header gnus-tmp-unread
3346 gnus-tmp-replied gnus-tmp-subject-or-nil
3347 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3348 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3349 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3351 (setq gnus-tmp-prev-subject nil)
3353 (if (vectorp (car threads))
3354 ;; If this is a straight (sic) list of headers, then a
3355 ;; threaded summary display isn't required, so we just create
3356 ;; an unthreaded one.
3357 (gnus-summary-prepare-unthreaded threads)
3359 ;; Do the threaded display.
3361 (while (or threads stack gnus-tmp-new-adopts new-roots)
3363 (if (and (= gnus-tmp-level 0)
3364 (not (setq gnus-tmp-dummy-line nil))
3367 (not gnus-tmp-false-parent)
3368 (or gnus-tmp-new-adopts new-roots))
3369 (if gnus-tmp-new-adopts
3370 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3371 thread (list (car gnus-tmp-new-adopts))
3372 gnus-tmp-header (caar thread)
3373 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3375 (setq thread (list (car new-roots))
3376 gnus-tmp-header (caar thread)
3377 new-roots (cdr new-roots))))
3380 ;; If there are some threads, we do them before the
3381 ;; threads on the stack.
3382 (setq thread threads
3383 gnus-tmp-header (caar thread))
3384 ;; There were no current threads, so we pop something off
3386 (setq state (car stack)
3387 gnus-tmp-level (car state)
3390 gnus-tmp-header (caar thread))))
3392 (setq gnus-tmp-false-parent nil)
3393 (setq gnus-tmp-root-expunged nil)
3394 (setq thread-end nil)
3396 (if (stringp gnus-tmp-header)
3397 ;; The header is a dummy root.
3399 ((eq gnus-summary-make-false-root 'adopt)
3400 ;; We let the first article adopt the rest.
3401 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3403 (setq gnus-tmp-gathered
3405 (lambda (h) (mail-header-number (car h)))
3408 (setq thread (cons (list (caar thread)
3411 (setq gnus-tmp-level -1
3412 gnus-tmp-false-parent t))
3413 ((eq gnus-summary-make-false-root 'empty)
3414 ;; We print adopted articles with empty subject fields.
3415 (setq gnus-tmp-gathered
3417 (lambda (h) (mail-header-number (car h)))
3420 (setq gnus-tmp-level -1))
3421 ((eq gnus-summary-make-false-root 'dummy)
3422 ;; We remember that we probably want to output a dummy
3424 (setq gnus-tmp-dummy-line gnus-tmp-header)
3425 (setq gnus-tmp-prev-subject gnus-tmp-header))
3427 ;; We do not make a root for the gathered
3428 ;; sub-threads at all.
3429 (setq gnus-tmp-level -1)))
3431 (setq number (mail-header-number gnus-tmp-header)
3432 subject (mail-header-subject gnus-tmp-header))
3435 ;; If the thread has changed subject, we might want to make
3436 ;; this subthread into a root.
3437 ((and (null gnus-thread-ignore-subject)
3438 (not (zerop gnus-tmp-level))
3439 gnus-tmp-prev-subject
3441 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3442 (setq new-roots (nconc new-roots (list (car thread)))
3444 gnus-tmp-header nil))
3445 ;; If the article lies outside the current limit,
3446 ;; then we do not display it.
3447 ((and (not (memq number gnus-newsgroup-limit))
3448 (not gnus-tmp-dummy-line))
3449 (setq gnus-tmp-gathered
3451 (lambda (h) (mail-header-number (car h)))
3454 (setq gnus-tmp-new-adopts (if (cdar thread)
3455 (append gnus-tmp-new-adopts
3457 gnus-tmp-new-adopts)
3459 gnus-tmp-header nil)
3460 (when (zerop gnus-tmp-level)
3461 (setq gnus-tmp-root-expunged t)))
3462 ;; Perhaps this article is to be marked as read?
3463 ((and gnus-summary-mark-below
3464 (< (or (cdr (assq number gnus-newsgroup-scored))
3466 gnus-summary-mark-below)
3467 ;; Don't touch sparse articles.
3468 (not (memq number gnus-newsgroup-sparse))
3469 (not (memq number gnus-newsgroup-ancient)))
3470 (setq gnus-newsgroup-unreads
3471 (delq number gnus-newsgroup-unreads))
3472 (if gnus-newsgroup-auto-expire
3473 (push number gnus-newsgroup-expirable)
3474 (push (cons number gnus-low-score-mark)
3475 gnus-newsgroup-reads))))
3477 (when gnus-tmp-header
3478 ;; We may have an old dummy line to output before this
3480 (when gnus-tmp-dummy-line
3481 (gnus-summary-insert-dummy-line
3482 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3483 (setq gnus-tmp-dummy-line nil))
3485 ;; Compute the mark.
3486 (setq gnus-tmp-unread (gnus-article-mark number))
3488 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3489 gnus-tmp-header gnus-tmp-level)
3490 gnus-newsgroup-data)
3492 ;; Actually insert the line.
3494 gnus-tmp-subject-or-nil
3496 ((and gnus-thread-ignore-subject
3497 gnus-tmp-prev-subject
3498 (not (inline (gnus-subject-equal
3499 gnus-tmp-prev-subject subject))))
3501 ((zerop gnus-tmp-level)
3502 (if (and (eq gnus-summary-make-false-root 'empty)
3503 (memq number gnus-tmp-gathered)
3504 gnus-tmp-prev-subject
3505 (inline (gnus-subject-equal
3506 gnus-tmp-prev-subject subject)))
3507 gnus-summary-same-subject
3509 (t gnus-summary-same-subject)))
3510 (if (and (eq gnus-summary-make-false-root 'adopt)
3511 (= gnus-tmp-level 1)
3512 (memq number gnus-tmp-gathered))
3513 (setq gnus-tmp-opening-bracket ?\<
3514 gnus-tmp-closing-bracket ?\>)
3515 (setq gnus-tmp-opening-bracket ?\[
3516 gnus-tmp-closing-bracket ?\]))
3518 gnus-tmp-indentation
3519 (aref gnus-thread-indent-array gnus-tmp-level)
3520 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3521 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3522 gnus-summary-default-score 0)
3524 (if (or (null gnus-summary-default-score)
3525 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3526 gnus-summary-zcore-fuzz))
3528 (if (< gnus-tmp-score gnus-summary-default-score)
3529 gnus-score-below-mark gnus-score-over-mark))
3531 (cond ((memq number gnus-newsgroup-processable)
3533 ((memq number gnus-newsgroup-cached)
3535 ((memq number gnus-newsgroup-replied)
3537 ((memq number gnus-newsgroup-saved)
3539 (t gnus-unread-mark))
3540 gnus-tmp-from (mail-header-from gnus-tmp-header)
3543 ((string-match "(.+)" gnus-tmp-from)
3544 (substring gnus-tmp-from
3545 (1+ (match-beginning 0)) (1- (match-end 0))))
3546 ((string-match "<[^>]+> *$" gnus-tmp-from)
3547 (setq beg-match (match-beginning 0))
3548 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3549 (substring gnus-tmp-from (1+ (match-beginning 0))
3550 (1- (match-end 0))))
3551 (substring gnus-tmp-from 0 beg-match)))
3553 (when (string= gnus-tmp-name "")
3554 (setq gnus-tmp-name gnus-tmp-from))
3555 (unless (numberp gnus-tmp-lines)
3556 (setq gnus-tmp-lines 0))
3557 (gnus-put-text-property
3559 (progn (eval gnus-summary-line-format-spec) (point))
3560 'gnus-number number)
3563 (run-hooks 'gnus-summary-update-hook)
3566 (setq gnus-tmp-prev-subject subject)))
3568 (when (nth 1 thread)
3569 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3570 (incf gnus-tmp-level)
3571 (setq threads (if thread-end nil (cdar thread)))
3573 (setq gnus-tmp-level 0)))))
3574 (gnus-message 7 "Generating summary...done"))
3576 (defun gnus-summary-prepare-unthreaded (headers)
3577 "Generate an unthreaded summary buffer based on HEADERS."
3578 (let (header number mark)
3581 ;; We may have to root out some bad articles...
3582 (when (memq (setq number (mail-header-number
3583 (setq header (pop headers))))
3584 gnus-newsgroup-limit)
3585 ;; Mark article as read when it has a low score.
3586 (when (and gnus-summary-mark-below
3587 (< (or (cdr (assq number gnus-newsgroup-scored))
3588 gnus-summary-default-score 0)
3589 gnus-summary-mark-below)
3590 (not (memq number gnus-newsgroup-ancient)))
3591 (setq gnus-newsgroup-unreads
3592 (delq number gnus-newsgroup-unreads))
3593 (if gnus-newsgroup-auto-expire
3594 (push number gnus-newsgroup-expirable)
3595 (push (cons number gnus-low-score-mark)
3596 gnus-newsgroup-reads)))
3598 (setq mark (gnus-article-mark number))
3599 (push (gnus-data-make number mark (1+ (point)) header 0)
3600 gnus-newsgroup-data)
3601 (gnus-summary-insert-line
3603 mark (memq number gnus-newsgroup-replied)
3604 (memq number gnus-newsgroup-expirable)
3605 (mail-header-subject header) nil
3606 (cdr (assq number gnus-newsgroup-scored))
3607 (memq number gnus-newsgroup-processable))))))
3609 (defun gnus-select-newsgroup (group &optional read-all)
3610 "Select newsgroup GROUP.
3611 If READ-ALL is non-nil, all articles in the group are selected."
3612 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3613 (info (nth 2 entry))
3614 articles fetched-articles cached)
3616 (unless (gnus-check-server
3617 (setq gnus-current-select-method (gnus-find-method-for-group group)))
3618 (error "Couldn't open server"))
3620 (or (and entry (not (eq (car entry) t))) ; Either it's active...
3621 (gnus-activate-group group) ; Or we can activate it...
3622 (progn ; Or we bug out.
3623 (when (equal major-mode 'gnus-summary-mode)
3624 (kill-buffer (current-buffer)))
3625 (error "Couldn't request group %s: %s"
3626 group (gnus-status-message group))))
3628 (unless (gnus-request-group group t)
3629 (when (equal major-mode 'gnus-summary-mode)
3630 (kill-buffer (current-buffer)))
3631 (error "Couldn't request group %s: %s"
3632 group (gnus-status-message group)))
3634 (setq gnus-newsgroup-name group)
3635 (setq gnus-newsgroup-unselected nil)
3636 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
3638 ;; Adjust and set lists of article marks.
3640 (gnus-adjust-marked-articles info))
3642 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3643 (when (gnus-virtual-group-p group)
3644 (setq cached gnus-newsgroup-cached))
3646 (setq gnus-newsgroup-unreads
3647 (gnus-set-difference
3648 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
3649 gnus-newsgroup-dormant))
3651 (setq gnus-newsgroup-processable nil)
3653 (setq articles (gnus-articles-to-read group read-all))
3657 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
3659 ((eq articles 0) nil)
3661 ;; Init the dependencies hash table.
3662 (setq gnus-newsgroup-dependencies
3663 (gnus-make-hashtable (length articles)))
3664 ;; Retrieve the headers and read them in.
3665 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
3666 (setq gnus-newsgroup-headers
3668 (setq gnus-headers-retrieved-by
3669 (gnus-retrieve-headers
3670 articles gnus-newsgroup-name
3671 ;; We might want to fetch old headers, but
3672 ;; not if there is only 1 article.
3673 (and gnus-fetch-old-headers
3675 (not (eq gnus-fetch-old-headers 'some))
3676 (not (numberp gnus-fetch-old-headers)))
3677 (> (length articles) 1))))))
3678 (gnus-get-newsgroup-headers-xover articles)
3679 (gnus-get-newsgroup-headers)))
3680 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
3682 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3684 (setq gnus-newsgroup-cached cached))
3686 ;; Suppress duplicates?
3687 (when gnus-suppress-duplicates
3688 (gnus-dup-suppress-articles))
3690 ;; Set the initial limit.
3691 (setq gnus-newsgroup-limit (copy-sequence articles))
3692 ;; Remove canceled articles from the list of unread articles.
3693 (setq gnus-newsgroup-unreads
3694 (gnus-set-sorted-intersection
3695 gnus-newsgroup-unreads
3696 (setq fetched-articles
3697 (mapcar (lambda (headers) (mail-header-number headers))
3698 gnus-newsgroup-headers))))
3699 ;; Removed marked articles that do not exist.
3700 (gnus-update-missing-marks
3701 (gnus-sorted-complement fetched-articles articles))
3702 ;; We might want to build some more threads first.
3703 (and gnus-fetch-old-headers
3704 (eq gnus-headers-retrieved-by 'nov)
3705 (gnus-build-old-threads))
3706 ;; Check whether auto-expire is to be done in this group.
3707 (setq gnus-newsgroup-auto-expire
3708 (gnus-group-auto-expirable-p group))
3709 ;; Set up the article buffer now, if necessary.
3710 (unless gnus-single-article-buffer
3711 (gnus-article-setup-buffer))
3712 ;; First and last article in this newsgroup.
3713 (when gnus-newsgroup-headers
3714 (setq gnus-newsgroup-begin
3715 (mail-header-number (car gnus-newsgroup-headers))
3718 (gnus-last-element gnus-newsgroup-headers))))
3719 ;; GROUP is successfully selected.
3720 (or gnus-newsgroup-headers t)))))
3722 (defun gnus-articles-to-read (group read-all)
3723 ;; Find out what articles the user wants to read.
3725 ;; Select all articles if `read-all' is non-nil, or if there
3726 ;; are no unread articles.
3728 (and (zerop (length gnus-newsgroup-marked))
3729 (zerop (length gnus-newsgroup-unreads)))
3730 (eq (gnus-group-find-parameter group 'display)
3732 (gnus-uncompress-range (gnus-active group))
3733 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
3734 (copy-sequence gnus-newsgroup-unreads))
3736 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
3737 (scored (length scored-list))
3738 (number (length articles))
3739 (marked (+ (length gnus-newsgroup-marked)
3740 (length gnus-newsgroup-dormant)))
3748 ((and (or (<= scored marked) (= scored number))
3749 (numberp gnus-large-newsgroup)
3750 (> number gnus-large-newsgroup))
3754 "How many articles from %s (default %d): "
3755 gnus-newsgroup-name number))))
3756 (if (string-match "^[ \t]*$" input) number input)))
3757 ((and (> scored marked) (< scored number)
3758 (> (- scored number) 20))
3761 (format "%s %s (%d scored, %d total): "
3762 "How many articles from"
3763 group scored number))))
3764 (if (string-match "^[ \t]*$" input)
3768 (setq select (if (stringp select) (string-to-number select) select))
3769 (if (or (null select) (zerop select))
3771 (if (and (not (zerop scored)) (<= (abs select) scored))
3773 (setq articles (sort scored-list '<))
3774 (setq number (length articles)))
3775 (setq articles (copy-sequence articles)))
3777 (when (< (abs select) number)
3779 ;; Select the N oldest articles.
3780 (setcdr (nthcdr (1- (abs select)) articles) nil)
3781 ;; Select the N most recent articles.
3782 (setq articles (nthcdr (- number select) articles))))
3783 (setq gnus-newsgroup-unselected
3784 (gnus-sorted-intersection
3785 gnus-newsgroup-unreads
3786 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
3789 (defun gnus-killed-articles (killed articles)
3792 (when (inline (gnus-member-of-range (car articles) killed))
3793 (push (car articles) out))
3794 (setq articles (cdr articles)))
3797 (defun gnus-uncompress-marks (marks)
3798 "Uncompress the mark ranges in MARKS."
3799 (let ((uncompressed '(score bookmark))
3802 (if (memq (caar marks) uncompressed)
3803 (push (car marks) out)
3804 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
3805 (setq marks (cdr marks)))
3808 (defun gnus-adjust-marked-articles (info)
3809 "Set all article lists and remove all marks that are no longer legal."
3810 (let* ((marked-lists (gnus-info-marks info))
3811 (active (gnus-active (gnus-info-group info)))
3814 (types gnus-article-mark-lists)
3815 (uncompressed '(score bookmark killed))
3816 marks var articles article mark)
3819 (setq marks (pop marked-lists))
3820 (set (setq var (intern (format "gnus-newsgroup-%s"
3821 (car (rassq (setq mark (car marks))
3823 (if (memq (car marks) uncompressed) (cdr marks)
3824 (gnus-uncompress-range (cdr marks))))
3826 (setq articles (symbol-value var))
3828 ;; All articles have to be subsets of the active articles.
3830 ;; Adjust "simple" lists.
3831 ((memq mark '(tick dormant expirable reply save))
3833 (when (or (< (setq article (pop articles)) min) (> article max))
3834 (set var (delq article (symbol-value var))))))
3836 ((memq mark uncompressed)
3838 (when (or (not (consp (setq article (pop articles))))
3839 (< (car article) min)
3840 (> (car article) max))
3841 (set var (delq article (symbol-value var))))))))))
3843 (defun gnus-update-missing-marks (missing)
3844 "Go through the list of MISSING articles and remove them mark lists."
3846 (let ((types gnus-article-mark-lists)
3848 ;; Go through all types.
3850 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
3851 (when (symbol-value var)
3852 ;; This list has articles. So we delete all missing articles
3856 (set var (delq (pop m) (symbol-value var)))))))))
3858 (defun gnus-update-marks ()
3859 "Enter the various lists of marked articles into the newsgroup info list."
3860 (let ((types gnus-article-mark-lists)
3861 (info (gnus-get-info gnus-newsgroup-name))
3862 (uncompressed '(score bookmark killed))
3863 type list newmarked symbol)
3865 ;; Add all marks lists that are non-nil to the list of marks lists.
3867 (setq type (pop types))
3868 (when (setq list (symbol-value
3870 (intern (format "gnus-newsgroup-%s"
3872 (push (cons (cdr type)
3873 (if (memq (cdr type) uncompressed) list
3874 (gnus-compress-sequence
3875 (set symbol (sort list '<)) t)))
3878 ;; Enter these new marks into the info of the group.
3880 (setcar (nthcdr 3 info) newmarked)
3881 ;; Add the marks lists to the end of the info.
3883 (setcdr (nthcdr 2 info) (list newmarked))))
3885 ;; Cut off the end of the info if there's nothing else there.
3889 (when (nthcdr (decf i) info)
3890 (setcdr (nthcdr i info) nil)))))))
3892 (defun gnus-set-mode-line (where)
3893 "This function sets the mode line of the article or summary buffers.
3894 If WHERE is `summary', the summary mode line format will be used."
3895 ;; Is this mode line one we keep updated?
3896 (when (memq where gnus-updated-mode-lines)
3899 ;; We evaluate this in the summary buffer since these
3900 ;; variables are buffer-local to that buffer.
3901 (set-buffer gnus-summary-buffer)
3902 ;; We bind all these variables that are used in the `eval' form
3904 (let* ((mformat (symbol-value
3906 (format "gnus-%s-mode-line-format-spec" where))))
3907 (gnus-tmp-group-name gnus-newsgroup-name)
3908 (gnus-tmp-article-number (or gnus-current-article 0))
3909 (gnus-tmp-unread gnus-newsgroup-unreads)
3910 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
3911 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
3912 (gnus-tmp-unread-and-unselected
3913 (cond ((and (zerop gnus-tmp-unread-and-unticked)
3914 (zerop gnus-tmp-unselected))
3916 ((zerop gnus-tmp-unselected)
3917 (format "{%d more}" gnus-tmp-unread-and-unticked))
3918 (t (format "{%d(+%d) more}"
3919 gnus-tmp-unread-and-unticked
3920 gnus-tmp-unselected))))
3922 (if (and gnus-current-headers
3923 (vectorp gnus-current-headers))
3924 (gnus-mode-string-quote
3925 (mail-header-subject gnus-current-headers))
3928 gnus-tmp-header);; passed as argument to any user-format-funcs
3929 (setq mode-string (eval mformat))
3930 (setq max-len (max 4 (if gnus-mode-non-string-length
3932 gnus-mode-non-string-length)
3933 (length mode-string))))
3934 ;; We might have to chop a bit of the string off...
3935 (when (> (length mode-string) max-len)
3937 (concat (gnus-truncate-string mode-string (- max-len 3))
3939 ;; Pad the mode string a bit.
3940 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
3941 ;; Update the mode line.
3942 (setq mode-line-buffer-identification
3943 (gnus-mode-line-buffer-identification
3944 (list mode-string)))
3945 (set-buffer-modified-p t))))
3947 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
3948 "Go through the HEADERS list and add all Xrefs to a hash table.
3949 The resulting hash table is returned, or nil if no Xrefs were found."
3950 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
3951 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
3952 (xref-hashtb (make-vector 63 0))
3953 start group entry number xrefs header)
3955 (setq header (pop headers))
3956 (when (and (setq xrefs (mail-header-xref header))
3957 (not (memq (setq number (mail-header-number header))
3960 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
3961 (setq start (match-end 0))
3962 (setq group (if prefix
3963 (concat prefix (substring xrefs (match-beginning 1)
3965 (substring xrefs (match-beginning 1) (match-end 1))))
3967 (string-to-int (substring xrefs (match-beginning 2)
3969 (if (setq entry (gnus-gethash group xref-hashtb))
3970 (setcdr entry (cons number (cdr entry)))
3971 (gnus-sethash group (cons number nil) xref-hashtb)))))
3972 (and start xref-hashtb)))
3974 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
3975 "Look through all the headers and mark the Xrefs as read."
3976 (let ((virtual (gnus-virtual-group-p from-newsgroup))
3977 name entry info xref-hashtb idlist method nth4)
3979 (set-buffer gnus-group-buffer)
3980 (when (setq xref-hashtb
3981 (gnus-create-xref-hashtb from-newsgroup headers unreads))
3984 (unless (string= from-newsgroup (setq name (symbol-name group)))
3985 (setq idlist (symbol-value group))
3986 ;; Dead groups are not updated.
3988 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
3990 (when (stringp (setq nth4 (gnus-info-method info)))
3991 (setq nth4 (gnus-server-to-method nth4))))
3992 ;; Only do the xrefs if the group has the same
3993 ;; select method as the group we have just read.
3994 (or (gnus-methods-equal-p
3995 nth4 (gnus-find-method-for-group from-newsgroup))
3997 (equal nth4 (setq method (gnus-find-method-for-group
3999 (and (equal (car nth4) (car method))
4000 (equal (nth 1 nth4) (nth 1 method))))
4001 gnus-use-cross-reference
4002 (or (not (eq gnus-use-cross-reference t))
4004 ;; Only do cross-references on subscribed
4005 ;; groups, if that is what is wanted.
4006 (<= (gnus-info-level info) gnus-level-subscribed))
4007 (gnus-group-make-articles-read name idlist))))
4010 (defun gnus-group-make-articles-read (group articles)
4011 "Update the info of GROUP to say that only ARTICLES are unread."
4013 (entry (gnus-gethash group gnus-newsrc-hashtb))
4014 (info (nth 2 entry))
4015 (active (gnus-active group))
4017 ;; First peel off all illegal article numbers.
4019 (let ((ids articles)
4021 (while (setq id (pop ids))
4022 (when (and first (> id (cdr active)))
4023 ;; We'll end up in this situation in one particular
4024 ;; obscure situation. If you re-scan a group and get
4025 ;; a new article that is cross-posted to a different
4026 ;; group that has not been re-scanned, you might get
4027 ;; crossposted article that has a higher number than
4028 ;; Gnus believes possible. So we re-activate this
4029 ;; group as well. This might mean doing the
4030 ;; crossposting thingy will *increase* the number
4031 ;; of articles in some groups. Tsk, tsk.
4032 (setq active (or (gnus-activate-group group) active)))
4033 (when (or (> id (cdr active))
4034 (< id (car active)))
4035 (setq articles (delq id articles))))))
4038 (gnus-info-set-marks ,info ,(gnus-info-marks info))
4039 (gnus-info-set-read ,info ,(gnus-info-read info))
4040 (gnus-group-update-group group t)))
4041 ;; If the read list is nil, we init it.
4043 (null (gnus-info-read info))
4045 (gnus-info-set-read info (cons 1 (1- (car active)))))
4046 ;; Then we add the read articles to the range.
4051 (gnus-info-read info) (setq articles (sort articles '<)))))
4052 ;; Then we have to re-compute how many unread
4053 ;; articles there are in this group.
4057 (setq num (- (1+ (cdr active)) (car active))))
4058 ((not (listp (cdr range)))
4059 (setq num (- (cdr active) (- (1+ (cdr range))
4063 (if (numberp (car range))
4065 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4066 (setq range (cdr range)))
4067 (setq num (- (cdr active) num))))
4068 ;; Update the number of unread articles.
4070 ;; Update the group buffer.
4071 (gnus-group-update-group group t))))
4073 (defun gnus-methods-equal-p (m1 m2)
4074 (let ((m1 (or m1 gnus-select-method))
4075 (m2 (or m2 gnus-select-method)))
4077 (and (eq (car m1) (car m2))
4078 (or (not (memq 'address (assoc (symbol-name (car m1))
4079 gnus-valid-select-methods)))
4080 (equal (nth 1 m1) (nth 1 m2)))))))
4082 (defsubst gnus-header-value ()
4083 (buffer-substring (match-end 0) (gnus-point-at-eol)))
4085 (defvar gnus-newsgroup-none-id 0)
4087 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4088 (let ((cur nntp-server-buffer)
4091 (save-excursion (set-buffer gnus-summary-buffer)
4092 gnus-newsgroup-dependencies)))
4093 headers id id-dep ref-dep end ref)
4095 (set-buffer nntp-server-buffer)
4096 ;; Translate all TAB characters into SPACE characters.
4097 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4098 (run-hooks 'gnus-parse-headers-hook)
4099 (let ((case-fold-search t)
4100 in-reply-to header p lines)
4101 (goto-char (point-min))
4102 ;; Search to the beginning of the next header. Error messages
4103 ;; do not begin with 2 or 3.
4104 (while (re-search-forward "^[23][0-9]+ " nil t)
4107 ;; This implementation of this function, with nine
4108 ;; search-forwards instead of the one re-search-forward and
4109 ;; a case (which basically was the old function) is actually
4110 ;; about twice as fast, even though it looks messier. You
4111 ;; can't have everything, I guess. Speed and elegance
4112 ;; doesn't always go hand in hand.
4121 (narrow-to-region (point)
4122 (or (and (search-forward "\n.\n" nil t)
4128 (if (search-forward "\nsubject: " nil t)
4129 (gnus-header-value) "(none)"))
4133 (if (search-forward "\nfrom: " nil t)
4134 (gnus-header-value) "(nobody)"))
4138 (if (search-forward "\ndate: " nil t)
4139 (gnus-header-value) ""))
4143 (if (search-forward "\nmessage-id: " nil t)
4144 (setq id (gnus-header-value))
4145 ;; If there was no message-id, we just fake one to make
4146 ;; subsequent routines simpler.
4147 (setq id (concat "none+"
4149 (setq gnus-newsgroup-none-id
4150 (1+ gnus-newsgroup-none-id)))))))
4154 (if (search-forward "\nreferences: " nil t)
4163 (search-backward ">" end t)
4166 (search-backward "<" end t)
4168 ;; Get the references from the in-reply-to header if there
4169 ;; were no references and the in-reply-to header looks
4171 (if (and (search-forward "\nin-reply-to: " nil t)
4172 (setq in-reply-to (gnus-header-value))
4173 (string-match "<[^>]+>" in-reply-to))
4174 (setq ref (substring in-reply-to (match-beginning 0)
4182 (if (search-forward "\nlines: " nil t)
4183 (if (numberp (setq lines (read cur)))
4189 (and (search-forward "\nxref: " nil t)
4190 (gnus-header-value)))))
4191 (when (equal id ref)
4193 ;; We do the threading while we read the headers. The
4194 ;; message-id and the last reference are both entered into
4195 ;; the same hash table. Some tippy-toeing around has to be
4196 ;; done in case an article has arrived before the article
4197 ;; which it refers to.
4198 (if (boundp (setq id-dep (intern id dependencies)))
4199 (if (and (car (symbol-value id-dep))
4201 ;; An article with this Message-ID has already
4202 ;; been seen, so we ignore this one, except we add
4203 ;; any additional Xrefs (in case the two articles
4204 ;; came from different servers).
4206 (mail-header-set-xref
4207 (car (symbol-value id-dep))
4208 (concat (or (mail-header-xref
4209 (car (symbol-value id-dep)))
4211 (or (mail-header-xref header) "")))
4213 (setcar (symbol-value id-dep) header))
4214 (set id-dep (list header)))
4216 (if (boundp (setq ref-dep (intern ref dependencies)))
4217 (setcdr (symbol-value ref-dep)
4218 (nconc (cdr (symbol-value ref-dep))
4219 (list (symbol-value id-dep))))
4220 (set ref-dep (list nil (symbol-value id-dep))))
4221 (push header headers))
4222 (goto-char (point-max))
4224 (nreverse headers)))))
4226 ;; The following macros and functions were written by Felix Lee
4227 ;; <flee@cse.psu.edu>.
4229 (defmacro gnus-nov-read-integer ()
4231 (if (= (following-char) ?\t)
4233 (let ((num (condition-case nil (read buffer) (error nil))))
4234 (if (numberp num) num 0)))
4238 (defmacro gnus-nov-skip-field ()
4239 '(search-forward "\t" eol 'move))
4241 (defmacro gnus-nov-field ()
4242 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
4244 (defvar gnus-nov-none-counter 0)
4246 ;; This function has to be called with point after the article number
4247 ;; on the beginning of the line.
4248 (defun gnus-nov-parse-line (number dependencies &optional force-new)
4249 (let ((eol (gnus-point-at-eol))
4250 (buffer (current-buffer))
4251 header ref id id-dep ref-dep)
4253 ;; overview: [num subject from date id refs chars lines misc]
4254 (narrow-to-region (point) eol)
4261 (gnus-nov-field) ; subject
4262 (gnus-nov-field) ; from
4263 (gnus-nov-field) ; date
4264 (setq id (or (gnus-nov-field)
4267 (incf gnus-nov-none-counter))))) ; id
4269 (let ((beg (point)))
4270 (search-forward "\t" eol)
4271 (if (search-backward ">" beg t)
4275 (search-backward "<" beg t)))
4278 (gnus-nov-field)) ; refs
4279 (gnus-nov-read-integer) ; chars
4280 (gnus-nov-read-integer) ; lines
4281 (if (= (following-char) ?\n)
4283 (gnus-nov-field)) ; misc
4288 ;; We build the thread tree.
4289 (when (equal id ref)
4290 ;; This article refers back to itself. Naughty, naughty.
4292 (if (boundp (setq id-dep (intern id dependencies)))
4293 (if (and (car (symbol-value id-dep))
4295 ;; An article with this Message-ID has already been seen,
4296 ;; so we ignore this one, except we add any additional
4297 ;; Xrefs (in case the two articles came from different
4300 (mail-header-set-xref
4301 (car (symbol-value id-dep))
4302 (concat (or (mail-header-xref
4303 (car (symbol-value id-dep)))
4305 (or (mail-header-xref header) "")))
4307 (setcar (symbol-value id-dep) header))
4308 (set id-dep (list header)))
4310 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
4311 (setcdr (symbol-value ref-dep)
4312 (nconc (cdr (symbol-value ref-dep))
4313 (list (symbol-value id-dep))))
4314 (set ref-dep (list nil (symbol-value id-dep)))))
4317 ;; Goes through the xover lines and returns a list of vectors
4318 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4319 force-new dependencies)
4320 "Parse the news overview data in the server buffer, and return a
4321 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4322 ;; Get the Xref when the users reads the articles since most/some
4323 ;; NNTP servers do not include Xrefs when using XOVER.
4324 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4325 (let ((cur nntp-server-buffer)
4326 (dependencies (or dependencies gnus-newsgroup-dependencies))
4327 number headers header)
4329 (set-buffer nntp-server-buffer)
4330 ;; Allow the user to mangle the headers before parsing them.
4331 (run-hooks 'gnus-parse-headers-hook)
4332 (goto-char (point-min))
4335 (while (and sequence (not (eobp)))
4336 (setq number (read cur))
4337 (while (and sequence
4338 (< (car sequence) number))
4339 (setq sequence (cdr sequence)))
4341 (eq number (car sequence))
4343 (setq sequence (cdr sequence))
4344 (setq header (inline
4345 (gnus-nov-parse-line
4346 number dependencies force-new))))
4347 (push header headers))
4350 (gnus-error 4 "Strange nov line")))
4352 (nreverse headers))))
4354 (defun gnus-article-get-xrefs ()
4355 "Fill in the Xref value in `gnus-current-headers', if necessary.
4356 This is meant to be called in `gnus-article-internal-prepare-hook'."
4357 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4358 gnus-current-headers)))
4359 (or (not gnus-use-cross-reference)
4361 (and (mail-header-xref headers)
4362 (not (string= (mail-header-xref headers) "")))
4363 (let ((case-fold-search t)
4366 (nnheader-narrow-to-headers)
4367 (goto-char (point-min))
4368 (when (or (and (eq (downcase (following-char)) ?x)
4369 (looking-at "Xref:"))
4370 (search-forward "\nXref:" nil t))
4371 (goto-char (1+ (match-end 0)))
4372 (setq xref (buffer-substring (point)
4373 (progn (end-of-line) (point))))
4374 (mail-header-set-xref headers xref)))))))
4376 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4377 "Find article ID and insert the summary line for that article."
4378 (let ((header (if (and old-header use-old-header)
4379 old-header (gnus-read-header id)))
4380 (number (and (numberp id) id))
4383 ;; Rebuild the thread that this article is part of and go to the
4384 ;; article we have fetched.
4385 (when (and (not gnus-show-threads)
4387 (when (setq pos (text-property-any
4388 (point-min) (point-max) 'gnus-number
4389 (mail-header-number old-header)))
4392 (gnus-data-remove (mail-header-number old-header))))
4394 (mail-header-set-number header (mail-header-number old-header)))
4395 (setq gnus-newsgroup-sparse
4396 (delq (setq number (mail-header-number header))
4397 gnus-newsgroup-sparse))
4398 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4399 (gnus-rebuild-thread (mail-header-id header))
4400 (gnus-summary-goto-subject number nil t))
4401 (when (and (numberp number)
4403 ;; We have to update the boundaries even if we can't fetch the
4404 ;; article if ID is a number -- so that the next `P' or `N'
4405 ;; command will fetch the previous (or next) article even
4406 ;; if the one we tried to fetch this time has been canceled.
4407 (when (> number gnus-newsgroup-end)
4408 (setq gnus-newsgroup-end number))
4409 (when (< number gnus-newsgroup-begin)
4410 (setq gnus-newsgroup-begin number))
4411 (setq gnus-newsgroup-unselected
4412 (delq number gnus-newsgroup-unselected)))
4413 ;; Report back a success?
4414 (and header (mail-header-number header))))
4416 ;;; Process/prefix in the summary buffer
4418 (defun gnus-summary-work-articles (n)
4419 "Return a list of articles to be worked upon. The prefix argument,
4420 the list of process marked articles, and the current article will be
4421 taken into consideration."
4424 ;; A numerical prefix has been given.
4425 (let ((backward (< n 0))
4426 (n (abs (prefix-numeric-value n)))
4431 (push (setq article (gnus-summary-article-number))
4434 (gnus-summary-find-prev nil article)
4435 (gnus-summary-find-next nil article)))
4437 (nreverse articles)))
4438 ((and (boundp 'transient-mark-mode)
4441 ;; Work on the region between point and mark.
4442 (let ((max (max (point) (mark)))
4445 (goto-char (min (point) (mark)))
4448 (push (setq article (gnus-summary-article-number)) articles)
4449 (gnus-summary-find-next nil article)
4451 (nreverse articles))))
4452 (gnus-newsgroup-processable
4453 ;; There are process-marked articles present.
4454 ;; Save current state.
4455 (gnus-summary-save-process-mark)
4457 (reverse gnus-newsgroup-processable))
4459 ;; Just return the current article.
4460 (list (gnus-summary-article-number)))))
4462 (defun gnus-summary-save-process-mark ()
4463 "Push the current set of process marked articles on the stack."
4465 (push (copy-sequence gnus-newsgroup-processable)
4466 gnus-newsgroup-process-stack))
4468 (defun gnus-summary-kill-process-mark ()
4469 "Push the current set of process marked articles on the stack and unmark."
4471 (gnus-summary-save-process-mark)
4472 (gnus-summary-unmark-all-processable))
4474 (defun gnus-summary-yank-process-mark ()
4475 "Pop the last process mark state off the stack and restore it."
4477 (unless gnus-newsgroup-process-stack
4478 (error "Empty mark stack"))
4479 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4481 (defun gnus-summary-process-mark-set (set)
4482 "Make SET into the current process marked articles."
4483 (gnus-summary-unmark-all-processable)
4485 (gnus-summary-set-process-mark (pop set))))
4487 ;;; Searching and stuff
4489 (defun gnus-summary-search-group (&optional backward use-level)
4490 "Search for next unread newsgroup.
4491 If optional argument BACKWARD is non-nil, search backward instead."
4493 (set-buffer gnus-group-buffer)
4494 (when (gnus-group-search-forward
4495 backward nil (if use-level (gnus-group-group-level) nil))
4496 (gnus-group-group-name))))
4498 (defun gnus-summary-best-group (&optional exclude-group)
4499 "Find the name of the best unread group.
4500 If EXCLUDE-GROUP, do not go to this group."
4502 (set-buffer gnus-group-buffer)
4504 (gnus-group-best-unread-group exclude-group))))
4506 (defun gnus-summary-find-next (&optional unread article backward)
4507 (if backward (gnus-summary-find-prev)
4508 (let* ((dummy (gnus-summary-article-intangible-p))
4509 (article (or article (gnus-summary-article-number)))
4510 (arts (gnus-data-find-list article))
4512 (when (and (not dummy)
4513 (or (not gnus-summary-check-current)
4515 (not (gnus-data-unread-p (car arts)))))
4516 (setq arts (cdr arts)))
4521 (when (gnus-data-unread-p (car arts))
4522 (setq result (car arts)
4524 (setq arts (cdr arts)))
4527 (goto-char (gnus-data-pos result))
4528 (gnus-data-number result)))))
4530 (defun gnus-summary-find-prev (&optional unread article)
4531 (let* ((eobp (eobp))
4532 (article (or article (gnus-summary-article-number)))
4533 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
4535 (when (and (not eobp)
4536 (or (not gnus-summary-check-current)
4538 (not (gnus-data-unread-p (car arts)))))
4539 (setq arts (cdr arts)))
4544 (when (gnus-data-unread-p (car arts))
4545 (setq result (car arts)
4547 (setq arts (cdr arts)))
4550 (goto-char (gnus-data-pos result))
4551 (gnus-data-number result))))
4553 (defun gnus-summary-find-subject (subject &optional unread backward article)
4554 (let* ((simp-subject (gnus-simplify-subject-fully subject))
4555 (article (or article (gnus-summary-article-number)))
4556 (articles (gnus-data-list backward))
4557 (arts (gnus-data-find-list article articles))
4559 (when (or (not gnus-summary-check-current)
4561 (not (gnus-data-unread-p (car arts))))
4562 (setq arts (cdr arts)))
4564 (and (or (not unread)
4565 (gnus-data-unread-p (car arts)))
4566 (vectorp (gnus-data-header (car arts)))
4568 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
4569 (setq result (car arts)
4571 (setq arts (cdr arts)))
4573 (goto-char (gnus-data-pos result))
4574 (gnus-data-number result))))
4576 (defun gnus-summary-search-forward (&optional unread subject backward)
4577 "Search forward for an article.
4578 If UNREAD, look for unread articles. If SUBJECT, look for
4579 articles with that subject. If BACKWARD, search backward instead."
4580 (cond (subject (gnus-summary-find-subject subject unread backward))
4581 (backward (gnus-summary-find-prev unread))
4582 (t (gnus-summary-find-next unread))))
4584 (defun gnus-recenter (&optional n)
4585 "Center point in window and redisplay frame.
4586 Also do horizontal recentering."
4588 (when (and gnus-auto-center-summary
4589 (not (eq gnus-auto-center-summary 'vertical)))
4590 (gnus-horizontal-recenter))
4593 (defun gnus-summary-recenter ()
4594 "Center point in the summary window.
4595 If `gnus-auto-center-summary' is nil, or the article buffer isn't
4596 displayed, no centering will be performed."
4597 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
4598 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
4599 (let* ((top (cond ((< (window-height) 4) 0)
4600 ((< (window-height) 7) 1)
4602 (height (1- (window-height)))
4603 (bottom (save-excursion (goto-char (point-max))
4604 (forward-line (- height))
4606 (window (get-buffer-window (current-buffer))))
4607 ;; The user has to want it.
4608 (when gnus-auto-center-summary
4609 (when (get-buffer-window gnus-article-buffer)
4610 ;; Only do recentering when the article buffer is displayed,
4611 ;; Set the window start to either `bottom', which is the biggest
4612 ;; possible valid number, or the second line from the top,
4613 ;; whichever is the least.
4615 window (min bottom (save-excursion
4616 (forward-line (- top)) (point)))))
4617 ;; Do horizontal recentering while we're at it.
4618 (when (and (get-buffer-window (current-buffer) t)
4619 (not (eq gnus-auto-center-summary 'vertical)))
4620 (let ((selected (selected-window)))
4621 (select-window (get-buffer-window (current-buffer) t))
4622 (gnus-summary-position-point)
4623 (gnus-horizontal-recenter)
4624 (select-window selected))))))
4626 (defun gnus-summary-jump-to-group (newsgroup)
4627 "Move point to NEWSGROUP in group mode buffer."
4628 ;; Keep update point of group mode buffer if visible.
4629 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
4630 (save-window-excursion
4631 ;; Take care of tree window mode.
4632 (when (get-buffer-window gnus-group-buffer)
4633 (pop-to-buffer gnus-group-buffer))
4634 (gnus-group-jump-to-group newsgroup))
4636 ;; Take care of tree window mode.
4637 (if (get-buffer-window gnus-group-buffer)
4638 (pop-to-buffer gnus-group-buffer)
4639 (set-buffer gnus-group-buffer))
4640 (gnus-group-jump-to-group newsgroup))))
4642 ;; This function returns a list of article numbers based on the
4643 ;; difference between the ranges of read articles in this group and
4644 ;; the range of active articles.
4645 (defun gnus-list-of-unread-articles (group)
4646 (let* ((read (gnus-info-read (gnus-get-info group)))
4647 (active (or (gnus-active group) (gnus-activate-group group)))
4650 ;; If none are read, then all are unread.
4652 (setq first (car active))
4653 ;; If the range of read articles is a single range, then the
4654 ;; first unread article is the article after the last read
4655 ;; article. Sounds logical, doesn't it?
4656 (if (not (listp (cdr read)))
4657 (setq first (1+ (cdr read)))
4658 ;; `read' is a list of ranges.
4659 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
4665 (while (< first nlast)
4667 (setq first (1+ first))))
4668 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
4669 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
4670 (setq read (cdr read)))))
4671 ;; And add the last unread articles.
4672 (while (<= first last)
4674 (setq first (1+ first)))
4675 ;; Return the list of unread articles.
4678 (defun gnus-list-of-read-articles (group)
4679 "Return a list of unread, unticked and non-dormant articles."
4680 (let* ((info (gnus-get-info group))
4681 (marked (gnus-info-marks info))
4682 (active (gnus-active group)))
4684 (gnus-set-difference
4685 (gnus-sorted-complement
4686 (gnus-uncompress-range active)
4687 (gnus-list-of-unread-articles group))
4689 (gnus-uncompress-range (cdr (assq 'dormant marked)))
4690 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
4692 ;; Various summary commands
4694 (defun gnus-summary-universal-argument (arg)
4695 "Perform any operation on all articles that are process/prefixed."
4697 (gnus-set-global-variables)
4698 (let ((articles (gnus-summary-work-articles arg))
4705 (substitute-command-keys
4706 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
4709 (gnus-error 1 "Undefined key")
4712 (gnus-summary-goto-subject (setq article (pop articles)))
4713 (command-execute func)
4714 (gnus-summary-remove-process-mark article)))))
4715 (gnus-summary-position-point))
4717 (defun gnus-summary-toggle-truncation (&optional arg)
4718 "Toggle truncation of summary lines.
4719 With arg, turn line truncation on iff arg is positive."
4721 (setq truncate-lines
4722 (if (null arg) (not truncate-lines)
4723 (> (prefix-numeric-value arg) 0)))
4726 (defun gnus-summary-reselect-current-group (&optional all rescan)
4727 "Exit and then reselect the current newsgroup.
4728 The prefix argument ALL means to select all articles."
4730 (gnus-set-global-variables)
4731 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
4732 (error "Ephemeral groups can't be reselected"))
4733 (let ((current-subject (gnus-summary-article-number))
4734 (group gnus-newsgroup-name))
4735 (setq gnus-newsgroup-begin nil)
4737 ;; We have to adjust the point of group mode buffer because the
4738 ;; current point was moved to the next unread newsgroup by
4740 (gnus-summary-jump-to-group group)
4743 (gnus-group-get-new-news-this-group 1)))
4744 (gnus-group-read-group all t)
4745 (gnus-summary-goto-subject current-subject nil t)))
4747 (defun gnus-summary-rescan-group (&optional all)
4748 "Exit the newsgroup, ask for new articles, and select the newsgroup."
4750 (gnus-summary-reselect-current-group all t))
4752 (defun gnus-summary-update-info ()
4753 (let ((group gnus-newsgroup-name))
4754 (when gnus-newsgroup-kill-headers
4755 (setq gnus-newsgroup-killed
4756 (gnus-compress-sequence
4758 (gnus-set-sorted-intersection
4759 (gnus-uncompress-range gnus-newsgroup-killed)
4760 (setq gnus-newsgroup-unselected
4761 (sort gnus-newsgroup-unselected '<)))
4762 (setq gnus-newsgroup-unreads
4763 (sort gnus-newsgroup-unreads '<)))
4765 (unless (listp (cdr gnus-newsgroup-killed))
4766 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
4767 (let ((headers gnus-newsgroup-headers))
4768 (run-hooks 'gnus-exit-group-hook)
4769 (unless gnus-save-score
4770 (setq gnus-newsgroup-scored nil))
4771 ;; Set the new ranges of read articles.
4772 (gnus-update-read-articles
4773 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
4774 ;; Set the current article marks.
4776 ;; Do the cross-ref thing.
4777 (when gnus-use-cross-reference
4778 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
4779 ;; Do adaptive scoring, and possibly save score files.
4780 (when gnus-newsgroup-adaptive
4781 (gnus-score-adaptive))
4782 (when gnus-use-scoring
4784 ;; Do not switch windows but change the buffer to work.
4785 (set-buffer gnus-group-buffer)
4786 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
4787 (gnus-group-update-group group)))))
4789 (defun gnus-summary-exit (&optional temporary)
4790 "Exit reading current newsgroup, and then return to group selection mode.
4791 gnus-exit-group-hook is called with no arguments if that value is non-nil."
4793 (gnus-set-global-variables)
4794 (gnus-kill-save-kill-buffer)
4795 (let* ((group gnus-newsgroup-name)
4796 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
4798 (buf (current-buffer)))
4799 (run-hooks 'gnus-summary-prepare-exit-hook)
4800 ;; If we have several article buffers, we kill them at exit.
4801 (unless gnus-single-article-buffer
4802 (gnus-kill-buffer gnus-original-article-buffer)
4803 (setq gnus-article-current nil))
4804 (when gnus-use-cache
4805 (gnus-cache-possibly-remove-articles)
4806 (gnus-cache-save-buffers))
4807 (gnus-async-prefetch-remove-group group)
4808 (when gnus-suppress-duplicates
4809 (gnus-dup-enter-articles))
4810 (when gnus-use-trees
4811 (gnus-tree-close group))
4812 ;; Make all changes in this group permanent.
4814 (gnus-summary-update-info))
4815 (gnus-close-group group)
4816 ;; Make sure where I was, and go to next newsgroup.
4817 (set-buffer gnus-group-buffer)
4819 (gnus-group-jump-to-group group))
4820 (run-hooks 'gnus-summary-exit-hook)
4822 (gnus-group-next-unread-group 1))
4825 ;; If we have several article buffers, we kill them at exit.
4826 (unless gnus-single-article-buffer
4827 (gnus-kill-buffer gnus-article-buffer)
4828 (gnus-kill-buffer gnus-original-article-buffer)
4829 (setq gnus-article-current nil))
4831 (if (not gnus-kill-summary-on-exit)
4832 (gnus-deaden-summary)
4833 ;; We set all buffer-local variables to nil. It is unclear why
4834 ;; this is needed, but if we don't, buffer-local variables are
4835 ;; not garbage-collected, it seems. This would the lead to en
4836 ;; ever-growing Emacs.
4837 (gnus-summary-clear-local-variables)
4838 (when (get-buffer gnus-article-buffer)
4839 (bury-buffer gnus-article-buffer))
4840 ;; We clear the global counterparts of the buffer-local
4841 ;; variables as well, just to be on the safe side.
4842 (set-buffer gnus-group-buffer)
4843 (gnus-summary-clear-local-variables)
4844 ;; Return to group mode buffer.
4845 (when (eq mode 'gnus-summary-mode)
4846 (gnus-kill-buffer buf)))
4847 (setq gnus-current-select-method gnus-select-method)
4848 (pop-to-buffer gnus-group-buffer)
4849 ;; Clear the current group name.
4850 (if (not quit-config)
4852 (gnus-group-jump-to-group group)
4853 (gnus-group-next-unread-group 1)
4854 (gnus-configure-windows 'group 'force))
4855 (gnus-handle-ephemeral-exit quit-config))
4857 (setq gnus-newsgroup-name nil)))))
4859 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
4860 (defun gnus-summary-exit-no-update (&optional no-questions)
4861 "Quit reading current newsgroup without updating read article info."
4863 (gnus-set-global-variables)
4864 (let* ((group gnus-newsgroup-name)
4865 (quit-config (gnus-group-quit-config group)))
4866 (when (or no-questions
4868 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
4869 ;; If we have several article buffers, we kill them at exit.
4870 (unless gnus-single-article-buffer
4871 (gnus-kill-buffer gnus-article-buffer)
4872 (gnus-kill-buffer gnus-original-article-buffer)
4873 (setq gnus-article-current nil))
4874 (if (not gnus-kill-summary-on-exit)
4875 (gnus-deaden-summary)
4876 (gnus-close-group group)
4877 (gnus-summary-clear-local-variables)
4878 (set-buffer gnus-group-buffer)
4879 (gnus-summary-clear-local-variables)
4880 (when (get-buffer gnus-summary-buffer)
4881 (kill-buffer gnus-summary-buffer)))
4882 (unless gnus-single-article-buffer
4883 (setq gnus-article-current nil))
4884 (when gnus-use-trees
4885 (gnus-tree-close group))
4886 (gnus-async-prefetch-remove-group group)
4887 (when (get-buffer gnus-article-buffer)
4888 (bury-buffer gnus-article-buffer))
4889 ;; Return to the group buffer.
4890 (gnus-configure-windows 'group 'force)
4891 ;; Clear the current group name.
4892 (setq gnus-newsgroup-name nil)
4893 (when (equal (gnus-group-group-name) group)
4894 (gnus-group-next-unread-group 1))
4896 (gnus-handle-ephemeral-exit quit-config)))))
4898 (defun gnus-handle-ephemeral-exit (quit-config)
4899 "Handle movement when leaving an ephemeral group. The state
4900 which existed when entering the ephemeral is reset."
4901 (if (not (buffer-name (car quit-config)))
4902 (gnus-configure-windows 'group 'force)
4903 (set-buffer (car quit-config))
4904 (cond ((eq major-mode 'gnus-summary-mode)
4905 (gnus-set-global-variables))
4906 ((eq major-mode 'gnus-article-mode)
4908 ;; The `gnus-summary-buffer' variable may point
4909 ;; to the old summary buffer when using a single
4911 (unless (gnus-buffer-live-p gnus-summary-buffer)
4912 (set-buffer gnus-group-buffer))
4913 (set-buffer gnus-summary-buffer)
4914 (gnus-set-global-variables))))
4915 (if (or (eq (cdr quit-config) 'article)
4916 (eq (cdr quit-config) 'pick))
4918 ;; The current article may be from the ephemeral group
4919 ;; thus it is best that we reload this article
4920 (gnus-summary-show-article)
4921 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
4922 (gnus-configure-windows 'pick 'force)
4923 (gnus-configure-windows (cdr quit-config) 'force)))
4924 (gnus-configure-windows (cdr quit-config) 'force))))
4928 (defvar gnus-dead-summary-mode-map nil)
4930 (unless gnus-dead-summary-mode-map
4931 (setq gnus-dead-summary-mode-map (make-keymap))
4932 (suppress-keymap gnus-dead-summary-mode-map)
4933 (substitute-key-definition
4934 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
4935 (let ((keys '("\C-d" "\r" "\177")))
4937 (define-key gnus-dead-summary-mode-map
4938 (pop keys) 'gnus-summary-wake-up-the-dead))))
4940 (defvar gnus-dead-summary-mode nil
4941 "Minor mode for Gnus summary buffers.")
4943 (defun gnus-dead-summary-mode (&optional arg)
4944 "Minor mode for Gnus summary buffers."
4946 (when (eq major-mode 'gnus-summary-mode)
4947 (make-local-variable 'gnus-dead-summary-mode)
4948 (setq gnus-dead-summary-mode
4949 (if (null arg) (not gnus-dead-summary-mode)
4950 (> (prefix-numeric-value arg) 0)))
4951 (when gnus-dead-summary-mode
4952 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
4953 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
4954 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
4955 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
4956 minor-mode-map-alist)))))
4958 (defun gnus-deaden-summary ()
4959 "Make the current summary buffer into a dead summary buffer."
4960 ;; Kill any previous dead summary buffer.
4961 (when (and gnus-dead-summary
4962 (buffer-name gnus-dead-summary))
4964 (set-buffer gnus-dead-summary)
4965 (when gnus-dead-summary-mode
4966 (kill-buffer (current-buffer)))))
4967 ;; Make this the current dead summary.
4968 (setq gnus-dead-summary (current-buffer))
4969 (gnus-dead-summary-mode 1)
4970 (let ((name (buffer-name)))
4971 (when (string-match "Summary" name)
4973 (concat (substring name 0 (match-beginning 0)) "Dead "
4974 (substring name (match-beginning 0)))
4977 (defun gnus-kill-or-deaden-summary (buffer)
4978 "Kill or deaden the summary BUFFER."
4979 (when (and (buffer-name buffer)
4980 (not gnus-single-article-buffer))
4983 (gnus-kill-buffer gnus-article-buffer)
4984 (gnus-kill-buffer gnus-original-article-buffer)))
4985 (cond (gnus-kill-summary-on-exit
4986 (when (and gnus-use-trees
4987 (and (get-buffer buffer)
4988 (buffer-name (get-buffer buffer))))
4990 (set-buffer (get-buffer buffer))
4991 (gnus-tree-close gnus-newsgroup-name)))
4992 (gnus-kill-buffer buffer))
4993 ((and (get-buffer buffer)
4994 (buffer-name (get-buffer buffer)))
4997 (gnus-deaden-summary)))))
4999 (defun gnus-summary-wake-up-the-dead (&rest args)
5000 "Wake up the dead summary buffer."
5002 (gnus-dead-summary-mode -1)
5003 (let ((name (buffer-name)))
5004 (when (string-match "Dead " name)
5006 (concat (substring name 0 (match-beginning 0))
5007 (substring name (match-end 0)))
5009 (gnus-message 3 "This dead summary is now alive again"))
5011 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5012 (defun gnus-summary-fetch-faq (&optional faq-dir)
5013 "Fetch the FAQ for the current group.
5014 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5018 (when current-prefix-arg
5020 "Faq dir: " (and (listp gnus-group-faq-directory)
5021 gnus-group-faq-directory)))))
5022 (let (gnus-faq-buffer)
5023 (when (setq gnus-faq-buffer
5024 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5025 (gnus-configure-windows 'summary-faq))))
5027 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5028 (defun gnus-summary-describe-group (&optional force)
5029 "Describe the current newsgroup."
5031 (gnus-group-describe-group force gnus-newsgroup-name))
5033 (defun gnus-summary-describe-briefly ()
5034 "Describe summary mode commands briefly."
5037 (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")))
5039 ;; Walking around group mode buffer from summary mode.
5041 (defun gnus-summary-next-group (&optional no-article target-group backward)
5042 "Exit current newsgroup and then select next unread newsgroup.
5043 If prefix argument NO-ARTICLE is non-nil, no article is selected
5044 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5045 previous group instead."
5047 (gnus-set-global-variables)
5048 (let ((current-group gnus-newsgroup-name)
5049 (current-buffer (current-buffer))
5051 ;; First we semi-exit this group to update Xrefs and all variables.
5052 ;; We can't do a real exit, because the window conf must remain
5053 ;; the same in case the user is prompted for info, and we don't
5054 ;; want the window conf to change before that...
5055 (gnus-summary-exit t)
5056 (while (not entered)
5057 ;; Then we find what group we are supposed to enter.
5058 (set-buffer gnus-group-buffer)
5059 (gnus-group-jump-to-group current-group)
5062 (if (eq gnus-keep-same-level 'best)
5063 (gnus-summary-best-group gnus-newsgroup-name)
5064 (gnus-summary-search-group backward gnus-keep-same-level))))
5065 (if (not target-group)
5066 ;; There are no further groups, so we return to the group
5069 (gnus-message 5 "Returning to the group buffer")
5071 (set-buffer current-buffer)
5073 (run-hooks 'gnus-group-no-more-groups-hook))
5074 ;; We try to enter the target group.
5075 (gnus-group-jump-to-group target-group)
5076 (let ((unreads (gnus-group-group-unread)))
5077 (if (and (or (eq t unreads)
5078 (and unreads (not (zerop unreads))))
5079 (gnus-summary-read-group
5080 target-group nil no-article current-buffer))
5082 (setq current-group target-group
5083 target-group nil)))))))
5085 (defun gnus-summary-prev-group (&optional no-article)
5086 "Exit current newsgroup and then select previous unread newsgroup.
5087 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5089 (gnus-summary-next-group no-article nil t))
5091 ;; Walking around summary lines.
5093 (defun gnus-summary-first-subject (&optional unread)
5094 "Go to the first unread subject.
5095 If UNREAD is non-nil, go to the first unread article.
5096 Returns the article selected or nil if there are no unread articles."
5101 ((null gnus-newsgroup-data)
5102 (gnus-message 3 "No articles in the group")
5104 ;; Pick the first article.
5106 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5107 (gnus-data-number (car gnus-newsgroup-data)))
5108 ;; No unread articles.
5109 ((null gnus-newsgroup-unreads)
5110 (gnus-message 3 "No more unread articles")
5112 ;; Find the first unread article.
5114 (let ((data gnus-newsgroup-data))
5116 (not (gnus-data-unread-p (car data))))
5117 (setq data (cdr data)))
5119 (goto-char (gnus-data-pos (car data)))
5120 (gnus-data-number (car data))))))
5121 (gnus-summary-position-point)))
5123 (defun gnus-summary-next-subject (n &optional unread dont-display)
5124 "Go to next N'th summary line.
5125 If N is negative, go to the previous N'th subject line.
5126 If UNREAD is non-nil, only unread articles are selected.
5127 The difference between N and the actual number of steps taken is
5130 (let ((backward (< n 0))
5134 (gnus-summary-find-prev unread)
5135 (gnus-summary-find-next unread)))
5138 (gnus-message 7 "No more%s articles"
5139 (if unread " unread" "")))
5140 (unless dont-display
5141 (gnus-summary-recenter)
5142 (gnus-summary-position-point))
5145 (defun gnus-summary-next-unread-subject (n)
5146 "Go to next N'th unread summary line."
5148 (gnus-summary-next-subject n t))
5150 (defun gnus-summary-prev-subject (n &optional unread)
5151 "Go to previous N'th summary line.
5152 If optional argument UNREAD is non-nil, only unread article is selected."
5154 (gnus-summary-next-subject (- n) unread))
5156 (defun gnus-summary-prev-unread-subject (n)
5157 "Go to previous N'th unread summary line."
5159 (gnus-summary-next-subject (- n) t))
5161 (defun gnus-summary-goto-subject (article &optional force silent)
5162 "Go the subject line of ARTICLE.
5163 If FORCE, also allow jumping to articles not currently shown."
5164 (interactive "nArticle number: ")
5166 (data (gnus-data-find article)))
5167 ;; We read in the article if we have to.
5170 (gnus-summary-insert-subject article (and (vectorp force) force) t)
5171 (setq data (gnus-data-find article)))
5176 (gnus-message 3 "Can't find article %d" article))
5178 (goto-char (gnus-data-pos data))
5181 ;; Walking around summary lines with displaying articles.
5183 (defun gnus-summary-expand-window (&optional arg)
5184 "Make the summary buffer take up the entire Emacs frame.
5185 Given a prefix, will force an `article' buffer configuration."
5187 (gnus-set-global-variables)
5189 (gnus-configure-windows 'article 'force)
5190 (gnus-configure-windows 'summary 'force)))
5192 (defun gnus-summary-display-article (article &optional all-header)
5193 "Display ARTICLE in article buffer."
5194 (gnus-set-global-variables)
5198 (if gnus-summary-display-article-function
5199 (funcall gnus-summary-display-article-function article all-header)
5200 (gnus-article-prepare article all-header))
5201 (run-hooks 'gnus-select-article-hook)
5202 (when (and gnus-current-article
5203 (not (zerop gnus-current-article)))
5204 (gnus-summary-goto-subject gnus-current-article))
5205 (gnus-summary-recenter)
5206 (when (and gnus-use-trees gnus-show-threads)
5207 (gnus-possibly-generate-tree article)
5208 (gnus-highlight-selected-tree article))
5209 ;; Successfully display article.
5210 (gnus-article-set-window-start
5211 (cdr (assq article gnus-newsgroup-bookmarks))))))
5213 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5214 "Select the current article.
5215 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5216 non-nil, the article will be re-fetched even if it already present in
5217 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5219 ;; Make sure we are in the summary buffer to work around bbdb bug.
5220 (unless (eq major-mode 'gnus-summary-mode)
5221 (set-buffer gnus-summary-buffer))
5222 (let ((article (or article (gnus-summary-article-number)))
5223 (all-headers (not (not all-headers))) ;Must be T or NIL.
5224 gnus-summary-display-article-function
5227 (gnus-summary-article-pseudo-p article)
5228 (error "This is a pseudo-article."))
5231 (set-buffer gnus-summary-buffer)
5232 (if (or (and gnus-single-article-buffer
5233 (or (null gnus-current-article)
5234 (null gnus-article-current)
5235 (null (get-buffer gnus-article-buffer))
5236 (not (eq article (cdr gnus-article-current)))
5237 (not (equal (car gnus-article-current)
5238 gnus-newsgroup-name))))
5239 (and (not gnus-single-article-buffer)
5240 (or (null gnus-current-article)
5241 (not (eq gnus-current-article article))))
5243 ;; The requested article is different from the current article.
5245 (gnus-summary-display-article article all-headers)
5247 (when (or all-headers gnus-show-all-headers)
5248 (gnus-article-show-all-headers))
5251 (gnus-article-set-window-start
5252 (cdr (assq article gnus-newsgroup-bookmarks)))))))
5254 (defun gnus-summary-set-current-mark (&optional current-mark)
5255 "Obsolete function."
5258 (defun gnus-summary-next-article (&optional unread subject backward push)
5259 "Select the next article.
5260 If UNREAD, only unread articles are selected.
5261 If SUBJECT, only articles with SUBJECT are selected.
5262 If BACKWARD, the previous article is selected instead of the next."
5264 (gnus-set-global-variables)
5266 ;; Is there such an article?
5267 ((and (gnus-summary-search-forward unread subject backward)
5268 (or (gnus-summary-display-article (gnus-summary-article-number))
5269 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5270 (gnus-summary-position-point))
5271 ;; If not, we try the first unread, if that is wanted.
5273 gnus-auto-select-same
5274 ;; Make sure that we don't select the current article.
5275 (not (eq (gnus-summary-article-number)
5277 (gnus-summary-first-subject t)
5278 (gnus-summary-article-number))))
5279 (gnus-summary-first-unread-article))
5280 (gnus-summary-position-point)
5281 (gnus-message 6 "Wrapped"))
5282 ;; Try to get next/previous article not displayed in this group.
5283 ((and gnus-auto-extend-newsgroup
5284 (not unread) (not subject))
5285 (gnus-summary-goto-article
5286 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5288 ;; Go to next/previous group.
5290 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5291 (gnus-summary-jump-to-group gnus-newsgroup-name))
5292 (let ((cmd last-command-char)
5294 (if (eq gnus-keep-same-level 'best)
5295 (gnus-summary-best-group gnus-newsgroup-name)
5296 (gnus-summary-search-group backward gnus-keep-same-level))))
5297 ;; For some reason, the group window gets selected. We change
5299 (select-window (get-buffer-window (current-buffer)))
5300 ;; Select next unread newsgroup automagically.
5302 ((or (not gnus-auto-select-next)
5304 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5305 ((or (eq gnus-auto-select-next 'quietly)
5306 (and (eq gnus-auto-select-next 'slightly-quietly)
5308 (and (eq gnus-auto-select-next 'almost-quietly)
5309 (gnus-summary-last-article-p)))
5311 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5313 (gnus-message 7 "No more%s articles (%s)..."
5314 (if unread " unread" "")
5315 (if group (concat "selecting " group)
5317 (gnus-summary-next-group nil group backward)))
5319 (gnus-summary-walk-group-buffer
5320 gnus-newsgroup-name cmd unread backward)))))))
5322 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
5323 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5324 (?\C-p (gnus-group-prev-unread-group 1))))
5325 (cursor-in-echo-area t)
5326 keve key group ended)
5328 (set-buffer gnus-group-buffer)
5329 (gnus-summary-jump-to-group from-group)
5331 (if (eq gnus-keep-same-level 'best)
5332 (gnus-summary-best-group gnus-newsgroup-name)
5333 (gnus-summary-search-group backward gnus-keep-same-level))))
5336 5 "No more%s articles%s" (if unread " unread" "")
5338 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5339 (format " (Type %s for %s [%s])"
5340 (single-key-description cmd) group
5341 (car (gnus-gethash group gnus-newsrc-hashtb)))
5342 (format " (Type %s to exit %s)"
5343 (single-key-description cmd)
5344 gnus-newsgroup-name)))
5345 ;; Confirm auto selection.
5346 (setq key (car (setq keve (gnus-read-event-char))))
5349 ((assq key keystrokes)
5350 (let ((obuf (current-buffer)))
5351 (switch-to-buffer gnus-group-buffer)
5353 (gnus-group-jump-to-group group))
5354 (eval (cadr (assq key keystrokes)))
5355 (setq group (gnus-group-group-name))
5356 (switch-to-buffer obuf))
5360 (gnus-ephemeral-group-p gnus-newsgroup-name))
5362 (gnus-summary-next-group nil group backward)))
5364 (push (cdr keve) unread-command-events))))))
5366 (defun gnus-summary-next-unread-article ()
5367 "Select unread article after current one."
5369 (gnus-summary-next-article t (and gnus-auto-select-same
5370 (gnus-summary-article-subject))))
5372 (defun gnus-summary-prev-article (&optional unread subject)
5373 "Select the article after the current one.
5374 If UNREAD is non-nil, only unread articles are selected."
5376 (gnus-summary-next-article unread subject t))
5378 (defun gnus-summary-prev-unread-article ()
5379 "Select unread article before current one."
5381 (gnus-summary-prev-article t (and gnus-auto-select-same
5382 (gnus-summary-article-subject))))
5384 (defun gnus-summary-next-page (&optional lines circular)
5385 "Show next page of the selected article.
5386 If at the end of the current article, select the next article.
5387 LINES says how many lines should be scrolled up.
5389 If CIRCULAR is non-nil, go to the start of the article instead of
5390 selecting the next article when reaching the end of the current
5393 (setq gnus-summary-buffer (current-buffer))
5394 (gnus-set-global-variables)
5395 (let ((article (gnus-summary-article-number))
5397 (gnus-configure-windows 'article)
5398 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
5399 (if (and (eq gnus-summary-goto-unread 'never)
5400 (not (gnus-summary-last-article-p article)))
5401 (gnus-summary-next-article)
5402 (gnus-summary-next-unread-article))
5403 (if (or (null gnus-current-article)
5404 (null gnus-article-current)
5405 (/= article (cdr gnus-article-current))
5406 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5407 ;; Selected subject is different from current article's.
5408 (gnus-summary-display-article article)
5409 (gnus-eval-in-buffer-window gnus-article-buffer
5410 (setq endp (gnus-article-next-page lines)))
5413 (gnus-summary-beginning-of-article))
5415 (gnus-message 3 "End of message"))
5417 (if (and (eq gnus-summary-goto-unread 'never)
5418 (not (gnus-summary-last-article-p article)))
5419 (gnus-summary-next-article)
5420 (gnus-summary-next-unread-article)))))))
5421 (gnus-summary-recenter)
5422 (gnus-summary-position-point)))
5424 (defun gnus-summary-prev-page (&optional lines)
5425 "Show previous page of selected article.
5426 Argument LINES specifies lines to be scrolled down."
5428 (gnus-set-global-variables)
5429 (let ((article (gnus-summary-article-number)))
5430 (gnus-configure-windows 'article)
5431 (if (or (null gnus-current-article)
5432 (null gnus-article-current)
5433 (/= article (cdr gnus-article-current))
5434 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5435 ;; Selected subject is different from current article's.
5436 (gnus-summary-display-article article)
5437 (gnus-summary-recenter)
5438 (gnus-eval-in-buffer-window gnus-article-buffer
5439 (gnus-article-prev-page lines))))
5440 (gnus-summary-position-point))
5442 (defun gnus-summary-scroll-up (lines)
5443 "Scroll up (or down) one line current article.
5444 Argument LINES specifies lines to be scrolled up (or down if negative)."
5446 (gnus-set-global-variables)
5447 (gnus-configure-windows 'article)
5448 (gnus-summary-show-thread)
5449 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
5450 (gnus-eval-in-buffer-window gnus-article-buffer
5452 (when (gnus-article-next-page lines)
5453 (gnus-message 3 "End of message")))
5455 (gnus-article-prev-page (- lines))))))
5456 (gnus-summary-recenter)
5457 (gnus-summary-position-point))
5459 (defun gnus-summary-next-same-subject ()
5460 "Select next article which has the same subject as current one."
5462 (gnus-set-global-variables)
5463 (gnus-summary-next-article nil (gnus-summary-article-subject)))
5465 (defun gnus-summary-prev-same-subject ()
5466 "Select previous article which has the same subject as current one."
5468 (gnus-set-global-variables)
5469 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
5471 (defun gnus-summary-next-unread-same-subject ()
5472 "Select next unread article which has the same subject as current one."
5474 (gnus-set-global-variables)
5475 (gnus-summary-next-article t (gnus-summary-article-subject)))
5477 (defun gnus-summary-prev-unread-same-subject ()
5478 "Select previous unread article which has the same subject as current one."
5480 (gnus-set-global-variables)
5481 (gnus-summary-prev-article t (gnus-summary-article-subject)))
5483 (defun gnus-summary-first-unread-article ()
5484 "Select the first unread article.
5485 Return nil if there are no unread articles."
5487 (gnus-set-global-variables)
5489 (when (gnus-summary-first-subject t)
5490 (gnus-summary-show-thread)
5491 (gnus-summary-first-subject t)
5492 (gnus-summary-display-article (gnus-summary-article-number)))
5493 (gnus-summary-position-point)))
5495 (defun gnus-summary-best-unread-article ()
5496 "Select the unread article with the highest score."
5498 (gnus-set-global-variables)
5499 (let ((best -1000000)
5500 (data gnus-newsgroup-data)
5503 (and (gnus-data-unread-p (car data))
5505 (gnus-summary-article-score (gnus-data-number (car data))))
5508 article (gnus-data-number (car data))))
5509 (setq data (cdr data)))
5512 (gnus-summary-goto-article article)
5513 (error "No unread articles"))
5514 (gnus-summary-position-point))))
5516 (defun gnus-summary-last-subject ()
5517 "Go to the last displayed subject line in the group."
5518 (let ((article (gnus-data-number (car (gnus-data-list t)))))
5520 (gnus-summary-goto-subject article))))
5522 (defun gnus-summary-goto-article (article &optional all-headers force)
5523 "Fetch ARTICLE and display it if it exists.
5524 If ALL-HEADERS is non-nil, no header lines are hidden."
5530 (mapcar (lambda (number) (list (int-to-string number)))
5531 gnus-newsgroup-limit)))
5535 (if (gnus-summary-goto-subject article force)
5536 (gnus-summary-display-article article all-headers)
5537 (gnus-message 4 "Couldn't go to article %s" article) nil)
5538 (gnus-summary-position-point)))
5540 (defun gnus-summary-goto-last-article ()
5541 "Go to the previously read article."
5544 (when gnus-last-article
5545 (gnus-summary-goto-article gnus-last-article))
5546 (gnus-summary-position-point)))
5548 (defun gnus-summary-pop-article (number)
5549 "Pop one article off the history and go to the previous.
5550 NUMBER articles will be popped off."
5553 (setq gnus-newsgroup-history
5554 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
5556 (gnus-summary-goto-article (car to))
5557 (error "Article history empty")))
5558 (gnus-summary-position-point))
5560 ;; Summary commands and functions for limiting the summary buffer.
5562 (defun gnus-summary-limit-to-articles (n)
5563 "Limit the summary buffer to the next N articles.
5564 If not given a prefix, use the process marked articles instead."
5566 (gnus-set-global-variables)
5568 (let ((articles (gnus-summary-work-articles n)))
5569 (setq gnus-newsgroup-processable nil)
5570 (gnus-summary-limit articles))
5571 (gnus-summary-position-point)))
5573 (defun gnus-summary-pop-limit (&optional total)
5574 "Restore the previous limit.
5575 If given a prefix, remove all limits."
5577 (gnus-set-global-variables)
5579 (setq gnus-newsgroup-limits
5580 (list (mapcar (lambda (h) (mail-header-number h))
5581 gnus-newsgroup-headers))))
5582 (unless gnus-newsgroup-limits
5583 (error "No limit to pop"))
5585 (gnus-summary-limit nil 'pop)
5586 (gnus-summary-position-point)))
5588 (defun gnus-summary-limit-to-subject (subject &optional header)
5589 "Limit the summary buffer to articles that have subjects that match a regexp."
5590 (interactive "sRegexp: ")
5592 (setq header "subject"))
5593 (when (not (equal "" subject))
5595 (let ((articles (gnus-summary-find-matching
5596 (or header "subject") subject 'all)))
5598 (error "Found no matches for \"%s\"" subject))
5599 (gnus-summary-limit articles))
5600 (gnus-summary-position-point))))
5602 (defun gnus-summary-limit-to-author (from)
5603 "Limit the summary buffer to articles that have authors that match a regexp."
5604 (interactive "sRegexp: ")
5605 (gnus-summary-limit-to-subject from "from"))
5607 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5609 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5611 (defun gnus-summary-limit-to-unread (&optional all)
5612 "Limit the summary buffer to articles that are not marked as read.
5613 If ALL is non-nil, limit strictly to unread articles."
5616 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
5617 (gnus-summary-limit-to-marks
5618 ;; Concat all the marks that say that an article is read and have
5620 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
5621 gnus-killed-mark gnus-kill-file-mark
5622 gnus-low-score-mark gnus-expirable-mark
5623 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
5624 gnus-duplicate-mark)
5627 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
5628 (make-obsolete 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
5630 (defun gnus-summary-limit-to-marks (marks &optional reverse)
5631 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
5632 If REVERSE, limit the summary buffer to articles that are not marked
5633 with MARKS. MARKS can either be a string of marks or a list of marks.
5634 Returns how many articles were removed."
5635 (interactive "sMarks: ")
5636 (gnus-set-global-variables)
5638 (let ((data gnus-newsgroup-data)
5639 (marks (if (listp marks) marks
5640 (append marks nil))) ; Transform to list.
5643 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
5644 (memq (gnus-data-mark (car data)) marks))
5645 (push (gnus-data-number (car data)) articles))
5646 (setq data (cdr data)))
5647 (gnus-summary-limit articles))
5648 (gnus-summary-position-point)))
5650 (defun gnus-summary-limit-to-score (&optional score)
5651 "Limit to articles with score at or above SCORE."
5653 (gnus-set-global-variables)
5654 (setq score (if score
5655 (prefix-numeric-value score)
5656 (or gnus-summary-default-score 0)))
5657 (let ((data gnus-newsgroup-data)
5660 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
5662 (push (gnus-data-number (car data)) articles))
5663 (setq data (cdr data)))
5665 (gnus-summary-limit articles)
5666 (gnus-summary-position-point))))
5668 (defun gnus-summary-limit-include-dormant ()
5669 "Display all the hidden articles that are marked as dormant."
5671 (gnus-set-global-variables)
5672 (unless gnus-newsgroup-dormant
5673 (error "There are no dormant articles in this group"))
5675 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
5676 (gnus-summary-position-point)))
5678 (defun gnus-summary-limit-exclude-dormant ()
5679 "Hide all dormant articles."
5681 (gnus-set-global-variables)
5683 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
5684 (gnus-summary-position-point)))
5686 (defun gnus-summary-limit-exclude-childless-dormant ()
5687 "Hide all dormant articles that have no children."
5689 (gnus-set-global-variables)
5690 (let ((data (gnus-data-list t))
5691 articles d children)
5692 ;; Find all articles that are either not dormant or have
5694 (while (setq d (pop data))
5695 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
5697 (gnus-article-children (gnus-data-number d)))
5700 (when (memq (car children) articles)
5705 (push (gnus-data-number d) articles)))
5708 (gnus-summary-limit articles)
5709 (gnus-summary-position-point))))
5711 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
5712 "Mark all unread excluded articles as read.
5713 If ALL, mark even excluded ticked and dormants as read."
5715 (let ((articles (gnus-sorted-complement
5717 (mapcar (lambda (h) (mail-header-number h))
5718 gnus-newsgroup-headers)
5720 (sort gnus-newsgroup-limit '<)))
5722 (setq gnus-newsgroup-unreads nil)
5724 (setq gnus-newsgroup-dormant nil
5725 gnus-newsgroup-marked nil
5726 gnus-newsgroup-reads
5728 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
5729 gnus-newsgroup-reads))
5730 (while (setq article (pop articles))
5731 (unless (or (memq article gnus-newsgroup-dormant)
5732 (memq article gnus-newsgroup-marked))
5733 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
5735 (defun gnus-summary-limit (articles &optional pop)
5737 ;; We pop the previous limit off the stack and use that.
5738 (setq articles (car gnus-newsgroup-limits)
5739 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
5740 ;; We use the new limit, so we push the old limit on the stack.
5741 (push gnus-newsgroup-limit gnus-newsgroup-limits))
5743 (setq gnus-newsgroup-limit articles)
5744 (let ((total (length gnus-newsgroup-data))
5745 (data (gnus-data-find-list (gnus-summary-article-number)))
5746 (gnus-summary-mark-below nil) ; Inhibit this.
5748 ;; This will do all the work of generating the new summary buffer
5749 ;; according to the new limit.
5750 (gnus-summary-prepare)
5751 ;; Hide any threads, possibly.
5752 (and gnus-show-threads
5753 gnus-thread-hide-subtree
5754 (gnus-summary-hide-all-threads))
5755 ;; Try to return to the article you were at, or one in the
5758 ;; We try to find some article after the current one.
5760 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
5763 (setq data (cdr data))))
5765 ;; If there is no data, that means that we were after the last
5766 ;; article. The same goes when we can't find any articles
5767 ;; after the current one.
5768 (goto-char (point-max))
5769 (gnus-summary-find-prev))
5770 ;; We return how many articles were removed from the summary
5771 ;; buffer as a result of the new limit.
5772 (- total (length gnus-newsgroup-data))))
5774 (defsubst gnus-invisible-cut-children (threads)
5777 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
5782 (defsubst gnus-cut-thread (thread)
5783 "Go forwards in the thread until we find an article that we want to display."
5784 (when (or (eq gnus-fetch-old-headers 'some)
5785 (eq gnus-build-sparse-threads 'some)
5786 (eq gnus-build-sparse-threads 'more))
5787 ;; Deal with old-fetched headers and sparse threads.
5791 (memq (mail-header-number (car thread)) gnus-newsgroup-sparse)
5792 (memq (mail-header-number (car thread)) gnus-newsgroup-ancient))
5793 (or (<= (length (cdr thread)) 1)
5794 (gnus-invisible-cut-children (cdr thread))))
5795 (setq thread (cadr thread))))
5798 (defun gnus-cut-threads (threads)
5799 "Cut off all uninteresting articles from the beginning of threads."
5800 (when (or (eq gnus-fetch-old-headers 'some)
5801 (eq gnus-build-sparse-threads 'some)
5802 (eq gnus-build-sparse-threads 'more))
5805 (setcar th (gnus-cut-thread (car th)))
5806 (setq th (cdr th)))))
5807 ;; Remove nixed out threads.
5810 (defun gnus-summary-initial-limit (&optional show-if-empty)
5811 "Figure out what the initial limit is supposed to be on group entry.
5812 This entails weeding out unwanted dormants, low-scored articles,
5813 fetch-old-headers verbiage, and so on."
5814 ;; Most groups have nothing to remove.
5815 (if (or gnus-inhibit-limiting
5816 (and (null gnus-newsgroup-dormant)
5817 (not (eq gnus-fetch-old-headers 'some))
5818 (null gnus-summary-expunge-below)
5819 (not (eq gnus-build-sparse-threads 'some))
5820 (not (eq gnus-build-sparse-threads 'more))
5821 (null gnus-thread-expunge-below)
5822 (not gnus-use-nocem)))
5824 (push gnus-newsgroup-limit gnus-newsgroup-limits)
5825 (setq gnus-newsgroup-limit nil)
5828 (unless (car (symbol-value node))
5829 ;; These threads have no parents -- they are roots.
5830 (let ((nodes (cdr (symbol-value node)))
5833 (if (and gnus-thread-expunge-below
5834 (< (gnus-thread-total-score (car nodes))
5835 gnus-thread-expunge-below))
5836 (gnus-expunge-thread (pop nodes))
5837 (setq thread (pop nodes))
5838 (gnus-summary-limit-children thread))))))
5839 gnus-newsgroup-dependencies)
5840 ;; If this limitation resulted in an empty group, we might
5841 ;; pop the previous limit and use it instead.
5842 (when (and (not gnus-newsgroup-limit)
5844 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
5845 gnus-newsgroup-limit))
5847 (defun gnus-summary-limit-children (thread)
5848 "Return 1 if this subthread is visible and 0 if it is not."
5849 ;; First we get the number of visible children to this thread. This
5850 ;; is done by recursing down the thread using this function, so this
5851 ;; will really go down to a leaf article first, before slowly
5852 ;; working its way up towards the root.
5856 (apply '+ (mapcar 'gnus-summary-limit-children
5859 (number (mail-header-number (car thread)))
5862 (not (memq number gnus-newsgroup-marked))
5864 ;; If this article is dormant and has absolutely no visible
5865 ;; children, then this article isn't visible.
5866 (and (memq number gnus-newsgroup-dormant)
5868 ;; If this is "fetch-old-headered" and there is only one
5869 ;; visible child (or less), then we don't want this article.
5870 (and (eq gnus-fetch-old-headers 'some)
5871 (memq number gnus-newsgroup-ancient)
5873 ;; If this is a sparsely inserted article with no children,
5874 ;; we don't want it.
5875 (and (eq gnus-build-sparse-threads 'some)
5876 (memq number gnus-newsgroup-sparse)
5878 ;; If we use expunging, and this article is really
5879 ;; low-scored, then we don't want this article.
5880 (when (and gnus-summary-expunge-below
5882 (or (cdr (assq number gnus-newsgroup-scored))
5883 gnus-summary-default-score))
5884 gnus-summary-expunge-below))
5885 ;; We increase the expunge-tally here, but that has
5886 ;; nothing to do with the limits, really.
5887 (incf gnus-newsgroup-expunged-tally)
5888 ;; We also mark as read here, if that's wanted.
5889 (when (and gnus-summary-mark-below
5890 (< score gnus-summary-mark-below))
5891 (setq gnus-newsgroup-unreads
5892 (delq number gnus-newsgroup-unreads))
5893 (if gnus-newsgroup-auto-expire
5894 (push number gnus-newsgroup-expirable)
5895 (push (cons number gnus-low-score-mark)
5896 gnus-newsgroup-reads)))
5898 ;; Check NoCeM things.
5900 (gnus-nocem-unwanted-article-p
5901 (mail-header-id (car thread))))))
5902 ;; Nope, invisible article.
5904 ;; Ok, this article is to be visible, so we add it to the limit
5906 (push number gnus-newsgroup-limit)
5909 (defun gnus-expunge-thread (thread)
5910 "Mark all articles in THREAD as read."
5911 (let* ((number (mail-header-number (car thread))))
5912 (incf gnus-newsgroup-expunged-tally)
5913 ;; We also mark as read here, if that's wanted.
5914 (setq gnus-newsgroup-unreads
5915 (delq number gnus-newsgroup-unreads))
5916 (if gnus-newsgroup-auto-expire
5917 (push number gnus-newsgroup-expirable)
5918 (push (cons number gnus-low-score-mark)
5919 gnus-newsgroup-reads)))
5920 ;; Go recursively through all subthreads.
5921 (mapcar 'gnus-expunge-thread (cdr thread)))
5923 ;; Summary article oriented commands
5925 (defun gnus-summary-refer-parent-article (n)
5926 "Refer parent article N times.
5927 If N is negative, go to ancestor -N instead.
5928 The difference between N and the number of articles fetched is returned."
5930 (gnus-set-global-variables)
5933 (when (not (natnump n))
5938 (setq header (gnus-summary-article-header))
5940 ;; If we try to find the parent of the currently
5941 ;; displayed article, then we take a look at the actual
5942 ;; References header, since this is slightly more
5943 ;; reliable than the References field we got from the
5945 (if (and (eq (mail-header-number header)
5946 (cdr gnus-article-current))
5947 (equal gnus-newsgroup-name
5948 (car gnus-article-current)))
5950 (set-buffer gnus-original-article-buffer)
5951 (nnheader-narrow-to-headers)
5953 (message-fetch-field "references")
5955 ;; It's not the current article, so we take a bet on
5956 ;; the value we got from the server.
5957 (mail-header-references header)))
5959 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
5960 (gnus-message 1 "Couldn't find parent"))
5961 (gnus-message 1 "No references in article %d"
5962 (gnus-summary-article-number))
5965 (gnus-summary-position-point)
5968 (defun gnus-summary-refer-references ()
5969 "Fetch all articles mentioned in the References header.
5970 Return how many articles were fetched."
5972 (gnus-set-global-variables)
5973 (let ((ref (mail-header-references (gnus-summary-article-header)))
5974 (current (gnus-summary-article-number))
5976 ;; For each Message-ID in the References header...
5977 (while (string-match "<[^>]*>" ref)
5979 ;; ... fetch that article.
5980 (gnus-summary-refer-article
5981 (prog1 (match-string 0 ref)
5982 (setq ref (substring ref (match-end 0))))))
5983 (gnus-summary-goto-subject current)
5984 (gnus-summary-position-point)
5987 (defun gnus-summary-refer-article (message-id)
5988 "Fetch an article specified by MESSAGE-ID."
5989 (interactive "sMessage-ID: ")
5990 (when (and (stringp message-id)
5991 (not (zerop (length message-id))))
5992 ;; Construct the correct Message-ID if necessary.
5993 ;; Suggested by tale@pawl.rpi.edu.
5994 (unless (string-match "^<" message-id)
5995 (setq message-id (concat "<" message-id)))
5996 (unless (string-match ">$" message-id)
5997 (setq message-id (concat message-id ">")))
5998 (let* ((header (gnus-id-to-header message-id))
6000 (memq (mail-header-number header)
6001 gnus-newsgroup-sparse))))
6004 ;; The article is present in the buffer, to we just go to it.
6005 (gnus-summary-goto-article
6006 (mail-header-number header) nil header)
6008 (gnus-summary-update-article (mail-header-number header))))
6009 ;; We fetch the article
6010 (let ((gnus-override-method
6011 (and (gnus-news-group-p gnus-newsgroup-name)
6012 gnus-refer-article-method))
6014 ;; Start the special refer-article method, if necessary.
6015 (when (and gnus-refer-article-method
6016 (gnus-news-group-p gnus-newsgroup-name))
6017 (gnus-check-server gnus-refer-article-method))
6018 ;; Fetch the header, and display the article.
6019 (if (setq number (gnus-summary-insert-subject message-id))
6020 (gnus-summary-select-article nil nil nil number)
6021 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
6023 (defun gnus-summary-enter-digest-group (&optional force)
6024 "Enter an nndoc group based on the current article.
6025 If FORCE, force a digest interpretation. If not, try
6026 to guess what the document format is."
6028 (gnus-set-global-variables)
6029 (let ((conf gnus-current-window-configuration))
6031 (gnus-summary-select-article))
6032 (setq gnus-current-window-configuration conf)
6033 (let* ((name (format "%s-%d"
6034 (gnus-group-prefixed-name
6035 gnus-newsgroup-name (list 'nndoc ""))
6037 (set-buffer gnus-summary-buffer)
6038 gnus-current-article)))
6039 (ogroup gnus-newsgroup-name)
6040 (params (append (gnus-info-params (gnus-get-info ogroup))
6041 (list (cons 'to-group ogroup))))
6042 (case-fold-search t)
6043 (buf (current-buffer))
6046 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6047 (insert-buffer-substring gnus-original-article-buffer)
6048 ;; Remove lines that may lead nndoc to misinterpret the
6051 (goto-char (point-min))
6052 (or (search-forward "\n\n" nil t) (point)))
6053 (goto-char (point-min))
6054 (delete-matching-lines "^\\(Path\\):\\|^From ")
6057 (if (gnus-group-read-ephemeral-group
6058 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6060 ,(if force 'digest 'guess))) t)
6061 ;; Make all postings to this group go to the parent group.
6062 (nconc (gnus-info-params (gnus-get-info name))
6064 ;; Couldn't select this doc group.
6065 (switch-to-buffer buf)
6066 (gnus-set-global-variables)
6067 (gnus-configure-windows 'summary)
6068 (gnus-message 3 "Article couldn't be entered?"))
6069 (kill-buffer dig)))))
6071 (defun gnus-summary-read-document (n)
6072 "Open a new group based on the current article(s).
6073 Obeys the standard process/prefix convention."
6075 (let* ((articles (gnus-summary-work-articles n))
6076 (ogroup gnus-newsgroup-name)
6077 (params (append (gnus-info-params (gnus-get-info ogroup))
6078 (list (cons 'to-group ogroup))))
6079 article group egroup groups vgroup)
6080 (while (setq article (pop articles))
6081 (setq group (format "%s-%d" gnus-newsgroup-name article))
6082 (gnus-summary-remove-process-mark article)
6083 (when (gnus-summary-display-article article)
6085 (nnheader-temp-write nil
6086 (insert-buffer-substring gnus-original-article-buffer)
6087 ;; Remove some headers that may lead nndoc to make
6089 (message-narrow-to-head)
6090 (goto-char (point-min))
6091 (delete-matching-lines "^\\(Path\\):\\|^From ")
6094 (gnus-group-read-ephemeral-group
6095 group `(nndoc ,group (nndoc-address ,(current-buffer))
6096 (nndoc-article-type guess))
6099 ;; Make all postings to this group go to the parent group.
6100 (nconc (gnus-info-params (gnus-get-info egroup))
6102 (push egroup groups))
6103 ;; Couldn't select this doc group.
6104 (gnus-error 3 "Article couldn't be entered"))))))
6105 ;; Now we have selected all the documents.
6108 (error "None of the articles could be interpreted as documents"))
6109 ((gnus-group-read-ephemeral-group
6110 (setq vgroup (format
6111 "nnvirtual:%s-%s" gnus-newsgroup-name
6112 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6113 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6115 (cons (current-buffer) 'summary)))
6117 (error "Couldn't select virtual nndoc group")))))
6119 (defun gnus-summary-isearch-article (&optional regexp-p)
6120 "Do incremental search forward on the current article.
6121 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6123 (gnus-set-global-variables)
6124 (gnus-summary-select-article)
6125 (gnus-configure-windows 'article)
6126 (gnus-eval-in-buffer-window gnus-article-buffer
6127 ;;(goto-char (point-min))
6128 (isearch-forward regexp-p)))
6130 (defun gnus-summary-search-article-forward (regexp &optional backward)
6131 "Search for an article containing REGEXP forward.
6132 If BACKWARD, search backward instead."
6135 (format "Search article %s (regexp%s): "
6136 (if current-prefix-arg "backward" "forward")
6137 (if gnus-last-search-regexp
6138 (concat ", default " gnus-last-search-regexp)
6140 current-prefix-arg))
6141 (gnus-set-global-variables)
6142 (if (string-equal regexp "")
6143 (setq regexp (or gnus-last-search-regexp ""))
6144 (setq gnus-last-search-regexp regexp))
6145 (if (gnus-summary-search-article regexp backward)
6146 (gnus-summary-show-thread)
6147 (error "Search failed: \"%s\"" regexp)))
6149 (defun gnus-summary-search-article-backward (regexp)
6150 "Search for an article containing REGEXP backward."
6153 (format "Search article backward (regexp%s): "
6154 (if gnus-last-search-regexp
6155 (concat ", default " gnus-last-search-regexp)
6157 (gnus-summary-search-article-forward regexp 'backward))
6159 (defun gnus-summary-search-article (regexp &optional backward)
6160 "Search for an article containing REGEXP.
6161 Optional argument BACKWARD means do search for backward.
6162 `gnus-select-article-hook' is not called during the search."
6163 (let ((gnus-select-article-hook nil) ;Disable hook.
6164 (gnus-article-display-hook nil)
6165 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6166 (gnus-use-article-prefetch nil)
6167 (sum (current-buffer))
6170 (gnus-save-hidden-threads
6171 (gnus-summary-select-article)
6172 (set-buffer gnus-article-buffer)
6176 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
6178 (re-search-backward regexp nil t)
6179 (re-search-forward regexp nil t))
6180 ;; We found the regexp.
6185 (get-buffer-window (current-buffer))
6189 (setq point (point)))
6190 ;; We didn't find it, so we go to the next article.
6192 (if (not (if backward (gnus-summary-find-prev)
6193 (gnus-summary-find-next)))
6194 ;; No more articles.
6196 ;; Select the next article and adjust point.
6197 (gnus-summary-select-article)
6198 (set-buffer gnus-article-buffer)
6200 (goto-char (if backward (point-max) (point-min))))))
6201 (gnus-message 7 ""))
6202 ;; Return whether we found the regexp.
6203 (when (eq found 'found)
6205 (gnus-summary-show-thread)
6206 (gnus-summary-goto-subject gnus-current-article)
6207 (gnus-summary-position-point)
6210 (defun gnus-summary-find-matching (header regexp &optional backward unread
6212 "Return a list of all articles that match REGEXP on HEADER.
6213 The search stars on the current article and goes forwards unless
6214 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
6215 If UNREAD is non-nil, only unread articles will
6216 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
6217 in the comparisons."
6218 (let ((data (if (eq backward 'all) gnus-newsgroup-data
6219 (gnus-data-find-list
6220 (gnus-summary-article-number) (gnus-data-list backward))))
6221 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
6222 (case-fold-search (not not-case-fold))
6224 (unless (fboundp (intern (concat "mail-header-" header)))
6225 (error "%s is not a valid header" header))
6228 (and (or (not unread) ; We want all articles...
6229 (gnus-data-unread-p d)) ; Or just unreads.
6230 (vectorp (gnus-data-header d)) ; It's not a pseudo.
6231 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
6232 (push (gnus-data-number d) articles)) ; Success!
6233 (setq data (cdr data)))
6234 (nreverse articles)))
6236 (defun gnus-summary-execute-command (header regexp command &optional backward)
6237 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
6238 If HEADER is an empty string (or nil), the match is done on the entire
6239 article. If BACKWARD (the prefix) is non-nil, search backward instead."
6241 (list (let ((completion-ignore-case t))
6244 (mapcar (lambda (string) (list string))
6245 '("Number" "Subject" "From" "Lines" "Date"
6246 "Message-ID" "Xref" "References" "Body"))
6247 nil 'require-match))
6248 (read-string "Regexp: ")
6249 (read-key-sequence "Command: ")
6250 current-prefix-arg))
6251 (when (equal header "Body")
6253 (gnus-set-global-variables)
6254 ;; Hidden thread subtrees must be searched as well.
6255 (gnus-summary-show-all-threads)
6256 ;; We don't want to change current point nor window configuration.
6258 (save-window-excursion
6259 (gnus-message 6 "Executing %s..." (key-description command))
6260 ;; We'd like to execute COMMAND interactively so as to give arguments.
6261 (gnus-execute header regexp
6262 `(call-interactively ',(key-binding command))
6264 (gnus-message 6 "Executing %s...done" (key-description command)))))
6266 (defun gnus-summary-beginning-of-article ()
6267 "Scroll the article back to the beginning."
6269 (gnus-set-global-variables)
6270 (gnus-summary-select-article)
6271 (gnus-configure-windows 'article)
6272 (gnus-eval-in-buffer-window gnus-article-buffer
6274 (goto-char (point-min))
6275 (when gnus-break-pages
6276 (gnus-narrow-to-page))))
6278 (defun gnus-summary-end-of-article ()
6279 "Scroll to the end of the article."
6281 (gnus-set-global-variables)
6282 (gnus-summary-select-article)
6283 (gnus-configure-windows 'article)
6284 (gnus-eval-in-buffer-window gnus-article-buffer
6286 (goto-char (point-max))
6288 (when gnus-break-pages
6289 (gnus-narrow-to-page))))
6291 (defun gnus-summary-show-article (&optional arg)
6292 "Force re-fetching of the current article.
6293 If ARG (the prefix) is non-nil, show the raw article without any
6294 article massaging functions being run."
6296 (gnus-set-global-variables)
6298 ;; Select the article the normal way.
6299 (gnus-summary-select-article nil 'force)
6300 ;; Bind the article treatment functions to nil.
6301 (let ((gnus-have-all-headers t)
6302 gnus-article-display-hook
6303 gnus-article-prepare-hook
6306 (gnus-summary-select-article nil 'force)))
6307 (gnus-summary-goto-subject gnus-current-article)
6308 ; (gnus-configure-windows 'article)
6309 (gnus-summary-position-point))
6311 (defun gnus-summary-verbose-headers (&optional arg)
6312 "Toggle permanent full header display.
6313 If ARG is a positive number, turn header display on.
6314 If ARG is a negative number, turn header display off."
6316 (gnus-set-global-variables)
6317 (setq gnus-show-all-headers
6318 (cond ((or (not (numberp arg))
6320 (not gnus-show-all-headers))
6323 (gnus-summary-show-article))
6325 (defun gnus-summary-toggle-header (&optional arg)
6326 "Show the headers if they are hidden, or hide them if they are shown.
6327 If ARG is a positive number, show the entire header.
6328 If ARG is a negative number, hide the unwanted header lines."
6330 (gnus-set-global-variables)
6332 (set-buffer gnus-article-buffer)
6333 (let* ((buffer-read-only nil)
6334 (inhibit-point-motion-hooks t)
6335 (hidden (text-property-any
6336 (goto-char (point-min)) (search-forward "\n\n")
6339 (goto-char (point-min))
6340 (when (search-forward "\n\n" nil t)
6341 (delete-region (point-min) (1- (point))))
6342 (goto-char (point-min))
6344 (set-buffer gnus-original-article-buffer)
6345 (goto-char (point-min))
6346 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
6347 (insert-buffer-substring gnus-original-article-buffer 1 e)
6348 (let ((article-inhibit-hiding t))
6349 (run-hooks 'gnus-article-display-hook))
6350 (when (or (not hidden) (and (numberp arg) (< arg 0)))
6351 (gnus-article-hide-headers)))))
6353 (defun gnus-summary-show-all-headers ()
6354 "Make all header lines visible."
6356 (gnus-set-global-variables)
6357 (gnus-article-show-all-headers))
6359 (defun gnus-summary-toggle-mime (&optional arg)
6360 "Toggle MIME processing.
6361 If ARG is a positive number, turn MIME processing on."
6363 (gnus-set-global-variables)
6364 (setq gnus-show-mime
6365 (if (null arg) (not gnus-show-mime)
6366 (> (prefix-numeric-value arg) 0)))
6367 (gnus-summary-select-article t 'force))
6369 (defun gnus-summary-caesar-message (&optional arg)
6370 "Caesar rotate the current article by 13.
6371 The numerical prefix specifies how manu places to rotate each letter
6374 (gnus-set-global-variables)
6375 (gnus-summary-select-article)
6376 (let ((mail-header-separator ""))
6377 (gnus-eval-in-buffer-window gnus-article-buffer
6380 (let ((start (window-start))
6382 (message-caesar-buffer-body arg)
6383 (set-window-start (get-buffer-window (current-buffer)) start))))))
6385 (defun gnus-summary-stop-page-breaking ()
6386 "Stop page breaking in the current article."
6388 (gnus-set-global-variables)
6389 (gnus-summary-select-article)
6390 (gnus-eval-in-buffer-window gnus-article-buffer
6393 (defun gnus-summary-move-article (&optional n to-newsgroup select-method action)
6394 "Move the current article to a different newsgroup.
6395 If N is a positive number, move the N next articles.
6396 If N is a negative number, move the N previous articles.
6397 If N is nil and any articles have been marked with the process mark,
6398 move those articles instead.
6399 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6400 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6401 re-spool using this method.
6403 For this function to work, both the current newsgroup and the
6404 newsgroup that you want to move to have to support the `request-move'
6405 and `request-accept' functions."
6408 (setq action 'move))
6409 (gnus-set-global-variables)
6410 ;; Check whether the source group supports the required functions.
6411 (cond ((and (eq action 'move)
6412 (not (gnus-check-backend-function
6413 'request-move-article gnus-newsgroup-name)))
6414 (error "The current group does not support article moving"))
6415 ((and (eq action 'crosspost)
6416 (not (gnus-check-backend-function
6417 'request-replace-article gnus-newsgroup-name)))
6418 (error "The current group does not support article editing")))
6419 (let ((articles (gnus-summary-work-articles n))
6420 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
6421 (names '((move "Move" "Moving")
6422 (copy "Copy" "Copying")
6423 (crosspost "Crosspost" "Crossposting")))
6424 (copy-buf (save-excursion
6425 (nnheader-set-temp-buffer " *copy article*")))
6426 art-group to-method new-xref article to-groups)
6427 (unless (assq action names)
6428 (error "Unknown action %s" action))
6429 ;; Read the newsgroup name.
6430 (when (and (not to-newsgroup)
6431 (not select-method))
6433 (gnus-read-move-group-name
6434 (cadr (assq action names))
6435 (symbol-value (intern (format "gnus-current-%s-group" action)))
6437 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
6438 (setq to-method (or select-method
6439 (gnus-group-name-to-method to-newsgroup)))
6440 ;; Check the method we are to move this article to...
6441 (unless (gnus-check-backend-function 'request-accept-article (car to-method))
6442 (error "%s does not support article copying" (car to-method)))
6443 (unless (gnus-check-server to-method)
6444 (error "Can't open server %s" (car to-method)))
6445 (gnus-message 6 "%s to %s: %s..."
6446 (caddr (assq action names))
6447 (or (car select-method) to-newsgroup) articles)
6449 (setq article (pop articles))
6453 ;; Move the article.
6455 (gnus-request-move-article
6456 article ; Article to move
6457 gnus-newsgroup-name ; From newsgroup
6458 (nth 1 (gnus-find-method-for-group
6459 gnus-newsgroup-name)) ; Server
6460 (list 'gnus-request-accept-article
6461 to-newsgroup (list 'quote select-method)
6462 (not articles)) ; Accept form
6463 (not articles))) ; Only save nov last time
6464 ;; Copy the article.
6467 (set-buffer copy-buf)
6468 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6469 (gnus-request-accept-article
6470 to-newsgroup select-method (not articles))))
6471 ;; Crosspost the article.
6472 ((eq action 'crosspost)
6473 (let ((xref (mail-header-xref (gnus-summary-article-header article))))
6474 (setq new-xref (concat gnus-newsgroup-name ":" article))
6475 (if (and xref (not (string= xref "")))
6477 (when (string-match "^Xref: " xref)
6478 (setq xref (substring xref (match-end 0))))
6479 (setq new-xref (concat xref " " new-xref)))
6480 (setq new-xref (concat (system-name) " " new-xref)))
6482 (set-buffer copy-buf)
6483 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6484 (nnheader-replace-header "xref" new-xref)
6485 (gnus-request-accept-article
6486 to-newsgroup select-method (not articles)))))))
6488 (gnus-message 1 "Couldn't %s article %s"
6489 (cadr (assq action names)) article)
6492 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
6494 (gnus-group-prefixed-name
6497 (gnus-find-method-for-group to-newsgroup)))
6498 gnus-newsrc-hashtb)))
6499 (info (nth 2 entry))
6500 (to-group (gnus-info-group info)))
6501 ;; Update the group that has been moved to.
6503 (memq action '(move copy)))
6504 (unless (member to-group to-groups)
6505 (push to-group to-groups))
6507 (unless (memq article gnus-newsgroup-unreads)
6509 info (gnus-add-to-range (gnus-info-read info)
6510 (list (cdr art-group)))))
6512 ;; Copy any marks over to the new group.
6513 (let ((marks gnus-article-mark-lists)
6514 (to-article (cdr art-group)))
6516 ;; See whether the article is to be put in the cache.
6517 (when gnus-use-cache
6518 (gnus-cache-possibly-enter-article
6520 (let ((header (copy-sequence
6521 (gnus-summary-article-header article))))
6522 (mail-header-set-number header to-article)
6524 (memq article gnus-newsgroup-marked)
6525 (memq article gnus-newsgroup-dormant)
6526 (memq article gnus-newsgroup-unreads)))
6529 (when (memq article (symbol-value
6530 (intern (format "gnus-newsgroup-%s"
6532 ;; If the other group is the same as this group,
6533 ;; then we have to add the mark to the list.
6534 (when (equal to-group gnus-newsgroup-name)
6535 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
6538 (intern (format "gnus-newsgroup-%s"
6540 ;; Copy mark to other group.
6541 (gnus-add-marked-articles
6542 to-group (cdar marks) (list to-article) info))
6543 (setq marks (cdr marks)))))
6545 ;; Update the Xref header in this article to point to
6546 ;; the new crossposted article we have just created.
6547 (when (eq action 'crosspost)
6549 (set-buffer copy-buf)
6550 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6551 (nnheader-replace-header
6552 "xref" (concat new-xref " " (gnus-group-prefixed-name
6553 (car art-group) to-method)
6554 ":" (cdr art-group)))
6555 (gnus-request-replace-article
6556 article gnus-newsgroup-name (current-buffer)))))
6558 (gnus-summary-goto-subject article)
6559 (when (eq action 'move)
6560 (gnus-summary-mark-article article gnus-canceled-mark)))
6561 (gnus-summary-remove-process-mark article))
6562 ;; Re-activate all groups that have been moved to.
6564 (gnus-activate-group (pop to-groups)))
6566 (gnus-kill-buffer copy-buf)
6567 (gnus-summary-position-point)
6568 (gnus-set-mode-line 'summary)))
6570 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
6571 "Move the current article to a different newsgroup.
6572 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6573 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6574 re-spool using this method."
6576 (gnus-summary-move-article n nil select-method 'copy))
6578 (defun gnus-summary-crosspost-article (&optional n)
6579 "Crosspost the current article to some other group."
6581 (gnus-summary-move-article n nil nil 'crosspost))
6583 (defvar gnus-summary-respool-default-method nil
6584 "Default method for respooling an article.
6585 If nil, use to the current newsgroup method.")
6587 (defun gnus-summary-respool-article (&optional n method)
6588 "Respool the current article.
6589 The article will be squeezed through the mail spooling process again,
6590 which means that it will be put in some mail newsgroup or other
6591 depending on `nnmail-split-methods'.
6592 If N is a positive number, respool the N next articles.
6593 If N is a negative number, respool the N previous articles.
6594 If N is nil and any articles have been marked with the process mark,
6595 respool those articles instead.
6597 Respooling can be done both from mail groups and \"real\" newsgroups.
6598 In the former case, the articles in question will be moved from the
6599 current group into whatever groups they are destined to. In the
6600 latter case, they will be copied into the relevant groups."
6602 (list current-prefix-arg
6603 (let* ((methods (gnus-methods-using 'respool))
6605 (symbol-name (or gnus-summary-respool-default-method
6606 (car (gnus-find-method-for-group
6607 gnus-newsgroup-name)))))
6609 (gnus-completing-read
6610 methname "What backend do you want to use when respooling?"
6611 methods nil t nil 'gnus-method-history))
6614 ((zerop (length (setq ms (gnus-servers-using-backend method))))
6615 (list (intern method) ""))
6619 (cdr (completing-read
6621 (mapcar (lambda (m) (cons (cadr m) m)) ms) nil t)))))))
6622 (gnus-set-global-variables)
6624 (error "No method given for respooling"))
6625 (if (assoc (symbol-name
6626 (car (gnus-find-method-for-group gnus-newsgroup-name)))
6627 (gnus-methods-using 'respool))
6628 (gnus-summary-move-article n nil method)
6629 (gnus-summary-copy-article n nil method)))
6631 (defun gnus-summary-import-article (file)
6632 "Import a random file into a mail newsgroup."
6633 (interactive "fImport file: ")
6634 (gnus-set-global-variables)
6635 (let ((group gnus-newsgroup-name)
6636 (now (current-time))
6638 (unless (gnus-check-backend-function 'request-accept-article group)
6639 (error "%s does not support article importing" group))
6640 (or (file-readable-p file)
6641 (not (file-regular-p file))
6642 (error "Can't read %s" file))
6644 (set-buffer (get-buffer-create " *import file*"))
6645 (buffer-disable-undo (current-buffer))
6647 (insert-file-contents file)
6648 (goto-char (point-min))
6649 (unless (nnheader-article-p)
6650 ;; This doesn't look like an article, so we fudge some headers.
6651 (setq atts (file-attributes file)
6652 lines (count-lines (point-min) (point-max)))
6653 (insert "From: " (read-string "From: ") "\n"
6654 "Subject: " (read-string "Subject: ") "\n"
6655 "Date: " (timezone-make-date-arpa-standard
6656 (current-time-string (nth 5 atts))
6657 (current-time-zone now)
6658 (current-time-zone now))
6660 "Message-ID: " (message-make-message-id) "\n"
6661 "Lines: " (int-to-string lines) "\n"
6662 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
6663 (gnus-request-accept-article group nil t)
6664 (kill-buffer (current-buffer)))))
6666 (defun gnus-summary-article-posted-p ()
6667 "Say whether the current (mail) article is available from `gnus-select-method' as well.
6668 This will be the case if the article has both been mailed and posted."
6670 (let ((id (mail-header-references (gnus-summary-article-header)))
6671 (gnus-override-method
6672 (or gnus-refer-article-method gnus-select-method)))
6673 (if (gnus-request-head id "")
6674 (gnus-message 2 "The current message was found on %s"
6675 gnus-override-method)
6676 (gnus-message 2 "The current message couldn't be found on %s"
6677 gnus-override-method)
6680 (defun gnus-summary-expire-articles (&optional now)
6681 "Expire all articles that are marked as expirable in the current group."
6683 (gnus-set-global-variables)
6684 (when (gnus-check-backend-function
6685 'request-expire-articles gnus-newsgroup-name)
6686 ;; This backend supports expiry.
6687 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
6688 (expirable (if total
6689 (gnus-list-of-read-articles gnus-newsgroup-name)
6690 (setq gnus-newsgroup-expirable
6691 (sort gnus-newsgroup-expirable '<))))
6692 (expiry-wait (if now 'immediate
6693 (gnus-group-find-parameter
6694 gnus-newsgroup-name 'expiry-wait)))
6697 ;; There are expirable articles in this group, so we run them
6698 ;; through the expiry process.
6699 (gnus-message 6 "Expiring articles...")
6700 ;; The list of articles that weren't expired is returned.
6702 (let ((nnmail-expiry-wait-function nil)
6703 (nnmail-expiry-wait expiry-wait))
6704 (setq es (gnus-request-expire-articles
6705 expirable gnus-newsgroup-name)))
6706 (setq es (gnus-request-expire-articles
6707 expirable gnus-newsgroup-name)))
6709 (setq gnus-newsgroup-expirable es))
6710 ;; We go through the old list of expirable, and mark all
6711 ;; really expired articles as nonexistent.
6712 (unless (eq es expirable) ;If nothing was expired, we don't mark.
6713 (let ((gnus-use-cache nil))
6715 (unless (memq (car expirable) es)
6716 (when (gnus-data-find (car expirable))
6717 (gnus-summary-mark-article
6718 (car expirable) gnus-canceled-mark)))
6719 (setq expirable (cdr expirable)))))
6720 (gnus-message 6 "Expiring articles...done")))))
6722 (defun gnus-summary-expire-articles-now ()
6723 "Expunge all expirable articles in the current group.
6724 This means that *all* articles that are marked as expirable will be
6725 deleted forever, right now."
6727 (gnus-set-global-variables)
6728 (or gnus-expert-user
6730 "Are you really, really, really sure you want to delete all these messages? ")
6732 (gnus-summary-expire-articles t))
6734 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6735 (defun gnus-summary-delete-article (&optional n)
6736 "Delete the N next (mail) articles.
6737 This command actually deletes articles. This is not a marking
6738 command. The article will disappear forever from your life, never to
6740 If N is negative, delete backwards.
6741 If N is nil and articles have been marked with the process mark,
6742 delete these instead."
6744 (gnus-set-global-variables)
6745 (unless (gnus-check-backend-function 'request-expire-articles
6746 gnus-newsgroup-name)
6747 (error "The current newsgroup does not support article deletion."))
6748 ;; Compute the list of articles to delete.
6749 (let ((articles (gnus-summary-work-articles n))
6751 (if (and gnus-novice-user
6753 (format "Do you really want to delete %s forever? "
6754 (if (> (length articles) 1)
6755 (format "these %s articles" (length articles))
6758 ;; Delete the articles.
6759 (setq not-deleted (gnus-request-expire-articles
6760 articles gnus-newsgroup-name 'force))
6762 (gnus-summary-remove-process-mark (car articles))
6763 ;; The backend might not have been able to delete the article
6765 (unless (memq (car articles) not-deleted)
6766 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
6767 (setq articles (cdr articles))))
6768 (gnus-summary-position-point)
6769 (gnus-set-mode-line 'summary)
6772 (defun gnus-summary-edit-article (&optional force)
6773 "Edit the current article.
6774 This will have permanent effect only in mail groups.
6775 If FORCE is non-nil, allow editing of articles even in read-only
6779 (set-buffer gnus-summary-buffer)
6780 (gnus-set-global-variables)
6781 (when (and (not force)
6782 (gnus-group-read-only-p))
6783 (error "The current newsgroup does not support article editing."))
6784 ;; Select article if needed.
6785 (unless (eq (gnus-summary-article-number)
6786 gnus-current-article)
6787 (gnus-summary-select-article t))
6788 (gnus-article-edit-article
6790 (gnus-summary-edit-article-done
6791 ,(or (mail-header-references gnus-current-headers) "")
6792 ,(gnus-group-read-only-p) ,gnus-summary-buffer)))))
6794 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
6796 (defun gnus-summary-edit-article-done (&optional references read-only buffer)
6797 "Make edits to the current article permanent."
6799 ;; Replace the article.
6800 (if (and (not read-only)
6801 (not (gnus-request-replace-article
6802 (cdr gnus-article-current) (car gnus-article-current)
6804 (error "Couldn't replace article.")
6805 ;; Update the summary buffer.
6807 (equal (message-tokenize-header references " ")
6808 (message-tokenize-header
6809 (or (message-fetch-field "references") "") " ")))
6810 ;; We only have to update this line.
6813 (message-narrow-to-head)
6814 (let ((header (nnheader-parse-head t)))
6816 (mail-header-set-number header (cdr gnus-article-current))
6817 (gnus-summary-update-article-line
6818 (cdr gnus-article-current) header))))
6820 (set-buffer (or buffer gnus-summary-buffer))
6821 (gnus-summary-update-article (cdr gnus-article-current)))
6822 ;; Prettify the article buffer again.
6824 (set-buffer gnus-article-buffer)
6825 (run-hooks 'gnus-article-display-hook))
6826 ;; Prettify the summary buffer line.
6827 (when (gnus-visual-p 'summary-highlight 'highlight)
6828 (run-hooks 'gnus-visual-mark-article-hook))))
6830 (defun gnus-summary-edit-wash (key)
6831 "Perform editing command in the article buffer."
6835 (message "%s" (concat (this-command-keys) "- "))
6838 (gnus-summary-edit-article)
6839 (execute-kbd-macro (concat (this-command-keys) key))
6840 (gnus-article-edit-done))
6844 (defun gnus-summary-respool-query ()
6845 "Query where the respool algorithm would put this article."
6847 (gnus-set-global-variables)
6848 (gnus-summary-select-article)
6850 (set-buffer gnus-article-buffer)
6852 (goto-char (point-min))
6853 (search-forward "\n\n")
6854 (narrow-to-region (point-min) (point))
6855 (message "This message would go to %s"
6856 (mapconcat 'car (nnmail-article-group 'identity) ", ")))))
6858 ;; Summary marking commands.
6860 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
6861 "Mark articles which has the same subject as read, and then select the next.
6862 If UNMARK is positive, remove any kind of mark.
6863 If UNMARK is negative, tick articles."
6865 (gnus-set-global-variables)
6867 (setq unmark (prefix-numeric-value unmark)))
6869 (gnus-summary-mark-same-subject
6870 (gnus-summary-article-subject) unmark)))
6871 ;; Select next unread article. If auto-select-same mode, should
6872 ;; select the first unread article.
6873 (gnus-summary-next-article t (and gnus-auto-select-same
6874 (gnus-summary-article-subject)))
6875 (gnus-message 7 "%d article%s marked as %s"
6876 count (if (= count 1) " is" "s are")
6877 (if unmark "unread" "read"))))
6879 (defun gnus-summary-kill-same-subject (&optional unmark)
6880 "Mark articles which has the same subject as read.
6881 If UNMARK is positive, remove any kind of mark.
6882 If UNMARK is negative, tick articles."
6884 (gnus-set-global-variables)
6886 (setq unmark (prefix-numeric-value unmark)))
6888 (gnus-summary-mark-same-subject
6889 (gnus-summary-article-subject) unmark)))
6890 ;; If marked as read, go to next unread subject.
6892 ;; Go to next unread subject.
6893 (gnus-summary-next-subject 1 t))
6894 (gnus-message 7 "%d articles are marked as %s"
6895 count (if unmark "unread" "read"))))
6897 (defun gnus-summary-mark-same-subject (subject &optional unmark)
6898 "Mark articles with same SUBJECT as read, and return marked number.
6899 If optional argument UNMARK is positive, remove any kinds of marks.
6900 If optional argument UNMARK is negative, mark articles as unread instead."
6904 ((null unmark) ; Mark as read.
6907 (gnus-summary-mark-article-as-read gnus-killed-mark)
6908 (gnus-summary-show-thread) t)
6909 (gnus-summary-find-subject subject))
6910 (setq count (1+ count))))
6911 ((> unmark 0) ; Tick.
6914 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
6915 (gnus-summary-show-thread) t)
6916 (gnus-summary-find-subject subject))
6917 (setq count (1+ count))))
6918 (t ; Mark as unread.
6921 (gnus-summary-mark-article-as-unread gnus-unread-mark)
6922 (gnus-summary-show-thread) t)
6923 (gnus-summary-find-subject subject))
6924 (setq count (1+ count)))))
6925 (gnus-set-mode-line 'summary)
6926 ;; Return the number of marked articles.
6929 (defun gnus-summary-mark-as-processable (n &optional unmark)
6930 "Set the process mark on the next N articles.
6931 If N is negative, mark backward instead. If UNMARK is non-nil, remove
6932 the process mark instead. The difference between N and the actual
6933 number of articles marked is returned."
6935 (gnus-set-global-variables)
6936 (let ((backward (< n 0))
6941 (gnus-summary-remove-process-mark
6942 (gnus-summary-article-number))
6943 (gnus-summary-set-process-mark (gnus-summary-article-number)))
6944 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
6947 (gnus-message 7 "No more articles"))
6948 (gnus-summary-recenter)
6949 (gnus-summary-position-point)
6952 (defun gnus-summary-unmark-as-processable (n)
6953 "Remove the process mark from the next N articles.
6954 If N is negative, mark backward instead. The difference between N and
6955 the actual number of articles marked is returned."
6957 (gnus-set-global-variables)
6958 (gnus-summary-mark-as-processable n t))
6960 (defun gnus-summary-unmark-all-processable ()
6961 "Remove the process mark from all articles."
6963 (gnus-set-global-variables)
6965 (while gnus-newsgroup-processable
6966 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
6967 (gnus-summary-position-point))
6969 (defun gnus-summary-mark-as-expirable (n)
6970 "Mark N articles forward as expirable.
6971 If N is negative, mark backward instead. The difference between N and
6972 the actual number of articles marked is returned."
6974 (gnus-set-global-variables)
6975 (gnus-summary-mark-forward n gnus-expirable-mark))
6977 (defun gnus-summary-mark-article-as-replied (article)
6978 "Mark ARTICLE replied and update the summary line."
6979 (push article gnus-newsgroup-replied)
6980 (let ((buffer-read-only nil))
6981 (when (gnus-summary-goto-subject article)
6982 (gnus-summary-update-secondary-mark article))))
6984 (defun gnus-summary-set-bookmark (article)
6985 "Set a bookmark in current article."
6986 (interactive (list (gnus-summary-article-number)))
6987 (gnus-set-global-variables)
6988 (when (or (not (get-buffer gnus-article-buffer))
6989 (not gnus-current-article)
6990 (not gnus-article-current)
6991 (not (equal gnus-newsgroup-name (car gnus-article-current))))
6992 (error "No current article selected"))
6993 ;; Remove old bookmark, if one exists.
6994 (let ((old (assq article gnus-newsgroup-bookmarks)))
6996 (setq gnus-newsgroup-bookmarks
6997 (delq old gnus-newsgroup-bookmarks))))
6998 ;; Set the new bookmark, which is on the form
6999 ;; (article-number . line-number-in-body).
7003 (set-buffer gnus-article-buffer)
7007 (goto-char (point-min))
7008 (search-forward "\n\n" nil t)
7011 gnus-newsgroup-bookmarks)
7012 (gnus-message 6 "A bookmark has been added to the current article."))
7014 (defun gnus-summary-remove-bookmark (article)
7015 "Remove the bookmark from the current article."
7016 (interactive (list (gnus-summary-article-number)))
7017 (gnus-set-global-variables)
7018 ;; Remove old bookmark, if one exists.
7019 (let ((old (assq article gnus-newsgroup-bookmarks)))
7022 (setq gnus-newsgroup-bookmarks
7023 (delq old gnus-newsgroup-bookmarks))
7024 (gnus-message 6 "Removed bookmark."))
7025 (gnus-message 6 "No bookmark in current article."))))
7027 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7028 (defun gnus-summary-mark-as-dormant (n)
7029 "Mark N articles forward as dormant.
7030 If N is negative, mark backward instead. The difference between N and
7031 the actual number of articles marked is returned."
7033 (gnus-set-global-variables)
7034 (gnus-summary-mark-forward n gnus-dormant-mark))
7036 (defun gnus-summary-set-process-mark (article)
7037 "Set the process mark on ARTICLE and update the summary line."
7038 (setq gnus-newsgroup-processable
7040 (delq article gnus-newsgroup-processable)))
7041 (when (gnus-summary-goto-subject article)
7042 (gnus-summary-show-thread)
7043 (gnus-summary-update-secondary-mark article)))
7045 (defun gnus-summary-remove-process-mark (article)
7046 "Remove the process mark from ARTICLE and update the summary line."
7047 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7048 (when (gnus-summary-goto-subject article)
7049 (gnus-summary-show-thread)
7050 (gnus-summary-update-secondary-mark article)))
7052 (defun gnus-summary-set-saved-mark (article)
7053 "Set the process mark on ARTICLE and update the summary line."
7054 (push article gnus-newsgroup-saved)
7055 (when (gnus-summary-goto-subject article)
7056 (gnus-summary-update-secondary-mark article)))
7058 (defun gnus-summary-mark-forward (n &optional mark no-expire)
7059 "Mark N articles as read forwards.
7060 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
7061 The difference between N and the actual number of articles marked is
7064 (gnus-set-global-variables)
7065 (let ((backward (< n 0))
7066 (gnus-summary-goto-unread
7067 (and gnus-summary-goto-unread
7068 (not (eq gnus-summary-goto-unread 'never))
7069 (not (memq mark (list gnus-unread-mark
7070 gnus-ticked-mark gnus-dormant-mark)))))
7072 (mark (or mark gnus-del-mark)))
7074 (gnus-summary-mark-article nil mark no-expire)
7075 (zerop (gnus-summary-next-subject
7077 (and gnus-summary-goto-unread
7078 (not (eq gnus-summary-goto-unread 'never)))
7082 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
7083 (gnus-summary-recenter)
7084 (gnus-summary-position-point)
7085 (gnus-set-mode-line 'summary)
7088 (defun gnus-summary-mark-article-as-read (mark)
7089 "Mark the current article quickly as read with MARK."
7090 (let ((article (gnus-summary-article-number)))
7091 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7092 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7093 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7094 (push (cons article mark) gnus-newsgroup-reads)
7095 ;; Possibly remove from cache, if that is used.
7096 (when gnus-use-cache
7097 (gnus-cache-enter-remove-article article))
7098 ;; Allow the backend to change the mark.
7099 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7100 ;; Check for auto-expiry.
7101 (when (and gnus-newsgroup-auto-expire
7102 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7103 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7104 (= mark gnus-ancient-mark)
7105 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7106 (= mark gnus-duplicate-mark)))
7107 (setq mark gnus-expirable-mark)
7108 (push article gnus-newsgroup-expirable))
7109 ;; Set the mark in the buffer.
7110 (gnus-summary-update-mark mark 'unread)
7113 (defun gnus-summary-mark-article-as-unread (mark)
7114 "Mark the current article quickly as unread with MARK."
7115 (let ((article (gnus-summary-article-number)))
7117 (gnus-error 1 "Unmarkable article")
7118 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7119 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7120 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
7121 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
7122 (cond ((= mark gnus-ticked-mark)
7123 (push article gnus-newsgroup-marked))
7124 ((= mark gnus-dormant-mark)
7125 (push article gnus-newsgroup-dormant))
7127 (push article gnus-newsgroup-unreads)))
7128 (setq gnus-newsgroup-reads
7129 (delq (assq article gnus-newsgroup-reads)
7130 gnus-newsgroup-reads))
7132 ;; See whether the article is to be put in the cache.
7134 (vectorp (gnus-summary-article-header article))
7136 (gnus-cache-possibly-enter-article
7137 gnus-newsgroup-name article
7138 (gnus-summary-article-header article)
7139 (= mark gnus-ticked-mark)
7140 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7143 (gnus-summary-update-mark mark 'unread))
7146 (defun gnus-summary-mark-article (&optional article mark no-expire)
7147 "Mark ARTICLE with MARK. MARK can be any character.
7148 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
7149 `??' (dormant) and `?E' (expirable).
7150 If MARK is nil, then the default character `?D' is used.
7151 If ARTICLE is nil, then the article on the current line will be
7153 ;; The mark might be a string.
7154 (when (stringp mark)
7155 (setq mark (aref mark 0)))
7156 ;; If no mark is given, then we check auto-expiring.
7157 (and (not no-expire)
7158 gnus-newsgroup-auto-expire
7161 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7162 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7163 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7164 (= mark gnus-duplicate-mark))))
7165 (setq mark gnus-expirable-mark))
7166 (let* ((mark (or mark gnus-del-mark))
7167 (article (or article (gnus-summary-article-number))))
7169 (error "No article on current line"))
7170 (if (or (= mark gnus-unread-mark)
7171 (= mark gnus-ticked-mark)
7172 (= mark gnus-dormant-mark))
7173 (gnus-mark-article-as-unread article mark)
7174 (gnus-mark-article-as-read article mark))
7176 ;; See whether the article is to be put in the cache.
7178 (not (= mark gnus-canceled-mark))
7179 (vectorp (gnus-summary-article-header article))
7181 (gnus-cache-possibly-enter-article
7182 gnus-newsgroup-name article
7183 (gnus-summary-article-header article)
7184 (= mark gnus-ticked-mark)
7185 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7187 (when (gnus-summary-goto-subject article nil t)
7188 (let ((buffer-read-only nil))
7189 (gnus-summary-show-thread)
7191 (gnus-summary-update-mark mark 'unread)
7194 (defun gnus-summary-update-secondary-mark (article)
7195 "Update the secondary (read, process, cache) mark."
7196 (gnus-summary-update-mark
7197 (cond ((memq article gnus-newsgroup-processable)
7199 ((memq article gnus-newsgroup-cached)
7201 ((memq article gnus-newsgroup-replied)
7203 ((memq article gnus-newsgroup-saved)
7205 (t gnus-unread-mark))
7207 (when (gnus-visual-p 'summary-highlight 'highlight)
7208 (run-hooks 'gnus-summary-update-hook))
7211 (defun gnus-summary-update-mark (mark type)
7212 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
7213 (buffer-read-only nil))
7214 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
7215 (when (looking-at "\r")
7218 (<= (+ forward (point)) (point-max)))
7219 ;; Go to the right position on the line.
7220 (goto-char (+ forward (point)))
7221 ;; Replace the old mark with the new mark.
7222 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
7223 ;; Optionally update the marks by some user rule.
7224 (when (eq type 'unread)
7226 (gnus-data-find (gnus-summary-article-number)) mark)
7227 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
7229 (defun gnus-mark-article-as-read (article &optional mark)
7230 "Enter ARTICLE in the pertinent lists and remove it from others."
7231 ;; Make the article expirable.
7232 (let ((mark (or mark gnus-del-mark)))
7233 (if (= mark gnus-expirable-mark)
7234 (push article gnus-newsgroup-expirable)
7235 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
7236 ;; Remove from unread and marked lists.
7237 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7238 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7239 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7240 (push (cons article mark) gnus-newsgroup-reads)
7241 ;; Possibly remove from cache, if that is used.
7242 (when gnus-use-cache
7243 (gnus-cache-enter-remove-article article))))
7245 (defun gnus-mark-article-as-unread (article &optional mark)
7246 "Enter ARTICLE in the pertinent lists and remove it from others."
7247 (let ((mark (or mark gnus-ticked-mark)))
7248 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
7249 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
7250 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
7251 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7253 ;; Unsuppress duplicates?
7254 (when gnus-suppress-duplicates
7255 (gnus-dup-unsuppress-article article))
7257 (cond ((= mark gnus-ticked-mark)
7258 (push article gnus-newsgroup-marked))
7259 ((= mark gnus-dormant-mark)
7260 (push article gnus-newsgroup-dormant))
7262 (push article gnus-newsgroup-unreads)))
7263 (setq gnus-newsgroup-reads
7264 (delq (assq article gnus-newsgroup-reads)
7265 gnus-newsgroup-reads))))
7267 (defalias 'gnus-summary-mark-as-unread-forward
7268 'gnus-summary-tick-article-forward)
7269 (make-obsolete 'gnus-summary-mark-as-unread-forward
7270 'gnus-summary-tick-article-forward)
7271 (defun gnus-summary-tick-article-forward (n)
7272 "Tick N articles forwards.
7273 If N is negative, tick backwards instead.
7274 The difference between N and the number of articles ticked is returned."
7276 (gnus-summary-mark-forward n gnus-ticked-mark))
7278 (defalias 'gnus-summary-mark-as-unread-backward
7279 'gnus-summary-tick-article-backward)
7280 (make-obsolete 'gnus-summary-mark-as-unread-backward
7281 'gnus-summary-tick-article-backward)
7282 (defun gnus-summary-tick-article-backward (n)
7283 "Tick N articles backwards.
7284 The difference between N and the number of articles ticked is returned."
7286 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
7288 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7289 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7290 (defun gnus-summary-tick-article (&optional article clear-mark)
7291 "Mark current article as unread.
7292 Optional 1st argument ARTICLE specifies article number to be marked as unread.
7293 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
7295 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
7298 (defun gnus-summary-mark-as-read-forward (n)
7299 "Mark N articles as read forwards.
7300 If N is negative, mark backwards instead.
7301 The difference between N and the actual number of articles marked is
7304 (gnus-summary-mark-forward n gnus-del-mark t))
7306 (defun gnus-summary-mark-as-read-backward (n)
7307 "Mark the N articles as read backwards.
7308 The difference between N and the actual number of articles marked is
7311 (gnus-summary-mark-forward (- n) gnus-del-mark t))
7313 (defun gnus-summary-mark-as-read (&optional article mark)
7314 "Mark current article as read.
7315 ARTICLE specifies the article to be marked as read.
7316 MARK specifies a string to be inserted at the beginning of the line."
7317 (gnus-summary-mark-article article mark))
7319 (defun gnus-summary-clear-mark-forward (n)
7320 "Clear marks from N articles forward.
7321 If N is negative, clear backward instead.
7322 The difference between N and the number of marks cleared is returned."
7324 (gnus-summary-mark-forward n gnus-unread-mark))
7326 (defun gnus-summary-clear-mark-backward (n)
7327 "Clear marks from N articles backward.
7328 The difference between N and the number of marks cleared is returned."
7330 (gnus-summary-mark-forward (- n) gnus-unread-mark))
7332 (defun gnus-summary-mark-unread-as-read ()
7333 "Intended to be used by `gnus-summary-mark-article-hook'."
7334 (when (memq gnus-current-article gnus-newsgroup-unreads)
7335 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
7337 (defun gnus-summary-mark-read-and-unread-as-read ()
7338 "Intended to be used by `gnus-summary-mark-article-hook'."
7339 (let ((mark (gnus-summary-article-mark)))
7340 (when (or (gnus-unread-mark-p mark)
7341 (gnus-read-mark-p mark))
7342 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
7344 (defun gnus-summary-mark-region-as-read (point mark all)
7345 "Mark all unread articles between point and mark as read.
7346 If given a prefix, mark all articles between point and mark as read,
7347 even ticked and dormant ones."
7348 (interactive "r\nP")
7357 (memq (setq article (gnus-summary-article-number))
7358 gnus-newsgroup-unreads))
7359 (gnus-summary-mark-article article gnus-del-mark))
7361 (gnus-summary-find-next))))))
7363 (defun gnus-summary-mark-below (score mark)
7364 "Mark articles with score less than SCORE with MARK."
7365 (interactive "P\ncMark: ")
7366 (gnus-set-global-variables)
7367 (setq score (if score
7368 (prefix-numeric-value score)
7369 (or gnus-summary-default-score 0)))
7371 (set-buffer gnus-summary-buffer)
7372 (goto-char (point-min))
7375 (and (< (gnus-summary-article-score) score)
7376 (gnus-summary-mark-article nil mark))
7377 (gnus-summary-find-next)))))
7379 (defun gnus-summary-kill-below (&optional score)
7380 "Mark articles with score below SCORE as read."
7382 (gnus-set-global-variables)
7383 (gnus-summary-mark-below score gnus-killed-mark))
7385 (defun gnus-summary-clear-above (&optional score)
7386 "Clear all marks from articles with score above SCORE."
7388 (gnus-set-global-variables)
7389 (gnus-summary-mark-above score gnus-unread-mark))
7391 (defun gnus-summary-tick-above (&optional score)
7392 "Tick all articles with score above SCORE."
7394 (gnus-set-global-variables)
7395 (gnus-summary-mark-above score gnus-ticked-mark))
7397 (defun gnus-summary-mark-above (score mark)
7398 "Mark articles with score over SCORE with MARK."
7399 (interactive "P\ncMark: ")
7400 (gnus-set-global-variables)
7401 (setq score (if score
7402 (prefix-numeric-value score)
7403 (or gnus-summary-default-score 0)))
7405 (set-buffer gnus-summary-buffer)
7406 (goto-char (point-min))
7408 (when (> (gnus-summary-article-score) score)
7409 (gnus-summary-mark-article nil mark))
7411 (gnus-summary-find-next)))))
7413 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7414 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
7415 (defun gnus-summary-limit-include-expunged (&optional no-error)
7416 "Display all the hidden articles that were expunged for low scores."
7418 (gnus-set-global-variables)
7419 (let ((buffer-read-only nil))
7420 (let ((scored gnus-newsgroup-scored)
7423 (unless (gnus-summary-goto-subject (caar scored))
7424 (and (setq h (gnus-summary-article-header (caar scored)))
7425 (< (cdar scored) gnus-summary-expunge-below)
7427 (setq scored (cdr scored)))
7429 (when (not no-error)
7430 (error "No expunged articles hidden."))
7431 (goto-char (point-min))
7432 (gnus-summary-prepare-unthreaded (nreverse headers))
7433 (goto-char (point-min))
7434 (gnus-summary-position-point)
7437 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
7438 "Mark all articles not marked as unread in this newsgroup as read.
7439 If prefix argument ALL is non-nil, all articles are marked as read.
7440 If QUIETLY is non-nil, no questions will be asked.
7441 If TO-HERE is non-nil, it should be a point in the buffer. All
7442 articles before this point will be marked as read.
7443 The number of articles marked as read is returned."
7445 (gnus-set-global-variables)
7448 (not gnus-interactive-catchup) ;Without confirmation?
7452 "Mark absolutely all articles as read? "
7453 "Mark all unread articles as read? ")))
7455 (not gnus-newsgroup-adaptive)
7456 (not gnus-newsgroup-auto-expire)
7457 (not gnus-suppress-duplicates))
7460 (setq gnus-newsgroup-marked nil
7461 gnus-newsgroup-dormant nil))
7462 (setq gnus-newsgroup-unreads nil))
7463 ;; We actually mark all articles as canceled, which we
7464 ;; have to do when using auto-expiry or adaptive scoring.
7465 (gnus-summary-show-all-threads)
7466 (when (gnus-summary-first-subject (not all))
7468 (if to-here (< (point) to-here) t)
7469 (gnus-summary-mark-article-as-read gnus-catchup-mark)
7470 (gnus-summary-find-next (not all)))))
7472 (setq gnus-newsgroup-unreads nil))
7473 (gnus-set-mode-line 'summary)))
7474 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
7475 (when (and (not to-here) (eq 'nnvirtual (car method)))
7476 (nnvirtual-catchup-group
7477 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
7478 (gnus-summary-position-point)))
7480 (defun gnus-summary-catchup-to-here (&optional all)
7481 "Mark all unticked articles before the current one as read.
7482 If ALL is non-nil, also mark ticked and dormant articles as read."
7484 (gnus-set-global-variables)
7486 (gnus-save-hidden-threads
7487 (let ((beg (point)))
7488 ;; We check that there are unread articles.
7489 (when (or all (gnus-summary-find-prev))
7490 (gnus-summary-catchup all t beg)))))
7491 (gnus-summary-position-point))
7493 (defun gnus-summary-catchup-all (&optional quietly)
7494 "Mark all articles in this newsgroup as read."
7496 (gnus-set-global-variables)
7497 (gnus-summary-catchup t quietly))
7499 (defun gnus-summary-catchup-and-exit (&optional all quietly)
7500 "Mark all articles not marked as unread in this newsgroup as read, then exit.
7501 If prefix argument ALL is non-nil, all articles are marked as read."
7503 (gnus-set-global-variables)
7504 (gnus-summary-catchup all quietly nil 'fast)
7505 ;; Select next newsgroup or exit.
7506 (if (eq gnus-auto-select-next 'quietly)
7507 (gnus-summary-next-group nil)
7508 (gnus-summary-exit)))
7510 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
7511 "Mark all articles in this newsgroup as read, and then exit."
7513 (gnus-set-global-variables)
7514 (gnus-summary-catchup-and-exit t quietly))
7516 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
7517 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
7518 "Mark all articles in this group as read and select the next group.
7519 If given a prefix, mark all articles, unread as well as ticked, as
7522 (gnus-set-global-variables)
7524 (gnus-summary-catchup all))
7525 (gnus-summary-next-article t nil nil t))
7527 ;; Thread-based commands.
7529 (defun gnus-summary-articles-in-thread (&optional article)
7530 "Return a list of all articles in the current thread.
7531 If ARTICLE is non-nil, return all articles in the thread that starts
7533 (let* ((article (or article (gnus-summary-article-number)))
7534 (data (gnus-data-find-list article))
7535 (top-level (gnus-data-level (car data)))
7537 (cond ((null gnus-thread-operation-ignore-subject)
7538 (gnus-simplify-subject-re
7539 (mail-header-subject (gnus-data-header (car data)))))
7540 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
7541 (gnus-simplify-subject-fuzzy
7542 (mail-header-subject (gnus-data-header (car data)))))
7544 (end-point (save-excursion
7545 (if (gnus-summary-go-to-next-thread)
7546 (point) (point-max))))
7549 (< (gnus-data-pos (car data)) end-point))
7550 (when (or (not top-subject)
7551 (string= top-subject
7552 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
7553 (gnus-simplify-subject-fuzzy
7554 (mail-header-subject
7555 (gnus-data-header (car data))))
7556 (gnus-simplify-subject-re
7557 (mail-header-subject
7558 (gnus-data-header (car data)))))))
7559 (push (gnus-data-number (car data)) articles))
7560 (unless (and (setq data (cdr data))
7561 (> (gnus-data-level (car data)) top-level))
7563 ;; Return the list of articles.
7564 (nreverse articles)))
7566 (defun gnus-summary-rethread-current ()
7567 "Rethread the thread the current article is part of."
7569 (gnus-set-global-variables)
7570 (let* ((gnus-show-threads t)
7571 (article (gnus-summary-article-number))
7572 (id (mail-header-id (gnus-summary-article-header)))
7573 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
7575 (error "No article on the current line"))
7576 (gnus-rebuild-thread id)
7577 (gnus-summary-goto-subject article)))
7579 (defun gnus-summary-reparent-thread ()
7580 "Make current article child of the marked (or previous) article.
7582 Note that the re-threading will only work if `gnus-thread-ignore-subject'
7583 is non-nil or the Subject: of both articles are the same."
7585 (unless (not (gnus-group-read-only-p))
7586 (error "The current newsgroup does not support article editing."))
7587 (unless (<= (length gnus-newsgroup-processable) 1)
7588 (error "No more than one article may be marked."))
7589 (save-window-excursion
7590 (let ((gnus-article-buffer " *reparent*")
7591 (current-article (gnus-summary-article-number))
7592 ; first grab the marked article, otherwise one line up.
7593 (parent-article (if (not (null gnus-newsgroup-processable))
7594 (car gnus-newsgroup-processable)
7596 (if (eq (forward-line -1) 0)
7597 (gnus-summary-article-number)
7598 (error "Beginning of summary buffer."))))))
7599 (unless (not (eq current-article parent-article))
7600 (error "An article may not be self-referential."))
7601 (let ((message-id (mail-header-id
7602 (gnus-summary-article-header parent-article))))
7603 (unless (and message-id (not (equal message-id "")))
7604 (error "No message-id in desired parent."))
7605 (gnus-summary-select-article t t nil current-article)
7606 (set-buffer gnus-article-buffer)
7607 (setq buffer-read-only nil)
7608 (let ((buf (format "%s" (buffer-string))))
7611 (goto-char (point-min))
7612 (if (search-forward-regexp "^References: " nil t)
7613 (insert message-id " " )
7614 (insert "References: " message-id "\n"))
7615 (unless (gnus-request-replace-article current-article
7616 (car gnus-article-current)
7617 gnus-article-buffer)
7618 (error "Couldn't replace article."))
7619 (set-buffer gnus-summary-buffer)
7620 (gnus-summary-unmark-all-processable)
7621 (gnus-summary-rethread-current)
7622 (gnus-message 3 "Article %d is now the child of article %d."
7623 current-article parent-article)))))
7625 (defun gnus-summary-toggle-threads (&optional arg)
7626 "Toggle showing conversation threads.
7627 If ARG is positive number, turn showing conversation threads on."
7629 (gnus-set-global-variables)
7630 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
7631 (setq gnus-show-threads
7632 (if (null arg) (not gnus-show-threads)
7633 (> (prefix-numeric-value arg) 0)))
7634 (gnus-summary-prepare)
7635 (gnus-summary-goto-subject current)
7636 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
7637 (gnus-summary-position-point)))
7639 (defun gnus-summary-show-all-threads ()
7642 (gnus-set-global-variables)
7644 (let ((buffer-read-only nil))
7645 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
7646 (gnus-summary-position-point))
7648 (defun gnus-summary-show-thread ()
7649 "Show thread subtrees.
7650 Returns nil if no thread was there to be shown."
7652 (gnus-set-global-variables)
7653 (let ((buffer-read-only nil)
7655 ;; first goto end then to beg, to have point at beg after let
7656 (end (progn (end-of-line) (point)))
7657 (beg (progn (beginning-of-line) (point))))
7659 ;; Any hidden lines here?
7660 (search-forward "\r" end t)
7661 (subst-char-in-region beg end ?\^M ?\n t)
7663 (gnus-summary-position-point))))
7665 (defun gnus-summary-hide-all-threads ()
7666 "Hide all thread subtrees."
7668 (gnus-set-global-variables)
7670 (goto-char (point-min))
7671 (gnus-summary-hide-thread)
7672 (while (zerop (gnus-summary-next-thread 1 t))
7673 (gnus-summary-hide-thread)))
7674 (gnus-summary-position-point))
7676 (defun gnus-summary-hide-thread ()
7677 "Hide thread subtrees.
7678 Returns nil if no threads were there to be hidden."
7680 (gnus-set-global-variables)
7681 (let ((buffer-read-only nil)
7683 (article (gnus-summary-article-number)))
7685 ;; Go forward until either the buffer ends or the subthread
7687 (when (and (not (eobp))
7688 (or (zerop (gnus-summary-next-thread 1 t))
7689 (goto-char (point-max))))
7691 (if (and (> (point) start)
7692 (search-backward "\n" start t))
7694 (subst-char-in-region start (point) ?\n ?\^M)
7695 (gnus-summary-goto-subject article))
7698 ;;(gnus-summary-position-point)
7701 (defun gnus-summary-go-to-next-thread (&optional previous)
7702 "Go to the same level (or less) next thread.
7703 If PREVIOUS is non-nil, go to previous thread instead.
7704 Return the article number moved to, or nil if moving was impossible."
7705 (let ((level (gnus-summary-thread-level))
7706 (way (if previous -1 1))
7709 (while (and (not (eobp))
7710 (< level (gnus-summary-thread-level)))
7718 (gnus-summary-article-number)
7721 (defun gnus-summary-next-thread (n &optional silent)
7722 "Go to the same level next N'th thread.
7723 If N is negative, search backward instead.
7724 Returns the difference between N and the number of skips actually
7727 If SILENT, don't output messages."
7729 (gnus-set-global-variables)
7730 (let ((backward (< n 0))
7733 (gnus-summary-go-to-next-thread backward))
7736 (gnus-summary-position-point))
7737 (when (and (not silent) (/= 0 n))
7738 (gnus-message 7 "No more threads"))
7741 (defun gnus-summary-prev-thread (n)
7742 "Go to the same level previous N'th thread.
7743 Returns the difference between N and the number of skips actually
7746 (gnus-set-global-variables)
7747 (gnus-summary-next-thread (- n)))
7749 (defun gnus-summary-go-down-thread ()
7750 "Go down one level in the current thread."
7751 (let ((children (gnus-summary-article-children)))
7753 (gnus-summary-goto-subject (car children)))))
7755 (defun gnus-summary-go-up-thread ()
7756 "Go up one level in the current thread."
7757 (let ((parent (gnus-summary-article-parent)))
7759 (gnus-summary-goto-subject parent))))
7761 (defun gnus-summary-down-thread (n)
7762 "Go down thread N steps.
7763 If N is negative, go up instead.
7764 Returns the difference between N and how many steps down that were
7767 (gnus-set-global-variables)
7771 (if up (gnus-summary-go-up-thread)
7772 (gnus-summary-go-down-thread)))
7774 (gnus-summary-position-point)
7776 (gnus-message 7 "Can't go further"))
7779 (defun gnus-summary-up-thread (n)
7780 "Go up thread N steps.
7781 If N is negative, go up instead.
7782 Returns the difference between N and how many steps down that were
7785 (gnus-set-global-variables)
7786 (gnus-summary-down-thread (- n)))
7788 (defun gnus-summary-top-thread ()
7789 "Go to the top of the thread."
7791 (gnus-set-global-variables)
7792 (while (gnus-summary-go-up-thread))
7793 (gnus-summary-article-number))
7795 (defun gnus-summary-kill-thread (&optional unmark)
7796 "Mark articles under current thread as read.
7797 If the prefix argument is positive, remove any kinds of marks.
7798 If the prefix argument is negative, tick articles instead."
7800 (gnus-set-global-variables)
7802 (setq unmark (prefix-numeric-value unmark)))
7803 (let ((articles (gnus-summary-articles-in-thread)))
7805 ;; Expand the thread.
7806 (gnus-summary-show-thread)
7807 ;; Mark all the articles.
7809 (gnus-summary-goto-subject (car articles))
7810 (cond ((null unmark)
7811 (gnus-summary-mark-article-as-read gnus-killed-mark))
7813 (gnus-summary-mark-article-as-unread gnus-unread-mark))
7815 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
7816 (setq articles (cdr articles))))
7817 ;; Hide killed subtrees.
7819 gnus-thread-hide-killed
7820 (gnus-summary-hide-thread))
7821 ;; If marked as read, go to next unread subject.
7823 ;; Go to next unread subject.
7824 (gnus-summary-next-subject 1 t)))
7825 (gnus-set-mode-line 'summary))
7827 ;; Summary sorting commands
7829 (defun gnus-summary-sort-by-number (&optional reverse)
7830 "Sort summary buffer by article number.
7831 Argument REVERSE means reverse order."
7833 (gnus-summary-sort 'number reverse))
7835 (defun gnus-summary-sort-by-author (&optional reverse)
7836 "Sort summary buffer by author name alphabetically.
7837 If case-fold-search is non-nil, case of letters is ignored.
7838 Argument REVERSE means reverse order."
7840 (gnus-summary-sort 'author reverse))
7842 (defun gnus-summary-sort-by-subject (&optional reverse)
7843 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
7844 If case-fold-search is non-nil, case of letters is ignored.
7845 Argument REVERSE means reverse order."
7847 (gnus-summary-sort 'subject reverse))
7849 (defun gnus-summary-sort-by-date (&optional reverse)
7850 "Sort summary buffer by date.
7851 Argument REVERSE means reverse order."
7853 (gnus-summary-sort 'date reverse))
7855 (defun gnus-summary-sort-by-score (&optional reverse)
7856 "Sort summary buffer by score.
7857 Argument REVERSE means reverse order."
7859 (gnus-summary-sort 'score reverse))
7861 (defun gnus-summary-sort (predicate reverse)
7862 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
7863 (gnus-set-global-variables)
7864 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
7865 (article (intern (format "gnus-article-sort-by-%s" predicate)))
7866 (gnus-thread-sort-functions
7872 (gnus-article-sort-functions
7877 (,article t2 t1)))))
7879 (gnus-summary-prepare-hook nil))
7880 ;; We do the sorting by regenerating the threads.
7881 (gnus-summary-prepare)
7882 ;; Hide subthreads if needed.
7883 (when (and gnus-show-threads gnus-thread-hide-subtree)
7884 (gnus-summary-hide-all-threads))))
7886 ;; Summary saving commands.
7888 (defun gnus-summary-save-article (&optional n not-saved)
7889 "Save the current article using the default saver function.
7890 If N is a positive number, save the N next articles.
7891 If N is a negative number, save the N previous articles.
7892 If N is nil and any articles have been marked with the process mark,
7893 save those articles instead.
7894 The variable `gnus-default-article-saver' specifies the saver function."
7896 (gnus-set-global-variables)
7897 (let* ((articles (gnus-summary-work-articles n))
7898 (save-buffer (save-excursion
7899 (nnheader-set-temp-buffer " *Gnus Save*")))
7900 (num (length articles))
7901 header article file)
7903 (setq header (gnus-summary-article-header
7904 (setq article (pop articles))))
7905 (if (not (vectorp header))
7906 ;; This is a pseudo-article.
7907 (if (assq 'name header)
7908 (gnus-copy-file (cdr (assq 'name header)))
7909 (gnus-message 1 "Article %d is unsaveable" article))
7910 ;; This is a real article.
7911 (save-window-excursion
7912 (gnus-summary-select-article t nil nil article))
7914 (set-buffer save-buffer)
7916 (insert-buffer-substring gnus-original-article-buffer))
7917 (setq file (gnus-article-save save-buffer file num))
7918 (gnus-summary-remove-process-mark article)
7920 (gnus-summary-set-saved-mark article))))
7921 (gnus-kill-buffer save-buffer)
7922 (gnus-summary-position-point)
7925 (defun gnus-summary-pipe-output (&optional arg)
7926 "Pipe the current article to a subprocess.
7927 If N is a positive number, pipe the N next articles.
7928 If N is a negative number, pipe the N previous articles.
7929 If N is nil and any articles have been marked with the process mark,
7930 pipe those articles instead."
7932 (gnus-set-global-variables)
7933 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
7934 (gnus-summary-save-article arg t))
7935 (gnus-configure-windows 'pipe))
7937 (defun gnus-summary-save-article-mail (&optional arg)
7938 "Append the current article to an mail file.
7939 If N is a positive number, save the N next articles.
7940 If N is a negative number, save the N previous articles.
7941 If N is nil and any articles have been marked with the process mark,
7942 save those articles instead."
7944 (gnus-set-global-variables)
7945 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
7946 (gnus-summary-save-article arg)))
7948 (defun gnus-summary-save-article-rmail (&optional arg)
7949 "Append the current article to an rmail file.
7950 If N is a positive number, save the N next articles.
7951 If N is a negative number, save the N previous articles.
7952 If N is nil and any articles have been marked with the process mark,
7953 save those articles instead."
7955 (gnus-set-global-variables)
7956 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
7957 (gnus-summary-save-article arg)))
7959 (defun gnus-summary-save-article-file (&optional arg)
7960 "Append the current article to a file.
7961 If N is a positive number, save the N next articles.
7962 If N is a negative number, save the N previous articles.
7963 If N is nil and any articles have been marked with the process mark,
7964 save those articles instead."
7966 (gnus-set-global-variables)
7967 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
7968 (gnus-summary-save-article arg)))
7970 (defun gnus-summary-save-article-body-file (&optional arg)
7971 "Append the current article body to a file.
7972 If N is a positive number, save the N next articles.
7973 If N is a negative number, save the N previous articles.
7974 If N is nil and any articles have been marked with the process mark,
7975 save those articles instead."
7977 (gnus-set-global-variables)
7978 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
7979 (gnus-summary-save-article arg)))
7981 (defun gnus-get-split-value (methods)
7982 "Return a value based on the split METHODS."
7983 (let (split-name method result match)
7986 (set-buffer gnus-original-article-buffer)
7988 (nnheader-narrow-to-headers)
7990 (goto-char (point-min))
7991 (setq method (pop methods))
7992 (setq match (car method))
7995 ;; Regular expression.
7997 (re-search-forward match nil t)
7999 ((gnus-functionp match)
8003 (setq result (funcall match gnus-newsgroup-name))))
8008 (setq result (eval match)))))
8009 (setq split-name (append (cdr method) split-name))
8010 (cond ((stringp result)
8011 (push result split-name))
8013 (setq split-name (append result split-name)))))))))
8016 (defun gnus-read-move-group-name (prompt default articles prefix)
8017 "Read a group name."
8018 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
8019 (minibuffer-confirm-incomplete nil) ; XEmacs
8027 (car (gnus-find-method-for-group
8029 gnus-valid-select-methods))
8030 (push (list (symbol-name g)) group-map)))
8031 gnus-active-hashtb))
8035 (if (> (length articles) 1)
8036 (format "these %d articles" (length articles))
8041 (gnus-completing-read default prom
8042 group-map nil nil prefix
8043 'gnus-group-history))
8044 ((= 1 (length split-name))
8045 (gnus-completing-read (car split-name) prom group-map
8047 'gnus-group-history))
8049 (gnus-completing-read nil prom
8050 (mapcar (lambda (el) (list el))
8051 (nreverse split-name))
8053 'gnus-group-history)))))
8055 (when (or (string= to-newsgroup "")
8056 (string= to-newsgroup prefix))
8057 (setq to-newsgroup (or default "")))
8058 (or (gnus-active to-newsgroup)
8059 (gnus-activate-group to-newsgroup)
8060 (when (gnus-y-or-n-p (format "No such group: %s. Create it? "
8062 (or (and (gnus-request-create-group
8063 to-newsgroup (gnus-group-name-to-method to-newsgroup))
8064 (gnus-activate-group to-newsgroup nil nil
8065 (gnus-group-name-to-method
8067 (error "Couldn't create group %s" to-newsgroup)))
8068 (error "No such group: %s" to-newsgroup)))
8071 ;; Summary extract commands
8073 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
8074 (let ((buffer-read-only nil)
8075 (article (gnus-summary-article-number))
8077 (unless (gnus-summary-goto-subject article)
8078 (error "No such article: %d" article))
8079 (gnus-summary-position-point)
8080 ;; If all commands are to be bunched up on one line, we collect
8082 (if gnus-view-pseudos-separately
8084 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
8087 (setq action (cdr (assq 'action (car ps))))
8088 (setq files (list (cdr (assq 'name (car ps)))))
8089 (while (and ps (cdr ps)
8090 (string= (or action "1")
8091 (or (cdr (assq 'action (cadr ps))) "2")))
8092 (push (cdr (assq 'name (cadr ps))) files)
8093 (setcdr ps (cddr ps)))
8096 (when (not (string-match "%s" action))
8099 (and (assq 'execute (car ps))
8100 (setcdr (assq 'execute (car ps))
8101 (funcall (if (string-match "%s" action)
8104 (mapconcat (lambda (f) f) files " ")))))
8105 (setq ps (cdr ps)))))
8106 (if (and gnus-view-pseudos (not not-view))
8108 (when (assq 'execute (car pslist))
8109 (gnus-execute-command (cdr (assq 'execute (car pslist)))
8110 (eq gnus-view-pseudos 'not-confirm)))
8111 (setq pslist (cdr pslist)))
8114 (setq after-article (or (cdr (assq 'article (car pslist)))
8115 (gnus-summary-article-number)))
8116 (gnus-summary-goto-subject after-article)
8119 (insert " " (file-name-nondirectory
8120 (cdr (assq 'name (car pslist))))
8121 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
8123 (forward-line -1) ; back to `b'
8124 (gnus-add-text-properties
8125 b (1- e) (list 'gnus-number gnus-reffed-article-number
8126 gnus-mouse-face-prop gnus-mouse-face))
8128 after-article gnus-reffed-article-number
8129 gnus-unread-mark b (car pslist) 0 (- e b))
8130 (push gnus-reffed-article-number gnus-newsgroup-unreads)
8131 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
8132 (setq pslist (cdr pslist)))))))
8134 (defun gnus-pseudos< (p1 p2)
8135 (let ((c1 (cdr (assq 'action p1)))
8136 (c2 (cdr (assq 'action p2))))
8137 (and c1 c2 (string< c1 c2))))
8139 (defun gnus-request-pseudo-article (props)
8140 (cond ((assq 'execute props)
8141 (gnus-execute-command (cdr (assq 'execute props)))))
8142 (let ((gnus-current-article (gnus-summary-article-number)))
8143 (run-hooks 'gnus-mark-article-hook)))
8145 (defun gnus-execute-command (command &optional automatic)
8147 (gnus-article-setup-buffer)
8148 (set-buffer gnus-article-buffer)
8149 (setq buffer-read-only nil)
8150 (let ((command (if automatic command (read-string "Command: " command)))
8151 ;; Just binding this here doesn't help, because there might
8152 ;; be output from the process after exiting the scope of
8154 ;; (buffer-read-only nil)
8157 (insert "$ " command "\n\n")
8158 (if gnus-view-pseudo-asynchronously
8159 (start-process "gnus-execute" nil shell-file-name
8160 shell-command-switch command)
8161 (call-process shell-file-name nil t nil
8162 shell-command-switch command)))))
8164 ;; Summary kill commands.
8166 (defun gnus-summary-edit-global-kill (article)
8167 "Edit the \"global\" kill file."
8168 (interactive (list (gnus-summary-article-number)))
8169 (gnus-set-global-variables)
8170 (gnus-group-edit-global-kill article))
8172 (defun gnus-summary-edit-local-kill ()
8173 "Edit a local kill file applied to the current newsgroup."
8175 (gnus-set-global-variables)
8176 (setq gnus-current-headers (gnus-summary-article-header))
8177 (gnus-set-global-variables)
8178 (gnus-group-edit-local-kill
8179 (gnus-summary-article-number) gnus-newsgroup-name))
8183 (defun gnus-read-header (id &optional header)
8184 "Read the headers of article ID and enter them into the Gnus system."
8185 (let ((group gnus-newsgroup-name)
8186 (gnus-override-method
8187 (and (gnus-news-group-p gnus-newsgroup-name)
8188 gnus-refer-article-method))
8190 ;; First we check to see whether the header in question is already
8193 ;; This is a Message-ID.
8194 (setq header (or header (gnus-id-to-header id)))
8195 ;; This is an article number.
8196 (setq header (or header (gnus-summary-article-header id))))
8198 (not (memq (mail-header-number header) gnus-newsgroup-sparse)))
8199 ;; We have found the header.
8201 ;; We have to really fetch the header to this article.
8203 (set-buffer nntp-server-buffer)
8204 (when (setq where (gnus-request-head id group))
8205 (goto-char (point-max))
8207 (goto-char (point-min))
8211 ((cdr where) (cdr where))
8212 (header (mail-header-number header))
8213 (t gnus-reffed-article-number))
8215 (insert " Article retrieved.\n"))
8216 (if (not (setq header (car (gnus-get-newsgroup-headers nil t))))
8217 () ; Malformed head.
8218 (unless (memq (mail-header-number header) gnus-newsgroup-sparse)
8219 (when (and (stringp id)
8220 (not (string= (gnus-group-real-name group)
8222 ;; If we fetched by Message-ID and the article came
8223 ;; from a different group, we fudge some bogus article
8224 ;; numbers for this article.
8225 (mail-header-set-number header gnus-reffed-article-number))
8227 (set-buffer gnus-summary-buffer)
8228 (decf gnus-reffed-article-number)
8229 (gnus-remove-header (mail-header-number header))
8230 (push header gnus-newsgroup-headers)
8231 (setq gnus-current-headers header)
8232 (push (mail-header-number header) gnus-newsgroup-limit)))
8235 (defun gnus-remove-header (number)
8236 "Remove header NUMBER from `gnus-newsgroup-headers'."
8237 (if (and gnus-newsgroup-headers
8238 (= number (mail-header-number (car gnus-newsgroup-headers))))
8239 (pop gnus-newsgroup-headers)
8240 (let ((headers gnus-newsgroup-headers))
8241 (while (and (cdr headers)
8242 (not (= number (mail-header-number (cadr headers)))))
8245 (setcdr headers (cddr headers))))))
8248 ;;; summary highlights
8251 (defun gnus-highlight-selected-summary ()
8252 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8253 ;; Highlight selected article in summary buffer
8254 (when gnus-summary-selected-face
8256 (let* ((beg (progn (beginning-of-line) (point)))
8257 (end (progn (end-of-line) (point)))
8258 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
8259 (from (if (get-text-property beg gnus-mouse-face-prop)
8261 (or (next-single-property-change
8262 beg gnus-mouse-face-prop nil end)
8267 (or (next-single-property-change
8268 from gnus-mouse-face-prop nil end)
8270 ;; If no mouse-face prop on line we will have to = from = end,
8271 ;; so we highlight the entire line instead.
8272 (when (= (+ to 2) from)
8275 (if gnus-newsgroup-selected-overlay
8276 ;; Move old overlay.
8278 gnus-newsgroup-selected-overlay from to (current-buffer))
8279 ;; Create new overlay.
8281 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
8282 'face gnus-summary-selected-face))))))
8284 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
8285 (defun gnus-summary-highlight-line ()
8286 "Highlight current line according to `gnus-summary-highlight'."
8287 (let* ((list gnus-summary-highlight)
8289 (end (progn (end-of-line) (point)))
8290 ;; now find out where the line starts and leave point there.
8291 (beg (progn (beginning-of-line) (point)))
8292 (article (gnus-summary-article-number))
8293 (score (or (cdr (assq (or article gnus-current-article)
8294 gnus-newsgroup-scored))
8295 gnus-summary-default-score 0))
8296 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
8297 (inhibit-read-only t))
8298 ;; Eval the cars of the lists until we find a match.
8299 (let ((default gnus-summary-default-score))
8301 (not (eval (caar list))))
8302 (setq list (cdr list))))
8303 (let ((face (cdar list)))
8304 (unless (eq face (get-text-property beg 'face))
8305 (gnus-put-text-property
8307 (setq face (if (boundp face) (symbol-value face) face)))
8308 (when gnus-summary-highlight-line-function
8309 (funcall gnus-summary-highlight-line-function article face))))
8312 (defun gnus-update-read-articles (group unread)
8313 "Update the list of read articles in GROUP."
8314 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
8315 (entry (gnus-gethash group gnus-newsrc-hashtb))
8316 (info (nth 2 entry))
8318 (unread (sort (copy-sequence unread) '<))
8320 (if (or (not info) (not active))
8321 ;; There is no info on this group if it was, in fact,
8322 ;; killed. Gnus stores no information on killed groups, so
8323 ;; there's nothing to be done.
8324 ;; One could store the information somewhere temporarily,
8325 ;; perhaps... Hmmm...
8327 ;; Remove any negative articles numbers.
8328 (while (and unread (< (car unread) 0))
8329 (setq unread (cdr unread)))
8330 ;; Remove any expired article numbers
8331 (while (and unread (< (car unread) (car active)))
8332 (setq unread (cdr unread)))
8333 ;; Compute the ranges of read articles by looking at the list of
8336 (when (/= (car unread) prev)
8337 (push (if (= prev (1- (car unread))) prev
8338 (cons prev (1- (car unread))))
8340 (setq prev (1+ (car unread)))
8341 (setq unread (cdr unread)))
8342 (when (<= prev (cdr active))
8343 (push (cons prev (cdr active)) read))
8346 (gnus-info-set-marks ,info ,(gnus-info-marks info))
8347 (gnus-info-set-read ,info ,(gnus-info-read info))
8348 (gnus-get-unread-articles-in-group ,info (gnus-active ,group))))
8349 ;; Enter this list into the group info.
8351 info (if (> (length read) 1) (nreverse read) read))
8352 ;; Set the number of unread articles in gnus-newsrc-hashtb.
8353 (gnus-get-unread-articles-in-group info (gnus-active group))
8358 ;;; gnus-sum.el ends here