1 ;;; gnus-sum.el --- summary mode commands for Gnus
2 ;; Copyright (C) 1996 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
35 (defgroup gnus-summary nil
39 (defcustom gnus-kill-summary-on-exit t
40 "*If non-nil, kill the summary buffer when you exit from it.
41 If nil, the summary will become a \"*Dead Summary*\" buffer, and
42 it will be killed sometime later."
46 (defcustom gnus-fetch-old-headers nil
47 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
48 If an unread article in the group refers to an older, already read (or
49 just marked as read) article, the old article will not normally be
50 displayed in the Summary buffer. If this variable is non-nil, Gnus
51 will attempt to grab the headers to the old articles, and thereby
52 build complete threads. If it has the value `some', only enough
53 headers to connect otherwise loose threads will be displayed.
54 This variable can also be a number. In that case, no more than that
55 number of old headers will be fetched.
57 The server has to support NOV for any of this to work."
59 :type '(choice (const :tag "off" nil)
62 (sexp :menu-tag "other" t)))
64 (defcustom gnus-summary-make-false-root 'adopt
65 "*nil means that Gnus won't gather loose threads.
66 If the root of a thread has expired or been read in a previous
67 session, the information necessary to build a complete thread has been
68 lost. Instead of having many small sub-threads from this original thread
69 scattered all over the summary buffer, Gnus can gather them.
71 If non-nil, Gnus will try to gather all loose sub-threads from an
72 original thread into one large thread.
74 If this variable is non-nil, it should be one of `none', `adopt',
77 If this variable is `none', Gnus will not make a false root, but just
78 present the sub-threads after another.
79 If this variable is `dummy', Gnus will create a dummy root that will
80 have all the sub-threads as children.
81 If this variable is `adopt', Gnus will make one of the \"children\"
82 the parent and mark all the step-children as such.
83 If this variable is `empty', the \"children\" are printed with empty
84 subject fields. (Or rather, they will be printed with a string
85 given by the `gnus-summary-same-subject' variable.)"
87 :type '(choice (const :tag "off" nil)
93 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
94 "*A regexp to match subjects to be excluded from loose thread gathering.
95 As loose thread gathering is done on subjects only, that means that
96 there can be many false gatherings performed. By rooting out certain
97 common subjects, gathering might become saner."
101 (defcustom gnus-summary-gather-subject-limit nil
102 "*Maximum length of subject comparisons when gathering loose threads.
103 Use nil to compare full subjects. Setting this variable to a low
104 number will help gather threads that have been corrupted by
105 newsreaders chopping off subject lines, but it might also mean that
106 unrelated articles that have subject that happen to begin with the
107 same few characters will be incorrectly gathered.
109 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
112 :type '(choice (const :tag "off" nil)
114 (sexp :menu-tag "on" t)))
116 (defcustom gnus-simplify-ignored-prefixes nil
117 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
119 :type '(choice (const :tag "off" nil)
122 (defcustom gnus-build-sparse-threads nil
123 "*If non-nil, fill in the gaps in threads.
124 If `some', only fill in the gaps that are needed to tie loose threads
125 together. If `more', fill in all leaf nodes that Gnus can find. If
126 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
128 :type '(choice (const :tag "off" nil)
131 (sexp :menu-tag "all" t)))
133 (defcustom gnus-summary-thread-gathering-function 'gnus-gather-threads-by-subject
134 "Function used for gathering loose threads.
135 There are two pre-defined functions: `gnus-gather-threads-by-subject',
136 which only takes Subjects into consideration; and
137 `gnus-gather-threads-by-references', which compared the References
138 headers of the articles to find matches."
140 :type '(set (function-item gnus-gather-threads-by-subject)
141 (function-item gnus-gather-threads-by-references)
142 (function :tag "other")))
144 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
145 (defcustom gnus-summary-same-subject ""
146 "*String indicating that the current article has the same subject as the previous.
147 This variable will only be used if the value of
148 `gnus-summary-make-false-root' is `empty'."
152 (defcustom gnus-summary-goto-unread t
153 "*If t, marking commands will go to the next unread article.
154 If `never', commands that usually go to the next unread article, will
155 go to the next article, whether it is read or not.
156 If nil, only the marking commands will go to the next (un)read article."
158 :type '(choice (const :tag "off" nil)
160 (sexp :menu-tag "on" t)))
162 (defcustom gnus-summary-default-score 0
163 "*Default article score level.
164 If this variable is nil, scoring will be disabled."
166 :type '(choice (const :tag "disable")
169 (defcustom gnus-summary-zcore-fuzz 0
170 "*Fuzziness factor for the zcore in the summary buffer.
171 Articles with scores closer than this to `gnus-summary-default-score'
176 (defcustom gnus-simplify-subject-fuzzy-regexp nil
177 "*Strings to be removed when doing fuzzy matches.
178 This can either be a regular expression or list of regular expressions
179 that will be removed from subject strings if fuzzy subject
180 simplification is selected."
182 :type '(repeat regexp))
184 (defcustom gnus-show-threads t
185 "*If non-nil, display threads in summary mode."
189 (defcustom gnus-thread-hide-subtree nil
190 "*If non-nil, hide all threads initially.
191 If threads are hidden, you have to run the command
192 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
193 to expose hidden threads."
197 (defcustom gnus-thread-hide-killed t
198 "*If non-nil, hide killed threads automatically."
202 (defcustom gnus-thread-ignore-subject nil
203 "*If non-nil, ignore subjects and do all threading based on the Reference header.
204 If nil, which is the default, articles that have different subjects
205 from their parents will start separate threads."
209 (defcustom gnus-thread-operation-ignore-subject t
210 "*If non-nil, subjects will be ignored when doing thread commands.
211 This affects commands like `gnus-summary-kill-thread' and
212 `gnus-summary-lower-thread'.
214 If this variable is nil, articles in the same thread with different
215 subjects will not be included in the operation in question. If this
216 variable is `fuzzy', only articles that have subjects that are fuzzily
217 equal will be included."
219 :type '(choice (const :tag "off" nil)
223 (defcustom gnus-thread-indent-level 4
224 "*Number that says how much each sub-thread should be indented."
228 (defcustom gnus-auto-extend-newsgroup t
229 "*If non-nil, extend newsgroup forward and backward when requested."
233 (defcustom gnus-auto-select-first t
234 "*If nil, don't select the first unread article when entering a group.
235 If this variable is `best', select the highest-scored unread article
236 in the group. If neither nil nor `best', select the first unread
239 If you want to prevent automatic selection of the first unread article
240 in some newsgroups, set the variable to nil in
241 `gnus-select-group-hook'."
243 :type '(choice (const :tag "none" nil)
245 (sexp :menu-tag "first" t)))
247 (defcustom gnus-auto-select-next t
248 "*If non-nil, offer to go to the next group from the end of the previous.
249 If the value is t and the next newsgroup is empty, Gnus will exit
250 summary mode and go back to group mode. If the value is neither nil
251 nor t, Gnus will select the following unread newsgroup. In
252 particular, if the value is the symbol `quietly', the next unread
253 newsgroup will be selected without any confirmation, and if it is
254 `almost-quietly', the next group will be selected without any
255 confirmation if you are located on the last article in the group.
256 Finally, if this variable is `slightly-quietly', the `Z n' command
257 will go to the next group without confirmation."
259 :type '(choice (const :tag "off" nil)
261 (const almost-quietly)
262 (const slightly-quietly)
263 (sexp :menu-tag "on" t)))
265 (defcustom gnus-auto-select-same nil
266 "*If non-nil, select the next article with the same subject."
270 (defcustom gnus-summary-check-current nil
271 "*If non-nil, consider the current article when moving.
272 The \"unread\" movement commands will stay on the same line if the
273 current article is unread."
277 (defcustom gnus-auto-center-summary t
278 "*If non-nil, always center the current summary buffer.
279 In particular, if `vertical' do only vertical recentering. If non-nil
280 and non-`vertical', do both horizontal and vertical recentering."
282 :type '(choice (const :tag "none" nil)
284 (sexp :menu-tag "both" t)))
286 (defcustom gnus-show-all-headers nil
287 "*If non-nil, don't hide any headers."
291 (defcustom gnus-single-article-buffer t
292 "*If non-nil, display all articles in the same buffer.
293 If nil, each group will get its own article buffer."
297 (defcustom gnus-break-pages t
298 "*If non-nil, do page breaking on articles.
299 The page delimiter is specified by the `gnus-page-delimiter'
304 (defcustom gnus-show-mime nil
305 "*If non-nil, do mime processing of articles.
306 The articles will simply be fed to the function given by
307 `gnus-show-mime-method'."
311 (defcustom gnus-move-split-methods nil
312 "*Variable used to suggest where articles are to be moved to.
313 It uses the same syntax as the `gnus-split-methods' variable."
315 :type '(repeat (choice (list function)
316 (cons regexp (repeat string))
319 ;; Mark variables suggested by Thomas Michanek
320 ;; <Thomas.Michanek@telelogic.se>.
322 (defgroup gnus-summary-marks nil
323 "Marks used in summary buffers."
324 :group 'gnus-summary)
326 (defcustom gnus-unread-mark ?
327 "*Mark used for unread articles."
328 :group 'gnus-summary-marks
331 (defcustom gnus-ticked-mark ?!
332 "*Mark used for ticked articles."
333 :group 'gnus-summary-marks
336 (defcustom gnus-dormant-mark ??
337 "*Mark used for dormant articles."
338 :group 'gnus-summary-marks
341 (defcustom gnus-del-mark ?r
342 "*Mark used for del'd articles."
343 :group 'gnus-summary-marks
346 (defcustom gnus-read-mark ?R
347 "*Mark used for read articles."
348 :group 'gnus-summary-marks
351 (defcustom gnus-expirable-mark ?E
352 "*Mark used for expirable articles."
353 :group 'gnus-summary-marks
356 (defcustom gnus-killed-mark ?K
357 "*Mark used for killed articles."
358 :group 'gnus-summary-marks
361 (defcustom gnus-souped-mark ?F
362 "*Mark used for killed articles."
363 :group 'gnus-summary-marks
366 (defcustom gnus-kill-file-mark ?X
367 "*Mark used for articles killed by kill files."
368 :group 'gnus-summary-marks
371 (defcustom gnus-low-score-mark ?Y
372 "*Mark used for articles with a low score."
373 :group 'gnus-summary-marks
376 (defcustom gnus-catchup-mark ?C
377 "*Mark used for articles that are caught up."
378 :group 'gnus-summary-marks
381 (defcustom gnus-replied-mark ?A
382 "*Mark used for articles that have been replied to."
383 :group 'gnus-summary-marks
386 (defcustom gnus-cached-mark ?*
387 "*Mark used for articles that are in the cache."
388 :group 'gnus-summary-marks
391 (defcustom gnus-saved-mark ?S
392 "*Mark used for articles that have been saved to."
393 :group 'gnus-summary-marks
396 (defcustom gnus-ancient-mark ?O
397 "*Mark used for ancient articles."
398 :group 'gnus-summary-marks
401 (defcustom gnus-sparse-mark ?Q
402 "*Mark used for sparsely reffed articles."
403 :group 'gnus-summary-marks
406 (defcustom gnus-canceled-mark ?G
407 "*Mark used for canceled articles."
408 :group 'gnus-summary-marks
411 (defcustom gnus-duplicate-mark ?M
412 "*Mark used for duplicate articles."
413 :group 'gnus-summary-marks
416 (defcustom gnus-score-over-mark ?+
417 "*Score mark used for articles with high scores."
418 :group 'gnus-summary-marks
421 (defcustom gnus-score-below-mark ?-
422 "*Score mark used for articles with low scores."
423 :group 'gnus-summary-marks
426 (defcustom gnus-empty-thread-mark ?
427 "*There is no thread under the article."
428 :group 'gnus-summary-marks
431 (defcustom gnus-not-empty-thread-mark ?=
432 "*There is a thread under the article."
433 :group 'gnus-summary-marks
436 (defcustom gnus-view-pseudo-asynchronously nil
437 "*If non-nil, Gnus will view pseudo-articles asynchronously."
441 (defcustom gnus-view-pseudos nil
442 "*If `automatic', pseudo-articles will be viewed automatically.
443 If `not-confirm', pseudos will be viewed automatically, and the user
444 will not be asked to confirm the command."
446 :type '(choice (const :tag "off" nil)
448 (const not-confirm)))
450 (defcustom gnus-view-pseudos-separately t
451 "*If non-nil, one pseudo-article will be created for each file to be viewed.
452 If nil, all files that use the same viewing command will be given as a
453 list of parameters to that command."
457 (defcustom gnus-insert-pseudo-articles t
458 "*If non-nil, insert pseudo-articles when decoding articles."
462 (defcustom gnus-summary-dummy-line-format
464 "*The format specification for the dummy roots in the summary buffer.
465 It works along the same lines as a normal formatting string,
466 with some simple extensions.
472 (defcustom gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
473 "*The format specification for the summary mode line.
474 It works along the same lines as a normal formatting string,
475 with some simple extensions:
478 %p Unprefixed group name
479 %A Current article number
481 %U Number of unread articles in the group
482 %e Number of unselected articles in the group
483 %Z A string with unread/unselected article counts
484 %g Shortish group name
485 %S Subject of the current article
487 %s Current score file name
488 %d Number of dormant articles
489 %r Number of articles that have been marked as read in this session
490 %E Number of articles expunged by the score files"
494 (defcustom gnus-summary-mark-below 0
495 "*Mark all articles with a score below this variable as read.
496 This variable is local to each summary buffer and usually set by the
501 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
502 "*List of functions used for sorting articles in the summary buffer.
503 This variable is only used when not using a threaded display."
505 :type '(repeat (choice (function-item gnus-article-sort-by-number)
506 (function-item gnus-article-sort-by-author)
507 (function-item gnus-article-sort-by-subject)
508 (function-item gnus-article-sort-by-date)
509 (function-item gnus-article-sort-by-score)
510 (function :tag "other"))))
512 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
513 "*List of functions used for sorting threads in the summary buffer.
514 By default, threads are sorted by article number.
516 Each function takes two threads and return non-nil if the first thread
517 should be sorted before the other. If you use more than one function,
518 the primary sort function should be the last. You should probably
519 always include `gnus-thread-sort-by-number' in the list of sorting
520 functions -- preferably first.
522 Ready-made functions include `gnus-thread-sort-by-number',
523 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
524 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
525 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
527 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
528 (function-item gnus-thread-sort-by-author)
529 (function-item gnus-thread-sort-by-subject)
530 (function-item gnus-thread-sort-by-date)
531 (function-item gnus-thread-sort-by-score)
532 (function-item gnus-thread-sort-by-total-score)
533 (function :tag "other"))))
535 (defcustom gnus-thread-score-function '+
536 "*Function used for calculating the total score of a thread.
538 The function is called with the scores of the article and each
539 subthread and should then return the score of the thread.
541 Some functions you can use are `+', `max', or `min'."
545 (defcustom gnus-summary-expunge-below nil
546 "All articles that have a score less than this variable will be expunged."
548 :type '(choice (const :tag "off" nil)
551 (defcustom gnus-thread-expunge-below nil
552 "All threads that have a total score less than this variable will be expunged.
553 See `gnus-thread-score-function' for en explanation of what a
554 \"thread score\" is."
556 :type '(choice (const :tag "off" nil)
559 (defcustom gnus-summary-mode-hook nil
560 "*A hook for Gnus summary mode.
561 This hook is run before any variables are set in the summary buffer."
565 (defcustom gnus-summary-menu-hook nil
566 "*Hook run after the creation of the summary mode menu."
570 (defcustom gnus-summary-exit-hook nil
571 "*A hook called on exit from the summary buffer."
575 (defcustom gnus-summary-prepare-hook nil
576 "*A hook called after the summary buffer has been generated.
577 If you want to modify the summary buffer, you can use this hook."
581 (defcustom gnus-summary-generate-hook nil
582 "*A hook run just before generating the summary buffer.
583 This hook is commonly used to customize threading variables and the
588 (defcustom gnus-select-group-hook nil
589 "*A hook called when a newsgroup is selected.
591 If you'd like to simplify subjects like the
592 `gnus-summary-next-same-subject' command does, you can use the
595 (setq gnus-select-group-hook
598 (mapcar (lambda (header)
599 (mail-header-set-subject
601 (gnus-simplify-subject
602 (mail-header-subject header) 're-only)))
603 gnus-newsgroup-headers))))"
607 (defcustom gnus-select-article-hook nil
608 "*A hook called when an article is selected."
612 (defcustom gnus-visual-mark-article-hook
613 (list 'gnus-highlight-selected-summary)
614 "*Hook run after selecting an article in the summary buffer.
615 It is meant to be used for highlighting the article in some way. It
616 is not run if `gnus-visual' is nil."
620 (defcustom gnus-parse-headers-hook
621 (list 'gnus-decode-rfc1522)
622 "*A hook called before parsing the headers."
626 (defcustom gnus-exit-group-hook nil
627 "*A hook called when exiting (not quitting) summary mode."
631 (defcustom gnus-summary-update-hook
632 (list 'gnus-summary-highlight-line)
633 "*A hook called when a summary line is changed.
634 The hook will not be called if `gnus-visual' is nil.
636 The default function `gnus-summary-highlight-line' will
637 highlight the line according to the `gnus-summary-highlight'
642 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
643 "*A hook called when an article is selected for the first time.
644 The hook is intended to mark an article as read (or unread)
645 automatically when it is selected."
649 (defcustom gnus-group-no-more-groups-hook nil
650 "*A hook run when returning to group mode having no more (unread) groups."
654 (defface gnus-summary-selected-face '((t
656 "Face used for selected articles.")
658 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
659 "Face used for highlighting the current article in the summary buffer."
663 (defface gnus-summary-cancelled-face
665 (:foreground "yellow" :background "black")))
666 "Face used for cancelled articles.")
668 (defface gnus-summary-high-ticked-face
671 (:foreground "pink" :bold t))
674 (:foreground "firebrick" :bold t))
677 "Face used for high interest ticked articles.")
679 (defface gnus-summary-low-ticked-face
682 (:foreground "pink" :italic t))
685 (:foreground "firebrick" :italic t))
688 "Face used for low interest ticked articles.")
690 (defface gnus-summary-normal-ticked-face
693 (:foreground "pink"))
696 (:foreground "firebrick"))
699 "Face used for normal interest ticked articles.")
701 (defface gnus-summary-high-ancient-face
704 (:foreground "SkyBlue" :bold t))
707 (:foreground "RoyalBlue" :bold t))
710 "Face used for high interest ancient articles.")
712 (defface gnus-summary-low-ancient-face
715 (:foreground "SkyBlue" :italic t))
718 (:foreground "RoyalBlue" :italic t))
721 "Face used for low interest ancient articles.")
723 (defface gnus-summary-normal-ancient-face
726 (:foreground "SkyBlue"))
729 (:foreground "RoyalBlue"))
732 "Face used for normal interest ancient articles.")
734 (defface gnus-summary-high-unread-face
737 "Face used for high interest unread articles.")
739 (defface gnus-summary-low-unread-face
742 "Face used for low interest unread articles.")
744 (defface gnus-summary-normal-unread-face
747 "Face used for normal interest unread articles.")
749 (defface gnus-summary-high-read-face
752 (:foreground "PaleGreen"
756 (:foreground "DarkGreen"
760 "Face used for high interest read articles.")
762 (defface gnus-summary-low-read-face
765 (:foreground "PaleGreen"
769 (:foreground "DarkGreen"
773 "Face used for low interest read articles.")
775 (defface gnus-summary-normal-read-face
778 (:foreground "PaleGreen"))
781 (:foreground "DarkGreen"))
784 "Face used for normal interest read articles.")
786 (defcustom gnus-summary-highlight
787 '(((= mark gnus-canceled-mark)
788 . gnus-summary-cancelled-face)
789 ((and (> score default)
790 (or (= mark gnus-dormant-mark)
791 (= mark gnus-ticked-mark)))
792 . gnus-summary-high-ticked-face)
793 ((and (< score default)
794 (or (= mark gnus-dormant-mark)
795 (= mark gnus-ticked-mark)))
796 . gnus-summary-low-ticked-face)
797 ((or (= mark gnus-dormant-mark)
798 (= mark gnus-ticked-mark))
799 . gnus-summary-normal-ticked-face)
800 ((and (> score default) (= mark gnus-ancient-mark))
801 . gnus-summary-high-ancient-face)
802 ((and (< score default) (= mark gnus-ancient-mark))
803 . gnus-summary-low-ancient-face)
804 ((= mark gnus-ancient-mark)
805 . gnus-summary-normal-ancient-face)
806 ((and (> score default) (= mark gnus-unread-mark))
807 . gnus-summary-high-unread-face)
808 ((and (< score default) (= mark gnus-unread-mark))
809 . gnus-summary-low-unread-face)
810 ((and (= mark gnus-unread-mark))
811 . gnus-summary-normal-unread-face)
813 . gnus-summary-high-read-face)
815 . gnus-summary-low-read-face)
817 . gnus-summary-normal-read-face))
818 "Controls the highlighting of summary buffer lines.
820 A list of (FORM . FACE) pairs. When deciding how a a particular
821 summary line should be displayed, each form is evaluated. The content
822 of the face field after the first true form is used. You can change
823 how those summary lines are displayed, by editing the face field.
825 You can use the following variables in the FORM field.
827 score: The articles score
828 default: The default article score.
829 below: The score below which articles are automatically marked as read.
830 mark: The articles mark."
832 :type '(repeat (cons (sexp :tag "Form" nil)
835 ;;; Internal variables
837 (defvar gnus-scores-exclude-files nil)
839 (defvar gnus-summary-display-table
840 ;; Change the display table. Odd characters have a tendency to mess
841 ;; up nicely formatted displays - we make all possible glyphs
842 ;; display only a single character.
844 ;; We start from the standard display table, if any.
845 (let ((table (or (copy-sequence standard-display-table)
846 (make-display-table)))
847 ;; Nix out all the control chars...
849 (while (>= (setq i (1- i)) 0)
851 ;; ... but not newline and cr, of course. (cr is necessary for the
852 ;; selective display).
855 ;; We nix out any glyphs over 126 that are not set already.
857 (while (>= (setq i (1- i)) 127)
858 ;; Only modify if the entry is nil.
860 (aset table i [??]))))
862 "Display table used in summary mode buffers.")
864 (defvar gnus-original-article nil)
865 (defvar gnus-article-internal-prepare-hook nil)
866 (defvar gnus-newsgroup-process-stack nil)
868 (defvar gnus-thread-indent-array nil)
869 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
871 ;; Avoid highlighting in kill files.
872 (defvar gnus-summary-inhibit-highlight nil)
873 (defvar gnus-newsgroup-selected-overlay nil)
874 (defvar gnus-inhibit-limiting nil)
875 (defvar gnus-newsgroup-adaptive-score-file nil)
876 (defvar gnus-current-score-file nil)
877 (defvar gnus-current-move-group nil)
878 (defvar gnus-current-copy-group nil)
879 (defvar gnus-current-crosspost-group nil)
881 (defvar gnus-newsgroup-dependencies nil)
882 (defvar gnus-newsgroup-adaptive nil)
883 (defvar gnus-summary-display-article-function nil)
884 (defvar gnus-summary-highlight-line-function nil
885 "Function called after highlighting a summary line.")
887 (defvar gnus-summary-line-format-alist
888 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
889 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
890 (?s gnus-tmp-subject-or-nil ?s)
891 (?n gnus-tmp-name ?s)
892 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
894 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
896 (?F gnus-tmp-from ?s)
897 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
898 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
899 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
900 (?o (gnus-date-iso8601 gnus-tmp-header) ?s)
901 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
902 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
903 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
904 (?L gnus-tmp-lines ?d)
905 (?I gnus-tmp-indentation ?s)
906 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
907 (?R gnus-tmp-replied ?c)
908 (?\[ gnus-tmp-opening-bracket ?c)
909 (?\] gnus-tmp-closing-bracket ?c)
910 (?\> (make-string gnus-tmp-level ? ) ?s)
911 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
912 (?i gnus-tmp-score ?d)
913 (?z gnus-tmp-score-char ?c)
914 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
915 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
916 (?U gnus-tmp-unread ?c)
917 (?t (gnus-summary-number-of-articles-in-thread
918 (and (boundp 'thread) (car thread)) gnus-tmp-level)
920 (?e (gnus-summary-number-of-articles-in-thread
921 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
923 (?u gnus-tmp-user-defined ?s)
924 (?P (gnus-pick-line-number) ?d))
925 "An alist of format specifications that can appear in summary lines,
926 and what variables they correspond with, along with the type of the
927 variable (string, integer, character, etc).")
929 (defvar gnus-summary-dummy-line-format-alist
930 `((?S gnus-tmp-subject ?s)
931 (?N gnus-tmp-number ?d)
932 (?u gnus-tmp-user-defined ?s)))
934 (defvar gnus-summary-mode-line-format-alist
935 `((?G gnus-tmp-group-name ?s)
936 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
937 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
938 (?A gnus-tmp-article-number ?d)
939 (?Z gnus-tmp-unread-and-unselected ?s)
941 (?U gnus-tmp-unread-and-unticked ?d)
942 (?S gnus-tmp-subject ?s)
943 (?e gnus-tmp-unselected ?d)
944 (?u gnus-tmp-user-defined ?s)
945 (?d (length gnus-newsgroup-dormant) ?d)
946 (?t (length gnus-newsgroup-marked) ?d)
947 (?r (length gnus-newsgroup-reads) ?d)
948 (?E gnus-newsgroup-expunged-tally ?d)
949 (?s (gnus-current-score-file-nondirectory) ?s)))
951 (defvar gnus-last-search-regexp nil
952 "Default regexp for article search command.")
954 (defvar gnus-last-shell-command nil
955 "Default shell command on article.")
957 (defvar gnus-newsgroup-begin nil)
958 (defvar gnus-newsgroup-end nil)
959 (defvar gnus-newsgroup-last-rmail nil)
960 (defvar gnus-newsgroup-last-mail nil)
961 (defvar gnus-newsgroup-last-folder nil)
962 (defvar gnus-newsgroup-last-file nil)
963 (defvar gnus-newsgroup-auto-expire nil)
964 (defvar gnus-newsgroup-active nil)
966 (defvar gnus-newsgroup-data nil)
967 (defvar gnus-newsgroup-data-reverse nil)
968 (defvar gnus-newsgroup-limit nil)
969 (defvar gnus-newsgroup-limits nil)
971 (defvar gnus-newsgroup-unreads nil
972 "List of unread articles in the current newsgroup.")
974 (defvar gnus-newsgroup-unselected nil
975 "List of unselected unread articles in the current newsgroup.")
977 (defvar gnus-newsgroup-reads nil
978 "Alist of read articles and article marks in the current newsgroup.")
980 (defvar gnus-newsgroup-expunged-tally nil)
982 (defvar gnus-newsgroup-marked nil
983 "List of ticked articles in the current newsgroup (a subset of unread art).")
985 (defvar gnus-newsgroup-killed nil
986 "List of ranges of articles that have been through the scoring process.")
988 (defvar gnus-newsgroup-cached nil
989 "List of articles that come from the article cache.")
991 (defvar gnus-newsgroup-saved nil
992 "List of articles that have been saved.")
994 (defvar gnus-newsgroup-kill-headers nil)
996 (defvar gnus-newsgroup-replied nil
997 "List of articles that have been replied to in the current newsgroup.")
999 (defvar gnus-newsgroup-expirable nil
1000 "List of articles in the current newsgroup that can be expired.")
1002 (defvar gnus-newsgroup-processable nil
1003 "List of articles in the current newsgroup that can be processed.")
1005 (defvar gnus-newsgroup-bookmarks nil
1006 "List of articles in the current newsgroup that have bookmarks.")
1008 (defvar gnus-newsgroup-dormant nil
1009 "List of dormant articles in the current newsgroup.")
1011 (defvar gnus-newsgroup-scored nil
1012 "List of scored articles in the current newsgroup.")
1014 (defvar gnus-newsgroup-headers nil
1015 "List of article headers in the current newsgroup.")
1017 (defvar gnus-newsgroup-threads nil)
1019 (defvar gnus-newsgroup-prepared nil
1020 "Whether the current group has been prepared properly.")
1022 (defvar gnus-newsgroup-ancient nil
1023 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1025 (defvar gnus-newsgroup-sparse nil)
1027 (defvar gnus-current-article nil)
1028 (defvar gnus-article-current nil)
1029 (defvar gnus-current-headers nil)
1030 (defvar gnus-have-all-headers nil)
1031 (defvar gnus-last-article nil)
1032 (defvar gnus-newsgroup-history nil)
1034 (defconst gnus-summary-local-variables
1035 '(gnus-newsgroup-name
1036 gnus-newsgroup-begin gnus-newsgroup-end
1037 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1038 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1039 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1040 gnus-newsgroup-unselected gnus-newsgroup-marked
1041 gnus-newsgroup-reads gnus-newsgroup-saved
1042 gnus-newsgroup-replied gnus-newsgroup-expirable
1043 gnus-newsgroup-processable gnus-newsgroup-killed
1044 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1045 gnus-newsgroup-headers gnus-newsgroup-threads
1046 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1047 gnus-current-article gnus-current-headers gnus-have-all-headers
1048 gnus-last-article gnus-article-internal-prepare-hook
1049 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1050 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1051 gnus-thread-expunge-below
1052 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1053 (gnus-summary-mark-below . global)
1054 gnus-newsgroup-active gnus-scores-exclude-files
1055 gnus-newsgroup-history gnus-newsgroup-ancient
1056 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1057 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1058 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1059 (gnus-newsgroup-expunged-tally . 0)
1060 gnus-cache-removable-articles gnus-newsgroup-cached
1061 gnus-newsgroup-data gnus-newsgroup-data-reverse
1062 gnus-newsgroup-limit gnus-newsgroup-limits)
1063 "Variables that are buffer-local to the summary buffers.")
1065 ;; Byte-compiler warning.
1066 (defvar gnus-article-mode-map)
1068 ;; Subject simplification.
1070 (defsubst gnus-simplify-subject-re (subject)
1071 "Remove \"Re:\" from subject lines."
1072 (if (string-match "^[Rr][Ee]: *" subject)
1073 (substring subject (match-end 0))
1076 (defun gnus-simplify-subject (subject &optional re-only)
1077 "Remove `Re:' and words in parentheses.
1078 If RE-ONLY is non-nil, strip leading `Re:'s only."
1079 (let ((case-fold-search t)) ;Ignore case.
1080 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1081 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1082 (setq subject (substring subject (match-end 0))))
1083 ;; Remove uninteresting prefixes.
1084 (when (and (not re-only)
1085 gnus-simplify-ignored-prefixes
1086 (string-match gnus-simplify-ignored-prefixes subject))
1087 (setq subject (substring subject (match-end 0))))
1088 ;; Remove words in parentheses from end.
1090 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1091 (setq subject (substring subject 0 (match-beginning 0)))))
1092 ;; Return subject string.
1095 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1097 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
1098 (defun gnus-simplify-buffer-fuzzy ()
1099 (let ((case-fold-search t))
1100 (goto-char (point-min))
1101 (while (search-forward "\t" nil t)
1102 (replace-match " " t t))
1103 (goto-char (point-min))
1104 (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *" nil t)
1105 (goto-char (match-beginning 0))
1107 (looking-at "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1108 (looking-at "^[[].*: .*[]]$"))
1109 (goto-char (point-min))
1110 (while (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *"
1112 (replace-match "" t t))
1113 (goto-char (point-min))
1114 (while (re-search-forward "^[[].*: .*[]]$" nil t)
1115 (goto-char (match-end 0))
1118 (progn (goto-char (match-beginning 0)))
1119 (re-search-forward ":"))))
1120 (goto-char (point-min))
1121 (while (re-search-forward " *[[{(][^()\n]*[]})] *$" nil t)
1122 (replace-match "" t t))
1123 (goto-char (point-min))
1124 (while (re-search-forward " +" nil t)
1125 (replace-match " " t t))
1126 (goto-char (point-min))
1127 (while (re-search-forward " $" nil t)
1128 (replace-match "" t t))
1129 (goto-char (point-min))
1130 (while (re-search-forward "^ +" nil t)
1131 (replace-match "" t t))
1132 (goto-char (point-min))
1133 (when gnus-simplify-subject-fuzzy-regexp
1134 (if (listp gnus-simplify-subject-fuzzy-regexp)
1135 (let ((list gnus-simplify-subject-fuzzy-regexp))
1137 (goto-char (point-min))
1138 (while (re-search-forward (car list) nil t)
1139 (replace-match "" t t))
1140 (setq list (cdr list))))
1141 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
1142 (replace-match "" t t))))))
1144 (defun gnus-simplify-subject-fuzzy (subject)
1145 "Simplify a subject string fuzzily."
1147 (gnus-set-work-buffer)
1148 (let ((case-fold-search t))
1150 (inline (gnus-simplify-buffer-fuzzy))
1153 (defsubst gnus-simplify-subject-fully (subject)
1154 "Simplify a subject string according to the user's wishes."
1156 ((null gnus-summary-gather-subject-limit)
1157 (gnus-simplify-subject-re subject))
1158 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1159 (gnus-simplify-subject-fuzzy subject))
1160 ((numberp gnus-summary-gather-subject-limit)
1161 (gnus-limit-string (gnus-simplify-subject-re subject)
1162 gnus-summary-gather-subject-limit))
1166 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1167 "Check whether two subjects are equal. If optional argument
1168 simple-first is t, first argument is already simplified."
1170 ((null simple-first)
1171 (equal (gnus-simplify-subject-fully s1)
1172 (gnus-simplify-subject-fully s2)))
1175 (gnus-simplify-subject-fully s2)))))
1177 (defun gnus-offer-save-summaries ()
1178 "Offer to save all active summary buffers."
1180 (let ((buflist (buffer-list))
1182 ;; Go through all buffers and find all summaries.
1184 (and (setq bufname (buffer-name (car buflist)))
1185 (string-match "Summary" bufname)
1187 (set-buffer bufname)
1188 ;; We check that this is, indeed, a summary buffer.
1189 (and (eq major-mode 'gnus-summary-mode)
1190 ;; Also make sure this isn't bogus.
1191 gnus-newsgroup-prepared))
1192 (push bufname buffers))
1193 (setq buflist (cdr buflist)))
1194 ;; Go through all these summary buffers and offer to save them.
1197 "Update summary buffer %s? "
1198 (lambda (buf) (set-buffer buf) (gnus-summary-exit))
1201 (defun gnus-summary-bubble-group ()
1202 "Increase the score of the current group.
1203 This is a handy function to add to `gnus-summary-exit-hook' to
1204 increase the score of each group you read."
1205 (gnus-group-add-score gnus-newsgroup-name))
1209 ;;; Gnus summary mode
1212 (put 'gnus-summary-mode 'mode-class 'special)
1215 ;; Non-orthogonal keys
1217 (gnus-define-keys gnus-summary-mode-map
1218 " " gnus-summary-next-page
1219 "\177" gnus-summary-prev-page
1220 [delete] gnus-summary-prev-page
1221 "\r" gnus-summary-scroll-up
1222 "n" gnus-summary-next-unread-article
1223 "p" gnus-summary-prev-unread-article
1224 "N" gnus-summary-next-article
1225 "P" gnus-summary-prev-article
1226 "\M-\C-n" gnus-summary-next-same-subject
1227 "\M-\C-p" gnus-summary-prev-same-subject
1228 "\M-n" gnus-summary-next-unread-subject
1229 "\M-p" gnus-summary-prev-unread-subject
1230 "." gnus-summary-first-unread-article
1231 "," gnus-summary-best-unread-article
1232 "\M-s" gnus-summary-search-article-forward
1233 "\M-r" gnus-summary-search-article-backward
1234 "<" gnus-summary-beginning-of-article
1235 ">" gnus-summary-end-of-article
1236 "j" gnus-summary-goto-article
1237 "^" gnus-summary-refer-parent-article
1238 "\M-^" gnus-summary-refer-article
1239 "u" gnus-summary-tick-article-forward
1240 "!" gnus-summary-tick-article-forward
1241 "U" gnus-summary-tick-article-backward
1242 "d" gnus-summary-mark-as-read-forward
1243 "D" gnus-summary-mark-as-read-backward
1244 "E" gnus-summary-mark-as-expirable
1245 "\M-u" gnus-summary-clear-mark-forward
1246 "\M-U" gnus-summary-clear-mark-backward
1247 "k" gnus-summary-kill-same-subject-and-select
1248 "\C-k" gnus-summary-kill-same-subject
1249 "\M-\C-k" gnus-summary-kill-thread
1250 "\M-\C-l" gnus-summary-lower-thread
1251 "e" gnus-summary-edit-article
1252 "#" gnus-summary-mark-as-processable
1253 "\M-#" gnus-summary-unmark-as-processable
1254 "\M-\C-t" gnus-summary-toggle-threads
1255 "\M-\C-s" gnus-summary-show-thread
1256 "\M-\C-h" gnus-summary-hide-thread
1257 "\M-\C-f" gnus-summary-next-thread
1258 "\M-\C-b" gnus-summary-prev-thread
1259 "\M-\C-u" gnus-summary-up-thread
1260 "\M-\C-d" gnus-summary-down-thread
1261 "&" gnus-summary-execute-command
1262 "c" gnus-summary-catchup-and-exit
1263 "\C-w" gnus-summary-mark-region-as-read
1264 "\C-t" gnus-summary-toggle-truncation
1265 "?" gnus-summary-mark-as-dormant
1266 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1267 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1268 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1269 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1270 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1271 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1272 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1273 "=" gnus-summary-expand-window
1274 "\C-x\C-s" gnus-summary-reselect-current-group
1275 "\M-g" gnus-summary-rescan-group
1276 "w" gnus-summary-stop-page-breaking
1277 "\C-c\C-r" gnus-summary-caesar-message
1278 "\M-t" gnus-summary-toggle-mime
1279 "f" gnus-summary-followup
1280 "F" gnus-summary-followup-with-original
1281 "C" gnus-summary-cancel-article
1282 "r" gnus-summary-reply
1283 "R" gnus-summary-reply-with-original
1284 "\C-c\C-f" gnus-summary-mail-forward
1285 "o" gnus-summary-save-article
1286 "\C-o" gnus-summary-save-article-mail
1287 "|" gnus-summary-pipe-output
1288 "\M-k" gnus-summary-edit-local-kill
1289 "\M-K" gnus-summary-edit-global-kill
1291 "\C-c\C-d" gnus-summary-describe-group
1292 "q" gnus-summary-exit
1293 "Q" gnus-summary-exit-no-update
1294 "\C-c\C-i" gnus-info-find-node
1295 gnus-mouse-2 gnus-mouse-pick-article
1296 "m" gnus-summary-mail-other-window
1297 "a" gnus-summary-post-news
1298 "x" gnus-summary-limit-to-unread
1299 "s" gnus-summary-isearch-article
1300 "t" gnus-article-hide-headers
1301 "g" gnus-summary-show-article
1302 "l" gnus-summary-goto-last-article
1303 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1304 "\C-d" gnus-summary-enter-digest-group
1305 "\M-\C-d" gnus-summary-read-document
1307 "*" gnus-cache-enter-article
1308 "\M-*" gnus-cache-remove-article
1309 "\M-&" gnus-summary-universal-argument
1310 "\C-l" gnus-recenter
1311 "I" gnus-summary-increase-score
1312 "L" gnus-summary-lower-score
1314 "V" gnus-summary-score-map
1315 "X" gnus-uu-extract-map
1316 "S" gnus-summary-send-map)
1318 ;; Sort of orthogonal keymap
1319 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1320 "t" gnus-summary-tick-article-forward
1321 "!" gnus-summary-tick-article-forward
1322 "d" gnus-summary-mark-as-read-forward
1323 "r" gnus-summary-mark-as-read-forward
1324 "c" gnus-summary-clear-mark-forward
1325 " " gnus-summary-clear-mark-forward
1326 "e" gnus-summary-mark-as-expirable
1327 "x" gnus-summary-mark-as-expirable
1328 "?" gnus-summary-mark-as-dormant
1329 "b" gnus-summary-set-bookmark
1330 "B" gnus-summary-remove-bookmark
1331 "#" gnus-summary-mark-as-processable
1332 "\M-#" gnus-summary-unmark-as-processable
1333 "S" gnus-summary-limit-include-expunged
1334 "C" gnus-summary-catchup
1335 "H" gnus-summary-catchup-to-here
1336 "\C-c" gnus-summary-catchup-all
1337 "k" gnus-summary-kill-same-subject-and-select
1338 "K" gnus-summary-kill-same-subject
1339 "P" gnus-uu-mark-map)
1341 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1342 "c" gnus-summary-clear-above
1343 "u" gnus-summary-tick-above
1344 "m" gnus-summary-mark-above
1345 "k" gnus-summary-kill-below)
1347 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1348 "/" gnus-summary-limit-to-subject
1349 "n" gnus-summary-limit-to-articles
1350 "w" gnus-summary-pop-limit
1351 "s" gnus-summary-limit-to-subject
1352 "a" gnus-summary-limit-to-author
1353 "u" gnus-summary-limit-to-unread
1354 "m" gnus-summary-limit-to-marks
1355 "v" gnus-summary-limit-to-score
1356 "D" gnus-summary-limit-include-dormant
1357 "d" gnus-summary-limit-exclude-dormant
1358 ;; "t" gnus-summary-limit-exclude-thread
1359 "E" gnus-summary-limit-include-expunged
1360 "c" gnus-summary-limit-exclude-childless-dormant
1361 "C" gnus-summary-limit-mark-excluded-as-read)
1363 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1364 "n" gnus-summary-next-unread-article
1365 "p" gnus-summary-prev-unread-article
1366 "N" gnus-summary-next-article
1367 "P" gnus-summary-prev-article
1368 "\C-n" gnus-summary-next-same-subject
1369 "\C-p" gnus-summary-prev-same-subject
1370 "\M-n" gnus-summary-next-unread-subject
1371 "\M-p" gnus-summary-prev-unread-subject
1372 "f" gnus-summary-first-unread-article
1373 "b" gnus-summary-best-unread-article
1374 "j" gnus-summary-goto-article
1375 "g" gnus-summary-goto-subject
1376 "l" gnus-summary-goto-last-article
1377 "p" gnus-summary-pop-article)
1379 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1380 "k" gnus-summary-kill-thread
1381 "l" gnus-summary-lower-thread
1382 "i" gnus-summary-raise-thread
1383 "T" gnus-summary-toggle-threads
1384 "t" gnus-summary-rethread-current
1385 "^" gnus-summary-reparent-thread
1386 "s" gnus-summary-show-thread
1387 "S" gnus-summary-show-all-threads
1388 "h" gnus-summary-hide-thread
1389 "H" gnus-summary-hide-all-threads
1390 "n" gnus-summary-next-thread
1391 "p" gnus-summary-prev-thread
1392 "u" gnus-summary-up-thread
1393 "o" gnus-summary-top-thread
1394 "d" gnus-summary-down-thread
1395 "#" gnus-uu-mark-thread
1396 "\M-#" gnus-uu-unmark-thread)
1398 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1399 "g" gnus-summary-prepare
1400 "c" gnus-summary-insert-cached-articles)
1402 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1403 "c" gnus-summary-catchup-and-exit
1404 "C" gnus-summary-catchup-all-and-exit
1405 "E" gnus-summary-exit-no-update
1406 "Q" gnus-summary-exit
1407 "Z" gnus-summary-exit
1408 "n" gnus-summary-catchup-and-goto-next-group
1409 "R" gnus-summary-reselect-current-group
1410 "G" gnus-summary-rescan-group
1411 "N" gnus-summary-next-group
1412 "P" gnus-summary-prev-group)
1414 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1415 " " gnus-summary-next-page
1416 "n" gnus-summary-next-page
1417 "\177" gnus-summary-prev-page
1418 [delete] gnus-summary-prev-page
1419 "p" gnus-summary-prev-page
1420 "\r" gnus-summary-scroll-up
1421 "<" gnus-summary-beginning-of-article
1422 ">" gnus-summary-end-of-article
1423 "b" gnus-summary-beginning-of-article
1424 "e" gnus-summary-end-of-article
1425 "^" gnus-summary-refer-parent-article
1426 "r" gnus-summary-refer-parent-article
1427 "R" gnus-summary-refer-references
1428 "g" gnus-summary-show-article
1429 "s" gnus-summary-isearch-article)
1431 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1432 "b" gnus-article-add-buttons
1433 "B" gnus-article-add-buttons-to-head
1434 "o" gnus-article-treat-overstrike
1435 "e" gnus-article-emphasize
1436 "w" gnus-article-fill-cited-article
1437 "c" gnus-article-remove-cr
1438 "q" gnus-article-de-quoted-unreadable
1439 "f" gnus-article-display-x-face
1440 "l" gnus-summary-stop-page-breaking
1441 "r" gnus-summary-caesar-message
1442 "t" gnus-article-hide-headers
1443 "v" gnus-summary-verbose-headers
1444 "m" gnus-summary-toggle-mime)
1446 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1447 "a" gnus-article-hide
1448 "h" gnus-article-hide-headers
1449 "b" gnus-article-hide-boring-headers
1450 "s" gnus-article-hide-signature
1451 "c" gnus-article-hide-citation
1452 "p" gnus-article-hide-pgp
1453 "P" gnus-article-hide-pem
1454 "\C-c" gnus-article-hide-citation-maybe)
1456 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1457 "a" gnus-article-highlight
1458 "h" gnus-article-highlight-headers
1459 "c" gnus-article-highlight-citation
1460 "s" gnus-article-highlight-signature)
1462 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1463 "z" gnus-article-date-ut
1464 "u" gnus-article-date-ut
1465 "l" gnus-article-date-local
1466 "e" gnus-article-date-lapsed
1467 "o" gnus-article-date-original)
1469 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1470 "t" gnus-article-remove-trailing-blank-lines
1471 "l" gnus-article-strip-leading-blank-lines
1472 "m" gnus-article-strip-multiple-blank-lines
1473 "a" gnus-article-strip-blank-lines)
1475 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1477 "f" gnus-summary-fetch-faq
1478 "d" gnus-summary-describe-group
1479 "h" gnus-summary-describe-briefly
1480 "i" gnus-info-find-node)
1482 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1483 "e" gnus-summary-expire-articles
1484 "\M-\C-e" gnus-summary-expire-articles-now
1485 "\177" gnus-summary-delete-article
1486 [delete] gnus-summary-delete-article
1487 "m" gnus-summary-move-article
1488 "r" gnus-summary-respool-article
1489 "w" gnus-summary-edit-article
1490 "c" gnus-summary-copy-article
1491 "B" gnus-summary-crosspost-article
1492 "q" gnus-summary-respool-query
1493 "i" gnus-summary-import-article
1494 "p" gnus-summary-article-posted-p)
1496 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1497 "o" gnus-summary-save-article
1498 "m" gnus-summary-save-article-mail
1499 "F" gnus-summary-write-article-file
1500 "r" gnus-summary-save-article-rmail
1501 "f" gnus-summary-save-article-file
1502 "b" gnus-summary-save-article-body-file
1503 "h" gnus-summary-save-article-folder
1504 "v" gnus-summary-save-article-vm
1505 "p" gnus-summary-pipe-output
1506 "s" gnus-soup-add-article))
1508 (defun gnus-summary-make-menu-bar ()
1509 (gnus-turn-off-edit-menu 'summary)
1511 (unless (boundp 'gnus-summary-misc-menu)
1514 gnus-summary-kill-menu gnus-summary-mode-map ""
1519 ["Enter score..." gnus-summary-score-entry t]
1520 ["Customize" gnus-score-customize t])
1521 (gnus-make-score-map 'increase)
1522 (gnus-make-score-map 'lower)
1524 ["Kill below" gnus-summary-kill-below t]
1525 ["Mark above" gnus-summary-mark-above t]
1526 ["Tick above" gnus-summary-tick-above t]
1527 ["Clear above" gnus-summary-clear-above t])
1528 ["Current score" gnus-summary-current-score t]
1529 ["Set score" gnus-summary-set-score t]
1530 ["Switch current score file..." gnus-score-change-score-file t]
1531 ["Set mark below..." gnus-score-set-mark-below t]
1532 ["Set expunge below..." gnus-score-set-expunge-below t]
1533 ["Edit current score file" gnus-score-edit-current-scores t]
1534 ["Edit score file" gnus-score-edit-file t]
1535 ["Trace score" gnus-score-find-trace t]
1536 ["Find words" gnus-score-find-favourite-words t]
1537 ["Rescore buffer" gnus-summary-rescore t]
1538 ["Increase score..." gnus-summary-increase-score t]
1539 ["Lower score..." gnus-summary-lower-score t]))))
1542 ["Ask" (gnus-score-set-default 'gnus-score-default-header nil)
1544 :selected (null gnus-score-default-header)]
1545 ["From" (gnus-score-set-default 'gnus-score-default-header 'a)
1547 :selected (eq gnus-score-default-header 'a)]
1548 ["Subject" (gnus-score-set-default 'gnus-score-default-header 's)
1550 :selected (eq gnus-score-default-header 's)]
1552 (gnus-score-set-default 'gnus-score-default-header 'b)
1554 :selected (eq gnus-score-default-header 'b )]
1556 (gnus-score-set-default 'gnus-score-default-header 'h)
1558 :selected (eq gnus-score-default-header 'h )]
1559 ["Message-ID" (gnus-score-set-default 'gnus-score-default-header 'i)
1561 :selected (eq gnus-score-default-header 'i )]
1562 ["Thread" (gnus-score-set-default 'gnus-score-default-header 't)
1564 :selected (eq gnus-score-default-header 't )]
1566 (gnus-score-set-default 'gnus-score-default-header 'x)
1568 :selected (eq gnus-score-default-header 'x )]
1569 ["Lines" (gnus-score-set-default 'gnus-score-default-header 'l)
1571 :selected (eq gnus-score-default-header 'l )]
1572 ["Date" (gnus-score-set-default 'gnus-score-default-header 'd)
1574 :selected (eq gnus-score-default-header 'd )]
1575 ["Followups to author"
1576 (gnus-score-set-default 'gnus-score-default-header 'f)
1578 :selected (eq gnus-score-default-header 'f )])
1580 ["Ask" (gnus-score-set-default 'gnus-score-default-type nil)
1582 :selected (null gnus-score-default-type)]
1583 ;; The `:active' key is commented out in the following,
1584 ;; because the GNU Emacs hack to support radio buttons use
1585 ;; active to indicate which button is selected.
1586 ["Substring" (gnus-score-set-default 'gnus-score-default-type 's)
1588 ;; :active (not (memq gnus-score-default-header '(l d)))
1589 :selected (eq gnus-score-default-type 's)]
1590 ["Regexp" (gnus-score-set-default 'gnus-score-default-type 'r)
1592 ;; :active (not (memq gnus-score-default-header '(l d)))
1593 :selected (eq gnus-score-default-type 'r)]
1594 ["Exact" (gnus-score-set-default 'gnus-score-default-type 'e)
1596 ;; :active (not (memq gnus-score-default-header '(l d)))
1597 :selected (eq gnus-score-default-type 'e)]
1598 ["Fuzzy" (gnus-score-set-default 'gnus-score-default-type 'f)
1600 ;; :active (not (memq gnus-score-default-header '(l d)))
1601 :selected (eq gnus-score-default-type 'f)]
1602 ["Before date" (gnus-score-set-default 'gnus-score-default-type 'b)
1604 ;; :active (eq (gnus-score-default-header 'd))
1605 :selected (eq gnus-score-default-type 'b)]
1606 ["At date" (gnus-score-set-default 'gnus-score-default-type 'n)
1608 ;; :active (eq (gnus-score-default-header 'd))
1609 :selected (eq gnus-score-default-type 'n)]
1610 ["After date" (gnus-score-set-default 'gnus-score-default-type 'a)
1612 ;; :active (eq (gnus-score-default-header 'd))
1613 :selected (eq gnus-score-default-type 'a)]
1615 (gnus-score-set-default 'gnus-score-default-type '<)
1617 ;; :active (eq (gnus-score-default-header 'l))
1618 :selected (eq gnus-score-default-type '<)]
1620 (gnus-score-set-default 'gnus-score-default-type '=)
1622 ;; :active (eq (gnus-score-default-header 'l))
1623 :selected (eq gnus-score-default-type '=)]
1624 ["Greater than number"
1625 (gnus-score-set-default 'gnus-score-default-type '>)
1627 ;; :active (eq (gnus-score-default-header 'l))
1628 :selected (eq gnus-score-default-type '>)])
1629 ["Default fold" gnus-score-default-fold-toggle
1631 :selected gnus-score-default-fold]
1633 ["Ask" (gnus-score-set-default 'gnus-score-default-duration nil)
1635 :selected (null gnus-score-default-duration)]
1637 (gnus-score-set-default 'gnus-score-default-duration 'p)
1639 :selected (eq gnus-score-default-duration 'p)]
1641 (gnus-score-set-default 'gnus-score-default-duration 't)
1643 :selected (eq gnus-score-default-duration 't)]
1645 (gnus-score-set-default 'gnus-score-default-duration 'i)
1647 :selected (eq gnus-score-default-duration 'i)]))
1650 gnus-summary-article-menu gnus-summary-mode-map ""
1653 ["All" gnus-article-hide t]
1654 ["Headers" gnus-article-hide-headers t]
1655 ["Signature" gnus-article-hide-signature t]
1656 ["Citation" gnus-article-hide-citation t]
1657 ["PGP" gnus-article-hide-pgp t]
1658 ["Boring headers" gnus-article-hide-boring-headers t])
1660 ["All" gnus-article-highlight t]
1661 ["Headers" gnus-article-highlight-headers t]
1662 ["Signature" gnus-article-highlight-signature t]
1663 ["Citation" gnus-article-highlight-citation t])
1665 ["Local" gnus-article-date-local t]
1666 ["UT" gnus-article-date-ut t]
1667 ["Original" gnus-article-date-original t]
1668 ["Lapsed" gnus-article-date-lapsed t])
1671 ["Leading" gnus-article-strip-leading-blank-lines t]
1672 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1673 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1674 ["All of the above" gnus-article-strip-blank-lines t])
1675 ["Overstrike" gnus-article-treat-overstrike t]
1676 ["Emphasis" gnus-article-emphasize t]
1677 ["Word wrap" gnus-article-fill-cited-article t]
1678 ["CR" gnus-article-remove-cr t]
1679 ["Show X-Face" gnus-article-display-x-face t]
1680 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1681 ["Rot 13" gnus-summary-caesar-message t]
1682 ["Add buttons" gnus-article-add-buttons t]
1683 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1684 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1685 ["Toggle MIME" gnus-summary-toggle-mime t]
1686 ["Verbose header" gnus-summary-verbose-headers t]
1687 ["Toggle header" gnus-summary-toggle-header t])
1689 ["Save in default format" gnus-summary-save-article t]
1690 ["Save in file" gnus-summary-save-article-file t]
1691 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1692 ["Write to file" gnus-summary-write-article-mail t]
1693 ["Save in MH folder" gnus-summary-save-article-folder t]
1694 ["Save in VM folder" gnus-summary-save-article-vm t]
1695 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1696 ["Save body in file" gnus-summary-save-article-body-file t]
1697 ["Pipe through a filter" gnus-summary-pipe-output t]
1698 ["Add to SOUP packet" gnus-soup-add-article t])
1700 ["Respool article..." gnus-summary-respool-article t]
1701 ["Move article..." gnus-summary-move-article
1702 (gnus-check-backend-function
1703 'request-move-article gnus-newsgroup-name)]
1704 ["Copy article..." gnus-summary-copy-article t]
1705 ["Crosspost article..." gnus-summary-crosspost-article
1706 (gnus-check-backend-function
1707 'request-replace-article gnus-newsgroup-name)]
1708 ["Import file..." gnus-summary-import-article t]
1709 ["Check if posted" gnus-summary-article-posted-p t]
1710 ["Edit article" gnus-summary-edit-article
1711 (not (gnus-group-read-only-p))]
1712 ["Delete article" gnus-summary-delete-article
1713 (gnus-check-backend-function
1714 'request-expire-articles gnus-newsgroup-name)]
1715 ["Query respool" gnus-summary-respool-query t]
1716 ["Delete expirable articles" gnus-summary-expire-articles-now
1717 (gnus-check-backend-function
1718 'request-expire-articles gnus-newsgroup-name)])
1720 ["Uudecode" gnus-uu-decode-uu t]
1721 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1722 ["Unshar" gnus-uu-decode-unshar t]
1723 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1724 ["Save" gnus-uu-decode-save t]
1725 ["Binhex" gnus-uu-decode-binhex t]
1726 ["Postscript" gnus-uu-decode-postscript t])
1727 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1728 ["Isearch article..." gnus-summary-isearch-article t]
1729 ["Search articles forward..." gnus-summary-search-article-forward t]
1730 ["Search articles backward..." gnus-summary-search-article-backward t]
1731 ["Beginning of the article" gnus-summary-beginning-of-article t]
1732 ["End of the article" gnus-summary-end-of-article t]
1733 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1734 ["Fetch referenced articles" gnus-summary-refer-references t]
1735 ["Fetch article with id..." gnus-summary-refer-article t]
1736 ["Redisplay" gnus-summary-show-article t]))
1739 gnus-summary-thread-menu gnus-summary-mode-map ""
1741 ["Toggle threading" gnus-summary-toggle-threads t]
1742 ["Hide threads" gnus-summary-hide-all-threads t]
1743 ["Show threads" gnus-summary-show-all-threads t]
1744 ["Hide thread" gnus-summary-hide-thread t]
1745 ["Show thread" gnus-summary-show-thread t]
1746 ["Go to next thread" gnus-summary-next-thread t]
1747 ["Go to previous thread" gnus-summary-prev-thread t]
1748 ["Go down thread" gnus-summary-down-thread t]
1749 ["Go up thread" gnus-summary-up-thread t]
1750 ["Top of thread" gnus-summary-top-thread t]
1751 ["Mark thread as read" gnus-summary-kill-thread t]
1752 ["Lower thread score" gnus-summary-lower-thread t]
1753 ["Raise thread score" gnus-summary-raise-thread t]
1754 ["Rethread current" gnus-summary-rethread-current t]
1758 gnus-summary-post-menu gnus-summary-mode-map ""
1760 ["Post an article" gnus-summary-post-news t]
1761 ["Followup" gnus-summary-followup t]
1762 ["Followup and yank" gnus-summary-followup-with-original t]
1763 ["Supersede article" gnus-summary-supersede-article t]
1764 ["Cancel article" gnus-summary-cancel-article t]
1765 ["Reply" gnus-summary-reply t]
1766 ["Reply and yank" gnus-summary-reply-with-original t]
1767 ["Mail forward" gnus-summary-mail-forward t]
1768 ["Post forward" gnus-summary-post-forward t]
1769 ["Digest and mail" gnus-uu-digest-mail-forward t]
1770 ["Digest and post" gnus-uu-digest-post-forward t]
1771 ["Resend message" gnus-summary-resend-message t]
1772 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1773 ["Send a mail" gnus-summary-mail-other-window t]
1774 ["Uuencode and post" gnus-uu-post-news t]
1775 ["Followup via news" gnus-summary-followup-to-mail t]
1776 ["Followup via news and yank"
1777 gnus-summary-followup-to-mail-with-original t]
1779 ;;["Send" gnus-summary-send-draft t]
1780 ;;["Send bounced" gnus-resend-bounced-mail t])
1784 gnus-summary-misc-menu gnus-summary-mode-map ""
1787 ["Mark as read" gnus-summary-mark-as-read-forward t]
1788 ["Mark same subject and select"
1789 gnus-summary-kill-same-subject-and-select t]
1790 ["Mark same subject" gnus-summary-kill-same-subject t]
1791 ["Catchup" gnus-summary-catchup t]
1792 ["Catchup all" gnus-summary-catchup-all t]
1793 ["Catchup to here" gnus-summary-catchup-to-here t]
1794 ["Catchup region" gnus-summary-mark-region-as-read t]
1795 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1797 ["Tick" gnus-summary-tick-article-forward t]
1798 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1799 ["Remove marks" gnus-summary-clear-mark-forward t]
1800 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1801 ["Set bookmark" gnus-summary-set-bookmark t]
1802 ["Remove bookmark" gnus-summary-remove-bookmark t])
1804 ["Marks..." gnus-summary-limit-to-marks t]
1805 ["Subject..." gnus-summary-limit-to-subject t]
1806 ["Author..." gnus-summary-limit-to-author t]
1807 ["Score" gnus-summary-limit-to-score t]
1808 ["Unread" gnus-summary-limit-to-unread t]
1809 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1810 ["Articles" gnus-summary-limit-to-articles t]
1811 ["Pop limit" gnus-summary-pop-limit t]
1812 ["Show dormant" gnus-summary-limit-include-dormant t]
1813 ["Hide childless dormant"
1814 gnus-summary-limit-exclude-childless-dormant t]
1815 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1816 ["Show expunged" gnus-summary-show-all-expunged t])
1818 ["Set mark" gnus-summary-mark-as-processable t]
1819 ["Remove mark" gnus-summary-unmark-as-processable t]
1820 ["Remove all marks" gnus-summary-unmark-all-processable t]
1821 ["Mark above" gnus-uu-mark-over t]
1822 ["Mark series" gnus-uu-mark-series t]
1823 ["Mark region" gnus-uu-mark-region t]
1824 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1825 ["Mark all" gnus-uu-mark-all t]
1826 ["Mark buffer" gnus-uu-mark-buffer t]
1827 ["Mark sparse" gnus-uu-mark-sparse t]
1828 ["Mark thread" gnus-uu-mark-thread t]
1829 ["Unmark thread" gnus-uu-unmark-thread t]
1830 ("Process Mark Sets"
1831 ["Kill" gnus-summary-kill-process-mark t]
1832 ["Yank" gnus-summary-yank-process-mark
1833 gnus-newsgroup-process-stack]
1834 ["Save" gnus-summary-save-process-mark t]))
1836 ["Page forward" gnus-summary-next-page t]
1837 ["Page backward" gnus-summary-prev-page t]
1838 ["Line forward" gnus-summary-scroll-up t])
1840 ["Next unread article" gnus-summary-next-unread-article t]
1841 ["Previous unread article" gnus-summary-prev-unread-article t]
1842 ["Next article" gnus-summary-next-article t]
1843 ["Previous article" gnus-summary-prev-article t]
1844 ["Next unread subject" gnus-summary-next-unread-subject t]
1845 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1846 ["Next article same subject" gnus-summary-next-same-subject t]
1847 ["Previous article same subject" gnus-summary-prev-same-subject t]
1848 ["First unread article" gnus-summary-first-unread-article t]
1849 ["Best unread article" gnus-summary-best-unread-article t]
1850 ["Go to subject number..." gnus-summary-goto-subject t]
1851 ["Go to article number..." gnus-summary-goto-article t]
1852 ["Go to the last article" gnus-summary-goto-last-article t]
1853 ["Pop article off history" gnus-summary-pop-article t])
1855 ["Sort by number" gnus-summary-sort-by-number t]
1856 ["Sort by author" gnus-summary-sort-by-author t]
1857 ["Sort by subject" gnus-summary-sort-by-subject t]
1858 ["Sort by date" gnus-summary-sort-by-date t]
1859 ["Sort by score" gnus-summary-sort-by-score t]
1860 ["Sort by lines" gnus-summary-sort-by-lines t])
1862 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1863 ["Describe group" gnus-summary-describe-group t]
1864 ["Read manual" gnus-info-find-node t])
1866 ["Enter article" gnus-cache-enter-article t]
1867 ["Remove article" gnus-cache-remove-article t])
1869 ["Pick and read" gnus-pick-mode t]
1870 ["Binary" gnus-binary-mode t])
1871 ["Filter articles..." gnus-summary-execute-command t]
1872 ["Run command on subjects..." gnus-summary-universal-argument t]
1873 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1874 ["Expand window" gnus-summary-expand-window t]
1875 ["Expire expirable articles" gnus-summary-expire-articles
1876 (gnus-check-backend-function
1877 'request-expire-articles gnus-newsgroup-name)]
1878 ["Regenerate buffer" gnus-summary-prepare t]
1879 ["Edit local kill file" gnus-summary-edit-local-kill t]
1880 ["Edit main kill file" gnus-summary-edit-global-kill t]
1882 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1883 ["Catchup all and exit" gnus-summary-catchup-and-exit t]
1884 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1885 ["Exit group" gnus-summary-exit t]
1886 ["Exit group without updating" gnus-summary-exit-no-update t]
1887 ["Exit and goto next group" gnus-summary-next-group t]
1888 ["Exit and goto prev group" gnus-summary-prev-group t]
1889 ["Reselect group" gnus-summary-reselect-current-group t]
1890 ["Rescan group" gnus-summary-rescan-group t])))
1892 (run-hooks 'gnus-summary-menu-hook)))
1894 (defun gnus-score-set-default (var value)
1895 "A version of set that updates the GNU Emacs menu-bar."
1897 ;; It is the message that forces the active status to be updated.
1900 (defun gnus-make-score-map (type)
1901 "Make a summary score map of type TYPE."
1904 (let ((headers '(("author" "from" string)
1905 ("subject" "subject" string)
1906 ("article body" "body" string)
1907 ("article head" "head" string)
1908 ("xref" "xref" string)
1909 ("lines" "lines" number)
1910 ("followups to author" "followup" string)))
1911 (types '((number ("less than" <)
1914 (string ("substring" s)
1918 (perms '(("temporary" (current-time-string))
1926 (if (eq type 'lower)
1931 (setq header (car headers))
1937 (let ((ts (cdr (assoc (nth 2 header) types)))
1953 'gnus-summary-score-entry
1955 (if (or (string= (nth 1 header)
1957 (string= (nth 1 header)
1960 (list 'gnus-summary-header
1962 (list 'quote (nth 1 (car ts)))
1963 (list 'gnus-score-default nil)
1969 (list (nreverse outp))))
1972 (list (nreverse outt))))
1974 (setq headers (cdr headers)))
1975 (list (nreverse outh))))))))
1979 (defun gnus-summary-mode (&optional group)
1980 "Major mode for reading articles.
1982 All normal editing commands are switched off.
1983 \\<gnus-summary-mode-map>
1984 Each line in this buffer represents one article. To read an
1985 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
1986 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
1989 You can also post articles and send mail from this buffer. To
1990 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
1991 of an article, type `\\[gnus-summary-reply]'.
1993 There are approx. one gazillion commands you can execute in this
1994 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
1996 The following commands are available:
1998 \\{gnus-summary-mode-map}"
2000 (when (and menu-bar-mode
2001 (gnus-visual-p 'summary-menu 'menu))
2002 (gnus-summary-make-menu-bar))
2003 (kill-all-local-variables)
2004 (gnus-summary-make-local-variables)
2005 (gnus-make-thread-indent-array)
2006 (gnus-simplify-mode-line)
2007 (setq major-mode 'gnus-summary-mode)
2008 (setq mode-name "Summary")
2009 (make-local-variable 'minor-mode-alist)
2010 (use-local-map gnus-summary-mode-map)
2011 (buffer-disable-undo (current-buffer))
2012 (setq buffer-read-only t) ;Disable modification
2013 (setq truncate-lines t)
2014 (setq selective-display t)
2015 (setq selective-display-ellipses t) ;Display `...'
2016 (setq buffer-display-table gnus-summary-display-table)
2017 (gnus-set-default-directory)
2018 (setq gnus-newsgroup-name group)
2019 (make-local-variable 'gnus-summary-line-format)
2020 (make-local-variable 'gnus-summary-line-format-spec)
2021 (make-local-variable 'gnus-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)
2025 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2026 (gnus-update-summary-mark-positions))
2028 (defun gnus-summary-make-local-variables ()
2029 "Make all the local summary buffer variables."
2030 (let ((locals gnus-summary-local-variables)
2032 (while (setq local (pop locals))
2035 (if (eq (cdr local) 'global)
2036 ;; Copy the global value of the variable.
2037 (setq global (symbol-value (car local)))
2038 ;; Use the value from the list.
2039 (setq global (eval (cdr local))))
2040 (make-local-variable (car local))
2041 (set (car local) global))
2042 ;; Simple nil-valued local variable.
2043 (make-local-variable local)
2046 (defun gnus-summary-clear-local-variables ()
2047 (let ((locals gnus-summary-local-variables))
2049 (if (consp (car locals))
2050 (and (vectorp (caar locals))
2051 (set (caar locals) nil))
2052 (and (vectorp (car locals))
2053 (set (car locals) nil)))
2054 (setq locals (cdr locals)))))
2056 ;; Summary data functions.
2058 (defmacro gnus-data-number (data)
2061 (defmacro gnus-data-set-number (data number)
2062 `(setcar ,data ,number))
2064 (defmacro gnus-data-mark (data)
2067 (defmacro gnus-data-set-mark (data mark)
2068 `(setcar (nthcdr 1 ,data) ,mark))
2070 (defmacro gnus-data-pos (data)
2073 (defmacro gnus-data-set-pos (data pos)
2074 `(setcar (nthcdr 2 ,data) ,pos))
2076 (defmacro gnus-data-header (data)
2079 (defmacro gnus-data-level (data)
2082 (defmacro gnus-data-unread-p (data)
2083 `(= (nth 1 ,data) gnus-unread-mark))
2085 (defmacro gnus-data-read-p (data)
2086 `(/= (nth 1 ,data) gnus-unread-mark))
2088 (defmacro gnus-data-pseudo-p (data)
2089 `(consp (nth 3 ,data)))
2091 (defmacro gnus-data-find (number)
2092 `(assq ,number gnus-newsgroup-data))
2094 (defmacro gnus-data-find-list (number &optional data)
2095 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2096 (memq (assq ,number bdata)
2099 (defmacro gnus-data-make (number mark pos header level)
2100 `(list ,number ,mark ,pos ,header ,level))
2102 (defun gnus-data-enter (after-article number mark pos header level offset)
2103 (let ((data (gnus-data-find-list after-article)))
2105 (error "No such article: %d" after-article))
2106 (setcdr data (cons (gnus-data-make number mark pos header level)
2108 (setq gnus-newsgroup-data-reverse nil)
2109 (gnus-data-update-list (cddr data) offset)))
2111 (defun gnus-data-enter-list (after-article list &optional offset)
2113 (let ((data (and after-article (gnus-data-find-list after-article)))
2115 (or data (not after-article) (error "No such article: %d" after-article))
2116 ;; Find the last element in the list to be spliced into the main
2119 (setq list (cdr list)))
2122 (setcdr list gnus-newsgroup-data)
2123 (setq gnus-newsgroup-data ilist)
2125 (gnus-data-update-list (cdr list) offset)))
2126 (setcdr list (cdr data))
2129 (gnus-data-update-list (cdr data) offset)))
2130 (setq gnus-newsgroup-data-reverse nil))))
2132 (defun gnus-data-remove (article &optional offset)
2133 (let ((data gnus-newsgroup-data))
2134 (if (= (gnus-data-number (car data)) article)
2135 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2136 gnus-newsgroup-data-reverse nil)
2138 (when (= (gnus-data-number (cadr data)) article)
2139 (setcdr data (cddr data))
2141 (gnus-data-update-list (cdr data) offset))
2143 gnus-newsgroup-data-reverse nil))
2144 (setq data (cdr data))))))
2146 (defmacro gnus-data-list (backward)
2148 (or gnus-newsgroup-data-reverse
2149 (setq gnus-newsgroup-data-reverse
2150 (reverse gnus-newsgroup-data)))
2151 gnus-newsgroup-data))
2153 (defun gnus-data-update-list (data offset)
2154 "Add OFFSET to the POS of all data entries in DATA."
2156 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2157 (setq data (cdr data))))
2159 (defun gnus-data-compute-positions ()
2160 "Compute the positions of all articles."
2161 (let ((data gnus-newsgroup-data)
2164 (when (setq pos (text-property-any
2165 (point-min) (point-max)
2166 'gnus-number (gnus-data-number (car data))))
2167 (gnus-data-set-pos (car data) (+ pos 3)))
2168 (setq data (cdr data)))))
2170 (defun gnus-summary-article-pseudo-p (article)
2171 "Say whether this article is a pseudo article or not."
2172 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2174 (defun gnus-article-parent-p (number)
2175 "Say whether this article is a parent or not."
2176 (let ((data (gnus-data-find-list number)))
2177 (and (cdr data) ; There has to be an article after...
2178 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2179 (gnus-data-level (nth 1 data))))))
2181 (defun gnus-article-children (number)
2182 "Return a list of all children to NUMBER."
2183 (let* ((data (gnus-data-find-list number))
2184 (level (gnus-data-level (car data)))
2186 (setq data (cdr data))
2188 (= (gnus-data-level (car data)) (1+ level)))
2189 (push (gnus-data-number (car data)) children)
2190 (setq data (cdr data)))
2193 (defmacro gnus-summary-skip-intangible ()
2194 "If the current article is intangible, then jump to a different article."
2195 '(let ((to (get-text-property (point) 'gnus-intangible)))
2196 (and to (gnus-summary-goto-subject to))))
2198 (defmacro gnus-summary-article-intangible-p ()
2199 "Say whether this article is intangible or not."
2200 '(get-text-property (point) 'gnus-intangible))
2202 (defun gnus-article-read-p (article)
2203 "Say whether ARTICLE is read or not."
2204 (not (or (memq article gnus-newsgroup-marked)
2205 (memq article gnus-newsgroup-unreads)
2206 (memq article gnus-newsgroup-unselected)
2207 (memq article gnus-newsgroup-dormant))))
2209 ;; Some summary mode macros.
2211 (defmacro gnus-summary-article-number ()
2212 "The article number of the article on the current line.
2213 If there isn's an article number here, then we return the current
2216 (gnus-summary-skip-intangible)
2217 (or (get-text-property (point) 'gnus-number)
2218 (gnus-summary-last-subject))))
2220 (defmacro gnus-summary-article-header (&optional number)
2221 `(gnus-data-header (gnus-data-find
2222 ,(or number '(gnus-summary-article-number)))))
2224 (defmacro gnus-summary-thread-level (&optional number)
2225 `(if (and (eq gnus-summary-make-false-root 'dummy)
2226 (get-text-property (point) 'gnus-intangible))
2228 (gnus-data-level (gnus-data-find
2229 ,(or number '(gnus-summary-article-number))))))
2231 (defmacro gnus-summary-article-mark (&optional number)
2232 `(gnus-data-mark (gnus-data-find
2233 ,(or number '(gnus-summary-article-number)))))
2235 (defmacro gnus-summary-article-pos (&optional number)
2236 `(gnus-data-pos (gnus-data-find
2237 ,(or number '(gnus-summary-article-number)))))
2239 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2240 (defmacro gnus-summary-article-subject (&optional number)
2241 "Return current subject string or nil if nothing."
2244 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2245 '(gnus-data-header (assq (gnus-summary-article-number)
2246 gnus-newsgroup-data)))))
2249 (mail-header-subject headers))))
2251 (defmacro gnus-summary-article-score (&optional number)
2252 "Return current article score."
2253 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2254 gnus-newsgroup-scored))
2255 gnus-summary-default-score 0))
2257 (defun gnus-summary-article-children (&optional number)
2258 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2259 (level (gnus-data-level (car data)))
2261 (while (and (setq data (cdr data))
2262 (> (setq l (gnus-data-level (car data))) level))
2263 (and (= (1+ level) l)
2264 (push (gnus-data-number (car data))
2266 (nreverse children)))
2268 (defun gnus-summary-article-parent (&optional number)
2269 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2270 (gnus-data-list t)))
2271 (level (gnus-data-level (car data))))
2273 () ; This is a root.
2274 ;; We search until we find an article with a level less than
2275 ;; this one. That function has to be the parent.
2276 (while (and (setq data (cdr data))
2277 (not (< (gnus-data-level (car data)) level))))
2278 (and data (gnus-data-number (car data))))))
2280 (defun gnus-unread-mark-p (mark)
2281 "Say whether MARK is the unread mark."
2282 (= mark gnus-unread-mark))
2284 (defun gnus-read-mark-p (mark)
2285 "Say whether MARK is one of the marks that mark as read.
2286 This is all marks except unread, ticked, dormant, and expirable."
2287 (not (or (= mark gnus-unread-mark)
2288 (= mark gnus-ticked-mark)
2289 (= mark gnus-dormant-mark)
2290 (= mark gnus-expirable-mark))))
2292 (defmacro gnus-article-mark (number)
2294 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2295 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2296 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2297 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2298 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2299 gnus-ancient-mark))))
2301 ;; Saving hidden threads.
2303 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2304 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2306 (defmacro gnus-save-hidden-threads (&rest forms)
2307 "Save hidden threads, eval FORMS, and restore the hidden threads."
2308 (let ((config (make-symbol "config")))
2309 `(let ((,config (gnus-hidden-threads-configuration)))
2313 (gnus-restore-hidden-threads-configuration ,config)))))
2315 (defun gnus-hidden-threads-configuration ()
2316 "Return the current hidden threads configuration."
2319 (goto-char (point-min))
2320 (while (search-forward "\r" nil t)
2321 (push (1- (point)) config))
2324 (defun gnus-restore-hidden-threads-configuration (config)
2325 "Restore hidden threads configuration from CONFIG."
2326 (let (point buffer-read-only)
2327 (while (setq point (pop config))
2328 (when (and (< point (point-max))
2330 (= (following-char) ?\n))
2331 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2333 ;; Various summary mode internalish functions.
2335 (defun gnus-mouse-pick-article (e)
2338 (gnus-summary-next-page nil t))
2340 (defun gnus-summary-setup-buffer (group)
2341 "Initialize summary buffer."
2342 (let ((buffer (concat "*Summary " group "*")))
2343 (if (get-buffer buffer)
2346 (setq gnus-summary-buffer (current-buffer))
2347 (not gnus-newsgroup-prepared))
2348 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2349 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
2350 (gnus-add-current-to-buffer-list)
2351 (gnus-summary-mode group)
2353 (gnus-carpal-setup-buffer 'summary))
2354 (unless gnus-single-article-buffer
2355 (make-local-variable 'gnus-article-buffer)
2356 (make-local-variable 'gnus-article-current)
2357 (make-local-variable 'gnus-original-article-buffer))
2358 (setq gnus-newsgroup-name group)
2361 (defun gnus-set-global-variables ()
2362 ;; Set the global equivalents of the summary buffer-local variables
2363 ;; to the latest values they had. These reflect the summary buffer
2364 ;; that was in action when the last article was fetched.
2365 (when (eq major-mode 'gnus-summary-mode)
2366 (setq gnus-summary-buffer (current-buffer))
2367 (let ((name gnus-newsgroup-name)
2368 (marked gnus-newsgroup-marked)
2369 (unread gnus-newsgroup-unreads)
2370 (headers gnus-current-headers)
2371 (data gnus-newsgroup-data)
2372 (summary gnus-summary-buffer)
2373 (article-buffer gnus-article-buffer)
2374 (original gnus-original-article-buffer)
2375 (gac gnus-article-current)
2376 (reffed gnus-reffed-article-number)
2377 (score-file gnus-current-score-file))
2379 (set-buffer gnus-group-buffer)
2380 (setq gnus-newsgroup-name name)
2381 (setq gnus-newsgroup-marked marked)
2382 (setq gnus-newsgroup-unreads unread)
2383 (setq gnus-current-headers headers)
2384 (setq gnus-newsgroup-data data)
2385 (setq gnus-article-current gac)
2386 (setq gnus-summary-buffer summary)
2387 (setq gnus-article-buffer article-buffer)
2388 (setq gnus-original-article-buffer original)
2389 (setq gnus-reffed-article-number reffed)
2390 (setq gnus-current-score-file score-file)
2391 ;; The article buffer also has local variables.
2392 (when (gnus-buffer-live-p gnus-article-buffer)
2393 (set-buffer gnus-article-buffer)
2394 (setq gnus-summary-buffer summary))))))
2396 (defun gnus-summary-first-article-p (&optional article)
2397 "Return whether ARTICLE is the first article in the buffer."
2398 (if (not (setq article (or article (gnus-summary-article-number))))
2400 (eq article (caar gnus-newsgroup-data))))
2402 (defun gnus-summary-last-article-p (&optional article)
2403 "Return whether ARTICLE is the last article in the buffer."
2404 (if (not (setq article (or article (gnus-summary-article-number))))
2405 t ; All non-existent numbers are the last article. :-)
2406 (not (cdr (gnus-data-find-list article)))))
2408 (defun gnus-make-thread-indent-array ()
2410 (unless (and gnus-thread-indent-array
2411 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2412 (setq gnus-thread-indent-array (make-vector 201 "")
2413 gnus-thread-indent-array-level gnus-thread-indent-level)
2415 (aset gnus-thread-indent-array n
2416 (make-string (* n gnus-thread-indent-level) ? ))
2419 (defun gnus-update-summary-mark-positions ()
2420 "Compute where the summary marks are to go."
2422 (when (and gnus-summary-buffer
2423 (get-buffer gnus-summary-buffer)
2424 (buffer-name (get-buffer gnus-summary-buffer)))
2425 (set-buffer gnus-summary-buffer))
2426 (let ((gnus-replied-mark 129)
2427 (gnus-score-below-mark 130)
2428 (gnus-score-over-mark 130)
2429 (spec gnus-summary-line-format-spec)
2430 thread gnus-visual pos)
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 (let ((beg (match-beginning 0)))
2484 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2485 (substring gnus-tmp-from (1+ (match-beginning 0))
2486 (1- (match-end 0))))
2487 (substring gnus-tmp-from 0 beg))))
2488 ((string-match "(.+)" gnus-tmp-from)
2489 (substring gnus-tmp-from
2490 (1+ (match-beginning 0)) (1- (match-end 0))))
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-lines (h1 h2)
3254 "Sort articles by article Lines header."
3255 (< (mail-header-lines h1)
3256 (mail-header-lines h2)))
3258 (defun gnus-thread-sort-by-lines (h1 h2)
3259 "Sort threads by root article Lines header."
3260 (gnus-article-sort-by-lines
3261 (gnus-thread-header h1) (gnus-thread-header h2)))
3263 (defsubst gnus-article-sort-by-author (h1 h2)
3264 "Sort articles by root author."
3266 (let ((extract (funcall
3267 gnus-extract-address-components
3268 (mail-header-from h1))))
3269 (or (car extract) (cdr extract)))
3270 (let ((extract (funcall
3271 gnus-extract-address-components
3272 (mail-header-from h2))))
3273 (or (car extract) (cdr extract)))))
3275 (defun gnus-thread-sort-by-author (h1 h2)
3276 "Sort threads by root author."
3277 (gnus-article-sort-by-author
3278 (gnus-thread-header h1) (gnus-thread-header h2)))
3280 (defsubst gnus-article-sort-by-subject (h1 h2)
3281 "Sort articles by root subject."
3283 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3284 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3286 (defun gnus-thread-sort-by-subject (h1 h2)
3287 "Sort threads by root subject."
3288 (gnus-article-sort-by-subject
3289 (gnus-thread-header h1) (gnus-thread-header h2)))
3291 (defsubst gnus-article-sort-by-date (h1 h2)
3292 "Sort articles by root article date."
3294 (gnus-date-get-time (mail-header-date h1))
3295 (gnus-date-get-time (mail-header-date h2))))
3297 (defun gnus-thread-sort-by-date (h1 h2)
3298 "Sort threads by root article date."
3299 (gnus-article-sort-by-date
3300 (gnus-thread-header h1) (gnus-thread-header h2)))
3302 (defsubst gnus-article-sort-by-score (h1 h2)
3303 "Sort articles by root article score.
3304 Unscored articles will be counted as having a score of zero."
3305 (> (or (cdr (assq (mail-header-number h1)
3306 gnus-newsgroup-scored))
3307 gnus-summary-default-score 0)
3308 (or (cdr (assq (mail-header-number h2)
3309 gnus-newsgroup-scored))
3310 gnus-summary-default-score 0)))
3312 (defun gnus-thread-sort-by-score (h1 h2)
3313 "Sort threads by root article score."
3314 (gnus-article-sort-by-score
3315 (gnus-thread-header h1) (gnus-thread-header h2)))
3317 (defun gnus-thread-sort-by-total-score (h1 h2)
3318 "Sort threads by the sum of all scores in the thread.
3319 Unscored articles will be counted as having a score of zero."
3320 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3322 (defun gnus-thread-total-score (thread)
3323 ;; This function find the total score of THREAD.
3324 (cond ((null thread)
3327 (if (stringp (car thread))
3328 (apply gnus-thread-score-function 0
3329 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3330 (gnus-thread-total-score-1 thread)))
3332 (gnus-thread-total-score-1 (list thread)))))
3334 (defun gnus-thread-total-score-1 (root)
3335 ;; This function find the total score of the thread below ROOT.
3336 (setq root (car root))
3337 (apply gnus-thread-score-function
3339 (mapcar 'gnus-thread-total-score
3340 (cdr (gnus-gethash (mail-header-id root)
3341 gnus-newsgroup-dependencies)))
3342 (when (> (mail-header-number root) 0)
3343 (list (or (cdr (assq (mail-header-number root)
3344 gnus-newsgroup-scored))
3345 gnus-summary-default-score 0))))
3346 (list gnus-summary-default-score)
3349 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3350 (defvar gnus-tmp-prev-subject nil)
3351 (defvar gnus-tmp-false-parent nil)
3352 (defvar gnus-tmp-root-expunged nil)
3353 (defvar gnus-tmp-dummy-line nil)
3355 (defun gnus-summary-prepare-threads (threads)
3356 "Prepare summary buffer from THREADS and indentation LEVEL.
3357 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3358 or a straight list of headers."
3359 (gnus-message 7 "Generating summary...")
3361 (setq gnus-newsgroup-threads threads)
3364 (let ((gnus-tmp-level 0)
3365 (default-score (or gnus-summary-default-score 0))
3366 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3367 thread number subject stack state gnus-tmp-gathered beg-match
3368 new-roots gnus-tmp-new-adopts thread-end
3369 gnus-tmp-header gnus-tmp-unread
3370 gnus-tmp-replied gnus-tmp-subject-or-nil
3371 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3372 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3373 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3375 (setq gnus-tmp-prev-subject nil)
3377 (if (vectorp (car threads))
3378 ;; If this is a straight (sic) list of headers, then a
3379 ;; threaded summary display isn't required, so we just create
3380 ;; an unthreaded one.
3381 (gnus-summary-prepare-unthreaded threads)
3383 ;; Do the threaded display.
3385 (while (or threads stack gnus-tmp-new-adopts new-roots)
3387 (if (and (= gnus-tmp-level 0)
3388 (not (setq gnus-tmp-dummy-line nil))
3391 (not gnus-tmp-false-parent)
3392 (or gnus-tmp-new-adopts new-roots))
3393 (if gnus-tmp-new-adopts
3394 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3395 thread (list (car gnus-tmp-new-adopts))
3396 gnus-tmp-header (caar thread)
3397 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3399 (setq thread (list (car new-roots))
3400 gnus-tmp-header (caar thread)
3401 new-roots (cdr new-roots))))
3404 ;; If there are some threads, we do them before the
3405 ;; threads on the stack.
3406 (setq thread threads
3407 gnus-tmp-header (caar thread))
3408 ;; There were no current threads, so we pop something off
3410 (setq state (car stack)
3411 gnus-tmp-level (car state)
3414 gnus-tmp-header (caar thread))))
3416 (setq gnus-tmp-false-parent nil)
3417 (setq gnus-tmp-root-expunged nil)
3418 (setq thread-end nil)
3420 (if (stringp gnus-tmp-header)
3421 ;; The header is a dummy root.
3423 ((eq gnus-summary-make-false-root 'adopt)
3424 ;; We let the first article adopt the rest.
3425 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3427 (setq gnus-tmp-gathered
3429 (lambda (h) (mail-header-number (car h)))
3432 (setq thread (cons (list (caar thread)
3435 (setq gnus-tmp-level -1
3436 gnus-tmp-false-parent t))
3437 ((eq gnus-summary-make-false-root 'empty)
3438 ;; We print adopted articles with empty subject fields.
3439 (setq gnus-tmp-gathered
3441 (lambda (h) (mail-header-number (car h)))
3444 (setq gnus-tmp-level -1))
3445 ((eq gnus-summary-make-false-root 'dummy)
3446 ;; We remember that we probably want to output a dummy
3448 (setq gnus-tmp-dummy-line gnus-tmp-header)
3449 (setq gnus-tmp-prev-subject gnus-tmp-header))
3451 ;; We do not make a root for the gathered
3452 ;; sub-threads at all.
3453 (setq gnus-tmp-level -1)))
3455 (setq number (mail-header-number gnus-tmp-header)
3456 subject (mail-header-subject gnus-tmp-header))
3459 ;; If the thread has changed subject, we might want to make
3460 ;; this subthread into a root.
3461 ((and (null gnus-thread-ignore-subject)
3462 (not (zerop gnus-tmp-level))
3463 gnus-tmp-prev-subject
3465 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3466 (setq new-roots (nconc new-roots (list (car thread)))
3468 gnus-tmp-header nil))
3469 ;; If the article lies outside the current limit,
3470 ;; then we do not display it.
3471 ((and (not (memq number gnus-newsgroup-limit))
3472 (not gnus-tmp-dummy-line))
3473 (setq gnus-tmp-gathered
3475 (lambda (h) (mail-header-number (car h)))
3478 (setq gnus-tmp-new-adopts (if (cdar thread)
3479 (append gnus-tmp-new-adopts
3481 gnus-tmp-new-adopts)
3483 gnus-tmp-header nil)
3484 (when (zerop gnus-tmp-level)
3485 (setq gnus-tmp-root-expunged t)))
3486 ;; Perhaps this article is to be marked as read?
3487 ((and gnus-summary-mark-below
3488 (< (or (cdr (assq number gnus-newsgroup-scored))
3490 gnus-summary-mark-below)
3491 ;; Don't touch sparse articles.
3492 (not (memq number gnus-newsgroup-sparse))
3493 (not (memq number gnus-newsgroup-ancient)))
3494 (setq gnus-newsgroup-unreads
3495 (delq number gnus-newsgroup-unreads))
3496 (if gnus-newsgroup-auto-expire
3497 (push number gnus-newsgroup-expirable)
3498 (push (cons number gnus-low-score-mark)
3499 gnus-newsgroup-reads))))
3501 (when gnus-tmp-header
3502 ;; We may have an old dummy line to output before this
3504 (when gnus-tmp-dummy-line
3505 (gnus-summary-insert-dummy-line
3506 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3507 (setq gnus-tmp-dummy-line nil))
3509 ;; Compute the mark.
3510 (setq gnus-tmp-unread (gnus-article-mark number))
3512 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3513 gnus-tmp-header gnus-tmp-level)
3514 gnus-newsgroup-data)
3516 ;; Actually insert the line.
3518 gnus-tmp-subject-or-nil
3520 ((and gnus-thread-ignore-subject
3521 gnus-tmp-prev-subject
3522 (not (inline (gnus-subject-equal
3523 gnus-tmp-prev-subject subject))))
3525 ((zerop gnus-tmp-level)
3526 (if (and (eq gnus-summary-make-false-root 'empty)
3527 (memq number gnus-tmp-gathered)
3528 gnus-tmp-prev-subject
3529 (inline (gnus-subject-equal
3530 gnus-tmp-prev-subject subject)))
3531 gnus-summary-same-subject
3533 (t gnus-summary-same-subject)))
3534 (if (and (eq gnus-summary-make-false-root 'adopt)
3535 (= gnus-tmp-level 1)
3536 (memq number gnus-tmp-gathered))
3537 (setq gnus-tmp-opening-bracket ?\<
3538 gnus-tmp-closing-bracket ?\>)
3539 (setq gnus-tmp-opening-bracket ?\[
3540 gnus-tmp-closing-bracket ?\]))
3542 gnus-tmp-indentation
3543 (aref gnus-thread-indent-array gnus-tmp-level)
3544 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3545 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3546 gnus-summary-default-score 0)
3548 (if (or (null gnus-summary-default-score)
3549 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3550 gnus-summary-zcore-fuzz))
3552 (if (< gnus-tmp-score gnus-summary-default-score)
3553 gnus-score-below-mark gnus-score-over-mark))
3555 (cond ((memq number gnus-newsgroup-processable)
3557 ((memq number gnus-newsgroup-cached)
3559 ((memq number gnus-newsgroup-replied)
3561 ((memq number gnus-newsgroup-saved)
3563 (t gnus-unread-mark))
3564 gnus-tmp-from (mail-header-from gnus-tmp-header)
3567 ((string-match "<[^>]+> *$" gnus-tmp-from)
3568 (setq beg-match (match-beginning 0))
3569 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3570 (substring gnus-tmp-from (1+ (match-beginning 0))
3571 (1- (match-end 0))))
3572 (substring gnus-tmp-from 0 beg-match)))
3573 ((string-match "(.+)" gnus-tmp-from)
3574 (substring gnus-tmp-from
3575 (1+ (match-beginning 0)) (1- (match-end 0))))
3577 (when (string= gnus-tmp-name "")
3578 (setq gnus-tmp-name gnus-tmp-from))
3579 (unless (numberp gnus-tmp-lines)
3580 (setq gnus-tmp-lines 0))
3581 (gnus-put-text-property
3583 (progn (eval gnus-summary-line-format-spec) (point))
3584 'gnus-number number)
3587 (run-hooks 'gnus-summary-update-hook)
3590 (setq gnus-tmp-prev-subject subject)))
3592 (when (nth 1 thread)
3593 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3594 (incf gnus-tmp-level)
3595 (setq threads (if thread-end nil (cdar thread)))
3597 (setq gnus-tmp-level 0)))))
3598 (gnus-message 7 "Generating summary...done"))
3600 (defun gnus-summary-prepare-unthreaded (headers)
3601 "Generate an unthreaded summary buffer based on HEADERS."
3602 (let (header number mark)
3605 ;; We may have to root out some bad articles...
3606 (when (memq (setq number (mail-header-number
3607 (setq header (pop headers))))
3608 gnus-newsgroup-limit)
3609 ;; Mark article as read when it has a low score.
3610 (when (and gnus-summary-mark-below
3611 (< (or (cdr (assq number gnus-newsgroup-scored))
3612 gnus-summary-default-score 0)
3613 gnus-summary-mark-below)
3614 (not (memq number gnus-newsgroup-ancient)))
3615 (setq gnus-newsgroup-unreads
3616 (delq number gnus-newsgroup-unreads))
3617 (if gnus-newsgroup-auto-expire
3618 (push number gnus-newsgroup-expirable)
3619 (push (cons number gnus-low-score-mark)
3620 gnus-newsgroup-reads)))
3622 (setq mark (gnus-article-mark number))
3623 (push (gnus-data-make number mark (1+ (point)) header 0)
3624 gnus-newsgroup-data)
3625 (gnus-summary-insert-line
3627 mark (memq number gnus-newsgroup-replied)
3628 (memq number gnus-newsgroup-expirable)
3629 (mail-header-subject header) nil
3630 (cdr (assq number gnus-newsgroup-scored))
3631 (memq number gnus-newsgroup-processable))))))
3633 (defun gnus-select-newsgroup (group &optional read-all)
3634 "Select newsgroup GROUP.
3635 If READ-ALL is non-nil, all articles in the group are selected."
3636 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3637 (info (nth 2 entry))
3638 articles fetched-articles cached)
3640 (unless (gnus-check-server
3641 (setq gnus-current-select-method (gnus-find-method-for-group group)))
3642 (error "Couldn't open server"))
3644 (or (and entry (not (eq (car entry) t))) ; Either it's active...
3645 (gnus-activate-group group) ; Or we can activate it...
3646 (progn ; Or we bug out.
3647 (when (equal major-mode 'gnus-summary-mode)
3648 (kill-buffer (current-buffer)))
3649 (error "Couldn't request group %s: %s"
3650 group (gnus-status-message group))))
3652 (unless (gnus-request-group group t)
3653 (when (equal major-mode 'gnus-summary-mode)
3654 (kill-buffer (current-buffer)))
3655 (error "Couldn't request group %s: %s"
3656 group (gnus-status-message group)))
3658 (setq gnus-newsgroup-name group)
3659 (setq gnus-newsgroup-unselected nil)
3660 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
3662 ;; Adjust and set lists of article marks.
3664 (gnus-adjust-marked-articles info))
3666 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3667 (when (gnus-virtual-group-p group)
3668 (setq cached gnus-newsgroup-cached))
3670 (setq gnus-newsgroup-unreads
3671 (gnus-set-difference
3672 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
3673 gnus-newsgroup-dormant))
3675 (setq gnus-newsgroup-processable nil)
3677 (setq articles (gnus-articles-to-read group read-all))
3681 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
3683 ((eq articles 0) nil)
3685 ;; Init the dependencies hash table.
3686 (setq gnus-newsgroup-dependencies
3687 (gnus-make-hashtable (length articles)))
3688 ;; Retrieve the headers and read them in.
3689 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
3690 (setq gnus-newsgroup-headers
3692 (setq gnus-headers-retrieved-by
3693 (gnus-retrieve-headers
3694 articles gnus-newsgroup-name
3695 ;; We might want to fetch old headers, but
3696 ;; not if there is only 1 article.
3697 (and gnus-fetch-old-headers
3699 (not (eq gnus-fetch-old-headers 'some))
3700 (not (numberp gnus-fetch-old-headers)))
3701 (> (length articles) 1))))))
3702 (gnus-get-newsgroup-headers-xover articles)
3703 (gnus-get-newsgroup-headers)))
3704 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
3706 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3708 (setq gnus-newsgroup-cached cached))
3710 ;; Suppress duplicates?
3711 (when gnus-suppress-duplicates
3712 (gnus-dup-suppress-articles))
3714 ;; Set the initial limit.
3715 (setq gnus-newsgroup-limit (copy-sequence articles))
3716 ;; Remove canceled articles from the list of unread articles.
3717 (setq gnus-newsgroup-unreads
3718 (gnus-set-sorted-intersection
3719 gnus-newsgroup-unreads
3720 (setq fetched-articles
3721 (mapcar (lambda (headers) (mail-header-number headers))
3722 gnus-newsgroup-headers))))
3723 ;; Removed marked articles that do not exist.
3724 (gnus-update-missing-marks
3725 (gnus-sorted-complement fetched-articles articles))
3726 ;; We might want to build some more threads first.
3727 (and gnus-fetch-old-headers
3728 (eq gnus-headers-retrieved-by 'nov)
3729 (gnus-build-old-threads))
3730 ;; Check whether auto-expire is to be done in this group.
3731 (setq gnus-newsgroup-auto-expire
3732 (gnus-group-auto-expirable-p group))
3733 ;; Set up the article buffer now, if necessary.
3734 (unless gnus-single-article-buffer
3735 (gnus-article-setup-buffer))
3736 ;; First and last article in this newsgroup.
3737 (when gnus-newsgroup-headers
3738 (setq gnus-newsgroup-begin
3739 (mail-header-number (car gnus-newsgroup-headers))
3742 (gnus-last-element gnus-newsgroup-headers))))
3743 ;; GROUP is successfully selected.
3744 (or gnus-newsgroup-headers t)))))
3746 (defun gnus-articles-to-read (group read-all)
3747 ;; Find out what articles the user wants to read.
3749 ;; Select all articles if `read-all' is non-nil, or if there
3750 ;; are no unread articles.
3752 (and (zerop (length gnus-newsgroup-marked))
3753 (zerop (length gnus-newsgroup-unreads)))
3754 (eq (gnus-group-find-parameter group 'display)
3756 (gnus-uncompress-range (gnus-active group))
3757 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
3758 (copy-sequence gnus-newsgroup-unreads))
3760 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
3761 (scored (length scored-list))
3762 (number (length articles))
3763 (marked (+ (length gnus-newsgroup-marked)
3764 (length gnus-newsgroup-dormant)))
3772 ((and (or (<= scored marked) (= scored number))
3773 (numberp gnus-large-newsgroup)
3774 (> number gnus-large-newsgroup))
3778 "How many articles from %s (default %d): "
3779 gnus-newsgroup-name number))))
3780 (if (string-match "^[ \t]*$" input) number input)))
3781 ((and (> scored marked) (< scored number)
3782 (> (- scored number) 20))
3785 (format "%s %s (%d scored, %d total): "
3786 "How many articles from"
3787 group scored number))))
3788 (if (string-match "^[ \t]*$" input)
3792 (setq select (if (stringp select) (string-to-number select) select))
3793 (if (or (null select) (zerop select))
3795 (if (and (not (zerop scored)) (<= (abs select) scored))
3797 (setq articles (sort scored-list '<))
3798 (setq number (length articles)))
3799 (setq articles (copy-sequence articles)))
3801 (when (< (abs select) number)
3803 ;; Select the N oldest articles.
3804 (setcdr (nthcdr (1- (abs select)) articles) nil)
3805 ;; Select the N most recent articles.
3806 (setq articles (nthcdr (- number select) articles))))
3807 (setq gnus-newsgroup-unselected
3808 (gnus-sorted-intersection
3809 gnus-newsgroup-unreads
3810 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
3813 (defun gnus-killed-articles (killed articles)
3816 (when (inline (gnus-member-of-range (car articles) killed))
3817 (push (car articles) out))
3818 (setq articles (cdr articles)))
3821 (defun gnus-uncompress-marks (marks)
3822 "Uncompress the mark ranges in MARKS."
3823 (let ((uncompressed '(score bookmark))
3826 (if (memq (caar marks) uncompressed)
3827 (push (car marks) out)
3828 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
3829 (setq marks (cdr marks)))
3832 (defun gnus-adjust-marked-articles (info)
3833 "Set all article lists and remove all marks that are no longer legal."
3834 (let* ((marked-lists (gnus-info-marks info))
3835 (active (gnus-active (gnus-info-group info)))
3838 (types gnus-article-mark-lists)
3839 (uncompressed '(score bookmark killed))
3840 marks var articles article mark)
3843 (setq marks (pop marked-lists))
3844 (set (setq var (intern (format "gnus-newsgroup-%s"
3845 (car (rassq (setq mark (car marks))
3847 (if (memq (car marks) uncompressed) (cdr marks)
3848 (gnus-uncompress-range (cdr marks))))
3850 (setq articles (symbol-value var))
3852 ;; All articles have to be subsets of the active articles.
3854 ;; Adjust "simple" lists.
3855 ((memq mark '(tick dormant expirable reply save))
3857 (when (or (< (setq article (pop articles)) min) (> article max))
3858 (set var (delq article (symbol-value var))))))
3860 ((memq mark uncompressed)
3862 (when (or (not (consp (setq article (pop articles))))
3863 (< (car article) min)
3864 (> (car article) max))
3865 (set var (delq article (symbol-value var))))))))))
3867 (defun gnus-update-missing-marks (missing)
3868 "Go through the list of MISSING articles and remove them mark lists."
3870 (let ((types gnus-article-mark-lists)
3872 ;; Go through all types.
3874 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
3875 (when (symbol-value var)
3876 ;; This list has articles. So we delete all missing articles
3880 (set var (delq (pop m) (symbol-value var)))))))))
3882 (defun gnus-update-marks ()
3883 "Enter the various lists of marked articles into the newsgroup info list."
3884 (let ((types gnus-article-mark-lists)
3885 (info (gnus-get-info gnus-newsgroup-name))
3886 (uncompressed '(score bookmark killed))
3887 type list newmarked symbol)
3889 ;; Add all marks lists that are non-nil to the list of marks lists.
3891 (setq type (pop types))
3892 (when (setq list (symbol-value
3894 (intern (format "gnus-newsgroup-%s"
3896 (push (cons (cdr type)
3897 (if (memq (cdr type) uncompressed) list
3898 (gnus-compress-sequence
3899 (set symbol (sort list '<)) t)))
3902 ;; Enter these new marks into the info of the group.
3904 (setcar (nthcdr 3 info) newmarked)
3905 ;; Add the marks lists to the end of the info.
3907 (setcdr (nthcdr 2 info) (list newmarked))))
3909 ;; Cut off the end of the info if there's nothing else there.
3913 (when (nthcdr (decf i) info)
3914 (setcdr (nthcdr i info) nil)))))))
3916 (defun gnus-set-mode-line (where)
3917 "This function sets the mode line of the article or summary buffers.
3918 If WHERE is `summary', the summary mode line format will be used."
3919 ;; Is this mode line one we keep updated?
3920 (when (memq where gnus-updated-mode-lines)
3923 ;; We evaluate this in the summary buffer since these
3924 ;; variables are buffer-local to that buffer.
3925 (set-buffer gnus-summary-buffer)
3926 ;; We bind all these variables that are used in the `eval' form
3928 (let* ((mformat (symbol-value
3930 (format "gnus-%s-mode-line-format-spec" where))))
3931 (gnus-tmp-group-name gnus-newsgroup-name)
3932 (gnus-tmp-article-number (or gnus-current-article 0))
3933 (gnus-tmp-unread gnus-newsgroup-unreads)
3934 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
3935 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
3936 (gnus-tmp-unread-and-unselected
3937 (cond ((and (zerop gnus-tmp-unread-and-unticked)
3938 (zerop gnus-tmp-unselected))
3940 ((zerop gnus-tmp-unselected)
3941 (format "{%d more}" gnus-tmp-unread-and-unticked))
3942 (t (format "{%d(+%d) more}"
3943 gnus-tmp-unread-and-unticked
3944 gnus-tmp-unselected))))
3946 (if (and gnus-current-headers
3947 (vectorp gnus-current-headers))
3948 (gnus-mode-string-quote
3949 (mail-header-subject gnus-current-headers))
3952 gnus-tmp-header);; passed as argument to any user-format-funcs
3953 (setq mode-string (eval mformat))
3954 (setq max-len (max 4 (if gnus-mode-non-string-length
3956 gnus-mode-non-string-length)
3957 (length mode-string))))
3958 ;; We might have to chop a bit of the string off...
3959 (when (> (length mode-string) max-len)
3961 (concat (gnus-truncate-string mode-string (- max-len 3))
3963 ;; Pad the mode string a bit.
3964 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
3965 ;; Update the mode line.
3966 (setq mode-line-buffer-identification
3967 (gnus-mode-line-buffer-identification
3968 (list mode-string)))
3969 (set-buffer-modified-p t))))
3971 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
3972 "Go through the HEADERS list and add all Xrefs to a hash table.
3973 The resulting hash table is returned, or nil if no Xrefs were found."
3974 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
3975 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
3976 (xref-hashtb (make-vector 63 0))
3977 start group entry number xrefs header)
3979 (setq header (pop headers))
3980 (when (and (setq xrefs (mail-header-xref header))
3981 (not (memq (setq number (mail-header-number header))
3984 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
3985 (setq start (match-end 0))
3986 (setq group (if prefix
3987 (concat prefix (substring xrefs (match-beginning 1)
3989 (substring xrefs (match-beginning 1) (match-end 1))))
3991 (string-to-int (substring xrefs (match-beginning 2)
3993 (if (setq entry (gnus-gethash group xref-hashtb))
3994 (setcdr entry (cons number (cdr entry)))
3995 (gnus-sethash group (cons number nil) xref-hashtb)))))
3996 (and start xref-hashtb)))
3998 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
3999 "Look through all the headers and mark the Xrefs as read."
4000 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4001 name entry info xref-hashtb idlist method nth4)
4003 (set-buffer gnus-group-buffer)
4004 (when (setq xref-hashtb
4005 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4008 (unless (string= from-newsgroup (setq name (symbol-name group)))
4009 (setq idlist (symbol-value group))
4010 ;; Dead groups are not updated.
4012 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4014 (when (stringp (setq nth4 (gnus-info-method info)))
4015 (setq nth4 (gnus-server-to-method nth4))))
4016 ;; Only do the xrefs if the group has the same
4017 ;; select method as the group we have just read.
4018 (or (gnus-methods-equal-p
4019 nth4 (gnus-find-method-for-group from-newsgroup))
4021 (equal nth4 (setq method (gnus-find-method-for-group
4023 (and (equal (car nth4) (car method))
4024 (equal (nth 1 nth4) (nth 1 method))))
4025 gnus-use-cross-reference
4026 (or (not (eq gnus-use-cross-reference t))
4028 ;; Only do cross-references on subscribed
4029 ;; groups, if that is what is wanted.
4030 (<= (gnus-info-level info) gnus-level-subscribed))
4031 (gnus-group-make-articles-read name idlist))))
4034 (defun gnus-group-make-articles-read (group articles)
4035 "Update the info of GROUP to say that only ARTICLES are unread."
4037 (entry (gnus-gethash group gnus-newsrc-hashtb))
4038 (info (nth 2 entry))
4039 (active (gnus-active group))
4041 ;; First peel off all illegal article numbers.
4043 (let ((ids articles)
4045 (while (setq id (pop ids))
4046 (when (and first (> id (cdr active)))
4047 ;; We'll end up in this situation in one particular
4048 ;; obscure situation. If you re-scan a group and get
4049 ;; a new article that is cross-posted to a different
4050 ;; group that has not been re-scanned, you might get
4051 ;; crossposted article that has a higher number than
4052 ;; Gnus believes possible. So we re-activate this
4053 ;; group as well. This might mean doing the
4054 ;; crossposting thingy will *increase* the number
4055 ;; of articles in some groups. Tsk, tsk.
4056 (setq active (or (gnus-activate-group group) active)))
4057 (when (or (> id (cdr active))
4058 (< id (car active)))
4059 (setq articles (delq id articles))))))
4062 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4063 (gnus-info-set-read ',info ',(gnus-info-read info))
4064 (gnus-group-update-group ,group t)))
4065 ;; If the read list is nil, we init it.
4067 (null (gnus-info-read info))
4069 (gnus-info-set-read info (cons 1 (1- (car active)))))
4070 ;; Then we add the read articles to the range.
4075 (gnus-info-read info) (setq articles (sort articles '<)))))
4076 ;; Then we have to re-compute how many unread
4077 ;; articles there are in this group.
4081 (setq num (- (1+ (cdr active)) (car active))))
4082 ((not (listp (cdr range)))
4083 (setq num (- (cdr active) (- (1+ (cdr range))
4087 (if (numberp (car range))
4089 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4090 (setq range (cdr range)))
4091 (setq num (- (cdr active) num))))
4092 ;; Update the number of unread articles.
4094 ;; Update the group buffer.
4095 (gnus-group-update-group group t))))
4097 (defun gnus-methods-equal-p (m1 m2)
4098 (let ((m1 (or m1 gnus-select-method))
4099 (m2 (or m2 gnus-select-method)))
4101 (and (eq (car m1) (car m2))
4102 (or (not (memq 'address (assoc (symbol-name (car m1))
4103 gnus-valid-select-methods)))
4104 (equal (nth 1 m1) (nth 1 m2)))))))
4106 (defvar gnus-newsgroup-none-id 0)
4108 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4109 (let ((cur nntp-server-buffer)
4112 (save-excursion (set-buffer gnus-summary-buffer)
4113 gnus-newsgroup-dependencies)))
4114 headers id id-dep ref-dep end ref)
4116 (set-buffer nntp-server-buffer)
4117 ;; Translate all TAB characters into SPACE characters.
4118 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4119 (run-hooks 'gnus-parse-headers-hook)
4120 (let ((case-fold-search t)
4121 in-reply-to header p lines)
4122 (goto-char (point-min))
4123 ;; Search to the beginning of the next header. Error messages
4124 ;; do not begin with 2 or 3.
4125 (while (re-search-forward "^[23][0-9]+ " nil t)
4128 ;; This implementation of this function, with nine
4129 ;; search-forwards instead of the one re-search-forward and
4130 ;; a case (which basically was the old function) is actually
4131 ;; about twice as fast, even though it looks messier. You
4132 ;; can't have everything, I guess. Speed and elegance
4133 ;; doesn't always go hand in hand.
4142 (narrow-to-region (point)
4143 (or (and (search-forward "\n.\n" nil t)
4149 (if (search-forward "\nsubject: " nil t)
4150 (nnheader-header-value) "(none)"))
4154 (if (search-forward "\nfrom: " nil t)
4155 (nnheader-header-value) "(nobody)"))
4159 (if (search-forward "\ndate: " nil t)
4160 (nnheader-header-value) ""))
4164 (if (search-forward "\nmessage-id: " nil t)
4165 (setq id (nnheader-header-value))
4166 ;; If there was no message-id, we just fake one to make
4167 ;; subsequent routines simpler.
4168 (setq id (concat "none+"
4170 (setq gnus-newsgroup-none-id
4171 (1+ gnus-newsgroup-none-id)))))))
4175 (if (search-forward "\nreferences: " nil t)
4179 (nnheader-header-value)
4184 (search-backward ">" end t)
4187 (search-backward "<" end t)
4189 ;; Get the references from the in-reply-to header if there
4190 ;; were no references and the in-reply-to header looks
4192 (if (and (search-forward "\nin-reply-to: " nil t)
4193 (setq in-reply-to (nnheader-header-value))
4194 (string-match "<[^>]+>" in-reply-to))
4195 (setq ref (substring in-reply-to (match-beginning 0)
4203 (if (search-forward "\nlines: " nil t)
4204 (if (numberp (setq lines (read cur)))
4210 (and (search-forward "\nxref: " nil t)
4211 (nnheader-header-value)))))
4212 (when (equal id ref)
4214 ;; We do the threading while we read the headers. The
4215 ;; message-id and the last reference are both entered into
4216 ;; the same hash table. Some tippy-toeing around has to be
4217 ;; done in case an article has arrived before the article
4218 ;; which it refers to.
4219 (if (boundp (setq id-dep (intern id dependencies)))
4220 (if (and (car (symbol-value id-dep))
4222 ;; An article with this Message-ID has already
4223 ;; been seen, so we ignore this one, except we add
4224 ;; any additional Xrefs (in case the two articles
4225 ;; came from different servers).
4227 (mail-header-set-xref
4228 (car (symbol-value id-dep))
4229 (concat (or (mail-header-xref
4230 (car (symbol-value id-dep)))
4232 (or (mail-header-xref header) "")))
4234 (setcar (symbol-value id-dep) header))
4235 (set id-dep (list header)))
4237 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
4238 (setcdr (symbol-value ref-dep)
4239 (nconc (cdr (symbol-value ref-dep))
4240 (list (symbol-value id-dep))))
4241 (set ref-dep (list nil (symbol-value id-dep))))
4242 (push header headers))
4243 (goto-char (point-max))
4245 (nreverse headers)))))
4247 ;; The following macros and functions were written by Felix Lee
4248 ;; <flee@cse.psu.edu>.
4250 (defmacro gnus-nov-read-integer ()
4252 (if (= (following-char) ?\t)
4254 (let ((num (ignore-errors (read buffer))))
4255 (if (numberp num) num 0)))
4259 (defmacro gnus-nov-skip-field ()
4260 '(search-forward "\t" eol 'move))
4262 (defmacro gnus-nov-field ()
4263 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
4265 (defvar gnus-nov-none-counter 0)
4267 ;; This function has to be called with point after the article number
4268 ;; on the beginning of the line.
4269 (defun gnus-nov-parse-line (number dependencies &optional force-new)
4270 (let ((eol (gnus-point-at-eol))
4271 (buffer (current-buffer))
4272 header ref id id-dep ref-dep)
4274 ;; overview: [num subject from date id refs chars lines misc]
4275 (narrow-to-region (point) eol)
4282 (gnus-nov-field) ; subject
4283 (gnus-nov-field) ; from
4284 (gnus-nov-field) ; date
4285 (setq id (or (gnus-nov-field)
4288 (incf gnus-nov-none-counter))))) ; id
4290 (let ((beg (point)))
4291 (search-forward "\t" eol)
4292 (if (search-backward ">" beg t)
4296 (search-backward "<" beg t)))
4299 (gnus-nov-field)) ; refs
4300 (gnus-nov-read-integer) ; chars
4301 (gnus-nov-read-integer) ; lines
4302 (if (= (following-char) ?\n)
4304 (gnus-nov-field)) ; misc
4309 ;; We build the thread tree.
4310 (when (equal id ref)
4311 ;; This article refers back to itself. Naughty, naughty.
4313 (if (boundp (setq id-dep (intern id dependencies)))
4314 (if (and (car (symbol-value id-dep))
4316 ;; An article with this Message-ID has already been seen,
4317 ;; so we ignore this one, except we add any additional
4318 ;; Xrefs (in case the two articles came from different
4321 (mail-header-set-xref
4322 (car (symbol-value id-dep))
4323 (concat (or (mail-header-xref
4324 (car (symbol-value id-dep)))
4326 (or (mail-header-xref header) "")))
4328 (setcar (symbol-value id-dep) header))
4329 (set id-dep (list header)))
4331 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
4332 (setcdr (symbol-value ref-dep)
4333 (nconc (cdr (symbol-value ref-dep))
4334 (list (symbol-value id-dep))))
4335 (set ref-dep (list nil (symbol-value id-dep)))))
4338 ;; Goes through the xover lines and returns a list of vectors
4339 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4340 force-new dependencies)
4341 "Parse the news overview data in the server buffer, and return a
4342 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4343 ;; Get the Xref when the users reads the articles since most/some
4344 ;; NNTP servers do not include Xrefs when using XOVER.
4345 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4346 (let ((cur nntp-server-buffer)
4347 (dependencies (or dependencies gnus-newsgroup-dependencies))
4348 number headers header)
4350 (set-buffer nntp-server-buffer)
4351 ;; Allow the user to mangle the headers before parsing them.
4352 (run-hooks 'gnus-parse-headers-hook)
4353 (goto-char (point-min))
4356 (while (and sequence (not (eobp)))
4357 (setq number (read cur))
4358 (while (and sequence
4359 (< (car sequence) number))
4360 (setq sequence (cdr sequence)))
4362 (eq number (car sequence))
4364 (setq sequence (cdr sequence))
4365 (setq header (inline
4366 (gnus-nov-parse-line
4367 number dependencies force-new))))
4368 (push header headers))
4371 (gnus-error 4 "Strange nov line")))
4373 (nreverse headers))))
4375 (defun gnus-article-get-xrefs ()
4376 "Fill in the Xref value in `gnus-current-headers', if necessary.
4377 This is meant to be called in `gnus-article-internal-prepare-hook'."
4378 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4379 gnus-current-headers)))
4380 (or (not gnus-use-cross-reference)
4382 (and (mail-header-xref headers)
4383 (not (string= (mail-header-xref headers) "")))
4384 (let ((case-fold-search t)
4387 (nnheader-narrow-to-headers)
4388 (goto-char (point-min))
4389 (when (or (and (eq (downcase (following-char)) ?x)
4390 (looking-at "Xref:"))
4391 (search-forward "\nXref:" nil t))
4392 (goto-char (1+ (match-end 0)))
4393 (setq xref (buffer-substring (point)
4394 (progn (end-of-line) (point))))
4395 (mail-header-set-xref headers xref)))))))
4397 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4398 "Find article ID and insert the summary line for that article."
4399 (let ((header (if (and old-header use-old-header)
4400 old-header (gnus-read-header id)))
4401 (number (and (numberp id) id))
4404 ;; Rebuild the thread that this article is part of and go to the
4405 ;; article we have fetched.
4406 (when (and (not gnus-show-threads)
4408 (when (setq pos (text-property-any
4409 (point-min) (point-max) 'gnus-number
4410 (mail-header-number old-header)))
4413 (gnus-data-remove (mail-header-number old-header))))
4415 (mail-header-set-number header (mail-header-number old-header)))
4416 (setq gnus-newsgroup-sparse
4417 (delq (setq number (mail-header-number header))
4418 gnus-newsgroup-sparse))
4419 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4420 (gnus-rebuild-thread (mail-header-id header))
4421 (gnus-summary-goto-subject number nil t))
4422 (when (and (numberp number)
4424 ;; We have to update the boundaries even if we can't fetch the
4425 ;; article if ID is a number -- so that the next `P' or `N'
4426 ;; command will fetch the previous (or next) article even
4427 ;; if the one we tried to fetch this time has been canceled.
4428 (when (> number gnus-newsgroup-end)
4429 (setq gnus-newsgroup-end number))
4430 (when (< number gnus-newsgroup-begin)
4431 (setq gnus-newsgroup-begin number))
4432 (setq gnus-newsgroup-unselected
4433 (delq number gnus-newsgroup-unselected)))
4434 ;; Report back a success?
4435 (and header (mail-header-number header))))
4437 ;;; Process/prefix in the summary buffer
4439 (defun gnus-summary-work-articles (n)
4440 "Return a list of articles to be worked upon. The prefix argument,
4441 the list of process marked articles, and the current article will be
4442 taken into consideration."
4445 ;; A numerical prefix has been given.
4446 (let ((backward (< n 0))
4447 (n (abs (prefix-numeric-value n)))
4452 (push (setq article (gnus-summary-article-number))
4455 (gnus-summary-find-prev nil article)
4456 (gnus-summary-find-next nil article)))
4458 (nreverse articles)))
4459 ((and (boundp 'transient-mark-mode)
4462 ;; Work on the region between point and mark.
4463 (let ((max (max (point) (mark)))
4466 (goto-char (min (point) (mark)))
4469 (push (setq article (gnus-summary-article-number)) articles)
4470 (gnus-summary-find-next nil article)
4472 (nreverse articles))))
4473 (gnus-newsgroup-processable
4474 ;; There are process-marked articles present.
4475 ;; Save current state.
4476 (gnus-summary-save-process-mark)
4478 (reverse gnus-newsgroup-processable))
4480 ;; Just return the current article.
4481 (list (gnus-summary-article-number)))))
4483 (defun gnus-summary-save-process-mark ()
4484 "Push the current set of process marked articles on the stack."
4486 (push (copy-sequence gnus-newsgroup-processable)
4487 gnus-newsgroup-process-stack))
4489 (defun gnus-summary-kill-process-mark ()
4490 "Push the current set of process marked articles on the stack and unmark."
4492 (gnus-summary-save-process-mark)
4493 (gnus-summary-unmark-all-processable))
4495 (defun gnus-summary-yank-process-mark ()
4496 "Pop the last process mark state off the stack and restore it."
4498 (unless gnus-newsgroup-process-stack
4499 (error "Empty mark stack"))
4500 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4502 (defun gnus-summary-process-mark-set (set)
4503 "Make SET into the current process marked articles."
4504 (gnus-summary-unmark-all-processable)
4506 (gnus-summary-set-process-mark (pop set))))
4508 ;;; Searching and stuff
4510 (defun gnus-summary-search-group (&optional backward use-level)
4511 "Search for next unread newsgroup.
4512 If optional argument BACKWARD is non-nil, search backward instead."
4514 (set-buffer gnus-group-buffer)
4515 (when (gnus-group-search-forward
4516 backward nil (if use-level (gnus-group-group-level) nil))
4517 (gnus-group-group-name))))
4519 (defun gnus-summary-best-group (&optional exclude-group)
4520 "Find the name of the best unread group.
4521 If EXCLUDE-GROUP, do not go to this group."
4523 (set-buffer gnus-group-buffer)
4525 (gnus-group-best-unread-group exclude-group))))
4527 (defun gnus-summary-find-next (&optional unread article backward)
4528 (if backward (gnus-summary-find-prev)
4529 (let* ((dummy (gnus-summary-article-intangible-p))
4530 (article (or article (gnus-summary-article-number)))
4531 (arts (gnus-data-find-list article))
4533 (when (and (not dummy)
4534 (or (not gnus-summary-check-current)
4536 (not (gnus-data-unread-p (car arts)))))
4537 (setq arts (cdr arts)))
4542 (when (gnus-data-unread-p (car arts))
4543 (setq result (car arts)
4545 (setq arts (cdr arts)))
4548 (goto-char (gnus-data-pos result))
4549 (gnus-data-number result)))))
4551 (defun gnus-summary-find-prev (&optional unread article)
4552 (let* ((eobp (eobp))
4553 (article (or article (gnus-summary-article-number)))
4554 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
4556 (when (and (not eobp)
4557 (or (not gnus-summary-check-current)
4559 (not (gnus-data-unread-p (car arts)))))
4560 (setq arts (cdr arts)))
4565 (when (gnus-data-unread-p (car arts))
4566 (setq result (car arts)
4568 (setq arts (cdr arts)))
4571 (goto-char (gnus-data-pos result))
4572 (gnus-data-number result))))
4574 (defun gnus-summary-find-subject (subject &optional unread backward article)
4575 (let* ((simp-subject (gnus-simplify-subject-fully subject))
4576 (article (or article (gnus-summary-article-number)))
4577 (articles (gnus-data-list backward))
4578 (arts (gnus-data-find-list article articles))
4580 (when (or (not gnus-summary-check-current)
4582 (not (gnus-data-unread-p (car arts))))
4583 (setq arts (cdr arts)))
4585 (and (or (not unread)
4586 (gnus-data-unread-p (car arts)))
4587 (vectorp (gnus-data-header (car arts)))
4589 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
4590 (setq result (car arts)
4592 (setq arts (cdr arts)))
4594 (goto-char (gnus-data-pos result))
4595 (gnus-data-number result))))
4597 (defun gnus-summary-search-forward (&optional unread subject backward)
4598 "Search forward for an article.
4599 If UNREAD, look for unread articles. If SUBJECT, look for
4600 articles with that subject. If BACKWARD, search backward instead."
4601 (cond (subject (gnus-summary-find-subject subject unread backward))
4602 (backward (gnus-summary-find-prev unread))
4603 (t (gnus-summary-find-next unread))))
4605 (defun gnus-recenter (&optional n)
4606 "Center point in window and redisplay frame.
4607 Also do horizontal recentering."
4609 (when (and gnus-auto-center-summary
4610 (not (eq gnus-auto-center-summary 'vertical)))
4611 (gnus-horizontal-recenter))
4614 (defun gnus-summary-recenter ()
4615 "Center point in the summary window.
4616 If `gnus-auto-center-summary' is nil, or the article buffer isn't
4617 displayed, no centering will be performed."
4618 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
4619 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
4620 (let* ((top (cond ((< (window-height) 4) 0)
4621 ((< (window-height) 7) 1)
4623 (height (1- (window-height)))
4624 (bottom (save-excursion (goto-char (point-max))
4625 (forward-line (- height))
4627 (window (get-buffer-window (current-buffer))))
4628 ;; The user has to want it.
4629 (when gnus-auto-center-summary
4630 (when (get-buffer-window gnus-article-buffer)
4631 ;; Only do recentering when the article buffer is displayed,
4632 ;; Set the window start to either `bottom', which is the biggest
4633 ;; possible valid number, or the second line from the top,
4634 ;; whichever is the least.
4636 window (min bottom (save-excursion
4637 (forward-line (- top)) (point)))))
4638 ;; Do horizontal recentering while we're at it.
4639 (when (and (get-buffer-window (current-buffer) t)
4640 (not (eq gnus-auto-center-summary 'vertical)))
4641 (let ((selected (selected-window)))
4642 (select-window (get-buffer-window (current-buffer) t))
4643 (gnus-summary-position-point)
4644 (gnus-horizontal-recenter)
4645 (select-window selected))))))
4647 (defun gnus-summary-jump-to-group (newsgroup)
4648 "Move point to NEWSGROUP in group mode buffer."
4649 ;; Keep update point of group mode buffer if visible.
4650 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
4651 (save-window-excursion
4652 ;; Take care of tree window mode.
4653 (when (get-buffer-window gnus-group-buffer)
4654 (pop-to-buffer gnus-group-buffer))
4655 (gnus-group-jump-to-group newsgroup))
4657 ;; Take care of tree window mode.
4658 (if (get-buffer-window gnus-group-buffer)
4659 (pop-to-buffer gnus-group-buffer)
4660 (set-buffer gnus-group-buffer))
4661 (gnus-group-jump-to-group newsgroup))))
4663 ;; This function returns a list of article numbers based on the
4664 ;; difference between the ranges of read articles in this group and
4665 ;; the range of active articles.
4666 (defun gnus-list-of-unread-articles (group)
4667 (let* ((read (gnus-info-read (gnus-get-info group)))
4668 (active (or (gnus-active group) (gnus-activate-group group)))
4671 ;; If none are read, then all are unread.
4673 (setq first (car active))
4674 ;; If the range of read articles is a single range, then the
4675 ;; first unread article is the article after the last read
4676 ;; article. Sounds logical, doesn't it?
4677 (if (not (listp (cdr read)))
4678 (setq first (1+ (cdr read)))
4679 ;; `read' is a list of ranges.
4680 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
4686 (while (< first nlast)
4688 (setq first (1+ first))))
4689 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
4690 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
4691 (setq read (cdr read)))))
4692 ;; And add the last unread articles.
4693 (while (<= first last)
4695 (setq first (1+ first)))
4696 ;; Return the list of unread articles.
4699 (defun gnus-list-of-read-articles (group)
4700 "Return a list of unread, unticked and non-dormant articles."
4701 (let* ((info (gnus-get-info group))
4702 (marked (gnus-info-marks info))
4703 (active (gnus-active group)))
4705 (gnus-set-difference
4706 (gnus-sorted-complement
4707 (gnus-uncompress-range active)
4708 (gnus-list-of-unread-articles group))
4710 (gnus-uncompress-range (cdr (assq 'dormant marked)))
4711 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
4713 ;; Various summary commands
4715 (defun gnus-summary-universal-argument (arg)
4716 "Perform any operation on all articles that are process/prefixed."
4718 (gnus-set-global-variables)
4719 (let ((articles (gnus-summary-work-articles arg))
4726 (substitute-command-keys
4727 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
4730 (gnus-error 1 "Undefined key")
4733 (gnus-summary-goto-subject (setq article (pop articles)))
4734 (let (gnus-newsgroup-processable)
4735 (command-execute func))
4736 (gnus-summary-remove-process-mark article)))))
4737 (gnus-summary-position-point))
4739 (defun gnus-summary-toggle-truncation (&optional arg)
4740 "Toggle truncation of summary lines.
4741 With arg, turn line truncation on iff arg is positive."
4743 (setq truncate-lines
4744 (if (null arg) (not truncate-lines)
4745 (> (prefix-numeric-value arg) 0)))
4748 (defun gnus-summary-reselect-current-group (&optional all rescan)
4749 "Exit and then reselect the current newsgroup.
4750 The prefix argument ALL means to select all articles."
4752 (gnus-set-global-variables)
4753 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
4754 (error "Ephemeral groups can't be reselected"))
4755 (let ((current-subject (gnus-summary-article-number))
4756 (group gnus-newsgroup-name))
4757 (setq gnus-newsgroup-begin nil)
4759 ;; We have to adjust the point of group mode buffer because the
4760 ;; current point was moved to the next unread newsgroup by
4762 (gnus-summary-jump-to-group group)
4765 (gnus-group-get-new-news-this-group 1)))
4766 (gnus-group-read-group all t)
4767 (gnus-summary-goto-subject current-subject nil t)))
4769 (defun gnus-summary-rescan-group (&optional all)
4770 "Exit the newsgroup, ask for new articles, and select the newsgroup."
4772 (gnus-summary-reselect-current-group all t))
4774 (defun gnus-summary-update-info ()
4775 (let ((group gnus-newsgroup-name))
4776 (when gnus-newsgroup-kill-headers
4777 (setq gnus-newsgroup-killed
4778 (gnus-compress-sequence
4780 (gnus-set-sorted-intersection
4781 (gnus-uncompress-range gnus-newsgroup-killed)
4782 (setq gnus-newsgroup-unselected
4783 (sort gnus-newsgroup-unselected '<)))
4784 (setq gnus-newsgroup-unreads
4785 (sort gnus-newsgroup-unreads '<)))
4787 (unless (listp (cdr gnus-newsgroup-killed))
4788 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
4789 (let ((headers gnus-newsgroup-headers))
4790 (run-hooks 'gnus-exit-group-hook)
4791 (unless gnus-save-score
4792 (setq gnus-newsgroup-scored nil))
4793 ;; Set the new ranges of read articles.
4794 (gnus-update-read-articles
4795 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
4796 ;; Set the current article marks.
4798 ;; Do the cross-ref thing.
4799 (when gnus-use-cross-reference
4800 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
4801 ;; Do adaptive scoring, and possibly save score files.
4802 (when gnus-newsgroup-adaptive
4803 (gnus-score-adaptive))
4804 (when gnus-use-scoring
4806 ;; Do not switch windows but change the buffer to work.
4807 (set-buffer gnus-group-buffer)
4808 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
4809 (gnus-group-update-group group)))))
4811 (defun gnus-summary-exit (&optional temporary)
4812 "Exit reading current newsgroup, and then return to group selection mode.
4813 gnus-exit-group-hook is called with no arguments if that value is non-nil."
4815 (gnus-set-global-variables)
4816 (gnus-kill-save-kill-buffer)
4817 (let* ((group gnus-newsgroup-name)
4818 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
4820 (buf (current-buffer)))
4821 (run-hooks 'gnus-summary-prepare-exit-hook)
4822 ;; If we have several article buffers, we kill them at exit.
4823 (unless gnus-single-article-buffer
4824 (gnus-kill-buffer gnus-original-article-buffer)
4825 (setq gnus-article-current nil))
4826 (when gnus-use-cache
4827 (gnus-cache-possibly-remove-articles)
4828 (gnus-cache-save-buffers))
4829 (gnus-async-prefetch-remove-group group)
4830 (when gnus-suppress-duplicates
4831 (gnus-dup-enter-articles))
4832 (when gnus-use-trees
4833 (gnus-tree-close group))
4834 ;; Make all changes in this group permanent.
4836 (gnus-summary-update-info))
4837 (gnus-close-group group)
4838 ;; Make sure where I was, and go to next newsgroup.
4839 (set-buffer gnus-group-buffer)
4841 (gnus-group-jump-to-group group))
4842 (run-hooks 'gnus-summary-exit-hook)
4844 (gnus-group-next-unread-group 1))
4847 ;; If we have several article buffers, we kill them at exit.
4848 (unless gnus-single-article-buffer
4849 (gnus-kill-buffer gnus-article-buffer)
4850 (gnus-kill-buffer gnus-original-article-buffer)
4851 (setq gnus-article-current nil))
4853 (if (not gnus-kill-summary-on-exit)
4854 (gnus-deaden-summary)
4855 ;; We set all buffer-local variables to nil. It is unclear why
4856 ;; this is needed, but if we don't, buffer-local variables are
4857 ;; not garbage-collected, it seems. This would the lead to en
4858 ;; ever-growing Emacs.
4859 (gnus-summary-clear-local-variables)
4860 (when (get-buffer gnus-article-buffer)
4861 (bury-buffer gnus-article-buffer))
4862 ;; We clear the global counterparts of the buffer-local
4863 ;; variables as well, just to be on the safe side.
4864 (set-buffer gnus-group-buffer)
4865 (gnus-summary-clear-local-variables)
4866 ;; Return to group mode buffer.
4867 (when (eq mode 'gnus-summary-mode)
4868 (gnus-kill-buffer buf)))
4869 (setq gnus-current-select-method gnus-select-method)
4870 (pop-to-buffer gnus-group-buffer)
4871 ;; Clear the current group name.
4872 (if (not quit-config)
4874 (gnus-group-jump-to-group group)
4875 (gnus-group-next-unread-group 1)
4876 (gnus-configure-windows 'group 'force))
4877 (gnus-handle-ephemeral-exit quit-config))
4879 (setq gnus-newsgroup-name nil)))))
4881 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
4882 (defun gnus-summary-exit-no-update (&optional no-questions)
4883 "Quit reading current newsgroup without updating read article info."
4885 (gnus-set-global-variables)
4886 (let* ((group gnus-newsgroup-name)
4887 (quit-config (gnus-group-quit-config group)))
4888 (when (or no-questions
4890 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
4891 ;; If we have several article buffers, we kill them at exit.
4892 (unless gnus-single-article-buffer
4893 (gnus-kill-buffer gnus-article-buffer)
4894 (gnus-kill-buffer gnus-original-article-buffer)
4895 (setq gnus-article-current nil))
4896 (if (not gnus-kill-summary-on-exit)
4897 (gnus-deaden-summary)
4898 (gnus-close-group group)
4899 (gnus-summary-clear-local-variables)
4900 (set-buffer gnus-group-buffer)
4901 (gnus-summary-clear-local-variables)
4902 (when (get-buffer gnus-summary-buffer)
4903 (kill-buffer gnus-summary-buffer)))
4904 (unless gnus-single-article-buffer
4905 (setq gnus-article-current nil))
4906 (when gnus-use-trees
4907 (gnus-tree-close group))
4908 (gnus-async-prefetch-remove-group group)
4909 (when (get-buffer gnus-article-buffer)
4910 (bury-buffer gnus-article-buffer))
4911 ;; Return to the group buffer.
4912 (gnus-configure-windows 'group 'force)
4913 ;; Clear the current group name.
4914 (setq gnus-newsgroup-name nil)
4915 (when (equal (gnus-group-group-name) group)
4916 (gnus-group-next-unread-group 1))
4918 (gnus-handle-ephemeral-exit quit-config)))))
4920 (defun gnus-handle-ephemeral-exit (quit-config)
4921 "Handle movement when leaving an ephemeral group. The state
4922 which existed when entering the ephemeral is reset."
4923 (if (not (buffer-name (car quit-config)))
4924 (gnus-configure-windows 'group 'force)
4925 (set-buffer (car quit-config))
4926 (cond ((eq major-mode 'gnus-summary-mode)
4927 (gnus-set-global-variables))
4928 ((eq major-mode 'gnus-article-mode)
4930 ;; The `gnus-summary-buffer' variable may point
4931 ;; to the old summary buffer when using a single
4933 (unless (gnus-buffer-live-p gnus-summary-buffer)
4934 (set-buffer gnus-group-buffer))
4935 (set-buffer gnus-summary-buffer)
4936 (gnus-set-global-variables))))
4937 (if (or (eq (cdr quit-config) 'article)
4938 (eq (cdr quit-config) 'pick))
4940 ;; The current article may be from the ephemeral group
4941 ;; thus it is best that we reload this article
4942 (gnus-summary-show-article)
4943 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
4944 (gnus-configure-windows 'pick 'force)
4945 (gnus-configure-windows (cdr quit-config) 'force)))
4946 (gnus-configure-windows (cdr quit-config) 'force))
4947 (when (eq major-mode 'gnus-summary-mode)
4948 (gnus-summary-next-subject 1 nil t)
4949 (gnus-summary-recenter)
4950 (gnus-summary-position-point))))
4954 (defvar gnus-dead-summary-mode-map nil)
4956 (unless gnus-dead-summary-mode-map
4957 (setq gnus-dead-summary-mode-map (make-keymap))
4958 (suppress-keymap gnus-dead-summary-mode-map)
4959 (substitute-key-definition
4960 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
4961 (let ((keys '("\C-d" "\r" "\177")))
4963 (define-key gnus-dead-summary-mode-map
4964 (pop keys) 'gnus-summary-wake-up-the-dead))))
4966 (defvar gnus-dead-summary-mode nil
4967 "Minor mode for Gnus summary buffers.")
4969 (defun gnus-dead-summary-mode (&optional arg)
4970 "Minor mode for Gnus summary buffers."
4972 (when (eq major-mode 'gnus-summary-mode)
4973 (make-local-variable 'gnus-dead-summary-mode)
4974 (setq gnus-dead-summary-mode
4975 (if (null arg) (not gnus-dead-summary-mode)
4976 (> (prefix-numeric-value arg) 0)))
4977 (when gnus-dead-summary-mode
4978 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
4979 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
4980 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
4981 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
4982 minor-mode-map-alist)))))
4984 (defun gnus-deaden-summary ()
4985 "Make the current summary buffer into a dead summary buffer."
4986 ;; Kill any previous dead summary buffer.
4987 (when (and gnus-dead-summary
4988 (buffer-name gnus-dead-summary))
4990 (set-buffer gnus-dead-summary)
4991 (when gnus-dead-summary-mode
4992 (kill-buffer (current-buffer)))))
4993 ;; Make this the current dead summary.
4994 (setq gnus-dead-summary (current-buffer))
4995 (gnus-dead-summary-mode 1)
4996 (let ((name (buffer-name)))
4997 (when (string-match "Summary" name)
4999 (concat (substring name 0 (match-beginning 0)) "Dead "
5000 (substring name (match-beginning 0)))
5003 (defun gnus-kill-or-deaden-summary (buffer)
5004 "Kill or deaden the summary BUFFER."
5005 (when (and (buffer-name buffer)
5006 (not gnus-single-article-buffer))
5009 (gnus-kill-buffer gnus-article-buffer)
5010 (gnus-kill-buffer gnus-original-article-buffer)))
5011 (cond (gnus-kill-summary-on-exit
5012 (when (and gnus-use-trees
5013 (and (get-buffer buffer)
5014 (buffer-name (get-buffer buffer))))
5016 (set-buffer (get-buffer buffer))
5017 (gnus-tree-close gnus-newsgroup-name)))
5018 (gnus-kill-buffer buffer))
5019 ((and (get-buffer buffer)
5020 (buffer-name (get-buffer buffer)))
5023 (gnus-deaden-summary)))))
5025 (defun gnus-summary-wake-up-the-dead (&rest args)
5026 "Wake up the dead summary buffer."
5028 (gnus-dead-summary-mode -1)
5029 (let ((name (buffer-name)))
5030 (when (string-match "Dead " name)
5032 (concat (substring name 0 (match-beginning 0))
5033 (substring name (match-end 0)))
5035 (gnus-message 3 "This dead summary is now alive again"))
5037 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5038 (defun gnus-summary-fetch-faq (&optional faq-dir)
5039 "Fetch the FAQ for the current group.
5040 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5044 (when current-prefix-arg
5046 "Faq dir: " (and (listp gnus-group-faq-directory)
5047 gnus-group-faq-directory)))))
5048 (let (gnus-faq-buffer)
5049 (when (setq gnus-faq-buffer
5050 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5051 (gnus-configure-windows 'summary-faq))))
5053 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5054 (defun gnus-summary-describe-group (&optional force)
5055 "Describe the current newsgroup."
5057 (gnus-group-describe-group force gnus-newsgroup-name))
5059 (defun gnus-summary-describe-briefly ()
5060 "Describe summary mode commands briefly."
5063 (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")))
5065 ;; Walking around group mode buffer from summary mode.
5067 (defun gnus-summary-next-group (&optional no-article target-group backward)
5068 "Exit current newsgroup and then select next unread newsgroup.
5069 If prefix argument NO-ARTICLE is non-nil, no article is selected
5070 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5071 previous group instead."
5073 (gnus-set-global-variables)
5074 ;; Stop pre-fetching.
5075 (gnus-async-halt-prefetch)
5076 (let ((current-group gnus-newsgroup-name)
5077 (current-buffer (current-buffer))
5079 ;; First we semi-exit this group to update Xrefs and all variables.
5080 ;; We can't do a real exit, because the window conf must remain
5081 ;; the same in case the user is prompted for info, and we don't
5082 ;; want the window conf to change before that...
5083 (gnus-summary-exit t)
5084 (while (not entered)
5085 ;; Then we find what group we are supposed to enter.
5086 (set-buffer gnus-group-buffer)
5087 (gnus-group-jump-to-group current-group)
5090 (if (eq gnus-keep-same-level 'best)
5091 (gnus-summary-best-group gnus-newsgroup-name)
5092 (gnus-summary-search-group backward gnus-keep-same-level))))
5093 (if (not target-group)
5094 ;; There are no further groups, so we return to the group
5097 (gnus-message 5 "Returning to the group buffer")
5099 (set-buffer current-buffer)
5101 (run-hooks 'gnus-group-no-more-groups-hook))
5102 ;; We try to enter the target group.
5103 (gnus-group-jump-to-group target-group)
5104 (let ((unreads (gnus-group-group-unread)))
5105 (if (and (or (eq t unreads)
5106 (and unreads (not (zerop unreads))))
5107 (gnus-summary-read-group
5108 target-group nil no-article current-buffer))
5110 (setq current-group target-group
5111 target-group nil)))))))
5113 (defun gnus-summary-prev-group (&optional no-article)
5114 "Exit current newsgroup and then select previous unread newsgroup.
5115 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5117 (gnus-summary-next-group no-article nil t))
5119 ;; Walking around summary lines.
5121 (defun gnus-summary-first-subject (&optional unread)
5122 "Go to the first unread subject.
5123 If UNREAD is non-nil, go to the first unread article.
5124 Returns the article selected or nil if there are no unread articles."
5129 ((null gnus-newsgroup-data)
5130 (gnus-message 3 "No articles in the group")
5132 ;; Pick the first article.
5134 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5135 (gnus-data-number (car gnus-newsgroup-data)))
5136 ;; No unread articles.
5137 ((null gnus-newsgroup-unreads)
5138 (gnus-message 3 "No more unread articles")
5140 ;; Find the first unread article.
5142 (let ((data gnus-newsgroup-data))
5144 (not (gnus-data-unread-p (car data))))
5145 (setq data (cdr data)))
5147 (goto-char (gnus-data-pos (car data)))
5148 (gnus-data-number (car data))))))
5149 (gnus-summary-position-point)))
5151 (defun gnus-summary-next-subject (n &optional unread dont-display)
5152 "Go to next N'th summary line.
5153 If N is negative, go to the previous N'th subject line.
5154 If UNREAD is non-nil, only unread articles are selected.
5155 The difference between N and the actual number of steps taken is
5158 (let ((backward (< n 0))
5162 (gnus-summary-find-prev unread)
5163 (gnus-summary-find-next unread)))
5166 (gnus-message 7 "No more%s articles"
5167 (if unread " unread" "")))
5168 (unless dont-display
5169 (gnus-summary-recenter)
5170 (gnus-summary-position-point))
5173 (defun gnus-summary-next-unread-subject (n)
5174 "Go to next N'th unread summary line."
5176 (gnus-summary-next-subject n t))
5178 (defun gnus-summary-prev-subject (n &optional unread)
5179 "Go to previous N'th summary line.
5180 If optional argument UNREAD is non-nil, only unread article is selected."
5182 (gnus-summary-next-subject (- n) unread))
5184 (defun gnus-summary-prev-unread-subject (n)
5185 "Go to previous N'th unread summary line."
5187 (gnus-summary-next-subject (- n) t))
5189 (defun gnus-summary-goto-subject (article &optional force silent)
5190 "Go the subject line of ARTICLE.
5191 If FORCE, also allow jumping to articles not currently shown."
5192 (interactive "nArticle number: ")
5194 (data (gnus-data-find article)))
5195 ;; We read in the article if we have to.
5198 (gnus-summary-insert-subject article (and (vectorp force) force) t)
5199 (setq data (gnus-data-find article)))
5204 (gnus-message 3 "Can't find article %d" article))
5206 (goto-char (gnus-data-pos data))
5209 ;; Walking around summary lines with displaying articles.
5211 (defun gnus-summary-expand-window (&optional arg)
5212 "Make the summary buffer take up the entire Emacs frame.
5213 Given a prefix, will force an `article' buffer configuration."
5215 (gnus-set-global-variables)
5217 (gnus-configure-windows 'article 'force)
5218 (gnus-configure-windows 'summary 'force)))
5220 (defun gnus-summary-display-article (article &optional all-header)
5221 "Display ARTICLE in article buffer."
5222 (gnus-set-global-variables)
5226 (if gnus-summary-display-article-function
5227 (funcall gnus-summary-display-article-function article all-header)
5228 (gnus-article-prepare article all-header))
5229 (run-hooks 'gnus-select-article-hook)
5230 (when (and gnus-current-article
5231 (not (zerop gnus-current-article)))
5232 (gnus-summary-goto-subject gnus-current-article))
5233 (gnus-summary-recenter)
5234 (when (and gnus-use-trees gnus-show-threads)
5235 (gnus-possibly-generate-tree article)
5236 (gnus-highlight-selected-tree article))
5237 ;; Successfully display article.
5238 (gnus-article-set-window-start
5239 (cdr (assq article gnus-newsgroup-bookmarks))))))
5241 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5242 "Select the current article.
5243 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5244 non-nil, the article will be re-fetched even if it already present in
5245 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5247 ;; Make sure we are in the summary buffer to work around bbdb bug.
5248 (unless (eq major-mode 'gnus-summary-mode)
5249 (set-buffer gnus-summary-buffer))
5250 (let ((article (or article (gnus-summary-article-number)))
5251 (all-headers (not (not all-headers))) ;Must be T or NIL.
5252 gnus-summary-display-article-function
5255 (gnus-summary-article-pseudo-p article)
5256 (error "This is a pseudo-article."))
5259 (set-buffer gnus-summary-buffer)
5260 (if (or (and gnus-single-article-buffer
5261 (or (null gnus-current-article)
5262 (null gnus-article-current)
5263 (null (get-buffer gnus-article-buffer))
5264 (not (eq article (cdr gnus-article-current)))
5265 (not (equal (car gnus-article-current)
5266 gnus-newsgroup-name))))
5267 (and (not gnus-single-article-buffer)
5268 (or (null gnus-current-article)
5269 (not (eq gnus-current-article article))))
5271 ;; The requested article is different from the current article.
5273 (gnus-summary-display-article article all-headers)
5275 (when (or all-headers gnus-show-all-headers)
5276 (gnus-article-show-all-headers))
5279 (gnus-article-set-window-start
5280 (cdr (assq article gnus-newsgroup-bookmarks)))))))
5282 (defun gnus-summary-set-current-mark (&optional current-mark)
5283 "Obsolete function."
5286 (defun gnus-summary-next-article (&optional unread subject backward push)
5287 "Select the next article.
5288 If UNREAD, only unread articles are selected.
5289 If SUBJECT, only articles with SUBJECT are selected.
5290 If BACKWARD, the previous article is selected instead of the next."
5292 (gnus-set-global-variables)
5294 ;; Is there such an article?
5295 ((and (gnus-summary-search-forward unread subject backward)
5296 (or (gnus-summary-display-article (gnus-summary-article-number))
5297 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5298 (gnus-summary-position-point))
5299 ;; If not, we try the first unread, if that is wanted.
5301 gnus-auto-select-same
5302 ;; Make sure that we don't select the current article.
5303 (not (eq (gnus-summary-article-number)
5305 (gnus-summary-first-subject t)
5306 (gnus-summary-article-number))))
5307 (gnus-summary-first-unread-article))
5308 (gnus-summary-position-point)
5309 (gnus-message 6 "Wrapped"))
5310 ;; Try to get next/previous article not displayed in this group.
5311 ((and gnus-auto-extend-newsgroup
5312 (not unread) (not subject))
5313 (gnus-summary-goto-article
5314 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5316 ;; Go to next/previous group.
5318 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5319 (gnus-summary-jump-to-group gnus-newsgroup-name))
5320 (let ((cmd last-command-char)
5322 (if (eq gnus-keep-same-level 'best)
5323 (gnus-summary-best-group gnus-newsgroup-name)
5324 (gnus-summary-search-group backward gnus-keep-same-level))))
5325 ;; For some reason, the group window gets selected. We change
5327 (select-window (get-buffer-window (current-buffer)))
5328 ;; Select next unread newsgroup automagically.
5330 ((or (not gnus-auto-select-next)
5332 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5333 ((or (eq gnus-auto-select-next 'quietly)
5334 (and (eq gnus-auto-select-next 'slightly-quietly)
5336 (and (eq gnus-auto-select-next 'almost-quietly)
5337 (gnus-summary-last-article-p)))
5339 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5341 (gnus-message 7 "No more%s articles (%s)..."
5342 (if unread " unread" "")
5343 (if group (concat "selecting " group)
5345 (gnus-summary-next-group nil group backward)))
5347 (when (gnus-key-press-event-p last-input-event)
5348 (gnus-summary-walk-group-buffer
5349 gnus-newsgroup-name cmd unread backward))))))))
5351 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
5352 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5353 (?\C-p (gnus-group-prev-unread-group 1))))
5354 (cursor-in-echo-area t)
5355 keve key group ended)
5357 (set-buffer gnus-group-buffer)
5358 (gnus-summary-jump-to-group from-group)
5360 (if (eq gnus-keep-same-level 'best)
5361 (gnus-summary-best-group gnus-newsgroup-name)
5362 (gnus-summary-search-group backward gnus-keep-same-level))))
5365 5 "No more%s articles%s" (if unread " unread" "")
5367 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5368 (format " (Type %s for %s [%s])"
5369 (single-key-description cmd) group
5370 (car (gnus-gethash group gnus-newsrc-hashtb)))
5371 (format " (Type %s to exit %s)"
5372 (single-key-description cmd)
5373 gnus-newsgroup-name)))
5374 ;; Confirm auto selection.
5375 (setq key (car (setq keve (gnus-read-event-char))))
5378 ((assq key keystrokes)
5379 (let ((obuf (current-buffer)))
5380 (switch-to-buffer gnus-group-buffer)
5382 (gnus-group-jump-to-group group))
5383 (eval (cadr (assq key keystrokes)))
5384 (setq group (gnus-group-group-name))
5385 (switch-to-buffer obuf))
5389 (gnus-ephemeral-group-p gnus-newsgroup-name))
5391 (gnus-summary-next-group nil group backward)))
5393 (push (cdr keve) unread-command-events))))))
5395 (defun gnus-summary-next-unread-article ()
5396 "Select unread article after current one."
5398 (gnus-summary-next-article
5399 (or (not (eq gnus-summary-goto-unread 'never))
5400 (gnus-summary-last-article-p (gnus-summary-article-number)))
5401 (and gnus-auto-select-same
5402 (gnus-summary-article-subject))))
5404 (defun gnus-summary-prev-article (&optional unread subject)
5405 "Select the article after the current one.
5406 If UNREAD is non-nil, only unread articles are selected."
5408 (gnus-summary-next-article unread subject t))
5410 (defun gnus-summary-prev-unread-article ()
5411 "Select unread article before current one."
5413 (gnus-summary-prev-article
5414 (or (not (eq gnus-summary-goto-unread 'never))
5415 (gnus-summary-first-article-p (gnus-summary-article-number)))
5416 (and gnus-auto-select-same
5417 (gnus-summary-article-subject))))
5419 (defun gnus-summary-next-page (&optional lines circular)
5420 "Show next page of the selected article.
5421 If at the end of the current article, select the next article.
5422 LINES says how many lines should be scrolled up.
5424 If CIRCULAR is non-nil, go to the start of the article instead of
5425 selecting the next article when reaching the end of the current
5428 (setq gnus-summary-buffer (current-buffer))
5429 (gnus-set-global-variables)
5430 (let ((article (gnus-summary-article-number))
5432 (gnus-configure-windows 'article)
5433 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
5434 (if (and (eq gnus-summary-goto-unread 'never)
5435 (not (gnus-summary-last-article-p article)))
5436 (gnus-summary-next-article)
5437 (gnus-summary-next-unread-article))
5438 (if (or (null gnus-current-article)
5439 (null gnus-article-current)
5440 (/= article (cdr gnus-article-current))
5441 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5442 ;; Selected subject is different from current article's.
5443 (gnus-summary-display-article article)
5444 (gnus-eval-in-buffer-window gnus-article-buffer
5445 (setq endp (gnus-article-next-page lines)))
5448 (gnus-summary-beginning-of-article))
5450 (gnus-message 3 "End of message"))
5452 (if (and (eq gnus-summary-goto-unread 'never)
5453 (not (gnus-summary-last-article-p article)))
5454 (gnus-summary-next-article)
5455 (gnus-summary-next-unread-article)))))))
5456 (gnus-summary-recenter)
5457 (gnus-summary-position-point)))
5459 (defun gnus-summary-prev-page (&optional lines)
5460 "Show previous page of selected article.
5461 Argument LINES specifies lines to be scrolled down."
5463 (gnus-set-global-variables)
5464 (let ((article (gnus-summary-article-number)))
5465 (gnus-configure-windows 'article)
5466 (if (or (null gnus-current-article)
5467 (null gnus-article-current)
5468 (/= article (cdr gnus-article-current))
5469 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5470 ;; Selected subject is different from current article's.
5471 (gnus-summary-display-article article)
5472 (gnus-summary-recenter)
5473 (gnus-eval-in-buffer-window gnus-article-buffer
5474 (gnus-article-prev-page lines))))
5475 (gnus-summary-position-point))
5477 (defun gnus-summary-scroll-up (lines)
5478 "Scroll up (or down) one line current article.
5479 Argument LINES specifies lines to be scrolled up (or down if negative)."
5481 (gnus-set-global-variables)
5482 (gnus-configure-windows 'article)
5483 (gnus-summary-show-thread)
5484 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
5485 (gnus-eval-in-buffer-window gnus-article-buffer
5487 (when (gnus-article-next-page lines)
5488 (gnus-message 3 "End of message")))
5490 (gnus-article-prev-page (- lines))))))
5491 (gnus-summary-recenter)
5492 (gnus-summary-position-point))
5494 (defun gnus-summary-next-same-subject ()
5495 "Select next article which has the same subject as current one."
5497 (gnus-set-global-variables)
5498 (gnus-summary-next-article nil (gnus-summary-article-subject)))
5500 (defun gnus-summary-prev-same-subject ()
5501 "Select previous article which has the same subject as current one."
5503 (gnus-set-global-variables)
5504 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
5506 (defun gnus-summary-next-unread-same-subject ()
5507 "Select next unread article which has the same subject as current one."
5509 (gnus-set-global-variables)
5510 (gnus-summary-next-article t (gnus-summary-article-subject)))
5512 (defun gnus-summary-prev-unread-same-subject ()
5513 "Select previous unread article which has the same subject as current one."
5515 (gnus-set-global-variables)
5516 (gnus-summary-prev-article t (gnus-summary-article-subject)))
5518 (defun gnus-summary-first-unread-article ()
5519 "Select the first unread article.
5520 Return nil if there are no unread articles."
5522 (gnus-set-global-variables)
5524 (when (gnus-summary-first-subject t)
5525 (gnus-summary-show-thread)
5526 (gnus-summary-first-subject t)
5527 (gnus-summary-display-article (gnus-summary-article-number)))
5528 (gnus-summary-position-point)))
5530 (defun gnus-summary-first-article ()
5531 "Select the first article.
5532 Return nil if there are no articles."
5534 (gnus-set-global-variables)
5536 (when (gnus-summary-first-subject)
5537 (gnus-summary-show-thread)
5538 (gnus-summary-first-subject)
5539 (gnus-summary-display-article (gnus-summary-article-number)))
5540 (gnus-summary-position-point)))
5542 (defun gnus-summary-best-unread-article ()
5543 "Select the unread article with the highest score."
5545 (gnus-set-global-variables)
5546 (let ((best -1000000)
5547 (data gnus-newsgroup-data)
5550 (and (gnus-data-unread-p (car data))
5552 (gnus-summary-article-score (gnus-data-number (car data))))
5555 article (gnus-data-number (car data))))
5556 (setq data (cdr data)))
5559 (gnus-summary-goto-article article)
5560 (error "No unread articles"))
5561 (gnus-summary-position-point))))
5563 (defun gnus-summary-last-subject ()
5564 "Go to the last displayed subject line in the group."
5565 (let ((article (gnus-data-number (car (gnus-data-list t)))))
5567 (gnus-summary-goto-subject article))))
5569 (defun gnus-summary-goto-article (article &optional all-headers force)
5570 "Fetch ARTICLE and display it if it exists.
5571 If ALL-HEADERS is non-nil, no header lines are hidden."
5577 (mapcar (lambda (number) (list (int-to-string number)))
5578 gnus-newsgroup-limit)))
5582 (if (gnus-summary-goto-subject article force)
5583 (gnus-summary-display-article article all-headers)
5584 (gnus-message 4 "Couldn't go to article %s" article) nil)
5585 (gnus-summary-position-point)))
5587 (defun gnus-summary-goto-last-article ()
5588 "Go to the previously read article."
5591 (when gnus-last-article
5592 (gnus-summary-goto-article gnus-last-article))
5593 (gnus-summary-position-point)))
5595 (defun gnus-summary-pop-article (number)
5596 "Pop one article off the history and go to the previous.
5597 NUMBER articles will be popped off."
5600 (setq gnus-newsgroup-history
5601 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
5603 (gnus-summary-goto-article (car to))
5604 (error "Article history empty")))
5605 (gnus-summary-position-point))
5607 ;; Summary commands and functions for limiting the summary buffer.
5609 (defun gnus-summary-limit-to-articles (n)
5610 "Limit the summary buffer to the next N articles.
5611 If not given a prefix, use the process marked articles instead."
5613 (gnus-set-global-variables)
5615 (let ((articles (gnus-summary-work-articles n)))
5616 (setq gnus-newsgroup-processable nil)
5617 (gnus-summary-limit articles))
5618 (gnus-summary-position-point)))
5620 (defun gnus-summary-pop-limit (&optional total)
5621 "Restore the previous limit.
5622 If given a prefix, remove all limits."
5624 (gnus-set-global-variables)
5626 (setq gnus-newsgroup-limits
5627 (list (mapcar (lambda (h) (mail-header-number h))
5628 gnus-newsgroup-headers))))
5629 (unless gnus-newsgroup-limits
5630 (error "No limit to pop"))
5632 (gnus-summary-limit nil 'pop)
5633 (gnus-summary-position-point)))
5635 (defun gnus-summary-limit-to-subject (subject &optional header)
5636 "Limit the summary buffer to articles that have subjects that match a regexp."
5637 (interactive "sRegexp: ")
5639 (setq header "subject"))
5640 (when (not (equal "" subject))
5642 (let ((articles (gnus-summary-find-matching
5643 (or header "subject") subject 'all)))
5645 (error "Found no matches for \"%s\"" subject))
5646 (gnus-summary-limit articles))
5647 (gnus-summary-position-point))))
5649 (defun gnus-summary-limit-to-author (from)
5650 "Limit the summary buffer to articles that have authors that match a regexp."
5651 (interactive "sRegexp: ")
5652 (gnus-summary-limit-to-subject from "from"))
5654 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5656 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5658 (defun gnus-summary-limit-to-unread (&optional all)
5659 "Limit the summary buffer to articles that are not marked as read.
5660 If ALL is non-nil, limit strictly to unread articles."
5663 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
5664 (gnus-summary-limit-to-marks
5665 ;; Concat all the marks that say that an article is read and have
5667 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
5668 gnus-killed-mark gnus-kill-file-mark
5669 gnus-low-score-mark gnus-expirable-mark
5670 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
5671 gnus-duplicate-mark)
5674 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
5675 (make-obsolete 'gnus-summary-delete-marked-with
5676 'gnus-summary-limit-exlude-marks)
5678 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
5679 "Exclude articles that are marked with MARKS (e.g. \"DK\").
5680 If REVERSE, limit the summary buffer to articles that are marked
5681 with MARKS. MARKS can either be a string of marks or a list of marks.
5682 Returns how many articles were removed."
5683 (interactive "sMarks: ")
5684 (gnus-summary-limit-to-marks marks t))
5686 (defun gnus-summary-limit-to-marks (marks &optional reverse)
5687 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
5688 If REVERSE (the prefix), limit the summary buffer to articles that are
5689 not marked with MARKS. MARKS can either be a string of marks or a
5691 Returns how many articles were removed."
5692 (interactive (list (read-string "Marks: ") current-prefix-arg))
5693 (gnus-set-global-variables)
5695 (let ((data gnus-newsgroup-data)
5696 (marks (if (listp marks) marks
5697 (append marks nil))) ; Transform to list.
5700 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
5701 (memq (gnus-data-mark (car data)) marks))
5702 (push (gnus-data-number (car data)) articles))
5703 (setq data (cdr data)))
5704 (gnus-summary-limit articles))
5705 (gnus-summary-position-point)))
5707 (defun gnus-summary-limit-to-score (&optional score)
5708 "Limit to articles with score at or above SCORE."
5710 (gnus-set-global-variables)
5711 (setq score (if score
5712 (prefix-numeric-value score)
5713 (or gnus-summary-default-score 0)))
5714 (let ((data gnus-newsgroup-data)
5717 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
5719 (push (gnus-data-number (car data)) articles))
5720 (setq data (cdr data)))
5722 (gnus-summary-limit articles)
5723 (gnus-summary-position-point))))
5725 (defun gnus-summary-limit-include-dormant ()
5726 "Display all the hidden articles that are marked as dormant."
5728 (gnus-set-global-variables)
5729 (unless gnus-newsgroup-dormant
5730 (error "There are no dormant articles in this group"))
5732 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
5733 (gnus-summary-position-point)))
5735 (defun gnus-summary-limit-exclude-dormant ()
5736 "Hide all dormant articles."
5738 (gnus-set-global-variables)
5740 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
5741 (gnus-summary-position-point)))
5743 (defun gnus-summary-limit-exclude-childless-dormant ()
5744 "Hide all dormant articles that have no children."
5746 (gnus-set-global-variables)
5747 (let ((data (gnus-data-list t))
5748 articles d children)
5749 ;; Find all articles that are either not dormant or have
5751 (while (setq d (pop data))
5752 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
5754 (gnus-article-children (gnus-data-number d)))
5757 (when (memq (car children) articles)
5762 (push (gnus-data-number d) articles)))
5765 (gnus-summary-limit articles)
5766 (gnus-summary-position-point))))
5768 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
5769 "Mark all unread excluded articles as read.
5770 If ALL, mark even excluded ticked and dormants as read."
5772 (let ((articles (gnus-sorted-complement
5774 (mapcar (lambda (h) (mail-header-number h))
5775 gnus-newsgroup-headers)
5777 (sort gnus-newsgroup-limit '<)))
5779 (setq gnus-newsgroup-unreads nil)
5781 (setq gnus-newsgroup-dormant nil
5782 gnus-newsgroup-marked nil
5783 gnus-newsgroup-reads
5785 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
5786 gnus-newsgroup-reads))
5787 (while (setq article (pop articles))
5788 (unless (or (memq article gnus-newsgroup-dormant)
5789 (memq article gnus-newsgroup-marked))
5790 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
5792 (defun gnus-summary-limit (articles &optional pop)
5794 ;; We pop the previous limit off the stack and use that.
5795 (setq articles (car gnus-newsgroup-limits)
5796 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
5797 ;; We use the new limit, so we push the old limit on the stack.
5798 (push gnus-newsgroup-limit gnus-newsgroup-limits))
5800 (setq gnus-newsgroup-limit articles)
5801 (let ((total (length gnus-newsgroup-data))
5802 (data (gnus-data-find-list (gnus-summary-article-number)))
5803 (gnus-summary-mark-below nil) ; Inhibit this.
5805 ;; This will do all the work of generating the new summary buffer
5806 ;; according to the new limit.
5807 (gnus-summary-prepare)
5808 ;; Hide any threads, possibly.
5809 (and gnus-show-threads
5810 gnus-thread-hide-subtree
5811 (gnus-summary-hide-all-threads))
5812 ;; Try to return to the article you were at, or one in the
5815 ;; We try to find some article after the current one.
5817 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
5820 (setq data (cdr data))))
5822 ;; If there is no data, that means that we were after the last
5823 ;; article. The same goes when we can't find any articles
5824 ;; after the current one.
5825 (goto-char (point-max))
5826 (gnus-summary-find-prev))
5827 ;; We return how many articles were removed from the summary
5828 ;; buffer as a result of the new limit.
5829 (- total (length gnus-newsgroup-data))))
5831 (defsubst gnus-invisible-cut-children (threads)
5834 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
5839 (defsubst gnus-cut-thread (thread)
5840 "Go forwards in the thread until we find an article that we want to display."
5841 (when (or (eq gnus-fetch-old-headers 'some)
5842 (eq gnus-build-sparse-threads 'some)
5843 (eq gnus-build-sparse-threads 'more))
5844 ;; Deal with old-fetched headers and sparse threads.
5848 (memq (mail-header-number (car thread)) gnus-newsgroup-sparse)
5849 (memq (mail-header-number (car thread)) gnus-newsgroup-ancient))
5850 (or (<= (length (cdr thread)) 1)
5851 (gnus-invisible-cut-children (cdr thread))))
5852 (setq thread (cadr thread))))
5855 (defun gnus-cut-threads (threads)
5856 "Cut off all uninteresting articles from the beginning of threads."
5857 (when (or (eq gnus-fetch-old-headers 'some)
5858 (eq gnus-build-sparse-threads 'some)
5859 (eq gnus-build-sparse-threads 'more))
5862 (setcar th (gnus-cut-thread (car th)))
5863 (setq th (cdr th)))))
5864 ;; Remove nixed out threads.
5867 (defun gnus-summary-initial-limit (&optional show-if-empty)
5868 "Figure out what the initial limit is supposed to be on group entry.
5869 This entails weeding out unwanted dormants, low-scored articles,
5870 fetch-old-headers verbiage, and so on."
5871 ;; Most groups have nothing to remove.
5872 (if (or gnus-inhibit-limiting
5873 (and (null gnus-newsgroup-dormant)
5874 (not (eq gnus-fetch-old-headers 'some))
5875 (null gnus-summary-expunge-below)
5876 (not (eq gnus-build-sparse-threads 'some))
5877 (not (eq gnus-build-sparse-threads 'more))
5878 (null gnus-thread-expunge-below)
5879 (not gnus-use-nocem)))
5881 (push gnus-newsgroup-limit gnus-newsgroup-limits)
5882 (setq gnus-newsgroup-limit nil)
5885 (unless (car (symbol-value node))
5886 ;; These threads have no parents -- they are roots.
5887 (let ((nodes (cdr (symbol-value node)))
5890 (if (and gnus-thread-expunge-below
5891 (< (gnus-thread-total-score (car nodes))
5892 gnus-thread-expunge-below))
5893 (gnus-expunge-thread (pop nodes))
5894 (setq thread (pop nodes))
5895 (gnus-summary-limit-children thread))))))
5896 gnus-newsgroup-dependencies)
5897 ;; If this limitation resulted in an empty group, we might
5898 ;; pop the previous limit and use it instead.
5899 (when (and (not gnus-newsgroup-limit)
5901 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
5902 gnus-newsgroup-limit))
5904 (defun gnus-summary-limit-children (thread)
5905 "Return 1 if this subthread is visible and 0 if it is not."
5906 ;; First we get the number of visible children to this thread. This
5907 ;; is done by recursing down the thread using this function, so this
5908 ;; will really go down to a leaf article first, before slowly
5909 ;; working its way up towards the root.
5913 (apply '+ (mapcar 'gnus-summary-limit-children
5916 (number (mail-header-number (car thread)))
5919 (not (memq number gnus-newsgroup-marked))
5921 ;; If this article is dormant and has absolutely no visible
5922 ;; children, then this article isn't visible.
5923 (and (memq number gnus-newsgroup-dormant)
5925 ;; If this is "fetch-old-headered" and there is only one
5926 ;; visible child (or less), then we don't want this article.
5927 (and (eq gnus-fetch-old-headers 'some)
5928 (memq number gnus-newsgroup-ancient)
5930 ;; If this is a sparsely inserted article with no children,
5931 ;; we don't want it.
5932 (and (eq gnus-build-sparse-threads 'some)
5933 (memq number gnus-newsgroup-sparse)
5935 ;; If we use expunging, and this article is really
5936 ;; low-scored, then we don't want this article.
5937 (when (and gnus-summary-expunge-below
5939 (or (cdr (assq number gnus-newsgroup-scored))
5940 gnus-summary-default-score))
5941 gnus-summary-expunge-below))
5942 ;; We increase the expunge-tally here, but that has
5943 ;; nothing to do with the limits, really.
5944 (incf gnus-newsgroup-expunged-tally)
5945 ;; We also mark as read here, if that's wanted.
5946 (when (and gnus-summary-mark-below
5947 (< score gnus-summary-mark-below))
5948 (setq gnus-newsgroup-unreads
5949 (delq number gnus-newsgroup-unreads))
5950 (if gnus-newsgroup-auto-expire
5951 (push number gnus-newsgroup-expirable)
5952 (push (cons number gnus-low-score-mark)
5953 gnus-newsgroup-reads)))
5955 ;; Check NoCeM things.
5957 (gnus-nocem-unwanted-article-p
5958 (mail-header-id (car thread))))))
5959 ;; Nope, invisible article.
5961 ;; Ok, this article is to be visible, so we add it to the limit
5963 (push number gnus-newsgroup-limit)
5966 (defun gnus-expunge-thread (thread)
5967 "Mark all articles in THREAD as read."
5968 (let* ((number (mail-header-number (car thread))))
5969 (incf gnus-newsgroup-expunged-tally)
5970 ;; We also mark as read here, if that's wanted.
5971 (setq gnus-newsgroup-unreads
5972 (delq number gnus-newsgroup-unreads))
5973 (if gnus-newsgroup-auto-expire
5974 (push number gnus-newsgroup-expirable)
5975 (push (cons number gnus-low-score-mark)
5976 gnus-newsgroup-reads)))
5977 ;; Go recursively through all subthreads.
5978 (mapcar 'gnus-expunge-thread (cdr thread)))
5980 ;; Summary article oriented commands
5982 (defun gnus-summary-refer-parent-article (n)
5983 "Refer parent article N times.
5984 If N is negative, go to ancestor -N instead.
5985 The difference between N and the number of articles fetched is returned."
5987 (gnus-set-global-variables)
5990 (when (not (natnump n))
5995 (setq header (gnus-summary-article-header))
5997 ;; If we try to find the parent of the currently
5998 ;; displayed article, then we take a look at the actual
5999 ;; References header, since this is slightly more
6000 ;; reliable than the References field we got from the
6002 (if (and (eq (mail-header-number header)
6003 (cdr gnus-article-current))
6004 (equal gnus-newsgroup-name
6005 (car gnus-article-current)))
6007 (set-buffer gnus-original-article-buffer)
6008 (nnheader-narrow-to-headers)
6010 (message-fetch-field "references")
6012 ;; It's not the current article, so we take a bet on
6013 ;; the value we got from the server.
6014 (mail-header-references header)))
6016 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6017 (gnus-message 1 "Couldn't find parent"))
6018 (gnus-message 1 "No references in article %d"
6019 (gnus-summary-article-number))
6022 (gnus-summary-position-point)
6025 (defun gnus-summary-refer-references ()
6026 "Fetch all articles mentioned in the References header.
6027 Return how many articles were fetched."
6029 (gnus-set-global-variables)
6030 (let ((ref (mail-header-references (gnus-summary-article-header)))
6031 (current (gnus-summary-article-number))
6035 (error "No References in the current article")
6036 ;; For each Message-ID in the References header...
6037 (while (string-match "<[^>]*>" ref)
6039 ;; ... fetch that article.
6040 (gnus-summary-refer-article
6041 (prog1 (match-string 0 ref)
6042 (setq ref (substring ref (match-end 0))))))
6043 (gnus-summary-goto-subject current)
6044 (gnus-summary-position-point)
6047 (defun gnus-summary-refer-article (message-id)
6048 "Fetch an article specified by MESSAGE-ID."
6049 (interactive "sMessage-ID: ")
6050 (when (and (stringp message-id)
6051 (not (zerop (length message-id))))
6052 ;; Construct the correct Message-ID if necessary.
6053 ;; Suggested by tale@pawl.rpi.edu.
6054 (unless (string-match "^<" message-id)
6055 (setq message-id (concat "<" message-id)))
6056 (unless (string-match ">$" message-id)
6057 (setq message-id (concat message-id ">")))
6058 (let* ((header (gnus-id-to-header message-id))
6060 (memq (mail-header-number header)
6061 gnus-newsgroup-sparse))))
6064 ;; The article is present in the buffer, to we just go to it.
6065 (gnus-summary-goto-article
6066 (mail-header-number header) nil header)
6068 (gnus-summary-update-article (mail-header-number header))))
6069 ;; We fetch the article
6070 (let ((gnus-override-method
6071 (and (gnus-news-group-p gnus-newsgroup-name)
6072 gnus-refer-article-method))
6074 ;; Start the special refer-article method, if necessary.
6075 (when (and gnus-refer-article-method
6076 (gnus-news-group-p gnus-newsgroup-name))
6077 (gnus-check-server gnus-refer-article-method))
6078 ;; Fetch the header, and display the article.
6079 (if (setq number (gnus-summary-insert-subject message-id))
6080 (gnus-summary-select-article nil nil nil number)
6081 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
6083 (defun gnus-summary-enter-digest-group (&optional force)
6084 "Enter an nndoc group based on the current article.
6085 If FORCE, force a digest interpretation. If not, try
6086 to guess what the document format is."
6088 (gnus-set-global-variables)
6089 (let ((conf gnus-current-window-configuration))
6091 (gnus-summary-select-article))
6092 (setq gnus-current-window-configuration conf)
6093 (let* ((name (format "%s-%d"
6094 (gnus-group-prefixed-name
6095 gnus-newsgroup-name (list 'nndoc ""))
6097 (set-buffer gnus-summary-buffer)
6098 gnus-current-article)))
6099 (ogroup gnus-newsgroup-name)
6100 (params (append (gnus-info-params (gnus-get-info ogroup))
6101 (list (cons 'to-group ogroup))))
6102 (case-fold-search t)
6103 (buf (current-buffer))
6106 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6107 (insert-buffer-substring gnus-original-article-buffer)
6108 ;; Remove lines that may lead nndoc to misinterpret the
6111 (goto-char (point-min))
6112 (or (search-forward "\n\n" nil t) (point)))
6113 (goto-char (point-min))
6114 (delete-matching-lines "^\\(Path\\):\\|^From ")
6117 (if (gnus-group-read-ephemeral-group
6118 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6120 ,(if force 'digest 'guess))) t)
6121 ;; Make all postings to this group go to the parent group.
6122 (nconc (gnus-info-params (gnus-get-info name))
6124 ;; Couldn't select this doc group.
6125 (switch-to-buffer buf)
6126 (gnus-set-global-variables)
6127 (gnus-configure-windows 'summary)
6128 (gnus-message 3 "Article couldn't be entered?"))
6129 (kill-buffer dig)))))
6131 (defun gnus-summary-read-document (n)
6132 "Open a new group based on the current article(s).
6133 This will allow you to read digests and other similar
6134 documents as newsgroups.
6135 Obeys the standard process/prefix convention."
6137 (let* ((articles (gnus-summary-work-articles n))
6138 (ogroup gnus-newsgroup-name)
6139 (params (append (gnus-info-params (gnus-get-info ogroup))
6140 (list (cons 'to-group ogroup))))
6141 article group egroup groups vgroup)
6142 (while (setq article (pop articles))
6143 (setq group (format "%s-%d" gnus-newsgroup-name article))
6144 (gnus-summary-remove-process-mark article)
6145 (when (gnus-summary-display-article article)
6147 (nnheader-temp-write nil
6148 (insert-buffer-substring gnus-original-article-buffer)
6149 ;; Remove some headers that may lead nndoc to make
6151 (message-narrow-to-head)
6152 (goto-char (point-min))
6153 (delete-matching-lines "^\\(Path\\):\\|^From ")
6156 (gnus-group-read-ephemeral-group
6157 group `(nndoc ,group (nndoc-address ,(current-buffer))
6158 (nndoc-article-type guess))
6161 ;; Make all postings to this group go to the parent group.
6162 (nconc (gnus-info-params (gnus-get-info egroup))
6164 (push egroup groups))
6165 ;; Couldn't select this doc group.
6166 (gnus-error 3 "Article couldn't be entered"))))))
6167 ;; Now we have selected all the documents.
6170 (error "None of the articles could be interpreted as documents"))
6171 ((gnus-group-read-ephemeral-group
6172 (setq vgroup (format
6173 "nnvirtual:%s-%s" gnus-newsgroup-name
6174 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6175 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6177 (cons (current-buffer) 'summary)))
6179 (error "Couldn't select virtual nndoc group")))))
6181 (defun gnus-summary-isearch-article (&optional regexp-p)
6182 "Do incremental search forward on the current article.
6183 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6185 (gnus-set-global-variables)
6186 (gnus-summary-select-article)
6187 (gnus-configure-windows 'article)
6188 (gnus-eval-in-buffer-window gnus-article-buffer
6189 ;;(goto-char (point-min))
6190 (isearch-forward regexp-p)))
6192 (defun gnus-summary-search-article-forward (regexp &optional backward)
6193 "Search for an article containing REGEXP forward.
6194 If BACKWARD, search backward instead."
6197 (format "Search article %s (regexp%s): "
6198 (if current-prefix-arg "backward" "forward")
6199 (if gnus-last-search-regexp
6200 (concat ", default " gnus-last-search-regexp)
6202 current-prefix-arg))
6203 (gnus-set-global-variables)
6204 (if (string-equal regexp "")
6205 (setq regexp (or gnus-last-search-regexp ""))
6206 (setq gnus-last-search-regexp regexp))
6207 (if (gnus-summary-search-article regexp backward)
6208 (gnus-summary-show-thread)
6209 (error "Search failed: \"%s\"" regexp)))
6211 (defun gnus-summary-search-article-backward (regexp)
6212 "Search for an article containing REGEXP backward."
6215 (format "Search article backward (regexp%s): "
6216 (if gnus-last-search-regexp
6217 (concat ", default " gnus-last-search-regexp)
6219 (gnus-summary-search-article-forward regexp 'backward))
6221 (defun gnus-summary-search-article (regexp &optional backward)
6222 "Search for an article containing REGEXP.
6223 Optional argument BACKWARD means do search for backward.
6224 `gnus-select-article-hook' is not called during the search."
6225 (let ((gnus-select-article-hook nil) ;Disable hook.
6226 (gnus-article-display-hook nil)
6227 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6228 (gnus-use-article-prefetch nil)
6229 (sum (current-buffer))
6232 (gnus-save-hidden-threads
6233 (gnus-summary-select-article)
6234 (set-buffer gnus-article-buffer)
6238 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
6240 (re-search-backward regexp nil t)
6241 (re-search-forward regexp nil t))
6242 ;; We found the regexp.
6247 (get-buffer-window (current-buffer))
6251 (setq point (point)))
6252 ;; We didn't find it, so we go to the next article.
6254 (if (not (if backward (gnus-summary-find-prev)
6255 (gnus-summary-find-next)))
6256 ;; No more articles.
6258 ;; Select the next article and adjust point.
6259 (gnus-summary-select-article)
6260 (set-buffer gnus-article-buffer)
6262 (goto-char (if backward (point-max) (point-min))))))
6263 (gnus-message 7 ""))
6264 ;; Return whether we found the regexp.
6265 (when (eq found 'found)
6267 (gnus-summary-show-thread)
6268 (gnus-summary-goto-subject gnus-current-article)
6269 (gnus-summary-position-point)
6272 (defun gnus-summary-find-matching (header regexp &optional backward unread
6274 "Return a list of all articles that match REGEXP on HEADER.
6275 The search stars on the current article and goes forwards unless
6276 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
6277 If UNREAD is non-nil, only unread articles will
6278 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
6279 in the comparisons."
6280 (let ((data (if (eq backward 'all) gnus-newsgroup-data
6281 (gnus-data-find-list
6282 (gnus-summary-article-number) (gnus-data-list backward))))
6283 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
6284 (case-fold-search (not not-case-fold))
6286 (unless (fboundp (intern (concat "mail-header-" header)))
6287 (error "%s is not a valid header" header))
6290 (and (or (not unread) ; We want all articles...
6291 (gnus-data-unread-p d)) ; Or just unreads.
6292 (vectorp (gnus-data-header d)) ; It's not a pseudo.
6293 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
6294 (push (gnus-data-number d) articles)) ; Success!
6295 (setq data (cdr data)))
6296 (nreverse articles)))
6298 (defun gnus-summary-execute-command (header regexp command &optional backward)
6299 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
6300 If HEADER is an empty string (or nil), the match is done on the entire
6301 article. If BACKWARD (the prefix) is non-nil, search backward instead."
6303 (list (let ((completion-ignore-case t))
6306 (mapcar (lambda (string) (list string))
6307 '("Number" "Subject" "From" "Lines" "Date"
6308 "Message-ID" "Xref" "References" "Body"))
6309 nil 'require-match))
6310 (read-string "Regexp: ")
6311 (read-key-sequence "Command: ")
6312 current-prefix-arg))
6313 (when (equal header "Body")
6315 (gnus-set-global-variables)
6316 ;; Hidden thread subtrees must be searched as well.
6317 (gnus-summary-show-all-threads)
6318 ;; We don't want to change current point nor window configuration.
6320 (save-window-excursion
6321 (gnus-message 6 "Executing %s..." (key-description command))
6322 ;; We'd like to execute COMMAND interactively so as to give arguments.
6323 (gnus-execute header regexp
6324 `(call-interactively ',(key-binding command))
6326 (gnus-message 6 "Executing %s...done" (key-description command)))))
6328 (defun gnus-summary-beginning-of-article ()
6329 "Scroll the article back to the beginning."
6331 (gnus-set-global-variables)
6332 (gnus-summary-select-article)
6333 (gnus-configure-windows 'article)
6334 (gnus-eval-in-buffer-window gnus-article-buffer
6336 (goto-char (point-min))
6337 (when gnus-break-pages
6338 (gnus-narrow-to-page))))
6340 (defun gnus-summary-end-of-article ()
6341 "Scroll to the end of the article."
6343 (gnus-set-global-variables)
6344 (gnus-summary-select-article)
6345 (gnus-configure-windows 'article)
6346 (gnus-eval-in-buffer-window gnus-article-buffer
6348 (goto-char (point-max))
6350 (when gnus-break-pages
6351 (gnus-narrow-to-page))))
6353 (defun gnus-summary-show-article (&optional arg)
6354 "Force re-fetching of the current article.
6355 If ARG (the prefix) is non-nil, show the raw article without any
6356 article massaging functions being run."
6358 (gnus-set-global-variables)
6360 ;; Select the article the normal way.
6361 (gnus-summary-select-article nil 'force)
6362 ;; Bind the article treatment functions to nil.
6363 (let ((gnus-have-all-headers t)
6364 gnus-article-display-hook
6365 gnus-article-prepare-hook
6368 (gnus-summary-select-article nil 'force)))
6369 (gnus-summary-goto-subject gnus-current-article)
6370 ; (gnus-configure-windows 'article)
6371 (gnus-summary-position-point))
6373 (defun gnus-summary-verbose-headers (&optional arg)
6374 "Toggle permanent full header display.
6375 If ARG is a positive number, turn header display on.
6376 If ARG is a negative number, turn header display off."
6378 (gnus-set-global-variables)
6379 (setq gnus-show-all-headers
6380 (cond ((or (not (numberp arg))
6382 (not gnus-show-all-headers))
6385 (gnus-summary-show-article))
6387 (defun gnus-summary-toggle-header (&optional arg)
6388 "Show the headers if they are hidden, or hide them if they are shown.
6389 If ARG is a positive number, show the entire header.
6390 If ARG is a negative number, hide the unwanted header lines."
6392 (gnus-set-global-variables)
6394 (set-buffer gnus-article-buffer)
6395 (let* ((buffer-read-only nil)
6396 (inhibit-point-motion-hooks t)
6397 (hidden (text-property-any
6398 (goto-char (point-min)) (search-forward "\n\n")
6401 (goto-char (point-min))
6402 (when (search-forward "\n\n" nil t)
6403 (delete-region (point-min) (1- (point))))
6404 (goto-char (point-min))
6406 (set-buffer gnus-original-article-buffer)
6407 (goto-char (point-min))
6408 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
6409 (insert-buffer-substring gnus-original-article-buffer 1 e)
6410 (let ((article-inhibit-hiding t))
6411 (run-hooks 'gnus-article-display-hook))
6412 (when (or (not hidden) (and (numberp arg) (< arg 0)))
6413 (gnus-article-hide-headers)))))
6415 (defun gnus-summary-show-all-headers ()
6416 "Make all header lines visible."
6418 (gnus-set-global-variables)
6419 (gnus-article-show-all-headers))
6421 (defun gnus-summary-toggle-mime (&optional arg)
6422 "Toggle MIME processing.
6423 If ARG is a positive number, turn MIME processing on."
6425 (gnus-set-global-variables)
6426 (setq gnus-show-mime
6427 (if (null arg) (not gnus-show-mime)
6428 (> (prefix-numeric-value arg) 0)))
6429 (gnus-summary-select-article t 'force))
6431 (defun gnus-summary-caesar-message (&optional arg)
6432 "Caesar rotate the current article by 13.
6433 The numerical prefix specifies how manu places to rotate each letter
6436 (gnus-set-global-variables)
6437 (gnus-summary-select-article)
6438 (let ((mail-header-separator ""))
6439 (gnus-eval-in-buffer-window gnus-article-buffer
6442 (let ((start (window-start))
6444 (message-caesar-buffer-body arg)
6445 (set-window-start (get-buffer-window (current-buffer)) start))))))
6447 (defun gnus-summary-stop-page-breaking ()
6448 "Stop page breaking in the current article."
6450 (gnus-set-global-variables)
6451 (gnus-summary-select-article)
6452 (gnus-eval-in-buffer-window gnus-article-buffer
6454 (when (gnus-visual-p 'page-marker)
6455 (let ((buffer-read-only nil))
6456 (gnus-remove-text-with-property 'gnus-prev)
6457 (gnus-remove-text-with-property 'gnus-next)))))
6459 (defun gnus-summary-move-article (&optional n to-newsgroup
6460 select-method action)
6461 "Move the current article to a different newsgroup.
6462 If N is a positive number, move the N next articles.
6463 If N is a negative number, move the N previous articles.
6464 If N is nil and any articles have been marked with the process mark,
6465 move those articles instead.
6466 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6467 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6468 re-spool using this method.
6470 For this function to work, both the current newsgroup and the
6471 newsgroup that you want to move to have to support the `request-move'
6472 and `request-accept' functions."
6475 (setq action 'move))
6476 (gnus-set-global-variables)
6477 ;; Check whether the source group supports the required functions.
6478 (cond ((and (eq action 'move)
6479 (not (gnus-check-backend-function
6480 'request-move-article gnus-newsgroup-name)))
6481 (error "The current group does not support article moving"))
6482 ((and (eq action 'crosspost)
6483 (not (gnus-check-backend-function
6484 'request-replace-article gnus-newsgroup-name)))
6485 (error "The current group does not support article editing")))
6486 (let ((articles (gnus-summary-work-articles n))
6487 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
6488 (names '((move "Move" "Moving")
6489 (copy "Copy" "Copying")
6490 (crosspost "Crosspost" "Crossposting")))
6491 (copy-buf (save-excursion
6492 (nnheader-set-temp-buffer " *copy article*")))
6493 art-group to-method new-xref article to-groups)
6494 (unless (assq action names)
6495 (error "Unknown action %s" action))
6496 ;; Read the newsgroup name.
6497 (when (and (not to-newsgroup)
6498 (not select-method))
6500 (gnus-read-move-group-name
6501 (cadr (assq action names))
6502 (symbol-value (intern (format "gnus-current-%s-group" action)))
6504 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
6505 (setq to-method (or select-method
6506 (gnus-group-name-to-method to-newsgroup)))
6507 ;; Check the method we are to move this article to...
6508 (unless (gnus-check-backend-function
6509 'request-accept-article (car to-method))
6510 (error "%s does not support article copying" (car to-method)))
6511 (unless (gnus-check-server to-method)
6512 (error "Can't open server %s" (car to-method)))
6513 (gnus-message 6 "%s to %s: %s..."
6514 (caddr (assq action names))
6515 (or (car select-method) to-newsgroup) articles)
6517 (setq article (pop articles))
6521 ;; Move the article.
6523 (gnus-request-move-article
6524 article ; Article to move
6525 gnus-newsgroup-name ; From newsgroup
6526 (nth 1 (gnus-find-method-for-group
6527 gnus-newsgroup-name)) ; Server
6528 (list 'gnus-request-accept-article
6529 to-newsgroup (list 'quote select-method)
6530 (not articles)) ; Accept form
6531 (not articles))) ; Only save nov last time
6532 ;; Copy the article.
6535 (set-buffer copy-buf)
6536 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6537 (gnus-request-accept-article
6538 to-newsgroup select-method (not articles))))
6539 ;; Crosspost the article.
6540 ((eq action 'crosspost)
6541 (let ((xref (message-tokenize-header
6542 (mail-header-xref (gnus-summary-article-header article))
6544 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
6547 (setq xref (list (system-name))))
6550 (mapconcat 'identity
6551 (delete "Xref:" (delete new-xref xref))
6555 (set-buffer copy-buf)
6556 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6557 (nnheader-replace-header "xref" new-xref)
6558 (gnus-request-accept-article
6559 to-newsgroup select-method (not articles)))))))
6561 (gnus-message 1 "Couldn't %s article %s"
6562 (cadr (assq action names)) article)
6565 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
6567 (gnus-group-prefixed-name
6570 (gnus-find-method-for-group to-newsgroup)))
6571 gnus-newsrc-hashtb)))
6572 (info (nth 2 entry))
6573 (to-group (gnus-info-group info)))
6574 ;; Update the group that has been moved to.
6576 (memq action '(move copy)))
6577 (unless (member to-group to-groups)
6578 (push to-group to-groups))
6580 (unless (memq article gnus-newsgroup-unreads)
6582 info (gnus-add-to-range (gnus-info-read info)
6583 (list (cdr art-group)))))
6585 ;; Copy any marks over to the new group.
6586 (let ((marks gnus-article-mark-lists)
6587 (to-article (cdr art-group)))
6589 ;; See whether the article is to be put in the cache.
6590 (when gnus-use-cache
6591 (gnus-cache-possibly-enter-article
6593 (let ((header (copy-sequence
6594 (gnus-summary-article-header article))))
6595 (mail-header-set-number header to-article)
6597 (memq article gnus-newsgroup-marked)
6598 (memq article gnus-newsgroup-dormant)
6599 (memq article gnus-newsgroup-unreads)))
6602 (when (memq article (symbol-value
6603 (intern (format "gnus-newsgroup-%s"
6605 ;; If the other group is the same as this group,
6606 ;; then we have to add the mark to the list.
6607 (when (equal to-group gnus-newsgroup-name)
6608 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
6611 (intern (format "gnus-newsgroup-%s"
6613 ;; Copy mark to other group.
6614 (gnus-add-marked-articles
6615 to-group (cdar marks) (list to-article) info))
6616 (setq marks (cdr marks)))))
6618 ;; Update the Xref header in this article to point to
6619 ;; the new crossposted article we have just created.
6620 (when (eq action 'crosspost)
6622 (set-buffer copy-buf)
6623 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6624 (nnheader-replace-header
6625 "xref" (concat new-xref " " (car art-group)
6626 ":" (cdr art-group)))
6627 (gnus-request-replace-article
6628 article gnus-newsgroup-name (current-buffer)))))
6630 (gnus-summary-goto-subject article)
6631 (when (eq action 'move)
6632 (gnus-summary-mark-article article gnus-canceled-mark)))
6633 (gnus-summary-remove-process-mark article))
6634 ;; Re-activate all groups that have been moved to.
6636 (gnus-activate-group (pop to-groups)))
6638 (gnus-kill-buffer copy-buf)
6639 (gnus-summary-position-point)
6640 (gnus-set-mode-line 'summary)))
6642 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
6643 "Move the current article to a different newsgroup.
6644 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6645 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6646 re-spool using this method."
6648 (gnus-summary-move-article n nil select-method 'copy))
6650 (defun gnus-summary-crosspost-article (&optional n)
6651 "Crosspost the current article to some other group."
6653 (gnus-summary-move-article n nil nil 'crosspost))
6655 (defcustom gnus-summary-respool-default-method nil
6656 "Default method for respooling an article.
6657 If nil, use to the current newsgroup method."
6658 :type 'gnus-select-method-name
6659 :group 'gnus-summary)
6661 (defun gnus-summary-respool-article (&optional n method)
6662 "Respool the current article.
6663 The article will be squeezed through the mail spooling process again,
6664 which means that it will be put in some mail newsgroup or other
6665 depending on `nnmail-split-methods'.
6666 If N is a positive number, respool the N next articles.
6667 If N is a negative number, respool the N previous articles.
6668 If N is nil and any articles have been marked with the process mark,
6669 respool those articles instead.
6671 Respooling can be done both from mail groups and \"real\" newsgroups.
6672 In the former case, the articles in question will be moved from the
6673 current group into whatever groups they are destined to. In the
6674 latter case, they will be copied into the relevant groups."
6676 (list current-prefix-arg
6677 (let* ((methods (gnus-methods-using 'respool))
6679 (symbol-name (or gnus-summary-respool-default-method
6680 (car (gnus-find-method-for-group
6681 gnus-newsgroup-name)))))
6683 (gnus-completing-read
6684 methname "What backend do you want to use when respooling?"
6685 methods nil t nil 'gnus-mail-method-history))
6688 ((zerop (length (setq ms (gnus-servers-using-backend
6690 (list (intern method) ""))
6694 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
6695 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
6697 (gnus-set-global-variables)
6699 (error "No method given for respooling"))
6700 (if (assoc (symbol-name
6701 (car (gnus-find-method-for-group gnus-newsgroup-name)))
6702 (gnus-methods-using 'respool))
6703 (gnus-summary-move-article n nil method)
6704 (gnus-summary-copy-article n nil method)))
6706 (defun gnus-summary-import-article (file)
6707 "Import a random file into a mail newsgroup."
6708 (interactive "fImport file: ")
6709 (gnus-set-global-variables)
6710 (let ((group gnus-newsgroup-name)
6711 (now (current-time))
6713 (unless (gnus-check-backend-function 'request-accept-article group)
6714 (error "%s does not support article importing" group))
6715 (or (file-readable-p file)
6716 (not (file-regular-p file))
6717 (error "Can't read %s" file))
6719 (set-buffer (get-buffer-create " *import file*"))
6720 (buffer-disable-undo (current-buffer))
6722 (insert-file-contents file)
6723 (goto-char (point-min))
6724 (unless (nnheader-article-p)
6725 ;; This doesn't look like an article, so we fudge some headers.
6726 (setq atts (file-attributes file)
6727 lines (count-lines (point-min) (point-max)))
6728 (insert "From: " (read-string "From: ") "\n"
6729 "Subject: " (read-string "Subject: ") "\n"
6730 "Date: " (timezone-make-date-arpa-standard
6731 (current-time-string (nth 5 atts))
6732 (current-time-zone now)
6733 (current-time-zone now))
6735 "Message-ID: " (message-make-message-id) "\n"
6736 "Lines: " (int-to-string lines) "\n"
6737 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
6738 (gnus-request-accept-article group nil t)
6739 (kill-buffer (current-buffer)))))
6741 (defun gnus-summary-article-posted-p ()
6742 "Say whether the current (mail) article is available from `gnus-select-method' as well.
6743 This will be the case if the article has both been mailed and posted."
6745 (let ((id (mail-header-references (gnus-summary-article-header)))
6746 (gnus-override-method
6747 (or gnus-refer-article-method gnus-select-method)))
6748 (if (gnus-request-head id "")
6749 (gnus-message 2 "The current message was found on %s"
6750 gnus-override-method)
6751 (gnus-message 2 "The current message couldn't be found on %s"
6752 gnus-override-method)
6755 (defun gnus-summary-expire-articles (&optional now)
6756 "Expire all articles that are marked as expirable in the current group."
6758 (gnus-set-global-variables)
6759 (when (gnus-check-backend-function
6760 'request-expire-articles gnus-newsgroup-name)
6761 ;; This backend supports expiry.
6762 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
6763 (expirable (if total
6765 ;; We need to update the info for
6766 ;; this group for `gnus-list-of-read-articles'
6767 ;; to give us the right answer.
6768 (gnus-summary-update-info)
6769 (gnus-list-of-read-articles gnus-newsgroup-name))
6770 (setq gnus-newsgroup-expirable
6771 (sort gnus-newsgroup-expirable '<))))
6772 (expiry-wait (if now 'immediate
6773 (gnus-group-find-parameter
6774 gnus-newsgroup-name 'expiry-wait)))
6777 ;; There are expirable articles in this group, so we run them
6778 ;; through the expiry process.
6779 (gnus-message 6 "Expiring articles...")
6780 ;; The list of articles that weren't expired is returned.
6782 (let ((nnmail-expiry-wait-function nil)
6783 (nnmail-expiry-wait expiry-wait))
6784 (setq es (gnus-request-expire-articles
6785 expirable gnus-newsgroup-name)))
6786 (setq es (gnus-request-expire-articles
6787 expirable gnus-newsgroup-name)))
6789 (setq gnus-newsgroup-expirable es))
6790 ;; We go through the old list of expirable, and mark all
6791 ;; really expired articles as nonexistent.
6792 (unless (eq es expirable) ;If nothing was expired, we don't mark.
6793 (let ((gnus-use-cache nil))
6795 (unless (memq (car expirable) es)
6796 (when (gnus-data-find (car expirable))
6797 (gnus-summary-mark-article
6798 (car expirable) gnus-canceled-mark)))
6799 (setq expirable (cdr expirable)))))
6800 (gnus-message 6 "Expiring articles...done")))))
6802 (defun gnus-summary-expire-articles-now ()
6803 "Expunge all expirable articles in the current group.
6804 This means that *all* articles that are marked as expirable will be
6805 deleted forever, right now."
6807 (gnus-set-global-variables)
6808 (or gnus-expert-user
6810 "Are you really, really, really sure you want to delete all these messages? ")
6812 (gnus-summary-expire-articles t))
6814 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6815 (defun gnus-summary-delete-article (&optional n)
6816 "Delete the N next (mail) articles.
6817 This command actually deletes articles. This is not a marking
6818 command. The article will disappear forever from your life, never to
6820 If N is negative, delete backwards.
6821 If N is nil and articles have been marked with the process mark,
6822 delete these instead."
6824 (gnus-set-global-variables)
6825 (unless (gnus-check-backend-function 'request-expire-articles
6826 gnus-newsgroup-name)
6827 (error "The current newsgroup does not support article deletion."))
6828 ;; Compute the list of articles to delete.
6829 (let ((articles (gnus-summary-work-articles n))
6831 (if (and gnus-novice-user
6833 (format "Do you really want to delete %s forever? "
6834 (if (> (length articles) 1)
6835 (format "these %s articles" (length articles))
6838 ;; Delete the articles.
6839 (setq not-deleted (gnus-request-expire-articles
6840 articles gnus-newsgroup-name 'force))
6842 (gnus-summary-remove-process-mark (car articles))
6843 ;; The backend might not have been able to delete the article
6845 (unless (memq (car articles) not-deleted)
6846 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
6847 (setq articles (cdr articles))))
6848 (gnus-summary-position-point)
6849 (gnus-set-mode-line 'summary)
6852 (defun gnus-summary-edit-article (&optional force)
6853 "Edit the current article.
6854 This will have permanent effect only in mail groups.
6855 If FORCE is non-nil, allow editing of articles even in read-only
6859 (set-buffer gnus-summary-buffer)
6860 (gnus-set-global-variables)
6861 (when (and (not force)
6862 (gnus-group-read-only-p))
6863 (error "The current newsgroup does not support article editing."))
6864 ;; Select article if needed.
6865 (unless (eq (gnus-summary-article-number)
6866 gnus-current-article)
6867 (gnus-summary-select-article t))
6868 (gnus-article-edit-article
6870 (gnus-summary-edit-article-done
6871 ,(or (mail-header-references gnus-current-headers) "")
6872 ,(gnus-group-read-only-p) ,gnus-summary-buffer)))))
6874 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
6876 (defun gnus-summary-edit-article-done (&optional references read-only buffer)
6877 "Make edits to the current article permanent."
6879 ;; Replace the article.
6880 (if (and (not read-only)
6881 (not (gnus-request-replace-article
6882 (cdr gnus-article-current) (car gnus-article-current)
6884 (error "Couldn't replace article.")
6885 ;; Update the summary buffer.
6887 (equal (message-tokenize-header references " ")
6888 (message-tokenize-header
6889 (or (message-fetch-field "references") "") " ")))
6890 ;; We only have to update this line.
6893 (message-narrow-to-head)
6894 (let ((header (nnheader-parse-head t)))
6896 (mail-header-set-number header (cdr gnus-article-current))
6897 (gnus-summary-update-article-line
6898 (cdr gnus-article-current) header))))
6900 (set-buffer (or buffer gnus-summary-buffer))
6901 (gnus-summary-update-article (cdr gnus-article-current)))
6902 ;; Prettify the article buffer again.
6904 (set-buffer gnus-article-buffer)
6905 (run-hooks 'gnus-article-display-hook))
6906 ;; Prettify the summary buffer line.
6907 (when (gnus-visual-p 'summary-highlight 'highlight)
6908 (run-hooks 'gnus-visual-mark-article-hook))))
6910 (defun gnus-summary-edit-wash (key)
6911 "Perform editing command in the article buffer."
6915 (message "%s" (concat (this-command-keys) "- "))
6918 (gnus-summary-edit-article)
6919 (execute-kbd-macro (concat (this-command-keys) key))
6920 (gnus-article-edit-done))
6924 (defun gnus-summary-respool-query ()
6925 "Query where the respool algorithm would put this article."
6927 (gnus-set-global-variables)
6928 (gnus-summary-select-article)
6930 (set-buffer gnus-article-buffer)
6932 (goto-char (point-min))
6933 (search-forward "\n\n")
6934 (narrow-to-region (point-min) (point))
6935 (message "This message would go to %s"
6936 (mapconcat 'car (nnmail-article-group 'identity) ", ")))))
6938 ;; Summary marking commands.
6940 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
6941 "Mark articles which has the same subject as read, and then select the next.
6942 If UNMARK is positive, remove any kind of mark.
6943 If UNMARK is negative, tick articles."
6945 (gnus-set-global-variables)
6947 (setq unmark (prefix-numeric-value unmark)))
6949 (gnus-summary-mark-same-subject
6950 (gnus-summary-article-subject) unmark)))
6951 ;; Select next unread article. If auto-select-same mode, should
6952 ;; select the first unread article.
6953 (gnus-summary-next-article t (and gnus-auto-select-same
6954 (gnus-summary-article-subject)))
6955 (gnus-message 7 "%d article%s marked as %s"
6956 count (if (= count 1) " is" "s are")
6957 (if unmark "unread" "read"))))
6959 (defun gnus-summary-kill-same-subject (&optional unmark)
6960 "Mark articles which has the same subject as read.
6961 If UNMARK is positive, remove any kind of mark.
6962 If UNMARK is negative, tick articles."
6964 (gnus-set-global-variables)
6966 (setq unmark (prefix-numeric-value unmark)))
6968 (gnus-summary-mark-same-subject
6969 (gnus-summary-article-subject) unmark)))
6970 ;; If marked as read, go to next unread subject.
6972 ;; Go to next unread subject.
6973 (gnus-summary-next-subject 1 t))
6974 (gnus-message 7 "%d articles are marked as %s"
6975 count (if unmark "unread" "read"))))
6977 (defun gnus-summary-mark-same-subject (subject &optional unmark)
6978 "Mark articles with same SUBJECT as read, and return marked number.
6979 If optional argument UNMARK is positive, remove any kinds of marks.
6980 If optional argument UNMARK is negative, mark articles as unread instead."
6984 ((null unmark) ; Mark as read.
6987 (gnus-summary-mark-article-as-read gnus-killed-mark)
6988 (gnus-summary-show-thread) t)
6989 (gnus-summary-find-subject subject))
6990 (setq count (1+ count))))
6991 ((> unmark 0) ; Tick.
6994 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
6995 (gnus-summary-show-thread) t)
6996 (gnus-summary-find-subject subject))
6997 (setq count (1+ count))))
6998 (t ; Mark as unread.
7001 (gnus-summary-mark-article-as-unread gnus-unread-mark)
7002 (gnus-summary-show-thread) t)
7003 (gnus-summary-find-subject subject))
7004 (setq count (1+ count)))))
7005 (gnus-set-mode-line 'summary)
7006 ;; Return the number of marked articles.
7009 (defun gnus-summary-mark-as-processable (n &optional unmark)
7010 "Set the process mark on the next N articles.
7011 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7012 the process mark instead. The difference between N and the actual
7013 number of articles marked is returned."
7015 (gnus-set-global-variables)
7016 (let ((backward (< n 0))
7021 (gnus-summary-remove-process-mark
7022 (gnus-summary-article-number))
7023 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7024 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7027 (gnus-message 7 "No more articles"))
7028 (gnus-summary-recenter)
7029 (gnus-summary-position-point)
7032 (defun gnus-summary-unmark-as-processable (n)
7033 "Remove the process mark from the next N articles.
7034 If N is negative, mark backward instead. The difference between N and
7035 the actual number of articles marked is returned."
7037 (gnus-set-global-variables)
7038 (gnus-summary-mark-as-processable n t))
7040 (defun gnus-summary-unmark-all-processable ()
7041 "Remove the process mark from all articles."
7043 (gnus-set-global-variables)
7045 (while gnus-newsgroup-processable
7046 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7047 (gnus-summary-position-point))
7049 (defun gnus-summary-mark-as-expirable (n)
7050 "Mark N articles forward as expirable.
7051 If N is negative, mark backward instead. The difference between N and
7052 the actual number of articles marked is returned."
7054 (gnus-set-global-variables)
7055 (gnus-summary-mark-forward n gnus-expirable-mark))
7057 (defun gnus-summary-mark-article-as-replied (article)
7058 "Mark ARTICLE replied and update the summary line."
7059 (push article gnus-newsgroup-replied)
7060 (let ((buffer-read-only nil))
7061 (when (gnus-summary-goto-subject article)
7062 (gnus-summary-update-secondary-mark article))))
7064 (defun gnus-summary-set-bookmark (article)
7065 "Set a bookmark in current article."
7066 (interactive (list (gnus-summary-article-number)))
7067 (gnus-set-global-variables)
7068 (when (or (not (get-buffer gnus-article-buffer))
7069 (not gnus-current-article)
7070 (not gnus-article-current)
7071 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7072 (error "No current article selected"))
7073 ;; Remove old bookmark, if one exists.
7074 (let ((old (assq article gnus-newsgroup-bookmarks)))
7076 (setq gnus-newsgroup-bookmarks
7077 (delq old gnus-newsgroup-bookmarks))))
7078 ;; Set the new bookmark, which is on the form
7079 ;; (article-number . line-number-in-body).
7083 (set-buffer gnus-article-buffer)
7087 (goto-char (point-min))
7088 (search-forward "\n\n" nil t)
7091 gnus-newsgroup-bookmarks)
7092 (gnus-message 6 "A bookmark has been added to the current article."))
7094 (defun gnus-summary-remove-bookmark (article)
7095 "Remove the bookmark from the current article."
7096 (interactive (list (gnus-summary-article-number)))
7097 (gnus-set-global-variables)
7098 ;; Remove old bookmark, if one exists.
7099 (let ((old (assq article gnus-newsgroup-bookmarks)))
7102 (setq gnus-newsgroup-bookmarks
7103 (delq old gnus-newsgroup-bookmarks))
7104 (gnus-message 6 "Removed bookmark."))
7105 (gnus-message 6 "No bookmark in current article."))))
7107 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7108 (defun gnus-summary-mark-as-dormant (n)
7109 "Mark N articles forward as dormant.
7110 If N is negative, mark backward instead. The difference between N and
7111 the actual number of articles marked is returned."
7113 (gnus-set-global-variables)
7114 (gnus-summary-mark-forward n gnus-dormant-mark))
7116 (defun gnus-summary-set-process-mark (article)
7117 "Set the process mark on ARTICLE and update the summary line."
7118 (setq gnus-newsgroup-processable
7120 (delq article gnus-newsgroup-processable)))
7121 (when (gnus-summary-goto-subject article)
7122 (gnus-summary-show-thread)
7123 (gnus-summary-update-secondary-mark article)))
7125 (defun gnus-summary-remove-process-mark (article)
7126 "Remove the process mark from ARTICLE and update the summary line."
7127 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7128 (when (gnus-summary-goto-subject article)
7129 (gnus-summary-show-thread)
7130 (gnus-summary-update-secondary-mark article)))
7132 (defun gnus-summary-set-saved-mark (article)
7133 "Set the process mark on ARTICLE and update the summary line."
7134 (push article gnus-newsgroup-saved)
7135 (when (gnus-summary-goto-subject article)
7136 (gnus-summary-update-secondary-mark article)))
7138 (defun gnus-summary-mark-forward (n &optional mark no-expire)
7139 "Mark N articles as read forwards.
7140 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
7141 The difference between N and the actual number of articles marked is
7144 (gnus-set-global-variables)
7145 (let ((backward (< n 0))
7146 (gnus-summary-goto-unread
7147 (and gnus-summary-goto-unread
7148 (not (eq gnus-summary-goto-unread 'never))
7149 (not (memq mark (list gnus-unread-mark
7150 gnus-ticked-mark gnus-dormant-mark)))))
7152 (mark (or mark gnus-del-mark)))
7154 (gnus-summary-mark-article nil mark no-expire)
7155 (zerop (gnus-summary-next-subject
7157 (and gnus-summary-goto-unread
7158 (not (eq gnus-summary-goto-unread 'never)))
7162 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
7163 (gnus-summary-recenter)
7164 (gnus-summary-position-point)
7165 (gnus-set-mode-line 'summary)
7168 (defun gnus-summary-mark-article-as-read (mark)
7169 "Mark the current article quickly as read with MARK."
7170 (let ((article (gnus-summary-article-number)))
7171 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7172 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7173 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7174 (push (cons article mark) gnus-newsgroup-reads)
7175 ;; Possibly remove from cache, if that is used.
7176 (when gnus-use-cache
7177 (gnus-cache-enter-remove-article article))
7178 ;; Allow the backend to change the mark.
7179 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7180 ;; Check for auto-expiry.
7181 (when (and gnus-newsgroup-auto-expire
7182 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7183 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7184 (= mark gnus-ancient-mark)
7185 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7186 (= mark gnus-duplicate-mark)))
7187 (setq mark gnus-expirable-mark)
7188 (push article gnus-newsgroup-expirable))
7189 ;; Set the mark in the buffer.
7190 (gnus-summary-update-mark mark 'unread)
7193 (defun gnus-summary-mark-article-as-unread (mark)
7194 "Mark the current article quickly as unread with MARK."
7195 (let ((article (gnus-summary-article-number)))
7197 (gnus-error 1 "Unmarkable article")
7198 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7199 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7200 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
7201 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
7202 (cond ((= mark gnus-ticked-mark)
7203 (push article gnus-newsgroup-marked))
7204 ((= mark gnus-dormant-mark)
7205 (push article gnus-newsgroup-dormant))
7207 (push article gnus-newsgroup-unreads)))
7208 (setq gnus-newsgroup-reads
7209 (delq (assq article gnus-newsgroup-reads)
7210 gnus-newsgroup-reads))
7212 ;; See whether the article is to be put in the cache.
7214 (vectorp (gnus-summary-article-header article))
7216 (gnus-cache-possibly-enter-article
7217 gnus-newsgroup-name article
7218 (gnus-summary-article-header article)
7219 (= mark gnus-ticked-mark)
7220 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7223 (gnus-summary-update-mark mark 'unread))
7226 (defun gnus-summary-mark-article (&optional article mark no-expire)
7227 "Mark ARTICLE with MARK. MARK can be any character.
7228 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
7229 `??' (dormant) and `?E' (expirable).
7230 If MARK is nil, then the default character `?D' is used.
7231 If ARTICLE is nil, then the article on the current line will be
7233 ;; The mark might be a string.
7234 (when (stringp mark)
7235 (setq mark (aref mark 0)))
7236 ;; If no mark is given, then we check auto-expiring.
7237 (and (not no-expire)
7238 gnus-newsgroup-auto-expire
7241 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7242 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7243 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7244 (= mark gnus-duplicate-mark))))
7245 (setq mark gnus-expirable-mark))
7246 (let* ((mark (or mark gnus-del-mark))
7247 (article (or article (gnus-summary-article-number))))
7249 (error "No article on current line"))
7250 (if (or (= mark gnus-unread-mark)
7251 (= mark gnus-ticked-mark)
7252 (= mark gnus-dormant-mark))
7253 (gnus-mark-article-as-unread article mark)
7254 (gnus-mark-article-as-read article mark))
7256 ;; See whether the article is to be put in the cache.
7258 (not (= mark gnus-canceled-mark))
7259 (vectorp (gnus-summary-article-header article))
7261 (gnus-cache-possibly-enter-article
7262 gnus-newsgroup-name article
7263 (gnus-summary-article-header article)
7264 (= mark gnus-ticked-mark)
7265 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7267 (when (gnus-summary-goto-subject article nil t)
7268 (let ((buffer-read-only nil))
7269 (gnus-summary-show-thread)
7271 (gnus-summary-update-mark mark 'unread)
7274 (defun gnus-summary-update-secondary-mark (article)
7275 "Update the secondary (read, process, cache) mark."
7276 (gnus-summary-update-mark
7277 (cond ((memq article gnus-newsgroup-processable)
7279 ((memq article gnus-newsgroup-cached)
7281 ((memq article gnus-newsgroup-replied)
7283 ((memq article gnus-newsgroup-saved)
7285 (t gnus-unread-mark))
7287 (when (gnus-visual-p 'summary-highlight 'highlight)
7288 (run-hooks 'gnus-summary-update-hook))
7291 (defun gnus-summary-update-mark (mark type)
7292 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
7293 (buffer-read-only nil))
7294 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
7295 (when (looking-at "\r")
7298 (<= (+ forward (point)) (point-max)))
7299 ;; Go to the right position on the line.
7300 (goto-char (+ forward (point)))
7301 ;; Replace the old mark with the new mark.
7302 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
7303 ;; Optionally update the marks by some user rule.
7304 (when (eq type 'unread)
7306 (gnus-data-find (gnus-summary-article-number)) mark)
7307 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
7309 (defun gnus-mark-article-as-read (article &optional mark)
7310 "Enter ARTICLE in the pertinent lists and remove it from others."
7311 ;; Make the article expirable.
7312 (let ((mark (or mark gnus-del-mark)))
7313 (if (= mark gnus-expirable-mark)
7314 (push article gnus-newsgroup-expirable)
7315 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
7316 ;; Remove from unread and marked lists.
7317 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7318 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7319 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7320 (push (cons article mark) gnus-newsgroup-reads)
7321 ;; Possibly remove from cache, if that is used.
7322 (when gnus-use-cache
7323 (gnus-cache-enter-remove-article article))))
7325 (defun gnus-mark-article-as-unread (article &optional mark)
7326 "Enter ARTICLE in the pertinent lists and remove it from others."
7327 (let ((mark (or mark gnus-ticked-mark)))
7328 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
7329 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
7330 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
7331 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7333 ;; Unsuppress duplicates?
7334 (when gnus-suppress-duplicates
7335 (gnus-dup-unsuppress-article article))
7337 (cond ((= mark gnus-ticked-mark)
7338 (push article gnus-newsgroup-marked))
7339 ((= mark gnus-dormant-mark)
7340 (push article gnus-newsgroup-dormant))
7342 (push article gnus-newsgroup-unreads)))
7343 (setq gnus-newsgroup-reads
7344 (delq (assq article gnus-newsgroup-reads)
7345 gnus-newsgroup-reads))))
7347 (defalias 'gnus-summary-mark-as-unread-forward
7348 'gnus-summary-tick-article-forward)
7349 (make-obsolete 'gnus-summary-mark-as-unread-forward
7350 'gnus-summary-tick-article-forward)
7351 (defun gnus-summary-tick-article-forward (n)
7352 "Tick N articles forwards.
7353 If N is negative, tick backwards instead.
7354 The difference between N and the number of articles ticked is returned."
7356 (gnus-summary-mark-forward n gnus-ticked-mark))
7358 (defalias 'gnus-summary-mark-as-unread-backward
7359 'gnus-summary-tick-article-backward)
7360 (make-obsolete 'gnus-summary-mark-as-unread-backward
7361 'gnus-summary-tick-article-backward)
7362 (defun gnus-summary-tick-article-backward (n)
7363 "Tick N articles backwards.
7364 The difference between N and the number of articles ticked is returned."
7366 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
7368 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7369 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7370 (defun gnus-summary-tick-article (&optional article clear-mark)
7371 "Mark current article as unread.
7372 Optional 1st argument ARTICLE specifies article number to be marked as unread.
7373 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
7375 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
7378 (defun gnus-summary-mark-as-read-forward (n)
7379 "Mark N articles as read forwards.
7380 If N is negative, mark backwards instead.
7381 The difference between N and the actual number of articles marked is
7384 (gnus-summary-mark-forward n gnus-del-mark t))
7386 (defun gnus-summary-mark-as-read-backward (n)
7387 "Mark the N articles as read backwards.
7388 The difference between N and the actual number of articles marked is
7391 (gnus-summary-mark-forward (- n) gnus-del-mark t))
7393 (defun gnus-summary-mark-as-read (&optional article mark)
7394 "Mark current article as read.
7395 ARTICLE specifies the article to be marked as read.
7396 MARK specifies a string to be inserted at the beginning of the line."
7397 (gnus-summary-mark-article article mark))
7399 (defun gnus-summary-clear-mark-forward (n)
7400 "Clear marks from N articles forward.
7401 If N is negative, clear backward instead.
7402 The difference between N and the number of marks cleared is returned."
7404 (gnus-summary-mark-forward n gnus-unread-mark))
7406 (defun gnus-summary-clear-mark-backward (n)
7407 "Clear marks from N articles backward.
7408 The difference between N and the number of marks cleared is returned."
7410 (gnus-summary-mark-forward (- n) gnus-unread-mark))
7412 (defun gnus-summary-mark-unread-as-read ()
7413 "Intended to be used by `gnus-summary-mark-article-hook'."
7414 (when (memq gnus-current-article gnus-newsgroup-unreads)
7415 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
7417 (defun gnus-summary-mark-read-and-unread-as-read ()
7418 "Intended to be used by `gnus-summary-mark-article-hook'."
7419 (let ((mark (gnus-summary-article-mark)))
7420 (when (or (gnus-unread-mark-p mark)
7421 (gnus-read-mark-p mark))
7422 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
7424 (defun gnus-summary-mark-region-as-read (point mark all)
7425 "Mark all unread articles between point and mark as read.
7426 If given a prefix, mark all articles between point and mark as read,
7427 even ticked and dormant ones."
7428 (interactive "r\nP")
7437 (memq (setq article (gnus-summary-article-number))
7438 gnus-newsgroup-unreads))
7439 (gnus-summary-mark-article article gnus-del-mark))
7441 (gnus-summary-find-next))))))
7443 (defun gnus-summary-mark-below (score mark)
7444 "Mark articles with score less than SCORE with MARK."
7445 (interactive "P\ncMark: ")
7446 (gnus-set-global-variables)
7447 (setq score (if score
7448 (prefix-numeric-value score)
7449 (or gnus-summary-default-score 0)))
7451 (set-buffer gnus-summary-buffer)
7452 (goto-char (point-min))
7455 (and (< (gnus-summary-article-score) score)
7456 (gnus-summary-mark-article nil mark))
7457 (gnus-summary-find-next)))))
7459 (defun gnus-summary-kill-below (&optional score)
7460 "Mark articles with score below SCORE as read."
7462 (gnus-set-global-variables)
7463 (gnus-summary-mark-below score gnus-killed-mark))
7465 (defun gnus-summary-clear-above (&optional score)
7466 "Clear all marks from articles with score above SCORE."
7468 (gnus-set-global-variables)
7469 (gnus-summary-mark-above score gnus-unread-mark))
7471 (defun gnus-summary-tick-above (&optional score)
7472 "Tick all articles with score above SCORE."
7474 (gnus-set-global-variables)
7475 (gnus-summary-mark-above score gnus-ticked-mark))
7477 (defun gnus-summary-mark-above (score mark)
7478 "Mark articles with score over SCORE with MARK."
7479 (interactive "P\ncMark: ")
7480 (gnus-set-global-variables)
7481 (setq score (if score
7482 (prefix-numeric-value score)
7483 (or gnus-summary-default-score 0)))
7485 (set-buffer gnus-summary-buffer)
7486 (goto-char (point-min))
7488 (when (> (gnus-summary-article-score) score)
7489 (gnus-summary-mark-article nil mark))
7491 (gnus-summary-find-next)))))
7493 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7494 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
7495 (defun gnus-summary-limit-include-expunged (&optional no-error)
7496 "Display all the hidden articles that were expunged for low scores."
7498 (gnus-set-global-variables)
7499 (let ((buffer-read-only nil))
7500 (let ((scored gnus-newsgroup-scored)
7503 (unless (gnus-summary-goto-subject (caar scored))
7504 (and (setq h (gnus-summary-article-header (caar scored)))
7505 (< (cdar scored) gnus-summary-expunge-below)
7507 (setq scored (cdr scored)))
7509 (when (not no-error)
7510 (error "No expunged articles hidden."))
7511 (goto-char (point-min))
7512 (gnus-summary-prepare-unthreaded (nreverse headers))
7513 (goto-char (point-min))
7514 (gnus-summary-position-point)
7517 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
7518 "Mark all articles not marked as unread in this newsgroup as read.
7519 If prefix argument ALL is non-nil, all articles are marked as read.
7520 If QUIETLY is non-nil, no questions will be asked.
7521 If TO-HERE is non-nil, it should be a point in the buffer. All
7522 articles before this point will be marked as read.
7523 The number of articles marked as read is returned."
7525 (gnus-set-global-variables)
7529 (not gnus-interactive-catchup) ;Without confirmation?
7533 "Mark absolutely all articles as read? "
7534 "Mark all unread articles as read? ")))
7536 (not gnus-newsgroup-adaptive)
7537 (not gnus-newsgroup-auto-expire)
7538 (not gnus-suppress-duplicates))
7541 (setq gnus-newsgroup-marked nil
7542 gnus-newsgroup-dormant nil))
7543 (setq gnus-newsgroup-unreads nil))
7544 ;; We actually mark all articles as canceled, which we
7545 ;; have to do when using auto-expiry or adaptive scoring.
7546 (gnus-summary-show-all-threads)
7547 (when (gnus-summary-first-subject (not all))
7549 (if to-here (< (point) to-here) t)
7550 (gnus-summary-mark-article-as-read gnus-catchup-mark)
7551 (gnus-summary-find-next (not all)))))
7553 (setq gnus-newsgroup-unreads nil))
7554 (gnus-set-mode-line 'summary))
7555 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
7556 (when (and (not to-here) (eq 'nnvirtual (car method)))
7557 (nnvirtual-catchup-group
7558 (gnus-group-real-name gnus-newsgroup-name)
7559 (nth 1 method) all)))
7561 (gnus-summary-position-point)))
7563 (defun gnus-summary-catchup-to-here (&optional all)
7564 "Mark all unticked articles before the current one as read.
7565 If ALL is non-nil, also mark ticked and dormant articles as read."
7567 (gnus-set-global-variables)
7569 (gnus-save-hidden-threads
7570 (let ((beg (point)))
7571 ;; We check that there are unread articles.
7572 (when (or all (gnus-summary-find-prev))
7573 (gnus-summary-catchup all t beg)))))
7574 (gnus-summary-position-point))
7576 (defun gnus-summary-catchup-all (&optional quietly)
7577 "Mark all articles in this newsgroup as read."
7579 (gnus-set-global-variables)
7580 (gnus-summary-catchup t quietly))
7582 (defun gnus-summary-catchup-and-exit (&optional all quietly)
7583 "Mark all articles not marked as unread in this newsgroup as read, then exit.
7584 If prefix argument ALL is non-nil, all articles are marked as read."
7586 (gnus-set-global-variables)
7587 (when (gnus-summary-catchup all quietly nil 'fast)
7588 ;; Select next newsgroup or exit.
7589 (if (eq gnus-auto-select-next 'quietly)
7590 (gnus-summary-next-group nil)
7591 (gnus-summary-exit))))
7593 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
7594 "Mark all articles in this newsgroup as read, and then exit."
7596 (gnus-set-global-variables)
7597 (gnus-summary-catchup-and-exit t quietly))
7599 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
7600 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
7601 "Mark all articles in this group as read and select the next group.
7602 If given a prefix, mark all articles, unread as well as ticked, as
7605 (gnus-set-global-variables)
7607 (gnus-summary-catchup all))
7608 (gnus-summary-next-article t nil nil t))
7610 ;; Thread-based commands.
7612 (defun gnus-summary-articles-in-thread (&optional article)
7613 "Return a list of all articles in the current thread.
7614 If ARTICLE is non-nil, return all articles in the thread that starts
7616 (let* ((article (or article (gnus-summary-article-number)))
7617 (data (gnus-data-find-list article))
7618 (top-level (gnus-data-level (car data)))
7620 (cond ((null gnus-thread-operation-ignore-subject)
7621 (gnus-simplify-subject-re
7622 (mail-header-subject (gnus-data-header (car data)))))
7623 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
7624 (gnus-simplify-subject-fuzzy
7625 (mail-header-subject (gnus-data-header (car data)))))
7627 (end-point (save-excursion
7628 (if (gnus-summary-go-to-next-thread)
7629 (point) (point-max))))
7632 (< (gnus-data-pos (car data)) end-point))
7633 (when (or (not top-subject)
7634 (string= top-subject
7635 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
7636 (gnus-simplify-subject-fuzzy
7637 (mail-header-subject
7638 (gnus-data-header (car data))))
7639 (gnus-simplify-subject-re
7640 (mail-header-subject
7641 (gnus-data-header (car data)))))))
7642 (push (gnus-data-number (car data)) articles))
7643 (unless (and (setq data (cdr data))
7644 (> (gnus-data-level (car data)) top-level))
7646 ;; Return the list of articles.
7647 (nreverse articles)))
7649 (defun gnus-summary-rethread-current ()
7650 "Rethread the thread the current article is part of."
7652 (gnus-set-global-variables)
7653 (let* ((gnus-show-threads t)
7654 (article (gnus-summary-article-number))
7655 (id (mail-header-id (gnus-summary-article-header)))
7656 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
7658 (error "No article on the current line"))
7659 (gnus-rebuild-thread id)
7660 (gnus-summary-goto-subject article)))
7662 (defun gnus-summary-reparent-thread ()
7663 "Make current article child of the marked (or previous) article.
7665 Note that the re-threading will only work if `gnus-thread-ignore-subject'
7666 is non-nil or the Subject: of both articles are the same."
7668 (unless (not (gnus-group-read-only-p))
7669 (error "The current newsgroup does not support article editing."))
7670 (unless (<= (length gnus-newsgroup-processable) 1)
7671 (error "No more than one article may be marked."))
7672 (save-window-excursion
7673 (let ((gnus-article-buffer " *reparent*")
7674 (current-article (gnus-summary-article-number))
7675 ; first grab the marked article, otherwise one line up.
7676 (parent-article (if (not (null gnus-newsgroup-processable))
7677 (car gnus-newsgroup-processable)
7679 (if (eq (forward-line -1) 0)
7680 (gnus-summary-article-number)
7681 (error "Beginning of summary buffer."))))))
7682 (unless (not (eq current-article parent-article))
7683 (error "An article may not be self-referential."))
7684 (let ((message-id (mail-header-id
7685 (gnus-summary-article-header parent-article))))
7686 (unless (and message-id (not (equal message-id "")))
7687 (error "No message-id in desired parent."))
7688 (gnus-summary-select-article t t nil current-article)
7689 (set-buffer gnus-article-buffer)
7690 (setq buffer-read-only nil)
7691 (let ((buf (format "%s" (buffer-string))))
7694 (goto-char (point-min))
7695 (if (search-forward-regexp "^References: " nil t)
7696 (insert message-id " " )
7697 (insert "References: " message-id "\n"))
7698 (unless (gnus-request-replace-article current-article
7699 (car gnus-article-current)
7700 gnus-article-buffer)
7701 (error "Couldn't replace article."))
7702 (set-buffer gnus-summary-buffer)
7703 (gnus-summary-unmark-all-processable)
7704 (gnus-summary-rethread-current)
7705 (gnus-message 3 "Article %d is now the child of article %d."
7706 current-article parent-article)))))
7708 (defun gnus-summary-toggle-threads (&optional arg)
7709 "Toggle showing conversation threads.
7710 If ARG is positive number, turn showing conversation threads on."
7712 (gnus-set-global-variables)
7713 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
7714 (setq gnus-show-threads
7715 (if (null arg) (not gnus-show-threads)
7716 (> (prefix-numeric-value arg) 0)))
7717 (gnus-summary-prepare)
7718 (gnus-summary-goto-subject current)
7719 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
7720 (gnus-summary-position-point)))
7722 (defun gnus-summary-show-all-threads ()
7725 (gnus-set-global-variables)
7727 (let ((buffer-read-only nil))
7728 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
7729 (gnus-summary-position-point))
7731 (defun gnus-summary-show-thread ()
7732 "Show thread subtrees.
7733 Returns nil if no thread was there to be shown."
7735 (gnus-set-global-variables)
7736 (let ((buffer-read-only nil)
7738 ;; first goto end then to beg, to have point at beg after let
7739 (end (progn (end-of-line) (point)))
7740 (beg (progn (beginning-of-line) (point))))
7742 ;; Any hidden lines here?
7743 (search-forward "\r" end t)
7744 (subst-char-in-region beg end ?\^M ?\n t)
7746 (gnus-summary-position-point))))
7748 (defun gnus-summary-hide-all-threads ()
7749 "Hide all thread subtrees."
7751 (gnus-set-global-variables)
7753 (goto-char (point-min))
7754 (gnus-summary-hide-thread)
7755 (while (zerop (gnus-summary-next-thread 1 t))
7756 (gnus-summary-hide-thread)))
7757 (gnus-summary-position-point))
7759 (defun gnus-summary-hide-thread ()
7760 "Hide thread subtrees.
7761 Returns nil if no threads were there to be hidden."
7763 (gnus-set-global-variables)
7764 (let ((buffer-read-only nil)
7766 (article (gnus-summary-article-number)))
7768 ;; Go forward until either the buffer ends or the subthread
7770 (when (and (not (eobp))
7771 (or (zerop (gnus-summary-next-thread 1 t))
7772 (goto-char (point-max))))
7774 (if (and (> (point) start)
7775 (search-backward "\n" start t))
7777 (subst-char-in-region start (point) ?\n ?\^M)
7778 (gnus-summary-goto-subject article))
7781 ;;(gnus-summary-position-point)
7784 (defun gnus-summary-go-to-next-thread (&optional previous)
7785 "Go to the same level (or less) next thread.
7786 If PREVIOUS is non-nil, go to previous thread instead.
7787 Return the article number moved to, or nil if moving was impossible."
7788 (let ((level (gnus-summary-thread-level))
7789 (way (if previous -1 1))
7792 (while (and (not (eobp))
7793 (< level (gnus-summary-thread-level)))
7801 (gnus-summary-article-number)
7804 (defun gnus-summary-next-thread (n &optional silent)
7805 "Go to the same level next N'th thread.
7806 If N is negative, search backward instead.
7807 Returns the difference between N and the number of skips actually
7810 If SILENT, don't output messages."
7812 (gnus-set-global-variables)
7813 (let ((backward (< n 0))
7816 (gnus-summary-go-to-next-thread backward))
7819 (gnus-summary-position-point))
7820 (when (and (not silent) (/= 0 n))
7821 (gnus-message 7 "No more threads"))
7824 (defun gnus-summary-prev-thread (n)
7825 "Go to the same level previous N'th thread.
7826 Returns the difference between N and the number of skips actually
7829 (gnus-set-global-variables)
7830 (gnus-summary-next-thread (- n)))
7832 (defun gnus-summary-go-down-thread ()
7833 "Go down one level in the current thread."
7834 (let ((children (gnus-summary-article-children)))
7836 (gnus-summary-goto-subject (car children)))))
7838 (defun gnus-summary-go-up-thread ()
7839 "Go up one level in the current thread."
7840 (let ((parent (gnus-summary-article-parent)))
7842 (gnus-summary-goto-subject parent))))
7844 (defun gnus-summary-down-thread (n)
7845 "Go down thread N steps.
7846 If N is negative, go up instead.
7847 Returns the difference between N and how many steps down that were
7850 (gnus-set-global-variables)
7854 (if up (gnus-summary-go-up-thread)
7855 (gnus-summary-go-down-thread)))
7857 (gnus-summary-position-point)
7859 (gnus-message 7 "Can't go further"))
7862 (defun gnus-summary-up-thread (n)
7863 "Go up thread N steps.
7864 If N is negative, go up instead.
7865 Returns the difference between N and how many steps down that were
7868 (gnus-set-global-variables)
7869 (gnus-summary-down-thread (- n)))
7871 (defun gnus-summary-top-thread ()
7872 "Go to the top of the thread."
7874 (gnus-set-global-variables)
7875 (while (gnus-summary-go-up-thread))
7876 (gnus-summary-article-number))
7878 (defun gnus-summary-kill-thread (&optional unmark)
7879 "Mark articles under current thread as read.
7880 If the prefix argument is positive, remove any kinds of marks.
7881 If the prefix argument is negative, tick articles instead."
7883 (gnus-set-global-variables)
7885 (setq unmark (prefix-numeric-value unmark)))
7886 (let ((articles (gnus-summary-articles-in-thread)))
7888 ;; Expand the thread.
7889 (gnus-summary-show-thread)
7890 ;; Mark all the articles.
7892 (gnus-summary-goto-subject (car articles))
7893 (cond ((null unmark)
7894 (gnus-summary-mark-article-as-read gnus-killed-mark))
7896 (gnus-summary-mark-article-as-unread gnus-unread-mark))
7898 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
7899 (setq articles (cdr articles))))
7900 ;; Hide killed subtrees.
7902 gnus-thread-hide-killed
7903 (gnus-summary-hide-thread))
7904 ;; If marked as read, go to next unread subject.
7906 ;; Go to next unread subject.
7907 (gnus-summary-next-subject 1 t)))
7908 (gnus-set-mode-line 'summary))
7910 ;; Summary sorting commands
7912 (defun gnus-summary-sort-by-number (&optional reverse)
7913 "Sort the summary buffer by article number.
7914 Argument REVERSE means reverse order."
7916 (gnus-summary-sort 'number reverse))
7918 (defun gnus-summary-sort-by-author (&optional reverse)
7919 "Sort the summary buffer by author name alphabetically.
7920 If case-fold-search is non-nil, case of letters is ignored.
7921 Argument REVERSE means reverse order."
7923 (gnus-summary-sort 'author reverse))
7925 (defun gnus-summary-sort-by-subject (&optional reverse)
7926 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
7927 If case-fold-search is non-nil, case of letters is ignored.
7928 Argument REVERSE means reverse order."
7930 (gnus-summary-sort 'subject reverse))
7932 (defun gnus-summary-sort-by-date (&optional reverse)
7933 "Sort the summary buffer by date.
7934 Argument REVERSE means reverse order."
7936 (gnus-summary-sort 'date reverse))
7938 (defun gnus-summary-sort-by-score (&optional reverse)
7939 "Sort the summary buffer by score.
7940 Argument REVERSE means reverse order."
7942 (gnus-summary-sort 'score reverse))
7944 (defun gnus-summary-sort-by-lines (&optional reverse)
7945 "Sort the summary buffer by article length.
7946 Argument REVERSE means reverse order."
7948 (gnus-summary-sort 'lines reverse))
7950 (defun gnus-summary-sort (predicate reverse)
7951 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
7952 (gnus-set-global-variables)
7953 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
7954 (article (intern (format "gnus-article-sort-by-%s" predicate)))
7955 (gnus-thread-sort-functions
7961 (gnus-article-sort-functions
7966 (,article t2 t1)))))
7968 (gnus-summary-prepare-hook nil))
7969 ;; We do the sorting by regenerating the threads.
7970 (gnus-summary-prepare)
7971 ;; Hide subthreads if needed.
7972 (when (and gnus-show-threads gnus-thread-hide-subtree)
7973 (gnus-summary-hide-all-threads))))
7975 ;; Summary saving commands.
7977 (defun gnus-summary-save-article (&optional n not-saved)
7978 "Save the current article using the default saver function.
7979 If N is a positive number, save the N next articles.
7980 If N is a negative number, save the N previous articles.
7981 If N is nil and any articles have been marked with the process mark,
7982 save those articles instead.
7983 The variable `gnus-default-article-saver' specifies the saver function."
7985 (gnus-set-global-variables)
7986 (let* ((articles (gnus-summary-work-articles n))
7987 (save-buffer (save-excursion
7988 (nnheader-set-temp-buffer " *Gnus Save*")))
7989 (num (length articles))
7990 header article file)
7992 (setq header (gnus-summary-article-header
7993 (setq article (pop articles))))
7994 (if (not (vectorp header))
7995 ;; This is a pseudo-article.
7996 (if (assq 'name header)
7997 (gnus-copy-file (cdr (assq 'name header)))
7998 (gnus-message 1 "Article %d is unsaveable" article))
7999 ;; This is a real article.
8000 (save-window-excursion
8001 (gnus-summary-select-article t nil nil article))
8003 (set-buffer save-buffer)
8005 (insert-buffer-substring gnus-original-article-buffer))
8006 (setq file (gnus-article-save save-buffer file num))
8007 (gnus-summary-remove-process-mark article)
8009 (gnus-summary-set-saved-mark article))))
8010 (gnus-kill-buffer save-buffer)
8011 (gnus-summary-position-point)
8014 (defun gnus-summary-pipe-output (&optional arg)
8015 "Pipe the current article to a subprocess.
8016 If N is a positive number, pipe the N next articles.
8017 If N is a negative number, pipe the N previous articles.
8018 If N is nil and any articles have been marked with the process mark,
8019 pipe those articles instead."
8021 (gnus-set-global-variables)
8022 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8023 (gnus-summary-save-article arg t))
8024 (gnus-configure-windows 'pipe))
8026 (defun gnus-summary-save-article-mail (&optional arg)
8027 "Append the current article to an mail file.
8028 If N is a positive number, save the N next articles.
8029 If N is a negative number, save the N previous articles.
8030 If N is nil and any articles have been marked with the process mark,
8031 save those articles instead."
8033 (gnus-set-global-variables)
8034 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8035 (gnus-summary-save-article arg)))
8037 (defun gnus-summary-save-article-rmail (&optional arg)
8038 "Append the current article to an rmail file.
8039 If N is a positive number, save the N next articles.
8040 If N is a negative number, save the N previous articles.
8041 If N is nil and any articles have been marked with the process mark,
8042 save those articles instead."
8044 (gnus-set-global-variables)
8045 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
8046 (gnus-summary-save-article arg)))
8048 (defun gnus-summary-save-article-file (&optional arg)
8049 "Append the current article to a file.
8050 If N is a positive number, save the N next articles.
8051 If N is a negative number, save the N previous articles.
8052 If N is nil and any articles have been marked with the process mark,
8053 save those articles instead."
8055 (gnus-set-global-variables)
8056 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8057 (gnus-summary-save-article arg)))
8059 (defun gnus-summary-write-article-file (&optional arg)
8060 "Write the current article to a file, deleting the previous file.
8061 If N is a positive number, save the N next articles.
8062 If N is a negative number, save the N previous articles.
8063 If N is nil and any articles have been marked with the process mark,
8064 save those articles instead."
8066 (gnus-set-global-variables)
8067 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
8068 (gnus-summary-save-article arg)))
8070 (defun gnus-summary-save-article-body-file (&optional arg)
8071 "Append the current article body to a file.
8072 If N is a positive number, save the N next articles.
8073 If N is a negative number, save the N previous articles.
8074 If N is nil and any articles have been marked with the process mark,
8075 save those articles instead."
8077 (gnus-set-global-variables)
8078 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
8079 (gnus-summary-save-article arg)))
8081 (defun gnus-get-split-value (methods)
8082 "Return a value based on the split METHODS."
8083 (let (split-name method result match)
8086 (set-buffer gnus-original-article-buffer)
8088 (nnheader-narrow-to-headers)
8090 (goto-char (point-min))
8091 (setq method (pop methods))
8092 (setq match (car method))
8095 ;; Regular expression.
8097 (re-search-forward match nil t)))
8098 ((gnus-functionp match)
8102 (setq result (funcall match gnus-newsgroup-name))))
8107 (setq result (eval match)))))
8108 (setq split-name (append (cdr method) split-name))
8109 (cond ((stringp result)
8110 (push result split-name))
8112 (setq split-name (append result split-name)))))))))
8115 (defun gnus-valid-move-group-p (group)
8120 (car (gnus-find-method-for-group
8121 (symbol-name group))))
8122 gnus-valid-select-methods))))
8124 (defun gnus-read-move-group-name (prompt default articles prefix)
8125 "Read a group name."
8126 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
8127 (minibuffer-confirm-incomplete nil) ; XEmacs
8131 (if (> (length articles) 1)
8132 (format "these %d articles" (length articles))
8137 (gnus-completing-read default prom
8139 'gnus-valid-move-group-p
8141 'gnus-group-history))
8142 ((= 1 (length split-name))
8143 (gnus-completing-read (car split-name) prom
8145 'gnus-valid-move-group-p
8147 'gnus-group-history))
8149 (gnus-completing-read nil prom
8150 (mapcar (lambda (el) (list el))
8151 (nreverse split-name))
8153 'gnus-group-history)))))
8155 (if (or (string= to-newsgroup "")
8156 (string= to-newsgroup prefix))
8157 (setq to-newsgroup (or default "")))
8158 (or (gnus-active to-newsgroup)
8159 (gnus-activate-group to-newsgroup)
8160 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
8162 (or (and (gnus-request-create-group
8163 to-newsgroup (gnus-group-name-to-method to-newsgroup))
8164 (gnus-activate-group to-newsgroup nil nil
8165 (gnus-group-name-to-method
8167 (error "Couldn't create group %s" to-newsgroup)))
8168 (error "No such group: %s" to-newsgroup)))
8171 ;; Summary extract commands
8173 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
8174 (let ((buffer-read-only nil)
8175 (article (gnus-summary-article-number))
8177 (unless (gnus-summary-goto-subject article)
8178 (error "No such article: %d" article))
8179 (gnus-summary-position-point)
8180 ;; If all commands are to be bunched up on one line, we collect
8182 (unless gnus-view-pseudos-separately
8183 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
8186 (setq action (cdr (assq 'action (car ps))))
8187 (setq files (list (cdr (assq 'name (car ps)))))
8188 (while (and ps (cdr ps)
8189 (string= (or action "1")
8190 (or (cdr (assq 'action (cadr ps))) "2")))
8191 (push (cdr (assq 'name (cadr ps))) files)
8192 (setcdr ps (cddr ps)))
8194 (when (not (string-match "%s" action))
8197 (when (assq 'execute (car ps))
8198 (setcdr (assq 'execute (car ps))
8199 (funcall (if (string-match "%s" action)
8202 (mapconcat (lambda (f) f) files " ")))))
8203 (setq ps (cdr ps)))))
8204 (if (and gnus-view-pseudos (not not-view))
8206 (when (assq 'execute (car pslist))
8207 (gnus-execute-command (cdr (assq 'execute (car pslist)))
8208 (eq gnus-view-pseudos 'not-confirm)))
8209 (setq pslist (cdr pslist)))
8212 (setq after-article (or (cdr (assq 'article (car pslist)))
8213 (gnus-summary-article-number)))
8214 (gnus-summary-goto-subject after-article)
8217 (insert " " (file-name-nondirectory
8218 (cdr (assq 'name (car pslist))))
8219 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
8221 (forward-line -1) ; back to `b'
8222 (gnus-add-text-properties
8223 b (1- e) (list 'gnus-number gnus-reffed-article-number
8224 gnus-mouse-face-prop gnus-mouse-face))
8226 after-article gnus-reffed-article-number
8227 gnus-unread-mark b (car pslist) 0 (- e b))
8228 (push gnus-reffed-article-number gnus-newsgroup-unreads)
8229 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
8230 (setq pslist (cdr pslist)))))))
8232 (defun gnus-pseudos< (p1 p2)
8233 (let ((c1 (cdr (assq 'action p1)))
8234 (c2 (cdr (assq 'action p2))))
8235 (and c1 c2 (string< c1 c2))))
8237 (defun gnus-request-pseudo-article (props)
8238 (cond ((assq 'execute props)
8239 (gnus-execute-command (cdr (assq 'execute props)))))
8240 (let ((gnus-current-article (gnus-summary-article-number)))
8241 (run-hooks 'gnus-mark-article-hook)))
8243 (defun gnus-execute-command (command &optional automatic)
8245 (gnus-article-setup-buffer)
8246 (set-buffer gnus-article-buffer)
8247 (setq buffer-read-only nil)
8248 (let ((command (if automatic command (read-string "Command: " command)))
8249 ;; Just binding this here doesn't help, because there might
8250 ;; be output from the process after exiting the scope of
8252 ;; (buffer-read-only nil)
8255 (insert "$ " command "\n\n")
8256 (if gnus-view-pseudo-asynchronously
8257 (start-process "gnus-execute" nil shell-file-name
8258 shell-command-switch command)
8259 (call-process shell-file-name nil t nil
8260 shell-command-switch command)))))
8262 ;; Summary kill commands.
8264 (defun gnus-summary-edit-global-kill (article)
8265 "Edit the \"global\" kill file."
8266 (interactive (list (gnus-summary-article-number)))
8267 (gnus-set-global-variables)
8268 (gnus-group-edit-global-kill article))
8270 (defun gnus-summary-edit-local-kill ()
8271 "Edit a local kill file applied to the current newsgroup."
8273 (gnus-set-global-variables)
8274 (setq gnus-current-headers (gnus-summary-article-header))
8275 (gnus-set-global-variables)
8276 (gnus-group-edit-local-kill
8277 (gnus-summary-article-number) gnus-newsgroup-name))
8281 (defun gnus-read-header (id &optional header)
8282 "Read the headers of article ID and enter them into the Gnus system."
8283 (let ((group gnus-newsgroup-name)
8284 (gnus-override-method
8285 (and (gnus-news-group-p gnus-newsgroup-name)
8286 gnus-refer-article-method))
8288 ;; First we check to see whether the header in question is already
8291 ;; This is a Message-ID.
8292 (setq header (or header (gnus-id-to-header id)))
8293 ;; This is an article number.
8294 (setq header (or header (gnus-summary-article-header id))))
8296 (not (memq (mail-header-number header) gnus-newsgroup-sparse)))
8297 ;; We have found the header.
8299 ;; We have to really fetch the header to this article.
8301 (set-buffer nntp-server-buffer)
8302 (when (setq where (gnus-request-head id group))
8303 (goto-char (point-max))
8305 (goto-char (point-min))
8309 ((cdr where) (cdr where))
8310 (header (mail-header-number header))
8311 (t gnus-reffed-article-number))
8313 (insert " Article retrieved.\n"))
8314 (if (not (setq header (car (gnus-get-newsgroup-headers nil t))))
8315 () ; Malformed head.
8316 (unless (memq (mail-header-number header) gnus-newsgroup-sparse)
8317 (when (and (stringp id)
8318 (not (string= (gnus-group-real-name group)
8320 ;; If we fetched by Message-ID and the article came
8321 ;; from a different group, we fudge some bogus article
8322 ;; numbers for this article.
8323 (mail-header-set-number header gnus-reffed-article-number))
8325 (set-buffer gnus-summary-buffer)
8326 (decf gnus-reffed-article-number)
8327 (gnus-remove-header (mail-header-number header))
8328 (push header gnus-newsgroup-headers)
8329 (setq gnus-current-headers header)
8330 (push (mail-header-number header) gnus-newsgroup-limit)))
8333 (defun gnus-remove-header (number)
8334 "Remove header NUMBER from `gnus-newsgroup-headers'."
8335 (if (and gnus-newsgroup-headers
8336 (= number (mail-header-number (car gnus-newsgroup-headers))))
8337 (pop gnus-newsgroup-headers)
8338 (let ((headers gnus-newsgroup-headers))
8339 (while (and (cdr headers)
8340 (not (= number (mail-header-number (cadr headers)))))
8343 (setcdr headers (cddr headers))))))
8346 ;;; summary highlights
8349 (defun gnus-highlight-selected-summary ()
8350 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8351 ;; Highlight selected article in summary buffer
8352 (when gnus-summary-selected-face
8354 (let* ((beg (progn (beginning-of-line) (point)))
8355 (end (progn (end-of-line) (point)))
8356 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
8357 (from (if (get-text-property beg gnus-mouse-face-prop)
8359 (or (next-single-property-change
8360 beg gnus-mouse-face-prop nil end)
8365 (or (next-single-property-change
8366 from gnus-mouse-face-prop nil end)
8368 ;; If no mouse-face prop on line we will have to = from = end,
8369 ;; so we highlight the entire line instead.
8370 (when (= (+ to 2) from)
8373 (if gnus-newsgroup-selected-overlay
8374 ;; Move old overlay.
8376 gnus-newsgroup-selected-overlay from to (current-buffer))
8377 ;; Create new overlay.
8379 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
8380 'face gnus-summary-selected-face))))))
8382 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
8383 (defun gnus-summary-highlight-line ()
8384 "Highlight current line according to `gnus-summary-highlight'."
8385 (let* ((list gnus-summary-highlight)
8387 (end (progn (end-of-line) (point)))
8388 ;; now find out where the line starts and leave point there.
8389 (beg (progn (beginning-of-line) (point)))
8390 (article (gnus-summary-article-number))
8391 (score (or (cdr (assq (or article gnus-current-article)
8392 gnus-newsgroup-scored))
8393 gnus-summary-default-score 0))
8394 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
8395 (inhibit-read-only t))
8396 ;; Eval the cars of the lists until we find a match.
8397 (let ((default gnus-summary-default-score))
8399 (not (eval (caar list))))
8400 (setq list (cdr list))))
8401 (let ((face (cdar list)))
8402 (unless (eq face (get-text-property beg 'face))
8403 (gnus-put-text-property
8405 (setq face (if (boundp face) (symbol-value face) face)))
8406 (when gnus-summary-highlight-line-function
8407 (funcall gnus-summary-highlight-line-function article face))))
8410 (defun gnus-update-read-articles (group unread)
8411 "Update the list of read articles in GROUP."
8412 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
8413 (entry (gnus-gethash group gnus-newsrc-hashtb))
8414 (info (nth 2 entry))
8416 (unread (sort (copy-sequence unread) '<))
8418 (if (or (not info) (not active))
8419 ;; There is no info on this group if it was, in fact,
8420 ;; killed. Gnus stores no information on killed groups, so
8421 ;; there's nothing to be done.
8422 ;; One could store the information somewhere temporarily,
8423 ;; perhaps... Hmmm...
8425 ;; Remove any negative articles numbers.
8426 (while (and unread (< (car unread) 0))
8427 (setq unread (cdr unread)))
8428 ;; Remove any expired article numbers
8429 (while (and unread (< (car unread) (car active)))
8430 (setq unread (cdr unread)))
8431 ;; Compute the ranges of read articles by looking at the list of
8434 (when (/= (car unread) prev)
8435 (push (if (= prev (1- (car unread))) prev
8436 (cons prev (1- (car unread))))
8438 (setq prev (1+ (car unread)))
8439 (setq unread (cdr unread)))
8440 (when (<= prev (cdr active))
8441 (push (cons prev (cdr active)) read))
8444 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
8445 (gnus-info-set-read ',info ',(gnus-info-read info))
8446 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))))
8447 ;; Enter this list into the group info.
8449 info (if (> (length read) 1) (nreverse read) read))
8450 ;; Set the number of unread articles in gnus-newsrc-hashtb.
8451 (gnus-get-unread-articles-in-group info (gnus-active group))
8456 (run-hooks 'gnus-sum-load-hook)
8458 ;;; gnus-sum.el ends here