1 ;;; gnus-sum.el --- summary mode commands for Gnus
2 ;; Copyright (C) 1996 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
35 (defgroup gnus-summary nil
39 (defcustom gnus-kill-summary-on-exit t
40 "*If non-nil, kill the summary buffer when you exit from it.
41 If nil, the summary will become a \"*Dead Summary*\" buffer, and
42 it will be killed sometime later."
46 (defcustom gnus-fetch-old-headers nil
47 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
48 If an unread article in the group refers to an older, already read (or
49 just marked as read) article, the old article will not normally be
50 displayed in the Summary buffer. If this variable is non-nil, Gnus
51 will attempt to grab the headers to the old articles, and thereby
52 build complete threads. If it has the value `some', only enough
53 headers to connect otherwise loose threads will be displayed.
54 This variable can also be a number. In that case, no more than that
55 number of old headers will be fetched.
57 The server has to support NOV for any of this to work."
59 :type '(choice (const :tag "off" nil)
62 (sexp :menu-tag "other" t)))
64 (defcustom gnus-summary-make-false-root 'adopt
65 "*nil means that Gnus won't gather loose threads.
66 If the root of a thread has expired or been read in a previous
67 session, the information necessary to build a complete thread has been
68 lost. Instead of having many small sub-threads from this original thread
69 scattered all over the summary buffer, Gnus can gather them.
71 If non-nil, Gnus will try to gather all loose sub-threads from an
72 original thread into one large thread.
74 If this variable is non-nil, it should be one of `none', `adopt',
77 If this variable is `none', Gnus will not make a false root, but just
78 present the sub-threads after another.
79 If this variable is `dummy', Gnus will create a dummy root that will
80 have all the sub-threads as children.
81 If this variable is `adopt', Gnus will make one of the \"children\"
82 the parent and mark all the step-children as such.
83 If this variable is `empty', the \"children\" are printed with empty
84 subject fields. (Or rather, they will be printed with a string
85 given by the `gnus-summary-same-subject' variable.)"
87 :type '(choice (const :tag "off" nil)
93 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
94 "*A regexp to match subjects to be excluded from loose thread gathering.
95 As loose thread gathering is done on subjects only, that means that
96 there can be many false gatherings performed. By rooting out certain
97 common subjects, gathering might become saner."
101 (defcustom gnus-summary-gather-subject-limit nil
102 "*Maximum length of subject comparisons when gathering loose threads.
103 Use nil to compare full subjects. Setting this variable to a low
104 number will help gather threads that have been corrupted by
105 newsreaders chopping off subject lines, but it might also mean that
106 unrelated articles that have subject that happen to begin with the
107 same few characters will be incorrectly gathered.
109 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
112 :type '(choice (const :tag "off" nil)
114 (sexp :menu-tag "on" t)))
116 (defcustom gnus-simplify-ignored-prefixes nil
117 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
119 :type '(choice (const :tag "off" nil)
122 (defcustom gnus-build-sparse-threads nil
123 "*If non-nil, fill in the gaps in threads.
124 If `some', only fill in the gaps that are needed to tie loose threads
125 together. If `more', fill in all leaf nodes that Gnus can find. If
126 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
128 :type '(choice (const :tag "off" nil)
131 (sexp :menu-tag "all" t)))
133 (defcustom gnus-summary-thread-gathering-function 'gnus-gather-threads-by-subject
134 "Function used for gathering loose threads.
135 There are two pre-defined functions: `gnus-gather-threads-by-subject',
136 which only takes Subjects into consideration; and
137 `gnus-gather-threads-by-references', which compared the References
138 headers of the articles to find matches."
140 :type '(set (function-item gnus-gather-threads-by-subject)
141 (function-item gnus-gather-threads-by-references)
142 (function :tag "other")))
144 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
145 (defcustom gnus-summary-same-subject ""
146 "*String indicating that the current article has the same subject as the previous.
147 This variable will only be used if the value of
148 `gnus-summary-make-false-root' is `empty'."
152 (defcustom gnus-summary-goto-unread t
153 "*If t, marking commands will go to the next unread article.
154 If `never', commands that usually go to the next unread article, will
155 go to the next article, whether it is read or not.
156 If nil, only the marking commands will go to the next (un)read article."
158 :type '(choice (const :tag "off" nil)
160 (sexp :menu-tag "on" t)))
162 (defcustom gnus-summary-default-score 0
163 "*Default article score level.
164 If this variable is nil, scoring will be disabled."
166 :type '(choice (const :tag "disable")
169 (defcustom gnus-summary-zcore-fuzz 0
170 "*Fuzziness factor for the zcore in the summary buffer.
171 Articles with scores closer than this to `gnus-summary-default-score'
176 (defcustom gnus-simplify-subject-fuzzy-regexp nil
177 "*Strings to be removed when doing fuzzy matches.
178 This can either be a regular expression or list of regular expressions
179 that will be removed from subject strings if fuzzy subject
180 simplification is selected."
182 :type '(repeat regexp))
184 (defcustom gnus-show-threads t
185 "*If non-nil, display threads in summary mode."
189 (defcustom gnus-thread-hide-subtree nil
190 "*If non-nil, hide all threads initially.
191 If threads are hidden, you have to run the command
192 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
193 to expose hidden threads."
197 (defcustom gnus-thread-hide-killed t
198 "*If non-nil, hide killed threads automatically."
202 (defcustom gnus-thread-ignore-subject nil
203 "*If non-nil, ignore subjects and do all threading based on the Reference header.
204 If nil, which is the default, articles that have different subjects
205 from their parents will start separate threads."
209 (defcustom gnus-thread-operation-ignore-subject t
210 "*If non-nil, subjects will be ignored when doing thread commands.
211 This affects commands like `gnus-summary-kill-thread' and
212 `gnus-summary-lower-thread'.
214 If this variable is nil, articles in the same thread with different
215 subjects will not be included in the operation in question. If this
216 variable is `fuzzy', only articles that have subjects that are fuzzily
217 equal will be included."
219 :type '(choice (const :tag "off" nil)
223 (defcustom gnus-thread-indent-level 4
224 "*Number that says how much each sub-thread should be indented."
228 (defcustom gnus-auto-extend-newsgroup t
229 "*If non-nil, extend newsgroup forward and backward when requested."
233 (defcustom gnus-auto-select-first t
234 "*If nil, don't select the first unread article when entering a group.
235 If this variable is `best', select the highest-scored unread article
236 in the group. If neither nil nor `best', select the first unread
239 If you want to prevent automatic selection of the first unread article
240 in some newsgroups, set the variable to nil in
241 `gnus-select-group-hook'."
243 :type '(choice (const :tag "none" nil)
245 (sexp :menu-tag "first" t)))
247 (defcustom gnus-auto-select-next t
248 "*If non-nil, offer to go to the next group from the end of the previous.
249 If the value is t and the next newsgroup is empty, Gnus will exit
250 summary mode and go back to group mode. If the value is neither nil
251 nor t, Gnus will select the following unread newsgroup. In
252 particular, if the value is the symbol `quietly', the next unread
253 newsgroup will be selected without any confirmation, and if it is
254 `almost-quietly', the next group will be selected without any
255 confirmation if you are located on the last article in the group.
256 Finally, if this variable is `slightly-quietly', the `Z n' command
257 will go to the next group without confirmation."
259 :type '(choice (const :tag "off" nil)
261 (const almost-quietly)
262 (const slightly-quietly)
263 (sexp :menu-tag "on" t)))
265 (defcustom gnus-auto-select-same nil
266 "*If non-nil, select the next article with the same subject."
270 (defcustom gnus-summary-check-current nil
271 "*If non-nil, consider the current article when moving.
272 The \"unread\" movement commands will stay on the same line if the
273 current article is unread."
277 (defcustom gnus-auto-center-summary t
278 "*If non-nil, always center the current summary buffer.
279 In particular, if `vertical' do only vertical recentering. If non-nil
280 and non-`vertical', do both horizontal and vertical recentering."
282 :type '(choice (const :tag "none" nil)
284 (sexp :menu-tag "both" t)))
286 (defcustom gnus-show-all-headers nil
287 "*If non-nil, don't hide any headers."
291 (defcustom gnus-single-article-buffer t
292 "*If non-nil, display all articles in the same buffer.
293 If nil, each group will get its own article buffer."
297 (defcustom gnus-break-pages t
298 "*If non-nil, do page breaking on articles.
299 The page delimiter is specified by the `gnus-page-delimiter'
304 (defcustom gnus-show-mime nil
305 "*If non-nil, do mime processing of articles.
306 The articles will simply be fed to the function given by
307 `gnus-show-mime-method'."
311 (defcustom gnus-move-split-methods nil
312 "*Variable used to suggest where articles are to be moved to.
313 It uses the same syntax as the `gnus-split-methods' variable."
315 :type '(repeat (choice (list function)
316 (cons regexp (repeat string))
319 ;; Mark variables suggested by Thomas Michanek
320 ;; <Thomas.Michanek@telelogic.se>.
322 (defgroup gnus-summary-marks nil
323 "Marks used in summary buffers."
324 :group 'gnus-summary)
326 (defcustom gnus-unread-mark ?
327 "*Mark used for unread articles."
328 :group 'gnus-summary-marks
331 (defcustom gnus-ticked-mark ?!
332 "*Mark used for ticked articles."
333 :group 'gnus-summary-marks
336 (defcustom gnus-dormant-mark ??
337 "*Mark used for dormant articles."
338 :group 'gnus-summary-marks
341 (defcustom gnus-del-mark ?r
342 "*Mark used for del'd articles."
343 :group 'gnus-summary-marks
346 (defcustom gnus-read-mark ?R
347 "*Mark used for read articles."
348 :group 'gnus-summary-marks
351 (defcustom gnus-expirable-mark ?E
352 "*Mark used for expirable articles."
353 :group 'gnus-summary-marks
356 (defcustom gnus-killed-mark ?K
357 "*Mark used for killed articles."
358 :group 'gnus-summary-marks
361 (defcustom gnus-souped-mark ?F
362 "*Mark used for killed articles."
363 :group 'gnus-summary-marks
366 (defcustom gnus-kill-file-mark ?X
367 "*Mark used for articles killed by kill files."
368 :group 'gnus-summary-marks
371 (defcustom gnus-low-score-mark ?Y
372 "*Mark used for articles with a low score."
373 :group 'gnus-summary-marks
376 (defcustom gnus-catchup-mark ?C
377 "*Mark used for articles that are caught up."
378 :group 'gnus-summary-marks
381 (defcustom gnus-replied-mark ?A
382 "*Mark used for articles that have been replied to."
383 :group 'gnus-summary-marks
386 (defcustom gnus-cached-mark ?*
387 "*Mark used for articles that are in the cache."
388 :group 'gnus-summary-marks
391 (defcustom gnus-saved-mark ?S
392 "*Mark used for articles that have been saved to."
393 :group 'gnus-summary-marks
396 (defcustom gnus-ancient-mark ?O
397 "*Mark used for ancient articles."
398 :group 'gnus-summary-marks
401 (defcustom gnus-sparse-mark ?Q
402 "*Mark used for sparsely reffed articles."
403 :group 'gnus-summary-marks
406 (defcustom gnus-canceled-mark ?G
407 "*Mark used for canceled articles."
408 :group 'gnus-summary-marks
411 (defcustom gnus-duplicate-mark ?M
412 "*Mark used for duplicate articles."
413 :group 'gnus-summary-marks
416 (defcustom gnus-score-over-mark ?+
417 "*Score mark used for articles with high scores."
418 :group 'gnus-summary-marks
421 (defcustom gnus-score-below-mark ?-
422 "*Score mark used for articles with low scores."
423 :group 'gnus-summary-marks
426 (defcustom gnus-empty-thread-mark ?
427 "*There is no thread under the article."
428 :group 'gnus-summary-marks
431 (defcustom gnus-not-empty-thread-mark ?=
432 "*There is a thread under the article."
433 :group 'gnus-summary-marks
436 (defcustom gnus-view-pseudo-asynchronously nil
437 "*If non-nil, Gnus will view pseudo-articles asynchronously."
441 (defcustom gnus-view-pseudos nil
442 "*If `automatic', pseudo-articles will be viewed automatically.
443 If `not-confirm', pseudos will be viewed automatically, and the user
444 will not be asked to confirm the command."
446 :type '(choice (const :tag "off" nil)
448 (const not-confirm)))
450 (defcustom gnus-view-pseudos-separately t
451 "*If non-nil, one pseudo-article will be created for each file to be viewed.
452 If nil, all files that use the same viewing command will be given as a
453 list of parameters to that command."
457 (defcustom gnus-insert-pseudo-articles t
458 "*If non-nil, insert pseudo-articles when decoding articles."
462 (defcustom gnus-summary-dummy-line-format
464 "*The format specification for the dummy roots in the summary buffer.
465 It works along the same lines as a normal formatting string,
466 with some simple extensions.
472 (defcustom gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
473 "*The format specification for the summary mode line.
474 It works along the same lines as a normal formatting string,
475 with some simple extensions:
478 %p Unprefixed group name
479 %A Current article number
481 %U Number of unread articles in the group
482 %e Number of unselected articles in the group
483 %Z A string with unread/unselected article counts
484 %g Shortish group name
485 %S Subject of the current article
487 %s Current score file name
488 %d Number of dormant articles
489 %r Number of articles that have been marked as read in this session
490 %E Number of articles expunged by the score files"
494 (defcustom gnus-summary-mark-below 0
495 "*Mark all articles with a score below this variable as read.
496 This variable is local to each summary buffer and usually set by the
501 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
502 "*List of functions used for sorting articles in the summary buffer.
503 This variable is only used when not using a threaded display."
505 :type '(repeat (choice (function-item gnus-article-sort-by-number)
506 (function-item gnus-article-sort-by-author)
507 (function-item gnus-article-sort-by-subject)
508 (function-item gnus-article-sort-by-date)
509 (function-item gnus-article-sort-by-score)
510 (function :tag "other"))))
512 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
513 "*List of functions used for sorting threads in the summary buffer.
514 By default, threads are sorted by article number.
516 Each function takes two threads and return non-nil if the first thread
517 should be sorted before the other. If you use more than one function,
518 the primary sort function should be the last. You should probably
519 always include `gnus-thread-sort-by-number' in the list of sorting
520 functions -- preferably first.
522 Ready-made functions include `gnus-thread-sort-by-number',
523 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
524 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
525 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
527 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
528 (function-item gnus-thread-sort-by-author)
529 (function-item gnus-thread-sort-by-subject)
530 (function-item gnus-thread-sort-by-date)
531 (function-item gnus-thread-sort-by-score)
532 (function-item gnus-thread-sort-by-total-score)
533 (function :tag "other"))))
535 (defcustom gnus-thread-score-function '+
536 "*Function used for calculating the total score of a thread.
538 The function is called with the scores of the article and each
539 subthread and should then return the score of the thread.
541 Some functions you can use are `+', `max', or `min'."
545 (defcustom gnus-summary-expunge-below nil
546 "All articles that have a score less than this variable will be expunged."
548 :type '(choice (const :tag "off" nil)
551 (defcustom gnus-thread-expunge-below nil
552 "All threads that have a total score less than this variable will be expunged.
553 See `gnus-thread-score-function' for en explanation of what a
554 \"thread score\" is."
556 :type '(choice (const :tag "off" nil)
559 (defcustom gnus-summary-mode-hook nil
560 "*A hook for Gnus summary mode.
561 This hook is run before any variables are set in the summary buffer."
565 (defcustom gnus-summary-menu-hook nil
566 "*Hook run after the creation of the summary mode menu."
570 (defcustom gnus-summary-exit-hook nil
571 "*A hook called on exit from the summary buffer."
575 (defcustom gnus-summary-prepare-hook nil
576 "*A hook called after the summary buffer has been generated.
577 If you want to modify the summary buffer, you can use this hook."
581 (defcustom gnus-summary-generate-hook nil
582 "*A hook run just before generating the summary buffer.
583 This hook is commonly used to customize threading variables and the
588 (defcustom gnus-select-group-hook nil
589 "*A hook called when a newsgroup is selected.
591 If you'd like to simplify subjects like the
592 `gnus-summary-next-same-subject' command does, you can use the
595 (setq gnus-select-group-hook
598 (mapcar (lambda (header)
599 (mail-header-set-subject
601 (gnus-simplify-subject
602 (mail-header-subject header) 're-only)))
603 gnus-newsgroup-headers))))"
607 (defcustom gnus-select-article-hook nil
608 "*A hook called when an article is selected."
612 (defcustom gnus-visual-mark-article-hook
613 (list 'gnus-highlight-selected-summary)
614 "*Hook run after selecting an article in the summary buffer.
615 It is meant to be used for highlighting the article in some way. It
616 is not run if `gnus-visual' is nil."
620 (defcustom gnus-parse-headers-hook
621 (list 'gnus-decode-rfc1522)
622 "*A hook called before parsing the headers."
626 (defcustom gnus-exit-group-hook nil
627 "*A hook called when exiting (not quitting) summary mode."
631 (defcustom gnus-summary-update-hook
632 (list 'gnus-summary-highlight-line)
633 "*A hook called when a summary line is changed.
634 The hook will not be called if `gnus-visual' is nil.
636 The default function `gnus-summary-highlight-line' will
637 highlight the line according to the `gnus-summary-highlight'
642 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
643 "*A hook called when an article is selected for the first time.
644 The hook is intended to mark an article as read (or unread)
645 automatically when it is selected."
649 (defcustom gnus-group-no-more-groups-hook nil
650 "*A hook run when returning to group mode having no more (unread) groups."
654 (defface gnus-summary-selected-face '((t
656 "Face used for selected articles.")
658 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
659 "Face used for highlighting the current article in the summary buffer."
663 (defface gnus-summary-cancelled-face
665 (:foreground "yellow" :background "black")))
666 "Face used for cancelled articles.")
668 (defface gnus-summary-high-ticked-face
671 (:foreground "pink" :bold t))
674 (:foreground "firebrick" :bold t))
677 "Face used for high interest ticked articles.")
679 (defface gnus-summary-low-ticked-face
682 (:foreground "pink" :italic t))
685 (:foreground "firebrick" :italic t))
688 "Face used for low interest ticked articles.")
690 (defface gnus-summary-normal-ticked-face
693 (:foreground "pink"))
696 (:foreground "firebrick"))
699 "Face used for normal interest ticked articles.")
701 (defface gnus-summary-high-ancient-face
704 (:foreground "SkyBlue" :bold t))
707 (:foreground "RoyalBlue" :bold t))
710 "Face used for high interest ancient articles.")
712 (defface gnus-summary-low-ancient-face
715 (:foreground "SkyBlue" :italic t))
718 (:foreground "RoyalBlue" :italic t))
721 "Face used for low interest ancient articles.")
723 (defface gnus-summary-normal-ancient-face
726 (:foreground "SkyBlue"))
729 (:foreground "RoyalBlue"))
732 "Face used for normal interest ancient articles.")
734 (defface gnus-summary-high-unread-face
737 "Face used for high interest unread articles.")
739 (defface gnus-summary-low-unread-face
742 "Face used for low interest unread articles.")
744 (defface gnus-summary-normal-unread-face
747 "Face used for normal interest unread articles.")
749 (defface gnus-summary-high-read-face
752 (:foreground "PaleGreen"
756 (:foreground "DarkGreen"
760 "Face used for high interest read articles.")
762 (defface gnus-summary-low-read-face
765 (:foreground "PaleGreen"
769 (:foreground "DarkGreen"
773 "Face used for low interest read articles.")
775 (defface gnus-summary-normal-read-face
778 (:foreground "PaleGreen"))
781 (:foreground "DarkGreen"))
784 "Face used for normal interest read articles.")
786 (defcustom gnus-summary-highlight
787 '(((= mark gnus-canceled-mark)
788 . gnus-summary-cancelled-face)
789 ((and (> score default)
790 (or (= mark gnus-dormant-mark)
791 (= mark gnus-ticked-mark)))
792 . gnus-summary-high-ticked-face)
793 ((and (< score default)
794 (or (= mark gnus-dormant-mark)
795 (= mark gnus-ticked-mark)))
796 . gnus-summary-low-ticked-face)
797 ((or (= mark gnus-dormant-mark)
798 (= mark gnus-ticked-mark))
799 . gnus-summary-normal-ticked-face)
800 ((and (> score default) (= mark gnus-ancient-mark))
801 . gnus-summary-high-ancient-face)
802 ((and (< score default) (= mark gnus-ancient-mark))
803 . gnus-summary-low-ancient-face)
804 ((= mark gnus-ancient-mark)
805 . gnus-summary-normal-ancient-face)
806 ((and (> score default) (= mark gnus-unread-mark))
807 . gnus-summary-high-unread-face)
808 ((and (< score default) (= mark gnus-unread-mark))
809 . gnus-summary-low-unread-face)
810 ((and (= mark gnus-unread-mark))
811 . gnus-summary-normal-unread-face)
813 . gnus-summary-high-read-face)
815 . gnus-summary-low-read-face)
817 . gnus-summary-normal-read-face))
818 "Controls the highlighting of summary buffer lines.
820 A list of (FORM . FACE) pairs. When deciding how a a particular
821 summary line should be displayed, each form is evaluated. The content
822 of the face field after the first true form is used. You can change
823 how those summary lines are displayed, by editing the face field.
825 You can use the following variables in the FORM field.
827 score: The articles score
828 default: The default article score.
829 below: The score below which articles are automatically marked as read.
830 mark: The articles mark."
832 :type '(repeat (cons (sexp :tag "Form" nil)
835 ;;; Internal variables
837 (defvar gnus-scores-exclude-files nil)
839 (defvar gnus-summary-display-table
840 ;; Change the display table. Odd characters have a tendency to mess
841 ;; up nicely formatted displays - we make all possible glyphs
842 ;; display only a single character.
844 ;; We start from the standard display table, if any.
845 (let ((table (or (copy-sequence standard-display-table)
846 (make-display-table)))
847 ;; Nix out all the control chars...
849 (while (>= (setq i (1- i)) 0)
851 ;; ... but not newline and cr, of course. (cr is necessary for the
852 ;; selective display).
855 ;; We nix out any glyphs over 126 that are not set already.
857 (while (>= (setq i (1- i)) 127)
858 ;; Only modify if the entry is nil.
860 (aset table i [??]))))
862 "Display table used in summary mode buffers.")
864 (defvar gnus-original-article nil)
865 (defvar gnus-article-internal-prepare-hook nil)
866 (defvar gnus-newsgroup-process-stack nil)
868 (defvar gnus-thread-indent-array nil)
869 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
871 ;; Avoid highlighting in kill files.
872 (defvar gnus-summary-inhibit-highlight nil)
873 (defvar gnus-newsgroup-selected-overlay nil)
874 (defvar gnus-inhibit-limiting nil)
875 (defvar gnus-newsgroup-adaptive-score-file nil)
876 (defvar gnus-current-score-file nil)
877 (defvar gnus-current-move-group nil)
878 (defvar gnus-current-copy-group nil)
879 (defvar gnus-current-crosspost-group nil)
881 (defvar gnus-newsgroup-dependencies nil)
882 (defvar gnus-newsgroup-adaptive nil)
883 (defvar gnus-summary-display-article-function nil)
884 (defvar gnus-summary-highlight-line-function nil
885 "Function called after highlighting a summary line.")
887 (defvar gnus-summary-line-format-alist
888 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
889 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
890 (?s gnus-tmp-subject-or-nil ?s)
891 (?n gnus-tmp-name ?s)
892 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
894 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
896 (?F gnus-tmp-from ?s)
897 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
898 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
899 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
900 (?o (gnus-date-iso8601 gnus-tmp-header) ?s)
901 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
902 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
903 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
904 (?L gnus-tmp-lines ?d)
905 (?I gnus-tmp-indentation ?s)
906 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
907 (?R gnus-tmp-replied ?c)
908 (?\[ gnus-tmp-opening-bracket ?c)
909 (?\] gnus-tmp-closing-bracket ?c)
910 (?\> (make-string gnus-tmp-level ? ) ?s)
911 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
912 (?i gnus-tmp-score ?d)
913 (?z gnus-tmp-score-char ?c)
914 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
915 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
916 (?U gnus-tmp-unread ?c)
917 (?t (gnus-summary-number-of-articles-in-thread
918 (and (boundp 'thread) (car thread)) gnus-tmp-level)
920 (?e (gnus-summary-number-of-articles-in-thread
921 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
923 (?u gnus-tmp-user-defined ?s)
924 (?P (gnus-pick-line-number) ?d))
925 "An alist of format specifications that can appear in summary lines,
926 and what variables they correspond with, along with the type of the
927 variable (string, integer, character, etc).")
929 (defvar gnus-summary-dummy-line-format-alist
930 `((?S gnus-tmp-subject ?s)
931 (?N gnus-tmp-number ?d)
932 (?u gnus-tmp-user-defined ?s)))
934 (defvar gnus-summary-mode-line-format-alist
935 `((?G gnus-tmp-group-name ?s)
936 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
937 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
938 (?A gnus-tmp-article-number ?d)
939 (?Z gnus-tmp-unread-and-unselected ?s)
941 (?U gnus-tmp-unread-and-unticked ?d)
942 (?S gnus-tmp-subject ?s)
943 (?e gnus-tmp-unselected ?d)
944 (?u gnus-tmp-user-defined ?s)
945 (?d (length gnus-newsgroup-dormant) ?d)
946 (?t (length gnus-newsgroup-marked) ?d)
947 (?r (length gnus-newsgroup-reads) ?d)
948 (?E gnus-newsgroup-expunged-tally ?d)
949 (?s (gnus-current-score-file-nondirectory) ?s)))
951 (defvar gnus-last-search-regexp nil
952 "Default regexp for article search command.")
954 (defvar gnus-last-shell-command nil
955 "Default shell command on article.")
957 (defvar gnus-newsgroup-begin nil)
958 (defvar gnus-newsgroup-end nil)
959 (defvar gnus-newsgroup-last-rmail nil)
960 (defvar gnus-newsgroup-last-mail nil)
961 (defvar gnus-newsgroup-last-folder nil)
962 (defvar gnus-newsgroup-last-file nil)
963 (defvar gnus-newsgroup-auto-expire nil)
964 (defvar gnus-newsgroup-active nil)
966 (defvar gnus-newsgroup-data nil)
967 (defvar gnus-newsgroup-data-reverse nil)
968 (defvar gnus-newsgroup-limit nil)
969 (defvar gnus-newsgroup-limits nil)
971 (defvar gnus-newsgroup-unreads nil
972 "List of unread articles in the current newsgroup.")
974 (defvar gnus-newsgroup-unselected nil
975 "List of unselected unread articles in the current newsgroup.")
977 (defvar gnus-newsgroup-reads nil
978 "Alist of read articles and article marks in the current newsgroup.")
980 (defvar gnus-newsgroup-expunged-tally nil)
982 (defvar gnus-newsgroup-marked nil
983 "List of ticked articles in the current newsgroup (a subset of unread art).")
985 (defvar gnus-newsgroup-killed nil
986 "List of ranges of articles that have been through the scoring process.")
988 (defvar gnus-newsgroup-cached nil
989 "List of articles that come from the article cache.")
991 (defvar gnus-newsgroup-saved nil
992 "List of articles that have been saved.")
994 (defvar gnus-newsgroup-kill-headers nil)
996 (defvar gnus-newsgroup-replied nil
997 "List of articles that have been replied to in the current newsgroup.")
999 (defvar gnus-newsgroup-expirable nil
1000 "List of articles in the current newsgroup that can be expired.")
1002 (defvar gnus-newsgroup-processable nil
1003 "List of articles in the current newsgroup that can be processed.")
1005 (defvar gnus-newsgroup-bookmarks nil
1006 "List of articles in the current newsgroup that have bookmarks.")
1008 (defvar gnus-newsgroup-dormant nil
1009 "List of dormant articles in the current newsgroup.")
1011 (defvar gnus-newsgroup-scored nil
1012 "List of scored articles in the current newsgroup.")
1014 (defvar gnus-newsgroup-headers nil
1015 "List of article headers in the current newsgroup.")
1017 (defvar gnus-newsgroup-threads nil)
1019 (defvar gnus-newsgroup-prepared nil
1020 "Whether the current group has been prepared properly.")
1022 (defvar gnus-newsgroup-ancient nil
1023 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1025 (defvar gnus-newsgroup-sparse nil)
1027 (defvar gnus-current-article nil)
1028 (defvar gnus-article-current nil)
1029 (defvar gnus-current-headers nil)
1030 (defvar gnus-have-all-headers nil)
1031 (defvar gnus-last-article nil)
1032 (defvar gnus-newsgroup-history nil)
1034 (defconst gnus-summary-local-variables
1035 '(gnus-newsgroup-name
1036 gnus-newsgroup-begin gnus-newsgroup-end
1037 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1038 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1039 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1040 gnus-newsgroup-unselected gnus-newsgroup-marked
1041 gnus-newsgroup-reads gnus-newsgroup-saved
1042 gnus-newsgroup-replied gnus-newsgroup-expirable
1043 gnus-newsgroup-processable gnus-newsgroup-killed
1044 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1045 gnus-newsgroup-headers gnus-newsgroup-threads
1046 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1047 gnus-current-article gnus-current-headers gnus-have-all-headers
1048 gnus-last-article gnus-article-internal-prepare-hook
1049 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1050 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1051 gnus-thread-expunge-below
1052 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1053 (gnus-summary-mark-below . global)
1054 gnus-newsgroup-active gnus-scores-exclude-files
1055 gnus-newsgroup-history gnus-newsgroup-ancient
1056 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1057 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1058 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1059 (gnus-newsgroup-expunged-tally . 0)
1060 gnus-cache-removable-articles gnus-newsgroup-cached
1061 gnus-newsgroup-data gnus-newsgroup-data-reverse
1062 gnus-newsgroup-limit gnus-newsgroup-limits)
1063 "Variables that are buffer-local to the summary buffers.")
1065 ;; Byte-compiler warning.
1066 (defvar gnus-article-mode-map)
1068 ;; Subject simplification.
1070 (defsubst gnus-simplify-subject-re (subject)
1071 "Remove \"Re:\" from subject lines."
1072 (if (string-match "^[Rr][Ee]: *" subject)
1073 (substring subject (match-end 0))
1076 (defun gnus-simplify-subject (subject &optional re-only)
1077 "Remove `Re:' and words in parentheses.
1078 If RE-ONLY is non-nil, strip leading `Re:'s only."
1079 (let ((case-fold-search t)) ;Ignore case.
1080 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1081 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1082 (setq subject (substring subject (match-end 0))))
1083 ;; Remove uninteresting prefixes.
1084 (when (and (not re-only)
1085 gnus-simplify-ignored-prefixes
1086 (string-match gnus-simplify-ignored-prefixes subject))
1087 (setq subject (substring subject (match-end 0))))
1088 ;; Remove words in parentheses from end.
1090 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1091 (setq subject (substring subject 0 (match-beginning 0)))))
1092 ;; Return subject string.
1095 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1097 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
1098 (defun gnus-simplify-buffer-fuzzy ()
1099 (let ((case-fold-search t))
1100 (goto-char (point-min))
1101 (while (search-forward "\t" nil t)
1102 (replace-match " " t t))
1103 (goto-char (point-min))
1104 (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *" nil t)
1105 (goto-char (match-beginning 0))
1107 (looking-at "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1108 (looking-at "^[[].*: .*[]]$"))
1109 (goto-char (point-min))
1110 (while (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *"
1112 (replace-match "" t t))
1113 (goto-char (point-min))
1114 (while (re-search-forward "^[[].*: .*[]]$" nil t)
1115 (goto-char (match-end 0))
1118 (progn (goto-char (match-beginning 0)))
1119 (re-search-forward ":"))))
1120 (goto-char (point-min))
1121 (while (re-search-forward " *[[{(][^()\n]*[]})] *$" nil t)
1122 (replace-match "" t t))
1123 (goto-char (point-min))
1124 (while (re-search-forward " +" nil t)
1125 (replace-match " " t t))
1126 (goto-char (point-min))
1127 (while (re-search-forward " $" nil t)
1128 (replace-match "" t t))
1129 (goto-char (point-min))
1130 (while (re-search-forward "^ +" nil t)
1131 (replace-match "" t t))
1132 (goto-char (point-min))
1133 (when gnus-simplify-subject-fuzzy-regexp
1134 (if (listp gnus-simplify-subject-fuzzy-regexp)
1135 (let ((list gnus-simplify-subject-fuzzy-regexp))
1137 (goto-char (point-min))
1138 (while (re-search-forward (car list) nil t)
1139 (replace-match "" t t))
1140 (setq list (cdr list))))
1141 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
1142 (replace-match "" t t))))))
1144 (defun gnus-simplify-subject-fuzzy (subject)
1145 "Simplify a subject string fuzzily."
1147 (gnus-set-work-buffer)
1148 (let ((case-fold-search t))
1150 (inline (gnus-simplify-buffer-fuzzy))
1153 (defsubst gnus-simplify-subject-fully (subject)
1154 "Simplify a subject string according to the user's wishes."
1156 ((null gnus-summary-gather-subject-limit)
1157 (gnus-simplify-subject-re subject))
1158 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1159 (gnus-simplify-subject-fuzzy subject))
1160 ((numberp gnus-summary-gather-subject-limit)
1161 (gnus-limit-string (gnus-simplify-subject-re subject)
1162 gnus-summary-gather-subject-limit))
1166 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1167 "Check whether two subjects are equal. If optional argument
1168 simple-first is t, first argument is already simplified."
1170 ((null simple-first)
1171 (equal (gnus-simplify-subject-fully s1)
1172 (gnus-simplify-subject-fully s2)))
1175 (gnus-simplify-subject-fully s2)))))
1177 (defun gnus-offer-save-summaries ()
1178 "Offer to save all active summary buffers."
1180 (let ((buflist (buffer-list))
1182 ;; Go through all buffers and find all summaries.
1184 (and (setq bufname (buffer-name (car buflist)))
1185 (string-match "Summary" bufname)
1187 (set-buffer bufname)
1188 ;; We check that this is, indeed, a summary buffer.
1189 (and (eq major-mode 'gnus-summary-mode)
1190 ;; Also make sure this isn't bogus.
1191 gnus-newsgroup-prepared))
1192 (push bufname buffers))
1193 (setq buflist (cdr buflist)))
1194 ;; Go through all these summary buffers and offer to save them.
1197 "Update summary buffer %s? "
1198 (lambda (buf) (set-buffer buf) (gnus-summary-exit))
1201 (defun gnus-summary-bubble-group ()
1202 "Increase the score of the current group.
1203 This is a handy function to add to `gnus-summary-exit-hook' to
1204 increase the score of each group you read."
1205 (gnus-group-add-score gnus-newsgroup-name))
1209 ;;; Gnus summary mode
1212 (put 'gnus-summary-mode 'mode-class 'special)
1215 ;; Non-orthogonal keys
1217 (gnus-define-keys gnus-summary-mode-map
1218 " " gnus-summary-next-page
1219 "\177" gnus-summary-prev-page
1220 [delete] gnus-summary-prev-page
1221 "\r" gnus-summary-scroll-up
1222 "n" gnus-summary-next-unread-article
1223 "p" gnus-summary-prev-unread-article
1224 "N" gnus-summary-next-article
1225 "P" gnus-summary-prev-article
1226 "\M-\C-n" gnus-summary-next-same-subject
1227 "\M-\C-p" gnus-summary-prev-same-subject
1228 "\M-n" gnus-summary-next-unread-subject
1229 "\M-p" gnus-summary-prev-unread-subject
1230 "." gnus-summary-first-unread-article
1231 "," gnus-summary-best-unread-article
1232 "\M-s" gnus-summary-search-article-forward
1233 "\M-r" gnus-summary-search-article-backward
1234 "<" gnus-summary-beginning-of-article
1235 ">" gnus-summary-end-of-article
1236 "j" gnus-summary-goto-article
1237 "^" gnus-summary-refer-parent-article
1238 "\M-^" gnus-summary-refer-article
1239 "u" gnus-summary-tick-article-forward
1240 "!" gnus-summary-tick-article-forward
1241 "U" gnus-summary-tick-article-backward
1242 "d" gnus-summary-mark-as-read-forward
1243 "D" gnus-summary-mark-as-read-backward
1244 "E" gnus-summary-mark-as-expirable
1245 "\M-u" gnus-summary-clear-mark-forward
1246 "\M-U" gnus-summary-clear-mark-backward
1247 "k" gnus-summary-kill-same-subject-and-select
1248 "\C-k" gnus-summary-kill-same-subject
1249 "\M-\C-k" gnus-summary-kill-thread
1250 "\M-\C-l" gnus-summary-lower-thread
1251 "e" gnus-summary-edit-article
1252 "#" gnus-summary-mark-as-processable
1253 "\M-#" gnus-summary-unmark-as-processable
1254 "\M-\C-t" gnus-summary-toggle-threads
1255 "\M-\C-s" gnus-summary-show-thread
1256 "\M-\C-h" gnus-summary-hide-thread
1257 "\M-\C-f" gnus-summary-next-thread
1258 "\M-\C-b" gnus-summary-prev-thread
1259 "\M-\C-u" gnus-summary-up-thread
1260 "\M-\C-d" gnus-summary-down-thread
1261 "&" gnus-summary-execute-command
1262 "c" gnus-summary-catchup-and-exit
1263 "\C-w" gnus-summary-mark-region-as-read
1264 "\C-t" gnus-summary-toggle-truncation
1265 "?" gnus-summary-mark-as-dormant
1266 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1267 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1268 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1269 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1270 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1271 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1272 "=" gnus-summary-expand-window
1273 "\C-x\C-s" gnus-summary-reselect-current-group
1274 "\M-g" gnus-summary-rescan-group
1275 "w" gnus-summary-stop-page-breaking
1276 "\C-c\C-r" gnus-summary-caesar-message
1277 "\M-t" gnus-summary-toggle-mime
1278 "f" gnus-summary-followup
1279 "F" gnus-summary-followup-with-original
1280 "C" gnus-summary-cancel-article
1281 "r" gnus-summary-reply
1282 "R" gnus-summary-reply-with-original
1283 "\C-c\C-f" gnus-summary-mail-forward
1284 "o" gnus-summary-save-article
1285 "\C-o" gnus-summary-save-article-mail
1286 "|" gnus-summary-pipe-output
1287 "\M-k" gnus-summary-edit-local-kill
1288 "\M-K" gnus-summary-edit-global-kill
1290 "\C-c\C-d" gnus-summary-describe-group
1291 "q" gnus-summary-exit
1292 "Q" gnus-summary-exit-no-update
1293 "\C-c\C-i" gnus-info-find-node
1294 gnus-mouse-2 gnus-mouse-pick-article
1295 "m" gnus-summary-mail-other-window
1296 "a" gnus-summary-post-news
1297 "x" gnus-summary-limit-to-unread
1298 "s" gnus-summary-isearch-article
1299 "t" gnus-article-hide-headers
1300 "g" gnus-summary-show-article
1301 "l" gnus-summary-goto-last-article
1302 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1303 "\C-d" gnus-summary-enter-digest-group
1304 "\M-\C-d" gnus-summary-read-document
1306 "*" gnus-cache-enter-article
1307 "\M-*" gnus-cache-remove-article
1308 "\M-&" gnus-summary-universal-argument
1309 "\C-l" gnus-recenter
1310 "I" gnus-summary-increase-score
1311 "L" gnus-summary-lower-score
1313 "V" gnus-summary-score-map
1314 "X" gnus-uu-extract-map
1315 "S" gnus-summary-send-map)
1317 ;; Sort of orthogonal keymap
1318 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1319 "t" gnus-summary-tick-article-forward
1320 "!" gnus-summary-tick-article-forward
1321 "d" gnus-summary-mark-as-read-forward
1322 "r" gnus-summary-mark-as-read-forward
1323 "c" gnus-summary-clear-mark-forward
1324 " " gnus-summary-clear-mark-forward
1325 "e" gnus-summary-mark-as-expirable
1326 "x" gnus-summary-mark-as-expirable
1327 "?" gnus-summary-mark-as-dormant
1328 "b" gnus-summary-set-bookmark
1329 "B" gnus-summary-remove-bookmark
1330 "#" gnus-summary-mark-as-processable
1331 "\M-#" gnus-summary-unmark-as-processable
1332 "S" gnus-summary-limit-include-expunged
1333 "C" gnus-summary-catchup
1334 "H" gnus-summary-catchup-to-here
1335 "\C-c" gnus-summary-catchup-all
1336 "k" gnus-summary-kill-same-subject-and-select
1337 "K" gnus-summary-kill-same-subject
1338 "P" gnus-uu-mark-map)
1340 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1341 "c" gnus-summary-clear-above
1342 "u" gnus-summary-tick-above
1343 "m" gnus-summary-mark-above
1344 "k" gnus-summary-kill-below)
1346 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1347 "/" gnus-summary-limit-to-subject
1348 "n" gnus-summary-limit-to-articles
1349 "w" gnus-summary-pop-limit
1350 "s" gnus-summary-limit-to-subject
1351 "a" gnus-summary-limit-to-author
1352 "u" gnus-summary-limit-to-unread
1353 "m" gnus-summary-limit-to-marks
1354 "v" gnus-summary-limit-to-score
1355 "D" gnus-summary-limit-include-dormant
1356 "d" gnus-summary-limit-exclude-dormant
1357 ;; "t" gnus-summary-limit-exclude-thread
1358 "E" gnus-summary-limit-include-expunged
1359 "c" gnus-summary-limit-exclude-childless-dormant
1360 "C" gnus-summary-limit-mark-excluded-as-read)
1362 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1363 "n" gnus-summary-next-unread-article
1364 "p" gnus-summary-prev-unread-article
1365 "N" gnus-summary-next-article
1366 "P" gnus-summary-prev-article
1367 "\C-n" gnus-summary-next-same-subject
1368 "\C-p" gnus-summary-prev-same-subject
1369 "\M-n" gnus-summary-next-unread-subject
1370 "\M-p" gnus-summary-prev-unread-subject
1371 "f" gnus-summary-first-unread-article
1372 "b" gnus-summary-best-unread-article
1373 "j" gnus-summary-goto-article
1374 "g" gnus-summary-goto-subject
1375 "l" gnus-summary-goto-last-article
1376 "p" gnus-summary-pop-article)
1378 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1379 "k" gnus-summary-kill-thread
1380 "l" gnus-summary-lower-thread
1381 "i" gnus-summary-raise-thread
1382 "T" gnus-summary-toggle-threads
1383 "t" gnus-summary-rethread-current
1384 "^" gnus-summary-reparent-thread
1385 "s" gnus-summary-show-thread
1386 "S" gnus-summary-show-all-threads
1387 "h" gnus-summary-hide-thread
1388 "H" gnus-summary-hide-all-threads
1389 "n" gnus-summary-next-thread
1390 "p" gnus-summary-prev-thread
1391 "u" gnus-summary-up-thread
1392 "o" gnus-summary-top-thread
1393 "d" gnus-summary-down-thread
1394 "#" gnus-uu-mark-thread
1395 "\M-#" gnus-uu-unmark-thread)
1397 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1398 "g" gnus-summary-prepare
1399 "c" gnus-summary-insert-cached-articles)
1401 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1402 "c" gnus-summary-catchup-and-exit
1403 "C" gnus-summary-catchup-all-and-exit
1404 "E" gnus-summary-exit-no-update
1405 "Q" gnus-summary-exit
1406 "Z" gnus-summary-exit
1407 "n" gnus-summary-catchup-and-goto-next-group
1408 "R" gnus-summary-reselect-current-group
1409 "G" gnus-summary-rescan-group
1410 "N" gnus-summary-next-group
1411 "P" gnus-summary-prev-group)
1413 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1414 " " gnus-summary-next-page
1415 "n" gnus-summary-next-page
1416 "\177" gnus-summary-prev-page
1417 [delete] gnus-summary-prev-page
1418 "p" gnus-summary-prev-page
1419 "\r" gnus-summary-scroll-up
1420 "<" gnus-summary-beginning-of-article
1421 ">" gnus-summary-end-of-article
1422 "b" gnus-summary-beginning-of-article
1423 "e" gnus-summary-end-of-article
1424 "^" gnus-summary-refer-parent-article
1425 "r" gnus-summary-refer-parent-article
1426 "R" gnus-summary-refer-references
1427 "g" gnus-summary-show-article
1428 "s" gnus-summary-isearch-article)
1430 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1431 "b" gnus-article-add-buttons
1432 "B" gnus-article-add-buttons-to-head
1433 "o" gnus-article-treat-overstrike
1434 "e" gnus-article-emphasize
1435 "w" gnus-article-fill-cited-article
1436 "c" gnus-article-remove-cr
1437 "q" gnus-article-de-quoted-unreadable
1438 "f" gnus-article-display-x-face
1439 "l" gnus-summary-stop-page-breaking
1440 "r" gnus-summary-caesar-message
1441 "t" gnus-article-hide-headers
1442 "v" gnus-summary-verbose-headers
1443 "m" gnus-summary-toggle-mime)
1445 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1446 "a" gnus-article-hide
1447 "h" gnus-article-hide-headers
1448 "b" gnus-article-hide-boring-headers
1449 "s" gnus-article-hide-signature
1450 "c" gnus-article-hide-citation
1451 "p" gnus-article-hide-pgp
1452 "P" gnus-article-hide-pem
1453 "\C-c" gnus-article-hide-citation-maybe)
1455 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1456 "a" gnus-article-highlight
1457 "h" gnus-article-highlight-headers
1458 "c" gnus-article-highlight-citation
1459 "s" gnus-article-highlight-signature)
1461 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1462 "z" gnus-article-date-ut
1463 "u" gnus-article-date-ut
1464 "l" gnus-article-date-local
1465 "e" gnus-article-date-lapsed
1466 "o" gnus-article-date-original)
1468 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1469 "t" gnus-article-remove-trailing-blank-lines
1470 "l" gnus-article-strip-leading-blank-lines
1471 "m" gnus-article-strip-multiple-blank-lines
1472 "a" gnus-article-strip-blank-lines)
1474 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1476 "f" gnus-summary-fetch-faq
1477 "d" gnus-summary-describe-group
1478 "h" gnus-summary-describe-briefly
1479 "i" gnus-info-find-node)
1481 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1482 "e" gnus-summary-expire-articles
1483 "\M-\C-e" gnus-summary-expire-articles-now
1484 "\177" gnus-summary-delete-article
1485 [delete] gnus-summary-delete-article
1486 "m" gnus-summary-move-article
1487 "r" gnus-summary-respool-article
1488 "w" gnus-summary-edit-article
1489 "c" gnus-summary-copy-article
1490 "B" gnus-summary-crosspost-article
1491 "q" gnus-summary-respool-query
1492 "i" gnus-summary-import-article
1493 "p" gnus-summary-article-posted-p)
1495 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1496 "o" gnus-summary-save-article
1497 "m" gnus-summary-save-article-mail
1498 "F" gnus-summary-write-article-file
1499 "r" gnus-summary-save-article-rmail
1500 "f" gnus-summary-save-article-file
1501 "b" gnus-summary-save-article-body-file
1502 "h" gnus-summary-save-article-folder
1503 "v" gnus-summary-save-article-vm
1504 "p" gnus-summary-pipe-output
1505 "s" gnus-soup-add-article))
1507 (defun gnus-summary-make-menu-bar ()
1508 (gnus-turn-off-edit-menu 'summary)
1510 (unless (boundp 'gnus-summary-misc-menu)
1513 gnus-summary-kill-menu gnus-summary-mode-map ""
1518 ["Enter score..." gnus-summary-score-entry t])
1519 (gnus-make-score-map 'increase)
1520 (gnus-make-score-map 'lower)
1522 ["Kill below" gnus-summary-kill-below t]
1523 ["Mark above" gnus-summary-mark-above t]
1524 ["Tick above" gnus-summary-tick-above t]
1525 ["Clear above" gnus-summary-clear-above t])
1526 ["Current score" gnus-summary-current-score t]
1527 ["Set score" gnus-summary-set-score t]
1528 ["Switch current score file..." gnus-score-change-score-file t]
1529 ["Set mark below..." gnus-score-set-mark-below t]
1530 ["Set expunge below..." gnus-score-set-expunge-below t]
1531 ["Edit current score file" gnus-score-edit-current-scores t]
1532 ["Edit score file" gnus-score-edit-file t]
1533 ["Trace score" gnus-score-find-trace t]
1534 ["Find words" gnus-score-find-favourite-words t]
1535 ["Rescore buffer" gnus-summary-rescore t]
1536 ["Increase score..." gnus-summary-increase-score t]
1537 ["Lower score..." gnus-summary-lower-score t]))))
1540 ["Ask" (gnus-score-set-default 'gnus-score-default-header nil)
1542 :selected (null gnus-score-default-header)]
1543 ["From" (gnus-score-set-default 'gnus-score-default-header 'a)
1545 :selected (eq gnus-score-default-header 'a)]
1546 ["Subject" (gnus-score-set-default 'gnus-score-default-header 's)
1548 :selected (eq gnus-score-default-header 's)]
1550 (gnus-score-set-default 'gnus-score-default-header 'b)
1552 :selected (eq gnus-score-default-header 'b )]
1554 (gnus-score-set-default 'gnus-score-default-header 'h)
1556 :selected (eq gnus-score-default-header 'h )]
1557 ["Message-ID" (gnus-score-set-default 'gnus-score-default-header 'i)
1559 :selected (eq gnus-score-default-header 'i )]
1560 ["Thread" (gnus-score-set-default 'gnus-score-default-header 't)
1562 :selected (eq gnus-score-default-header 't )]
1564 (gnus-score-set-default 'gnus-score-default-header 'x)
1566 :selected (eq gnus-score-default-header 'x )]
1567 ["Lines" (gnus-score-set-default 'gnus-score-default-header 'l)
1569 :selected (eq gnus-score-default-header 'l )]
1570 ["Date" (gnus-score-set-default 'gnus-score-default-header 'd)
1572 :selected (eq gnus-score-default-header 'd )]
1573 ["Followups to author"
1574 (gnus-score-set-default 'gnus-score-default-header 'f)
1576 :selected (eq gnus-score-default-header 'f )])
1578 ["Ask" (gnus-score-set-default 'gnus-score-default-type nil)
1580 :selected (null gnus-score-default-type)]
1581 ;; The `:active' key is commented out in the following,
1582 ;; because the GNU Emacs hack to support radio buttons use
1583 ;; active to indicate which button is selected.
1584 ["Substring" (gnus-score-set-default 'gnus-score-default-type 's)
1586 ;; :active (not (memq gnus-score-default-header '(l d)))
1587 :selected (eq gnus-score-default-type 's)]
1588 ["Regexp" (gnus-score-set-default 'gnus-score-default-type 'r)
1590 ;; :active (not (memq gnus-score-default-header '(l d)))
1591 :selected (eq gnus-score-default-type 'r)]
1592 ["Exact" (gnus-score-set-default 'gnus-score-default-type 'e)
1594 ;; :active (not (memq gnus-score-default-header '(l d)))
1595 :selected (eq gnus-score-default-type 'e)]
1596 ["Fuzzy" (gnus-score-set-default 'gnus-score-default-type 'f)
1598 ;; :active (not (memq gnus-score-default-header '(l d)))
1599 :selected (eq gnus-score-default-type 'f)]
1600 ["Before date" (gnus-score-set-default 'gnus-score-default-type 'b)
1602 ;; :active (eq (gnus-score-default-header 'd))
1603 :selected (eq gnus-score-default-type 'b)]
1604 ["At date" (gnus-score-set-default 'gnus-score-default-type 'n)
1606 ;; :active (eq (gnus-score-default-header 'd))
1607 :selected (eq gnus-score-default-type 'n)]
1608 ["After date" (gnus-score-set-default 'gnus-score-default-type 'a)
1610 ;; :active (eq (gnus-score-default-header 'd))
1611 :selected (eq gnus-score-default-type 'a)]
1613 (gnus-score-set-default 'gnus-score-default-type '<)
1615 ;; :active (eq (gnus-score-default-header 'l))
1616 :selected (eq gnus-score-default-type '<)]
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 ["Greater than number"
1623 (gnus-score-set-default 'gnus-score-default-type '>)
1625 ;; :active (eq (gnus-score-default-header 'l))
1626 :selected (eq gnus-score-default-type '>)])
1627 ["Default fold" gnus-score-default-fold-toggle
1629 :selected gnus-score-default-fold]
1631 ["Ask" (gnus-score-set-default 'gnus-score-default-duration nil)
1633 :selected (null gnus-score-default-duration)]
1635 (gnus-score-set-default 'gnus-score-default-duration 'p)
1637 :selected (eq gnus-score-default-duration 'p)]
1639 (gnus-score-set-default 'gnus-score-default-duration 't)
1641 :selected (eq gnus-score-default-duration 't)]
1643 (gnus-score-set-default 'gnus-score-default-duration 'i)
1645 :selected (eq gnus-score-default-duration 'i)]))
1648 gnus-summary-article-menu gnus-summary-mode-map ""
1651 ["All" gnus-article-hide t]
1652 ["Headers" gnus-article-hide-headers t]
1653 ["Signature" gnus-article-hide-signature t]
1654 ["Citation" gnus-article-hide-citation t]
1655 ["PGP" gnus-article-hide-pgp t]
1656 ["Boring headers" gnus-article-hide-boring-headers t])
1658 ["All" gnus-article-highlight t]
1659 ["Headers" gnus-article-highlight-headers t]
1660 ["Signature" gnus-article-highlight-signature t]
1661 ["Citation" gnus-article-highlight-citation t])
1663 ["Local" gnus-article-date-local t]
1664 ["UT" gnus-article-date-ut t]
1665 ["Original" gnus-article-date-original t]
1666 ["Lapsed" gnus-article-date-lapsed t])
1669 ["Leading" gnus-article-strip-leading-blank-lines t]
1670 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1671 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1672 ["All of the above" gnus-article-strip-blank-lines t])
1673 ["Overstrike" gnus-article-treat-overstrike t]
1674 ["Emphasis" gnus-article-emphasize t]
1675 ["Word wrap" gnus-article-fill-cited-article t]
1676 ["CR" gnus-article-remove-cr t]
1677 ["Show X-Face" gnus-article-display-x-face t]
1678 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1679 ["Rot 13" gnus-summary-caesar-message t]
1680 ["Add buttons" gnus-article-add-buttons t]
1681 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1682 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1683 ["Toggle MIME" gnus-summary-toggle-mime t]
1684 ["Verbose header" gnus-summary-verbose-headers t]
1685 ["Toggle header" gnus-summary-toggle-header t])
1687 ["Save in default format" gnus-summary-save-article t]
1688 ["Save in file" gnus-summary-save-article-file t]
1689 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1690 ["Write to file" gnus-summary-write-article-mail t]
1691 ["Save in MH folder" gnus-summary-save-article-folder t]
1692 ["Save in VM folder" gnus-summary-save-article-vm t]
1693 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1694 ["Save body in file" gnus-summary-save-article-body-file t]
1695 ["Pipe through a filter" gnus-summary-pipe-output t]
1696 ["Add to SOUP packet" gnus-soup-add-article t])
1698 ["Respool article..." gnus-summary-respool-article t]
1699 ["Move article..." gnus-summary-move-article
1700 (gnus-check-backend-function
1701 'request-move-article gnus-newsgroup-name)]
1702 ["Copy article..." gnus-summary-copy-article t]
1703 ["Crosspost article..." gnus-summary-crosspost-article
1704 (gnus-check-backend-function
1705 'request-replace-article gnus-newsgroup-name)]
1706 ["Import file..." gnus-summary-import-article t]
1707 ["Check if posted" gnus-summary-article-posted-p t]
1708 ["Edit article" gnus-summary-edit-article
1709 (not (gnus-group-read-only-p))]
1710 ["Delete article" gnus-summary-delete-article
1711 (gnus-check-backend-function
1712 'request-expire-articles gnus-newsgroup-name)]
1713 ["Query respool" gnus-summary-respool-query t]
1714 ["Delete expirable articles" gnus-summary-expire-articles-now
1715 (gnus-check-backend-function
1716 'request-expire-articles gnus-newsgroup-name)])
1718 ["Uudecode" gnus-uu-decode-uu t]
1719 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1720 ["Unshar" gnus-uu-decode-unshar t]
1721 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1722 ["Save" gnus-uu-decode-save t]
1723 ["Binhex" gnus-uu-decode-binhex t]
1724 ["Postscript" gnus-uu-decode-postscript t])
1725 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1726 ["Isearch article..." gnus-summary-isearch-article t]
1727 ["Search articles forward..." gnus-summary-search-article-forward t]
1728 ["Search articles backward..." gnus-summary-search-article-backward t]
1729 ["Beginning of the article" gnus-summary-beginning-of-article t]
1730 ["End of the article" gnus-summary-end-of-article t]
1731 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1732 ["Fetch referenced articles" gnus-summary-refer-references t]
1733 ["Fetch article with id..." gnus-summary-refer-article t]
1734 ["Redisplay" gnus-summary-show-article t]))
1737 gnus-summary-thread-menu gnus-summary-mode-map ""
1739 ["Toggle threading" gnus-summary-toggle-threads t]
1740 ["Hide threads" gnus-summary-hide-all-threads t]
1741 ["Show threads" gnus-summary-show-all-threads t]
1742 ["Hide thread" gnus-summary-hide-thread t]
1743 ["Show thread" gnus-summary-show-thread t]
1744 ["Go to next thread" gnus-summary-next-thread t]
1745 ["Go to previous thread" gnus-summary-prev-thread t]
1746 ["Go down thread" gnus-summary-down-thread t]
1747 ["Go up thread" gnus-summary-up-thread t]
1748 ["Top of thread" gnus-summary-top-thread t]
1749 ["Mark thread as read" gnus-summary-kill-thread t]
1750 ["Lower thread score" gnus-summary-lower-thread t]
1751 ["Raise thread score" gnus-summary-raise-thread t]
1752 ["Rethread current" gnus-summary-rethread-current t]
1756 gnus-summary-post-menu gnus-summary-mode-map ""
1758 ["Post an article" gnus-summary-post-news t]
1759 ["Followup" gnus-summary-followup t]
1760 ["Followup and yank" gnus-summary-followup-with-original t]
1761 ["Supersede article" gnus-summary-supersede-article t]
1762 ["Cancel article" gnus-summary-cancel-article t]
1763 ["Reply" gnus-summary-reply t]
1764 ["Reply and yank" gnus-summary-reply-with-original t]
1765 ["Mail forward" gnus-summary-mail-forward t]
1766 ["Post forward" gnus-summary-post-forward t]
1767 ["Digest and mail" gnus-uu-digest-mail-forward t]
1768 ["Digest and post" gnus-uu-digest-post-forward t]
1769 ["Resend message" gnus-summary-resend-message t]
1770 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1771 ["Send a mail" gnus-summary-mail-other-window t]
1772 ["Uuencode and post" gnus-uu-post-news t]
1773 ["Followup via news" gnus-summary-followup-to-mail t]
1774 ["Followup via news and yank"
1775 gnus-summary-followup-to-mail-with-original t]
1777 ;;["Send" gnus-summary-send-draft t]
1778 ;;["Send bounced" gnus-resend-bounced-mail t])
1782 gnus-summary-misc-menu gnus-summary-mode-map ""
1786 ["Mark as read" gnus-summary-mark-as-read-forward t]
1787 ["Mark same subject and select"
1788 gnus-summary-kill-same-subject-and-select t]
1789 ["Mark same subject" gnus-summary-kill-same-subject t]
1790 ["Catchup" gnus-summary-catchup t]
1791 ["Catchup all" gnus-summary-catchup-all t]
1792 ["Catchup to here" gnus-summary-catchup-to-here t]
1793 ["Catchup region" gnus-summary-mark-region-as-read t]
1794 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1796 ["Tick" gnus-summary-tick-article-forward t]
1797 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1798 ["Remove marks" gnus-summary-clear-mark-forward t]
1799 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1800 ["Set bookmark" gnus-summary-set-bookmark t]
1801 ["Remove bookmark" gnus-summary-remove-bookmark t])
1803 ["Marks..." gnus-summary-limit-to-marks t]
1804 ["Subject..." gnus-summary-limit-to-subject t]
1805 ["Author..." gnus-summary-limit-to-author t]
1806 ["Score" gnus-summary-limit-to-score t]
1807 ["Unread" gnus-summary-limit-to-unread t]
1808 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1809 ["Articles" gnus-summary-limit-to-articles t]
1810 ["Pop limit" gnus-summary-pop-limit t]
1811 ["Show dormant" gnus-summary-limit-include-dormant t]
1812 ["Hide childless dormant"
1813 gnus-summary-limit-exclude-childless-dormant t]
1814 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1815 ["Show expunged" gnus-summary-show-all-expunged t])
1817 ["Set mark" gnus-summary-mark-as-processable t]
1818 ["Remove mark" gnus-summary-unmark-as-processable t]
1819 ["Remove all marks" gnus-summary-unmark-all-processable t]
1820 ["Mark above" gnus-uu-mark-over t]
1821 ["Mark series" gnus-uu-mark-series t]
1822 ["Mark region" gnus-uu-mark-region t]
1823 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1824 ["Mark all" gnus-uu-mark-all t]
1825 ["Mark buffer" gnus-uu-mark-buffer t]
1826 ["Mark sparse" gnus-uu-mark-sparse t]
1827 ["Mark thread" gnus-uu-mark-thread t]
1828 ["Unmark thread" gnus-uu-unmark-thread t]
1829 ("Process Mark Sets"
1830 ["Kill" gnus-summary-kill-process-mark t]
1831 ["Yank" gnus-summary-yank-process-mark
1832 gnus-newsgroup-process-stack]
1833 ["Save" gnus-summary-save-process-mark t])))
1835 ["Page forward" gnus-summary-next-page t]
1836 ["Page backward" gnus-summary-prev-page t]
1837 ["Line forward" gnus-summary-scroll-up t])
1839 ["Next unread article" gnus-summary-next-unread-article t]
1840 ["Previous unread article" gnus-summary-prev-unread-article t]
1841 ["Next article" gnus-summary-next-article t]
1842 ["Previous article" gnus-summary-prev-article t]
1843 ["Next unread subject" gnus-summary-next-unread-subject t]
1844 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1845 ["Next article same subject" gnus-summary-next-same-subject t]
1846 ["Previous article same subject" gnus-summary-prev-same-subject t]
1847 ["First unread article" gnus-summary-first-unread-article t]
1848 ["Best unread article" gnus-summary-best-unread-article t]
1849 ["Go to subject number..." gnus-summary-goto-subject t]
1850 ["Go to article number..." gnus-summary-goto-article t]
1851 ["Go to the last article" gnus-summary-goto-last-article t]
1852 ["Pop article off history" gnus-summary-pop-article t])
1854 ["Sort by number" gnus-summary-sort-by-number t]
1855 ["Sort by author" gnus-summary-sort-by-author t]
1856 ["Sort by subject" gnus-summary-sort-by-subject t]
1857 ["Sort by date" gnus-summary-sort-by-date t]
1858 ["Sort by score" gnus-summary-sort-by-score t])
1860 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1861 ["Describe group" gnus-summary-describe-group t]
1862 ["Read manual" gnus-info-find-node t])
1864 ["Enter article" gnus-cache-enter-article t]
1865 ["Remove article" gnus-cache-remove-article t])
1867 ["Pick and read" gnus-pick-mode t]
1868 ["Binary" gnus-binary-mode t])
1869 ["Filter articles..." gnus-summary-execute-command t]
1870 ["Run command on subjects..." gnus-summary-universal-argument t]
1871 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1872 ["Expand window" gnus-summary-expand-window t]
1873 ["Expire expirable articles" gnus-summary-expire-articles
1874 (gnus-check-backend-function
1875 'request-expire-articles gnus-newsgroup-name)]
1876 ["Regenerate buffer" gnus-summary-prepare t]
1877 ["Edit local kill file" gnus-summary-edit-local-kill t]
1878 ["Edit main kill file" gnus-summary-edit-global-kill t]
1880 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1881 ["Catchup all and exit" gnus-summary-catchup-and-exit t]
1882 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1883 ["Exit group" gnus-summary-exit t]
1884 ["Exit group without updating" gnus-summary-exit-no-update t]
1885 ["Exit and goto next group" gnus-summary-next-group t]
1886 ["Exit and goto prev group" gnus-summary-prev-group t]
1887 ["Reselect group" gnus-summary-reselect-current-group t]
1888 ["Rescan group" gnus-summary-rescan-group t])))
1890 (run-hooks 'gnus-summary-menu-hook)))
1892 (defun gnus-score-set-default (var value)
1893 "A version of set that updates the GNU Emacs menu-bar."
1895 ;; It is the message that forces the active status to be updated.
1898 (defun gnus-make-score-map (type)
1899 "Make a summary score map of type TYPE."
1902 (let ((headers '(("author" "from" string)
1903 ("subject" "subject" string)
1904 ("article body" "body" string)
1905 ("article head" "head" string)
1906 ("xref" "xref" string)
1907 ("lines" "lines" number)
1908 ("followups to author" "followup" string)))
1909 (types '((number ("less than" <)
1912 (string ("substring" s)
1916 (perms '(("temporary" (current-time-string))
1924 (if (eq type 'lower)
1929 (setq header (car headers))
1935 (let ((ts (cdr (assoc (nth 2 header) types)))
1951 'gnus-summary-score-entry
1953 (if (or (string= (nth 1 header)
1955 (string= (nth 1 header)
1958 (list 'gnus-summary-header
1960 (list 'quote (nth 1 (car ts)))
1961 (list 'gnus-score-default nil)
1967 (list (nreverse outp))))
1970 (list (nreverse outt))))
1972 (setq headers (cdr headers)))
1973 (list (nreverse outh))))))))
1977 (defun gnus-summary-mode (&optional group)
1978 "Major mode for reading articles.
1980 All normal editing commands are switched off.
1981 \\<gnus-summary-mode-map>
1982 Each line in this buffer represents one article. To read an
1983 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
1984 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
1987 You can also post articles and send mail from this buffer. To
1988 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
1989 of an article, type `\\[gnus-summary-reply]'.
1991 There are approx. one gazillion commands you can execute in this
1992 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
1994 The following commands are available:
1996 \\{gnus-summary-mode-map}"
1998 (when (and menu-bar-mode
1999 (gnus-visual-p 'summary-menu 'menu))
2000 (gnus-summary-make-menu-bar))
2001 (kill-all-local-variables)
2002 (gnus-summary-make-local-variables)
2003 (gnus-make-thread-indent-array)
2004 (gnus-simplify-mode-line)
2005 (setq major-mode 'gnus-summary-mode)
2006 (setq mode-name "Summary")
2007 (make-local-variable 'minor-mode-alist)
2008 (use-local-map gnus-summary-mode-map)
2009 (buffer-disable-undo (current-buffer))
2010 (setq buffer-read-only t) ;Disable modification
2011 (setq truncate-lines t)
2012 (setq selective-display t)
2013 (setq selective-display-ellipses t) ;Display `...'
2014 (setq buffer-display-table gnus-summary-display-table)
2015 (gnus-set-default-directory)
2016 (setq gnus-newsgroup-name group)
2017 (make-local-variable 'gnus-summary-line-format)
2018 (make-local-variable 'gnus-summary-line-format-spec)
2019 (make-local-variable 'gnus-summary-mark-positions)
2020 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2021 (gnus-update-summary-mark-positions)
2022 (gnus-make-local-hook 'post-command-hook)
2023 (gnus-add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
2024 (run-hooks 'gnus-summary-mode-hook))
2026 (defun gnus-summary-make-local-variables ()
2027 "Make all the local summary buffer variables."
2028 (let ((locals gnus-summary-local-variables)
2030 (while (setq local (pop locals))
2033 (if (eq (cdr local) 'global)
2034 ;; Copy the global value of the variable.
2035 (setq global (symbol-value (car local)))
2036 ;; Use the value from the list.
2037 (setq global (eval (cdr local))))
2038 (make-local-variable (car local))
2039 (set (car local) global))
2040 ;; Simple nil-valued local variable.
2041 (make-local-variable local)
2044 (defun gnus-summary-clear-local-variables ()
2045 (let ((locals gnus-summary-local-variables))
2047 (if (consp (car locals))
2048 (and (vectorp (caar locals))
2049 (set (caar locals) nil))
2050 (and (vectorp (car locals))
2051 (set (car locals) nil)))
2052 (setq locals (cdr locals)))))
2054 ;; Summary data functions.
2056 (defmacro gnus-data-number (data)
2059 (defmacro gnus-data-set-number (data number)
2060 `(setcar ,data ,number))
2062 (defmacro gnus-data-mark (data)
2065 (defmacro gnus-data-set-mark (data mark)
2066 `(setcar (nthcdr 1 ,data) ,mark))
2068 (defmacro gnus-data-pos (data)
2071 (defmacro gnus-data-set-pos (data pos)
2072 `(setcar (nthcdr 2 ,data) ,pos))
2074 (defmacro gnus-data-header (data)
2077 (defmacro gnus-data-level (data)
2080 (defmacro gnus-data-unread-p (data)
2081 `(= (nth 1 ,data) gnus-unread-mark))
2083 (defmacro gnus-data-read-p (data)
2084 `(/= (nth 1 ,data) gnus-unread-mark))
2086 (defmacro gnus-data-pseudo-p (data)
2087 `(consp (nth 3 ,data)))
2089 (defmacro gnus-data-find (number)
2090 `(assq ,number gnus-newsgroup-data))
2092 (defmacro gnus-data-find-list (number &optional data)
2093 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2094 (memq (assq ,number bdata)
2097 (defmacro gnus-data-make (number mark pos header level)
2098 `(list ,number ,mark ,pos ,header ,level))
2100 (defun gnus-data-enter (after-article number mark pos header level offset)
2101 (let ((data (gnus-data-find-list after-article)))
2103 (error "No such article: %d" after-article))
2104 (setcdr data (cons (gnus-data-make number mark pos header level)
2106 (setq gnus-newsgroup-data-reverse nil)
2107 (gnus-data-update-list (cddr data) offset)))
2109 (defun gnus-data-enter-list (after-article list &optional offset)
2111 (let ((data (and after-article (gnus-data-find-list after-article)))
2113 (or data (not after-article) (error "No such article: %d" after-article))
2114 ;; Find the last element in the list to be spliced into the main
2117 (setq list (cdr list)))
2120 (setcdr list gnus-newsgroup-data)
2121 (setq gnus-newsgroup-data ilist)
2123 (gnus-data-update-list (cdr list) offset)))
2124 (setcdr list (cdr data))
2127 (gnus-data-update-list (cdr data) offset)))
2128 (setq gnus-newsgroup-data-reverse nil))))
2130 (defun gnus-data-remove (article &optional offset)
2131 (let ((data gnus-newsgroup-data))
2132 (if (= (gnus-data-number (car data)) article)
2133 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2134 gnus-newsgroup-data-reverse nil)
2136 (when (= (gnus-data-number (cadr data)) article)
2137 (setcdr data (cddr data))
2139 (gnus-data-update-list (cdr data) offset))
2141 gnus-newsgroup-data-reverse nil))
2142 (setq data (cdr data))))))
2144 (defmacro gnus-data-list (backward)
2146 (or gnus-newsgroup-data-reverse
2147 (setq gnus-newsgroup-data-reverse
2148 (reverse gnus-newsgroup-data)))
2149 gnus-newsgroup-data))
2151 (defun gnus-data-update-list (data offset)
2152 "Add OFFSET to the POS of all data entries in DATA."
2154 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2155 (setq data (cdr data))))
2157 (defun gnus-data-compute-positions ()
2158 "Compute the positions of all articles."
2159 (let ((data gnus-newsgroup-data)
2162 (when (setq pos (text-property-any
2163 (point-min) (point-max)
2164 'gnus-number (gnus-data-number (car data))))
2165 (gnus-data-set-pos (car data) (+ pos 3)))
2166 (setq data (cdr data)))))
2168 (defun gnus-summary-article-pseudo-p (article)
2169 "Say whether this article is a pseudo article or not."
2170 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2172 (defun gnus-article-parent-p (number)
2173 "Say whether this article is a parent or not."
2174 (let ((data (gnus-data-find-list number)))
2175 (and (cdr data) ; There has to be an article after...
2176 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2177 (gnus-data-level (nth 1 data))))))
2179 (defun gnus-article-children (number)
2180 "Return a list of all children to NUMBER."
2181 (let* ((data (gnus-data-find-list number))
2182 (level (gnus-data-level (car data)))
2184 (setq data (cdr data))
2186 (= (gnus-data-level (car data)) (1+ level)))
2187 (push (gnus-data-number (car data)) children)
2188 (setq data (cdr data)))
2191 (defmacro gnus-summary-skip-intangible ()
2192 "If the current article is intangible, then jump to a different article."
2193 '(let ((to (get-text-property (point) 'gnus-intangible)))
2194 (and to (gnus-summary-goto-subject to))))
2196 (defmacro gnus-summary-article-intangible-p ()
2197 "Say whether this article is intangible or not."
2198 '(get-text-property (point) 'gnus-intangible))
2200 (defun gnus-article-read-p (article)
2201 "Say whether ARTICLE is read or not."
2202 (not (or (memq article gnus-newsgroup-marked)
2203 (memq article gnus-newsgroup-unreads)
2204 (memq article gnus-newsgroup-unselected)
2205 (memq article gnus-newsgroup-dormant))))
2207 ;; Some summary mode macros.
2209 (defmacro gnus-summary-article-number ()
2210 "The article number of the article on the current line.
2211 If there isn's an article number here, then we return the current
2214 (gnus-summary-skip-intangible)
2215 (or (get-text-property (point) 'gnus-number)
2216 (gnus-summary-last-subject))))
2218 (defmacro gnus-summary-article-header (&optional number)
2219 `(gnus-data-header (gnus-data-find
2220 ,(or number '(gnus-summary-article-number)))))
2222 (defmacro gnus-summary-thread-level (&optional number)
2223 `(if (and (eq gnus-summary-make-false-root 'dummy)
2224 (get-text-property (point) 'gnus-intangible))
2226 (gnus-data-level (gnus-data-find
2227 ,(or number '(gnus-summary-article-number))))))
2229 (defmacro gnus-summary-article-mark (&optional number)
2230 `(gnus-data-mark (gnus-data-find
2231 ,(or number '(gnus-summary-article-number)))))
2233 (defmacro gnus-summary-article-pos (&optional number)
2234 `(gnus-data-pos (gnus-data-find
2235 ,(or number '(gnus-summary-article-number)))))
2237 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2238 (defmacro gnus-summary-article-subject (&optional number)
2239 "Return current subject string or nil if nothing."
2242 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2243 '(gnus-data-header (assq (gnus-summary-article-number)
2244 gnus-newsgroup-data)))))
2247 (mail-header-subject headers))))
2249 (defmacro gnus-summary-article-score (&optional number)
2250 "Return current article score."
2251 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2252 gnus-newsgroup-scored))
2253 gnus-summary-default-score 0))
2255 (defun gnus-summary-article-children (&optional number)
2256 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2257 (level (gnus-data-level (car data)))
2259 (while (and (setq data (cdr data))
2260 (> (setq l (gnus-data-level (car data))) level))
2261 (and (= (1+ level) l)
2262 (push (gnus-data-number (car data))
2264 (nreverse children)))
2266 (defun gnus-summary-article-parent (&optional number)
2267 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2268 (gnus-data-list t)))
2269 (level (gnus-data-level (car data))))
2271 () ; This is a root.
2272 ;; We search until we find an article with a level less than
2273 ;; this one. That function has to be the parent.
2274 (while (and (setq data (cdr data))
2275 (not (< (gnus-data-level (car data)) level))))
2276 (and data (gnus-data-number (car data))))))
2278 (defun gnus-unread-mark-p (mark)
2279 "Say whether MARK is the unread mark."
2280 (= mark gnus-unread-mark))
2282 (defun gnus-read-mark-p (mark)
2283 "Say whether MARK is one of the marks that mark as read.
2284 This is all marks except unread, ticked, dormant, and expirable."
2285 (not (or (= mark gnus-unread-mark)
2286 (= mark gnus-ticked-mark)
2287 (= mark gnus-dormant-mark)
2288 (= mark gnus-expirable-mark))))
2290 (defmacro gnus-article-mark (number)
2292 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2293 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2294 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2295 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2296 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2297 gnus-ancient-mark))))
2299 ;; Saving hidden threads.
2301 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2302 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2304 (defmacro gnus-save-hidden-threads (&rest forms)
2305 "Save hidden threads, eval FORMS, and restore the hidden threads."
2306 (let ((config (make-symbol "config")))
2307 `(let ((,config (gnus-hidden-threads-configuration)))
2311 (gnus-restore-hidden-threads-configuration ,config)))))
2313 (defun gnus-hidden-threads-configuration ()
2314 "Return the current hidden threads configuration."
2317 (goto-char (point-min))
2318 (while (search-forward "\r" nil t)
2319 (push (1- (point)) config))
2322 (defun gnus-restore-hidden-threads-configuration (config)
2323 "Restore hidden threads configuration from CONFIG."
2324 (let (point buffer-read-only)
2325 (while (setq point (pop config))
2326 (when (and (< point (point-max))
2328 (= (following-char) ?\n))
2329 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2331 ;; Various summary mode internalish functions.
2333 (defun gnus-mouse-pick-article (e)
2336 (gnus-summary-next-page nil t))
2338 (defun gnus-summary-setup-buffer (group)
2339 "Initialize summary buffer."
2340 (let ((buffer (concat "*Summary " group "*")))
2341 (if (get-buffer buffer)
2344 (setq gnus-summary-buffer (current-buffer))
2345 (not gnus-newsgroup-prepared))
2346 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2347 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
2348 (gnus-add-current-to-buffer-list)
2349 (gnus-summary-mode group)
2351 (gnus-carpal-setup-buffer 'summary))
2352 (unless gnus-single-article-buffer
2353 (make-local-variable 'gnus-article-buffer)
2354 (make-local-variable 'gnus-article-current)
2355 (make-local-variable 'gnus-original-article-buffer))
2356 (setq gnus-newsgroup-name group)
2359 (defun gnus-set-global-variables ()
2360 ;; Set the global equivalents of the summary buffer-local variables
2361 ;; to the latest values they had. These reflect the summary buffer
2362 ;; that was in action when the last article was fetched.
2363 (when (eq major-mode 'gnus-summary-mode)
2364 (setq gnus-summary-buffer (current-buffer))
2365 (let ((name gnus-newsgroup-name)
2366 (marked gnus-newsgroup-marked)
2367 (unread gnus-newsgroup-unreads)
2368 (headers gnus-current-headers)
2369 (data gnus-newsgroup-data)
2370 (summary gnus-summary-buffer)
2371 (article-buffer gnus-article-buffer)
2372 (original gnus-original-article-buffer)
2373 (gac gnus-article-current)
2374 (reffed gnus-reffed-article-number)
2375 (score-file gnus-current-score-file))
2377 (set-buffer gnus-group-buffer)
2378 (setq gnus-newsgroup-name name)
2379 (setq gnus-newsgroup-marked marked)
2380 (setq gnus-newsgroup-unreads unread)
2381 (setq gnus-current-headers headers)
2382 (setq gnus-newsgroup-data data)
2383 (setq gnus-article-current gac)
2384 (setq gnus-summary-buffer summary)
2385 (setq gnus-article-buffer article-buffer)
2386 (setq gnus-original-article-buffer original)
2387 (setq gnus-reffed-article-number reffed)
2388 (setq gnus-current-score-file score-file)
2389 ;; The article buffer also has local variables.
2390 (when (gnus-buffer-live-p gnus-article-buffer)
2391 (set-buffer gnus-article-buffer)
2392 (setq gnus-summary-buffer summary))))))
2394 (defun gnus-summary-first-article-p (&optional article)
2395 "Return whether ARTICLE is the first article in the buffer."
2396 (if (not (setq article (or article (gnus-summary-article-number))))
2398 (eq article (caar gnus-newsgroup-data))))
2400 (defun gnus-summary-last-article-p (&optional article)
2401 "Return whether ARTICLE is the last article in the buffer."
2402 (if (not (setq article (or article (gnus-summary-article-number))))
2403 t ; All non-existent numbers are the last article. :-)
2404 (not (cdr (gnus-data-find-list article)))))
2406 (defun gnus-make-thread-indent-array ()
2408 (unless (and gnus-thread-indent-array
2409 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2410 (setq gnus-thread-indent-array (make-vector 201 "")
2411 gnus-thread-indent-array-level gnus-thread-indent-level)
2413 (aset gnus-thread-indent-array n
2414 (make-string (* n gnus-thread-indent-level) ? ))
2417 (defun gnus-update-summary-mark-positions ()
2418 "Compute where the summary marks are to go."
2420 (when (and gnus-summary-buffer
2421 (get-buffer gnus-summary-buffer)
2422 (buffer-name (get-buffer gnus-summary-buffer)))
2423 (set-buffer gnus-summary-buffer))
2424 (let ((gnus-replied-mark 129)
2425 (gnus-score-below-mark 130)
2426 (gnus-score-over-mark 130)
2429 (spec gnus-summary-line-format-spec)
2432 (gnus-set-work-buffer)
2433 (let ((gnus-summary-line-format-spec spec))
2434 (gnus-summary-insert-line
2435 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2436 (goto-char (point-min))
2437 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2439 (goto-char (point-min))
2440 (push (cons 'replied (and (search-forward "\201" nil t)
2443 (goto-char (point-min))
2444 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2446 (setq gnus-summary-mark-positions pos))))
2448 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2449 "Insert a dummy root in the summary buffer."
2451 (gnus-add-text-properties
2452 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2453 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2455 (defun gnus-summary-insert-line (gnus-tmp-header
2456 gnus-tmp-level gnus-tmp-current
2457 gnus-tmp-unread gnus-tmp-replied
2458 gnus-tmp-expirable gnus-tmp-subject-or-nil
2459 &optional gnus-tmp-dummy gnus-tmp-score
2461 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2462 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2463 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2464 (gnus-tmp-score-char
2465 (if (or (null gnus-summary-default-score)
2466 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2467 gnus-summary-zcore-fuzz))
2469 (if (< gnus-tmp-score gnus-summary-default-score)
2470 gnus-score-below-mark gnus-score-over-mark)))
2472 (cond (gnus-tmp-process gnus-process-mark)
2473 ((memq gnus-tmp-current gnus-newsgroup-cached)
2475 (gnus-tmp-replied gnus-replied-mark)
2476 ((memq gnus-tmp-current gnus-newsgroup-saved)
2478 (t gnus-unread-mark)))
2479 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2482 ((string-match "(.+)" gnus-tmp-from)
2483 (substring gnus-tmp-from
2484 (1+ (match-beginning 0)) (1- (match-end 0))))
2485 ((string-match "<[^>]+> *$" gnus-tmp-from)
2486 (let ((beg (match-beginning 0)))
2487 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2488 (substring gnus-tmp-from (1+ (match-beginning 0))
2489 (1- (match-end 0))))
2490 (substring gnus-tmp-from 0 beg))))
2492 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2493 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2494 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2495 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2496 (buffer-read-only nil))
2497 (when (string= gnus-tmp-name "")
2498 (setq gnus-tmp-name gnus-tmp-from))
2499 (unless (numberp gnus-tmp-lines)
2500 (setq gnus-tmp-lines 0))
2501 (gnus-put-text-property
2503 (progn (eval gnus-summary-line-format-spec) (point))
2504 'gnus-number gnus-tmp-number)
2505 (when (gnus-visual-p 'summary-highlight 'highlight)
2507 (run-hooks 'gnus-summary-update-hook)
2510 (defun gnus-summary-update-line (&optional dont-update)
2511 ;; Update summary line after change.
2512 (when (and gnus-summary-default-score
2513 (not gnus-summary-inhibit-highlight))
2514 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2515 (article (gnus-summary-article-number))
2516 (score (gnus-summary-article-score article)))
2518 (if (and gnus-summary-mark-below
2519 (< (gnus-summary-article-score)
2520 gnus-summary-mark-below))
2521 ;; This article has a low score, so we mark it as read.
2522 (when (memq article gnus-newsgroup-unreads)
2523 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2524 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2525 ;; This article was previously marked as read on account
2526 ;; of a low score, but now it has risen, so we mark it as
2528 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2529 (gnus-summary-update-mark
2530 (if (or (null gnus-summary-default-score)
2531 (<= (abs (- score gnus-summary-default-score))
2532 gnus-summary-zcore-fuzz))
2534 (if (< score gnus-summary-default-score)
2535 gnus-score-below-mark gnus-score-over-mark))
2537 ;; Do visual highlighting.
2538 (when (gnus-visual-p 'summary-highlight 'highlight)
2539 (run-hooks 'gnus-summary-update-hook)))))
2541 (defvar gnus-tmp-new-adopts nil)
2543 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2544 "Return the number of articles in THREAD.
2545 This may be 0 in some cases -- if none of the articles in
2546 the thread are to be displayed."
2548 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2550 ((not (listp thread))
2552 ((and (consp thread) (cdr thread))
2555 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2558 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2561 (when (and level (zerop level) gnus-tmp-new-adopts)
2564 'gnus-summary-number-of-articles-in-thread
2565 gnus-tmp-new-adopts))))
2567 (if (> number 1) gnus-not-empty-thread-mark
2568 gnus-empty-thread-mark)
2571 (defun gnus-summary-set-local-parameters (group)
2572 "Go through the local params of GROUP and set all variable specs in that list."
2573 (let ((params (gnus-group-find-parameter group))
2576 (setq elem (car params)
2577 params (cdr params))
2578 (and (consp elem) ; Has to be a cons.
2579 (consp (cdr elem)) ; The cdr has to be a list.
2580 (symbolp (car elem)) ; Has to be a symbol in there.
2581 (not (memq (car elem)
2582 '(quit-config to-address to-list to-group)))
2583 (progn ; So we set it.
2584 (make-local-variable (car elem))
2585 (set (car elem) (eval (nth 1 elem))))))))
2587 (defun gnus-summary-read-group (group &optional show-all no-article
2588 kill-buffer no-display)
2589 "Start reading news in newsgroup GROUP.
2590 If SHOW-ALL is non-nil, already read articles are also listed.
2591 If NO-ARTICLE is non-nil, no article is selected initially.
2592 If NO-DISPLAY, don't generate a summary buffer."
2593 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2594 (let* ((new-group (gnus-summary-setup-buffer group))
2595 (quit-config (gnus-group-quit-config group))
2596 (did-select (and new-group (gnus-select-newsgroup group show-all))))
2598 ;; This summary buffer exists already, so we just select it.
2600 (gnus-set-global-variables)
2602 (gnus-kill-or-deaden-summary kill-buffer))
2603 (gnus-configure-windows 'summary 'force)
2604 (gnus-set-mode-line 'summary)
2605 (gnus-summary-position-point)
2608 ;; We couldn't select this group.
2610 (when (and (eq major-mode 'gnus-summary-mode)
2611 (not (equal (current-buffer) kill-buffer)))
2612 (kill-buffer (current-buffer))
2613 (if (not quit-config)
2615 (set-buffer gnus-group-buffer)
2616 (gnus-group-jump-to-group group)
2617 (gnus-group-next-unread-group 1))
2618 (gnus-handle-ephemeral-exit quit-config)))
2619 (gnus-message 3 "Can't select group")
2621 ;; The user did a `C-g' while prompting for number of articles,
2622 ;; so we exit this group.
2623 ((eq did-select 'quit)
2624 (and (eq major-mode 'gnus-summary-mode)
2625 (not (equal (current-buffer) kill-buffer))
2626 (kill-buffer (current-buffer)))
2628 (gnus-kill-or-deaden-summary kill-buffer))
2629 (if (not quit-config)
2631 (set-buffer gnus-group-buffer)
2632 (gnus-group-jump-to-group group)
2633 (gnus-group-next-unread-group 1)
2634 (gnus-configure-windows 'group 'force))
2635 (gnus-handle-ephemeral-exit quit-config))
2636 ;; Finally signal the quit.
2638 ;; The group was successfully selected.
2640 (gnus-set-global-variables)
2641 ;; Save the active value in effect when the group was entered.
2642 (setq gnus-newsgroup-active
2644 (gnus-active gnus-newsgroup-name)))
2645 ;; You can change the summary buffer in some way with this hook.
2646 (run-hooks 'gnus-select-group-hook)
2647 ;; Set any local variables in the group parameters.
2648 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2649 (gnus-update-format-specifications
2650 nil 'summary 'summary-mode 'summary-dummy)
2651 ;; Do score processing.
2652 (when gnus-use-scoring
2653 (gnus-possibly-score-headers))
2654 ;; Check whether to fill in the gaps in the threads.
2655 (when gnus-build-sparse-threads
2656 (gnus-build-sparse-threads))
2657 ;; Find the initial limit.
2658 (if gnus-show-threads
2660 (let ((gnus-newsgroup-dormant nil))
2661 (gnus-summary-initial-limit show-all))
2662 (gnus-summary-initial-limit show-all))
2663 (setq gnus-newsgroup-limit
2665 (lambda (header) (mail-header-number header))
2666 gnus-newsgroup-headers)))
2667 ;; Generate the summary buffer.
2669 (gnus-summary-prepare))
2670 (when gnus-use-trees
2671 (gnus-tree-open group)
2672 (setq gnus-summary-highlight-line-function
2673 'gnus-tree-highlight-article))
2674 ;; If the summary buffer is empty, but there are some low-scored
2675 ;; articles or some excluded dormants, we include these in the
2677 (when (and (zerop (buffer-size))
2679 (cond (gnus-newsgroup-dormant
2680 (gnus-summary-limit-include-dormant))
2681 ((and gnus-newsgroup-scored show-all)
2682 (gnus-summary-limit-include-expunged t))))
2683 ;; Function `gnus-apply-kill-file' must be called in this hook.
2684 (run-hooks 'gnus-apply-kill-hook)
2685 (if (and (zerop (buffer-size))
2688 ;; This newsgroup is empty.
2689 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
2690 (gnus-message 6 "No unread news")
2692 (gnus-kill-or-deaden-summary kill-buffer))
2693 ;; Return nil from this function.
2695 ;; Hide conversation thread subtrees. We cannot do this in
2696 ;; gnus-summary-prepare-hook since kill processing may not
2697 ;; work with hidden articles.
2698 (and gnus-show-threads
2699 gnus-thread-hide-subtree
2700 (gnus-summary-hide-all-threads))
2701 ;; Show first unread article if requested.
2702 (if (and (not no-article)
2704 gnus-newsgroup-unreads
2705 gnus-auto-select-first)
2706 (unless (if (eq gnus-auto-select-first 'best)
2707 (gnus-summary-best-unread-article)
2708 (gnus-summary-first-unread-article))
2709 (gnus-configure-windows 'summary))
2710 ;; Don't select any articles, just move point to the first
2711 ;; article in the group.
2712 (goto-char (point-min))
2713 (gnus-summary-position-point)
2714 (gnus-set-mode-line 'summary)
2715 (gnus-configure-windows 'summary 'force))
2717 (gnus-kill-or-deaden-summary kill-buffer))
2718 (when (get-buffer-window gnus-group-buffer t)
2719 ;; Gotta use windows, because recenter does weird stuff if
2720 ;; the current buffer ain't the displayed window.
2721 (let ((owin (selected-window)))
2722 (select-window (get-buffer-window gnus-group-buffer t))
2723 (when (gnus-group-goto-group group)
2725 (select-window owin))))
2726 ;; Mark this buffer as "prepared".
2727 (setq gnus-newsgroup-prepared t)
2730 (defun gnus-summary-prepare ()
2731 "Generate the summary buffer."
2733 (let ((buffer-read-only nil))
2735 (setq gnus-newsgroup-data nil
2736 gnus-newsgroup-data-reverse nil)
2737 (run-hooks 'gnus-summary-generate-hook)
2738 ;; Generate the buffer, either with threads or without.
2739 (when gnus-newsgroup-headers
2740 (gnus-summary-prepare-threads
2741 (if gnus-show-threads
2742 (gnus-sort-gathered-threads
2743 (funcall gnus-summary-thread-gathering-function
2745 (gnus-cut-threads (gnus-make-threads)))))
2746 ;; Unthreaded display.
2747 (gnus-sort-articles gnus-newsgroup-headers))))
2748 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2749 ;; Call hooks for modifying summary buffer.
2750 (goto-char (point-min))
2751 (run-hooks 'gnus-summary-prepare-hook)))
2753 (defsubst gnus-general-simplify-subject (subject)
2754 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2757 ;; Truncate the subject.
2758 ((numberp gnus-summary-gather-subject-limit)
2759 (setq subject (gnus-simplify-subject-re subject))
2760 (if (> (length subject) gnus-summary-gather-subject-limit)
2761 (substring subject 0 gnus-summary-gather-subject-limit)
2763 ;; Fuzzily simplify it.
2764 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2765 (gnus-simplify-subject-fuzzy subject))
2766 ;; Just remove the leading "Re:".
2768 (gnus-simplify-subject-re subject))))
2770 (if (and gnus-summary-gather-exclude-subject
2771 (string-match gnus-summary-gather-exclude-subject subject))
2772 nil ; This article shouldn't be gathered
2775 (defun gnus-summary-simplify-subject-query ()
2776 "Query where the respool algorithm would put this article."
2778 (gnus-set-global-variables)
2779 (gnus-summary-select-article)
2780 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2782 (defun gnus-gather-threads-by-subject (threads)
2783 "Gather threads by looking at Subject headers."
2784 (if (not gnus-summary-make-false-root)
2786 (let ((hashtb (gnus-make-hashtable 1023))
2789 subject hthread whole-subject)
2791 (setq subject (gnus-general-simplify-subject
2792 (setq whole-subject (mail-header-subject
2795 (if (setq hthread (gnus-gethash subject hashtb))
2797 ;; We enter a dummy root into the thread, if we
2798 ;; haven't done that already.
2799 (unless (stringp (caar hthread))
2800 (setcar hthread (list whole-subject (car hthread))))
2801 ;; We add this new gathered thread to this gathered
2803 (setcdr (car hthread)
2804 (nconc (cdar hthread) (list (car threads))))
2805 ;; Remove it from the list of threads.
2806 (setcdr prev (cdr threads))
2807 (setq threads prev))
2808 ;; Enter this thread into the hash table.
2809 (gnus-sethash subject threads hashtb)))
2811 (setq threads (cdr threads)))
2814 (defun gnus-gather-threads-by-references (threads)
2815 "Gather threads by looking at References headers."
2816 (let ((idhashtb (gnus-make-hashtable 1023))
2817 (thhashtb (gnus-make-hashtable 1023))
2820 ids references id gthread gid entered ref)
2822 (when (setq references (mail-header-references (caar threads)))
2823 (setq id (mail-header-id (caar threads))
2824 ids (gnus-split-references references)
2826 (while (setq ref (pop ids))
2827 (setq ids (delete ref ids))
2828 (if (not (setq gid (gnus-gethash ref idhashtb)))
2830 (gnus-sethash ref id idhashtb)
2831 (gnus-sethash id threads thhashtb))
2832 (setq gthread (gnus-gethash gid thhashtb))
2834 ;; We enter a dummy root into the thread, if we
2835 ;; haven't done that already.
2836 (unless (stringp (caar gthread))
2837 (setcar gthread (list (mail-header-subject (caar gthread))
2839 ;; We add this new gathered thread to this gathered
2841 (setcdr (car gthread)
2842 (nconc (cdar gthread) (list (car threads)))))
2843 ;; Add it into the thread hash table.
2844 (gnus-sethash id gthread thhashtb)
2846 ;; Remove it from the list of threads.
2847 (setcdr prev (cdr threads))
2848 (setq threads prev))))
2850 (setq threads (cdr threads)))
2853 (defun gnus-sort-gathered-threads (threads)
2854 "Sort subtreads inside each gathered thread by article number."
2855 (let ((result threads))
2857 (when (stringp (caar threads))
2858 (setcdr (car threads)
2859 (sort (cdar threads) 'gnus-thread-sort-by-number)))
2860 (setq threads (cdr threads)))
2863 (defun gnus-make-threads ()
2864 "Go through the dependency hashtb and find the roots. Return all threads."
2868 (unless (car (symbol-value refs))
2869 ;; These threads do not refer back to any other articles,
2870 ;; so they're roots.
2871 (setq threads (append (cdr (symbol-value refs)) threads))))
2872 gnus-newsgroup-dependencies)
2875 (defun gnus-build-sparse-threads ()
2876 (let ((headers gnus-newsgroup-headers)
2877 (deps gnus-newsgroup-dependencies)
2878 header references generation relations
2879 cthread subject child end pthread relation)
2880 ;; First we create an alist of generations/relations, where
2881 ;; generations is how much we trust the relation, and the relation
2883 (gnus-message 7 "Making sparse threads...")
2885 (nnheader-set-temp-buffer " *gnus sparse threads*")
2886 (while (setq header (pop headers))
2887 (when (and (setq references (mail-header-references header))
2888 (not (string= references "")))
2890 (setq child (mail-header-id header)
2891 subject (mail-header-subject header))
2893 (while (search-backward ">" nil t)
2894 (setq end (1+ (point)))
2895 (when (search-backward "<" nil t)
2896 (push (list (incf generation)
2897 child (setq child (buffer-substring (point) end))
2900 (push (list (1+ generation) child nil subject) relations)
2902 (kill-buffer (current-buffer)))
2903 ;; Sort over trustworthiness.
2904 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
2905 (while (setq relation (pop relations))
2906 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
2907 (unless (car (symbol-value cthread))
2908 ;; Make this article the parent of these threads.
2909 (setcar (symbol-value cthread)
2910 (vector gnus-reffed-article-number
2914 (or (caddr relation) "") 0 0 "")))
2915 (set cthread (list (vector gnus-reffed-article-number
2917 "" "" (cadr relation)
2918 (or (caddr relation) "") 0 0 ""))))
2919 (push gnus-reffed-article-number gnus-newsgroup-limit)
2920 (push gnus-reffed-article-number gnus-newsgroup-sparse)
2921 (push (cons gnus-reffed-article-number gnus-sparse-mark)
2922 gnus-newsgroup-reads)
2923 (decf gnus-reffed-article-number)
2924 ;; Make this new thread the child of its parent.
2925 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
2926 (setcdr (symbol-value pthread)
2927 (nconc (cdr (symbol-value pthread))
2928 (list (symbol-value cthread))))
2929 (set pthread (list nil (symbol-value cthread))))))
2930 (gnus-message 7 "Making sparse threads...done")))
2932 (defun gnus-build-old-threads ()
2933 ;; Look at all the articles that refer back to old articles, and
2934 ;; fetch the headers for the articles that aren't there. This will
2935 ;; build complete threads - if the roots haven't been expired by the
2940 (when (not (car (symbol-value refs)))
2941 (setq heads (cdr (symbol-value refs)))
2943 (if (memq (mail-header-number (caar heads))
2944 gnus-newsgroup-dormant)
2945 (setq heads (cdr heads))
2946 (setq id (symbol-name refs))
2947 (while (and (setq id (gnus-build-get-header id))
2948 (not (car (gnus-gethash
2949 id gnus-newsgroup-dependencies)))))
2950 (setq heads nil)))))
2951 gnus-newsgroup-dependencies)))
2953 (defun gnus-build-get-header (id)
2954 ;; Look through the buffer of NOV lines and find the header to
2955 ;; ID. Enter this line into the dependencies hash table, and return
2956 ;; the id of the parent article (if any).
2957 (let ((deps gnus-newsgroup-dependencies)
2961 (set-buffer nntp-server-buffer)
2962 (goto-char (point-min))
2963 (while (and (not found) (search-forward id nil t))
2965 (setq found (looking-at
2966 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
2967 (regexp-quote id))))
2968 (or found (beginning-of-line 2)))
2972 (setq header (gnus-nov-parse-line
2973 (read (current-buffer)) deps))
2974 (gnus-parent-id (mail-header-references header)))))
2976 (let ((number (mail-header-number header)))
2977 (push number gnus-newsgroup-limit)
2978 (push header gnus-newsgroup-headers)
2979 (if (memq number gnus-newsgroup-unselected)
2981 (push number gnus-newsgroup-unreads)
2982 (setq gnus-newsgroup-unselected
2983 (delq number gnus-newsgroup-unselected)))
2984 (push number gnus-newsgroup-ancient)))))))
2986 (defun gnus-summary-update-article-line (article header)
2987 "Update the line for ARTICLE using HEADERS."
2988 (let* ((id (mail-header-id header))
2989 (thread (gnus-id-to-thread id)))
2991 (error "Article in no thread"))
2992 ;; Update the thread.
2993 (setcar thread header)
2994 (gnus-summary-goto-subject article)
2995 (let* ((datal (gnus-data-find-list article))
2997 (length (when (cdr datal)
2998 (- (gnus-data-pos data)
2999 (gnus-data-pos (cadr datal)))))
3000 (buffer-read-only nil)
3001 (level (gnus-summary-thread-level)))
3003 (gnus-summary-insert-line
3004 header level nil (gnus-article-mark article)
3005 (memq article gnus-newsgroup-replied)
3006 (memq article gnus-newsgroup-expirable)
3007 (mail-header-subject header)
3008 nil (cdr (assq article gnus-newsgroup-scored))
3009 (memq article gnus-newsgroup-processable))
3011 (gnus-data-update-list
3012 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3014 (defun gnus-summary-update-article (article &optional iheader)
3015 "Update ARTICLE in the summary buffer."
3016 (set-buffer gnus-summary-buffer)
3017 (let* ((header (or iheader (gnus-summary-article-header article)))
3018 (id (mail-header-id header))
3019 (data (gnus-data-find article))
3020 (thread (gnus-id-to-thread id))
3021 (references (mail-header-references header))
3025 (when (and references
3026 (not (equal "" references)))
3029 (buffer-read-only nil)
3031 (number (mail-header-number header))
3034 ;; !!! Should this be in or not?
3036 (setcar thread nil))
3038 (delq thread parent))
3039 (if (gnus-summary-insert-subject id header iheader)
3040 ;; Set the (possibly) new article number in the data structure.
3041 (gnus-data-set-number data (gnus-id-to-article id))
3045 (defun gnus-rebuild-thread (id)
3046 "Rebuild the thread containing ID."
3047 (let ((buffer-read-only nil)
3048 current thread data)
3049 (if (not gnus-show-threads)
3050 (setq thread (list (car (gnus-id-to-thread id))))
3051 ;; Get the thread this article is part of.
3052 (setq thread (gnus-remove-thread id)))
3053 (setq current (save-excursion
3054 (and (zerop (forward-line -1))
3055 (gnus-summary-article-number))))
3056 ;; If this is a gathered thread, we have to go some re-gathering.
3057 (when (stringp (car thread))
3058 (let ((subject (car thread))
3060 (setq thread (cdr thread))
3062 (unless (memq (setq thr (gnus-id-to-thread
3064 (mail-header-id (caar thread)))))
3067 (setq thread (cdr thread)))
3068 ;; We now have all (unique) roots.
3069 (if (= (length roots) 1)
3070 ;; All the loose roots are now one solid root.
3071 (setq thread (car roots))
3072 (setq thread (cons subject (gnus-sort-threads roots))))))
3074 ;; We then insert this thread into the summary buffer.
3075 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3076 (if gnus-show-threads
3077 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3078 (gnus-summary-prepare-unthreaded thread))
3079 (setq data (nreverse gnus-newsgroup-data))
3080 (setq threads gnus-newsgroup-threads))
3081 ;; We splice the new data into the data structure.
3082 (gnus-data-enter-list current data)
3083 (gnus-data-compute-positions)
3084 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
3086 (defun gnus-number-to-header (number)
3087 "Return the header for article NUMBER."
3088 (let ((headers gnus-newsgroup-headers))
3090 (not (= number (mail-header-number (car headers)))))
3095 (defun gnus-parent-headers (headers &optional generation)
3096 "Return the headers of the GENERATIONeth parent of HEADERS."
3098 (setq generation 1))
3099 (let (references parent)
3100 (while (and headers (not (zerop generation)))
3101 (setq references (mail-header-references headers))
3102 (when (and references
3103 (setq parent (gnus-parent-id references))
3104 (setq headers (car (gnus-id-to-thread parent))))
3108 (defun gnus-id-to-thread (id)
3109 "Return the (sub-)thread where ID appears."
3110 (gnus-gethash id gnus-newsgroup-dependencies))
3112 (defun gnus-id-to-article (id)
3113 "Return the article number of ID."
3114 (let ((thread (gnus-id-to-thread id)))
3117 (mail-header-number (car thread)))))
3119 (defun gnus-id-to-header (id)
3120 "Return the article headers of ID."
3121 (car (gnus-id-to-thread id)))
3123 (defun gnus-article-displayed-root-p (article)
3124 "Say whether ARTICLE is a root(ish) article."
3125 (let ((level (gnus-summary-thread-level article))
3126 (refs (mail-header-references (gnus-summary-article-header article)))
3132 ((null (gnus-parent-id refs)) t)
3134 (null (setq particle (gnus-id-to-article
3135 (gnus-parent-id refs))))
3136 (null (gnus-summary-thread-level particle)))))))
3138 (defun gnus-root-id (id)
3139 "Return the id of the root of the thread where ID appears."
3141 (while (and id (setq prev (car (gnus-gethash
3142 id gnus-newsgroup-dependencies))))
3144 id (gnus-parent-id (mail-header-references prev))))
3147 (defun gnus-remove-thread (id &optional dont-remove)
3148 "Remove the thread that has ID in it."
3149 (let ((dep gnus-newsgroup-dependencies)
3150 headers thread last-id)
3151 ;; First go up in this thread until we find the root.
3152 (setq last-id (gnus-root-id id))
3153 (setq headers (list (car (gnus-id-to-thread last-id))
3154 (caadr (gnus-id-to-thread last-id))))
3155 ;; We have now found the real root of this thread. It might have
3156 ;; been gathered into some loose thread, so we have to search
3157 ;; through the threads to find the thread we wanted.
3158 (let ((threads gnus-newsgroup-threads)
3161 (setq sub (car threads))
3162 (if (stringp (car sub))
3163 ;; This is a gathered thread, so we look at the roots
3164 ;; below it to find whether this article is in this
3167 (setq sub (cdr sub))
3169 (when (member (caar sub) headers)
3170 (setq thread (car threads)
3173 (setq sub (cdr sub))))
3174 ;; It's an ordinary thread, so we check it.
3175 (when (eq (car sub) (car headers))
3178 (setq threads (cdr threads)))
3179 ;; If this article is in no thread, then it's a root.
3182 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3183 (setq thread (gnus-gethash last-id dep)))
3186 thread ; We return this thread.
3188 (if (stringp (car thread))
3190 ;; If we use dummy roots, then we have to remove the
3191 ;; dummy root as well.
3192 (when (eq gnus-summary-make-false-root 'dummy)
3195 (setq thread (cdr thread))
3197 (gnus-remove-thread-1 (car thread))
3198 (setq thread (cdr thread))))
3199 (gnus-remove-thread-1 thread))))))))
3201 (defun gnus-remove-thread-1 (thread)
3202 "Remove the thread THREAD recursively."
3203 (let ((number (mail-header-number (car thread)))
3205 (when (setq pos (text-property-any
3206 (point-min) (point-max) 'gnus-number number))
3209 (gnus-data-remove number))
3210 (setq thread (cdr thread))
3212 (gnus-remove-thread-1 (pop thread)))))
3214 (defun gnus-sort-threads (threads)
3216 (if (not gnus-thread-sort-functions)
3218 (gnus-message 7 "Sorting threads...")
3220 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3221 (gnus-message 7 "Sorting threads...done"))))
3223 (defun gnus-sort-articles (articles)
3225 (when gnus-article-sort-functions
3226 (gnus-message 7 "Sorting articles...")
3228 (setq gnus-newsgroup-headers
3229 (sort articles (gnus-make-sort-function
3230 gnus-article-sort-functions)))
3231 (gnus-message 7 "Sorting articles...done"))))
3233 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3234 (defmacro gnus-thread-header (thread)
3235 ;; Return header of first article in THREAD.
3236 ;; Note that THREAD must never, ever be anything else than a variable -
3237 ;; using some other form will lead to serious barfage.
3238 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3239 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3240 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
3243 (defsubst gnus-article-sort-by-number (h1 h2)
3244 "Sort articles by article number."
3245 (< (mail-header-number h1)
3246 (mail-header-number h2)))
3248 (defun gnus-thread-sort-by-number (h1 h2)
3249 "Sort threads by root article number."
3250 (gnus-article-sort-by-number
3251 (gnus-thread-header h1) (gnus-thread-header h2)))
3253 (defsubst gnus-article-sort-by-author (h1 h2)
3254 "Sort articles by root author."
3256 (let ((extract (funcall
3257 gnus-extract-address-components
3258 (mail-header-from h1))))
3259 (or (car extract) (cdr extract)))
3260 (let ((extract (funcall
3261 gnus-extract-address-components
3262 (mail-header-from h2))))
3263 (or (car extract) (cdr extract)))))
3265 (defun gnus-thread-sort-by-author (h1 h2)
3266 "Sort threads by root author."
3267 (gnus-article-sort-by-author
3268 (gnus-thread-header h1) (gnus-thread-header h2)))
3270 (defsubst gnus-article-sort-by-subject (h1 h2)
3271 "Sort articles by root subject."
3273 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3274 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3276 (defun gnus-thread-sort-by-subject (h1 h2)
3277 "Sort threads by root subject."
3278 (gnus-article-sort-by-subject
3279 (gnus-thread-header h1) (gnus-thread-header h2)))
3281 (defsubst gnus-article-sort-by-date (h1 h2)
3282 "Sort articles by root article date."
3284 (gnus-date-get-time (mail-header-date h1))
3285 (gnus-date-get-time (mail-header-date h2))))
3287 (defun gnus-thread-sort-by-date (h1 h2)
3288 "Sort threads by root article date."
3289 (gnus-article-sort-by-date
3290 (gnus-thread-header h1) (gnus-thread-header h2)))
3292 (defsubst gnus-article-sort-by-score (h1 h2)
3293 "Sort articles by root article score.
3294 Unscored articles will be counted as having a score of zero."
3295 (> (or (cdr (assq (mail-header-number h1)
3296 gnus-newsgroup-scored))
3297 gnus-summary-default-score 0)
3298 (or (cdr (assq (mail-header-number h2)
3299 gnus-newsgroup-scored))
3300 gnus-summary-default-score 0)))
3302 (defun gnus-thread-sort-by-score (h1 h2)
3303 "Sort threads by root article score."
3304 (gnus-article-sort-by-score
3305 (gnus-thread-header h1) (gnus-thread-header h2)))
3307 (defun gnus-thread-sort-by-total-score (h1 h2)
3308 "Sort threads by the sum of all scores in the thread.
3309 Unscored articles will be counted as having a score of zero."
3310 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3312 (defun gnus-thread-total-score (thread)
3313 ;; This function find the total score of THREAD.
3314 (cond ((null thread)
3317 (if (stringp (car thread))
3318 (apply gnus-thread-score-function 0
3319 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3320 (gnus-thread-total-score-1 thread)))
3322 (gnus-thread-total-score-1 (list thread)))))
3324 (defun gnus-thread-total-score-1 (root)
3325 ;; This function find the total score of the thread below ROOT.
3326 (setq root (car root))
3327 (apply gnus-thread-score-function
3329 (mapcar 'gnus-thread-total-score
3330 (cdr (gnus-gethash (mail-header-id root)
3331 gnus-newsgroup-dependencies)))
3332 (when (> (mail-header-number root) 0)
3333 (list (or (cdr (assq (mail-header-number root)
3334 gnus-newsgroup-scored))
3335 gnus-summary-default-score 0))))
3336 (list gnus-summary-default-score)
3339 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3340 (defvar gnus-tmp-prev-subject nil)
3341 (defvar gnus-tmp-false-parent nil)
3342 (defvar gnus-tmp-root-expunged nil)
3343 (defvar gnus-tmp-dummy-line nil)
3345 (defun gnus-summary-prepare-threads (threads)
3346 "Prepare summary buffer from THREADS and indentation LEVEL.
3347 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3348 or a straight list of headers."
3349 (gnus-message 7 "Generating summary...")
3351 (setq gnus-newsgroup-threads threads)
3354 (let ((gnus-tmp-level 0)
3355 (default-score (or gnus-summary-default-score 0))
3356 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3357 thread number subject stack state gnus-tmp-gathered beg-match
3358 new-roots gnus-tmp-new-adopts thread-end
3359 gnus-tmp-header gnus-tmp-unread
3360 gnus-tmp-replied gnus-tmp-subject-or-nil
3361 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3362 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3363 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3365 (setq gnus-tmp-prev-subject nil)
3367 (if (vectorp (car threads))
3368 ;; If this is a straight (sic) list of headers, then a
3369 ;; threaded summary display isn't required, so we just create
3370 ;; an unthreaded one.
3371 (gnus-summary-prepare-unthreaded threads)
3373 ;; Do the threaded display.
3375 (while (or threads stack gnus-tmp-new-adopts new-roots)
3377 (if (and (= gnus-tmp-level 0)
3378 (not (setq gnus-tmp-dummy-line nil))
3381 (not gnus-tmp-false-parent)
3382 (or gnus-tmp-new-adopts new-roots))
3383 (if gnus-tmp-new-adopts
3384 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3385 thread (list (car gnus-tmp-new-adopts))
3386 gnus-tmp-header (caar thread)
3387 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3389 (setq thread (list (car new-roots))
3390 gnus-tmp-header (caar thread)
3391 new-roots (cdr new-roots))))
3394 ;; If there are some threads, we do them before the
3395 ;; threads on the stack.
3396 (setq thread threads
3397 gnus-tmp-header (caar thread))
3398 ;; There were no current threads, so we pop something off
3400 (setq state (car stack)
3401 gnus-tmp-level (car state)
3404 gnus-tmp-header (caar thread))))
3406 (setq gnus-tmp-false-parent nil)
3407 (setq gnus-tmp-root-expunged nil)
3408 (setq thread-end nil)
3410 (if (stringp gnus-tmp-header)
3411 ;; The header is a dummy root.
3413 ((eq gnus-summary-make-false-root 'adopt)
3414 ;; We let the first article adopt the rest.
3415 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3417 (setq gnus-tmp-gathered
3419 (lambda (h) (mail-header-number (car h)))
3422 (setq thread (cons (list (caar thread)
3425 (setq gnus-tmp-level -1
3426 gnus-tmp-false-parent t))
3427 ((eq gnus-summary-make-false-root 'empty)
3428 ;; We print adopted articles with empty subject fields.
3429 (setq gnus-tmp-gathered
3431 (lambda (h) (mail-header-number (car h)))
3434 (setq gnus-tmp-level -1))
3435 ((eq gnus-summary-make-false-root 'dummy)
3436 ;; We remember that we probably want to output a dummy
3438 (setq gnus-tmp-dummy-line gnus-tmp-header)
3439 (setq gnus-tmp-prev-subject gnus-tmp-header))
3441 ;; We do not make a root for the gathered
3442 ;; sub-threads at all.
3443 (setq gnus-tmp-level -1)))
3445 (setq number (mail-header-number gnus-tmp-header)
3446 subject (mail-header-subject gnus-tmp-header))
3449 ;; If the thread has changed subject, we might want to make
3450 ;; this subthread into a root.
3451 ((and (null gnus-thread-ignore-subject)
3452 (not (zerop gnus-tmp-level))
3453 gnus-tmp-prev-subject
3455 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3456 (setq new-roots (nconc new-roots (list (car thread)))
3458 gnus-tmp-header nil))
3459 ;; If the article lies outside the current limit,
3460 ;; then we do not display it.
3461 ((and (not (memq number gnus-newsgroup-limit))
3462 (not gnus-tmp-dummy-line))
3463 (setq gnus-tmp-gathered
3465 (lambda (h) (mail-header-number (car h)))
3468 (setq gnus-tmp-new-adopts (if (cdar thread)
3469 (append gnus-tmp-new-adopts
3471 gnus-tmp-new-adopts)
3473 gnus-tmp-header nil)
3474 (when (zerop gnus-tmp-level)
3475 (setq gnus-tmp-root-expunged t)))
3476 ;; Perhaps this article is to be marked as read?
3477 ((and gnus-summary-mark-below
3478 (< (or (cdr (assq number gnus-newsgroup-scored))
3480 gnus-summary-mark-below)
3481 ;; Don't touch sparse articles.
3482 (not (memq number gnus-newsgroup-sparse))
3483 (not (memq number gnus-newsgroup-ancient)))
3484 (setq gnus-newsgroup-unreads
3485 (delq number gnus-newsgroup-unreads))
3486 (if gnus-newsgroup-auto-expire
3487 (push number gnus-newsgroup-expirable)
3488 (push (cons number gnus-low-score-mark)
3489 gnus-newsgroup-reads))))
3491 (when gnus-tmp-header
3492 ;; We may have an old dummy line to output before this
3494 (when gnus-tmp-dummy-line
3495 (gnus-summary-insert-dummy-line
3496 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3497 (setq gnus-tmp-dummy-line nil))
3499 ;; Compute the mark.
3500 (setq gnus-tmp-unread (gnus-article-mark number))
3502 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3503 gnus-tmp-header gnus-tmp-level)
3504 gnus-newsgroup-data)
3506 ;; Actually insert the line.
3508 gnus-tmp-subject-or-nil
3510 ((and gnus-thread-ignore-subject
3511 gnus-tmp-prev-subject
3512 (not (inline (gnus-subject-equal
3513 gnus-tmp-prev-subject subject))))
3515 ((zerop gnus-tmp-level)
3516 (if (and (eq gnus-summary-make-false-root 'empty)
3517 (memq number gnus-tmp-gathered)
3518 gnus-tmp-prev-subject
3519 (inline (gnus-subject-equal
3520 gnus-tmp-prev-subject subject)))
3521 gnus-summary-same-subject
3523 (t gnus-summary-same-subject)))
3524 (if (and (eq gnus-summary-make-false-root 'adopt)
3525 (= gnus-tmp-level 1)
3526 (memq number gnus-tmp-gathered))
3527 (setq gnus-tmp-opening-bracket ?\<
3528 gnus-tmp-closing-bracket ?\>)
3529 (setq gnus-tmp-opening-bracket ?\[
3530 gnus-tmp-closing-bracket ?\]))
3532 gnus-tmp-indentation
3533 (aref gnus-thread-indent-array gnus-tmp-level)
3534 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3535 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3536 gnus-summary-default-score 0)
3538 (if (or (null gnus-summary-default-score)
3539 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3540 gnus-summary-zcore-fuzz))
3542 (if (< gnus-tmp-score gnus-summary-default-score)
3543 gnus-score-below-mark gnus-score-over-mark))
3545 (cond ((memq number gnus-newsgroup-processable)
3547 ((memq number gnus-newsgroup-cached)
3549 ((memq number gnus-newsgroup-replied)
3551 ((memq number gnus-newsgroup-saved)
3553 (t gnus-unread-mark))
3554 gnus-tmp-from (mail-header-from gnus-tmp-header)
3557 ((string-match "(.+)" gnus-tmp-from)
3558 (substring gnus-tmp-from
3559 (1+ (match-beginning 0)) (1- (match-end 0))))
3560 ((string-match "<[^>]+> *$" gnus-tmp-from)
3561 (setq beg-match (match-beginning 0))
3562 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3563 (substring gnus-tmp-from (1+ (match-beginning 0))
3564 (1- (match-end 0))))
3565 (substring gnus-tmp-from 0 beg-match)))
3567 (when (string= gnus-tmp-name "")
3568 (setq gnus-tmp-name gnus-tmp-from))
3569 (unless (numberp gnus-tmp-lines)
3570 (setq gnus-tmp-lines 0))
3571 (gnus-put-text-property
3573 (progn (eval gnus-summary-line-format-spec) (point))
3574 'gnus-number number)
3577 (run-hooks 'gnus-summary-update-hook)
3580 (setq gnus-tmp-prev-subject subject)))
3582 (when (nth 1 thread)
3583 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3584 (incf gnus-tmp-level)
3585 (setq threads (if thread-end nil (cdar thread)))
3587 (setq gnus-tmp-level 0)))))
3588 (gnus-message 7 "Generating summary...done"))
3590 (defun gnus-summary-prepare-unthreaded (headers)
3591 "Generate an unthreaded summary buffer based on HEADERS."
3592 (let (header number mark)
3595 ;; We may have to root out some bad articles...
3596 (when (memq (setq number (mail-header-number
3597 (setq header (pop headers))))
3598 gnus-newsgroup-limit)
3599 ;; Mark article as read when it has a low score.
3600 (when (and gnus-summary-mark-below
3601 (< (or (cdr (assq number gnus-newsgroup-scored))
3602 gnus-summary-default-score 0)
3603 gnus-summary-mark-below)
3604 (not (memq number gnus-newsgroup-ancient)))
3605 (setq gnus-newsgroup-unreads
3606 (delq number gnus-newsgroup-unreads))
3607 (if gnus-newsgroup-auto-expire
3608 (push number gnus-newsgroup-expirable)
3609 (push (cons number gnus-low-score-mark)
3610 gnus-newsgroup-reads)))
3612 (setq mark (gnus-article-mark number))
3613 (push (gnus-data-make number mark (1+ (point)) header 0)
3614 gnus-newsgroup-data)
3615 (gnus-summary-insert-line
3617 mark (memq number gnus-newsgroup-replied)
3618 (memq number gnus-newsgroup-expirable)
3619 (mail-header-subject header) nil
3620 (cdr (assq number gnus-newsgroup-scored))
3621 (memq number gnus-newsgroup-processable))))))
3623 (defun gnus-select-newsgroup (group &optional read-all)
3624 "Select newsgroup GROUP.
3625 If READ-ALL is non-nil, all articles in the group are selected."
3626 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3627 (info (nth 2 entry))
3628 articles fetched-articles cached)
3630 (unless (gnus-check-server
3631 (setq gnus-current-select-method (gnus-find-method-for-group group)))
3632 (error "Couldn't open server"))
3634 (or (and entry (not (eq (car entry) t))) ; Either it's active...
3635 (gnus-activate-group group) ; Or we can activate it...
3636 (progn ; Or we bug out.
3637 (when (equal major-mode 'gnus-summary-mode)
3638 (kill-buffer (current-buffer)))
3639 (error "Couldn't request group %s: %s"
3640 group (gnus-status-message group))))
3642 (unless (gnus-request-group group t)
3643 (when (equal major-mode 'gnus-summary-mode)
3644 (kill-buffer (current-buffer)))
3645 (error "Couldn't request group %s: %s"
3646 group (gnus-status-message group)))
3648 (setq gnus-newsgroup-name group)
3649 (setq gnus-newsgroup-unselected nil)
3650 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
3652 ;; Adjust and set lists of article marks.
3654 (gnus-adjust-marked-articles info))
3656 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3657 (when (gnus-virtual-group-p group)
3658 (setq cached gnus-newsgroup-cached))
3660 (setq gnus-newsgroup-unreads
3661 (gnus-set-difference
3662 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
3663 gnus-newsgroup-dormant))
3665 (setq gnus-newsgroup-processable nil)
3667 (setq articles (gnus-articles-to-read group read-all))
3671 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
3673 ((eq articles 0) nil)
3675 ;; Init the dependencies hash table.
3676 (setq gnus-newsgroup-dependencies
3677 (gnus-make-hashtable (length articles)))
3678 ;; Retrieve the headers and read them in.
3679 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
3680 (setq gnus-newsgroup-headers
3682 (setq gnus-headers-retrieved-by
3683 (gnus-retrieve-headers
3684 articles gnus-newsgroup-name
3685 ;; We might want to fetch old headers, but
3686 ;; not if there is only 1 article.
3687 (and gnus-fetch-old-headers
3689 (not (eq gnus-fetch-old-headers 'some))
3690 (not (numberp gnus-fetch-old-headers)))
3691 (> (length articles) 1))))))
3692 (gnus-get-newsgroup-headers-xover articles)
3693 (gnus-get-newsgroup-headers)))
3694 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
3696 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3698 (setq gnus-newsgroup-cached cached))
3700 ;; Suppress duplicates?
3701 (when gnus-suppress-duplicates
3702 (gnus-dup-suppress-articles))
3704 ;; Set the initial limit.
3705 (setq gnus-newsgroup-limit (copy-sequence articles))
3706 ;; Remove canceled articles from the list of unread articles.
3707 (setq gnus-newsgroup-unreads
3708 (gnus-set-sorted-intersection
3709 gnus-newsgroup-unreads
3710 (setq fetched-articles
3711 (mapcar (lambda (headers) (mail-header-number headers))
3712 gnus-newsgroup-headers))))
3713 ;; Removed marked articles that do not exist.
3714 (gnus-update-missing-marks
3715 (gnus-sorted-complement fetched-articles articles))
3716 ;; We might want to build some more threads first.
3717 (and gnus-fetch-old-headers
3718 (eq gnus-headers-retrieved-by 'nov)
3719 (gnus-build-old-threads))
3720 ;; Check whether auto-expire is to be done in this group.
3721 (setq gnus-newsgroup-auto-expire
3722 (gnus-group-auto-expirable-p group))
3723 ;; Set up the article buffer now, if necessary.
3724 (unless gnus-single-article-buffer
3725 (gnus-article-setup-buffer))
3726 ;; First and last article in this newsgroup.
3727 (when gnus-newsgroup-headers
3728 (setq gnus-newsgroup-begin
3729 (mail-header-number (car gnus-newsgroup-headers))
3732 (gnus-last-element gnus-newsgroup-headers))))
3733 ;; GROUP is successfully selected.
3734 (or gnus-newsgroup-headers t)))))
3736 (defun gnus-articles-to-read (group read-all)
3737 ;; Find out what articles the user wants to read.
3739 ;; Select all articles if `read-all' is non-nil, or if there
3740 ;; are no unread articles.
3742 (and (zerop (length gnus-newsgroup-marked))
3743 (zerop (length gnus-newsgroup-unreads)))
3744 (eq (gnus-group-find-parameter group 'display)
3746 (gnus-uncompress-range (gnus-active group))
3747 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
3748 (copy-sequence gnus-newsgroup-unreads))
3750 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
3751 (scored (length scored-list))
3752 (number (length articles))
3753 (marked (+ (length gnus-newsgroup-marked)
3754 (length gnus-newsgroup-dormant)))
3762 ((and (or (<= scored marked) (= scored number))
3763 (numberp gnus-large-newsgroup)
3764 (> number gnus-large-newsgroup))
3768 "How many articles from %s (default %d): "
3769 gnus-newsgroup-name number))))
3770 (if (string-match "^[ \t]*$" input) number input)))
3771 ((and (> scored marked) (< scored number)
3772 (> (- scored number) 20))
3775 (format "%s %s (%d scored, %d total): "
3776 "How many articles from"
3777 group scored number))))
3778 (if (string-match "^[ \t]*$" input)
3782 (setq select (if (stringp select) (string-to-number select) select))
3783 (if (or (null select) (zerop select))
3785 (if (and (not (zerop scored)) (<= (abs select) scored))
3787 (setq articles (sort scored-list '<))
3788 (setq number (length articles)))
3789 (setq articles (copy-sequence articles)))
3791 (when (< (abs select) number)
3793 ;; Select the N oldest articles.
3794 (setcdr (nthcdr (1- (abs select)) articles) nil)
3795 ;; Select the N most recent articles.
3796 (setq articles (nthcdr (- number select) articles))))
3797 (setq gnus-newsgroup-unselected
3798 (gnus-sorted-intersection
3799 gnus-newsgroup-unreads
3800 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
3803 (defun gnus-killed-articles (killed articles)
3806 (when (inline (gnus-member-of-range (car articles) killed))
3807 (push (car articles) out))
3808 (setq articles (cdr articles)))
3811 (defun gnus-uncompress-marks (marks)
3812 "Uncompress the mark ranges in MARKS."
3813 (let ((uncompressed '(score bookmark))
3816 (if (memq (caar marks) uncompressed)
3817 (push (car marks) out)
3818 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
3819 (setq marks (cdr marks)))
3822 (defun gnus-adjust-marked-articles (info)
3823 "Set all article lists and remove all marks that are no longer legal."
3824 (let* ((marked-lists (gnus-info-marks info))
3825 (active (gnus-active (gnus-info-group info)))
3828 (types gnus-article-mark-lists)
3829 (uncompressed '(score bookmark killed))
3830 marks var articles article mark)
3833 (setq marks (pop marked-lists))
3834 (set (setq var (intern (format "gnus-newsgroup-%s"
3835 (car (rassq (setq mark (car marks))
3837 (if (memq (car marks) uncompressed) (cdr marks)
3838 (gnus-uncompress-range (cdr marks))))
3840 (setq articles (symbol-value var))
3842 ;; All articles have to be subsets of the active articles.
3844 ;; Adjust "simple" lists.
3845 ((memq mark '(tick dormant expirable reply save))
3847 (when (or (< (setq article (pop articles)) min) (> article max))
3848 (set var (delq article (symbol-value var))))))
3850 ((memq mark uncompressed)
3852 (when (or (not (consp (setq article (pop articles))))
3853 (< (car article) min)
3854 (> (car article) max))
3855 (set var (delq article (symbol-value var))))))))))
3857 (defun gnus-update-missing-marks (missing)
3858 "Go through the list of MISSING articles and remove them mark lists."
3860 (let ((types gnus-article-mark-lists)
3862 ;; Go through all types.
3864 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
3865 (when (symbol-value var)
3866 ;; This list has articles. So we delete all missing articles
3870 (set var (delq (pop m) (symbol-value var)))))))))
3872 (defun gnus-update-marks ()
3873 "Enter the various lists of marked articles into the newsgroup info list."
3874 (let ((types gnus-article-mark-lists)
3875 (info (gnus-get-info gnus-newsgroup-name))
3876 (uncompressed '(score bookmark killed))
3877 type list newmarked symbol)
3879 ;; Add all marks lists that are non-nil to the list of marks lists.
3881 (setq type (pop types))
3882 (when (setq list (symbol-value
3884 (intern (format "gnus-newsgroup-%s"
3886 (push (cons (cdr type)
3887 (if (memq (cdr type) uncompressed) list
3888 (gnus-compress-sequence
3889 (set symbol (sort list '<)) t)))
3892 ;; Enter these new marks into the info of the group.
3894 (setcar (nthcdr 3 info) newmarked)
3895 ;; Add the marks lists to the end of the info.
3897 (setcdr (nthcdr 2 info) (list newmarked))))
3899 ;; Cut off the end of the info if there's nothing else there.
3903 (when (nthcdr (decf i) info)
3904 (setcdr (nthcdr i info) nil)))))))
3906 (defun gnus-set-mode-line (where)
3907 "This function sets the mode line of the article or summary buffers.
3908 If WHERE is `summary', the summary mode line format will be used."
3909 ;; Is this mode line one we keep updated?
3910 (when (memq where gnus-updated-mode-lines)
3913 ;; We evaluate this in the summary buffer since these
3914 ;; variables are buffer-local to that buffer.
3915 (set-buffer gnus-summary-buffer)
3916 ;; We bind all these variables that are used in the `eval' form
3918 (let* ((mformat (symbol-value
3920 (format "gnus-%s-mode-line-format-spec" where))))
3921 (gnus-tmp-group-name gnus-newsgroup-name)
3922 (gnus-tmp-article-number (or gnus-current-article 0))
3923 (gnus-tmp-unread gnus-newsgroup-unreads)
3924 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
3925 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
3926 (gnus-tmp-unread-and-unselected
3927 (cond ((and (zerop gnus-tmp-unread-and-unticked)
3928 (zerop gnus-tmp-unselected))
3930 ((zerop gnus-tmp-unselected)
3931 (format "{%d more}" gnus-tmp-unread-and-unticked))
3932 (t (format "{%d(+%d) more}"
3933 gnus-tmp-unread-and-unticked
3934 gnus-tmp-unselected))))
3936 (if (and gnus-current-headers
3937 (vectorp gnus-current-headers))
3938 (gnus-mode-string-quote
3939 (mail-header-subject gnus-current-headers))
3942 gnus-tmp-header);; passed as argument to any user-format-funcs
3943 (setq mode-string (eval mformat))
3944 (setq max-len (max 4 (if gnus-mode-non-string-length
3946 gnus-mode-non-string-length)
3947 (length mode-string))))
3948 ;; We might have to chop a bit of the string off...
3949 (when (> (length mode-string) max-len)
3951 (concat (gnus-truncate-string mode-string (- max-len 3))
3953 ;; Pad the mode string a bit.
3954 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
3955 ;; Update the mode line.
3956 (setq mode-line-buffer-identification
3957 (gnus-mode-line-buffer-identification
3958 (list mode-string)))
3959 (set-buffer-modified-p t))))
3961 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
3962 "Go through the HEADERS list and add all Xrefs to a hash table.
3963 The resulting hash table is returned, or nil if no Xrefs were found."
3964 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
3965 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
3966 (xref-hashtb (make-vector 63 0))
3967 start group entry number xrefs header)
3969 (setq header (pop headers))
3970 (when (and (setq xrefs (mail-header-xref header))
3971 (not (memq (setq number (mail-header-number header))
3974 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
3975 (setq start (match-end 0))
3976 (setq group (if prefix
3977 (concat prefix (substring xrefs (match-beginning 1)
3979 (substring xrefs (match-beginning 1) (match-end 1))))
3981 (string-to-int (substring xrefs (match-beginning 2)
3983 (if (setq entry (gnus-gethash group xref-hashtb))
3984 (setcdr entry (cons number (cdr entry)))
3985 (gnus-sethash group (cons number nil) xref-hashtb)))))
3986 (and start xref-hashtb)))
3988 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
3989 "Look through all the headers and mark the Xrefs as read."
3990 (let ((virtual (gnus-virtual-group-p from-newsgroup))
3991 name entry info xref-hashtb idlist method nth4)
3993 (set-buffer gnus-group-buffer)
3994 (when (setq xref-hashtb
3995 (gnus-create-xref-hashtb from-newsgroup headers unreads))
3998 (unless (string= from-newsgroup (setq name (symbol-name group)))
3999 (setq idlist (symbol-value group))
4000 ;; Dead groups are not updated.
4002 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4004 (when (stringp (setq nth4 (gnus-info-method info)))
4005 (setq nth4 (gnus-server-to-method nth4))))
4006 ;; Only do the xrefs if the group has the same
4007 ;; select method as the group we have just read.
4008 (or (gnus-methods-equal-p
4009 nth4 (gnus-find-method-for-group from-newsgroup))
4011 (equal nth4 (setq method (gnus-find-method-for-group
4013 (and (equal (car nth4) (car method))
4014 (equal (nth 1 nth4) (nth 1 method))))
4015 gnus-use-cross-reference
4016 (or (not (eq gnus-use-cross-reference t))
4018 ;; Only do cross-references on subscribed
4019 ;; groups, if that is what is wanted.
4020 (<= (gnus-info-level info) gnus-level-subscribed))
4021 (gnus-group-make-articles-read name idlist))))
4024 (defun gnus-group-make-articles-read (group articles)
4025 "Update the info of GROUP to say that only ARTICLES are unread."
4027 (entry (gnus-gethash group gnus-newsrc-hashtb))
4028 (info (nth 2 entry))
4029 (active (gnus-active group))
4031 ;; First peel off all illegal article numbers.
4033 (let ((ids articles)
4035 (while (setq id (pop ids))
4036 (when (and first (> id (cdr active)))
4037 ;; We'll end up in this situation in one particular
4038 ;; obscure situation. If you re-scan a group and get
4039 ;; a new article that is cross-posted to a different
4040 ;; group that has not been re-scanned, you might get
4041 ;; crossposted article that has a higher number than
4042 ;; Gnus believes possible. So we re-activate this
4043 ;; group as well. This might mean doing the
4044 ;; crossposting thingy will *increase* the number
4045 ;; of articles in some groups. Tsk, tsk.
4046 (setq active (or (gnus-activate-group group) active)))
4047 (when (or (> id (cdr active))
4048 (< id (car active)))
4049 (setq articles (delq id articles))))))
4052 (gnus-info-set-marks ,info ,(gnus-info-marks info))
4053 (gnus-info-set-read ,info ,(gnus-info-read info))
4054 (gnus-group-update-group group t)))
4055 ;; If the read list is nil, we init it.
4057 (null (gnus-info-read info))
4059 (gnus-info-set-read info (cons 1 (1- (car active)))))
4060 ;; Then we add the read articles to the range.
4065 (gnus-info-read info) (setq articles (sort articles '<)))))
4066 ;; Then we have to re-compute how many unread
4067 ;; articles there are in this group.
4071 (setq num (- (1+ (cdr active)) (car active))))
4072 ((not (listp (cdr range)))
4073 (setq num (- (cdr active) (- (1+ (cdr range))
4077 (if (numberp (car range))
4079 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4080 (setq range (cdr range)))
4081 (setq num (- (cdr active) num))))
4082 ;; Update the number of unread articles.
4084 ;; Update the group buffer.
4085 (gnus-group-update-group group t))))
4087 (defun gnus-methods-equal-p (m1 m2)
4088 (let ((m1 (or m1 gnus-select-method))
4089 (m2 (or m2 gnus-select-method)))
4091 (and (eq (car m1) (car m2))
4092 (or (not (memq 'address (assoc (symbol-name (car m1))
4093 gnus-valid-select-methods)))
4094 (equal (nth 1 m1) (nth 1 m2)))))))
4096 (defvar gnus-newsgroup-none-id 0)
4098 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4099 (let ((cur nntp-server-buffer)
4102 (save-excursion (set-buffer gnus-summary-buffer)
4103 gnus-newsgroup-dependencies)))
4104 headers id id-dep ref-dep end ref)
4106 (set-buffer nntp-server-buffer)
4107 ;; Translate all TAB characters into SPACE characters.
4108 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4109 (run-hooks 'gnus-parse-headers-hook)
4110 (let ((case-fold-search t)
4111 in-reply-to header p lines)
4112 (goto-char (point-min))
4113 ;; Search to the beginning of the next header. Error messages
4114 ;; do not begin with 2 or 3.
4115 (while (re-search-forward "^[23][0-9]+ " nil t)
4118 ;; This implementation of this function, with nine
4119 ;; search-forwards instead of the one re-search-forward and
4120 ;; a case (which basically was the old function) is actually
4121 ;; about twice as fast, even though it looks messier. You
4122 ;; can't have everything, I guess. Speed and elegance
4123 ;; doesn't always go hand in hand.
4132 (narrow-to-region (point)
4133 (or (and (search-forward "\n.\n" nil t)
4139 (if (search-forward "\nsubject: " nil t)
4140 (nnheader-header-value) "(none)"))
4144 (if (search-forward "\nfrom: " nil t)
4145 (nnheader-header-value) "(nobody)"))
4149 (if (search-forward "\ndate: " nil t)
4150 (nnheader-header-value) ""))
4154 (if (search-forward "\nmessage-id: " nil t)
4155 (setq id (nnheader-header-value))
4156 ;; If there was no message-id, we just fake one to make
4157 ;; subsequent routines simpler.
4158 (setq id (concat "none+"
4160 (setq gnus-newsgroup-none-id
4161 (1+ gnus-newsgroup-none-id)))))))
4165 (if (search-forward "\nreferences: " nil t)
4169 (nnheader-header-value)
4174 (search-backward ">" end t)
4177 (search-backward "<" end t)
4179 ;; Get the references from the in-reply-to header if there
4180 ;; were no references and the in-reply-to header looks
4182 (if (and (search-forward "\nin-reply-to: " nil t)
4183 (setq in-reply-to (nnheader-header-value))
4184 (string-match "<[^>]+>" in-reply-to))
4185 (setq ref (substring in-reply-to (match-beginning 0)
4193 (if (search-forward "\nlines: " nil t)
4194 (if (numberp (setq lines (read cur)))
4200 (and (search-forward "\nxref: " nil t)
4201 (nnheader-header-value)))))
4202 (when (equal id ref)
4204 ;; We do the threading while we read the headers. The
4205 ;; message-id and the last reference are both entered into
4206 ;; the same hash table. Some tippy-toeing around has to be
4207 ;; done in case an article has arrived before the article
4208 ;; which it refers to.
4209 (if (boundp (setq id-dep (intern id dependencies)))
4210 (if (and (car (symbol-value id-dep))
4212 ;; An article with this Message-ID has already
4213 ;; been seen, so we ignore this one, except we add
4214 ;; any additional Xrefs (in case the two articles
4215 ;; came from different servers).
4217 (mail-header-set-xref
4218 (car (symbol-value id-dep))
4219 (concat (or (mail-header-xref
4220 (car (symbol-value id-dep)))
4222 (or (mail-header-xref header) "")))
4224 (setcar (symbol-value id-dep) header))
4225 (set id-dep (list header)))
4227 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
4228 (setcdr (symbol-value ref-dep)
4229 (nconc (cdr (symbol-value ref-dep))
4230 (list (symbol-value id-dep))))
4231 (set ref-dep (list nil (symbol-value id-dep))))
4232 (push header headers))
4233 (goto-char (point-max))
4235 (nreverse headers)))))
4237 ;; The following macros and functions were written by Felix Lee
4238 ;; <flee@cse.psu.edu>.
4240 (defmacro gnus-nov-read-integer ()
4242 (if (= (following-char) ?\t)
4244 (let ((num (ignore-errors (read buffer))))
4245 (if (numberp num) num 0)))
4249 (defmacro gnus-nov-skip-field ()
4250 '(search-forward "\t" eol 'move))
4252 (defmacro gnus-nov-field ()
4253 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
4255 (defvar gnus-nov-none-counter 0)
4257 ;; This function has to be called with point after the article number
4258 ;; on the beginning of the line.
4259 (defun gnus-nov-parse-line (number dependencies &optional force-new)
4260 (let ((eol (gnus-point-at-eol))
4261 (buffer (current-buffer))
4262 header ref id id-dep ref-dep)
4264 ;; overview: [num subject from date id refs chars lines misc]
4265 (narrow-to-region (point) eol)
4272 (gnus-nov-field) ; subject
4273 (gnus-nov-field) ; from
4274 (gnus-nov-field) ; date
4275 (setq id (or (gnus-nov-field)
4278 (incf gnus-nov-none-counter))))) ; id
4280 (let ((beg (point)))
4281 (search-forward "\t" eol)
4282 (if (search-backward ">" beg t)
4286 (search-backward "<" beg t)))
4289 (gnus-nov-field)) ; refs
4290 (gnus-nov-read-integer) ; chars
4291 (gnus-nov-read-integer) ; lines
4292 (if (= (following-char) ?\n)
4294 (gnus-nov-field)) ; misc
4299 ;; We build the thread tree.
4300 (when (equal id ref)
4301 ;; This article refers back to itself. Naughty, naughty.
4303 (if (boundp (setq id-dep (intern id dependencies)))
4304 (if (and (car (symbol-value id-dep))
4306 ;; An article with this Message-ID has already been seen,
4307 ;; so we ignore this one, except we add any additional
4308 ;; Xrefs (in case the two articles came from different
4311 (mail-header-set-xref
4312 (car (symbol-value id-dep))
4313 (concat (or (mail-header-xref
4314 (car (symbol-value id-dep)))
4316 (or (mail-header-xref header) "")))
4318 (setcar (symbol-value id-dep) header))
4319 (set id-dep (list header)))
4321 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
4322 (setcdr (symbol-value ref-dep)
4323 (nconc (cdr (symbol-value ref-dep))
4324 (list (symbol-value id-dep))))
4325 (set ref-dep (list nil (symbol-value id-dep)))))
4328 ;; Goes through the xover lines and returns a list of vectors
4329 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4330 force-new dependencies)
4331 "Parse the news overview data in the server buffer, and return a
4332 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4333 ;; Get the Xref when the users reads the articles since most/some
4334 ;; NNTP servers do not include Xrefs when using XOVER.
4335 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4336 (let ((cur nntp-server-buffer)
4337 (dependencies (or dependencies gnus-newsgroup-dependencies))
4338 number headers header)
4340 (set-buffer nntp-server-buffer)
4341 ;; Allow the user to mangle the headers before parsing them.
4342 (run-hooks 'gnus-parse-headers-hook)
4343 (goto-char (point-min))
4346 (while (and sequence (not (eobp)))
4347 (setq number (read cur))
4348 (while (and sequence
4349 (< (car sequence) number))
4350 (setq sequence (cdr sequence)))
4352 (eq number (car sequence))
4354 (setq sequence (cdr sequence))
4355 (setq header (inline
4356 (gnus-nov-parse-line
4357 number dependencies force-new))))
4358 (push header headers))
4361 (gnus-error 4 "Strange nov line")))
4363 (nreverse headers))))
4365 (defun gnus-article-get-xrefs ()
4366 "Fill in the Xref value in `gnus-current-headers', if necessary.
4367 This is meant to be called in `gnus-article-internal-prepare-hook'."
4368 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4369 gnus-current-headers)))
4370 (or (not gnus-use-cross-reference)
4372 (and (mail-header-xref headers)
4373 (not (string= (mail-header-xref headers) "")))
4374 (let ((case-fold-search t)
4377 (nnheader-narrow-to-headers)
4378 (goto-char (point-min))
4379 (when (or (and (eq (downcase (following-char)) ?x)
4380 (looking-at "Xref:"))
4381 (search-forward "\nXref:" nil t))
4382 (goto-char (1+ (match-end 0)))
4383 (setq xref (buffer-substring (point)
4384 (progn (end-of-line) (point))))
4385 (mail-header-set-xref headers xref)))))))
4387 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4388 "Find article ID and insert the summary line for that article."
4389 (let ((header (if (and old-header use-old-header)
4390 old-header (gnus-read-header id)))
4391 (number (and (numberp id) id))
4394 ;; Rebuild the thread that this article is part of and go to the
4395 ;; article we have fetched.
4396 (when (and (not gnus-show-threads)
4398 (when (setq pos (text-property-any
4399 (point-min) (point-max) 'gnus-number
4400 (mail-header-number old-header)))
4403 (gnus-data-remove (mail-header-number old-header))))
4405 (mail-header-set-number header (mail-header-number old-header)))
4406 (setq gnus-newsgroup-sparse
4407 (delq (setq number (mail-header-number header))
4408 gnus-newsgroup-sparse))
4409 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4410 (gnus-rebuild-thread (mail-header-id header))
4411 (gnus-summary-goto-subject number nil t))
4412 (when (and (numberp number)
4414 ;; We have to update the boundaries even if we can't fetch the
4415 ;; article if ID is a number -- so that the next `P' or `N'
4416 ;; command will fetch the previous (or next) article even
4417 ;; if the one we tried to fetch this time has been canceled.
4418 (when (> number gnus-newsgroup-end)
4419 (setq gnus-newsgroup-end number))
4420 (when (< number gnus-newsgroup-begin)
4421 (setq gnus-newsgroup-begin number))
4422 (setq gnus-newsgroup-unselected
4423 (delq number gnus-newsgroup-unselected)))
4424 ;; Report back a success?
4425 (and header (mail-header-number header))))
4427 ;;; Process/prefix in the summary buffer
4429 (defun gnus-summary-work-articles (n)
4430 "Return a list of articles to be worked upon. The prefix argument,
4431 the list of process marked articles, and the current article will be
4432 taken into consideration."
4435 ;; A numerical prefix has been given.
4436 (let ((backward (< n 0))
4437 (n (abs (prefix-numeric-value n)))
4442 (push (setq article (gnus-summary-article-number))
4445 (gnus-summary-find-prev nil article)
4446 (gnus-summary-find-next nil article)))
4448 (nreverse articles)))
4449 ((and (boundp 'transient-mark-mode)
4452 ;; Work on the region between point and mark.
4453 (let ((max (max (point) (mark)))
4456 (goto-char (min (point) (mark)))
4459 (push (setq article (gnus-summary-article-number)) articles)
4460 (gnus-summary-find-next nil article)
4462 (nreverse articles))))
4463 (gnus-newsgroup-processable
4464 ;; There are process-marked articles present.
4465 ;; Save current state.
4466 (gnus-summary-save-process-mark)
4468 (reverse gnus-newsgroup-processable))
4470 ;; Just return the current article.
4471 (list (gnus-summary-article-number)))))
4473 (defun gnus-summary-save-process-mark ()
4474 "Push the current set of process marked articles on the stack."
4476 (push (copy-sequence gnus-newsgroup-processable)
4477 gnus-newsgroup-process-stack))
4479 (defun gnus-summary-kill-process-mark ()
4480 "Push the current set of process marked articles on the stack and unmark."
4482 (gnus-summary-save-process-mark)
4483 (gnus-summary-unmark-all-processable))
4485 (defun gnus-summary-yank-process-mark ()
4486 "Pop the last process mark state off the stack and restore it."
4488 (unless gnus-newsgroup-process-stack
4489 (error "Empty mark stack"))
4490 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4492 (defun gnus-summary-process-mark-set (set)
4493 "Make SET into the current process marked articles."
4494 (gnus-summary-unmark-all-processable)
4496 (gnus-summary-set-process-mark (pop set))))
4498 ;;; Searching and stuff
4500 (defun gnus-summary-search-group (&optional backward use-level)
4501 "Search for next unread newsgroup.
4502 If optional argument BACKWARD is non-nil, search backward instead."
4504 (set-buffer gnus-group-buffer)
4505 (when (gnus-group-search-forward
4506 backward nil (if use-level (gnus-group-group-level) nil))
4507 (gnus-group-group-name))))
4509 (defun gnus-summary-best-group (&optional exclude-group)
4510 "Find the name of the best unread group.
4511 If EXCLUDE-GROUP, do not go to this group."
4513 (set-buffer gnus-group-buffer)
4515 (gnus-group-best-unread-group exclude-group))))
4517 (defun gnus-summary-find-next (&optional unread article backward)
4518 (if backward (gnus-summary-find-prev)
4519 (let* ((dummy (gnus-summary-article-intangible-p))
4520 (article (or article (gnus-summary-article-number)))
4521 (arts (gnus-data-find-list article))
4523 (when (and (not dummy)
4524 (or (not gnus-summary-check-current)
4526 (not (gnus-data-unread-p (car arts)))))
4527 (setq arts (cdr arts)))
4532 (when (gnus-data-unread-p (car arts))
4533 (setq result (car arts)
4535 (setq arts (cdr arts)))
4538 (goto-char (gnus-data-pos result))
4539 (gnus-data-number result)))))
4541 (defun gnus-summary-find-prev (&optional unread article)
4542 (let* ((eobp (eobp))
4543 (article (or article (gnus-summary-article-number)))
4544 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
4546 (when (and (not eobp)
4547 (or (not gnus-summary-check-current)
4549 (not (gnus-data-unread-p (car arts)))))
4550 (setq arts (cdr arts)))
4555 (when (gnus-data-unread-p (car arts))
4556 (setq result (car arts)
4558 (setq arts (cdr arts)))
4561 (goto-char (gnus-data-pos result))
4562 (gnus-data-number result))))
4564 (defun gnus-summary-find-subject (subject &optional unread backward article)
4565 (let* ((simp-subject (gnus-simplify-subject-fully subject))
4566 (article (or article (gnus-summary-article-number)))
4567 (articles (gnus-data-list backward))
4568 (arts (gnus-data-find-list article articles))
4570 (when (or (not gnus-summary-check-current)
4572 (not (gnus-data-unread-p (car arts))))
4573 (setq arts (cdr arts)))
4575 (and (or (not unread)
4576 (gnus-data-unread-p (car arts)))
4577 (vectorp (gnus-data-header (car arts)))
4579 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
4580 (setq result (car arts)
4582 (setq arts (cdr arts)))
4584 (goto-char (gnus-data-pos result))
4585 (gnus-data-number result))))
4587 (defun gnus-summary-search-forward (&optional unread subject backward)
4588 "Search forward for an article.
4589 If UNREAD, look for unread articles. If SUBJECT, look for
4590 articles with that subject. If BACKWARD, search backward instead."
4591 (cond (subject (gnus-summary-find-subject subject unread backward))
4592 (backward (gnus-summary-find-prev unread))
4593 (t (gnus-summary-find-next unread))))
4595 (defun gnus-recenter (&optional n)
4596 "Center point in window and redisplay frame.
4597 Also do horizontal recentering."
4599 (when (and gnus-auto-center-summary
4600 (not (eq gnus-auto-center-summary 'vertical)))
4601 (gnus-horizontal-recenter))
4604 (defun gnus-summary-recenter ()
4605 "Center point in the summary window.
4606 If `gnus-auto-center-summary' is nil, or the article buffer isn't
4607 displayed, no centering will be performed."
4608 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
4609 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
4610 (let* ((top (cond ((< (window-height) 4) 0)
4611 ((< (window-height) 7) 1)
4613 (height (1- (window-height)))
4614 (bottom (save-excursion (goto-char (point-max))
4615 (forward-line (- height))
4617 (window (get-buffer-window (current-buffer))))
4618 ;; The user has to want it.
4619 (when gnus-auto-center-summary
4620 (when (get-buffer-window gnus-article-buffer)
4621 ;; Only do recentering when the article buffer is displayed,
4622 ;; Set the window start to either `bottom', which is the biggest
4623 ;; possible valid number, or the second line from the top,
4624 ;; whichever is the least.
4626 window (min bottom (save-excursion
4627 (forward-line (- top)) (point)))))
4628 ;; Do horizontal recentering while we're at it.
4629 (when (and (get-buffer-window (current-buffer) t)
4630 (not (eq gnus-auto-center-summary 'vertical)))
4631 (let ((selected (selected-window)))
4632 (select-window (get-buffer-window (current-buffer) t))
4633 (gnus-summary-position-point)
4634 (gnus-horizontal-recenter)
4635 (select-window selected))))))
4637 (defun gnus-summary-jump-to-group (newsgroup)
4638 "Move point to NEWSGROUP in group mode buffer."
4639 ;; Keep update point of group mode buffer if visible.
4640 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
4641 (save-window-excursion
4642 ;; Take care of tree window mode.
4643 (when (get-buffer-window gnus-group-buffer)
4644 (pop-to-buffer gnus-group-buffer))
4645 (gnus-group-jump-to-group newsgroup))
4647 ;; Take care of tree window mode.
4648 (if (get-buffer-window gnus-group-buffer)
4649 (pop-to-buffer gnus-group-buffer)
4650 (set-buffer gnus-group-buffer))
4651 (gnus-group-jump-to-group newsgroup))))
4653 ;; This function returns a list of article numbers based on the
4654 ;; difference between the ranges of read articles in this group and
4655 ;; the range of active articles.
4656 (defun gnus-list-of-unread-articles (group)
4657 (let* ((read (gnus-info-read (gnus-get-info group)))
4658 (active (or (gnus-active group) (gnus-activate-group group)))
4661 ;; If none are read, then all are unread.
4663 (setq first (car active))
4664 ;; If the range of read articles is a single range, then the
4665 ;; first unread article is the article after the last read
4666 ;; article. Sounds logical, doesn't it?
4667 (if (not (listp (cdr read)))
4668 (setq first (1+ (cdr read)))
4669 ;; `read' is a list of ranges.
4670 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
4676 (while (< first nlast)
4678 (setq first (1+ first))))
4679 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
4680 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
4681 (setq read (cdr read)))))
4682 ;; And add the last unread articles.
4683 (while (<= first last)
4685 (setq first (1+ first)))
4686 ;; Return the list of unread articles.
4689 (defun gnus-list-of-read-articles (group)
4690 "Return a list of unread, unticked and non-dormant articles."
4691 (let* ((info (gnus-get-info group))
4692 (marked (gnus-info-marks info))
4693 (active (gnus-active group)))
4695 (gnus-set-difference
4696 (gnus-sorted-complement
4697 (gnus-uncompress-range active)
4698 (gnus-list-of-unread-articles group))
4700 (gnus-uncompress-range (cdr (assq 'dormant marked)))
4701 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
4703 ;; Various summary commands
4705 (defun gnus-summary-universal-argument (arg)
4706 "Perform any operation on all articles that are process/prefixed."
4708 (gnus-set-global-variables)
4709 (let ((articles (gnus-summary-work-articles arg))
4716 (substitute-command-keys
4717 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
4720 (gnus-error 1 "Undefined key")
4723 (gnus-summary-goto-subject (setq article (pop articles)))
4724 (let (gnus-newsgroup-processable)
4725 (command-execute func))
4726 (gnus-summary-remove-process-mark article)))))
4727 (gnus-summary-position-point))
4729 (defun gnus-summary-toggle-truncation (&optional arg)
4730 "Toggle truncation of summary lines.
4731 With arg, turn line truncation on iff arg is positive."
4733 (setq truncate-lines
4734 (if (null arg) (not truncate-lines)
4735 (> (prefix-numeric-value arg) 0)))
4738 (defun gnus-summary-reselect-current-group (&optional all rescan)
4739 "Exit and then reselect the current newsgroup.
4740 The prefix argument ALL means to select all articles."
4742 (gnus-set-global-variables)
4743 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
4744 (error "Ephemeral groups can't be reselected"))
4745 (let ((current-subject (gnus-summary-article-number))
4746 (group gnus-newsgroup-name))
4747 (setq gnus-newsgroup-begin nil)
4749 ;; We have to adjust the point of group mode buffer because the
4750 ;; current point was moved to the next unread newsgroup by
4752 (gnus-summary-jump-to-group group)
4755 (gnus-group-get-new-news-this-group 1)))
4756 (gnus-group-read-group all t)
4757 (gnus-summary-goto-subject current-subject nil t)))
4759 (defun gnus-summary-rescan-group (&optional all)
4760 "Exit the newsgroup, ask for new articles, and select the newsgroup."
4762 (gnus-summary-reselect-current-group all t))
4764 (defun gnus-summary-update-info ()
4765 (let ((group gnus-newsgroup-name))
4766 (when gnus-newsgroup-kill-headers
4767 (setq gnus-newsgroup-killed
4768 (gnus-compress-sequence
4770 (gnus-set-sorted-intersection
4771 (gnus-uncompress-range gnus-newsgroup-killed)
4772 (setq gnus-newsgroup-unselected
4773 (sort gnus-newsgroup-unselected '<)))
4774 (setq gnus-newsgroup-unreads
4775 (sort gnus-newsgroup-unreads '<)))
4777 (unless (listp (cdr gnus-newsgroup-killed))
4778 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
4779 (let ((headers gnus-newsgroup-headers))
4780 (run-hooks 'gnus-exit-group-hook)
4781 (unless gnus-save-score
4782 (setq gnus-newsgroup-scored nil))
4783 ;; Set the new ranges of read articles.
4784 (gnus-update-read-articles
4785 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
4786 ;; Set the current article marks.
4788 ;; Do the cross-ref thing.
4789 (when gnus-use-cross-reference
4790 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
4791 ;; Do adaptive scoring, and possibly save score files.
4792 (when gnus-newsgroup-adaptive
4793 (gnus-score-adaptive))
4794 (when gnus-use-scoring
4796 ;; Do not switch windows but change the buffer to work.
4797 (set-buffer gnus-group-buffer)
4798 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
4799 (gnus-group-update-group group)))))
4801 (defun gnus-summary-exit (&optional temporary)
4802 "Exit reading current newsgroup, and then return to group selection mode.
4803 gnus-exit-group-hook is called with no arguments if that value is non-nil."
4805 (gnus-set-global-variables)
4806 (gnus-kill-save-kill-buffer)
4807 (let* ((group gnus-newsgroup-name)
4808 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
4810 (buf (current-buffer)))
4811 (run-hooks 'gnus-summary-prepare-exit-hook)
4812 ;; If we have several article buffers, we kill them at exit.
4813 (unless gnus-single-article-buffer
4814 (gnus-kill-buffer gnus-original-article-buffer)
4815 (setq gnus-article-current nil))
4816 (when gnus-use-cache
4817 (gnus-cache-possibly-remove-articles)
4818 (gnus-cache-save-buffers))
4819 (gnus-async-prefetch-remove-group group)
4820 (when gnus-suppress-duplicates
4821 (gnus-dup-enter-articles))
4822 (when gnus-use-trees
4823 (gnus-tree-close group))
4824 ;; Make all changes in this group permanent.
4826 (gnus-summary-update-info))
4827 (gnus-close-group group)
4828 ;; Make sure where I was, and go to next newsgroup.
4829 (set-buffer gnus-group-buffer)
4831 (gnus-group-jump-to-group group))
4832 (run-hooks 'gnus-summary-exit-hook)
4834 (gnus-group-next-unread-group 1))
4837 ;; If we have several article buffers, we kill them at exit.
4838 (unless gnus-single-article-buffer
4839 (gnus-kill-buffer gnus-article-buffer)
4840 (gnus-kill-buffer gnus-original-article-buffer)
4841 (setq gnus-article-current nil))
4843 (if (not gnus-kill-summary-on-exit)
4844 (gnus-deaden-summary)
4845 ;; We set all buffer-local variables to nil. It is unclear why
4846 ;; this is needed, but if we don't, buffer-local variables are
4847 ;; not garbage-collected, it seems. This would the lead to en
4848 ;; ever-growing Emacs.
4849 (gnus-summary-clear-local-variables)
4850 (when (get-buffer gnus-article-buffer)
4851 (bury-buffer gnus-article-buffer))
4852 ;; We clear the global counterparts of the buffer-local
4853 ;; variables as well, just to be on the safe side.
4854 (set-buffer gnus-group-buffer)
4855 (gnus-summary-clear-local-variables)
4856 ;; Return to group mode buffer.
4857 (when (eq mode 'gnus-summary-mode)
4858 (gnus-kill-buffer buf)))
4859 (setq gnus-current-select-method gnus-select-method)
4860 (pop-to-buffer gnus-group-buffer)
4861 ;; Clear the current group name.
4862 (if (not quit-config)
4864 (gnus-group-jump-to-group group)
4865 (gnus-group-next-unread-group 1)
4866 (gnus-configure-windows 'group 'force))
4867 (gnus-handle-ephemeral-exit quit-config))
4869 (setq gnus-newsgroup-name nil)))))
4871 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
4872 (defun gnus-summary-exit-no-update (&optional no-questions)
4873 "Quit reading current newsgroup without updating read article info."
4875 (gnus-set-global-variables)
4876 (let* ((group gnus-newsgroup-name)
4877 (quit-config (gnus-group-quit-config group)))
4878 (when (or no-questions
4880 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
4881 ;; If we have several article buffers, we kill them at exit.
4882 (unless gnus-single-article-buffer
4883 (gnus-kill-buffer gnus-article-buffer)
4884 (gnus-kill-buffer gnus-original-article-buffer)
4885 (setq gnus-article-current nil))
4886 (if (not gnus-kill-summary-on-exit)
4887 (gnus-deaden-summary)
4888 (gnus-close-group group)
4889 (gnus-summary-clear-local-variables)
4890 (set-buffer gnus-group-buffer)
4891 (gnus-summary-clear-local-variables)
4892 (when (get-buffer gnus-summary-buffer)
4893 (kill-buffer gnus-summary-buffer)))
4894 (unless gnus-single-article-buffer
4895 (setq gnus-article-current nil))
4896 (when gnus-use-trees
4897 (gnus-tree-close group))
4898 (gnus-async-prefetch-remove-group group)
4899 (when (get-buffer gnus-article-buffer)
4900 (bury-buffer gnus-article-buffer))
4901 ;; Return to the group buffer.
4902 (gnus-configure-windows 'group 'force)
4903 ;; Clear the current group name.
4904 (setq gnus-newsgroup-name nil)
4905 (when (equal (gnus-group-group-name) group)
4906 (gnus-group-next-unread-group 1))
4908 (gnus-handle-ephemeral-exit quit-config)))))
4910 (defun gnus-handle-ephemeral-exit (quit-config)
4911 "Handle movement when leaving an ephemeral group. The state
4912 which existed when entering the ephemeral is reset."
4913 (if (not (buffer-name (car quit-config)))
4914 (gnus-configure-windows 'group 'force)
4915 (set-buffer (car quit-config))
4916 (cond ((eq major-mode 'gnus-summary-mode)
4917 (gnus-set-global-variables))
4918 ((eq major-mode 'gnus-article-mode)
4920 ;; The `gnus-summary-buffer' variable may point
4921 ;; to the old summary buffer when using a single
4923 (unless (gnus-buffer-live-p gnus-summary-buffer)
4924 (set-buffer gnus-group-buffer))
4925 (set-buffer gnus-summary-buffer)
4926 (gnus-set-global-variables))))
4927 (if (or (eq (cdr quit-config) 'article)
4928 (eq (cdr quit-config) 'pick))
4930 ;; The current article may be from the ephemeral group
4931 ;; thus it is best that we reload this article
4932 (gnus-summary-show-article)
4933 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
4934 (gnus-configure-windows 'pick 'force)
4935 (gnus-configure-windows (cdr quit-config) 'force)))
4936 (gnus-configure-windows (cdr quit-config) 'force))
4937 (when (eq major-mode 'gnus-summary-mode)
4938 (gnus-summary-next-subject 1 nil t)
4939 (gnus-summary-recenter)
4940 (gnus-summary-position-point))))
4944 (defvar gnus-dead-summary-mode-map nil)
4946 (unless gnus-dead-summary-mode-map
4947 (setq gnus-dead-summary-mode-map (make-keymap))
4948 (suppress-keymap gnus-dead-summary-mode-map)
4949 (substitute-key-definition
4950 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
4951 (let ((keys '("\C-d" "\r" "\177")))
4953 (define-key gnus-dead-summary-mode-map
4954 (pop keys) 'gnus-summary-wake-up-the-dead))))
4956 (defvar gnus-dead-summary-mode nil
4957 "Minor mode for Gnus summary buffers.")
4959 (defun gnus-dead-summary-mode (&optional arg)
4960 "Minor mode for Gnus summary buffers."
4962 (when (eq major-mode 'gnus-summary-mode)
4963 (make-local-variable 'gnus-dead-summary-mode)
4964 (setq gnus-dead-summary-mode
4965 (if (null arg) (not gnus-dead-summary-mode)
4966 (> (prefix-numeric-value arg) 0)))
4967 (when gnus-dead-summary-mode
4968 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
4969 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
4970 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
4971 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
4972 minor-mode-map-alist)))))
4974 (defun gnus-deaden-summary ()
4975 "Make the current summary buffer into a dead summary buffer."
4976 ;; Kill any previous dead summary buffer.
4977 (when (and gnus-dead-summary
4978 (buffer-name gnus-dead-summary))
4980 (set-buffer gnus-dead-summary)
4981 (when gnus-dead-summary-mode
4982 (kill-buffer (current-buffer)))))
4983 ;; Make this the current dead summary.
4984 (setq gnus-dead-summary (current-buffer))
4985 (gnus-dead-summary-mode 1)
4986 (let ((name (buffer-name)))
4987 (when (string-match "Summary" name)
4989 (concat (substring name 0 (match-beginning 0)) "Dead "
4990 (substring name (match-beginning 0)))
4993 (defun gnus-kill-or-deaden-summary (buffer)
4994 "Kill or deaden the summary BUFFER."
4995 (when (and (buffer-name buffer)
4996 (not gnus-single-article-buffer))
4999 (gnus-kill-buffer gnus-article-buffer)
5000 (gnus-kill-buffer gnus-original-article-buffer)))
5001 (cond (gnus-kill-summary-on-exit
5002 (when (and gnus-use-trees
5003 (and (get-buffer buffer)
5004 (buffer-name (get-buffer buffer))))
5006 (set-buffer (get-buffer buffer))
5007 (gnus-tree-close gnus-newsgroup-name)))
5008 (gnus-kill-buffer buffer))
5009 ((and (get-buffer buffer)
5010 (buffer-name (get-buffer buffer)))
5013 (gnus-deaden-summary)))))
5015 (defun gnus-summary-wake-up-the-dead (&rest args)
5016 "Wake up the dead summary buffer."
5018 (gnus-dead-summary-mode -1)
5019 (let ((name (buffer-name)))
5020 (when (string-match "Dead " name)
5022 (concat (substring name 0 (match-beginning 0))
5023 (substring name (match-end 0)))
5025 (gnus-message 3 "This dead summary is now alive again"))
5027 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5028 (defun gnus-summary-fetch-faq (&optional faq-dir)
5029 "Fetch the FAQ for the current group.
5030 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5034 (when current-prefix-arg
5036 "Faq dir: " (and (listp gnus-group-faq-directory)
5037 gnus-group-faq-directory)))))
5038 (let (gnus-faq-buffer)
5039 (when (setq gnus-faq-buffer
5040 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5041 (gnus-configure-windows 'summary-faq))))
5043 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5044 (defun gnus-summary-describe-group (&optional force)
5045 "Describe the current newsgroup."
5047 (gnus-group-describe-group force gnus-newsgroup-name))
5049 (defun gnus-summary-describe-briefly ()
5050 "Describe summary mode commands briefly."
5053 (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")))
5055 ;; Walking around group mode buffer from summary mode.
5057 (defun gnus-summary-next-group (&optional no-article target-group backward)
5058 "Exit current newsgroup and then select next unread newsgroup.
5059 If prefix argument NO-ARTICLE is non-nil, no article is selected
5060 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5061 previous group instead."
5063 (gnus-set-global-variables)
5064 ;; Stop pre-fetching.
5065 (gnus-async-halt-prefetch)
5066 (let ((current-group gnus-newsgroup-name)
5067 (current-buffer (current-buffer))
5069 ;; First we semi-exit this group to update Xrefs and all variables.
5070 ;; We can't do a real exit, because the window conf must remain
5071 ;; the same in case the user is prompted for info, and we don't
5072 ;; want the window conf to change before that...
5073 (gnus-summary-exit t)
5074 (while (not entered)
5075 ;; Then we find what group we are supposed to enter.
5076 (set-buffer gnus-group-buffer)
5077 (gnus-group-jump-to-group current-group)
5080 (if (eq gnus-keep-same-level 'best)
5081 (gnus-summary-best-group gnus-newsgroup-name)
5082 (gnus-summary-search-group backward gnus-keep-same-level))))
5083 (if (not target-group)
5084 ;; There are no further groups, so we return to the group
5087 (gnus-message 5 "Returning to the group buffer")
5089 (set-buffer current-buffer)
5091 (run-hooks 'gnus-group-no-more-groups-hook))
5092 ;; We try to enter the target group.
5093 (gnus-group-jump-to-group target-group)
5094 (let ((unreads (gnus-group-group-unread)))
5095 (if (and (or (eq t unreads)
5096 (and unreads (not (zerop unreads))))
5097 (gnus-summary-read-group
5098 target-group nil no-article current-buffer))
5100 (setq current-group target-group
5101 target-group nil)))))))
5103 (defun gnus-summary-prev-group (&optional no-article)
5104 "Exit current newsgroup and then select previous unread newsgroup.
5105 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5107 (gnus-summary-next-group no-article nil t))
5109 ;; Walking around summary lines.
5111 (defun gnus-summary-first-subject (&optional unread)
5112 "Go to the first unread subject.
5113 If UNREAD is non-nil, go to the first unread article.
5114 Returns the article selected or nil if there are no unread articles."
5119 ((null gnus-newsgroup-data)
5120 (gnus-message 3 "No articles in the group")
5122 ;; Pick the first article.
5124 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5125 (gnus-data-number (car gnus-newsgroup-data)))
5126 ;; No unread articles.
5127 ((null gnus-newsgroup-unreads)
5128 (gnus-message 3 "No more unread articles")
5130 ;; Find the first unread article.
5132 (let ((data gnus-newsgroup-data))
5134 (not (gnus-data-unread-p (car data))))
5135 (setq data (cdr data)))
5137 (goto-char (gnus-data-pos (car data)))
5138 (gnus-data-number (car data))))))
5139 (gnus-summary-position-point)))
5141 (defun gnus-summary-next-subject (n &optional unread dont-display)
5142 "Go to next N'th summary line.
5143 If N is negative, go to the previous N'th subject line.
5144 If UNREAD is non-nil, only unread articles are selected.
5145 The difference between N and the actual number of steps taken is
5148 (let ((backward (< n 0))
5152 (gnus-summary-find-prev unread)
5153 (gnus-summary-find-next unread)))
5156 (gnus-message 7 "No more%s articles"
5157 (if unread " unread" "")))
5158 (unless dont-display
5159 (gnus-summary-recenter)
5160 (gnus-summary-position-point))
5163 (defun gnus-summary-next-unread-subject (n)
5164 "Go to next N'th unread summary line."
5166 (gnus-summary-next-subject n t))
5168 (defun gnus-summary-prev-subject (n &optional unread)
5169 "Go to previous N'th summary line.
5170 If optional argument UNREAD is non-nil, only unread article is selected."
5172 (gnus-summary-next-subject (- n) unread))
5174 (defun gnus-summary-prev-unread-subject (n)
5175 "Go to previous N'th unread summary line."
5177 (gnus-summary-next-subject (- n) t))
5179 (defun gnus-summary-goto-subject (article &optional force silent)
5180 "Go the subject line of ARTICLE.
5181 If FORCE, also allow jumping to articles not currently shown."
5182 (interactive "nArticle number: ")
5184 (data (gnus-data-find article)))
5185 ;; We read in the article if we have to.
5188 (gnus-summary-insert-subject article (and (vectorp force) force) t)
5189 (setq data (gnus-data-find article)))
5194 (gnus-message 3 "Can't find article %d" article))
5196 (goto-char (gnus-data-pos data))
5199 ;; Walking around summary lines with displaying articles.
5201 (defun gnus-summary-expand-window (&optional arg)
5202 "Make the summary buffer take up the entire Emacs frame.
5203 Given a prefix, will force an `article' buffer configuration."
5205 (gnus-set-global-variables)
5207 (gnus-configure-windows 'article 'force)
5208 (gnus-configure-windows 'summary 'force)))
5210 (defun gnus-summary-display-article (article &optional all-header)
5211 "Display ARTICLE in article buffer."
5212 (gnus-set-global-variables)
5216 (if gnus-summary-display-article-function
5217 (funcall gnus-summary-display-article-function article all-header)
5218 (gnus-article-prepare article all-header))
5219 (run-hooks 'gnus-select-article-hook)
5220 (when (and gnus-current-article
5221 (not (zerop gnus-current-article)))
5222 (gnus-summary-goto-subject gnus-current-article))
5223 (gnus-summary-recenter)
5224 (when (and gnus-use-trees gnus-show-threads)
5225 (gnus-possibly-generate-tree article)
5226 (gnus-highlight-selected-tree article))
5227 ;; Successfully display article.
5228 (gnus-article-set-window-start
5229 (cdr (assq article gnus-newsgroup-bookmarks))))))
5231 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5232 "Select the current article.
5233 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5234 non-nil, the article will be re-fetched even if it already present in
5235 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5237 ;; Make sure we are in the summary buffer to work around bbdb bug.
5238 (unless (eq major-mode 'gnus-summary-mode)
5239 (set-buffer gnus-summary-buffer))
5240 (let ((article (or article (gnus-summary-article-number)))
5241 (all-headers (not (not all-headers))) ;Must be T or NIL.
5242 gnus-summary-display-article-function
5245 (gnus-summary-article-pseudo-p article)
5246 (error "This is a pseudo-article."))
5249 (set-buffer gnus-summary-buffer)
5250 (if (or (and gnus-single-article-buffer
5251 (or (null gnus-current-article)
5252 (null gnus-article-current)
5253 (null (get-buffer gnus-article-buffer))
5254 (not (eq article (cdr gnus-article-current)))
5255 (not (equal (car gnus-article-current)
5256 gnus-newsgroup-name))))
5257 (and (not gnus-single-article-buffer)
5258 (or (null gnus-current-article)
5259 (not (eq gnus-current-article article))))
5261 ;; The requested article is different from the current article.
5263 (gnus-summary-display-article article all-headers)
5265 (when (or all-headers gnus-show-all-headers)
5266 (gnus-article-show-all-headers))
5269 (gnus-article-set-window-start
5270 (cdr (assq article gnus-newsgroup-bookmarks)))))))
5272 (defun gnus-summary-set-current-mark (&optional current-mark)
5273 "Obsolete function."
5276 (defun gnus-summary-next-article (&optional unread subject backward push)
5277 "Select the next article.
5278 If UNREAD, only unread articles are selected.
5279 If SUBJECT, only articles with SUBJECT are selected.
5280 If BACKWARD, the previous article is selected instead of the next."
5282 (gnus-set-global-variables)
5284 ;; Is there such an article?
5285 ((and (gnus-summary-search-forward unread subject backward)
5286 (or (gnus-summary-display-article (gnus-summary-article-number))
5287 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5288 (gnus-summary-position-point))
5289 ;; If not, we try the first unread, if that is wanted.
5291 gnus-auto-select-same
5292 ;; Make sure that we don't select the current article.
5293 (not (eq (gnus-summary-article-number)
5295 (gnus-summary-first-subject t)
5296 (gnus-summary-article-number))))
5297 (gnus-summary-first-unread-article))
5298 (gnus-summary-position-point)
5299 (gnus-message 6 "Wrapped"))
5300 ;; Try to get next/previous article not displayed in this group.
5301 ((and gnus-auto-extend-newsgroup
5302 (not unread) (not subject))
5303 (gnus-summary-goto-article
5304 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5306 ;; Go to next/previous group.
5308 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5309 (gnus-summary-jump-to-group gnus-newsgroup-name))
5310 (let ((cmd last-command-char)
5312 (if (eq gnus-keep-same-level 'best)
5313 (gnus-summary-best-group gnus-newsgroup-name)
5314 (gnus-summary-search-group backward gnus-keep-same-level))))
5315 ;; For some reason, the group window gets selected. We change
5317 (select-window (get-buffer-window (current-buffer)))
5318 ;; Select next unread newsgroup automagically.
5320 ((or (not gnus-auto-select-next)
5322 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5323 ((or (eq gnus-auto-select-next 'quietly)
5324 (and (eq gnus-auto-select-next 'slightly-quietly)
5326 (and (eq gnus-auto-select-next 'almost-quietly)
5327 (gnus-summary-last-article-p)))
5329 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5331 (gnus-message 7 "No more%s articles (%s)..."
5332 (if unread " unread" "")
5333 (if group (concat "selecting " group)
5335 (gnus-summary-next-group nil group backward)))
5337 (gnus-summary-walk-group-buffer
5338 gnus-newsgroup-name cmd unread backward)))))))
5340 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
5341 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5342 (?\C-p (gnus-group-prev-unread-group 1))))
5343 (cursor-in-echo-area t)
5344 keve key group ended)
5346 (set-buffer gnus-group-buffer)
5347 (gnus-summary-jump-to-group from-group)
5349 (if (eq gnus-keep-same-level 'best)
5350 (gnus-summary-best-group gnus-newsgroup-name)
5351 (gnus-summary-search-group backward gnus-keep-same-level))))
5354 5 "No more%s articles%s" (if unread " unread" "")
5356 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5357 (format " (Type %s for %s [%s])"
5358 (single-key-description cmd) group
5359 (car (gnus-gethash group gnus-newsrc-hashtb)))
5360 (format " (Type %s to exit %s)"
5361 (single-key-description cmd)
5362 gnus-newsgroup-name)))
5363 ;; Confirm auto selection.
5364 (setq key (car (setq keve (gnus-read-event-char))))
5367 ((assq key keystrokes)
5368 (let ((obuf (current-buffer)))
5369 (switch-to-buffer gnus-group-buffer)
5371 (gnus-group-jump-to-group group))
5372 (eval (cadr (assq key keystrokes)))
5373 (setq group (gnus-group-group-name))
5374 (switch-to-buffer obuf))
5378 (gnus-ephemeral-group-p gnus-newsgroup-name))
5380 (gnus-summary-next-group nil group backward)))
5382 (push (cdr keve) unread-command-events))))))
5384 (defun gnus-summary-next-unread-article ()
5385 "Select unread article after current one."
5387 (gnus-summary-next-article
5388 (or (not (eq gnus-summary-goto-unread 'never))
5389 (gnus-summary-last-article-p (gnus-summary-article-number)))
5390 (and gnus-auto-select-same
5391 (gnus-summary-article-subject))))
5393 (defun gnus-summary-prev-article (&optional unread subject)
5394 "Select the article after the current one.
5395 If UNREAD is non-nil, only unread articles are selected."
5397 (gnus-summary-next-article unread subject t))
5399 (defun gnus-summary-prev-unread-article ()
5400 "Select unread article before current one."
5402 (gnus-summary-prev-article
5403 (or (not (eq gnus-summary-goto-unread 'never))
5404 (gnus-summary-first-article-p (gnus-summary-article-number)))
5405 (and gnus-auto-select-same
5406 (gnus-summary-article-subject))))
5408 (defun gnus-summary-next-page (&optional lines circular)
5409 "Show next page of the selected article.
5410 If at the end of the current article, select the next article.
5411 LINES says how many lines should be scrolled up.
5413 If CIRCULAR is non-nil, go to the start of the article instead of
5414 selecting the next article when reaching the end of the current
5417 (setq gnus-summary-buffer (current-buffer))
5418 (gnus-set-global-variables)
5419 (let ((article (gnus-summary-article-number))
5421 (gnus-configure-windows 'article)
5422 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
5423 (if (and (eq gnus-summary-goto-unread 'never)
5424 (not (gnus-summary-last-article-p article)))
5425 (gnus-summary-next-article)
5426 (gnus-summary-next-unread-article))
5427 (if (or (null gnus-current-article)
5428 (null gnus-article-current)
5429 (/= article (cdr gnus-article-current))
5430 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5431 ;; Selected subject is different from current article's.
5432 (gnus-summary-display-article article)
5433 (gnus-eval-in-buffer-window gnus-article-buffer
5434 (setq endp (gnus-article-next-page lines)))
5437 (gnus-summary-beginning-of-article))
5439 (gnus-message 3 "End of message"))
5441 (if (and (eq gnus-summary-goto-unread 'never)
5442 (not (gnus-summary-last-article-p article)))
5443 (gnus-summary-next-article)
5444 (gnus-summary-next-unread-article)))))))
5445 (gnus-summary-recenter)
5446 (gnus-summary-position-point)))
5448 (defun gnus-summary-prev-page (&optional lines)
5449 "Show previous page of selected article.
5450 Argument LINES specifies lines to be scrolled down."
5452 (gnus-set-global-variables)
5453 (let ((article (gnus-summary-article-number)))
5454 (gnus-configure-windows 'article)
5455 (if (or (null gnus-current-article)
5456 (null gnus-article-current)
5457 (/= article (cdr gnus-article-current))
5458 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5459 ;; Selected subject is different from current article's.
5460 (gnus-summary-display-article article)
5461 (gnus-summary-recenter)
5462 (gnus-eval-in-buffer-window gnus-article-buffer
5463 (gnus-article-prev-page lines))))
5464 (gnus-summary-position-point))
5466 (defun gnus-summary-scroll-up (lines)
5467 "Scroll up (or down) one line current article.
5468 Argument LINES specifies lines to be scrolled up (or down if negative)."
5470 (gnus-set-global-variables)
5471 (gnus-configure-windows 'article)
5472 (gnus-summary-show-thread)
5473 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
5474 (gnus-eval-in-buffer-window gnus-article-buffer
5476 (when (gnus-article-next-page lines)
5477 (gnus-message 3 "End of message")))
5479 (gnus-article-prev-page (- lines))))))
5480 (gnus-summary-recenter)
5481 (gnus-summary-position-point))
5483 (defun gnus-summary-next-same-subject ()
5484 "Select next article which has the same subject as current one."
5486 (gnus-set-global-variables)
5487 (gnus-summary-next-article nil (gnus-summary-article-subject)))
5489 (defun gnus-summary-prev-same-subject ()
5490 "Select previous article which has the same subject as current one."
5492 (gnus-set-global-variables)
5493 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
5495 (defun gnus-summary-next-unread-same-subject ()
5496 "Select next unread article which has the same subject as current one."
5498 (gnus-set-global-variables)
5499 (gnus-summary-next-article t (gnus-summary-article-subject)))
5501 (defun gnus-summary-prev-unread-same-subject ()
5502 "Select previous unread article which has the same subject as current one."
5504 (gnus-set-global-variables)
5505 (gnus-summary-prev-article t (gnus-summary-article-subject)))
5507 (defun gnus-summary-first-unread-article ()
5508 "Select the first unread article.
5509 Return nil if there are no unread articles."
5511 (gnus-set-global-variables)
5513 (when (gnus-summary-first-subject t)
5514 (gnus-summary-show-thread)
5515 (gnus-summary-first-subject t)
5516 (gnus-summary-display-article (gnus-summary-article-number)))
5517 (gnus-summary-position-point)))
5519 (defun gnus-summary-first-article ()
5520 "Select the first article.
5521 Return nil if there are no articles."
5523 (gnus-set-global-variables)
5525 (when (gnus-summary-first-subject)
5526 (gnus-summary-show-thread)
5527 (gnus-summary-first-subject)
5528 (gnus-summary-display-article (gnus-summary-article-number)))
5529 (gnus-summary-position-point)))
5531 (defun gnus-summary-best-unread-article ()
5532 "Select the unread article with the highest score."
5534 (gnus-set-global-variables)
5535 (let ((best -1000000)
5536 (data gnus-newsgroup-data)
5539 (and (gnus-data-unread-p (car data))
5541 (gnus-summary-article-score (gnus-data-number (car data))))
5544 article (gnus-data-number (car data))))
5545 (setq data (cdr data)))
5548 (gnus-summary-goto-article article)
5549 (error "No unread articles"))
5550 (gnus-summary-position-point))))
5552 (defun gnus-summary-last-subject ()
5553 "Go to the last displayed subject line in the group."
5554 (let ((article (gnus-data-number (car (gnus-data-list t)))))
5556 (gnus-summary-goto-subject article))))
5558 (defun gnus-summary-goto-article (article &optional all-headers force)
5559 "Fetch ARTICLE and display it if it exists.
5560 If ALL-HEADERS is non-nil, no header lines are hidden."
5566 (mapcar (lambda (number) (list (int-to-string number)))
5567 gnus-newsgroup-limit)))
5571 (if (gnus-summary-goto-subject article force)
5572 (gnus-summary-display-article article all-headers)
5573 (gnus-message 4 "Couldn't go to article %s" article) nil)
5574 (gnus-summary-position-point)))
5576 (defun gnus-summary-goto-last-article ()
5577 "Go to the previously read article."
5580 (when gnus-last-article
5581 (gnus-summary-goto-article gnus-last-article))
5582 (gnus-summary-position-point)))
5584 (defun gnus-summary-pop-article (number)
5585 "Pop one article off the history and go to the previous.
5586 NUMBER articles will be popped off."
5589 (setq gnus-newsgroup-history
5590 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
5592 (gnus-summary-goto-article (car to))
5593 (error "Article history empty")))
5594 (gnus-summary-position-point))
5596 ;; Summary commands and functions for limiting the summary buffer.
5598 (defun gnus-summary-limit-to-articles (n)
5599 "Limit the summary buffer to the next N articles.
5600 If not given a prefix, use the process marked articles instead."
5602 (gnus-set-global-variables)
5604 (let ((articles (gnus-summary-work-articles n)))
5605 (setq gnus-newsgroup-processable nil)
5606 (gnus-summary-limit articles))
5607 (gnus-summary-position-point)))
5609 (defun gnus-summary-pop-limit (&optional total)
5610 "Restore the previous limit.
5611 If given a prefix, remove all limits."
5613 (gnus-set-global-variables)
5615 (setq gnus-newsgroup-limits
5616 (list (mapcar (lambda (h) (mail-header-number h))
5617 gnus-newsgroup-headers))))
5618 (unless gnus-newsgroup-limits
5619 (error "No limit to pop"))
5621 (gnus-summary-limit nil 'pop)
5622 (gnus-summary-position-point)))
5624 (defun gnus-summary-limit-to-subject (subject &optional header)
5625 "Limit the summary buffer to articles that have subjects that match a regexp."
5626 (interactive "sRegexp: ")
5628 (setq header "subject"))
5629 (when (not (equal "" subject))
5631 (let ((articles (gnus-summary-find-matching
5632 (or header "subject") subject 'all)))
5634 (error "Found no matches for \"%s\"" subject))
5635 (gnus-summary-limit articles))
5636 (gnus-summary-position-point))))
5638 (defun gnus-summary-limit-to-author (from)
5639 "Limit the summary buffer to articles that have authors that match a regexp."
5640 (interactive "sRegexp: ")
5641 (gnus-summary-limit-to-subject from "from"))
5643 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5645 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5647 (defun gnus-summary-limit-to-unread (&optional all)
5648 "Limit the summary buffer to articles that are not marked as read.
5649 If ALL is non-nil, limit strictly to unread articles."
5652 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
5653 (gnus-summary-limit-to-marks
5654 ;; Concat all the marks that say that an article is read and have
5656 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
5657 gnus-killed-mark gnus-kill-file-mark
5658 gnus-low-score-mark gnus-expirable-mark
5659 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
5660 gnus-duplicate-mark)
5663 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
5664 (make-obsolete 'gnus-summary-delete-marked-with
5665 'gnus-summary-limit-exlude-marks)
5667 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
5668 "Exclude articles that are marked with MARKS (e.g. \"DK\").
5669 If REVERSE, limit the summary buffer to articles that are marked
5670 with MARKS. MARKS can either be a string of marks or a list of marks.
5671 Returns how many articles were removed."
5672 (interactive "sMarks: ")
5673 (gnus-summary-limit-to-marks marks t))
5675 (defun gnus-summary-limit-to-marks (marks &optional reverse)
5676 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
5677 If REVERSE (the prefix), limit the summary buffer to articles that are
5678 not marked with MARKS. MARKS can either be a string of marks or a
5680 Returns how many articles were removed."
5681 (interactive (list (read-string "Marks: ") current-prefix-arg))
5682 (gnus-set-global-variables)
5684 (let ((data gnus-newsgroup-data)
5685 (marks (if (listp marks) marks
5686 (append marks nil))) ; Transform to list.
5689 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
5690 (memq (gnus-data-mark (car data)) marks))
5691 (push (gnus-data-number (car data)) articles))
5692 (setq data (cdr data)))
5693 (gnus-summary-limit articles))
5694 (gnus-summary-position-point)))
5696 (defun gnus-summary-limit-to-score (&optional score)
5697 "Limit to articles with score at or above SCORE."
5699 (gnus-set-global-variables)
5700 (setq score (if score
5701 (prefix-numeric-value score)
5702 (or gnus-summary-default-score 0)))
5703 (let ((data gnus-newsgroup-data)
5706 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
5708 (push (gnus-data-number (car data)) articles))
5709 (setq data (cdr data)))
5711 (gnus-summary-limit articles)
5712 (gnus-summary-position-point))))
5714 (defun gnus-summary-limit-include-dormant ()
5715 "Display all the hidden articles that are marked as dormant."
5717 (gnus-set-global-variables)
5718 (unless gnus-newsgroup-dormant
5719 (error "There are no dormant articles in this group"))
5721 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
5722 (gnus-summary-position-point)))
5724 (defun gnus-summary-limit-exclude-dormant ()
5725 "Hide all dormant articles."
5727 (gnus-set-global-variables)
5729 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
5730 (gnus-summary-position-point)))
5732 (defun gnus-summary-limit-exclude-childless-dormant ()
5733 "Hide all dormant articles that have no children."
5735 (gnus-set-global-variables)
5736 (let ((data (gnus-data-list t))
5737 articles d children)
5738 ;; Find all articles that are either not dormant or have
5740 (while (setq d (pop data))
5741 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
5743 (gnus-article-children (gnus-data-number d)))
5746 (when (memq (car children) articles)
5751 (push (gnus-data-number d) articles)))
5754 (gnus-summary-limit articles)
5755 (gnus-summary-position-point))))
5757 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
5758 "Mark all unread excluded articles as read.
5759 If ALL, mark even excluded ticked and dormants as read."
5761 (let ((articles (gnus-sorted-complement
5763 (mapcar (lambda (h) (mail-header-number h))
5764 gnus-newsgroup-headers)
5766 (sort gnus-newsgroup-limit '<)))
5768 (setq gnus-newsgroup-unreads nil)
5770 (setq gnus-newsgroup-dormant nil
5771 gnus-newsgroup-marked nil
5772 gnus-newsgroup-reads
5774 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
5775 gnus-newsgroup-reads))
5776 (while (setq article (pop articles))
5777 (unless (or (memq article gnus-newsgroup-dormant)
5778 (memq article gnus-newsgroup-marked))
5779 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
5781 (defun gnus-summary-limit (articles &optional pop)
5783 ;; We pop the previous limit off the stack and use that.
5784 (setq articles (car gnus-newsgroup-limits)
5785 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
5786 ;; We use the new limit, so we push the old limit on the stack.
5787 (push gnus-newsgroup-limit gnus-newsgroup-limits))
5789 (setq gnus-newsgroup-limit articles)
5790 (let ((total (length gnus-newsgroup-data))
5791 (data (gnus-data-find-list (gnus-summary-article-number)))
5792 (gnus-summary-mark-below nil) ; Inhibit this.
5794 ;; This will do all the work of generating the new summary buffer
5795 ;; according to the new limit.
5796 (gnus-summary-prepare)
5797 ;; Hide any threads, possibly.
5798 (and gnus-show-threads
5799 gnus-thread-hide-subtree
5800 (gnus-summary-hide-all-threads))
5801 ;; Try to return to the article you were at, or one in the
5804 ;; We try to find some article after the current one.
5806 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
5809 (setq data (cdr data))))
5811 ;; If there is no data, that means that we were after the last
5812 ;; article. The same goes when we can't find any articles
5813 ;; after the current one.
5814 (goto-char (point-max))
5815 (gnus-summary-find-prev))
5816 ;; We return how many articles were removed from the summary
5817 ;; buffer as a result of the new limit.
5818 (- total (length gnus-newsgroup-data))))
5820 (defsubst gnus-invisible-cut-children (threads)
5823 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
5828 (defsubst gnus-cut-thread (thread)
5829 "Go forwards in the thread until we find an article that we want to display."
5830 (when (or (eq gnus-fetch-old-headers 'some)
5831 (eq gnus-build-sparse-threads 'some)
5832 (eq gnus-build-sparse-threads 'more))
5833 ;; Deal with old-fetched headers and sparse threads.
5837 (memq (mail-header-number (car thread)) gnus-newsgroup-sparse)
5838 (memq (mail-header-number (car thread)) gnus-newsgroup-ancient))
5839 (or (<= (length (cdr thread)) 1)
5840 (gnus-invisible-cut-children (cdr thread))))
5841 (setq thread (cadr thread))))
5844 (defun gnus-cut-threads (threads)
5845 "Cut off all uninteresting articles from the beginning of threads."
5846 (when (or (eq gnus-fetch-old-headers 'some)
5847 (eq gnus-build-sparse-threads 'some)
5848 (eq gnus-build-sparse-threads 'more))
5851 (setcar th (gnus-cut-thread (car th)))
5852 (setq th (cdr th)))))
5853 ;; Remove nixed out threads.
5856 (defun gnus-summary-initial-limit (&optional show-if-empty)
5857 "Figure out what the initial limit is supposed to be on group entry.
5858 This entails weeding out unwanted dormants, low-scored articles,
5859 fetch-old-headers verbiage, and so on."
5860 ;; Most groups have nothing to remove.
5861 (if (or gnus-inhibit-limiting
5862 (and (null gnus-newsgroup-dormant)
5863 (not (eq gnus-fetch-old-headers 'some))
5864 (null gnus-summary-expunge-below)
5865 (not (eq gnus-build-sparse-threads 'some))
5866 (not (eq gnus-build-sparse-threads 'more))
5867 (null gnus-thread-expunge-below)
5868 (not gnus-use-nocem)))
5870 (push gnus-newsgroup-limit gnus-newsgroup-limits)
5871 (setq gnus-newsgroup-limit nil)
5874 (unless (car (symbol-value node))
5875 ;; These threads have no parents -- they are roots.
5876 (let ((nodes (cdr (symbol-value node)))
5879 (if (and gnus-thread-expunge-below
5880 (< (gnus-thread-total-score (car nodes))
5881 gnus-thread-expunge-below))
5882 (gnus-expunge-thread (pop nodes))
5883 (setq thread (pop nodes))
5884 (gnus-summary-limit-children thread))))))
5885 gnus-newsgroup-dependencies)
5886 ;; If this limitation resulted in an empty group, we might
5887 ;; pop the previous limit and use it instead.
5888 (when (and (not gnus-newsgroup-limit)
5890 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
5891 gnus-newsgroup-limit))
5893 (defun gnus-summary-limit-children (thread)
5894 "Return 1 if this subthread is visible and 0 if it is not."
5895 ;; First we get the number of visible children to this thread. This
5896 ;; is done by recursing down the thread using this function, so this
5897 ;; will really go down to a leaf article first, before slowly
5898 ;; working its way up towards the root.
5902 (apply '+ (mapcar 'gnus-summary-limit-children
5905 (number (mail-header-number (car thread)))
5908 (not (memq number gnus-newsgroup-marked))
5910 ;; If this article is dormant and has absolutely no visible
5911 ;; children, then this article isn't visible.
5912 (and (memq number gnus-newsgroup-dormant)
5914 ;; If this is "fetch-old-headered" and there is only one
5915 ;; visible child (or less), then we don't want this article.
5916 (and (eq gnus-fetch-old-headers 'some)
5917 (memq number gnus-newsgroup-ancient)
5919 ;; If this is a sparsely inserted article with no children,
5920 ;; we don't want it.
5921 (and (eq gnus-build-sparse-threads 'some)
5922 (memq number gnus-newsgroup-sparse)
5924 ;; If we use expunging, and this article is really
5925 ;; low-scored, then we don't want this article.
5926 (when (and gnus-summary-expunge-below
5928 (or (cdr (assq number gnus-newsgroup-scored))
5929 gnus-summary-default-score))
5930 gnus-summary-expunge-below))
5931 ;; We increase the expunge-tally here, but that has
5932 ;; nothing to do with the limits, really.
5933 (incf gnus-newsgroup-expunged-tally)
5934 ;; We also mark as read here, if that's wanted.
5935 (when (and gnus-summary-mark-below
5936 (< score gnus-summary-mark-below))
5937 (setq gnus-newsgroup-unreads
5938 (delq number gnus-newsgroup-unreads))
5939 (if gnus-newsgroup-auto-expire
5940 (push number gnus-newsgroup-expirable)
5941 (push (cons number gnus-low-score-mark)
5942 gnus-newsgroup-reads)))
5944 ;; Check NoCeM things.
5946 (gnus-nocem-unwanted-article-p
5947 (mail-header-id (car thread))))))
5948 ;; Nope, invisible article.
5950 ;; Ok, this article is to be visible, so we add it to the limit
5952 (push number gnus-newsgroup-limit)
5955 (defun gnus-expunge-thread (thread)
5956 "Mark all articles in THREAD as read."
5957 (let* ((number (mail-header-number (car thread))))
5958 (incf gnus-newsgroup-expunged-tally)
5959 ;; We also mark as read here, if that's wanted.
5960 (setq gnus-newsgroup-unreads
5961 (delq number gnus-newsgroup-unreads))
5962 (if gnus-newsgroup-auto-expire
5963 (push number gnus-newsgroup-expirable)
5964 (push (cons number gnus-low-score-mark)
5965 gnus-newsgroup-reads)))
5966 ;; Go recursively through all subthreads.
5967 (mapcar 'gnus-expunge-thread (cdr thread)))
5969 ;; Summary article oriented commands
5971 (defun gnus-summary-refer-parent-article (n)
5972 "Refer parent article N times.
5973 If N is negative, go to ancestor -N instead.
5974 The difference between N and the number of articles fetched is returned."
5976 (gnus-set-global-variables)
5979 (when (not (natnump n))
5984 (setq header (gnus-summary-article-header))
5986 ;; If we try to find the parent of the currently
5987 ;; displayed article, then we take a look at the actual
5988 ;; References header, since this is slightly more
5989 ;; reliable than the References field we got from the
5991 (if (and (eq (mail-header-number header)
5992 (cdr gnus-article-current))
5993 (equal gnus-newsgroup-name
5994 (car gnus-article-current)))
5996 (set-buffer gnus-original-article-buffer)
5997 (nnheader-narrow-to-headers)
5999 (message-fetch-field "references")
6001 ;; It's not the current article, so we take a bet on
6002 ;; the value we got from the server.
6003 (mail-header-references header)))
6005 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6006 (gnus-message 1 "Couldn't find parent"))
6007 (gnus-message 1 "No references in article %d"
6008 (gnus-summary-article-number))
6011 (gnus-summary-position-point)
6014 (defun gnus-summary-refer-references ()
6015 "Fetch all articles mentioned in the References header.
6016 Return how many articles were fetched."
6018 (gnus-set-global-variables)
6019 (let ((ref (mail-header-references (gnus-summary-article-header)))
6020 (current (gnus-summary-article-number))
6022 ;; For each Message-ID in the References header...
6023 (while (string-match "<[^>]*>" ref)
6025 ;; ... fetch that article.
6026 (gnus-summary-refer-article
6027 (prog1 (match-string 0 ref)
6028 (setq ref (substring ref (match-end 0))))))
6029 (gnus-summary-goto-subject current)
6030 (gnus-summary-position-point)
6033 (defun gnus-summary-refer-article (message-id)
6034 "Fetch an article specified by MESSAGE-ID."
6035 (interactive "sMessage-ID: ")
6036 (when (and (stringp message-id)
6037 (not (zerop (length message-id))))
6038 ;; Construct the correct Message-ID if necessary.
6039 ;; Suggested by tale@pawl.rpi.edu.
6040 (unless (string-match "^<" message-id)
6041 (setq message-id (concat "<" message-id)))
6042 (unless (string-match ">$" message-id)
6043 (setq message-id (concat message-id ">")))
6044 (let* ((header (gnus-id-to-header message-id))
6046 (memq (mail-header-number header)
6047 gnus-newsgroup-sparse))))
6050 ;; The article is present in the buffer, to we just go to it.
6051 (gnus-summary-goto-article
6052 (mail-header-number header) nil header)
6054 (gnus-summary-update-article (mail-header-number header))))
6055 ;; We fetch the article
6056 (let ((gnus-override-method
6057 (and (gnus-news-group-p gnus-newsgroup-name)
6058 gnus-refer-article-method))
6060 ;; Start the special refer-article method, if necessary.
6061 (when (and gnus-refer-article-method
6062 (gnus-news-group-p gnus-newsgroup-name))
6063 (gnus-check-server gnus-refer-article-method))
6064 ;; Fetch the header, and display the article.
6065 (if (setq number (gnus-summary-insert-subject message-id))
6066 (gnus-summary-select-article nil nil nil number)
6067 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
6069 (defun gnus-summary-enter-digest-group (&optional force)
6070 "Enter an nndoc group based on the current article.
6071 If FORCE, force a digest interpretation. If not, try
6072 to guess what the document format is."
6074 (gnus-set-global-variables)
6075 (let ((conf gnus-current-window-configuration))
6077 (gnus-summary-select-article))
6078 (setq gnus-current-window-configuration conf)
6079 (let* ((name (format "%s-%d"
6080 (gnus-group-prefixed-name
6081 gnus-newsgroup-name (list 'nndoc ""))
6083 (set-buffer gnus-summary-buffer)
6084 gnus-current-article)))
6085 (ogroup gnus-newsgroup-name)
6086 (params (append (gnus-info-params (gnus-get-info ogroup))
6087 (list (cons 'to-group ogroup))))
6088 (case-fold-search t)
6089 (buf (current-buffer))
6092 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6093 (insert-buffer-substring gnus-original-article-buffer)
6094 ;; Remove lines that may lead nndoc to misinterpret the
6097 (goto-char (point-min))
6098 (or (search-forward "\n\n" nil t) (point)))
6099 (goto-char (point-min))
6100 (delete-matching-lines "^\\(Path\\):\\|^From ")
6103 (if (gnus-group-read-ephemeral-group
6104 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6106 ,(if force 'digest 'guess))) t)
6107 ;; Make all postings to this group go to the parent group.
6108 (nconc (gnus-info-params (gnus-get-info name))
6110 ;; Couldn't select this doc group.
6111 (switch-to-buffer buf)
6112 (gnus-set-global-variables)
6113 (gnus-configure-windows 'summary)
6114 (gnus-message 3 "Article couldn't be entered?"))
6115 (kill-buffer dig)))))
6117 (defun gnus-summary-read-document (n)
6118 "Open a new group based on the current article(s).
6119 This will allow you to read digests and other similar
6120 documents as newsgroups.
6121 Obeys the standard process/prefix convention."
6123 (let* ((articles (gnus-summary-work-articles n))
6124 (ogroup gnus-newsgroup-name)
6125 (params (append (gnus-info-params (gnus-get-info ogroup))
6126 (list (cons 'to-group ogroup))))
6127 article group egroup groups vgroup)
6128 (while (setq article (pop articles))
6129 (setq group (format "%s-%d" gnus-newsgroup-name article))
6130 (gnus-summary-remove-process-mark article)
6131 (when (gnus-summary-display-article article)
6133 (nnheader-temp-write nil
6134 (insert-buffer-substring gnus-original-article-buffer)
6135 ;; Remove some headers that may lead nndoc to make
6137 (message-narrow-to-head)
6138 (goto-char (point-min))
6139 (delete-matching-lines "^\\(Path\\):\\|^From ")
6142 (gnus-group-read-ephemeral-group
6143 group `(nndoc ,group (nndoc-address ,(current-buffer))
6144 (nndoc-article-type guess))
6147 ;; Make all postings to this group go to the parent group.
6148 (nconc (gnus-info-params (gnus-get-info egroup))
6150 (push egroup groups))
6151 ;; Couldn't select this doc group.
6152 (gnus-error 3 "Article couldn't be entered"))))))
6153 ;; Now we have selected all the documents.
6156 (error "None of the articles could be interpreted as documents"))
6157 ((gnus-group-read-ephemeral-group
6158 (setq vgroup (format
6159 "nnvirtual:%s-%s" gnus-newsgroup-name
6160 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6161 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6163 (cons (current-buffer) 'summary)))
6165 (error "Couldn't select virtual nndoc group")))))
6167 (defun gnus-summary-isearch-article (&optional regexp-p)
6168 "Do incremental search forward on the current article.
6169 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6171 (gnus-set-global-variables)
6172 (gnus-summary-select-article)
6173 (gnus-configure-windows 'article)
6174 (gnus-eval-in-buffer-window gnus-article-buffer
6175 ;;(goto-char (point-min))
6176 (isearch-forward regexp-p)))
6178 (defun gnus-summary-search-article-forward (regexp &optional backward)
6179 "Search for an article containing REGEXP forward.
6180 If BACKWARD, search backward instead."
6183 (format "Search article %s (regexp%s): "
6184 (if current-prefix-arg "backward" "forward")
6185 (if gnus-last-search-regexp
6186 (concat ", default " gnus-last-search-regexp)
6188 current-prefix-arg))
6189 (gnus-set-global-variables)
6190 (if (string-equal regexp "")
6191 (setq regexp (or gnus-last-search-regexp ""))
6192 (setq gnus-last-search-regexp regexp))
6193 (if (gnus-summary-search-article regexp backward)
6194 (gnus-summary-show-thread)
6195 (error "Search failed: \"%s\"" regexp)))
6197 (defun gnus-summary-search-article-backward (regexp)
6198 "Search for an article containing REGEXP backward."
6201 (format "Search article backward (regexp%s): "
6202 (if gnus-last-search-regexp
6203 (concat ", default " gnus-last-search-regexp)
6205 (gnus-summary-search-article-forward regexp 'backward))
6207 (defun gnus-summary-search-article (regexp &optional backward)
6208 "Search for an article containing REGEXP.
6209 Optional argument BACKWARD means do search for backward.
6210 `gnus-select-article-hook' is not called during the search."
6211 (let ((gnus-select-article-hook nil) ;Disable hook.
6212 (gnus-article-display-hook nil)
6213 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6214 (gnus-use-article-prefetch nil)
6215 (sum (current-buffer))
6218 (gnus-save-hidden-threads
6219 (gnus-summary-select-article)
6220 (set-buffer gnus-article-buffer)
6224 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
6226 (re-search-backward regexp nil t)
6227 (re-search-forward regexp nil t))
6228 ;; We found the regexp.
6233 (get-buffer-window (current-buffer))
6237 (setq point (point)))
6238 ;; We didn't find it, so we go to the next article.
6240 (if (not (if backward (gnus-summary-find-prev)
6241 (gnus-summary-find-next)))
6242 ;; No more articles.
6244 ;; Select the next article and adjust point.
6245 (gnus-summary-select-article)
6246 (set-buffer gnus-article-buffer)
6248 (goto-char (if backward (point-max) (point-min))))))
6249 (gnus-message 7 ""))
6250 ;; Return whether we found the regexp.
6251 (when (eq found 'found)
6253 (gnus-summary-show-thread)
6254 (gnus-summary-goto-subject gnus-current-article)
6255 (gnus-summary-position-point)
6258 (defun gnus-summary-find-matching (header regexp &optional backward unread
6260 "Return a list of all articles that match REGEXP on HEADER.
6261 The search stars on the current article and goes forwards unless
6262 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
6263 If UNREAD is non-nil, only unread articles will
6264 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
6265 in the comparisons."
6266 (let ((data (if (eq backward 'all) gnus-newsgroup-data
6267 (gnus-data-find-list
6268 (gnus-summary-article-number) (gnus-data-list backward))))
6269 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
6270 (case-fold-search (not not-case-fold))
6272 (unless (fboundp (intern (concat "mail-header-" header)))
6273 (error "%s is not a valid header" header))
6276 (and (or (not unread) ; We want all articles...
6277 (gnus-data-unread-p d)) ; Or just unreads.
6278 (vectorp (gnus-data-header d)) ; It's not a pseudo.
6279 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
6280 (push (gnus-data-number d) articles)) ; Success!
6281 (setq data (cdr data)))
6282 (nreverse articles)))
6284 (defun gnus-summary-execute-command (header regexp command &optional backward)
6285 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
6286 If HEADER is an empty string (or nil), the match is done on the entire
6287 article. If BACKWARD (the prefix) is non-nil, search backward instead."
6289 (list (let ((completion-ignore-case t))
6292 (mapcar (lambda (string) (list string))
6293 '("Number" "Subject" "From" "Lines" "Date"
6294 "Message-ID" "Xref" "References" "Body"))
6295 nil 'require-match))
6296 (read-string "Regexp: ")
6297 (read-key-sequence "Command: ")
6298 current-prefix-arg))
6299 (when (equal header "Body")
6301 (gnus-set-global-variables)
6302 ;; Hidden thread subtrees must be searched as well.
6303 (gnus-summary-show-all-threads)
6304 ;; We don't want to change current point nor window configuration.
6306 (save-window-excursion
6307 (gnus-message 6 "Executing %s..." (key-description command))
6308 ;; We'd like to execute COMMAND interactively so as to give arguments.
6309 (gnus-execute header regexp
6310 `(call-interactively ',(key-binding command))
6312 (gnus-message 6 "Executing %s...done" (key-description command)))))
6314 (defun gnus-summary-beginning-of-article ()
6315 "Scroll the article back to the beginning."
6317 (gnus-set-global-variables)
6318 (gnus-summary-select-article)
6319 (gnus-configure-windows 'article)
6320 (gnus-eval-in-buffer-window gnus-article-buffer
6322 (goto-char (point-min))
6323 (when gnus-break-pages
6324 (gnus-narrow-to-page))))
6326 (defun gnus-summary-end-of-article ()
6327 "Scroll to the end of the article."
6329 (gnus-set-global-variables)
6330 (gnus-summary-select-article)
6331 (gnus-configure-windows 'article)
6332 (gnus-eval-in-buffer-window gnus-article-buffer
6334 (goto-char (point-max))
6336 (when gnus-break-pages
6337 (gnus-narrow-to-page))))
6339 (defun gnus-summary-show-article (&optional arg)
6340 "Force re-fetching of the current article.
6341 If ARG (the prefix) is non-nil, show the raw article without any
6342 article massaging functions being run."
6344 (gnus-set-global-variables)
6346 ;; Select the article the normal way.
6347 (gnus-summary-select-article nil 'force)
6348 ;; Bind the article treatment functions to nil.
6349 (let ((gnus-have-all-headers t)
6350 gnus-article-display-hook
6351 gnus-article-prepare-hook
6354 (gnus-summary-select-article nil 'force)))
6355 (gnus-summary-goto-subject gnus-current-article)
6356 ; (gnus-configure-windows 'article)
6357 (gnus-summary-position-point))
6359 (defun gnus-summary-verbose-headers (&optional arg)
6360 "Toggle permanent full header display.
6361 If ARG is a positive number, turn header display on.
6362 If ARG is a negative number, turn header display off."
6364 (gnus-set-global-variables)
6365 (setq gnus-show-all-headers
6366 (cond ((or (not (numberp arg))
6368 (not gnus-show-all-headers))
6371 (gnus-summary-show-article))
6373 (defun gnus-summary-toggle-header (&optional arg)
6374 "Show the headers if they are hidden, or hide them if they are shown.
6375 If ARG is a positive number, show the entire header.
6376 If ARG is a negative number, hide the unwanted header lines."
6378 (gnus-set-global-variables)
6380 (set-buffer gnus-article-buffer)
6381 (let* ((buffer-read-only nil)
6382 (inhibit-point-motion-hooks t)
6383 (hidden (text-property-any
6384 (goto-char (point-min)) (search-forward "\n\n")
6387 (goto-char (point-min))
6388 (when (search-forward "\n\n" nil t)
6389 (delete-region (point-min) (1- (point))))
6390 (goto-char (point-min))
6392 (set-buffer gnus-original-article-buffer)
6393 (goto-char (point-min))
6394 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
6395 (insert-buffer-substring gnus-original-article-buffer 1 e)
6396 (let ((article-inhibit-hiding t))
6397 (run-hooks 'gnus-article-display-hook))
6398 (when (or (not hidden) (and (numberp arg) (< arg 0)))
6399 (gnus-article-hide-headers)))))
6401 (defun gnus-summary-show-all-headers ()
6402 "Make all header lines visible."
6404 (gnus-set-global-variables)
6405 (gnus-article-show-all-headers))
6407 (defun gnus-summary-toggle-mime (&optional arg)
6408 "Toggle MIME processing.
6409 If ARG is a positive number, turn MIME processing on."
6411 (gnus-set-global-variables)
6412 (setq gnus-show-mime
6413 (if (null arg) (not gnus-show-mime)
6414 (> (prefix-numeric-value arg) 0)))
6415 (gnus-summary-select-article t 'force))
6417 (defun gnus-summary-caesar-message (&optional arg)
6418 "Caesar rotate the current article by 13.
6419 The numerical prefix specifies how manu places to rotate each letter
6422 (gnus-set-global-variables)
6423 (gnus-summary-select-article)
6424 (let ((mail-header-separator ""))
6425 (gnus-eval-in-buffer-window gnus-article-buffer
6428 (let ((start (window-start))
6430 (message-caesar-buffer-body arg)
6431 (set-window-start (get-buffer-window (current-buffer)) start))))))
6433 (defun gnus-summary-stop-page-breaking ()
6434 "Stop page breaking in the current article."
6436 (gnus-set-global-variables)
6437 (gnus-summary-select-article)
6438 (gnus-eval-in-buffer-window gnus-article-buffer
6440 (when (gnus-visual-p 'page-marker)
6441 (let ((buffer-read-only nil))
6442 (gnus-remove-text-with-property 'gnus-prev)
6443 (gnus-remove-text-with-property 'gnus-next)))))
6445 (defun gnus-summary-move-article (&optional n to-newsgroup
6446 select-method action)
6447 "Move the current article to a different newsgroup.
6448 If N is a positive number, move the N next articles.
6449 If N is a negative number, move the N previous articles.
6450 If N is nil and any articles have been marked with the process mark,
6451 move those articles instead.
6452 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6453 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6454 re-spool using this method.
6456 For this function to work, both the current newsgroup and the
6457 newsgroup that you want to move to have to support the `request-move'
6458 and `request-accept' functions."
6461 (setq action 'move))
6462 (gnus-set-global-variables)
6463 ;; Check whether the source group supports the required functions.
6464 (cond ((and (eq action 'move)
6465 (not (gnus-check-backend-function
6466 'request-move-article gnus-newsgroup-name)))
6467 (error "The current group does not support article moving"))
6468 ((and (eq action 'crosspost)
6469 (not (gnus-check-backend-function
6470 'request-replace-article gnus-newsgroup-name)))
6471 (error "The current group does not support article editing")))
6472 (let ((articles (gnus-summary-work-articles n))
6473 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
6474 (names '((move "Move" "Moving")
6475 (copy "Copy" "Copying")
6476 (crosspost "Crosspost" "Crossposting")))
6477 (copy-buf (save-excursion
6478 (nnheader-set-temp-buffer " *copy article*")))
6479 art-group to-method new-xref article to-groups)
6480 (unless (assq action names)
6481 (error "Unknown action %s" action))
6482 ;; Read the newsgroup name.
6483 (when (and (not to-newsgroup)
6484 (not select-method))
6486 (gnus-read-move-group-name
6487 (cadr (assq action names))
6488 (symbol-value (intern (format "gnus-current-%s-group" action)))
6490 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
6491 (setq to-method (or select-method
6492 (gnus-group-name-to-method to-newsgroup)))
6493 ;; Check the method we are to move this article to...
6494 (unless (gnus-check-backend-function
6495 'request-accept-article (car to-method))
6496 (error "%s does not support article copying" (car to-method)))
6497 (unless (gnus-check-server to-method)
6498 (error "Can't open server %s" (car to-method)))
6499 (gnus-message 6 "%s to %s: %s..."
6500 (caddr (assq action names))
6501 (or (car select-method) to-newsgroup) articles)
6503 (setq article (pop articles))
6507 ;; Move the article.
6509 (gnus-request-move-article
6510 article ; Article to move
6511 gnus-newsgroup-name ; From newsgroup
6512 (nth 1 (gnus-find-method-for-group
6513 gnus-newsgroup-name)) ; Server
6514 (list 'gnus-request-accept-article
6515 to-newsgroup (list 'quote select-method)
6516 (not articles)) ; Accept form
6517 (not articles))) ; Only save nov last time
6518 ;; Copy the article.
6521 (set-buffer copy-buf)
6522 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6523 (gnus-request-accept-article
6524 to-newsgroup select-method (not articles))))
6525 ;; Crosspost the article.
6526 ((eq action 'crosspost)
6527 (let ((xref (mail-header-xref (gnus-summary-article-header article))))
6528 (setq new-xref (concat gnus-newsgroup-name ":" article))
6529 (if (and xref (not (string= xref "")))
6531 (when (string-match "^Xref: " xref)
6532 (setq xref (substring xref (match-end 0))))
6533 (setq new-xref (concat xref " " new-xref)))
6534 (setq new-xref (concat (system-name) " " new-xref)))
6536 (set-buffer copy-buf)
6537 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6538 (nnheader-replace-header "xref" new-xref)
6539 (gnus-request-accept-article
6540 to-newsgroup select-method (not articles)))))))
6542 (gnus-message 1 "Couldn't %s article %s"
6543 (cadr (assq action names)) article)
6546 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
6548 (gnus-group-prefixed-name
6551 (gnus-find-method-for-group to-newsgroup)))
6552 gnus-newsrc-hashtb)))
6553 (info (nth 2 entry))
6554 (to-group (gnus-info-group info)))
6555 ;; Update the group that has been moved to.
6557 (memq action '(move copy)))
6558 (unless (member to-group to-groups)
6559 (push to-group to-groups))
6561 (unless (memq article gnus-newsgroup-unreads)
6563 info (gnus-add-to-range (gnus-info-read info)
6564 (list (cdr art-group)))))
6566 ;; Copy any marks over to the new group.
6567 (let ((marks gnus-article-mark-lists)
6568 (to-article (cdr art-group)))
6570 ;; See whether the article is to be put in the cache.
6571 (when gnus-use-cache
6572 (gnus-cache-possibly-enter-article
6574 (let ((header (copy-sequence
6575 (gnus-summary-article-header article))))
6576 (mail-header-set-number header to-article)
6578 (memq article gnus-newsgroup-marked)
6579 (memq article gnus-newsgroup-dormant)
6580 (memq article gnus-newsgroup-unreads)))
6583 (when (memq article (symbol-value
6584 (intern (format "gnus-newsgroup-%s"
6586 ;; If the other group is the same as this group,
6587 ;; then we have to add the mark to the list.
6588 (when (equal to-group gnus-newsgroup-name)
6589 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
6592 (intern (format "gnus-newsgroup-%s"
6594 ;; Copy mark to other group.
6595 (gnus-add-marked-articles
6596 to-group (cdar marks) (list to-article) info))
6597 (setq marks (cdr marks)))))
6599 ;; Update the Xref header in this article to point to
6600 ;; the new crossposted article we have just created.
6601 (when (eq action 'crosspost)
6603 (set-buffer copy-buf)
6604 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6605 (nnheader-replace-header
6606 "xref" (concat new-xref " " (gnus-group-prefixed-name
6607 (car art-group) to-method)
6608 ":" (cdr art-group)))
6609 (gnus-request-replace-article
6610 article gnus-newsgroup-name (current-buffer)))))
6612 (gnus-summary-goto-subject article)
6613 (when (eq action 'move)
6614 (gnus-summary-mark-article article gnus-canceled-mark)))
6615 (gnus-summary-remove-process-mark article))
6616 ;; Re-activate all groups that have been moved to.
6618 (gnus-activate-group (pop to-groups)))
6620 (gnus-kill-buffer copy-buf)
6621 (gnus-summary-position-point)
6622 (gnus-set-mode-line 'summary)))
6624 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
6625 "Move the current article to a different newsgroup.
6626 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6627 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6628 re-spool using this method."
6630 (gnus-summary-move-article n nil select-method 'copy))
6632 (defun gnus-summary-crosspost-article (&optional n)
6633 "Crosspost the current article to some other group."
6635 (gnus-summary-move-article n nil nil 'crosspost))
6637 (defvar gnus-summary-respool-default-method nil
6638 "Default method for respooling an article.
6639 If nil, use to the current newsgroup method.")
6641 (defun gnus-summary-respool-article (&optional n method)
6642 "Respool the current article.
6643 The article will be squeezed through the mail spooling process again,
6644 which means that it will be put in some mail newsgroup or other
6645 depending on `nnmail-split-methods'.
6646 If N is a positive number, respool the N next articles.
6647 If N is a negative number, respool the N previous articles.
6648 If N is nil and any articles have been marked with the process mark,
6649 respool those articles instead.
6651 Respooling can be done both from mail groups and \"real\" newsgroups.
6652 In the former case, the articles in question will be moved from the
6653 current group into whatever groups they are destined to. In the
6654 latter case, they will be copied into the relevant groups."
6656 (list current-prefix-arg
6657 (let* ((methods (gnus-methods-using 'respool))
6659 (symbol-name (or gnus-summary-respool-default-method
6660 (car (gnus-find-method-for-group
6661 gnus-newsgroup-name)))))
6663 (gnus-completing-read
6664 methname "What backend do you want to use when respooling?"
6665 methods nil t nil 'gnus-mail-method-history))
6668 ((zerop (length (setq ms (gnus-servers-using-backend
6670 (list (intern method) ""))
6674 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
6675 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
6677 (gnus-set-global-variables)
6679 (error "No method given for respooling"))
6680 (if (assoc (symbol-name
6681 (car (gnus-find-method-for-group gnus-newsgroup-name)))
6682 (gnus-methods-using 'respool))
6683 (gnus-summary-move-article n nil method)
6684 (gnus-summary-copy-article n nil method)))
6686 (defun gnus-summary-import-article (file)
6687 "Import a random file into a mail newsgroup."
6688 (interactive "fImport file: ")
6689 (gnus-set-global-variables)
6690 (let ((group gnus-newsgroup-name)
6691 (now (current-time))
6693 (unless (gnus-check-backend-function 'request-accept-article group)
6694 (error "%s does not support article importing" group))
6695 (or (file-readable-p file)
6696 (not (file-regular-p file))
6697 (error "Can't read %s" file))
6699 (set-buffer (get-buffer-create " *import file*"))
6700 (buffer-disable-undo (current-buffer))
6702 (insert-file-contents file)
6703 (goto-char (point-min))
6704 (unless (nnheader-article-p)
6705 ;; This doesn't look like an article, so we fudge some headers.
6706 (setq atts (file-attributes file)
6707 lines (count-lines (point-min) (point-max)))
6708 (insert "From: " (read-string "From: ") "\n"
6709 "Subject: " (read-string "Subject: ") "\n"
6710 "Date: " (timezone-make-date-arpa-standard
6711 (current-time-string (nth 5 atts))
6712 (current-time-zone now)
6713 (current-time-zone now))
6715 "Message-ID: " (message-make-message-id) "\n"
6716 "Lines: " (int-to-string lines) "\n"
6717 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
6718 (gnus-request-accept-article group nil t)
6719 (kill-buffer (current-buffer)))))
6721 (defun gnus-summary-article-posted-p ()
6722 "Say whether the current (mail) article is available from `gnus-select-method' as well.
6723 This will be the case if the article has both been mailed and posted."
6725 (let ((id (mail-header-references (gnus-summary-article-header)))
6726 (gnus-override-method
6727 (or gnus-refer-article-method gnus-select-method)))
6728 (if (gnus-request-head id "")
6729 (gnus-message 2 "The current message was found on %s"
6730 gnus-override-method)
6731 (gnus-message 2 "The current message couldn't be found on %s"
6732 gnus-override-method)
6735 (defun gnus-summary-expire-articles (&optional now)
6736 "Expire all articles that are marked as expirable in the current group."
6738 (gnus-set-global-variables)
6739 (when (gnus-check-backend-function
6740 'request-expire-articles gnus-newsgroup-name)
6741 ;; This backend supports expiry.
6742 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
6743 (expirable (if total
6744 (gnus-list-of-read-articles gnus-newsgroup-name)
6745 (setq gnus-newsgroup-expirable
6746 (sort gnus-newsgroup-expirable '<))))
6747 (expiry-wait (if now 'immediate
6748 (gnus-group-find-parameter
6749 gnus-newsgroup-name 'expiry-wait)))
6752 ;; There are expirable articles in this group, so we run them
6753 ;; through the expiry process.
6754 (gnus-message 6 "Expiring articles...")
6755 ;; The list of articles that weren't expired is returned.
6757 (let ((nnmail-expiry-wait-function nil)
6758 (nnmail-expiry-wait expiry-wait))
6759 (setq es (gnus-request-expire-articles
6760 expirable gnus-newsgroup-name)))
6761 (setq es (gnus-request-expire-articles
6762 expirable gnus-newsgroup-name)))
6764 (setq gnus-newsgroup-expirable es))
6765 ;; We go through the old list of expirable, and mark all
6766 ;; really expired articles as nonexistent.
6767 (unless (eq es expirable) ;If nothing was expired, we don't mark.
6768 (let ((gnus-use-cache nil))
6770 (unless (memq (car expirable) es)
6771 (when (gnus-data-find (car expirable))
6772 (gnus-summary-mark-article
6773 (car expirable) gnus-canceled-mark)))
6774 (setq expirable (cdr expirable)))))
6775 (gnus-message 6 "Expiring articles...done")))))
6777 (defun gnus-summary-expire-articles-now ()
6778 "Expunge all expirable articles in the current group.
6779 This means that *all* articles that are marked as expirable will be
6780 deleted forever, right now."
6782 (gnus-set-global-variables)
6783 (or gnus-expert-user
6785 "Are you really, really, really sure you want to delete all these messages? ")
6787 (gnus-summary-expire-articles t))
6789 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6790 (defun gnus-summary-delete-article (&optional n)
6791 "Delete the N next (mail) articles.
6792 This command actually deletes articles. This is not a marking
6793 command. The article will disappear forever from your life, never to
6795 If N is negative, delete backwards.
6796 If N is nil and articles have been marked with the process mark,
6797 delete these instead."
6799 (gnus-set-global-variables)
6800 (unless (gnus-check-backend-function 'request-expire-articles
6801 gnus-newsgroup-name)
6802 (error "The current newsgroup does not support article deletion."))
6803 ;; Compute the list of articles to delete.
6804 (let ((articles (gnus-summary-work-articles n))
6806 (if (and gnus-novice-user
6808 (format "Do you really want to delete %s forever? "
6809 (if (> (length articles) 1)
6810 (format "these %s articles" (length articles))
6813 ;; Delete the articles.
6814 (setq not-deleted (gnus-request-expire-articles
6815 articles gnus-newsgroup-name 'force))
6817 (gnus-summary-remove-process-mark (car articles))
6818 ;; The backend might not have been able to delete the article
6820 (unless (memq (car articles) not-deleted)
6821 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
6822 (setq articles (cdr articles))))
6823 (gnus-summary-position-point)
6824 (gnus-set-mode-line 'summary)
6827 (defun gnus-summary-edit-article (&optional force)
6828 "Edit the current article.
6829 This will have permanent effect only in mail groups.
6830 If FORCE is non-nil, allow editing of articles even in read-only
6834 (set-buffer gnus-summary-buffer)
6835 (gnus-set-global-variables)
6836 (when (and (not force)
6837 (gnus-group-read-only-p))
6838 (error "The current newsgroup does not support article editing."))
6839 ;; Select article if needed.
6840 (unless (eq (gnus-summary-article-number)
6841 gnus-current-article)
6842 (gnus-summary-select-article t))
6843 (gnus-article-edit-article
6845 (gnus-summary-edit-article-done
6846 ,(or (mail-header-references gnus-current-headers) "")
6847 ,(gnus-group-read-only-p) ,gnus-summary-buffer)))))
6849 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
6851 (defun gnus-summary-edit-article-done (&optional references read-only buffer)
6852 "Make edits to the current article permanent."
6854 ;; Replace the article.
6855 (if (and (not read-only)
6856 (not (gnus-request-replace-article
6857 (cdr gnus-article-current) (car gnus-article-current)
6859 (error "Couldn't replace article.")
6860 ;; Update the summary buffer.
6862 (equal (message-tokenize-header references " ")
6863 (message-tokenize-header
6864 (or (message-fetch-field "references") "") " ")))
6865 ;; We only have to update this line.
6868 (message-narrow-to-head)
6869 (let ((header (nnheader-parse-head t)))
6871 (mail-header-set-number header (cdr gnus-article-current))
6872 (gnus-summary-update-article-line
6873 (cdr gnus-article-current) header))))
6875 (set-buffer (or buffer gnus-summary-buffer))
6876 (gnus-summary-update-article (cdr gnus-article-current)))
6877 ;; Prettify the article buffer again.
6879 (set-buffer gnus-article-buffer)
6880 (run-hooks 'gnus-article-display-hook))
6881 ;; Prettify the summary buffer line.
6882 (when (gnus-visual-p 'summary-highlight 'highlight)
6883 (run-hooks 'gnus-visual-mark-article-hook))))
6885 (defun gnus-summary-edit-wash (key)
6886 "Perform editing command in the article buffer."
6890 (message "%s" (concat (this-command-keys) "- "))
6893 (gnus-summary-edit-article)
6894 (execute-kbd-macro (concat (this-command-keys) key))
6895 (gnus-article-edit-done))
6899 (defun gnus-summary-respool-query ()
6900 "Query where the respool algorithm would put this article."
6902 (gnus-set-global-variables)
6903 (gnus-summary-select-article)
6905 (set-buffer gnus-article-buffer)
6907 (goto-char (point-min))
6908 (search-forward "\n\n")
6909 (narrow-to-region (point-min) (point))
6910 (message "This message would go to %s"
6911 (mapconcat 'car (nnmail-article-group 'identity) ", ")))))
6913 ;; Summary marking commands.
6915 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
6916 "Mark articles which has the same subject as read, and then select the next.
6917 If UNMARK is positive, remove any kind of mark.
6918 If UNMARK is negative, tick articles."
6920 (gnus-set-global-variables)
6922 (setq unmark (prefix-numeric-value unmark)))
6924 (gnus-summary-mark-same-subject
6925 (gnus-summary-article-subject) unmark)))
6926 ;; Select next unread article. If auto-select-same mode, should
6927 ;; select the first unread article.
6928 (gnus-summary-next-article t (and gnus-auto-select-same
6929 (gnus-summary-article-subject)))
6930 (gnus-message 7 "%d article%s marked as %s"
6931 count (if (= count 1) " is" "s are")
6932 (if unmark "unread" "read"))))
6934 (defun gnus-summary-kill-same-subject (&optional unmark)
6935 "Mark articles which has the same subject as read.
6936 If UNMARK is positive, remove any kind of mark.
6937 If UNMARK is negative, tick articles."
6939 (gnus-set-global-variables)
6941 (setq unmark (prefix-numeric-value unmark)))
6943 (gnus-summary-mark-same-subject
6944 (gnus-summary-article-subject) unmark)))
6945 ;; If marked as read, go to next unread subject.
6947 ;; Go to next unread subject.
6948 (gnus-summary-next-subject 1 t))
6949 (gnus-message 7 "%d articles are marked as %s"
6950 count (if unmark "unread" "read"))))
6952 (defun gnus-summary-mark-same-subject (subject &optional unmark)
6953 "Mark articles with same SUBJECT as read, and return marked number.
6954 If optional argument UNMARK is positive, remove any kinds of marks.
6955 If optional argument UNMARK is negative, mark articles as unread instead."
6959 ((null unmark) ; Mark as read.
6962 (gnus-summary-mark-article-as-read gnus-killed-mark)
6963 (gnus-summary-show-thread) t)
6964 (gnus-summary-find-subject subject))
6965 (setq count (1+ count))))
6966 ((> unmark 0) ; Tick.
6969 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
6970 (gnus-summary-show-thread) t)
6971 (gnus-summary-find-subject subject))
6972 (setq count (1+ count))))
6973 (t ; Mark as unread.
6976 (gnus-summary-mark-article-as-unread gnus-unread-mark)
6977 (gnus-summary-show-thread) t)
6978 (gnus-summary-find-subject subject))
6979 (setq count (1+ count)))))
6980 (gnus-set-mode-line 'summary)
6981 ;; Return the number of marked articles.
6984 (defun gnus-summary-mark-as-processable (n &optional unmark)
6985 "Set the process mark on the next N articles.
6986 If N is negative, mark backward instead. If UNMARK is non-nil, remove
6987 the process mark instead. The difference between N and the actual
6988 number of articles marked is returned."
6990 (gnus-set-global-variables)
6991 (let ((backward (< n 0))
6996 (gnus-summary-remove-process-mark
6997 (gnus-summary-article-number))
6998 (gnus-summary-set-process-mark (gnus-summary-article-number)))
6999 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7002 (gnus-message 7 "No more articles"))
7003 (gnus-summary-recenter)
7004 (gnus-summary-position-point)
7007 (defun gnus-summary-unmark-as-processable (n)
7008 "Remove the process mark from the next N articles.
7009 If N is negative, mark backward instead. The difference between N and
7010 the actual number of articles marked is returned."
7012 (gnus-set-global-variables)
7013 (gnus-summary-mark-as-processable n t))
7015 (defun gnus-summary-unmark-all-processable ()
7016 "Remove the process mark from all articles."
7018 (gnus-set-global-variables)
7020 (while gnus-newsgroup-processable
7021 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7022 (gnus-summary-position-point))
7024 (defun gnus-summary-mark-as-expirable (n)
7025 "Mark N articles forward as expirable.
7026 If N is negative, mark backward instead. The difference between N and
7027 the actual number of articles marked is returned."
7029 (gnus-set-global-variables)
7030 (gnus-summary-mark-forward n gnus-expirable-mark))
7032 (defun gnus-summary-mark-article-as-replied (article)
7033 "Mark ARTICLE replied and update the summary line."
7034 (push article gnus-newsgroup-replied)
7035 (let ((buffer-read-only nil))
7036 (when (gnus-summary-goto-subject article)
7037 (gnus-summary-update-secondary-mark article))))
7039 (defun gnus-summary-set-bookmark (article)
7040 "Set a bookmark in current article."
7041 (interactive (list (gnus-summary-article-number)))
7042 (gnus-set-global-variables)
7043 (when (or (not (get-buffer gnus-article-buffer))
7044 (not gnus-current-article)
7045 (not gnus-article-current)
7046 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7047 (error "No current article selected"))
7048 ;; Remove old bookmark, if one exists.
7049 (let ((old (assq article gnus-newsgroup-bookmarks)))
7051 (setq gnus-newsgroup-bookmarks
7052 (delq old gnus-newsgroup-bookmarks))))
7053 ;; Set the new bookmark, which is on the form
7054 ;; (article-number . line-number-in-body).
7058 (set-buffer gnus-article-buffer)
7062 (goto-char (point-min))
7063 (search-forward "\n\n" nil t)
7066 gnus-newsgroup-bookmarks)
7067 (gnus-message 6 "A bookmark has been added to the current article."))
7069 (defun gnus-summary-remove-bookmark (article)
7070 "Remove the bookmark from the current article."
7071 (interactive (list (gnus-summary-article-number)))
7072 (gnus-set-global-variables)
7073 ;; Remove old bookmark, if one exists.
7074 (let ((old (assq article gnus-newsgroup-bookmarks)))
7077 (setq gnus-newsgroup-bookmarks
7078 (delq old gnus-newsgroup-bookmarks))
7079 (gnus-message 6 "Removed bookmark."))
7080 (gnus-message 6 "No bookmark in current article."))))
7082 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7083 (defun gnus-summary-mark-as-dormant (n)
7084 "Mark N articles forward as dormant.
7085 If N is negative, mark backward instead. The difference between N and
7086 the actual number of articles marked is returned."
7088 (gnus-set-global-variables)
7089 (gnus-summary-mark-forward n gnus-dormant-mark))
7091 (defun gnus-summary-set-process-mark (article)
7092 "Set the process mark on ARTICLE and update the summary line."
7093 (setq gnus-newsgroup-processable
7095 (delq article gnus-newsgroup-processable)))
7096 (when (gnus-summary-goto-subject article)
7097 (gnus-summary-show-thread)
7098 (gnus-summary-update-secondary-mark article)))
7100 (defun gnus-summary-remove-process-mark (article)
7101 "Remove the process mark from ARTICLE and update the summary line."
7102 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7103 (when (gnus-summary-goto-subject article)
7104 (gnus-summary-show-thread)
7105 (gnus-summary-update-secondary-mark article)))
7107 (defun gnus-summary-set-saved-mark (article)
7108 "Set the process mark on ARTICLE and update the summary line."
7109 (push article gnus-newsgroup-saved)
7110 (when (gnus-summary-goto-subject article)
7111 (gnus-summary-update-secondary-mark article)))
7113 (defun gnus-summary-mark-forward (n &optional mark no-expire)
7114 "Mark N articles as read forwards.
7115 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
7116 The difference between N and the actual number of articles marked is
7119 (gnus-set-global-variables)
7120 (let ((backward (< n 0))
7121 (gnus-summary-goto-unread
7122 (and gnus-summary-goto-unread
7123 (not (eq gnus-summary-goto-unread 'never))
7124 (not (memq mark (list gnus-unread-mark
7125 gnus-ticked-mark gnus-dormant-mark)))))
7127 (mark (or mark gnus-del-mark)))
7129 (gnus-summary-mark-article nil mark no-expire)
7130 (zerop (gnus-summary-next-subject
7132 (and gnus-summary-goto-unread
7133 (not (eq gnus-summary-goto-unread 'never)))
7137 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
7138 (gnus-summary-recenter)
7139 (gnus-summary-position-point)
7140 (gnus-set-mode-line 'summary)
7143 (defun gnus-summary-mark-article-as-read (mark)
7144 "Mark the current article quickly as read with MARK."
7145 (let ((article (gnus-summary-article-number)))
7146 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7147 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7148 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7149 (push (cons article mark) gnus-newsgroup-reads)
7150 ;; Possibly remove from cache, if that is used.
7151 (when gnus-use-cache
7152 (gnus-cache-enter-remove-article article))
7153 ;; Allow the backend to change the mark.
7154 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7155 ;; Check for auto-expiry.
7156 (when (and gnus-newsgroup-auto-expire
7157 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7158 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7159 (= mark gnus-ancient-mark)
7160 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7161 (= mark gnus-duplicate-mark)))
7162 (setq mark gnus-expirable-mark)
7163 (push article gnus-newsgroup-expirable))
7164 ;; Set the mark in the buffer.
7165 (gnus-summary-update-mark mark 'unread)
7168 (defun gnus-summary-mark-article-as-unread (mark)
7169 "Mark the current article quickly as unread with MARK."
7170 (let ((article (gnus-summary-article-number)))
7172 (gnus-error 1 "Unmarkable article")
7173 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7174 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7175 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
7176 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
7177 (cond ((= mark gnus-ticked-mark)
7178 (push article gnus-newsgroup-marked))
7179 ((= mark gnus-dormant-mark)
7180 (push article gnus-newsgroup-dormant))
7182 (push article gnus-newsgroup-unreads)))
7183 (setq gnus-newsgroup-reads
7184 (delq (assq article gnus-newsgroup-reads)
7185 gnus-newsgroup-reads))
7187 ;; See whether the article is to be put in the cache.
7189 (vectorp (gnus-summary-article-header article))
7191 (gnus-cache-possibly-enter-article
7192 gnus-newsgroup-name article
7193 (gnus-summary-article-header article)
7194 (= mark gnus-ticked-mark)
7195 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7198 (gnus-summary-update-mark mark 'unread))
7201 (defun gnus-summary-mark-article (&optional article mark no-expire)
7202 "Mark ARTICLE with MARK. MARK can be any character.
7203 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
7204 `??' (dormant) and `?E' (expirable).
7205 If MARK is nil, then the default character `?D' is used.
7206 If ARTICLE is nil, then the article on the current line will be
7208 ;; The mark might be a string.
7209 (when (stringp mark)
7210 (setq mark (aref mark 0)))
7211 ;; If no mark is given, then we check auto-expiring.
7212 (and (not no-expire)
7213 gnus-newsgroup-auto-expire
7216 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7217 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7218 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7219 (= mark gnus-duplicate-mark))))
7220 (setq mark gnus-expirable-mark))
7221 (let* ((mark (or mark gnus-del-mark))
7222 (article (or article (gnus-summary-article-number))))
7224 (error "No article on current line"))
7225 (if (or (= mark gnus-unread-mark)
7226 (= mark gnus-ticked-mark)
7227 (= mark gnus-dormant-mark))
7228 (gnus-mark-article-as-unread article mark)
7229 (gnus-mark-article-as-read article mark))
7231 ;; See whether the article is to be put in the cache.
7233 (not (= mark gnus-canceled-mark))
7234 (vectorp (gnus-summary-article-header article))
7236 (gnus-cache-possibly-enter-article
7237 gnus-newsgroup-name article
7238 (gnus-summary-article-header article)
7239 (= mark gnus-ticked-mark)
7240 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7242 (when (gnus-summary-goto-subject article nil t)
7243 (let ((buffer-read-only nil))
7244 (gnus-summary-show-thread)
7246 (gnus-summary-update-mark mark 'unread)
7249 (defun gnus-summary-update-secondary-mark (article)
7250 "Update the secondary (read, process, cache) mark."
7251 (gnus-summary-update-mark
7252 (cond ((memq article gnus-newsgroup-processable)
7254 ((memq article gnus-newsgroup-cached)
7256 ((memq article gnus-newsgroup-replied)
7258 ((memq article gnus-newsgroup-saved)
7260 (t gnus-unread-mark))
7262 (when (gnus-visual-p 'summary-highlight 'highlight)
7263 (run-hooks 'gnus-summary-update-hook))
7266 (defun gnus-summary-update-mark (mark type)
7267 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
7268 (buffer-read-only nil))
7269 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
7270 (when (looking-at "\r")
7273 (<= (+ forward (point)) (point-max)))
7274 ;; Go to the right position on the line.
7275 (goto-char (+ forward (point)))
7276 ;; Replace the old mark with the new mark.
7277 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
7278 ;; Optionally update the marks by some user rule.
7279 (when (eq type 'unread)
7281 (gnus-data-find (gnus-summary-article-number)) mark)
7282 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
7284 (defun gnus-mark-article-as-read (article &optional mark)
7285 "Enter ARTICLE in the pertinent lists and remove it from others."
7286 ;; Make the article expirable.
7287 (let ((mark (or mark gnus-del-mark)))
7288 (if (= mark gnus-expirable-mark)
7289 (push article gnus-newsgroup-expirable)
7290 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
7291 ;; Remove from unread and marked lists.
7292 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7293 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7294 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7295 (push (cons article mark) gnus-newsgroup-reads)
7296 ;; Possibly remove from cache, if that is used.
7297 (when gnus-use-cache
7298 (gnus-cache-enter-remove-article article))))
7300 (defun gnus-mark-article-as-unread (article &optional mark)
7301 "Enter ARTICLE in the pertinent lists and remove it from others."
7302 (let ((mark (or mark gnus-ticked-mark)))
7303 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
7304 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
7305 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
7306 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7308 ;; Unsuppress duplicates?
7309 (when gnus-suppress-duplicates
7310 (gnus-dup-unsuppress-article article))
7312 (cond ((= mark gnus-ticked-mark)
7313 (push article gnus-newsgroup-marked))
7314 ((= mark gnus-dormant-mark)
7315 (push article gnus-newsgroup-dormant))
7317 (push article gnus-newsgroup-unreads)))
7318 (setq gnus-newsgroup-reads
7319 (delq (assq article gnus-newsgroup-reads)
7320 gnus-newsgroup-reads))))
7322 (defalias 'gnus-summary-mark-as-unread-forward
7323 'gnus-summary-tick-article-forward)
7324 (make-obsolete 'gnus-summary-mark-as-unread-forward
7325 'gnus-summary-tick-article-forward)
7326 (defun gnus-summary-tick-article-forward (n)
7327 "Tick N articles forwards.
7328 If N is negative, tick backwards instead.
7329 The difference between N and the number of articles ticked is returned."
7331 (gnus-summary-mark-forward n gnus-ticked-mark))
7333 (defalias 'gnus-summary-mark-as-unread-backward
7334 'gnus-summary-tick-article-backward)
7335 (make-obsolete 'gnus-summary-mark-as-unread-backward
7336 'gnus-summary-tick-article-backward)
7337 (defun gnus-summary-tick-article-backward (n)
7338 "Tick N articles backwards.
7339 The difference between N and the number of articles ticked is returned."
7341 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
7343 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7344 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7345 (defun gnus-summary-tick-article (&optional article clear-mark)
7346 "Mark current article as unread.
7347 Optional 1st argument ARTICLE specifies article number to be marked as unread.
7348 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
7350 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
7353 (defun gnus-summary-mark-as-read-forward (n)
7354 "Mark N articles as read forwards.
7355 If N is negative, mark backwards instead.
7356 The difference between N and the actual number of articles marked is
7359 (gnus-summary-mark-forward n gnus-del-mark t))
7361 (defun gnus-summary-mark-as-read-backward (n)
7362 "Mark the N articles as read backwards.
7363 The difference between N and the actual number of articles marked is
7366 (gnus-summary-mark-forward (- n) gnus-del-mark t))
7368 (defun gnus-summary-mark-as-read (&optional article mark)
7369 "Mark current article as read.
7370 ARTICLE specifies the article to be marked as read.
7371 MARK specifies a string to be inserted at the beginning of the line."
7372 (gnus-summary-mark-article article mark))
7374 (defun gnus-summary-clear-mark-forward (n)
7375 "Clear marks from N articles forward.
7376 If N is negative, clear backward instead.
7377 The difference between N and the number of marks cleared is returned."
7379 (gnus-summary-mark-forward n gnus-unread-mark))
7381 (defun gnus-summary-clear-mark-backward (n)
7382 "Clear marks from N articles backward.
7383 The difference between N and the number of marks cleared is returned."
7385 (gnus-summary-mark-forward (- n) gnus-unread-mark))
7387 (defun gnus-summary-mark-unread-as-read ()
7388 "Intended to be used by `gnus-summary-mark-article-hook'."
7389 (when (memq gnus-current-article gnus-newsgroup-unreads)
7390 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
7392 (defun gnus-summary-mark-read-and-unread-as-read ()
7393 "Intended to be used by `gnus-summary-mark-article-hook'."
7394 (let ((mark (gnus-summary-article-mark)))
7395 (when (or (gnus-unread-mark-p mark)
7396 (gnus-read-mark-p mark))
7397 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
7399 (defun gnus-summary-mark-region-as-read (point mark all)
7400 "Mark all unread articles between point and mark as read.
7401 If given a prefix, mark all articles between point and mark as read,
7402 even ticked and dormant ones."
7403 (interactive "r\nP")
7412 (memq (setq article (gnus-summary-article-number))
7413 gnus-newsgroup-unreads))
7414 (gnus-summary-mark-article article gnus-del-mark))
7416 (gnus-summary-find-next))))))
7418 (defun gnus-summary-mark-below (score mark)
7419 "Mark articles with score less than SCORE with MARK."
7420 (interactive "P\ncMark: ")
7421 (gnus-set-global-variables)
7422 (setq score (if score
7423 (prefix-numeric-value score)
7424 (or gnus-summary-default-score 0)))
7426 (set-buffer gnus-summary-buffer)
7427 (goto-char (point-min))
7430 (and (< (gnus-summary-article-score) score)
7431 (gnus-summary-mark-article nil mark))
7432 (gnus-summary-find-next)))))
7434 (defun gnus-summary-kill-below (&optional score)
7435 "Mark articles with score below SCORE as read."
7437 (gnus-set-global-variables)
7438 (gnus-summary-mark-below score gnus-killed-mark))
7440 (defun gnus-summary-clear-above (&optional score)
7441 "Clear all marks from articles with score above SCORE."
7443 (gnus-set-global-variables)
7444 (gnus-summary-mark-above score gnus-unread-mark))
7446 (defun gnus-summary-tick-above (&optional score)
7447 "Tick all articles with score above SCORE."
7449 (gnus-set-global-variables)
7450 (gnus-summary-mark-above score gnus-ticked-mark))
7452 (defun gnus-summary-mark-above (score mark)
7453 "Mark articles with score over SCORE with MARK."
7454 (interactive "P\ncMark: ")
7455 (gnus-set-global-variables)
7456 (setq score (if score
7457 (prefix-numeric-value score)
7458 (or gnus-summary-default-score 0)))
7460 (set-buffer gnus-summary-buffer)
7461 (goto-char (point-min))
7463 (when (> (gnus-summary-article-score) score)
7464 (gnus-summary-mark-article nil mark))
7466 (gnus-summary-find-next)))))
7468 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7469 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
7470 (defun gnus-summary-limit-include-expunged (&optional no-error)
7471 "Display all the hidden articles that were expunged for low scores."
7473 (gnus-set-global-variables)
7474 (let ((buffer-read-only nil))
7475 (let ((scored gnus-newsgroup-scored)
7478 (unless (gnus-summary-goto-subject (caar scored))
7479 (and (setq h (gnus-summary-article-header (caar scored)))
7480 (< (cdar scored) gnus-summary-expunge-below)
7482 (setq scored (cdr scored)))
7484 (when (not no-error)
7485 (error "No expunged articles hidden."))
7486 (goto-char (point-min))
7487 (gnus-summary-prepare-unthreaded (nreverse headers))
7488 (goto-char (point-min))
7489 (gnus-summary-position-point)
7492 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
7493 "Mark all articles not marked as unread in this newsgroup as read.
7494 If prefix argument ALL is non-nil, all articles are marked as read.
7495 If QUIETLY is non-nil, no questions will be asked.
7496 If TO-HERE is non-nil, it should be a point in the buffer. All
7497 articles before this point will be marked as read.
7498 The number of articles marked as read is returned."
7500 (gnus-set-global-variables)
7504 (not gnus-interactive-catchup) ;Without confirmation?
7508 "Mark absolutely all articles as read? "
7509 "Mark all unread articles as read? ")))
7511 (not gnus-newsgroup-adaptive)
7512 (not gnus-newsgroup-auto-expire)
7513 (not gnus-suppress-duplicates))
7516 (setq gnus-newsgroup-marked nil
7517 gnus-newsgroup-dormant nil))
7518 (setq gnus-newsgroup-unreads nil))
7519 ;; We actually mark all articles as canceled, which we
7520 ;; have to do when using auto-expiry or adaptive scoring.
7521 (gnus-summary-show-all-threads)
7522 (when (gnus-summary-first-subject (not all))
7524 (if to-here (< (point) to-here) t)
7525 (gnus-summary-mark-article-as-read gnus-catchup-mark)
7526 (gnus-summary-find-next (not all)))))
7528 (setq gnus-newsgroup-unreads nil))
7529 (gnus-set-mode-line 'summary))
7530 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
7531 (when (and (not to-here) (eq 'nnvirtual (car method)))
7532 (nnvirtual-catchup-group
7533 (gnus-group-real-name gnus-newsgroup-name)
7534 (nth 1 method) all)))
7536 (gnus-summary-position-point)))
7538 (defun gnus-summary-catchup-to-here (&optional all)
7539 "Mark all unticked articles before the current one as read.
7540 If ALL is non-nil, also mark ticked and dormant articles as read."
7542 (gnus-set-global-variables)
7544 (gnus-save-hidden-threads
7545 (let ((beg (point)))
7546 ;; We check that there are unread articles.
7547 (when (or all (gnus-summary-find-prev))
7548 (gnus-summary-catchup all t beg)))))
7549 (gnus-summary-position-point))
7551 (defun gnus-summary-catchup-all (&optional quietly)
7552 "Mark all articles in this newsgroup as read."
7554 (gnus-set-global-variables)
7555 (gnus-summary-catchup t quietly))
7557 (defun gnus-summary-catchup-and-exit (&optional all quietly)
7558 "Mark all articles not marked as unread in this newsgroup as read, then exit.
7559 If prefix argument ALL is non-nil, all articles are marked as read."
7561 (gnus-set-global-variables)
7562 (when (gnus-summary-catchup all quietly nil 'fast)
7563 ;; Select next newsgroup or exit.
7564 (if (eq gnus-auto-select-next 'quietly)
7565 (gnus-summary-next-group nil)
7566 (gnus-summary-exit))))
7568 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
7569 "Mark all articles in this newsgroup as read, and then exit."
7571 (gnus-set-global-variables)
7572 (gnus-summary-catchup-and-exit t quietly))
7574 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
7575 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
7576 "Mark all articles in this group as read and select the next group.
7577 If given a prefix, mark all articles, unread as well as ticked, as
7580 (gnus-set-global-variables)
7582 (gnus-summary-catchup all))
7583 (gnus-summary-next-article t nil nil t))
7585 ;; Thread-based commands.
7587 (defun gnus-summary-articles-in-thread (&optional article)
7588 "Return a list of all articles in the current thread.
7589 If ARTICLE is non-nil, return all articles in the thread that starts
7591 (let* ((article (or article (gnus-summary-article-number)))
7592 (data (gnus-data-find-list article))
7593 (top-level (gnus-data-level (car data)))
7595 (cond ((null gnus-thread-operation-ignore-subject)
7596 (gnus-simplify-subject-re
7597 (mail-header-subject (gnus-data-header (car data)))))
7598 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
7599 (gnus-simplify-subject-fuzzy
7600 (mail-header-subject (gnus-data-header (car data)))))
7602 (end-point (save-excursion
7603 (if (gnus-summary-go-to-next-thread)
7604 (point) (point-max))))
7607 (< (gnus-data-pos (car data)) end-point))
7608 (when (or (not top-subject)
7609 (string= top-subject
7610 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
7611 (gnus-simplify-subject-fuzzy
7612 (mail-header-subject
7613 (gnus-data-header (car data))))
7614 (gnus-simplify-subject-re
7615 (mail-header-subject
7616 (gnus-data-header (car data)))))))
7617 (push (gnus-data-number (car data)) articles))
7618 (unless (and (setq data (cdr data))
7619 (> (gnus-data-level (car data)) top-level))
7621 ;; Return the list of articles.
7622 (nreverse articles)))
7624 (defun gnus-summary-rethread-current ()
7625 "Rethread the thread the current article is part of."
7627 (gnus-set-global-variables)
7628 (let* ((gnus-show-threads t)
7629 (article (gnus-summary-article-number))
7630 (id (mail-header-id (gnus-summary-article-header)))
7631 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
7633 (error "No article on the current line"))
7634 (gnus-rebuild-thread id)
7635 (gnus-summary-goto-subject article)))
7637 (defun gnus-summary-reparent-thread ()
7638 "Make current article child of the marked (or previous) article.
7640 Note that the re-threading will only work if `gnus-thread-ignore-subject'
7641 is non-nil or the Subject: of both articles are the same."
7643 (unless (not (gnus-group-read-only-p))
7644 (error "The current newsgroup does not support article editing."))
7645 (unless (<= (length gnus-newsgroup-processable) 1)
7646 (error "No more than one article may be marked."))
7647 (save-window-excursion
7648 (let ((gnus-article-buffer " *reparent*")
7649 (current-article (gnus-summary-article-number))
7650 ; first grab the marked article, otherwise one line up.
7651 (parent-article (if (not (null gnus-newsgroup-processable))
7652 (car gnus-newsgroup-processable)
7654 (if (eq (forward-line -1) 0)
7655 (gnus-summary-article-number)
7656 (error "Beginning of summary buffer."))))))
7657 (unless (not (eq current-article parent-article))
7658 (error "An article may not be self-referential."))
7659 (let ((message-id (mail-header-id
7660 (gnus-summary-article-header parent-article))))
7661 (unless (and message-id (not (equal message-id "")))
7662 (error "No message-id in desired parent."))
7663 (gnus-summary-select-article t t nil current-article)
7664 (set-buffer gnus-article-buffer)
7665 (setq buffer-read-only nil)
7666 (let ((buf (format "%s" (buffer-string))))
7669 (goto-char (point-min))
7670 (if (search-forward-regexp "^References: " nil t)
7671 (insert message-id " " )
7672 (insert "References: " message-id "\n"))
7673 (unless (gnus-request-replace-article current-article
7674 (car gnus-article-current)
7675 gnus-article-buffer)
7676 (error "Couldn't replace article."))
7677 (set-buffer gnus-summary-buffer)
7678 (gnus-summary-unmark-all-processable)
7679 (gnus-summary-rethread-current)
7680 (gnus-message 3 "Article %d is now the child of article %d."
7681 current-article parent-article)))))
7683 (defun gnus-summary-toggle-threads (&optional arg)
7684 "Toggle showing conversation threads.
7685 If ARG is positive number, turn showing conversation threads on."
7687 (gnus-set-global-variables)
7688 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
7689 (setq gnus-show-threads
7690 (if (null arg) (not gnus-show-threads)
7691 (> (prefix-numeric-value arg) 0)))
7692 (gnus-summary-prepare)
7693 (gnus-summary-goto-subject current)
7694 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
7695 (gnus-summary-position-point)))
7697 (defun gnus-summary-show-all-threads ()
7700 (gnus-set-global-variables)
7702 (let ((buffer-read-only nil))
7703 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
7704 (gnus-summary-position-point))
7706 (defun gnus-summary-show-thread ()
7707 "Show thread subtrees.
7708 Returns nil if no thread was there to be shown."
7710 (gnus-set-global-variables)
7711 (let ((buffer-read-only nil)
7713 ;; first goto end then to beg, to have point at beg after let
7714 (end (progn (end-of-line) (point)))
7715 (beg (progn (beginning-of-line) (point))))
7717 ;; Any hidden lines here?
7718 (search-forward "\r" end t)
7719 (subst-char-in-region beg end ?\^M ?\n t)
7721 (gnus-summary-position-point))))
7723 (defun gnus-summary-hide-all-threads ()
7724 "Hide all thread subtrees."
7726 (gnus-set-global-variables)
7728 (goto-char (point-min))
7729 (gnus-summary-hide-thread)
7730 (while (zerop (gnus-summary-next-thread 1 t))
7731 (gnus-summary-hide-thread)))
7732 (gnus-summary-position-point))
7734 (defun gnus-summary-hide-thread ()
7735 "Hide thread subtrees.
7736 Returns nil if no threads were there to be hidden."
7738 (gnus-set-global-variables)
7739 (let ((buffer-read-only nil)
7741 (article (gnus-summary-article-number)))
7743 ;; Go forward until either the buffer ends or the subthread
7745 (when (and (not (eobp))
7746 (or (zerop (gnus-summary-next-thread 1 t))
7747 (goto-char (point-max))))
7749 (if (and (> (point) start)
7750 (search-backward "\n" start t))
7752 (subst-char-in-region start (point) ?\n ?\^M)
7753 (gnus-summary-goto-subject article))
7756 ;;(gnus-summary-position-point)
7759 (defun gnus-summary-go-to-next-thread (&optional previous)
7760 "Go to the same level (or less) next thread.
7761 If PREVIOUS is non-nil, go to previous thread instead.
7762 Return the article number moved to, or nil if moving was impossible."
7763 (let ((level (gnus-summary-thread-level))
7764 (way (if previous -1 1))
7767 (while (and (not (eobp))
7768 (< level (gnus-summary-thread-level)))
7776 (gnus-summary-article-number)
7779 (defun gnus-summary-next-thread (n &optional silent)
7780 "Go to the same level next N'th thread.
7781 If N is negative, search backward instead.
7782 Returns the difference between N and the number of skips actually
7785 If SILENT, don't output messages."
7787 (gnus-set-global-variables)
7788 (let ((backward (< n 0))
7791 (gnus-summary-go-to-next-thread backward))
7794 (gnus-summary-position-point))
7795 (when (and (not silent) (/= 0 n))
7796 (gnus-message 7 "No more threads"))
7799 (defun gnus-summary-prev-thread (n)
7800 "Go to the same level previous N'th thread.
7801 Returns the difference between N and the number of skips actually
7804 (gnus-set-global-variables)
7805 (gnus-summary-next-thread (- n)))
7807 (defun gnus-summary-go-down-thread ()
7808 "Go down one level in the current thread."
7809 (let ((children (gnus-summary-article-children)))
7811 (gnus-summary-goto-subject (car children)))))
7813 (defun gnus-summary-go-up-thread ()
7814 "Go up one level in the current thread."
7815 (let ((parent (gnus-summary-article-parent)))
7817 (gnus-summary-goto-subject parent))))
7819 (defun gnus-summary-down-thread (n)
7820 "Go down thread N steps.
7821 If N is negative, go up instead.
7822 Returns the difference between N and how many steps down that were
7825 (gnus-set-global-variables)
7829 (if up (gnus-summary-go-up-thread)
7830 (gnus-summary-go-down-thread)))
7832 (gnus-summary-position-point)
7834 (gnus-message 7 "Can't go further"))
7837 (defun gnus-summary-up-thread (n)
7838 "Go up thread N steps.
7839 If N is negative, go up instead.
7840 Returns the difference between N and how many steps down that were
7843 (gnus-set-global-variables)
7844 (gnus-summary-down-thread (- n)))
7846 (defun gnus-summary-top-thread ()
7847 "Go to the top of the thread."
7849 (gnus-set-global-variables)
7850 (while (gnus-summary-go-up-thread))
7851 (gnus-summary-article-number))
7853 (defun gnus-summary-kill-thread (&optional unmark)
7854 "Mark articles under current thread as read.
7855 If the prefix argument is positive, remove any kinds of marks.
7856 If the prefix argument is negative, tick articles instead."
7858 (gnus-set-global-variables)
7860 (setq unmark (prefix-numeric-value unmark)))
7861 (let ((articles (gnus-summary-articles-in-thread)))
7863 ;; Expand the thread.
7864 (gnus-summary-show-thread)
7865 ;; Mark all the articles.
7867 (gnus-summary-goto-subject (car articles))
7868 (cond ((null unmark)
7869 (gnus-summary-mark-article-as-read gnus-killed-mark))
7871 (gnus-summary-mark-article-as-unread gnus-unread-mark))
7873 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
7874 (setq articles (cdr articles))))
7875 ;; Hide killed subtrees.
7877 gnus-thread-hide-killed
7878 (gnus-summary-hide-thread))
7879 ;; If marked as read, go to next unread subject.
7881 ;; Go to next unread subject.
7882 (gnus-summary-next-subject 1 t)))
7883 (gnus-set-mode-line 'summary))
7885 ;; Summary sorting commands
7887 (defun gnus-summary-sort-by-number (&optional reverse)
7888 "Sort summary buffer by article number.
7889 Argument REVERSE means reverse order."
7891 (gnus-summary-sort 'number reverse))
7893 (defun gnus-summary-sort-by-author (&optional reverse)
7894 "Sort summary buffer by author name alphabetically.
7895 If case-fold-search is non-nil, case of letters is ignored.
7896 Argument REVERSE means reverse order."
7898 (gnus-summary-sort 'author reverse))
7900 (defun gnus-summary-sort-by-subject (&optional reverse)
7901 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
7902 If case-fold-search is non-nil, case of letters is ignored.
7903 Argument REVERSE means reverse order."
7905 (gnus-summary-sort 'subject reverse))
7907 (defun gnus-summary-sort-by-date (&optional reverse)
7908 "Sort summary buffer by date.
7909 Argument REVERSE means reverse order."
7911 (gnus-summary-sort 'date reverse))
7913 (defun gnus-summary-sort-by-score (&optional reverse)
7914 "Sort summary buffer by score.
7915 Argument REVERSE means reverse order."
7917 (gnus-summary-sort 'score reverse))
7919 (defun gnus-summary-sort (predicate reverse)
7920 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
7921 (gnus-set-global-variables)
7922 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
7923 (article (intern (format "gnus-article-sort-by-%s" predicate)))
7924 (gnus-thread-sort-functions
7930 (gnus-article-sort-functions
7935 (,article t2 t1)))))
7937 (gnus-summary-prepare-hook nil))
7938 ;; We do the sorting by regenerating the threads.
7939 (gnus-summary-prepare)
7940 ;; Hide subthreads if needed.
7941 (when (and gnus-show-threads gnus-thread-hide-subtree)
7942 (gnus-summary-hide-all-threads))))
7944 ;; Summary saving commands.
7946 (defun gnus-summary-save-article (&optional n not-saved)
7947 "Save the current article using the default saver function.
7948 If N is a positive number, save the N next articles.
7949 If N is a negative number, save the N previous articles.
7950 If N is nil and any articles have been marked with the process mark,
7951 save those articles instead.
7952 The variable `gnus-default-article-saver' specifies the saver function."
7954 (gnus-set-global-variables)
7955 (let* ((articles (gnus-summary-work-articles n))
7956 (save-buffer (save-excursion
7957 (nnheader-set-temp-buffer " *Gnus Save*")))
7958 (num (length articles))
7959 header article file)
7961 (setq header (gnus-summary-article-header
7962 (setq article (pop articles))))
7963 (if (not (vectorp header))
7964 ;; This is a pseudo-article.
7965 (if (assq 'name header)
7966 (gnus-copy-file (cdr (assq 'name header)))
7967 (gnus-message 1 "Article %d is unsaveable" article))
7968 ;; This is a real article.
7969 (save-window-excursion
7970 (gnus-summary-select-article t nil nil article))
7972 (set-buffer save-buffer)
7974 (insert-buffer-substring gnus-original-article-buffer))
7975 (setq file (gnus-article-save save-buffer file num))
7976 (gnus-summary-remove-process-mark article)
7978 (gnus-summary-set-saved-mark article))))
7979 (gnus-kill-buffer save-buffer)
7980 (gnus-summary-position-point)
7983 (defun gnus-summary-pipe-output (&optional arg)
7984 "Pipe the current article to a subprocess.
7985 If N is a positive number, pipe the N next articles.
7986 If N is a negative number, pipe the N previous articles.
7987 If N is nil and any articles have been marked with the process mark,
7988 pipe those articles instead."
7990 (gnus-set-global-variables)
7991 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
7992 (gnus-summary-save-article arg t))
7993 (gnus-configure-windows 'pipe))
7995 (defun gnus-summary-save-article-mail (&optional arg)
7996 "Append the current article to an mail file.
7997 If N is a positive number, save the N next articles.
7998 If N is a negative number, save the N previous articles.
7999 If N is nil and any articles have been marked with the process mark,
8000 save those articles instead."
8002 (gnus-set-global-variables)
8003 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8004 (gnus-summary-save-article arg)))
8006 (defun gnus-summary-save-article-rmail (&optional arg)
8007 "Append the current article to an rmail file.
8008 If N is a positive number, save the N next articles.
8009 If N is a negative number, save the N previous articles.
8010 If N is nil and any articles have been marked with the process mark,
8011 save those articles instead."
8013 (gnus-set-global-variables)
8014 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
8015 (gnus-summary-save-article arg)))
8017 (defun gnus-summary-save-article-file (&optional arg)
8018 "Append the current article to a file.
8019 If N is a positive number, save the N next articles.
8020 If N is a negative number, save the N previous articles.
8021 If N is nil and any articles have been marked with the process mark,
8022 save those articles instead."
8024 (gnus-set-global-variables)
8025 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8026 (gnus-summary-save-article arg)))
8028 (defun gnus-summary-write-article-file (&optional arg)
8029 "Write the current article to a file, deleting the previous file.
8030 If N is a positive number, save the N next articles.
8031 If N is a negative number, save the N previous articles.
8032 If N is nil and any articles have been marked with the process mark,
8033 save those articles instead."
8035 (gnus-set-global-variables)
8036 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
8037 (gnus-summary-save-article arg)))
8039 (defun gnus-summary-save-article-body-file (&optional arg)
8040 "Append the current article body to a file.
8041 If N is a positive number, save the N next articles.
8042 If N is a negative number, save the N previous articles.
8043 If N is nil and any articles have been marked with the process mark,
8044 save those articles instead."
8046 (gnus-set-global-variables)
8047 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
8048 (gnus-summary-save-article arg)))
8050 (defun gnus-get-split-value (methods)
8051 "Return a value based on the split METHODS."
8052 (let (split-name method result match)
8055 (set-buffer gnus-original-article-buffer)
8057 (nnheader-narrow-to-headers)
8059 (goto-char (point-min))
8060 (setq method (pop methods))
8061 (setq match (car method))
8064 ;; Regular expression.
8066 (re-search-forward match nil t)))
8067 ((gnus-functionp match)
8071 (setq result (funcall match gnus-newsgroup-name))))
8076 (setq result (eval match)))))
8077 (setq split-name (append (cdr method) split-name))
8078 (cond ((stringp result)
8079 (push result split-name))
8081 (setq split-name (append result split-name)))))))))
8084 (defun gnus-valid-move-group-p (group)
8089 (car (gnus-find-method-for-group
8090 (symbol-name group))))
8091 gnus-valid-select-methods))))
8093 (defun gnus-read-move-group-name (prompt default articles prefix)
8094 "Read a group name."
8095 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
8096 (minibuffer-confirm-incomplete nil) ; XEmacs
8100 (if (> (length articles) 1)
8101 (format "these %d articles" (length articles))
8106 (gnus-completing-read default prom
8108 'gnus-valid-move-group-p
8110 'gnus-group-history))
8111 ((= 1 (length split-name))
8112 (gnus-completing-read (car split-name) prom
8114 'gnus-valid-move-group-p
8116 'gnus-group-history))
8118 (gnus-completing-read nil prom
8119 (mapcar (lambda (el) (list el))
8120 (nreverse split-name))
8122 'gnus-group-history)))))
8124 (if (or (string= to-newsgroup "")
8125 (string= to-newsgroup prefix))
8126 (setq to-newsgroup (or default "")))
8127 (or (gnus-active to-newsgroup)
8128 (gnus-activate-group to-newsgroup)
8129 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
8131 (or (and (gnus-request-create-group
8132 to-newsgroup (gnus-group-name-to-method to-newsgroup))
8133 (gnus-activate-group to-newsgroup nil nil
8134 (gnus-group-name-to-method
8136 (error "Couldn't create group %s" to-newsgroup)))
8137 (error "No such group: %s" to-newsgroup)))
8140 ;; Summary extract commands
8142 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
8143 (let ((buffer-read-only nil)
8144 (article (gnus-summary-article-number))
8146 (unless (gnus-summary-goto-subject article)
8147 (error "No such article: %d" article))
8148 (gnus-summary-position-point)
8149 ;; If all commands are to be bunched up on one line, we collect
8151 (if gnus-view-pseudos-separately
8153 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
8156 (setq action (cdr (assq 'action (car ps))))
8157 (setq files (list (cdr (assq 'name (car ps)))))
8158 (while (and ps (cdr ps)
8159 (string= (or action "1")
8160 (or (cdr (assq 'action (cadr ps))) "2")))
8161 (push (cdr (assq 'name (cadr ps))) files)
8162 (setcdr ps (cddr ps)))
8165 (when (not (string-match "%s" action))
8168 (and (assq 'execute (car ps))
8169 (setcdr (assq 'execute (car ps))
8170 (funcall (if (string-match "%s" action)
8173 (mapconcat (lambda (f) f) files " ")))))
8174 (setq ps (cdr ps)))))
8175 (if (and gnus-view-pseudos (not not-view))
8177 (when (assq 'execute (car pslist))
8178 (gnus-execute-command (cdr (assq 'execute (car pslist)))
8179 (eq gnus-view-pseudos 'not-confirm)))
8180 (setq pslist (cdr pslist)))
8183 (setq after-article (or (cdr (assq 'article (car pslist)))
8184 (gnus-summary-article-number)))
8185 (gnus-summary-goto-subject after-article)
8188 (insert " " (file-name-nondirectory
8189 (cdr (assq 'name (car pslist))))
8190 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
8192 (forward-line -1) ; back to `b'
8193 (gnus-add-text-properties
8194 b (1- e) (list 'gnus-number gnus-reffed-article-number
8195 gnus-mouse-face-prop gnus-mouse-face))
8197 after-article gnus-reffed-article-number
8198 gnus-unread-mark b (car pslist) 0 (- e b))
8199 (push gnus-reffed-article-number gnus-newsgroup-unreads)
8200 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
8201 (setq pslist (cdr pslist)))))))
8203 (defun gnus-pseudos< (p1 p2)
8204 (let ((c1 (cdr (assq 'action p1)))
8205 (c2 (cdr (assq 'action p2))))
8206 (and c1 c2 (string< c1 c2))))
8208 (defun gnus-request-pseudo-article (props)
8209 (cond ((assq 'execute props)
8210 (gnus-execute-command (cdr (assq 'execute props)))))
8211 (let ((gnus-current-article (gnus-summary-article-number)))
8212 (run-hooks 'gnus-mark-article-hook)))
8214 (defun gnus-execute-command (command &optional automatic)
8216 (gnus-article-setup-buffer)
8217 (set-buffer gnus-article-buffer)
8218 (setq buffer-read-only nil)
8219 (let ((command (if automatic command (read-string "Command: " command)))
8220 ;; Just binding this here doesn't help, because there might
8221 ;; be output from the process after exiting the scope of
8223 ;; (buffer-read-only nil)
8226 (insert "$ " command "\n\n")
8227 (if gnus-view-pseudo-asynchronously
8228 (start-process "gnus-execute" nil shell-file-name
8229 shell-command-switch command)
8230 (call-process shell-file-name nil t nil
8231 shell-command-switch command)))))
8233 ;; Summary kill commands.
8235 (defun gnus-summary-edit-global-kill (article)
8236 "Edit the \"global\" kill file."
8237 (interactive (list (gnus-summary-article-number)))
8238 (gnus-set-global-variables)
8239 (gnus-group-edit-global-kill article))
8241 (defun gnus-summary-edit-local-kill ()
8242 "Edit a local kill file applied to the current newsgroup."
8244 (gnus-set-global-variables)
8245 (setq gnus-current-headers (gnus-summary-article-header))
8246 (gnus-set-global-variables)
8247 (gnus-group-edit-local-kill
8248 (gnus-summary-article-number) gnus-newsgroup-name))
8252 (defun gnus-read-header (id &optional header)
8253 "Read the headers of article ID and enter them into the Gnus system."
8254 (let ((group gnus-newsgroup-name)
8255 (gnus-override-method
8256 (and (gnus-news-group-p gnus-newsgroup-name)
8257 gnus-refer-article-method))
8259 ;; First we check to see whether the header in question is already
8262 ;; This is a Message-ID.
8263 (setq header (or header (gnus-id-to-header id)))
8264 ;; This is an article number.
8265 (setq header (or header (gnus-summary-article-header id))))
8267 (not (memq (mail-header-number header) gnus-newsgroup-sparse)))
8268 ;; We have found the header.
8270 ;; We have to really fetch the header to this article.
8272 (set-buffer nntp-server-buffer)
8273 (when (setq where (gnus-request-head id group))
8274 (goto-char (point-max))
8276 (goto-char (point-min))
8280 ((cdr where) (cdr where))
8281 (header (mail-header-number header))
8282 (t gnus-reffed-article-number))
8284 (insert " Article retrieved.\n"))
8285 (if (not (setq header (car (gnus-get-newsgroup-headers nil t))))
8286 () ; Malformed head.
8287 (unless (memq (mail-header-number header) gnus-newsgroup-sparse)
8288 (when (and (stringp id)
8289 (not (string= (gnus-group-real-name group)
8291 ;; If we fetched by Message-ID and the article came
8292 ;; from a different group, we fudge some bogus article
8293 ;; numbers for this article.
8294 (mail-header-set-number header gnus-reffed-article-number))
8296 (set-buffer gnus-summary-buffer)
8297 (decf gnus-reffed-article-number)
8298 (gnus-remove-header (mail-header-number header))
8299 (push header gnus-newsgroup-headers)
8300 (setq gnus-current-headers header)
8301 (push (mail-header-number header) gnus-newsgroup-limit)))
8304 (defun gnus-remove-header (number)
8305 "Remove header NUMBER from `gnus-newsgroup-headers'."
8306 (if (and gnus-newsgroup-headers
8307 (= number (mail-header-number (car gnus-newsgroup-headers))))
8308 (pop gnus-newsgroup-headers)
8309 (let ((headers gnus-newsgroup-headers))
8310 (while (and (cdr headers)
8311 (not (= number (mail-header-number (cadr headers)))))
8314 (setcdr headers (cddr headers))))))
8317 ;;; summary highlights
8320 (defun gnus-highlight-selected-summary ()
8321 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8322 ;; Highlight selected article in summary buffer
8323 (when gnus-summary-selected-face
8325 (let* ((beg (progn (beginning-of-line) (point)))
8326 (end (progn (end-of-line) (point)))
8327 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
8328 (from (if (get-text-property beg gnus-mouse-face-prop)
8330 (or (next-single-property-change
8331 beg gnus-mouse-face-prop nil end)
8336 (or (next-single-property-change
8337 from gnus-mouse-face-prop nil end)
8339 ;; If no mouse-face prop on line we will have to = from = end,
8340 ;; so we highlight the entire line instead.
8341 (when (= (+ to 2) from)
8344 (if gnus-newsgroup-selected-overlay
8345 ;; Move old overlay.
8347 gnus-newsgroup-selected-overlay from to (current-buffer))
8348 ;; Create new overlay.
8350 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
8351 'face gnus-summary-selected-face))))))
8353 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
8354 (defun gnus-summary-highlight-line ()
8355 "Highlight current line according to `gnus-summary-highlight'."
8356 (let* ((list gnus-summary-highlight)
8358 (end (progn (end-of-line) (point)))
8359 ;; now find out where the line starts and leave point there.
8360 (beg (progn (beginning-of-line) (point)))
8361 (article (gnus-summary-article-number))
8362 (score (or (cdr (assq (or article gnus-current-article)
8363 gnus-newsgroup-scored))
8364 gnus-summary-default-score 0))
8365 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
8366 (inhibit-read-only t))
8367 ;; Eval the cars of the lists until we find a match.
8368 (let ((default gnus-summary-default-score))
8370 (not (eval (caar list))))
8371 (setq list (cdr list))))
8372 (let ((face (cdar list)))
8373 (unless (eq face (get-text-property beg 'face))
8374 (gnus-put-text-property
8376 (setq face (if (boundp face) (symbol-value face) face)))
8377 (when gnus-summary-highlight-line-function
8378 (funcall gnus-summary-highlight-line-function article face))))
8381 (defun gnus-update-read-articles (group unread)
8382 "Update the list of read articles in GROUP."
8383 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
8384 (entry (gnus-gethash group gnus-newsrc-hashtb))
8385 (info (nth 2 entry))
8387 (unread (sort (copy-sequence unread) '<))
8389 (if (or (not info) (not active))
8390 ;; There is no info on this group if it was, in fact,
8391 ;; killed. Gnus stores no information on killed groups, so
8392 ;; there's nothing to be done.
8393 ;; One could store the information somewhere temporarily,
8394 ;; perhaps... Hmmm...
8396 ;; Remove any negative articles numbers.
8397 (while (and unread (< (car unread) 0))
8398 (setq unread (cdr unread)))
8399 ;; Remove any expired article numbers
8400 (while (and unread (< (car unread) (car active)))
8401 (setq unread (cdr unread)))
8402 ;; Compute the ranges of read articles by looking at the list of
8405 (when (/= (car unread) prev)
8406 (push (if (= prev (1- (car unread))) prev
8407 (cons prev (1- (car unread))))
8409 (setq prev (1+ (car unread)))
8410 (setq unread (cdr unread)))
8411 (when (<= prev (cdr active))
8412 (push (cons prev (cdr active)) read))
8415 (gnus-info-set-marks ,info ,(gnus-info-marks info))
8416 (gnus-info-set-read ,info ,(gnus-info-read info))
8417 (gnus-get-unread-articles-in-group ,info (gnus-active ,group))))
8418 ;; Enter this list into the group info.
8420 info (if (> (length read) 1) (nreverse read) read))
8421 ;; Set the number of unread articles in gnus-newsrc-hashtb.
8422 (gnus-get-unread-articles-in-group info (gnus-active group))
8427 (run-hooks 'gnus-sum-load-hook)
8429 ;;; gnus-sum.el ends here