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 (gnus-visual-p 'summary-menu 'menu)
2001 (gnus-summary-make-menu-bar))
2002 (kill-all-local-variables)
2003 (gnus-summary-make-local-variables)
2004 (gnus-make-thread-indent-array)
2005 (gnus-simplify-mode-line)
2006 (setq major-mode 'gnus-summary-mode)
2007 (setq mode-name "Summary")
2008 (make-local-variable 'minor-mode-alist)
2009 (use-local-map gnus-summary-mode-map)
2010 (buffer-disable-undo (current-buffer))
2011 (setq buffer-read-only t) ;Disable modification
2012 (setq truncate-lines t)
2013 (setq selective-display t)
2014 (setq selective-display-ellipses t) ;Display `...'
2015 (setq buffer-display-table gnus-summary-display-table)
2016 (gnus-set-default-directory)
2017 (setq gnus-newsgroup-name group)
2018 (make-local-variable 'gnus-summary-line-format)
2019 (make-local-variable 'gnus-summary-line-format-spec)
2020 (make-local-variable 'gnus-summary-mark-positions)
2021 (gnus-make-local-hook 'post-command-hook)
2022 (gnus-add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
2023 (run-hooks 'gnus-summary-mode-hook)
2024 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2025 (gnus-update-summary-mark-positions))
2027 (defun gnus-summary-make-local-variables ()
2028 "Make all the local summary buffer variables."
2029 (let ((locals gnus-summary-local-variables)
2031 (while (setq local (pop locals))
2034 (if (eq (cdr local) 'global)
2035 ;; Copy the global value of the variable.
2036 (setq global (symbol-value (car local)))
2037 ;; Use the value from the list.
2038 (setq global (eval (cdr local))))
2039 (make-local-variable (car local))
2040 (set (car local) global))
2041 ;; Simple nil-valued local variable.
2042 (make-local-variable local)
2045 (defun gnus-summary-clear-local-variables ()
2046 (let ((locals gnus-summary-local-variables))
2048 (if (consp (car locals))
2049 (and (vectorp (caar locals))
2050 (set (caar locals) nil))
2051 (and (vectorp (car locals))
2052 (set (car locals) nil)))
2053 (setq locals (cdr locals)))))
2055 ;; Summary data functions.
2057 (defmacro gnus-data-number (data)
2060 (defmacro gnus-data-set-number (data number)
2061 `(setcar ,data ,number))
2063 (defmacro gnus-data-mark (data)
2066 (defmacro gnus-data-set-mark (data mark)
2067 `(setcar (nthcdr 1 ,data) ,mark))
2069 (defmacro gnus-data-pos (data)
2072 (defmacro gnus-data-set-pos (data pos)
2073 `(setcar (nthcdr 2 ,data) ,pos))
2075 (defmacro gnus-data-header (data)
2078 (defmacro gnus-data-level (data)
2081 (defmacro gnus-data-unread-p (data)
2082 `(= (nth 1 ,data) gnus-unread-mark))
2084 (defmacro gnus-data-read-p (data)
2085 `(/= (nth 1 ,data) gnus-unread-mark))
2087 (defmacro gnus-data-pseudo-p (data)
2088 `(consp (nth 3 ,data)))
2090 (defmacro gnus-data-find (number)
2091 `(assq ,number gnus-newsgroup-data))
2093 (defmacro gnus-data-find-list (number &optional data)
2094 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2095 (memq (assq ,number bdata)
2098 (defmacro gnus-data-make (number mark pos header level)
2099 `(list ,number ,mark ,pos ,header ,level))
2101 (defun gnus-data-enter (after-article number mark pos header level offset)
2102 (let ((data (gnus-data-find-list after-article)))
2104 (error "No such article: %d" after-article))
2105 (setcdr data (cons (gnus-data-make number mark pos header level)
2107 (setq gnus-newsgroup-data-reverse nil)
2108 (gnus-data-update-list (cddr data) offset)))
2110 (defun gnus-data-enter-list (after-article list &optional offset)
2112 (let ((data (and after-article (gnus-data-find-list after-article)))
2114 (or data (not after-article) (error "No such article: %d" after-article))
2115 ;; Find the last element in the list to be spliced into the main
2118 (setq list (cdr list)))
2121 (setcdr list gnus-newsgroup-data)
2122 (setq gnus-newsgroup-data ilist)
2124 (gnus-data-update-list (cdr list) offset)))
2125 (setcdr list (cdr data))
2128 (gnus-data-update-list (cdr list) offset)))
2129 (setq gnus-newsgroup-data-reverse nil))))
2131 (defun gnus-data-remove (article &optional offset)
2132 (let ((data gnus-newsgroup-data))
2133 (if (= (gnus-data-number (car data)) article)
2134 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2135 gnus-newsgroup-data-reverse nil)
2137 (when (= (gnus-data-number (cadr data)) article)
2138 (setcdr data (cddr data))
2140 (gnus-data-update-list (cdr data) offset))
2142 gnus-newsgroup-data-reverse nil))
2143 (setq data (cdr data))))))
2145 (defmacro gnus-data-list (backward)
2147 (or gnus-newsgroup-data-reverse
2148 (setq gnus-newsgroup-data-reverse
2149 (reverse gnus-newsgroup-data)))
2150 gnus-newsgroup-data))
2152 (defun gnus-data-update-list (data offset)
2153 "Add OFFSET to the POS of all data entries in DATA."
2155 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2156 (setq data (cdr data))))
2158 (defun gnus-summary-article-pseudo-p (article)
2159 "Say whether this article is a pseudo article or not."
2160 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2162 (defmacro gnus-summary-article-sparse-p (article)
2163 "Say whether this article is a sparse article or not."
2164 ` (memq ,article gnus-newsgroup-sparse))
2166 (defmacro gnus-summary-article-ancient-p (article)
2167 "Say whether this article is a sparse article or not."
2168 `(memq ,article gnus-newsgroup-ancient))
2170 (defun gnus-article-parent-p (number)
2171 "Say whether this article is a parent or not."
2172 (let ((data (gnus-data-find-list number)))
2173 (and (cdr data) ; There has to be an article after...
2174 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2175 (gnus-data-level (nth 1 data))))))
2177 (defun gnus-article-children (number)
2178 "Return a list of all children to NUMBER."
2179 (let* ((data (gnus-data-find-list number))
2180 (level (gnus-data-level (car data)))
2182 (setq data (cdr data))
2184 (= (gnus-data-level (car data)) (1+ level)))
2185 (push (gnus-data-number (car data)) children)
2186 (setq data (cdr data)))
2189 (defmacro gnus-summary-skip-intangible ()
2190 "If the current article is intangible, then jump to a different article."
2191 '(let ((to (get-text-property (point) 'gnus-intangible)))
2192 (and to (gnus-summary-goto-subject to))))
2194 (defmacro gnus-summary-article-intangible-p ()
2195 "Say whether this article is intangible or not."
2196 '(get-text-property (point) 'gnus-intangible))
2198 (defun gnus-article-read-p (article)
2199 "Say whether ARTICLE is read or not."
2200 (not (or (memq article gnus-newsgroup-marked)
2201 (memq article gnus-newsgroup-unreads)
2202 (memq article gnus-newsgroup-unselected)
2203 (memq article gnus-newsgroup-dormant))))
2205 ;; Some summary mode macros.
2207 (defmacro gnus-summary-article-number ()
2208 "The article number of the article on the current line.
2209 If there isn's an article number here, then we return the current
2212 (gnus-summary-skip-intangible)
2213 (or (get-text-property (point) 'gnus-number)
2214 (gnus-summary-last-subject))))
2216 (defmacro gnus-summary-article-header (&optional number)
2217 `(gnus-data-header (gnus-data-find
2218 ,(or number '(gnus-summary-article-number)))))
2220 (defmacro gnus-summary-thread-level (&optional number)
2221 `(if (and (eq gnus-summary-make-false-root 'dummy)
2222 (get-text-property (point) 'gnus-intangible))
2224 (gnus-data-level (gnus-data-find
2225 ,(or number '(gnus-summary-article-number))))))
2227 (defmacro gnus-summary-article-mark (&optional number)
2228 `(gnus-data-mark (gnus-data-find
2229 ,(or number '(gnus-summary-article-number)))))
2231 (defmacro gnus-summary-article-pos (&optional number)
2232 `(gnus-data-pos (gnus-data-find
2233 ,(or number '(gnus-summary-article-number)))))
2235 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2236 (defmacro gnus-summary-article-subject (&optional number)
2237 "Return current subject string or nil if nothing."
2240 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2241 '(gnus-data-header (assq (gnus-summary-article-number)
2242 gnus-newsgroup-data)))))
2245 (mail-header-subject headers))))
2247 (defmacro gnus-summary-article-score (&optional number)
2248 "Return current article score."
2249 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2250 gnus-newsgroup-scored))
2251 gnus-summary-default-score 0))
2253 (defun gnus-summary-article-children (&optional number)
2254 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2255 (level (gnus-data-level (car data)))
2257 (while (and (setq data (cdr data))
2258 (> (setq l (gnus-data-level (car data))) level))
2259 (and (= (1+ level) l)
2260 (push (gnus-data-number (car data))
2262 (nreverse children)))
2264 (defun gnus-summary-article-parent (&optional number)
2265 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2266 (gnus-data-list t)))
2267 (level (gnus-data-level (car data))))
2269 () ; This is a root.
2270 ;; We search until we find an article with a level less than
2271 ;; this one. That function has to be the parent.
2272 (while (and (setq data (cdr data))
2273 (not (< (gnus-data-level (car data)) level))))
2274 (and data (gnus-data-number (car data))))))
2276 (defun gnus-unread-mark-p (mark)
2277 "Say whether MARK is the unread mark."
2278 (= mark gnus-unread-mark))
2280 (defun gnus-read-mark-p (mark)
2281 "Say whether MARK is one of the marks that mark as read.
2282 This is all marks except unread, ticked, dormant, and expirable."
2283 (not (or (= mark gnus-unread-mark)
2284 (= mark gnus-ticked-mark)
2285 (= mark gnus-dormant-mark)
2286 (= mark gnus-expirable-mark))))
2288 (defmacro gnus-article-mark (number)
2290 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2291 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2292 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2293 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2294 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2295 gnus-ancient-mark))))
2297 ;; Saving hidden threads.
2299 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2300 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2302 (defmacro gnus-save-hidden-threads (&rest forms)
2303 "Save hidden threads, eval FORMS, and restore the hidden threads."
2304 (let ((config (make-symbol "config")))
2305 `(let ((,config (gnus-hidden-threads-configuration)))
2309 (gnus-restore-hidden-threads-configuration ,config)))))
2311 (defun gnus-hidden-threads-configuration ()
2312 "Return the current hidden threads configuration."
2315 (goto-char (point-min))
2316 (while (search-forward "\r" nil t)
2317 (push (1- (point)) config))
2320 (defun gnus-restore-hidden-threads-configuration (config)
2321 "Restore hidden threads configuration from CONFIG."
2322 (let (point buffer-read-only)
2323 (while (setq point (pop config))
2324 (when (and (< point (point-max))
2326 (= (following-char) ?\n))
2327 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2329 ;; Various summary mode internalish functions.
2331 (defun gnus-mouse-pick-article (e)
2334 (gnus-summary-next-page nil t))
2336 (defun gnus-summary-setup-buffer (group)
2337 "Initialize summary buffer."
2338 (let ((buffer (concat "*Summary " group "*")))
2339 (if (get-buffer buffer)
2342 (setq gnus-summary-buffer (current-buffer))
2343 (not gnus-newsgroup-prepared))
2344 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2345 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
2346 (gnus-add-current-to-buffer-list)
2347 (gnus-summary-mode group)
2349 (gnus-carpal-setup-buffer 'summary))
2350 (unless gnus-single-article-buffer
2351 (make-local-variable 'gnus-article-buffer)
2352 (make-local-variable 'gnus-article-current)
2353 (make-local-variable 'gnus-original-article-buffer))
2354 (setq gnus-newsgroup-name group)
2357 (defun gnus-set-global-variables ()
2358 ;; Set the global equivalents of the summary buffer-local variables
2359 ;; to the latest values they had. These reflect the summary buffer
2360 ;; that was in action when the last article was fetched.
2361 (when (eq major-mode 'gnus-summary-mode)
2362 (setq gnus-summary-buffer (current-buffer))
2363 (let ((name gnus-newsgroup-name)
2364 (marked gnus-newsgroup-marked)
2365 (unread gnus-newsgroup-unreads)
2366 (headers gnus-current-headers)
2367 (data gnus-newsgroup-data)
2368 (summary gnus-summary-buffer)
2369 (article-buffer gnus-article-buffer)
2370 (original gnus-original-article-buffer)
2371 (gac gnus-article-current)
2372 (reffed gnus-reffed-article-number)
2373 (score-file gnus-current-score-file))
2375 (set-buffer gnus-group-buffer)
2376 (setq gnus-newsgroup-name name)
2377 (setq gnus-newsgroup-marked marked)
2378 (setq gnus-newsgroup-unreads unread)
2379 (setq gnus-current-headers headers)
2380 (setq gnus-newsgroup-data data)
2381 (setq gnus-article-current gac)
2382 (setq gnus-summary-buffer summary)
2383 (setq gnus-article-buffer article-buffer)
2384 (setq gnus-original-article-buffer original)
2385 (setq gnus-reffed-article-number reffed)
2386 (setq gnus-current-score-file score-file)
2387 ;; The article buffer also has local variables.
2388 (when (gnus-buffer-live-p gnus-article-buffer)
2389 (set-buffer gnus-article-buffer)
2390 (setq gnus-summary-buffer summary))))))
2392 (defun gnus-summary-article-unread-p (article)
2393 "Say whether ARTICLE is unread or not."
2394 (memq article gnus-newsgroup-unreads))
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 (old-pos (gnus-point-at-bol))
3049 current thread data)
3050 (if (not gnus-show-threads)
3051 (setq thread (list (car (gnus-id-to-thread id))))
3052 ;; Get the thread this article is part of.
3053 (setq thread (gnus-remove-thread id)))
3054 (setq current (save-excursion
3055 (and (zerop (forward-line -1))
3056 (gnus-summary-article-number))))
3057 ;; If this is a gathered thread, we have to go some re-gathering.
3058 (when (stringp (car thread))
3059 (let ((subject (car thread))
3061 (setq thread (cdr thread))
3063 (unless (memq (setq thr (gnus-id-to-thread
3065 (mail-header-id (caar thread)))))
3068 (setq thread (cdr thread)))
3069 ;; We now have all (unique) roots.
3070 (if (= (length roots) 1)
3071 ;; All the loose roots are now one solid root.
3072 (setq thread (car roots))
3073 (setq thread (cons subject (gnus-sort-threads roots))))))
3075 ;; We then insert this thread into the summary buffer.
3076 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3077 (if gnus-show-threads
3078 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3079 (gnus-summary-prepare-unthreaded thread))
3080 (setq data (nreverse gnus-newsgroup-data))
3081 (setq threads gnus-newsgroup-threads))
3082 ;; We splice the new data into the data structure.
3083 (gnus-data-enter-list current data (- (point) old-pos))
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 (pop thread)))
3205 (setq thread (reverse thread))
3207 (gnus-remove-thread-1 (pop thread)))
3208 (when (setq d (gnus-data-find number))
3209 (goto-char (gnus-data-pos d))
3212 (- (gnus-point-at-bol)
3214 (1+ (gnus-point-at-eol))
3215 (gnus-delete-line)))))))
3217 (defun gnus-sort-threads (threads)
3219 (if (not gnus-thread-sort-functions)
3221 (gnus-message 7 "Sorting threads...")
3223 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3224 (gnus-message 7 "Sorting threads...done"))))
3226 (defun gnus-sort-articles (articles)
3228 (when gnus-article-sort-functions
3229 (gnus-message 7 "Sorting articles...")
3231 (setq gnus-newsgroup-headers
3232 (sort articles (gnus-make-sort-function
3233 gnus-article-sort-functions)))
3234 (gnus-message 7 "Sorting articles...done"))))
3236 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3237 (defmacro gnus-thread-header (thread)
3238 ;; Return header of first article in THREAD.
3239 ;; Note that THREAD must never, ever be anything else than a variable -
3240 ;; using some other form will lead to serious barfage.
3241 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3242 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3243 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
3246 (defsubst gnus-article-sort-by-number (h1 h2)
3247 "Sort articles by article number."
3248 (< (mail-header-number h1)
3249 (mail-header-number h2)))
3251 (defun gnus-thread-sort-by-number (h1 h2)
3252 "Sort threads by root article number."
3253 (gnus-article-sort-by-number
3254 (gnus-thread-header h1) (gnus-thread-header h2)))
3256 (defsubst gnus-article-sort-by-lines (h1 h2)
3257 "Sort articles by article Lines header."
3258 (< (mail-header-lines h1)
3259 (mail-header-lines h2)))
3261 (defun gnus-thread-sort-by-lines (h1 h2)
3262 "Sort threads by root article Lines header."
3263 (gnus-article-sort-by-lines
3264 (gnus-thread-header h1) (gnus-thread-header h2)))
3266 (defsubst gnus-article-sort-by-author (h1 h2)
3267 "Sort articles by root author."
3269 (let ((extract (funcall
3270 gnus-extract-address-components
3271 (mail-header-from h1))))
3272 (or (car extract) (cdr extract)))
3273 (let ((extract (funcall
3274 gnus-extract-address-components
3275 (mail-header-from h2))))
3276 (or (car extract) (cdr extract)))))
3278 (defun gnus-thread-sort-by-author (h1 h2)
3279 "Sort threads by root author."
3280 (gnus-article-sort-by-author
3281 (gnus-thread-header h1) (gnus-thread-header h2)))
3283 (defsubst gnus-article-sort-by-subject (h1 h2)
3284 "Sort articles by root subject."
3286 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3287 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3289 (defun gnus-thread-sort-by-subject (h1 h2)
3290 "Sort threads by root subject."
3291 (gnus-article-sort-by-subject
3292 (gnus-thread-header h1) (gnus-thread-header h2)))
3294 (defsubst gnus-article-sort-by-date (h1 h2)
3295 "Sort articles by root article date."
3297 (gnus-date-get-time (mail-header-date h1))
3298 (gnus-date-get-time (mail-header-date h2))))
3300 (defun gnus-thread-sort-by-date (h1 h2)
3301 "Sort threads by root article date."
3302 (gnus-article-sort-by-date
3303 (gnus-thread-header h1) (gnus-thread-header h2)))
3305 (defsubst gnus-article-sort-by-score (h1 h2)
3306 "Sort articles by root article score.
3307 Unscored articles will be counted as having a score of zero."
3308 (> (or (cdr (assq (mail-header-number h1)
3309 gnus-newsgroup-scored))
3310 gnus-summary-default-score 0)
3311 (or (cdr (assq (mail-header-number h2)
3312 gnus-newsgroup-scored))
3313 gnus-summary-default-score 0)))
3315 (defun gnus-thread-sort-by-score (h1 h2)
3316 "Sort threads by root article score."
3317 (gnus-article-sort-by-score
3318 (gnus-thread-header h1) (gnus-thread-header h2)))
3320 (defun gnus-thread-sort-by-total-score (h1 h2)
3321 "Sort threads by the sum of all scores in the thread.
3322 Unscored articles will be counted as having a score of zero."
3323 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3325 (defun gnus-thread-total-score (thread)
3326 ;; This function find the total score of THREAD.
3327 (cond ((null thread)
3330 (if (stringp (car thread))
3331 (apply gnus-thread-score-function 0
3332 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3333 (gnus-thread-total-score-1 thread)))
3335 (gnus-thread-total-score-1 (list thread)))))
3337 (defun gnus-thread-total-score-1 (root)
3338 ;; This function find the total score of the thread below ROOT.
3339 (setq root (car root))
3340 (apply gnus-thread-score-function
3342 (mapcar 'gnus-thread-total-score
3343 (cdr (gnus-gethash (mail-header-id root)
3344 gnus-newsgroup-dependencies)))
3345 (when (> (mail-header-number root) 0)
3346 (list (or (cdr (assq (mail-header-number root)
3347 gnus-newsgroup-scored))
3348 gnus-summary-default-score 0))))
3349 (list gnus-summary-default-score)
3352 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3353 (defvar gnus-tmp-prev-subject nil)
3354 (defvar gnus-tmp-false-parent nil)
3355 (defvar gnus-tmp-root-expunged nil)
3356 (defvar gnus-tmp-dummy-line nil)
3358 (defun gnus-summary-prepare-threads (threads)
3359 "Prepare summary buffer from THREADS and indentation LEVEL.
3360 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3361 or a straight list of headers."
3362 (gnus-message 7 "Generating summary...")
3364 (setq gnus-newsgroup-threads threads)
3367 (let ((gnus-tmp-level 0)
3368 (default-score (or gnus-summary-default-score 0))
3369 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3370 thread number subject stack state gnus-tmp-gathered beg-match
3371 new-roots gnus-tmp-new-adopts thread-end
3372 gnus-tmp-header gnus-tmp-unread
3373 gnus-tmp-replied gnus-tmp-subject-or-nil
3374 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3375 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3376 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3378 (setq gnus-tmp-prev-subject nil)
3380 (if (vectorp (car threads))
3381 ;; If this is a straight (sic) list of headers, then a
3382 ;; threaded summary display isn't required, so we just create
3383 ;; an unthreaded one.
3384 (gnus-summary-prepare-unthreaded threads)
3386 ;; Do the threaded display.
3388 (while (or threads stack gnus-tmp-new-adopts new-roots)
3390 (if (and (= gnus-tmp-level 0)
3391 (not (setq gnus-tmp-dummy-line nil))
3394 (not gnus-tmp-false-parent)
3395 (or gnus-tmp-new-adopts new-roots))
3396 (if gnus-tmp-new-adopts
3397 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3398 thread (list (car gnus-tmp-new-adopts))
3399 gnus-tmp-header (caar thread)
3400 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3402 (setq thread (list (car new-roots))
3403 gnus-tmp-header (caar thread)
3404 new-roots (cdr new-roots))))
3407 ;; If there are some threads, we do them before the
3408 ;; threads on the stack.
3409 (setq thread threads
3410 gnus-tmp-header (caar thread))
3411 ;; There were no current threads, so we pop something off
3413 (setq state (car stack)
3414 gnus-tmp-level (car state)
3417 gnus-tmp-header (caar thread))))
3419 (setq gnus-tmp-false-parent nil)
3420 (setq gnus-tmp-root-expunged nil)
3421 (setq thread-end nil)
3423 (if (stringp gnus-tmp-header)
3424 ;; The header is a dummy root.
3426 ((eq gnus-summary-make-false-root 'adopt)
3427 ;; We let the first article adopt the rest.
3428 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3430 (setq gnus-tmp-gathered
3432 (lambda (h) (mail-header-number (car h)))
3435 (setq thread (cons (list (caar thread)
3438 (setq gnus-tmp-level -1
3439 gnus-tmp-false-parent t))
3440 ((eq gnus-summary-make-false-root 'empty)
3441 ;; We print adopted articles with empty subject fields.
3442 (setq gnus-tmp-gathered
3444 (lambda (h) (mail-header-number (car h)))
3447 (setq gnus-tmp-level -1))
3448 ((eq gnus-summary-make-false-root 'dummy)
3449 ;; We remember that we probably want to output a dummy
3451 (setq gnus-tmp-dummy-line gnus-tmp-header)
3452 (setq gnus-tmp-prev-subject gnus-tmp-header))
3454 ;; We do not make a root for the gathered
3455 ;; sub-threads at all.
3456 (setq gnus-tmp-level -1)))
3458 (setq number (mail-header-number gnus-tmp-header)
3459 subject (mail-header-subject gnus-tmp-header))
3462 ;; If the thread has changed subject, we might want to make
3463 ;; this subthread into a root.
3464 ((and (null gnus-thread-ignore-subject)
3465 (not (zerop gnus-tmp-level))
3466 gnus-tmp-prev-subject
3468 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3469 (setq new-roots (nconc new-roots (list (car thread)))
3471 gnus-tmp-header nil))
3472 ;; If the article lies outside the current limit,
3473 ;; then we do not display it.
3474 ((and (not (memq number gnus-newsgroup-limit))
3475 (not gnus-tmp-dummy-line))
3476 (setq gnus-tmp-gathered
3478 (lambda (h) (mail-header-number (car h)))
3481 (setq gnus-tmp-new-adopts (if (cdar thread)
3482 (append gnus-tmp-new-adopts
3484 gnus-tmp-new-adopts)
3486 gnus-tmp-header nil)
3487 (when (zerop gnus-tmp-level)
3488 (setq gnus-tmp-root-expunged t)))
3489 ;; Perhaps this article is to be marked as read?
3490 ((and gnus-summary-mark-below
3491 (< (or (cdr (assq number gnus-newsgroup-scored))
3493 gnus-summary-mark-below)
3494 ;; Don't touch sparse articles.
3495 (not (gnus-summary-article-sparse-p number))
3496 (not (gnus-summary-article-ancient-p number)))
3497 (setq gnus-newsgroup-unreads
3498 (delq number gnus-newsgroup-unreads))
3499 (if gnus-newsgroup-auto-expire
3500 (push number gnus-newsgroup-expirable)
3501 (push (cons number gnus-low-score-mark)
3502 gnus-newsgroup-reads))))
3504 (when gnus-tmp-header
3505 ;; We may have an old dummy line to output before this
3507 (when gnus-tmp-dummy-line
3508 (gnus-summary-insert-dummy-line
3509 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3510 (setq gnus-tmp-dummy-line nil))
3512 ;; Compute the mark.
3513 (setq gnus-tmp-unread (gnus-article-mark number))
3515 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3516 gnus-tmp-header gnus-tmp-level)
3517 gnus-newsgroup-data)
3519 ;; Actually insert the line.
3521 gnus-tmp-subject-or-nil
3523 ((and gnus-thread-ignore-subject
3524 gnus-tmp-prev-subject
3525 (not (inline (gnus-subject-equal
3526 gnus-tmp-prev-subject subject))))
3528 ((zerop gnus-tmp-level)
3529 (if (and (eq gnus-summary-make-false-root 'empty)
3530 (memq number gnus-tmp-gathered)
3531 gnus-tmp-prev-subject
3532 (inline (gnus-subject-equal
3533 gnus-tmp-prev-subject subject)))
3534 gnus-summary-same-subject
3536 (t gnus-summary-same-subject)))
3537 (if (and (eq gnus-summary-make-false-root 'adopt)
3538 (= gnus-tmp-level 1)
3539 (memq number gnus-tmp-gathered))
3540 (setq gnus-tmp-opening-bracket ?\<
3541 gnus-tmp-closing-bracket ?\>)
3542 (setq gnus-tmp-opening-bracket ?\[
3543 gnus-tmp-closing-bracket ?\]))
3545 gnus-tmp-indentation
3546 (aref gnus-thread-indent-array gnus-tmp-level)
3547 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3548 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3549 gnus-summary-default-score 0)
3551 (if (or (null gnus-summary-default-score)
3552 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3553 gnus-summary-zcore-fuzz))
3555 (if (< gnus-tmp-score gnus-summary-default-score)
3556 gnus-score-below-mark gnus-score-over-mark))
3558 (cond ((memq number gnus-newsgroup-processable)
3560 ((memq number gnus-newsgroup-cached)
3562 ((memq number gnus-newsgroup-replied)
3564 ((memq number gnus-newsgroup-saved)
3566 (t gnus-unread-mark))
3567 gnus-tmp-from (mail-header-from gnus-tmp-header)
3570 ((string-match "<[^>]+> *$" gnus-tmp-from)
3571 (setq beg-match (match-beginning 0))
3572 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3573 (substring gnus-tmp-from (1+ (match-beginning 0))
3574 (1- (match-end 0))))
3575 (substring gnus-tmp-from 0 beg-match)))
3576 ((string-match "(.+)" gnus-tmp-from)
3577 (substring gnus-tmp-from
3578 (1+ (match-beginning 0)) (1- (match-end 0))))
3580 (when (string= gnus-tmp-name "")
3581 (setq gnus-tmp-name gnus-tmp-from))
3582 (unless (numberp gnus-tmp-lines)
3583 (setq gnus-tmp-lines 0))
3584 (gnus-put-text-property
3586 (progn (eval gnus-summary-line-format-spec) (point))
3587 'gnus-number number)
3590 (run-hooks 'gnus-summary-update-hook)
3593 (setq gnus-tmp-prev-subject subject)))
3595 (when (nth 1 thread)
3596 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3597 (incf gnus-tmp-level)
3598 (setq threads (if thread-end nil (cdar thread)))
3600 (setq gnus-tmp-level 0)))))
3601 (gnus-message 7 "Generating summary...done"))
3603 (defun gnus-summary-prepare-unthreaded (headers)
3604 "Generate an unthreaded summary buffer based on HEADERS."
3605 (let (header number mark)
3608 ;; We may have to root out some bad articles...
3609 (when (memq (setq number (mail-header-number
3610 (setq header (pop headers))))
3611 gnus-newsgroup-limit)
3612 ;; Mark article as read when it has a low score.
3613 (when (and gnus-summary-mark-below
3614 (< (or (cdr (assq number gnus-newsgroup-scored))
3615 gnus-summary-default-score 0)
3616 gnus-summary-mark-below)
3617 (not (gnus-summary-article-ancient-p number)))
3618 (setq gnus-newsgroup-unreads
3619 (delq number gnus-newsgroup-unreads))
3620 (if gnus-newsgroup-auto-expire
3621 (push number gnus-newsgroup-expirable)
3622 (push (cons number gnus-low-score-mark)
3623 gnus-newsgroup-reads)))
3625 (setq mark (gnus-article-mark number))
3626 (push (gnus-data-make number mark (1+ (point)) header 0)
3627 gnus-newsgroup-data)
3628 (gnus-summary-insert-line
3630 mark (memq number gnus-newsgroup-replied)
3631 (memq number gnus-newsgroup-expirable)
3632 (mail-header-subject header) nil
3633 (cdr (assq number gnus-newsgroup-scored))
3634 (memq number gnus-newsgroup-processable))))))
3636 (defun gnus-select-newsgroup (group &optional read-all)
3637 "Select newsgroup GROUP.
3638 If READ-ALL is non-nil, all articles in the group are selected."
3639 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3640 (info (nth 2 entry))
3641 articles fetched-articles cached)
3643 (unless (gnus-check-server
3644 (setq gnus-current-select-method (gnus-find-method-for-group group)))
3645 (error "Couldn't open server"))
3647 (or (and entry (not (eq (car entry) t))) ; Either it's active...
3648 (gnus-activate-group group) ; Or we can activate it...
3649 (progn ; Or we bug out.
3650 (when (equal major-mode 'gnus-summary-mode)
3651 (kill-buffer (current-buffer)))
3652 (error "Couldn't request group %s: %s"
3653 group (gnus-status-message group))))
3655 (unless (gnus-request-group group t)
3656 (when (equal major-mode 'gnus-summary-mode)
3657 (kill-buffer (current-buffer)))
3658 (error "Couldn't request group %s: %s"
3659 group (gnus-status-message group)))
3661 (setq gnus-newsgroup-name group)
3662 (setq gnus-newsgroup-unselected nil)
3663 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
3665 ;; Adjust and set lists of article marks.
3667 (gnus-adjust-marked-articles info))
3669 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3670 (when (gnus-virtual-group-p group)
3671 (setq cached gnus-newsgroup-cached))
3673 (setq gnus-newsgroup-unreads
3674 (gnus-set-difference
3675 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
3676 gnus-newsgroup-dormant))
3678 (setq gnus-newsgroup-processable nil)
3680 (setq articles (gnus-articles-to-read group read-all))
3684 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
3686 ((eq articles 0) nil)
3688 ;; Init the dependencies hash table.
3689 (setq gnus-newsgroup-dependencies
3690 (gnus-make-hashtable (length articles)))
3691 ;; Retrieve the headers and read them in.
3692 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
3693 (setq gnus-newsgroup-headers
3695 (setq gnus-headers-retrieved-by
3696 (gnus-retrieve-headers
3697 articles gnus-newsgroup-name
3698 ;; We might want to fetch old headers, but
3699 ;; not if there is only 1 article.
3700 (and gnus-fetch-old-headers
3702 (not (eq gnus-fetch-old-headers 'some))
3703 (not (numberp gnus-fetch-old-headers)))
3704 (> (length articles) 1))))))
3705 (gnus-get-newsgroup-headers-xover articles)
3706 (gnus-get-newsgroup-headers)))
3707 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
3709 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3711 (setq gnus-newsgroup-cached cached))
3713 ;; Suppress duplicates?
3714 (when gnus-suppress-duplicates
3715 (gnus-dup-suppress-articles))
3717 ;; Set the initial limit.
3718 (setq gnus-newsgroup-limit (copy-sequence articles))
3719 ;; Remove canceled articles from the list of unread articles.
3720 (setq gnus-newsgroup-unreads
3721 (gnus-set-sorted-intersection
3722 gnus-newsgroup-unreads
3723 (setq fetched-articles
3724 (mapcar (lambda (headers) (mail-header-number headers))
3725 gnus-newsgroup-headers))))
3726 ;; Removed marked articles that do not exist.
3727 (gnus-update-missing-marks
3728 (gnus-sorted-complement fetched-articles articles))
3729 ;; We might want to build some more threads first.
3730 (and gnus-fetch-old-headers
3731 (eq gnus-headers-retrieved-by 'nov)
3732 (gnus-build-old-threads))
3733 ;; Check whether auto-expire is to be done in this group.
3734 (setq gnus-newsgroup-auto-expire
3735 (gnus-group-auto-expirable-p group))
3736 ;; Set up the article buffer now, if necessary.
3737 (unless gnus-single-article-buffer
3738 (gnus-article-setup-buffer))
3739 ;; First and last article in this newsgroup.
3740 (when gnus-newsgroup-headers
3741 (setq gnus-newsgroup-begin
3742 (mail-header-number (car gnus-newsgroup-headers))
3745 (gnus-last-element gnus-newsgroup-headers))))
3746 ;; GROUP is successfully selected.
3747 (or gnus-newsgroup-headers t)))))
3749 (defun gnus-articles-to-read (group read-all)
3750 ;; Find out what articles the user wants to read.
3752 ;; Select all articles if `read-all' is non-nil, or if there
3753 ;; are no unread articles.
3755 (and (zerop (length gnus-newsgroup-marked))
3756 (zerop (length gnus-newsgroup-unreads)))
3757 (eq (gnus-group-find-parameter group 'display)
3759 (gnus-uncompress-range (gnus-active group))
3760 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
3761 (copy-sequence gnus-newsgroup-unreads))
3763 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
3764 (scored (length scored-list))
3765 (number (length articles))
3766 (marked (+ (length gnus-newsgroup-marked)
3767 (length gnus-newsgroup-dormant)))
3775 ((and (or (<= scored marked) (= scored number))
3776 (numberp gnus-large-newsgroup)
3777 (> number gnus-large-newsgroup))
3781 "How many articles from %s (default %d): "
3782 gnus-newsgroup-name number))))
3783 (if (string-match "^[ \t]*$" input) number input)))
3784 ((and (> scored marked) (< scored number)
3785 (> (- scored number) 20))
3788 (format "%s %s (%d scored, %d total): "
3789 "How many articles from"
3790 group scored number))))
3791 (if (string-match "^[ \t]*$" input)
3795 (setq select (if (stringp select) (string-to-number select) select))
3796 (if (or (null select) (zerop select))
3798 (if (and (not (zerop scored)) (<= (abs select) scored))
3800 (setq articles (sort scored-list '<))
3801 (setq number (length articles)))
3802 (setq articles (copy-sequence articles)))
3804 (when (< (abs select) number)
3806 ;; Select the N oldest articles.
3807 (setcdr (nthcdr (1- (abs select)) articles) nil)
3808 ;; Select the N most recent articles.
3809 (setq articles (nthcdr (- number select) articles))))
3810 (setq gnus-newsgroup-unselected
3811 (gnus-sorted-intersection
3812 gnus-newsgroup-unreads
3813 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
3816 (defun gnus-killed-articles (killed articles)
3819 (when (inline (gnus-member-of-range (car articles) killed))
3820 (push (car articles) out))
3821 (setq articles (cdr articles)))
3824 (defun gnus-uncompress-marks (marks)
3825 "Uncompress the mark ranges in MARKS."
3826 (let ((uncompressed '(score bookmark))
3829 (if (memq (caar marks) uncompressed)
3830 (push (car marks) out)
3831 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
3832 (setq marks (cdr marks)))
3835 (defun gnus-adjust-marked-articles (info)
3836 "Set all article lists and remove all marks that are no longer legal."
3837 (let* ((marked-lists (gnus-info-marks info))
3838 (active (gnus-active (gnus-info-group info)))
3841 (types gnus-article-mark-lists)
3842 (uncompressed '(score bookmark killed))
3843 marks var articles article mark)
3846 (setq marks (pop marked-lists))
3847 (set (setq var (intern (format "gnus-newsgroup-%s"
3848 (car (rassq (setq mark (car marks))
3850 (if (memq (car marks) uncompressed) (cdr marks)
3851 (gnus-uncompress-range (cdr marks))))
3853 (setq articles (symbol-value var))
3855 ;; All articles have to be subsets of the active articles.
3857 ;; Adjust "simple" lists.
3858 ((memq mark '(tick dormant expirable reply save))
3860 (when (or (< (setq article (pop articles)) min) (> article max))
3861 (set var (delq article (symbol-value var))))))
3863 ((memq mark uncompressed)
3865 (when (or (not (consp (setq article (pop articles))))
3866 (< (car article) min)
3867 (> (car article) max))
3868 (set var (delq article (symbol-value var))))))))))
3870 (defun gnus-update-missing-marks (missing)
3871 "Go through the list of MISSING articles and remove them mark lists."
3873 (let ((types gnus-article-mark-lists)
3875 ;; Go through all types.
3877 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
3878 (when (symbol-value var)
3879 ;; This list has articles. So we delete all missing articles
3883 (set var (delq (pop m) (symbol-value var)))))))))
3885 (defun gnus-update-marks ()
3886 "Enter the various lists of marked articles into the newsgroup info list."
3887 (let ((types gnus-article-mark-lists)
3888 (info (gnus-get-info gnus-newsgroup-name))
3889 (uncompressed '(score bookmark killed))
3890 type list newmarked symbol)
3892 ;; Add all marks lists that are non-nil to the list of marks lists.
3894 (setq type (pop types))
3895 (when (setq list (symbol-value
3897 (intern (format "gnus-newsgroup-%s"
3899 (push (cons (cdr type)
3900 (if (memq (cdr type) uncompressed) list
3901 (gnus-compress-sequence
3902 (set symbol (sort list '<)) t)))
3905 ;; Enter these new marks into the info of the group.
3907 (setcar (nthcdr 3 info) newmarked)
3908 ;; Add the marks lists to the end of the info.
3910 (setcdr (nthcdr 2 info) (list newmarked))))
3912 ;; Cut off the end of the info if there's nothing else there.
3916 (when (nthcdr (decf i) info)
3917 (setcdr (nthcdr i info) nil)))))))
3919 (defun gnus-set-mode-line (where)
3920 "This function sets the mode line of the article or summary buffers.
3921 If WHERE is `summary', the summary mode line format will be used."
3922 ;; Is this mode line one we keep updated?
3923 (when (memq where gnus-updated-mode-lines)
3926 ;; We evaluate this in the summary buffer since these
3927 ;; variables are buffer-local to that buffer.
3928 (set-buffer gnus-summary-buffer)
3929 ;; We bind all these variables that are used in the `eval' form
3931 (let* ((mformat (symbol-value
3933 (format "gnus-%s-mode-line-format-spec" where))))
3934 (gnus-tmp-group-name gnus-newsgroup-name)
3935 (gnus-tmp-article-number (or gnus-current-article 0))
3936 (gnus-tmp-unread gnus-newsgroup-unreads)
3937 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
3938 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
3939 (gnus-tmp-unread-and-unselected
3940 (cond ((and (zerop gnus-tmp-unread-and-unticked)
3941 (zerop gnus-tmp-unselected))
3943 ((zerop gnus-tmp-unselected)
3944 (format "{%d more}" gnus-tmp-unread-and-unticked))
3945 (t (format "{%d(+%d) more}"
3946 gnus-tmp-unread-and-unticked
3947 gnus-tmp-unselected))))
3949 (if (and gnus-current-headers
3950 (vectorp gnus-current-headers))
3951 (gnus-mode-string-quote
3952 (mail-header-subject gnus-current-headers))
3955 gnus-tmp-header);; passed as argument to any user-format-funcs
3956 (setq mode-string (eval mformat))
3957 (setq max-len (max 4 (if gnus-mode-non-string-length
3959 gnus-mode-non-string-length)
3960 (length mode-string))))
3961 ;; We might have to chop a bit of the string off...
3962 (when (> (length mode-string) max-len)
3964 (concat (gnus-truncate-string mode-string (- max-len 3))
3966 ;; Pad the mode string a bit.
3967 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
3968 ;; Update the mode line.
3969 (setq mode-line-buffer-identification
3970 (gnus-mode-line-buffer-identification
3971 (list mode-string)))
3972 (set-buffer-modified-p t))))
3974 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
3975 "Go through the HEADERS list and add all Xrefs to a hash table.
3976 The resulting hash table is returned, or nil if no Xrefs were found."
3977 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
3978 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
3979 (xref-hashtb (make-vector 63 0))
3980 start group entry number xrefs header)
3982 (setq header (pop headers))
3983 (when (and (setq xrefs (mail-header-xref header))
3984 (not (memq (setq number (mail-header-number header))
3987 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
3988 (setq start (match-end 0))
3989 (setq group (if prefix
3990 (concat prefix (substring xrefs (match-beginning 1)
3992 (substring xrefs (match-beginning 1) (match-end 1))))
3994 (string-to-int (substring xrefs (match-beginning 2)
3996 (if (setq entry (gnus-gethash group xref-hashtb))
3997 (setcdr entry (cons number (cdr entry)))
3998 (gnus-sethash group (cons number nil) xref-hashtb)))))
3999 (and start xref-hashtb)))
4001 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4002 "Look through all the headers and mark the Xrefs as read."
4003 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4004 name entry info xref-hashtb idlist method nth4)
4006 (set-buffer gnus-group-buffer)
4007 (when (setq xref-hashtb
4008 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4011 (unless (string= from-newsgroup (setq name (symbol-name group)))
4012 (setq idlist (symbol-value group))
4013 ;; Dead groups are not updated.
4015 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4017 (when (stringp (setq nth4 (gnus-info-method info)))
4018 (setq nth4 (gnus-server-to-method nth4))))
4019 ;; Only do the xrefs if the group has the same
4020 ;; select method as the group we have just read.
4021 (or (gnus-methods-equal-p
4022 nth4 (gnus-find-method-for-group from-newsgroup))
4024 (equal nth4 (setq method (gnus-find-method-for-group
4026 (and (equal (car nth4) (car method))
4027 (equal (nth 1 nth4) (nth 1 method))))
4028 gnus-use-cross-reference
4029 (or (not (eq gnus-use-cross-reference t))
4031 ;; Only do cross-references on subscribed
4032 ;; groups, if that is what is wanted.
4033 (<= (gnus-info-level info) gnus-level-subscribed))
4034 (gnus-group-make-articles-read name idlist))))
4037 (defun gnus-group-make-articles-read (group articles)
4038 "Update the info of GROUP to say that only ARTICLES are unread."
4040 (entry (gnus-gethash group gnus-newsrc-hashtb))
4041 (info (nth 2 entry))
4042 (active (gnus-active group))
4044 ;; First peel off all illegal article numbers.
4046 (let ((ids articles)
4048 (while (setq id (pop ids))
4049 (when (and first (> id (cdr active)))
4050 ;; We'll end up in this situation in one particular
4051 ;; obscure situation. If you re-scan a group and get
4052 ;; a new article that is cross-posted to a different
4053 ;; group that has not been re-scanned, you might get
4054 ;; crossposted article that has a higher number than
4055 ;; Gnus believes possible. So we re-activate this
4056 ;; group as well. This might mean doing the
4057 ;; crossposting thingy will *increase* the number
4058 ;; of articles in some groups. Tsk, tsk.
4059 (setq active (or (gnus-activate-group group) active)))
4060 (when (or (> id (cdr active))
4061 (< id (car active)))
4062 (setq articles (delq id articles))))))
4064 (set-buffer gnus-group-buffer)
4067 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4068 (gnus-info-set-read ',info ',(gnus-info-read info))
4069 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4070 (gnus-group-update-group ,group t))))
4071 ;; If the read list is nil, we init it.
4073 (null (gnus-info-read info))
4075 (gnus-info-set-read info (cons 1 (1- (car active)))))
4076 ;; Then we add the read articles to the range.
4081 (gnus-info-read info) (setq articles (sort articles '<)))))
4082 ;; Then we have to re-compute how many unread
4083 ;; articles there are in this group.
4087 (setq num (- (1+ (cdr active)) (car active))))
4088 ((not (listp (cdr range)))
4089 (setq num (- (cdr active) (- (1+ (cdr range))
4093 (if (numberp (car range))
4095 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4096 (setq range (cdr range)))
4097 (setq num (- (cdr active) num))))
4098 ;; Update the number of unread articles.
4100 ;; Update the group buffer.
4101 (gnus-group-update-group group t))))
4103 (defun gnus-methods-equal-p (m1 m2)
4104 (let ((m1 (or m1 gnus-select-method))
4105 (m2 (or m2 gnus-select-method)))
4107 (and (eq (car m1) (car m2))
4108 (or (not (memq 'address (assoc (symbol-name (car m1))
4109 gnus-valid-select-methods)))
4110 (equal (nth 1 m1) (nth 1 m2)))))))
4112 (defvar gnus-newsgroup-none-id 0)
4114 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4115 (let ((cur nntp-server-buffer)
4118 (save-excursion (set-buffer gnus-summary-buffer)
4119 gnus-newsgroup-dependencies)))
4120 headers id id-dep ref-dep end ref)
4122 (set-buffer nntp-server-buffer)
4123 ;; Translate all TAB characters into SPACE characters.
4124 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4125 (run-hooks 'gnus-parse-headers-hook)
4126 (let ((case-fold-search t)
4127 in-reply-to header p lines)
4128 (goto-char (point-min))
4129 ;; Search to the beginning of the next header. Error messages
4130 ;; do not begin with 2 or 3.
4131 (while (re-search-forward "^[23][0-9]+ " nil t)
4134 ;; This implementation of this function, with nine
4135 ;; search-forwards instead of the one re-search-forward and
4136 ;; a case (which basically was the old function) is actually
4137 ;; about twice as fast, even though it looks messier. You
4138 ;; can't have everything, I guess. Speed and elegance
4139 ;; doesn't always go hand in hand.
4148 (narrow-to-region (point)
4149 (or (and (search-forward "\n.\n" nil t)
4155 (if (search-forward "\nsubject: " nil t)
4156 (nnheader-header-value) "(none)"))
4160 (if (search-forward "\nfrom: " nil t)
4161 (nnheader-header-value) "(nobody)"))
4165 (if (search-forward "\ndate: " nil t)
4166 (nnheader-header-value) ""))
4170 (setq id (if (search-forward "\nmessage-id: " nil t)
4171 (nnheader-header-value)
4172 ;; If there was no message-id, we just fake one
4173 ;; to make subsequent routines simpler.
4174 (nnheader-generate-fake-message-id))))
4178 (if (search-forward "\nreferences: " nil t)
4182 (nnheader-header-value)
4187 (search-backward ">" end t)
4190 (search-backward "<" end t)
4192 ;; Get the references from the in-reply-to header if there
4193 ;; were no references and the in-reply-to header looks
4195 (if (and (search-forward "\nin-reply-to: " nil t)
4196 (setq in-reply-to (nnheader-header-value))
4197 (string-match "<[^>]+>" in-reply-to))
4198 (setq ref (substring in-reply-to (match-beginning 0)
4206 (if (search-forward "\nlines: " nil t)
4207 (if (numberp (setq lines (read cur)))
4213 (and (search-forward "\nxref: " nil t)
4214 (nnheader-header-value)))))
4215 (when (equal id ref)
4217 ;; We do the threading while we read the headers. The
4218 ;; message-id and the last reference are both entered into
4219 ;; the same hash table. Some tippy-toeing around has to be
4220 ;; done in case an article has arrived before the article
4221 ;; which it refers to.
4222 (if (boundp (setq id-dep (intern id dependencies)))
4223 (if (and (car (symbol-value id-dep))
4225 ;; An article with this Message-ID has already
4226 ;; been seen, so we ignore this one, except we add
4227 ;; any additional Xrefs (in case the two articles
4228 ;; came from different servers).
4230 (mail-header-set-xref
4231 (car (symbol-value id-dep))
4232 (concat (or (mail-header-xref
4233 (car (symbol-value id-dep)))
4235 (or (mail-header-xref header) "")))
4237 (setcar (symbol-value id-dep) header))
4238 (set id-dep (list header)))
4240 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
4241 (setcdr (symbol-value ref-dep)
4242 (nconc (cdr (symbol-value ref-dep))
4243 (list (symbol-value id-dep))))
4244 (set ref-dep (list nil (symbol-value id-dep))))
4245 (push header headers))
4246 (goto-char (point-max))
4248 (nreverse headers)))))
4250 ;; The following macros and functions were written by Felix Lee
4251 ;; <flee@cse.psu.edu>.
4253 (defmacro gnus-nov-read-integer ()
4255 (if (= (following-char) ?\t)
4257 (let ((num (ignore-errors (read buffer))))
4258 (if (numberp num) num 0)))
4262 (defmacro gnus-nov-skip-field ()
4263 '(search-forward "\t" eol 'move))
4265 (defmacro gnus-nov-field ()
4266 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
4268 ;; (defvar gnus-nov-none-counter 0)
4270 ;; This function has to be called with point after the article number
4271 ;; on the beginning of the line.
4272 (defun gnus-nov-parse-line (number dependencies &optional force-new)
4273 (let ((eol (gnus-point-at-eol))
4274 (buffer (current-buffer))
4275 header ref id id-dep ref-dep)
4277 ;; overview: [num subject from date id refs chars lines misc]
4278 (narrow-to-region (point) eol)
4285 (gnus-nov-field) ; subject
4286 (gnus-nov-field) ; from
4287 (gnus-nov-field) ; date
4288 (setq id (or (gnus-nov-field)
4289 (nnheader-generate-fake-message-id))) ; id
4291 (let ((beg (point)))
4292 (search-forward "\t" eol)
4293 (if (search-backward ">" beg t)
4297 (search-backward "<" beg t)))
4300 (gnus-nov-field)) ; refs
4301 (gnus-nov-read-integer) ; chars
4302 (gnus-nov-read-integer) ; lines
4303 (if (= (following-char) ?\n)
4305 (gnus-nov-field)) ; misc
4310 ;; We build the thread tree.
4311 (when (equal id ref)
4312 ;; This article refers back to itself. Naughty, naughty.
4314 (if (boundp (setq id-dep (intern id dependencies)))
4315 (if (and (car (symbol-value id-dep))
4317 ;; An article with this Message-ID has already been seen,
4318 ;; so we ignore this one, except we add any additional
4319 ;; Xrefs (in case the two articles came from different
4322 (mail-header-set-xref
4323 (car (symbol-value id-dep))
4324 (concat (or (mail-header-xref
4325 (car (symbol-value id-dep)))
4327 (or (mail-header-xref header) "")))
4329 (setcar (symbol-value id-dep) header))
4330 (set id-dep (list header)))
4332 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
4333 (setcdr (symbol-value ref-dep)
4334 (nconc (cdr (symbol-value ref-dep))
4335 (list (symbol-value id-dep))))
4336 (set ref-dep (list nil (symbol-value id-dep)))))
4339 ;; Goes through the xover lines and returns a list of vectors
4340 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4341 force-new dependencies)
4342 "Parse the news overview data in the server buffer, and return a
4343 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4344 ;; Get the Xref when the users reads the articles since most/some
4345 ;; NNTP servers do not include Xrefs when using XOVER.
4346 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4347 (let ((cur nntp-server-buffer)
4348 (dependencies (or dependencies gnus-newsgroup-dependencies))
4349 number headers header)
4351 (set-buffer nntp-server-buffer)
4352 ;; Allow the user to mangle the headers before parsing them.
4353 (run-hooks 'gnus-parse-headers-hook)
4354 (goto-char (point-min))
4357 (while (and sequence (not (eobp)))
4358 (setq number (read cur))
4359 (while (and sequence
4360 (< (car sequence) number))
4361 (setq sequence (cdr sequence)))
4363 (eq number (car sequence))
4365 (setq sequence (cdr sequence))
4366 (setq header (inline
4367 (gnus-nov-parse-line
4368 number dependencies force-new))))
4369 (push header headers))
4372 (gnus-error 4 "Strange nov line")))
4374 (nreverse headers))))
4376 (defun gnus-article-get-xrefs ()
4377 "Fill in the Xref value in `gnus-current-headers', if necessary.
4378 This is meant to be called in `gnus-article-internal-prepare-hook'."
4379 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4380 gnus-current-headers)))
4381 (or (not gnus-use-cross-reference)
4383 (and (mail-header-xref headers)
4384 (not (string= (mail-header-xref headers) "")))
4385 (let ((case-fold-search t)
4388 (nnheader-narrow-to-headers)
4389 (goto-char (point-min))
4390 (when (or (and (eq (downcase (following-char)) ?x)
4391 (looking-at "Xref:"))
4392 (search-forward "\nXref:" nil t))
4393 (goto-char (1+ (match-end 0)))
4394 (setq xref (buffer-substring (point)
4395 (progn (end-of-line) (point))))
4396 (mail-header-set-xref headers xref)))))))
4398 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4399 "Find article ID and insert the summary line for that article."
4400 (let ((header (if (and old-header use-old-header)
4401 old-header (gnus-read-header id)))
4402 (number (and (numberp id) id))
4405 ;; Rebuild the thread that this article is part of and go to the
4406 ;; article we have fetched.
4407 (when (and (not gnus-show-threads)
4409 (when (setq d (gnus-data-find (mail-header-number old-header)))
4410 (goto-char (gnus-data-pos d))
4413 (- (gnus-point-at-bol)
4415 (1+ (gnus-point-at-eol))
4416 (gnus-delete-line))))))
4418 (mail-header-set-number header (mail-header-number old-header)))
4419 (setq gnus-newsgroup-sparse
4420 (delq (setq number (mail-header-number header))
4421 gnus-newsgroup-sparse))
4422 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4423 (gnus-rebuild-thread (mail-header-id header))
4424 (gnus-summary-goto-subject number nil t))
4425 (when (and (numberp number)
4427 ;; We have to update the boundaries even if we can't fetch the
4428 ;; article if ID is a number -- so that the next `P' or `N'
4429 ;; command will fetch the previous (or next) article even
4430 ;; if the one we tried to fetch this time has been canceled.
4431 (when (> number gnus-newsgroup-end)
4432 (setq gnus-newsgroup-end number))
4433 (when (< number gnus-newsgroup-begin)
4434 (setq gnus-newsgroup-begin number))
4435 (setq gnus-newsgroup-unselected
4436 (delq number gnus-newsgroup-unselected)))
4437 ;; Report back a success?
4438 (and header (mail-header-number header))))
4440 ;;; Process/prefix in the summary buffer
4442 (defun gnus-summary-work-articles (n)
4443 "Return a list of articles to be worked upon. The prefix argument,
4444 the list of process marked articles, and the current article will be
4445 taken into consideration."
4448 ;; A numerical prefix has been given.
4449 (let ((backward (< n 0))
4450 (n (abs (prefix-numeric-value n)))
4455 (push (setq article (gnus-summary-article-number))
4458 (gnus-summary-find-prev nil article)
4459 (gnus-summary-find-next nil article)))
4461 (nreverse articles)))
4462 ((and (boundp 'transient-mark-mode)
4465 ;; Work on the region between point and mark.
4466 (let ((max (max (point) (mark)))
4469 (goto-char (min (point) (mark)))
4472 (push (setq article (gnus-summary-article-number)) articles)
4473 (gnus-summary-find-next nil article)
4475 (nreverse articles))))
4476 (gnus-newsgroup-processable
4477 ;; There are process-marked articles present.
4478 ;; Save current state.
4479 (gnus-summary-save-process-mark)
4481 (reverse gnus-newsgroup-processable))
4483 ;; Just return the current article.
4484 (list (gnus-summary-article-number)))))
4486 (defun gnus-summary-save-process-mark ()
4487 "Push the current set of process marked articles on the stack."
4489 (push (copy-sequence gnus-newsgroup-processable)
4490 gnus-newsgroup-process-stack))
4492 (defun gnus-summary-kill-process-mark ()
4493 "Push the current set of process marked articles on the stack and unmark."
4495 (gnus-summary-save-process-mark)
4496 (gnus-summary-unmark-all-processable))
4498 (defun gnus-summary-yank-process-mark ()
4499 "Pop the last process mark state off the stack and restore it."
4501 (unless gnus-newsgroup-process-stack
4502 (error "Empty mark stack"))
4503 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4505 (defun gnus-summary-process-mark-set (set)
4506 "Make SET into the current process marked articles."
4507 (gnus-summary-unmark-all-processable)
4509 (gnus-summary-set-process-mark (pop set))))
4511 ;;; Searching and stuff
4513 (defun gnus-summary-search-group (&optional backward use-level)
4514 "Search for next unread newsgroup.
4515 If optional argument BACKWARD is non-nil, search backward instead."
4517 (set-buffer gnus-group-buffer)
4518 (when (gnus-group-search-forward
4519 backward nil (if use-level (gnus-group-group-level) nil))
4520 (gnus-group-group-name))))
4522 (defun gnus-summary-best-group (&optional exclude-group)
4523 "Find the name of the best unread group.
4524 If EXCLUDE-GROUP, do not go to this group."
4526 (set-buffer gnus-group-buffer)
4528 (gnus-group-best-unread-group exclude-group))))
4530 (defun gnus-summary-find-next (&optional unread article backward)
4531 (if backward (gnus-summary-find-prev)
4532 (let* ((dummy (gnus-summary-article-intangible-p))
4533 (article (or article (gnus-summary-article-number)))
4534 (arts (gnus-data-find-list article))
4536 (when (and (not dummy)
4537 (or (not gnus-summary-check-current)
4539 (not (gnus-data-unread-p (car arts)))))
4540 (setq arts (cdr arts)))
4545 (when (gnus-data-unread-p (car arts))
4546 (setq result (car arts)
4548 (setq arts (cdr arts)))
4551 (goto-char (gnus-data-pos result))
4552 (gnus-data-number result)))))
4554 (defun gnus-summary-find-prev (&optional unread article)
4555 (let* ((eobp (eobp))
4556 (article (or article (gnus-summary-article-number)))
4557 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
4559 (when (and (not eobp)
4560 (or (not gnus-summary-check-current)
4562 (not (gnus-data-unread-p (car arts)))))
4563 (setq arts (cdr arts)))
4568 (when (gnus-data-unread-p (car arts))
4569 (setq result (car arts)
4571 (setq arts (cdr arts)))
4574 (goto-char (gnus-data-pos result))
4575 (gnus-data-number result))))
4577 (defun gnus-summary-find-subject (subject &optional unread backward article)
4578 (let* ((simp-subject (gnus-simplify-subject-fully subject))
4579 (article (or article (gnus-summary-article-number)))
4580 (articles (gnus-data-list backward))
4581 (arts (gnus-data-find-list article articles))
4583 (when (or (not gnus-summary-check-current)
4585 (not (gnus-data-unread-p (car arts))))
4586 (setq arts (cdr arts)))
4588 (and (or (not unread)
4589 (gnus-data-unread-p (car arts)))
4590 (vectorp (gnus-data-header (car arts)))
4592 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
4593 (setq result (car arts)
4595 (setq arts (cdr arts)))
4597 (goto-char (gnus-data-pos result))
4598 (gnus-data-number result))))
4600 (defun gnus-summary-search-forward (&optional unread subject backward)
4601 "Search forward for an article.
4602 If UNREAD, look for unread articles. If SUBJECT, look for
4603 articles with that subject. If BACKWARD, search backward instead."
4604 (cond (subject (gnus-summary-find-subject subject unread backward))
4605 (backward (gnus-summary-find-prev unread))
4606 (t (gnus-summary-find-next unread))))
4608 (defun gnus-recenter (&optional n)
4609 "Center point in window and redisplay frame.
4610 Also do horizontal recentering."
4612 (when (and gnus-auto-center-summary
4613 (not (eq gnus-auto-center-summary 'vertical)))
4614 (gnus-horizontal-recenter))
4617 (defun gnus-summary-recenter ()
4618 "Center point in the summary window.
4619 If `gnus-auto-center-summary' is nil, or the article buffer isn't
4620 displayed, no centering will be performed."
4621 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
4622 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
4623 (let* ((top (cond ((< (window-height) 4) 0)
4624 ((< (window-height) 7) 1)
4626 (height (1- (window-height)))
4627 (bottom (save-excursion (goto-char (point-max))
4628 (forward-line (- height))
4630 (window (get-buffer-window (current-buffer))))
4631 ;; The user has to want it.
4632 (when gnus-auto-center-summary
4633 (when (get-buffer-window gnus-article-buffer)
4634 ;; Only do recentering when the article buffer is displayed,
4635 ;; Set the window start to either `bottom', which is the biggest
4636 ;; possible valid number, or the second line from the top,
4637 ;; whichever is the least.
4639 window (min bottom (save-excursion
4640 (forward-line (- top)) (point)))))
4641 ;; Do horizontal recentering while we're at it.
4642 (when (and (get-buffer-window (current-buffer) t)
4643 (not (eq gnus-auto-center-summary 'vertical)))
4644 (let ((selected (selected-window)))
4645 (select-window (get-buffer-window (current-buffer) t))
4646 (gnus-summary-position-point)
4647 (gnus-horizontal-recenter)
4648 (select-window selected))))))
4650 (defun gnus-summary-jump-to-group (newsgroup)
4651 "Move point to NEWSGROUP in group mode buffer."
4652 ;; Keep update point of group mode buffer if visible.
4653 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
4654 (save-window-excursion
4655 ;; Take care of tree window mode.
4656 (when (get-buffer-window gnus-group-buffer)
4657 (pop-to-buffer gnus-group-buffer))
4658 (gnus-group-jump-to-group newsgroup))
4660 ;; Take care of tree window mode.
4661 (if (get-buffer-window gnus-group-buffer)
4662 (pop-to-buffer gnus-group-buffer)
4663 (set-buffer gnus-group-buffer))
4664 (gnus-group-jump-to-group newsgroup))))
4666 ;; This function returns a list of article numbers based on the
4667 ;; difference between the ranges of read articles in this group and
4668 ;; the range of active articles.
4669 (defun gnus-list-of-unread-articles (group)
4670 (let* ((read (gnus-info-read (gnus-get-info group)))
4671 (active (or (gnus-active group) (gnus-activate-group group)))
4674 ;; If none are read, then all are unread.
4676 (setq first (car active))
4677 ;; If the range of read articles is a single range, then the
4678 ;; first unread article is the article after the last read
4679 ;; article. Sounds logical, doesn't it?
4680 (if (not (listp (cdr read)))
4681 (setq first (1+ (cdr read)))
4682 ;; `read' is a list of ranges.
4683 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
4689 (while (< first nlast)
4691 (setq first (1+ first))))
4692 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
4693 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
4694 (setq read (cdr read)))))
4695 ;; And add the last unread articles.
4696 (while (<= first last)
4698 (setq first (1+ first)))
4699 ;; Return the list of unread articles.
4702 (defun gnus-list-of-read-articles (group)
4703 "Return a list of unread, unticked and non-dormant articles."
4704 (let* ((info (gnus-get-info group))
4705 (marked (gnus-info-marks info))
4706 (active (gnus-active group)))
4708 (gnus-set-difference
4709 (gnus-sorted-complement
4710 (gnus-uncompress-range active)
4711 (gnus-list-of-unread-articles group))
4713 (gnus-uncompress-range (cdr (assq 'dormant marked)))
4714 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
4716 ;; Various summary commands
4718 (defun gnus-summary-universal-argument (arg)
4719 "Perform any operation on all articles that are process/prefixed."
4721 (gnus-set-global-variables)
4722 (let ((articles (gnus-summary-work-articles arg))
4729 (substitute-command-keys
4730 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
4733 (gnus-error 1 "Undefined key")
4736 (gnus-summary-goto-subject (setq article (pop articles)))
4737 (let (gnus-newsgroup-processable)
4738 (command-execute func))
4739 (gnus-summary-remove-process-mark article)))))
4740 (gnus-summary-position-point))
4742 (defun gnus-summary-toggle-truncation (&optional arg)
4743 "Toggle truncation of summary lines.
4744 With arg, turn line truncation on iff arg is positive."
4746 (setq truncate-lines
4747 (if (null arg) (not truncate-lines)
4748 (> (prefix-numeric-value arg) 0)))
4751 (defun gnus-summary-reselect-current-group (&optional all rescan)
4752 "Exit and then reselect the current newsgroup.
4753 The prefix argument ALL means to select all articles."
4755 (gnus-set-global-variables)
4756 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
4757 (error "Ephemeral groups can't be reselected"))
4758 (let ((current-subject (gnus-summary-article-number))
4759 (group gnus-newsgroup-name))
4760 (setq gnus-newsgroup-begin nil)
4762 ;; We have to adjust the point of group mode buffer because the
4763 ;; current point was moved to the next unread newsgroup by
4765 (gnus-summary-jump-to-group group)
4768 (gnus-group-get-new-news-this-group 1)))
4769 (gnus-group-read-group all t)
4770 (gnus-summary-goto-subject current-subject nil t)))
4772 (defun gnus-summary-rescan-group (&optional all)
4773 "Exit the newsgroup, ask for new articles, and select the newsgroup."
4775 (gnus-summary-reselect-current-group all t))
4777 (defun gnus-summary-update-info ()
4778 (let ((group gnus-newsgroup-name))
4779 (when gnus-newsgroup-kill-headers
4780 (setq gnus-newsgroup-killed
4781 (gnus-compress-sequence
4783 (gnus-set-sorted-intersection
4784 (gnus-uncompress-range gnus-newsgroup-killed)
4785 (setq gnus-newsgroup-unselected
4786 (sort gnus-newsgroup-unselected '<)))
4787 (setq gnus-newsgroup-unreads
4788 (sort gnus-newsgroup-unreads '<)))
4790 (unless (listp (cdr gnus-newsgroup-killed))
4791 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
4792 (let ((headers gnus-newsgroup-headers))
4793 (run-hooks 'gnus-exit-group-hook)
4794 (unless gnus-save-score
4795 (setq gnus-newsgroup-scored nil))
4796 ;; Set the new ranges of read articles.
4797 (gnus-update-read-articles
4798 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
4799 ;; Set the current article marks.
4801 ;; Do the cross-ref thing.
4802 (when gnus-use-cross-reference
4803 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
4804 ;; Do adaptive scoring, and possibly save score files.
4805 (when gnus-newsgroup-adaptive
4806 (gnus-score-adaptive))
4807 (when gnus-use-scoring
4809 ;; Do not switch windows but change the buffer to work.
4810 (set-buffer gnus-group-buffer)
4811 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
4812 (gnus-group-update-group group)))))
4814 (defun gnus-summary-exit (&optional temporary)
4815 "Exit reading current newsgroup, and then return to group selection mode.
4816 gnus-exit-group-hook is called with no arguments if that value is non-nil."
4818 (gnus-set-global-variables)
4819 (gnus-kill-save-kill-buffer)
4820 (let* ((group gnus-newsgroup-name)
4821 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
4823 (buf (current-buffer)))
4824 (run-hooks 'gnus-summary-prepare-exit-hook)
4825 ;; If we have several article buffers, we kill them at exit.
4826 (unless gnus-single-article-buffer
4827 (gnus-kill-buffer gnus-original-article-buffer)
4828 (setq gnus-article-current nil))
4829 (when gnus-use-cache
4830 (gnus-cache-possibly-remove-articles)
4831 (gnus-cache-save-buffers))
4832 (gnus-async-prefetch-remove-group group)
4833 (when gnus-suppress-duplicates
4834 (gnus-dup-enter-articles))
4835 (when gnus-use-trees
4836 (gnus-tree-close group))
4837 ;; Make all changes in this group permanent.
4839 (gnus-summary-update-info))
4840 (gnus-close-group group)
4841 ;; Make sure where I was, and go to next newsgroup.
4842 (set-buffer gnus-group-buffer)
4844 (gnus-group-jump-to-group group))
4845 (run-hooks 'gnus-summary-exit-hook)
4847 (gnus-group-next-unread-group 1))
4850 ;; If we have several article buffers, we kill them at exit.
4851 (unless gnus-single-article-buffer
4852 (gnus-kill-buffer gnus-article-buffer)
4853 (gnus-kill-buffer gnus-original-article-buffer)
4854 (setq gnus-article-current nil))
4856 (if (not gnus-kill-summary-on-exit)
4857 (gnus-deaden-summary)
4858 ;; We set all buffer-local variables to nil. It is unclear why
4859 ;; this is needed, but if we don't, buffer-local variables are
4860 ;; not garbage-collected, it seems. This would the lead to en
4861 ;; ever-growing Emacs.
4862 (gnus-summary-clear-local-variables)
4863 (when (get-buffer gnus-article-buffer)
4864 (bury-buffer gnus-article-buffer))
4865 ;; We clear the global counterparts of the buffer-local
4866 ;; variables as well, just to be on the safe side.
4867 (set-buffer gnus-group-buffer)
4868 (gnus-summary-clear-local-variables)
4869 ;; Return to group mode buffer.
4870 (when (eq mode 'gnus-summary-mode)
4871 (gnus-kill-buffer buf)))
4872 (setq gnus-current-select-method gnus-select-method)
4873 (pop-to-buffer gnus-group-buffer)
4874 ;; Clear the current group name.
4875 (if (not quit-config)
4877 (gnus-group-jump-to-group group)
4878 (gnus-group-next-unread-group 1)
4879 (gnus-configure-windows 'group 'force))
4880 (gnus-handle-ephemeral-exit quit-config))
4882 (setq gnus-newsgroup-name nil)))))
4884 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
4885 (defun gnus-summary-exit-no-update (&optional no-questions)
4886 "Quit reading current newsgroup without updating read article info."
4888 (gnus-set-global-variables)
4889 (let* ((group gnus-newsgroup-name)
4890 (quit-config (gnus-group-quit-config group)))
4891 (when (or no-questions
4893 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
4894 ;; If we have several article buffers, we kill them at exit.
4895 (unless gnus-single-article-buffer
4896 (gnus-kill-buffer gnus-article-buffer)
4897 (gnus-kill-buffer gnus-original-article-buffer)
4898 (setq gnus-article-current nil))
4899 (if (not gnus-kill-summary-on-exit)
4900 (gnus-deaden-summary)
4901 (gnus-close-group group)
4902 (gnus-summary-clear-local-variables)
4903 (set-buffer gnus-group-buffer)
4904 (gnus-summary-clear-local-variables)
4905 (when (get-buffer gnus-summary-buffer)
4906 (kill-buffer gnus-summary-buffer)))
4907 (unless gnus-single-article-buffer
4908 (setq gnus-article-current nil))
4909 (when gnus-use-trees
4910 (gnus-tree-close group))
4911 (gnus-async-prefetch-remove-group group)
4912 (when (get-buffer gnus-article-buffer)
4913 (bury-buffer gnus-article-buffer))
4914 ;; Return to the group buffer.
4915 (gnus-configure-windows 'group 'force)
4916 ;; Clear the current group name.
4917 (setq gnus-newsgroup-name nil)
4918 (when (equal (gnus-group-group-name) group)
4919 (gnus-group-next-unread-group 1))
4921 (gnus-handle-ephemeral-exit quit-config)))))
4923 (defun gnus-handle-ephemeral-exit (quit-config)
4924 "Handle movement when leaving an ephemeral group. The state
4925 which existed when entering the ephemeral is reset."
4926 (if (not (buffer-name (car quit-config)))
4927 (gnus-configure-windows 'group 'force)
4928 (set-buffer (car quit-config))
4929 (cond ((eq major-mode 'gnus-summary-mode)
4930 (gnus-set-global-variables))
4931 ((eq major-mode 'gnus-article-mode)
4933 ;; The `gnus-summary-buffer' variable may point
4934 ;; to the old summary buffer when using a single
4936 (unless (gnus-buffer-live-p gnus-summary-buffer)
4937 (set-buffer gnus-group-buffer))
4938 (set-buffer gnus-summary-buffer)
4939 (gnus-set-global-variables))))
4940 (if (or (eq (cdr quit-config) 'article)
4941 (eq (cdr quit-config) 'pick))
4943 ;; The current article may be from the ephemeral group
4944 ;; thus it is best that we reload this article
4945 (gnus-summary-show-article)
4946 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
4947 (gnus-configure-windows 'pick 'force)
4948 (gnus-configure-windows (cdr quit-config) 'force)))
4949 (gnus-configure-windows (cdr quit-config) 'force))
4950 (when (eq major-mode 'gnus-summary-mode)
4951 (gnus-summary-next-subject 1 nil t)
4952 (gnus-summary-recenter)
4953 (gnus-summary-position-point))))
4957 (defvar gnus-dead-summary-mode-map nil)
4959 (unless gnus-dead-summary-mode-map
4960 (setq gnus-dead-summary-mode-map (make-keymap))
4961 (suppress-keymap gnus-dead-summary-mode-map)
4962 (substitute-key-definition
4963 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
4964 (let ((keys '("\C-d" "\r" "\177")))
4966 (define-key gnus-dead-summary-mode-map
4967 (pop keys) 'gnus-summary-wake-up-the-dead))))
4969 (defvar gnus-dead-summary-mode nil
4970 "Minor mode for Gnus summary buffers.")
4972 (defun gnus-dead-summary-mode (&optional arg)
4973 "Minor mode for Gnus summary buffers."
4975 (when (eq major-mode 'gnus-summary-mode)
4976 (make-local-variable 'gnus-dead-summary-mode)
4977 (setq gnus-dead-summary-mode
4978 (if (null arg) (not gnus-dead-summary-mode)
4979 (> (prefix-numeric-value arg) 0)))
4980 (when gnus-dead-summary-mode
4981 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
4982 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
4983 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
4984 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
4985 minor-mode-map-alist)))))
4987 (defun gnus-deaden-summary ()
4988 "Make the current summary buffer into a dead summary buffer."
4989 ;; Kill any previous dead summary buffer.
4990 (when (and gnus-dead-summary
4991 (buffer-name gnus-dead-summary))
4993 (set-buffer gnus-dead-summary)
4994 (when gnus-dead-summary-mode
4995 (kill-buffer (current-buffer)))))
4996 ;; Make this the current dead summary.
4997 (setq gnus-dead-summary (current-buffer))
4998 (gnus-dead-summary-mode 1)
4999 (let ((name (buffer-name)))
5000 (when (string-match "Summary" name)
5002 (concat (substring name 0 (match-beginning 0)) "Dead "
5003 (substring name (match-beginning 0)))
5006 (defun gnus-kill-or-deaden-summary (buffer)
5007 "Kill or deaden the summary BUFFER."
5008 (when (and (buffer-name buffer)
5009 (not gnus-single-article-buffer))
5012 (gnus-kill-buffer gnus-article-buffer)
5013 (gnus-kill-buffer gnus-original-article-buffer)))
5014 (cond (gnus-kill-summary-on-exit
5015 (when (and gnus-use-trees
5016 (and (get-buffer buffer)
5017 (buffer-name (get-buffer buffer))))
5019 (set-buffer (get-buffer buffer))
5020 (gnus-tree-close gnus-newsgroup-name)))
5021 (gnus-kill-buffer buffer))
5022 ((and (get-buffer buffer)
5023 (buffer-name (get-buffer buffer)))
5026 (gnus-deaden-summary)))))
5028 (defun gnus-summary-wake-up-the-dead (&rest args)
5029 "Wake up the dead summary buffer."
5031 (gnus-dead-summary-mode -1)
5032 (let ((name (buffer-name)))
5033 (when (string-match "Dead " name)
5035 (concat (substring name 0 (match-beginning 0))
5036 (substring name (match-end 0)))
5038 (gnus-message 3 "This dead summary is now alive again"))
5040 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5041 (defun gnus-summary-fetch-faq (&optional faq-dir)
5042 "Fetch the FAQ for the current group.
5043 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5047 (when current-prefix-arg
5049 "Faq dir: " (and (listp gnus-group-faq-directory)
5050 gnus-group-faq-directory)))))
5051 (let (gnus-faq-buffer)
5052 (when (setq gnus-faq-buffer
5053 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5054 (gnus-configure-windows 'summary-faq))))
5056 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5057 (defun gnus-summary-describe-group (&optional force)
5058 "Describe the current newsgroup."
5060 (gnus-group-describe-group force gnus-newsgroup-name))
5062 (defun gnus-summary-describe-briefly ()
5063 "Describe summary mode commands briefly."
5066 (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")))
5068 ;; Walking around group mode buffer from summary mode.
5070 (defun gnus-summary-next-group (&optional no-article target-group backward)
5071 "Exit current newsgroup and then select next unread newsgroup.
5072 If prefix argument NO-ARTICLE is non-nil, no article is selected
5073 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5074 previous group instead."
5076 (gnus-set-global-variables)
5077 ;; Stop pre-fetching.
5078 (gnus-async-halt-prefetch)
5079 (let ((current-group gnus-newsgroup-name)
5080 (current-buffer (current-buffer))
5082 ;; First we semi-exit this group to update Xrefs and all variables.
5083 ;; We can't do a real exit, because the window conf must remain
5084 ;; the same in case the user is prompted for info, and we don't
5085 ;; want the window conf to change before that...
5086 (gnus-summary-exit t)
5087 (while (not entered)
5088 ;; Then we find what group we are supposed to enter.
5089 (set-buffer gnus-group-buffer)
5090 (gnus-group-jump-to-group current-group)
5093 (if (eq gnus-keep-same-level 'best)
5094 (gnus-summary-best-group gnus-newsgroup-name)
5095 (gnus-summary-search-group backward gnus-keep-same-level))))
5096 (if (not target-group)
5097 ;; There are no further groups, so we return to the group
5100 (gnus-message 5 "Returning to the group buffer")
5102 (set-buffer current-buffer)
5104 (run-hooks 'gnus-group-no-more-groups-hook))
5105 ;; We try to enter the target group.
5106 (gnus-group-jump-to-group target-group)
5107 (let ((unreads (gnus-group-group-unread)))
5108 (if (and (or (eq t unreads)
5109 (and unreads (not (zerop unreads))))
5110 (gnus-summary-read-group
5111 target-group nil no-article current-buffer))
5113 (setq current-group target-group
5114 target-group nil)))))))
5116 (defun gnus-summary-prev-group (&optional no-article)
5117 "Exit current newsgroup and then select previous unread newsgroup.
5118 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5120 (gnus-summary-next-group no-article nil t))
5122 ;; Walking around summary lines.
5124 (defun gnus-summary-first-subject (&optional unread)
5125 "Go to the first unread subject.
5126 If UNREAD is non-nil, go to the first unread article.
5127 Returns the article selected or nil if there are no unread articles."
5132 ((null gnus-newsgroup-data)
5133 (gnus-message 3 "No articles in the group")
5135 ;; Pick the first article.
5137 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5138 (gnus-data-number (car gnus-newsgroup-data)))
5139 ;; No unread articles.
5140 ((null gnus-newsgroup-unreads)
5141 (gnus-message 3 "No more unread articles")
5143 ;; Find the first unread article.
5145 (let ((data gnus-newsgroup-data))
5147 (not (gnus-data-unread-p (car data))))
5148 (setq data (cdr data)))
5150 (goto-char (gnus-data-pos (car data)))
5151 (gnus-data-number (car data))))))
5152 (gnus-summary-position-point)))
5154 (defun gnus-summary-next-subject (n &optional unread dont-display)
5155 "Go to next N'th summary line.
5156 If N is negative, go to the previous N'th subject line.
5157 If UNREAD is non-nil, only unread articles are selected.
5158 The difference between N and the actual number of steps taken is
5161 (let ((backward (< n 0))
5165 (gnus-summary-find-prev unread)
5166 (gnus-summary-find-next unread)))
5169 (gnus-message 7 "No more%s articles"
5170 (if unread " unread" "")))
5171 (unless dont-display
5172 (gnus-summary-recenter)
5173 (gnus-summary-position-point))
5176 (defun gnus-summary-next-unread-subject (n)
5177 "Go to next N'th unread summary line."
5179 (gnus-summary-next-subject n t))
5181 (defun gnus-summary-prev-subject (n &optional unread)
5182 "Go to previous N'th summary line.
5183 If optional argument UNREAD is non-nil, only unread article is selected."
5185 (gnus-summary-next-subject (- n) unread))
5187 (defun gnus-summary-prev-unread-subject (n)
5188 "Go to previous N'th unread summary line."
5190 (gnus-summary-next-subject (- n) t))
5192 (defun gnus-summary-goto-subject (article &optional force silent)
5193 "Go the subject line of ARTICLE.
5194 If FORCE, also allow jumping to articles not currently shown."
5195 (interactive "nArticle number: ")
5197 (data (gnus-data-find article)))
5198 ;; We read in the article if we have to.
5201 (gnus-summary-insert-subject article (and (vectorp force) force) t)
5202 (setq data (gnus-data-find article)))
5207 (gnus-message 3 "Can't find article %d" article))
5209 (goto-char (gnus-data-pos data))
5212 ;; Walking around summary lines with displaying articles.
5214 (defun gnus-summary-expand-window (&optional arg)
5215 "Make the summary buffer take up the entire Emacs frame.
5216 Given a prefix, will force an `article' buffer configuration."
5218 (gnus-set-global-variables)
5220 (gnus-configure-windows 'article 'force)
5221 (gnus-configure-windows 'summary 'force)))
5223 (defun gnus-summary-display-article (article &optional all-header)
5224 "Display ARTICLE in article buffer."
5225 (gnus-set-global-variables)
5229 (if gnus-summary-display-article-function
5230 (funcall gnus-summary-display-article-function article all-header)
5231 (gnus-article-prepare article all-header))
5232 (run-hooks 'gnus-select-article-hook)
5233 (when (and gnus-current-article
5234 (not (zerop gnus-current-article)))
5235 (gnus-summary-goto-subject gnus-current-article))
5236 (gnus-summary-recenter)
5237 (when (and gnus-use-trees gnus-show-threads)
5238 (gnus-possibly-generate-tree article)
5239 (gnus-highlight-selected-tree article))
5240 ;; Successfully display article.
5241 (gnus-article-set-window-start
5242 (cdr (assq article gnus-newsgroup-bookmarks))))))
5244 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5245 "Select the current article.
5246 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5247 non-nil, the article will be re-fetched even if it already present in
5248 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5250 ;; Make sure we are in the summary buffer to work around bbdb bug.
5251 (unless (eq major-mode 'gnus-summary-mode)
5252 (set-buffer gnus-summary-buffer))
5253 (let ((article (or article (gnus-summary-article-number)))
5254 (all-headers (not (not all-headers))) ;Must be T or NIL.
5255 gnus-summary-display-article-function
5258 (gnus-summary-article-pseudo-p article)
5259 (error "This is a pseudo-article."))
5262 (set-buffer gnus-summary-buffer)
5263 (if (or (and gnus-single-article-buffer
5264 (or (null gnus-current-article)
5265 (null gnus-article-current)
5266 (null (get-buffer gnus-article-buffer))
5267 (not (eq article (cdr gnus-article-current)))
5268 (not (equal (car gnus-article-current)
5269 gnus-newsgroup-name))))
5270 (and (not gnus-single-article-buffer)
5271 (or (null gnus-current-article)
5272 (not (eq gnus-current-article article))))
5274 ;; The requested article is different from the current article.
5276 (gnus-summary-display-article article all-headers)
5278 (when (or all-headers gnus-show-all-headers)
5279 (gnus-article-show-all-headers))
5282 (gnus-article-set-window-start
5283 (cdr (assq article gnus-newsgroup-bookmarks)))))))
5285 (defun gnus-summary-set-current-mark (&optional current-mark)
5286 "Obsolete function."
5289 (defun gnus-summary-next-article (&optional unread subject backward push)
5290 "Select the next article.
5291 If UNREAD, only unread articles are selected.
5292 If SUBJECT, only articles with SUBJECT are selected.
5293 If BACKWARD, the previous article is selected instead of the next."
5295 (gnus-set-global-variables)
5297 ;; Is there such an article?
5298 ((and (gnus-summary-search-forward unread subject backward)
5299 (or (gnus-summary-display-article (gnus-summary-article-number))
5300 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5301 (gnus-summary-position-point))
5302 ;; If not, we try the first unread, if that is wanted.
5304 gnus-auto-select-same
5305 ;; Make sure that we don't select the current article.
5306 (not (eq (gnus-summary-article-number)
5308 (gnus-summary-first-subject t)
5309 (gnus-summary-article-number))))
5310 (gnus-summary-first-unread-article))
5311 (gnus-summary-position-point)
5312 (gnus-message 6 "Wrapped"))
5313 ;; Try to get next/previous article not displayed in this group.
5314 ((and gnus-auto-extend-newsgroup
5315 (not unread) (not subject))
5316 (gnus-summary-goto-article
5317 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5319 ;; Go to next/previous group.
5321 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5322 (gnus-summary-jump-to-group gnus-newsgroup-name))
5323 (let ((cmd last-command-char)
5325 (if (eq gnus-keep-same-level 'best)
5326 (gnus-summary-best-group gnus-newsgroup-name)
5327 (gnus-summary-search-group backward gnus-keep-same-level))))
5328 ;; For some reason, the group window gets selected. We change
5330 (select-window (get-buffer-window (current-buffer)))
5331 ;; Select next unread newsgroup automagically.
5333 ((or (not gnus-auto-select-next)
5335 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5336 ((or (eq gnus-auto-select-next 'quietly)
5337 (and (eq gnus-auto-select-next 'slightly-quietly)
5339 (and (eq gnus-auto-select-next 'almost-quietly)
5340 (gnus-summary-last-article-p)))
5342 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5344 (gnus-message 7 "No more%s articles (%s)..."
5345 (if unread " unread" "")
5346 (if group (concat "selecting " group)
5348 (gnus-summary-next-group nil group backward)))
5350 (when (gnus-key-press-event-p last-input-event)
5351 (gnus-summary-walk-group-buffer
5352 gnus-newsgroup-name cmd unread backward))))))))
5354 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
5355 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5356 (?\C-p (gnus-group-prev-unread-group 1))))
5357 (cursor-in-echo-area t)
5358 keve key group ended)
5360 (set-buffer gnus-group-buffer)
5361 (gnus-summary-jump-to-group from-group)
5363 (if (eq gnus-keep-same-level 'best)
5364 (gnus-summary-best-group gnus-newsgroup-name)
5365 (gnus-summary-search-group backward gnus-keep-same-level))))
5368 5 "No more%s articles%s" (if unread " unread" "")
5370 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5371 (format " (Type %s for %s [%s])"
5372 (single-key-description cmd) group
5373 (car (gnus-gethash group gnus-newsrc-hashtb)))
5374 (format " (Type %s to exit %s)"
5375 (single-key-description cmd)
5376 gnus-newsgroup-name)))
5377 ;; Confirm auto selection.
5378 (setq key (car (setq keve (gnus-read-event-char))))
5381 ((assq key keystrokes)
5382 (let ((obuf (current-buffer)))
5383 (switch-to-buffer gnus-group-buffer)
5385 (gnus-group-jump-to-group group))
5386 (eval (cadr (assq key keystrokes)))
5387 (setq group (gnus-group-group-name))
5388 (switch-to-buffer obuf))
5392 (gnus-ephemeral-group-p gnus-newsgroup-name))
5394 (gnus-summary-next-group nil group backward)))
5396 (push (cdr keve) unread-command-events))))))
5398 (defun gnus-summary-next-unread-article ()
5399 "Select unread article after current one."
5401 (gnus-summary-next-article
5402 (or (not (eq gnus-summary-goto-unread 'never))
5403 (gnus-summary-last-article-p (gnus-summary-article-number)))
5404 (and gnus-auto-select-same
5405 (gnus-summary-article-subject))))
5407 (defun gnus-summary-prev-article (&optional unread subject)
5408 "Select the article after the current one.
5409 If UNREAD is non-nil, only unread articles are selected."
5411 (gnus-summary-next-article unread subject t))
5413 (defun gnus-summary-prev-unread-article ()
5414 "Select unread article before current one."
5416 (gnus-summary-prev-article
5417 (or (not (eq gnus-summary-goto-unread 'never))
5418 (gnus-summary-first-article-p (gnus-summary-article-number)))
5419 (and gnus-auto-select-same
5420 (gnus-summary-article-subject))))
5422 (defun gnus-summary-next-page (&optional lines circular)
5423 "Show next page of the selected article.
5424 If at the end of the current article, select the next article.
5425 LINES says how many lines should be scrolled up.
5427 If CIRCULAR is non-nil, go to the start of the article instead of
5428 selecting the next article when reaching the end of the current
5431 (setq gnus-summary-buffer (current-buffer))
5432 (gnus-set-global-variables)
5433 (let ((article (gnus-summary-article-number))
5435 (gnus-configure-windows 'article)
5436 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
5437 (if (and (eq gnus-summary-goto-unread 'never)
5438 (not (gnus-summary-last-article-p article)))
5439 (gnus-summary-next-article)
5440 (gnus-summary-next-unread-article))
5441 (if (or (null gnus-current-article)
5442 (null gnus-article-current)
5443 (/= article (cdr gnus-article-current))
5444 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5445 ;; Selected subject is different from current article's.
5446 (gnus-summary-display-article article)
5447 (gnus-eval-in-buffer-window gnus-article-buffer
5448 (setq endp (gnus-article-next-page lines)))
5451 (gnus-summary-beginning-of-article))
5453 (gnus-message 3 "End of message"))
5455 (if (and (eq gnus-summary-goto-unread 'never)
5456 (not (gnus-summary-last-article-p article)))
5457 (gnus-summary-next-article)
5458 (gnus-summary-next-unread-article)))))))
5459 (gnus-summary-recenter)
5460 (gnus-summary-position-point)))
5462 (defun gnus-summary-prev-page (&optional lines)
5463 "Show previous page of selected article.
5464 Argument LINES specifies lines to be scrolled down."
5466 (gnus-set-global-variables)
5467 (let ((article (gnus-summary-article-number)))
5468 (gnus-configure-windows 'article)
5469 (if (or (null gnus-current-article)
5470 (null gnus-article-current)
5471 (/= article (cdr gnus-article-current))
5472 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5473 ;; Selected subject is different from current article's.
5474 (gnus-summary-display-article article)
5475 (gnus-summary-recenter)
5476 (gnus-eval-in-buffer-window gnus-article-buffer
5477 (gnus-article-prev-page lines))))
5478 (gnus-summary-position-point))
5480 (defun gnus-summary-scroll-up (lines)
5481 "Scroll up (or down) one line current article.
5482 Argument LINES specifies lines to be scrolled up (or down if negative)."
5484 (gnus-set-global-variables)
5485 (gnus-configure-windows 'article)
5486 (gnus-summary-show-thread)
5487 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
5488 (gnus-eval-in-buffer-window gnus-article-buffer
5490 (when (gnus-article-next-page lines)
5491 (gnus-message 3 "End of message")))
5493 (gnus-article-prev-page (- lines))))))
5494 (gnus-summary-recenter)
5495 (gnus-summary-position-point))
5497 (defun gnus-summary-next-same-subject ()
5498 "Select next article which has the same subject as current one."
5500 (gnus-set-global-variables)
5501 (gnus-summary-next-article nil (gnus-summary-article-subject)))
5503 (defun gnus-summary-prev-same-subject ()
5504 "Select previous article which has the same subject as current one."
5506 (gnus-set-global-variables)
5507 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
5509 (defun gnus-summary-next-unread-same-subject ()
5510 "Select next unread article which has the same subject as current one."
5512 (gnus-set-global-variables)
5513 (gnus-summary-next-article t (gnus-summary-article-subject)))
5515 (defun gnus-summary-prev-unread-same-subject ()
5516 "Select previous unread article which has the same subject as current one."
5518 (gnus-set-global-variables)
5519 (gnus-summary-prev-article t (gnus-summary-article-subject)))
5521 (defun gnus-summary-first-unread-article ()
5522 "Select the first unread article.
5523 Return nil if there are no unread articles."
5525 (gnus-set-global-variables)
5527 (when (gnus-summary-first-subject t)
5528 (gnus-summary-show-thread)
5529 (gnus-summary-first-subject t)
5530 (gnus-summary-display-article (gnus-summary-article-number)))
5531 (gnus-summary-position-point)))
5533 (defun gnus-summary-first-article ()
5534 "Select the first article.
5535 Return nil if there are no articles."
5537 (gnus-set-global-variables)
5539 (when (gnus-summary-first-subject)
5540 (gnus-summary-show-thread)
5541 (gnus-summary-first-subject)
5542 (gnus-summary-display-article (gnus-summary-article-number)))
5543 (gnus-summary-position-point)))
5545 (defun gnus-summary-best-unread-article ()
5546 "Select the unread article with the highest score."
5548 (gnus-set-global-variables)
5549 (let ((best -1000000)
5550 (data gnus-newsgroup-data)
5553 (and (gnus-data-unread-p (car data))
5555 (gnus-summary-article-score (gnus-data-number (car data))))
5558 article (gnus-data-number (car data))))
5559 (setq data (cdr data)))
5562 (gnus-summary-goto-article article)
5563 (error "No unread articles"))
5564 (gnus-summary-position-point))))
5566 (defun gnus-summary-last-subject ()
5567 "Go to the last displayed subject line in the group."
5568 (let ((article (gnus-data-number (car (gnus-data-list t)))))
5570 (gnus-summary-goto-subject article))))
5572 (defun gnus-summary-goto-article (article &optional all-headers force)
5573 "Fetch ARTICLE and display it if it exists.
5574 If ALL-HEADERS is non-nil, no header lines are hidden."
5580 (mapcar (lambda (number) (list (int-to-string number)))
5581 gnus-newsgroup-limit)))
5585 (if (gnus-summary-goto-subject article force)
5586 (gnus-summary-display-article article all-headers)
5587 (gnus-message 4 "Couldn't go to article %s" article) nil)
5588 (gnus-summary-position-point)))
5590 (defun gnus-summary-goto-last-article ()
5591 "Go to the previously read article."
5594 (when gnus-last-article
5595 (gnus-summary-goto-article gnus-last-article))
5596 (gnus-summary-position-point)))
5598 (defun gnus-summary-pop-article (number)
5599 "Pop one article off the history and go to the previous.
5600 NUMBER articles will be popped off."
5603 (setq gnus-newsgroup-history
5604 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
5606 (gnus-summary-goto-article (car to))
5607 (error "Article history empty")))
5608 (gnus-summary-position-point))
5610 ;; Summary commands and functions for limiting the summary buffer.
5612 (defun gnus-summary-limit-to-articles (n)
5613 "Limit the summary buffer to the next N articles.
5614 If not given a prefix, use the process marked articles instead."
5616 (gnus-set-global-variables)
5618 (let ((articles (gnus-summary-work-articles n)))
5619 (setq gnus-newsgroup-processable nil)
5620 (gnus-summary-limit articles))
5621 (gnus-summary-position-point)))
5623 (defun gnus-summary-pop-limit (&optional total)
5624 "Restore the previous limit.
5625 If given a prefix, remove all limits."
5627 (gnus-set-global-variables)
5629 (setq gnus-newsgroup-limits
5630 (list (mapcar (lambda (h) (mail-header-number h))
5631 gnus-newsgroup-headers))))
5632 (unless gnus-newsgroup-limits
5633 (error "No limit to pop"))
5635 (gnus-summary-limit nil 'pop)
5636 (gnus-summary-position-point)))
5638 (defun gnus-summary-limit-to-subject (subject &optional header)
5639 "Limit the summary buffer to articles that have subjects that match a regexp."
5640 (interactive "sRegexp: ")
5642 (setq header "subject"))
5643 (when (not (equal "" subject))
5645 (let ((articles (gnus-summary-find-matching
5646 (or header "subject") subject 'all)))
5648 (error "Found no matches for \"%s\"" subject))
5649 (gnus-summary-limit articles))
5650 (gnus-summary-position-point))))
5652 (defun gnus-summary-limit-to-author (from)
5653 "Limit the summary buffer to articles that have authors that match a regexp."
5654 (interactive "sRegexp: ")
5655 (gnus-summary-limit-to-subject from "from"))
5657 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5659 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5661 (defun gnus-summary-limit-to-unread (&optional all)
5662 "Limit the summary buffer to articles that are not marked as read.
5663 If ALL is non-nil, limit strictly to unread articles."
5666 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
5667 (gnus-summary-limit-to-marks
5668 ;; Concat all the marks that say that an article is read and have
5670 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
5671 gnus-killed-mark gnus-kill-file-mark
5672 gnus-low-score-mark gnus-expirable-mark
5673 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
5674 gnus-duplicate-mark)
5677 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
5678 (make-obsolete 'gnus-summary-delete-marked-with
5679 'gnus-summary-limit-exlude-marks)
5681 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
5682 "Exclude articles that are marked with MARKS (e.g. \"DK\").
5683 If REVERSE, limit the summary buffer to articles that are marked
5684 with MARKS. MARKS can either be a string of marks or a list of marks.
5685 Returns how many articles were removed."
5686 (interactive "sMarks: ")
5687 (gnus-summary-limit-to-marks marks t))
5689 (defun gnus-summary-limit-to-marks (marks &optional reverse)
5690 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
5691 If REVERSE (the prefix), limit the summary buffer to articles that are
5692 not marked with MARKS. MARKS can either be a string of marks or a
5694 Returns how many articles were removed."
5695 (interactive (list (read-string "Marks: ") current-prefix-arg))
5696 (gnus-set-global-variables)
5698 (let ((data gnus-newsgroup-data)
5699 (marks (if (listp marks) marks
5700 (append marks nil))) ; Transform to list.
5703 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
5704 (memq (gnus-data-mark (car data)) marks))
5705 (push (gnus-data-number (car data)) articles))
5706 (setq data (cdr data)))
5707 (gnus-summary-limit articles))
5708 (gnus-summary-position-point)))
5710 (defun gnus-summary-limit-to-score (&optional score)
5711 "Limit to articles with score at or above SCORE."
5713 (gnus-set-global-variables)
5714 (setq score (if score
5715 (prefix-numeric-value score)
5716 (or gnus-summary-default-score 0)))
5717 (let ((data gnus-newsgroup-data)
5720 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
5722 (push (gnus-data-number (car data)) articles))
5723 (setq data (cdr data)))
5725 (gnus-summary-limit articles)
5726 (gnus-summary-position-point))))
5728 (defun gnus-summary-limit-include-dormant ()
5729 "Display all the hidden articles that are marked as dormant."
5731 (gnus-set-global-variables)
5732 (unless gnus-newsgroup-dormant
5733 (error "There are no dormant articles in this group"))
5735 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
5736 (gnus-summary-position-point)))
5738 (defun gnus-summary-limit-exclude-dormant ()
5739 "Hide all dormant articles."
5741 (gnus-set-global-variables)
5743 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
5744 (gnus-summary-position-point)))
5746 (defun gnus-summary-limit-exclude-childless-dormant ()
5747 "Hide all dormant articles that have no children."
5749 (gnus-set-global-variables)
5750 (let ((data (gnus-data-list t))
5751 articles d children)
5752 ;; Find all articles that are either not dormant or have
5754 (while (setq d (pop data))
5755 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
5757 (gnus-article-children (gnus-data-number d)))
5760 (when (memq (car children) articles)
5765 (push (gnus-data-number d) articles)))
5768 (gnus-summary-limit articles)
5769 (gnus-summary-position-point))))
5771 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
5772 "Mark all unread excluded articles as read.
5773 If ALL, mark even excluded ticked and dormants as read."
5775 (let ((articles (gnus-sorted-complement
5777 (mapcar (lambda (h) (mail-header-number h))
5778 gnus-newsgroup-headers)
5780 (sort gnus-newsgroup-limit '<)))
5782 (setq gnus-newsgroup-unreads nil)
5784 (setq gnus-newsgroup-dormant nil
5785 gnus-newsgroup-marked nil
5786 gnus-newsgroup-reads
5788 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
5789 gnus-newsgroup-reads))
5790 (while (setq article (pop articles))
5791 (unless (or (memq article gnus-newsgroup-dormant)
5792 (memq article gnus-newsgroup-marked))
5793 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
5795 (defun gnus-summary-limit (articles &optional pop)
5797 ;; We pop the previous limit off the stack and use that.
5798 (setq articles (car gnus-newsgroup-limits)
5799 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
5800 ;; We use the new limit, so we push the old limit on the stack.
5801 (push gnus-newsgroup-limit gnus-newsgroup-limits))
5803 (setq gnus-newsgroup-limit articles)
5804 (let ((total (length gnus-newsgroup-data))
5805 (data (gnus-data-find-list (gnus-summary-article-number)))
5806 (gnus-summary-mark-below nil) ; Inhibit this.
5808 ;; This will do all the work of generating the new summary buffer
5809 ;; according to the new limit.
5810 (gnus-summary-prepare)
5811 ;; Hide any threads, possibly.
5812 (and gnus-show-threads
5813 gnus-thread-hide-subtree
5814 (gnus-summary-hide-all-threads))
5815 ;; Try to return to the article you were at, or one in the
5818 ;; We try to find some article after the current one.
5820 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
5823 (setq data (cdr data))))
5825 ;; If there is no data, that means that we were after the last
5826 ;; article. The same goes when we can't find any articles
5827 ;; after the current one.
5828 (goto-char (point-max))
5829 (gnus-summary-find-prev))
5830 ;; We return how many articles were removed from the summary
5831 ;; buffer as a result of the new limit.
5832 (- total (length gnus-newsgroup-data))))
5834 (defsubst gnus-invisible-cut-children (threads)
5837 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
5842 (defsubst gnus-cut-thread (thread)
5843 "Go forwards in the thread until we find an article that we want to display."
5844 (when (or (eq gnus-fetch-old-headers 'some)
5845 (eq gnus-build-sparse-threads 'some)
5846 (eq gnus-build-sparse-threads 'more))
5847 ;; Deal with old-fetched headers and sparse threads.
5851 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
5852 (gnus-summary-article-ancient-p
5853 (mail-header-number (car thread))))
5854 (or (<= (length (cdr thread)) 1)
5855 (gnus-invisible-cut-children (cdr thread))))
5856 (setq thread (cadr thread))))
5859 (defun gnus-cut-threads (threads)
5860 "Cut off all uninteresting articles from the beginning of threads."
5861 (when (or (eq gnus-fetch-old-headers 'some)
5862 (eq gnus-build-sparse-threads 'some)
5863 (eq gnus-build-sparse-threads 'more))
5866 (setcar th (gnus-cut-thread (car th)))
5867 (setq th (cdr th)))))
5868 ;; Remove nixed out threads.
5871 (defun gnus-summary-initial-limit (&optional show-if-empty)
5872 "Figure out what the initial limit is supposed to be on group entry.
5873 This entails weeding out unwanted dormants, low-scored articles,
5874 fetch-old-headers verbiage, and so on."
5875 ;; Most groups have nothing to remove.
5876 (if (or gnus-inhibit-limiting
5877 (and (null gnus-newsgroup-dormant)
5878 (not (eq gnus-fetch-old-headers 'some))
5879 (null gnus-summary-expunge-below)
5880 (not (eq gnus-build-sparse-threads 'some))
5881 (not (eq gnus-build-sparse-threads 'more))
5882 (null gnus-thread-expunge-below)
5883 (not gnus-use-nocem)))
5885 (push gnus-newsgroup-limit gnus-newsgroup-limits)
5886 (setq gnus-newsgroup-limit nil)
5889 (unless (car (symbol-value node))
5890 ;; These threads have no parents -- they are roots.
5891 (let ((nodes (cdr (symbol-value node)))
5894 (if (and gnus-thread-expunge-below
5895 (< (gnus-thread-total-score (car nodes))
5896 gnus-thread-expunge-below))
5897 (gnus-expunge-thread (pop nodes))
5898 (setq thread (pop nodes))
5899 (gnus-summary-limit-children thread))))))
5900 gnus-newsgroup-dependencies)
5901 ;; If this limitation resulted in an empty group, we might
5902 ;; pop the previous limit and use it instead.
5903 (when (and (not gnus-newsgroup-limit)
5905 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
5906 gnus-newsgroup-limit))
5908 (defun gnus-summary-limit-children (thread)
5909 "Return 1 if this subthread is visible and 0 if it is not."
5910 ;; First we get the number of visible children to this thread. This
5911 ;; is done by recursing down the thread using this function, so this
5912 ;; will really go down to a leaf article first, before slowly
5913 ;; working its way up towards the root.
5917 (apply '+ (mapcar 'gnus-summary-limit-children
5920 (number (mail-header-number (car thread)))
5923 (not (memq number gnus-newsgroup-marked))
5925 ;; If this article is dormant and has absolutely no visible
5926 ;; children, then this article isn't visible.
5927 (and (memq number gnus-newsgroup-dormant)
5929 ;; If this is "fetch-old-headered" and there is only one
5930 ;; visible child (or less), then we don't want this article.
5931 (and (eq gnus-fetch-old-headers 'some)
5932 (gnus-summary-article-ancient-p number)
5934 ;; If this is a sparsely inserted article with no children,
5935 ;; we don't want it.
5936 (and (eq gnus-build-sparse-threads 'some)
5937 (gnus-summary-article-sparse-p number)
5939 ;; If we use expunging, and this article is really
5940 ;; low-scored, then we don't want this article.
5941 (when (and gnus-summary-expunge-below
5943 (or (cdr (assq number gnus-newsgroup-scored))
5944 gnus-summary-default-score))
5945 gnus-summary-expunge-below))
5946 ;; We increase the expunge-tally here, but that has
5947 ;; nothing to do with the limits, really.
5948 (incf gnus-newsgroup-expunged-tally)
5949 ;; We also mark as read here, if that's wanted.
5950 (when (and gnus-summary-mark-below
5951 (< score gnus-summary-mark-below))
5952 (setq gnus-newsgroup-unreads
5953 (delq number gnus-newsgroup-unreads))
5954 (if gnus-newsgroup-auto-expire
5955 (push number gnus-newsgroup-expirable)
5956 (push (cons number gnus-low-score-mark)
5957 gnus-newsgroup-reads)))
5959 ;; Check NoCeM things.
5961 (gnus-nocem-unwanted-article-p
5962 (mail-header-id (car thread))))))
5963 ;; Nope, invisible article.
5965 ;; Ok, this article is to be visible, so we add it to the limit
5967 (push number gnus-newsgroup-limit)
5970 (defun gnus-expunge-thread (thread)
5971 "Mark all articles in THREAD as read."
5972 (let* ((number (mail-header-number (car thread))))
5973 (incf gnus-newsgroup-expunged-tally)
5974 ;; We also mark as read here, if that's wanted.
5975 (setq gnus-newsgroup-unreads
5976 (delq number gnus-newsgroup-unreads))
5977 (if gnus-newsgroup-auto-expire
5978 (push number gnus-newsgroup-expirable)
5979 (push (cons number gnus-low-score-mark)
5980 gnus-newsgroup-reads)))
5981 ;; Go recursively through all subthreads.
5982 (mapcar 'gnus-expunge-thread (cdr thread)))
5984 ;; Summary article oriented commands
5986 (defun gnus-summary-refer-parent-article (n)
5987 "Refer parent article N times.
5988 If N is negative, go to ancestor -N instead.
5989 The difference between N and the number of articles fetched is returned."
5991 (gnus-set-global-variables)
5994 (when (not (natnump n))
5999 (setq header (gnus-summary-article-header))
6001 ;; If we try to find the parent of the currently
6002 ;; displayed article, then we take a look at the actual
6003 ;; References header, since this is slightly more
6004 ;; reliable than the References field we got from the
6006 (if (and (eq (mail-header-number header)
6007 (cdr gnus-article-current))
6008 (equal gnus-newsgroup-name
6009 (car gnus-article-current)))
6011 (set-buffer gnus-original-article-buffer)
6012 (nnheader-narrow-to-headers)
6014 (message-fetch-field "references")
6016 ;; It's not the current article, so we take a bet on
6017 ;; the value we got from the server.
6018 (mail-header-references header)))
6020 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6021 (gnus-message 1 "Couldn't find parent"))
6022 (gnus-message 1 "No references in article %d"
6023 (gnus-summary-article-number))
6026 (gnus-summary-position-point)
6029 (defun gnus-summary-refer-references ()
6030 "Fetch all articles mentioned in the References header.
6031 Return how many articles were fetched."
6033 (gnus-set-global-variables)
6034 (let ((ref (mail-header-references (gnus-summary-article-header)))
6035 (current (gnus-summary-article-number))
6039 (error "No References in the current article")
6040 ;; For each Message-ID in the References header...
6041 (while (string-match "<[^>]*>" ref)
6043 ;; ... fetch that article.
6044 (gnus-summary-refer-article
6045 (prog1 (match-string 0 ref)
6046 (setq ref (substring ref (match-end 0))))))
6047 (gnus-summary-goto-subject current)
6048 (gnus-summary-position-point)
6051 (defun gnus-summary-refer-article (message-id)
6052 "Fetch an article specified by MESSAGE-ID."
6053 (interactive "sMessage-ID: ")
6054 (when (and (stringp message-id)
6055 (not (zerop (length message-id))))
6056 ;; Construct the correct Message-ID if necessary.
6057 ;; Suggested by tale@pawl.rpi.edu.
6058 (unless (string-match "^<" message-id)
6059 (setq message-id (concat "<" message-id)))
6060 (unless (string-match ">$" message-id)
6061 (setq message-id (concat message-id ">")))
6062 (let* ((header (gnus-id-to-header message-id))
6064 (gnus-summary-article-sparse-p
6065 (mail-header-number header)))))
6068 ;; The article is present in the buffer, to we just go to it.
6069 (gnus-summary-goto-article
6070 (mail-header-number header) nil header)
6072 (gnus-summary-update-article (mail-header-number header))))
6073 ;; We fetch the article
6074 (let ((gnus-override-method
6075 (and (gnus-news-group-p gnus-newsgroup-name)
6076 gnus-refer-article-method))
6078 ;; Start the special refer-article method, if necessary.
6079 (when (and gnus-refer-article-method
6080 (gnus-news-group-p gnus-newsgroup-name))
6081 (gnus-check-server gnus-refer-article-method))
6082 ;; Fetch the header, and display the article.
6083 (if (setq number (gnus-summary-insert-subject message-id))
6084 (gnus-summary-select-article nil nil nil number)
6085 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
6087 (defun gnus-summary-enter-digest-group (&optional force)
6088 "Enter an nndoc group based on the current article.
6089 If FORCE, force a digest interpretation. If not, try
6090 to guess what the document format is."
6092 (gnus-set-global-variables)
6093 (let ((conf gnus-current-window-configuration))
6095 (gnus-summary-select-article))
6096 (setq gnus-current-window-configuration conf)
6097 (let* ((name (format "%s-%d"
6098 (gnus-group-prefixed-name
6099 gnus-newsgroup-name (list 'nndoc ""))
6101 (set-buffer gnus-summary-buffer)
6102 gnus-current-article)))
6103 (ogroup gnus-newsgroup-name)
6104 (params (append (gnus-info-params (gnus-get-info ogroup))
6105 (list (cons 'to-group ogroup))))
6106 (case-fold-search t)
6107 (buf (current-buffer))
6110 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6111 (insert-buffer-substring gnus-original-article-buffer)
6112 ;; Remove lines that may lead nndoc to misinterpret the
6115 (goto-char (point-min))
6116 (or (search-forward "\n\n" nil t) (point)))
6117 (goto-char (point-min))
6118 (delete-matching-lines "^\\(Path\\):\\|^From ")
6121 (if (gnus-group-read-ephemeral-group
6122 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6124 ,(if force 'digest 'guess))) t)
6125 ;; Make all postings to this group go to the parent group.
6126 (nconc (gnus-info-params (gnus-get-info name))
6128 ;; Couldn't select this doc group.
6129 (switch-to-buffer buf)
6130 (gnus-set-global-variables)
6131 (gnus-configure-windows 'summary)
6132 (gnus-message 3 "Article couldn't be entered?"))
6133 (kill-buffer dig)))))
6135 (defun gnus-summary-read-document (n)
6136 "Open a new group based on the current article(s).
6137 This will allow you to read digests and other similar
6138 documents as newsgroups.
6139 Obeys the standard process/prefix convention."
6141 (let* ((articles (gnus-summary-work-articles n))
6142 (ogroup gnus-newsgroup-name)
6143 (params (append (gnus-info-params (gnus-get-info ogroup))
6144 (list (cons 'to-group ogroup))))
6145 article group egroup groups vgroup)
6146 (while (setq article (pop articles))
6147 (setq group (format "%s-%d" gnus-newsgroup-name article))
6148 (gnus-summary-remove-process-mark article)
6149 (when (gnus-summary-display-article article)
6151 (nnheader-temp-write nil
6152 (insert-buffer-substring gnus-original-article-buffer)
6153 ;; Remove some headers that may lead nndoc to make
6155 (message-narrow-to-head)
6156 (goto-char (point-min))
6157 (delete-matching-lines "^\\(Path\\):\\|^From ")
6160 (gnus-group-read-ephemeral-group
6161 group `(nndoc ,group (nndoc-address ,(current-buffer))
6162 (nndoc-article-type guess))
6165 ;; Make all postings to this group go to the parent group.
6166 (nconc (gnus-info-params (gnus-get-info egroup))
6168 (push egroup groups))
6169 ;; Couldn't select this doc group.
6170 (gnus-error 3 "Article couldn't be entered"))))))
6171 ;; Now we have selected all the documents.
6174 (error "None of the articles could be interpreted as documents"))
6175 ((gnus-group-read-ephemeral-group
6176 (setq vgroup (format
6177 "nnvirtual:%s-%s" gnus-newsgroup-name
6178 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6179 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6181 (cons (current-buffer) 'summary)))
6183 (error "Couldn't select virtual nndoc group")))))
6185 (defun gnus-summary-isearch-article (&optional regexp-p)
6186 "Do incremental search forward on the current article.
6187 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6189 (gnus-set-global-variables)
6190 (gnus-summary-select-article)
6191 (gnus-configure-windows 'article)
6192 (gnus-eval-in-buffer-window gnus-article-buffer
6193 ;;(goto-char (point-min))
6194 (isearch-forward regexp-p)))
6196 (defun gnus-summary-search-article-forward (regexp &optional backward)
6197 "Search for an article containing REGEXP forward.
6198 If BACKWARD, search backward instead."
6201 (format "Search article %s (regexp%s): "
6202 (if current-prefix-arg "backward" "forward")
6203 (if gnus-last-search-regexp
6204 (concat ", default " gnus-last-search-regexp)
6206 current-prefix-arg))
6207 (gnus-set-global-variables)
6208 (if (string-equal regexp "")
6209 (setq regexp (or gnus-last-search-regexp ""))
6210 (setq gnus-last-search-regexp regexp))
6211 (if (gnus-summary-search-article regexp backward)
6212 (gnus-summary-show-thread)
6213 (error "Search failed: \"%s\"" regexp)))
6215 (defun gnus-summary-search-article-backward (regexp)
6216 "Search for an article containing REGEXP backward."
6219 (format "Search article backward (regexp%s): "
6220 (if gnus-last-search-regexp
6221 (concat ", default " gnus-last-search-regexp)
6223 (gnus-summary-search-article-forward regexp 'backward))
6225 (defun gnus-summary-search-article (regexp &optional backward)
6226 "Search for an article containing REGEXP.
6227 Optional argument BACKWARD means do search for backward.
6228 `gnus-select-article-hook' is not called during the search."
6229 (let ((gnus-select-article-hook nil) ;Disable hook.
6230 (gnus-article-display-hook nil)
6231 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6232 (gnus-use-article-prefetch nil)
6233 (sum (current-buffer))
6236 (gnus-save-hidden-threads
6237 (gnus-summary-select-article)
6238 (set-buffer gnus-article-buffer)
6242 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
6244 (re-search-backward regexp nil t)
6245 (re-search-forward regexp nil t))
6246 ;; We found the regexp.
6251 (get-buffer-window (current-buffer))
6255 (setq point (point)))
6256 ;; We didn't find it, so we go to the next article.
6258 (while (and (not found)
6259 (gnus-summary-article-sparse-p
6260 (gnus-summary-article-number)))
6261 (if (not (if backward (gnus-summary-find-prev)
6262 (gnus-summary-find-next)))
6263 ;; No more articles.
6265 ;; Select the next article and adjust point.
6266 (unless (gnus-summary-article-sparse-p
6267 (gnus-summary-article-number))
6268 (gnus-summary-select-article)
6269 (set-buffer gnus-article-buffer)
6271 (goto-char (if backward (point-max) (point-min))))))))
6272 (gnus-message 7 ""))
6273 ;; Return whether we found the regexp.
6274 (when (eq found 'found)
6276 (gnus-summary-show-thread)
6277 (gnus-summary-goto-subject gnus-current-article)
6278 (gnus-summary-position-point)
6281 (defun gnus-summary-find-matching (header regexp &optional backward unread
6283 "Return a list of all articles that match REGEXP on HEADER.
6284 The search stars on the current article and goes forwards unless
6285 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
6286 If UNREAD is non-nil, only unread articles will
6287 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
6288 in the comparisons."
6289 (let ((data (if (eq backward 'all) gnus-newsgroup-data
6290 (gnus-data-find-list
6291 (gnus-summary-article-number) (gnus-data-list backward))))
6292 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
6293 (case-fold-search (not not-case-fold))
6295 (unless (fboundp (intern (concat "mail-header-" header)))
6296 (error "%s is not a valid header" header))
6299 (and (or (not unread) ; We want all articles...
6300 (gnus-data-unread-p d)) ; Or just unreads.
6301 (vectorp (gnus-data-header d)) ; It's not a pseudo.
6302 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
6303 (push (gnus-data-number d) articles)) ; Success!
6304 (setq data (cdr data)))
6305 (nreverse articles)))
6307 (defun gnus-summary-execute-command (header regexp command &optional backward)
6308 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
6309 If HEADER is an empty string (or nil), the match is done on the entire
6310 article. If BACKWARD (the prefix) is non-nil, search backward instead."
6312 (list (let ((completion-ignore-case t))
6315 (mapcar (lambda (string) (list string))
6316 '("Number" "Subject" "From" "Lines" "Date"
6317 "Message-ID" "Xref" "References" "Body"))
6318 nil 'require-match))
6319 (read-string "Regexp: ")
6320 (read-key-sequence "Command: ")
6321 current-prefix-arg))
6322 (when (equal header "Body")
6324 (gnus-set-global-variables)
6325 ;; Hidden thread subtrees must be searched as well.
6326 (gnus-summary-show-all-threads)
6327 ;; We don't want to change current point nor window configuration.
6329 (save-window-excursion
6330 (gnus-message 6 "Executing %s..." (key-description command))
6331 ;; We'd like to execute COMMAND interactively so as to give arguments.
6332 (gnus-execute header regexp
6333 `(call-interactively ',(key-binding command))
6335 (gnus-message 6 "Executing %s...done" (key-description command)))))
6337 (defun gnus-summary-beginning-of-article ()
6338 "Scroll the article back to the beginning."
6340 (gnus-set-global-variables)
6341 (gnus-summary-select-article)
6342 (gnus-configure-windows 'article)
6343 (gnus-eval-in-buffer-window gnus-article-buffer
6345 (goto-char (point-min))
6346 (when gnus-break-pages
6347 (gnus-narrow-to-page))))
6349 (defun gnus-summary-end-of-article ()
6350 "Scroll to the end of the article."
6352 (gnus-set-global-variables)
6353 (gnus-summary-select-article)
6354 (gnus-configure-windows 'article)
6355 (gnus-eval-in-buffer-window gnus-article-buffer
6357 (goto-char (point-max))
6359 (when gnus-break-pages
6360 (gnus-narrow-to-page))))
6362 (defun gnus-summary-show-article (&optional arg)
6363 "Force re-fetching of the current article.
6364 If ARG (the prefix) is non-nil, show the raw article without any
6365 article massaging functions being run."
6367 (gnus-set-global-variables)
6369 ;; Select the article the normal way.
6370 (gnus-summary-select-article nil 'force)
6371 ;; Bind the article treatment functions to nil.
6372 (let ((gnus-have-all-headers t)
6373 gnus-article-display-hook
6374 gnus-article-prepare-hook
6377 (gnus-summary-select-article nil 'force)))
6378 (gnus-summary-goto-subject gnus-current-article)
6379 ; (gnus-configure-windows 'article)
6380 (gnus-summary-position-point))
6382 (defun gnus-summary-verbose-headers (&optional arg)
6383 "Toggle permanent full header display.
6384 If ARG is a positive number, turn header display on.
6385 If ARG is a negative number, turn header display off."
6387 (gnus-set-global-variables)
6388 (setq gnus-show-all-headers
6389 (cond ((or (not (numberp arg))
6391 (not gnus-show-all-headers))
6394 (gnus-summary-show-article))
6396 (defun gnus-summary-toggle-header (&optional arg)
6397 "Show the headers if they are hidden, or hide them if they are shown.
6398 If ARG is a positive number, show the entire header.
6399 If ARG is a negative number, hide the unwanted header lines."
6401 (gnus-set-global-variables)
6403 (set-buffer gnus-article-buffer)
6404 (let* ((buffer-read-only nil)
6405 (inhibit-point-motion-hooks t)
6406 (hidden (text-property-any
6407 (goto-char (point-min)) (search-forward "\n\n")
6410 (goto-char (point-min))
6411 (when (search-forward "\n\n" nil t)
6412 (delete-region (point-min) (1- (point))))
6413 (goto-char (point-min))
6415 (set-buffer gnus-original-article-buffer)
6416 (goto-char (point-min))
6417 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
6418 (insert-buffer-substring gnus-original-article-buffer 1 e)
6419 (let ((article-inhibit-hiding t))
6420 (run-hooks 'gnus-article-display-hook))
6421 (when (or (not hidden) (and (numberp arg) (< arg 0)))
6422 (gnus-article-hide-headers)))))
6424 (defun gnus-summary-show-all-headers ()
6425 "Make all header lines visible."
6427 (gnus-set-global-variables)
6428 (gnus-article-show-all-headers))
6430 (defun gnus-summary-toggle-mime (&optional arg)
6431 "Toggle MIME processing.
6432 If ARG is a positive number, turn MIME processing on."
6434 (gnus-set-global-variables)
6435 (setq gnus-show-mime
6436 (if (null arg) (not gnus-show-mime)
6437 (> (prefix-numeric-value arg) 0)))
6438 (gnus-summary-select-article t 'force))
6440 (defun gnus-summary-caesar-message (&optional arg)
6441 "Caesar rotate the current article by 13.
6442 The numerical prefix specifies how manu places to rotate each letter
6445 (gnus-set-global-variables)
6446 (gnus-summary-select-article)
6447 (let ((mail-header-separator ""))
6448 (gnus-eval-in-buffer-window gnus-article-buffer
6451 (let ((start (window-start))
6453 (message-caesar-buffer-body arg)
6454 (set-window-start (get-buffer-window (current-buffer)) start))))))
6456 (defun gnus-summary-stop-page-breaking ()
6457 "Stop page breaking in the current article."
6459 (gnus-set-global-variables)
6460 (gnus-summary-select-article)
6461 (gnus-eval-in-buffer-window gnus-article-buffer
6463 (when (gnus-visual-p 'page-marker)
6464 (let ((buffer-read-only nil))
6465 (gnus-remove-text-with-property 'gnus-prev)
6466 (gnus-remove-text-with-property 'gnus-next)))))
6468 (defun gnus-summary-move-article (&optional n to-newsgroup
6469 select-method action)
6470 "Move the current article to a different newsgroup.
6471 If N is a positive number, move the N next articles.
6472 If N is a negative number, move the N previous articles.
6473 If N is nil and any articles have been marked with the process mark,
6474 move those articles instead.
6475 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6476 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6477 re-spool using this method.
6479 For this function to work, both the current newsgroup and the
6480 newsgroup that you want to move to have to support the `request-move'
6481 and `request-accept' functions."
6484 (setq action 'move))
6485 (gnus-set-global-variables)
6486 ;; Check whether the source group supports the required functions.
6487 (cond ((and (eq action 'move)
6488 (not (gnus-check-backend-function
6489 'request-move-article gnus-newsgroup-name)))
6490 (error "The current group does not support article moving"))
6491 ((and (eq action 'crosspost)
6492 (not (gnus-check-backend-function
6493 'request-replace-article gnus-newsgroup-name)))
6494 (error "The current group does not support article editing")))
6495 (let ((articles (gnus-summary-work-articles n))
6496 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
6497 (names '((move "Move" "Moving")
6498 (copy "Copy" "Copying")
6499 (crosspost "Crosspost" "Crossposting")))
6500 (copy-buf (save-excursion
6501 (nnheader-set-temp-buffer " *copy article*")))
6502 art-group to-method new-xref article to-groups)
6503 (unless (assq action names)
6504 (error "Unknown action %s" action))
6505 ;; Read the newsgroup name.
6506 (when (and (not to-newsgroup)
6507 (not select-method))
6509 (gnus-read-move-group-name
6510 (cadr (assq action names))
6511 (symbol-value (intern (format "gnus-current-%s-group" action)))
6513 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
6514 (setq to-method (or select-method
6515 (gnus-group-name-to-method to-newsgroup)))
6516 ;; Check the method we are to move this article to...
6517 (unless (gnus-check-backend-function
6518 'request-accept-article (car to-method))
6519 (error "%s does not support article copying" (car to-method)))
6520 (unless (gnus-check-server to-method)
6521 (error "Can't open server %s" (car to-method)))
6522 (gnus-message 6 "%s to %s: %s..."
6523 (caddr (assq action names))
6524 (or (car select-method) to-newsgroup) articles)
6526 (setq article (pop articles))
6530 ;; Move the article.
6532 (gnus-request-move-article
6533 article ; Article to move
6534 gnus-newsgroup-name ; From newsgroup
6535 (nth 1 (gnus-find-method-for-group
6536 gnus-newsgroup-name)) ; Server
6537 (list 'gnus-request-accept-article
6538 to-newsgroup (list 'quote select-method)
6539 (not articles)) ; Accept form
6540 (not articles))) ; Only save nov last time
6541 ;; Copy the article.
6544 (set-buffer copy-buf)
6545 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6546 (gnus-request-accept-article
6547 to-newsgroup select-method (not articles))))
6548 ;; Crosspost the article.
6549 ((eq action 'crosspost)
6550 (let ((xref (message-tokenize-header
6551 (mail-header-xref (gnus-summary-article-header article))
6553 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
6556 (setq xref (list (system-name))))
6559 (mapconcat 'identity
6560 (delete "Xref:" (delete new-xref xref))
6564 (set-buffer copy-buf)
6565 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6566 (nnheader-replace-header "xref" new-xref)
6567 (gnus-request-accept-article
6568 to-newsgroup select-method (not articles)))))))
6570 (gnus-message 1 "Couldn't %s article %s"
6571 (cadr (assq action names)) article)
6574 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
6576 (gnus-group-prefixed-name
6579 (gnus-find-method-for-group to-newsgroup)))
6580 gnus-newsrc-hashtb)))
6581 (info (nth 2 entry))
6582 (to-group (gnus-info-group info)))
6583 ;; Update the group that has been moved to.
6585 (memq action '(move copy)))
6586 (unless (member to-group to-groups)
6587 (push to-group to-groups))
6589 (unless (memq article gnus-newsgroup-unreads)
6591 info (gnus-add-to-range (gnus-info-read info)
6592 (list (cdr art-group)))))
6594 ;; Copy any marks over to the new group.
6595 (let ((marks gnus-article-mark-lists)
6596 (to-article (cdr art-group)))
6598 ;; See whether the article is to be put in the cache.
6599 (when gnus-use-cache
6600 (gnus-cache-possibly-enter-article
6602 (let ((header (copy-sequence
6603 (gnus-summary-article-header article))))
6604 (mail-header-set-number header to-article)
6606 (memq article gnus-newsgroup-marked)
6607 (memq article gnus-newsgroup-dormant)
6608 (memq article gnus-newsgroup-unreads)))
6611 (when (memq article (symbol-value
6612 (intern (format "gnus-newsgroup-%s"
6614 ;; If the other group is the same as this group,
6615 ;; then we have to add the mark to the list.
6616 (when (equal to-group gnus-newsgroup-name)
6617 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
6620 (intern (format "gnus-newsgroup-%s"
6622 ;; Copy mark to other group.
6623 (gnus-add-marked-articles
6624 to-group (cdar marks) (list to-article) info))
6625 (setq marks (cdr marks)))))
6627 ;; Update the Xref header in this article to point to
6628 ;; the new crossposted article we have just created.
6629 (when (eq action 'crosspost)
6631 (set-buffer copy-buf)
6632 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6633 (nnheader-replace-header
6634 "xref" (concat new-xref " " (car art-group)
6635 ":" (cdr art-group)))
6636 (gnus-request-replace-article
6637 article gnus-newsgroup-name (current-buffer)))))
6639 (gnus-summary-goto-subject article)
6640 (when (eq action 'move)
6641 (gnus-summary-mark-article article gnus-canceled-mark)))
6642 (gnus-summary-remove-process-mark article))
6643 ;; Re-activate all groups that have been moved to.
6645 (gnus-activate-group (pop to-groups)))
6647 (gnus-kill-buffer copy-buf)
6648 (gnus-summary-position-point)
6649 (gnus-set-mode-line 'summary)))
6651 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
6652 "Move the current article to a different newsgroup.
6653 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6654 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6655 re-spool using this method."
6657 (gnus-summary-move-article n nil select-method 'copy))
6659 (defun gnus-summary-crosspost-article (&optional n)
6660 "Crosspost the current article to some other group."
6662 (gnus-summary-move-article n nil nil 'crosspost))
6664 (defcustom gnus-summary-respool-default-method nil
6665 "Default method for respooling an article.
6666 If nil, use to the current newsgroup method."
6667 :type 'gnus-select-method-name
6668 :group 'gnus-summary)
6670 (defun gnus-summary-respool-article (&optional n method)
6671 "Respool the current article.
6672 The article will be squeezed through the mail spooling process again,
6673 which means that it will be put in some mail newsgroup or other
6674 depending on `nnmail-split-methods'.
6675 If N is a positive number, respool the N next articles.
6676 If N is a negative number, respool the N previous articles.
6677 If N is nil and any articles have been marked with the process mark,
6678 respool those articles instead.
6680 Respooling can be done both from mail groups and \"real\" newsgroups.
6681 In the former case, the articles in question will be moved from the
6682 current group into whatever groups they are destined to. In the
6683 latter case, they will be copied into the relevant groups."
6685 (list current-prefix-arg
6686 (let* ((methods (gnus-methods-using 'respool))
6688 (symbol-name (or gnus-summary-respool-default-method
6689 (car (gnus-find-method-for-group
6690 gnus-newsgroup-name)))))
6692 (gnus-completing-read
6693 methname "What backend do you want to use when respooling?"
6694 methods nil t nil 'gnus-mail-method-history))
6697 ((zerop (length (setq ms (gnus-servers-using-backend
6699 (list (intern method) ""))
6703 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
6704 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
6706 (gnus-set-global-variables)
6708 (error "No method given for respooling"))
6709 (if (assoc (symbol-name
6710 (car (gnus-find-method-for-group gnus-newsgroup-name)))
6711 (gnus-methods-using 'respool))
6712 (gnus-summary-move-article n nil method)
6713 (gnus-summary-copy-article n nil method)))
6715 (defun gnus-summary-import-article (file)
6716 "Import a random file into a mail newsgroup."
6717 (interactive "fImport file: ")
6718 (gnus-set-global-variables)
6719 (let ((group gnus-newsgroup-name)
6720 (now (current-time))
6722 (unless (gnus-check-backend-function 'request-accept-article group)
6723 (error "%s does not support article importing" group))
6724 (or (file-readable-p file)
6725 (not (file-regular-p file))
6726 (error "Can't read %s" file))
6728 (set-buffer (get-buffer-create " *import file*"))
6729 (buffer-disable-undo (current-buffer))
6731 (insert-file-contents file)
6732 (goto-char (point-min))
6733 (unless (nnheader-article-p)
6734 ;; This doesn't look like an article, so we fudge some headers.
6735 (setq atts (file-attributes file)
6736 lines (count-lines (point-min) (point-max)))
6737 (insert "From: " (read-string "From: ") "\n"
6738 "Subject: " (read-string "Subject: ") "\n"
6739 "Date: " (timezone-make-date-arpa-standard
6740 (current-time-string (nth 5 atts))
6741 (current-time-zone now)
6742 (current-time-zone now))
6744 "Message-ID: " (message-make-message-id) "\n"
6745 "Lines: " (int-to-string lines) "\n"
6746 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
6747 (gnus-request-accept-article group nil t)
6748 (kill-buffer (current-buffer)))))
6750 (defun gnus-summary-article-posted-p ()
6751 "Say whether the current (mail) article is available from `gnus-select-method' as well.
6752 This will be the case if the article has both been mailed and posted."
6754 (let ((id (mail-header-references (gnus-summary-article-header)))
6755 (gnus-override-method
6756 (or gnus-refer-article-method gnus-select-method)))
6757 (if (gnus-request-head id "")
6758 (gnus-message 2 "The current message was found on %s"
6759 gnus-override-method)
6760 (gnus-message 2 "The current message couldn't be found on %s"
6761 gnus-override-method)
6764 (defun gnus-summary-expire-articles (&optional now)
6765 "Expire all articles that are marked as expirable in the current group."
6767 (gnus-set-global-variables)
6768 (when (gnus-check-backend-function
6769 'request-expire-articles gnus-newsgroup-name)
6770 ;; This backend supports expiry.
6771 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
6772 (expirable (if total
6774 ;; We need to update the info for
6775 ;; this group for `gnus-list-of-read-articles'
6776 ;; to give us the right answer.
6777 (gnus-summary-update-info)
6778 (gnus-list-of-read-articles gnus-newsgroup-name))
6779 (setq gnus-newsgroup-expirable
6780 (sort gnus-newsgroup-expirable '<))))
6781 (expiry-wait (if now 'immediate
6782 (gnus-group-find-parameter
6783 gnus-newsgroup-name 'expiry-wait)))
6786 ;; There are expirable articles in this group, so we run them
6787 ;; through the expiry process.
6788 (gnus-message 6 "Expiring articles...")
6789 ;; The list of articles that weren't expired is returned.
6791 (let ((nnmail-expiry-wait-function nil)
6792 (nnmail-expiry-wait expiry-wait))
6793 (setq es (gnus-request-expire-articles
6794 expirable gnus-newsgroup-name)))
6795 (setq es (gnus-request-expire-articles
6796 expirable gnus-newsgroup-name)))
6798 (setq gnus-newsgroup-expirable es))
6799 ;; We go through the old list of expirable, and mark all
6800 ;; really expired articles as nonexistent.
6801 (unless (eq es expirable) ;If nothing was expired, we don't mark.
6802 (let ((gnus-use-cache nil))
6804 (unless (memq (car expirable) es)
6805 (when (gnus-data-find (car expirable))
6806 (gnus-summary-mark-article
6807 (car expirable) gnus-canceled-mark)))
6808 (setq expirable (cdr expirable)))))
6809 (gnus-message 6 "Expiring articles...done")))))
6811 (defun gnus-summary-expire-articles-now ()
6812 "Expunge all expirable articles in the current group.
6813 This means that *all* articles that are marked as expirable will be
6814 deleted forever, right now."
6816 (gnus-set-global-variables)
6817 (or gnus-expert-user
6819 "Are you really, really, really sure you want to delete all these messages? ")
6821 (gnus-summary-expire-articles t))
6823 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6824 (defun gnus-summary-delete-article (&optional n)
6825 "Delete the N next (mail) articles.
6826 This command actually deletes articles. This is not a marking
6827 command. The article will disappear forever from your life, never to
6829 If N is negative, delete backwards.
6830 If N is nil and articles have been marked with the process mark,
6831 delete these instead."
6833 (gnus-set-global-variables)
6834 (unless (gnus-check-backend-function 'request-expire-articles
6835 gnus-newsgroup-name)
6836 (error "The current newsgroup does not support article deletion."))
6837 ;; Compute the list of articles to delete.
6838 (let ((articles (gnus-summary-work-articles n))
6840 (if (and gnus-novice-user
6842 (format "Do you really want to delete %s forever? "
6843 (if (> (length articles) 1)
6844 (format "these %s articles" (length articles))
6847 ;; Delete the articles.
6848 (setq not-deleted (gnus-request-expire-articles
6849 articles gnus-newsgroup-name 'force))
6851 (gnus-summary-remove-process-mark (car articles))
6852 ;; The backend might not have been able to delete the article
6854 (unless (memq (car articles) not-deleted)
6855 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
6856 (setq articles (cdr articles))))
6857 (gnus-summary-position-point)
6858 (gnus-set-mode-line 'summary)
6861 (defun gnus-summary-edit-article (&optional force)
6862 "Edit the current article.
6863 This will have permanent effect only in mail groups.
6864 If FORCE is non-nil, allow editing of articles even in read-only
6868 (set-buffer gnus-summary-buffer)
6869 (gnus-set-global-variables)
6870 (when (and (not force)
6871 (gnus-group-read-only-p))
6872 (error "The current newsgroup does not support article editing."))
6873 ;; Select article if needed.
6874 (unless (eq (gnus-summary-article-number)
6875 gnus-current-article)
6876 (gnus-summary-select-article t))
6877 (gnus-article-edit-article
6879 (gnus-summary-edit-article-done
6880 ,(or (mail-header-references gnus-current-headers) "")
6881 ,(gnus-group-read-only-p) ,gnus-summary-buffer)))))
6883 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
6885 (defun gnus-summary-edit-article-done (&optional references read-only buffer)
6886 "Make edits to the current article permanent."
6888 ;; Replace the article.
6889 (if (and (not read-only)
6890 (not (gnus-request-replace-article
6891 (cdr gnus-article-current) (car gnus-article-current)
6893 (error "Couldn't replace article.")
6894 ;; Update the summary buffer.
6896 (equal (message-tokenize-header references " ")
6897 (message-tokenize-header
6898 (or (message-fetch-field "references") "") " ")))
6899 ;; We only have to update this line.
6902 (message-narrow-to-head)
6903 (let ((header (nnheader-parse-head t)))
6905 (mail-header-set-number header (cdr gnus-article-current))
6906 (gnus-summary-update-article-line
6907 (cdr gnus-article-current) header))))
6909 (set-buffer (or buffer gnus-summary-buffer))
6910 (gnus-summary-update-article (cdr gnus-article-current)))
6911 ;; Prettify the article buffer again.
6913 (set-buffer gnus-article-buffer)
6914 (run-hooks 'gnus-article-display-hook))
6915 ;; Prettify the summary buffer line.
6916 (when (gnus-visual-p 'summary-highlight 'highlight)
6917 (run-hooks 'gnus-visual-mark-article-hook))))
6919 (defun gnus-summary-edit-wash (key)
6920 "Perform editing command in the article buffer."
6924 (message "%s" (concat (this-command-keys) "- "))
6927 (gnus-summary-edit-article)
6928 (execute-kbd-macro (concat (this-command-keys) key))
6929 (gnus-article-edit-done))
6933 (defun gnus-summary-respool-query ()
6934 "Query where the respool algorithm would put this article."
6936 (gnus-set-global-variables)
6937 (gnus-summary-select-article)
6939 (set-buffer gnus-article-buffer)
6941 (goto-char (point-min))
6942 (search-forward "\n\n")
6943 (narrow-to-region (point-min) (point))
6944 (message "This message would go to %s"
6945 (mapconcat 'car (nnmail-article-group 'identity) ", ")))))
6947 ;; Summary marking commands.
6949 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
6950 "Mark articles which has the same subject as read, and then select the next.
6951 If UNMARK is positive, remove any kind of mark.
6952 If UNMARK is negative, tick articles."
6954 (gnus-set-global-variables)
6956 (setq unmark (prefix-numeric-value unmark)))
6958 (gnus-summary-mark-same-subject
6959 (gnus-summary-article-subject) unmark)))
6960 ;; Select next unread article. If auto-select-same mode, should
6961 ;; select the first unread article.
6962 (gnus-summary-next-article t (and gnus-auto-select-same
6963 (gnus-summary-article-subject)))
6964 (gnus-message 7 "%d article%s marked as %s"
6965 count (if (= count 1) " is" "s are")
6966 (if unmark "unread" "read"))))
6968 (defun gnus-summary-kill-same-subject (&optional unmark)
6969 "Mark articles which has the same subject as read.
6970 If UNMARK is positive, remove any kind of mark.
6971 If UNMARK is negative, tick articles."
6973 (gnus-set-global-variables)
6975 (setq unmark (prefix-numeric-value unmark)))
6977 (gnus-summary-mark-same-subject
6978 (gnus-summary-article-subject) unmark)))
6979 ;; If marked as read, go to next unread subject.
6981 ;; Go to next unread subject.
6982 (gnus-summary-next-subject 1 t))
6983 (gnus-message 7 "%d articles are marked as %s"
6984 count (if unmark "unread" "read"))))
6986 (defun gnus-summary-mark-same-subject (subject &optional unmark)
6987 "Mark articles with same SUBJECT as read, and return marked number.
6988 If optional argument UNMARK is positive, remove any kinds of marks.
6989 If optional argument UNMARK is negative, mark articles as unread instead."
6993 ((null unmark) ; Mark as read.
6996 (gnus-summary-mark-article-as-read gnus-killed-mark)
6997 (gnus-summary-show-thread) t)
6998 (gnus-summary-find-subject subject))
6999 (setq count (1+ count))))
7000 ((> unmark 0) ; Tick.
7003 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
7004 (gnus-summary-show-thread) t)
7005 (gnus-summary-find-subject subject))
7006 (setq count (1+ count))))
7007 (t ; Mark as unread.
7010 (gnus-summary-mark-article-as-unread gnus-unread-mark)
7011 (gnus-summary-show-thread) t)
7012 (gnus-summary-find-subject subject))
7013 (setq count (1+ count)))))
7014 (gnus-set-mode-line 'summary)
7015 ;; Return the number of marked articles.
7018 (defun gnus-summary-mark-as-processable (n &optional unmark)
7019 "Set the process mark on the next N articles.
7020 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7021 the process mark instead. The difference between N and the actual
7022 number of articles marked is returned."
7024 (gnus-set-global-variables)
7025 (let ((backward (< n 0))
7030 (gnus-summary-remove-process-mark
7031 (gnus-summary-article-number))
7032 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7033 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7036 (gnus-message 7 "No more articles"))
7037 (gnus-summary-recenter)
7038 (gnus-summary-position-point)
7041 (defun gnus-summary-unmark-as-processable (n)
7042 "Remove the process mark from the next N articles.
7043 If N is negative, mark backward instead. The difference between N and
7044 the actual number of articles marked is returned."
7046 (gnus-set-global-variables)
7047 (gnus-summary-mark-as-processable n t))
7049 (defun gnus-summary-unmark-all-processable ()
7050 "Remove the process mark from all articles."
7052 (gnus-set-global-variables)
7054 (while gnus-newsgroup-processable
7055 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7056 (gnus-summary-position-point))
7058 (defun gnus-summary-mark-as-expirable (n)
7059 "Mark N articles forward as expirable.
7060 If N is negative, mark backward instead. The difference between N and
7061 the actual number of articles marked is returned."
7063 (gnus-set-global-variables)
7064 (gnus-summary-mark-forward n gnus-expirable-mark))
7066 (defun gnus-summary-mark-article-as-replied (article)
7067 "Mark ARTICLE replied and update the summary line."
7068 (push article gnus-newsgroup-replied)
7069 (let ((buffer-read-only nil))
7070 (when (gnus-summary-goto-subject article)
7071 (gnus-summary-update-secondary-mark article))))
7073 (defun gnus-summary-set-bookmark (article)
7074 "Set a bookmark in current article."
7075 (interactive (list (gnus-summary-article-number)))
7076 (gnus-set-global-variables)
7077 (when (or (not (get-buffer gnus-article-buffer))
7078 (not gnus-current-article)
7079 (not gnus-article-current)
7080 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7081 (error "No current article selected"))
7082 ;; Remove old bookmark, if one exists.
7083 (let ((old (assq article gnus-newsgroup-bookmarks)))
7085 (setq gnus-newsgroup-bookmarks
7086 (delq old gnus-newsgroup-bookmarks))))
7087 ;; Set the new bookmark, which is on the form
7088 ;; (article-number . line-number-in-body).
7092 (set-buffer gnus-article-buffer)
7096 (goto-char (point-min))
7097 (search-forward "\n\n" nil t)
7100 gnus-newsgroup-bookmarks)
7101 (gnus-message 6 "A bookmark has been added to the current article."))
7103 (defun gnus-summary-remove-bookmark (article)
7104 "Remove the bookmark from the current article."
7105 (interactive (list (gnus-summary-article-number)))
7106 (gnus-set-global-variables)
7107 ;; Remove old bookmark, if one exists.
7108 (let ((old (assq article gnus-newsgroup-bookmarks)))
7111 (setq gnus-newsgroup-bookmarks
7112 (delq old gnus-newsgroup-bookmarks))
7113 (gnus-message 6 "Removed bookmark."))
7114 (gnus-message 6 "No bookmark in current article."))))
7116 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7117 (defun gnus-summary-mark-as-dormant (n)
7118 "Mark N articles forward as dormant.
7119 If N is negative, mark backward instead. The difference between N and
7120 the actual number of articles marked is returned."
7122 (gnus-set-global-variables)
7123 (gnus-summary-mark-forward n gnus-dormant-mark))
7125 (defun gnus-summary-set-process-mark (article)
7126 "Set the process mark on ARTICLE and update the summary line."
7127 (setq gnus-newsgroup-processable
7129 (delq article gnus-newsgroup-processable)))
7130 (when (gnus-summary-goto-subject article)
7131 (gnus-summary-show-thread)
7132 (gnus-summary-update-secondary-mark article)))
7134 (defun gnus-summary-remove-process-mark (article)
7135 "Remove the process mark from ARTICLE and update the summary line."
7136 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7137 (when (gnus-summary-goto-subject article)
7138 (gnus-summary-show-thread)
7139 (gnus-summary-update-secondary-mark article)))
7141 (defun gnus-summary-set-saved-mark (article)
7142 "Set the process mark on ARTICLE and update the summary line."
7143 (push article gnus-newsgroup-saved)
7144 (when (gnus-summary-goto-subject article)
7145 (gnus-summary-update-secondary-mark article)))
7147 (defun gnus-summary-mark-forward (n &optional mark no-expire)
7148 "Mark N articles as read forwards.
7149 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
7150 The difference between N and the actual number of articles marked is
7153 (gnus-set-global-variables)
7154 (let ((backward (< n 0))
7155 (gnus-summary-goto-unread
7156 (and gnus-summary-goto-unread
7157 (not (eq gnus-summary-goto-unread 'never))
7158 (not (memq mark (list gnus-unread-mark
7159 gnus-ticked-mark gnus-dormant-mark)))))
7161 (mark (or mark gnus-del-mark)))
7163 (gnus-summary-mark-article nil mark no-expire)
7164 (zerop (gnus-summary-next-subject
7166 (and gnus-summary-goto-unread
7167 (not (eq gnus-summary-goto-unread 'never)))
7171 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
7172 (gnus-summary-recenter)
7173 (gnus-summary-position-point)
7174 (gnus-set-mode-line 'summary)
7177 (defun gnus-summary-mark-article-as-read (mark)
7178 "Mark the current article quickly as read with MARK."
7179 (let ((article (gnus-summary-article-number)))
7180 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7181 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7182 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7183 (push (cons article mark) gnus-newsgroup-reads)
7184 ;; Possibly remove from cache, if that is used.
7185 (when gnus-use-cache
7186 (gnus-cache-enter-remove-article article))
7187 ;; Allow the backend to change the mark.
7188 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7189 ;; Check for auto-expiry.
7190 (when (and gnus-newsgroup-auto-expire
7191 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7192 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7193 (= mark gnus-ancient-mark)
7194 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7195 (= mark gnus-duplicate-mark)))
7196 (setq mark gnus-expirable-mark)
7197 (push article gnus-newsgroup-expirable))
7198 ;; Set the mark in the buffer.
7199 (gnus-summary-update-mark mark 'unread)
7202 (defun gnus-summary-mark-article-as-unread (mark)
7203 "Mark the current article quickly as unread with MARK."
7204 (let ((article (gnus-summary-article-number)))
7206 (gnus-error 1 "Unmarkable article")
7207 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7208 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7209 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
7210 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
7211 (cond ((= mark gnus-ticked-mark)
7212 (push article gnus-newsgroup-marked))
7213 ((= mark gnus-dormant-mark)
7214 (push article gnus-newsgroup-dormant))
7216 (push article gnus-newsgroup-unreads)))
7217 (setq gnus-newsgroup-reads
7218 (delq (assq article gnus-newsgroup-reads)
7219 gnus-newsgroup-reads))
7221 ;; See whether the article is to be put in the cache.
7223 (vectorp (gnus-summary-article-header article))
7225 (gnus-cache-possibly-enter-article
7226 gnus-newsgroup-name article
7227 (gnus-summary-article-header article)
7228 (= mark gnus-ticked-mark)
7229 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7232 (gnus-summary-update-mark mark 'unread))
7235 (defun gnus-summary-mark-article (&optional article mark no-expire)
7236 "Mark ARTICLE with MARK. MARK can be any character.
7237 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
7238 `??' (dormant) and `?E' (expirable).
7239 If MARK is nil, then the default character `?D' is used.
7240 If ARTICLE is nil, then the article on the current line will be
7242 ;; The mark might be a string.
7243 (when (stringp mark)
7244 (setq mark (aref mark 0)))
7245 ;; If no mark is given, then we check auto-expiring.
7246 (and (not no-expire)
7247 gnus-newsgroup-auto-expire
7250 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7251 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7252 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7253 (= mark gnus-duplicate-mark))))
7254 (setq mark gnus-expirable-mark))
7255 (let* ((mark (or mark gnus-del-mark))
7256 (article (or article (gnus-summary-article-number))))
7258 (error "No article on current line"))
7259 (if (or (= mark gnus-unread-mark)
7260 (= mark gnus-ticked-mark)
7261 (= mark gnus-dormant-mark))
7262 (gnus-mark-article-as-unread article mark)
7263 (gnus-mark-article-as-read article mark))
7265 ;; See whether the article is to be put in the cache.
7267 (not (= mark gnus-canceled-mark))
7268 (vectorp (gnus-summary-article-header article))
7270 (gnus-cache-possibly-enter-article
7271 gnus-newsgroup-name article
7272 (gnus-summary-article-header article)
7273 (= mark gnus-ticked-mark)
7274 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7276 (when (gnus-summary-goto-subject article nil t)
7277 (let ((buffer-read-only nil))
7278 (gnus-summary-show-thread)
7280 (gnus-summary-update-mark mark 'unread)
7283 (defun gnus-summary-update-secondary-mark (article)
7284 "Update the secondary (read, process, cache) mark."
7285 (gnus-summary-update-mark
7286 (cond ((memq article gnus-newsgroup-processable)
7288 ((memq article gnus-newsgroup-cached)
7290 ((memq article gnus-newsgroup-replied)
7292 ((memq article gnus-newsgroup-saved)
7294 (t gnus-unread-mark))
7296 (when (gnus-visual-p 'summary-highlight 'highlight)
7297 (run-hooks 'gnus-summary-update-hook))
7300 (defun gnus-summary-update-mark (mark type)
7301 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
7302 (buffer-read-only nil))
7303 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
7304 (when (looking-at "\r")
7307 (<= (+ forward (point)) (point-max)))
7308 ;; Go to the right position on the line.
7309 (goto-char (+ forward (point)))
7310 ;; Replace the old mark with the new mark.
7311 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
7312 ;; Optionally update the marks by some user rule.
7313 (when (eq type 'unread)
7315 (gnus-data-find (gnus-summary-article-number)) mark)
7316 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
7318 (defun gnus-mark-article-as-read (article &optional mark)
7319 "Enter ARTICLE in the pertinent lists and remove it from others."
7320 ;; Make the article expirable.
7321 (let ((mark (or mark gnus-del-mark)))
7322 (if (= mark gnus-expirable-mark)
7323 (push article gnus-newsgroup-expirable)
7324 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
7325 ;; Remove from unread and marked lists.
7326 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7327 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7328 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7329 (push (cons article mark) gnus-newsgroup-reads)
7330 ;; Possibly remove from cache, if that is used.
7331 (when gnus-use-cache
7332 (gnus-cache-enter-remove-article article))))
7334 (defun gnus-mark-article-as-unread (article &optional mark)
7335 "Enter ARTICLE in the pertinent lists and remove it from others."
7336 (let ((mark (or mark gnus-ticked-mark)))
7337 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
7338 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
7339 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
7340 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7342 ;; Unsuppress duplicates?
7343 (when gnus-suppress-duplicates
7344 (gnus-dup-unsuppress-article article))
7346 (cond ((= mark gnus-ticked-mark)
7347 (push article gnus-newsgroup-marked))
7348 ((= mark gnus-dormant-mark)
7349 (push article gnus-newsgroup-dormant))
7351 (push article gnus-newsgroup-unreads)))
7352 (setq gnus-newsgroup-reads
7353 (delq (assq article gnus-newsgroup-reads)
7354 gnus-newsgroup-reads))))
7356 (defalias 'gnus-summary-mark-as-unread-forward
7357 'gnus-summary-tick-article-forward)
7358 (make-obsolete 'gnus-summary-mark-as-unread-forward
7359 'gnus-summary-tick-article-forward)
7360 (defun gnus-summary-tick-article-forward (n)
7361 "Tick N articles forwards.
7362 If N is negative, tick backwards instead.
7363 The difference between N and the number of articles ticked is returned."
7365 (gnus-summary-mark-forward n gnus-ticked-mark))
7367 (defalias 'gnus-summary-mark-as-unread-backward
7368 'gnus-summary-tick-article-backward)
7369 (make-obsolete 'gnus-summary-mark-as-unread-backward
7370 'gnus-summary-tick-article-backward)
7371 (defun gnus-summary-tick-article-backward (n)
7372 "Tick N articles backwards.
7373 The difference between N and the number of articles ticked is returned."
7375 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
7377 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7378 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7379 (defun gnus-summary-tick-article (&optional article clear-mark)
7380 "Mark current article as unread.
7381 Optional 1st argument ARTICLE specifies article number to be marked as unread.
7382 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
7384 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
7387 (defun gnus-summary-mark-as-read-forward (n)
7388 "Mark N articles as read forwards.
7389 If N is negative, mark backwards instead.
7390 The difference between N and the actual number of articles marked is
7393 (gnus-summary-mark-forward n gnus-del-mark t))
7395 (defun gnus-summary-mark-as-read-backward (n)
7396 "Mark the N articles as read backwards.
7397 The difference between N and the actual number of articles marked is
7400 (gnus-summary-mark-forward (- n) gnus-del-mark t))
7402 (defun gnus-summary-mark-as-read (&optional article mark)
7403 "Mark current article as read.
7404 ARTICLE specifies the article to be marked as read.
7405 MARK specifies a string to be inserted at the beginning of the line."
7406 (gnus-summary-mark-article article mark))
7408 (defun gnus-summary-clear-mark-forward (n)
7409 "Clear marks from N articles forward.
7410 If N is negative, clear backward instead.
7411 The difference between N and the number of marks cleared is returned."
7413 (gnus-summary-mark-forward n gnus-unread-mark))
7415 (defun gnus-summary-clear-mark-backward (n)
7416 "Clear marks from N articles backward.
7417 The difference between N and the number of marks cleared is returned."
7419 (gnus-summary-mark-forward (- n) gnus-unread-mark))
7421 (defun gnus-summary-mark-unread-as-read ()
7422 "Intended to be used by `gnus-summary-mark-article-hook'."
7423 (when (memq gnus-current-article gnus-newsgroup-unreads)
7424 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
7426 (defun gnus-summary-mark-read-and-unread-as-read ()
7427 "Intended to be used by `gnus-summary-mark-article-hook'."
7428 (let ((mark (gnus-summary-article-mark)))
7429 (when (or (gnus-unread-mark-p mark)
7430 (gnus-read-mark-p mark))
7431 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
7433 (defun gnus-summary-mark-region-as-read (point mark all)
7434 "Mark all unread articles between point and mark as read.
7435 If given a prefix, mark all articles between point and mark as read,
7436 even ticked and dormant ones."
7437 (interactive "r\nP")
7446 (memq (setq article (gnus-summary-article-number))
7447 gnus-newsgroup-unreads))
7448 (gnus-summary-mark-article article gnus-del-mark))
7450 (gnus-summary-find-next))))))
7452 (defun gnus-summary-mark-below (score mark)
7453 "Mark articles with score less than SCORE with MARK."
7454 (interactive "P\ncMark: ")
7455 (gnus-set-global-variables)
7456 (setq score (if score
7457 (prefix-numeric-value score)
7458 (or gnus-summary-default-score 0)))
7460 (set-buffer gnus-summary-buffer)
7461 (goto-char (point-min))
7464 (and (< (gnus-summary-article-score) score)
7465 (gnus-summary-mark-article nil mark))
7466 (gnus-summary-find-next)))))
7468 (defun gnus-summary-kill-below (&optional score)
7469 "Mark articles with score below SCORE as read."
7471 (gnus-set-global-variables)
7472 (gnus-summary-mark-below score gnus-killed-mark))
7474 (defun gnus-summary-clear-above (&optional score)
7475 "Clear all marks from articles with score above SCORE."
7477 (gnus-set-global-variables)
7478 (gnus-summary-mark-above score gnus-unread-mark))
7480 (defun gnus-summary-tick-above (&optional score)
7481 "Tick all articles with score above SCORE."
7483 (gnus-set-global-variables)
7484 (gnus-summary-mark-above score gnus-ticked-mark))
7486 (defun gnus-summary-mark-above (score mark)
7487 "Mark articles with score over SCORE with MARK."
7488 (interactive "P\ncMark: ")
7489 (gnus-set-global-variables)
7490 (setq score (if score
7491 (prefix-numeric-value score)
7492 (or gnus-summary-default-score 0)))
7494 (set-buffer gnus-summary-buffer)
7495 (goto-char (point-min))
7497 (when (> (gnus-summary-article-score) score)
7498 (gnus-summary-mark-article nil mark))
7500 (gnus-summary-find-next)))))
7502 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7503 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
7504 (defun gnus-summary-limit-include-expunged (&optional no-error)
7505 "Display all the hidden articles that were expunged for low scores."
7507 (gnus-set-global-variables)
7508 (let ((buffer-read-only nil))
7509 (let ((scored gnus-newsgroup-scored)
7512 (unless (gnus-summary-goto-subject (caar scored))
7513 (and (setq h (gnus-summary-article-header (caar scored)))
7514 (< (cdar scored) gnus-summary-expunge-below)
7516 (setq scored (cdr scored)))
7518 (when (not no-error)
7519 (error "No expunged articles hidden."))
7520 (goto-char (point-min))
7521 (gnus-summary-prepare-unthreaded (nreverse headers))
7522 (goto-char (point-min))
7523 (gnus-summary-position-point)
7526 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
7527 "Mark all articles not marked as unread in this newsgroup as read.
7528 If prefix argument ALL is non-nil, all articles are marked as read.
7529 If QUIETLY is non-nil, no questions will be asked.
7530 If TO-HERE is non-nil, it should be a point in the buffer. All
7531 articles before this point will be marked as read.
7532 The number of articles marked as read is returned."
7534 (gnus-set-global-variables)
7538 (not gnus-interactive-catchup) ;Without confirmation?
7542 "Mark absolutely all articles as read? "
7543 "Mark all unread articles as read? ")))
7545 (not gnus-newsgroup-adaptive)
7546 (not gnus-newsgroup-auto-expire)
7547 (not gnus-suppress-duplicates))
7550 (setq gnus-newsgroup-marked nil
7551 gnus-newsgroup-dormant nil))
7552 (setq gnus-newsgroup-unreads nil))
7553 ;; We actually mark all articles as canceled, which we
7554 ;; have to do when using auto-expiry or adaptive scoring.
7555 (gnus-summary-show-all-threads)
7556 (when (gnus-summary-first-subject (not all))
7558 (if to-here (< (point) to-here) t)
7559 (gnus-summary-mark-article-as-read gnus-catchup-mark)
7560 (gnus-summary-find-next (not all)))))
7562 (setq gnus-newsgroup-unreads nil))
7563 (gnus-set-mode-line 'summary))
7564 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
7565 (when (and (not to-here) (eq 'nnvirtual (car method)))
7566 (nnvirtual-catchup-group
7567 (gnus-group-real-name gnus-newsgroup-name)
7568 (nth 1 method) all)))
7570 (gnus-summary-position-point)))
7572 (defun gnus-summary-catchup-to-here (&optional all)
7573 "Mark all unticked articles before the current one as read.
7574 If ALL is non-nil, also mark ticked and dormant articles as read."
7576 (gnus-set-global-variables)
7578 (gnus-save-hidden-threads
7579 (let ((beg (point)))
7580 ;; We check that there are unread articles.
7581 (when (or all (gnus-summary-find-prev))
7582 (gnus-summary-catchup all t beg)))))
7583 (gnus-summary-position-point))
7585 (defun gnus-summary-catchup-all (&optional quietly)
7586 "Mark all articles in this newsgroup as read."
7588 (gnus-set-global-variables)
7589 (gnus-summary-catchup t quietly))
7591 (defun gnus-summary-catchup-and-exit (&optional all quietly)
7592 "Mark all articles not marked as unread in this newsgroup as read, then exit.
7593 If prefix argument ALL is non-nil, all articles are marked as read."
7595 (gnus-set-global-variables)
7596 (when (gnus-summary-catchup all quietly nil 'fast)
7597 ;; Select next newsgroup or exit.
7598 (if (eq gnus-auto-select-next 'quietly)
7599 (gnus-summary-next-group nil)
7600 (gnus-summary-exit))))
7602 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
7603 "Mark all articles in this newsgroup as read, and then exit."
7605 (gnus-set-global-variables)
7606 (gnus-summary-catchup-and-exit t quietly))
7608 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
7609 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
7610 "Mark all articles in this group as read and select the next group.
7611 If given a prefix, mark all articles, unread as well as ticked, as
7614 (gnus-set-global-variables)
7616 (gnus-summary-catchup all))
7617 (gnus-summary-next-article t nil nil t))
7619 ;; Thread-based commands.
7621 (defun gnus-summary-articles-in-thread (&optional article)
7622 "Return a list of all articles in the current thread.
7623 If ARTICLE is non-nil, return all articles in the thread that starts
7625 (let* ((article (or article (gnus-summary-article-number)))
7626 (data (gnus-data-find-list article))
7627 (top-level (gnus-data-level (car data)))
7629 (cond ((null gnus-thread-operation-ignore-subject)
7630 (gnus-simplify-subject-re
7631 (mail-header-subject (gnus-data-header (car data)))))
7632 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
7633 (gnus-simplify-subject-fuzzy
7634 (mail-header-subject (gnus-data-header (car data)))))
7636 (end-point (save-excursion
7637 (if (gnus-summary-go-to-next-thread)
7638 (point) (point-max))))
7641 (< (gnus-data-pos (car data)) end-point))
7642 (when (or (not top-subject)
7643 (string= top-subject
7644 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
7645 (gnus-simplify-subject-fuzzy
7646 (mail-header-subject
7647 (gnus-data-header (car data))))
7648 (gnus-simplify-subject-re
7649 (mail-header-subject
7650 (gnus-data-header (car data)))))))
7651 (push (gnus-data-number (car data)) articles))
7652 (unless (and (setq data (cdr data))
7653 (> (gnus-data-level (car data)) top-level))
7655 ;; Return the list of articles.
7656 (nreverse articles)))
7658 (defun gnus-summary-rethread-current ()
7659 "Rethread the thread the current article is part of."
7661 (gnus-set-global-variables)
7662 (let* ((gnus-show-threads t)
7663 (article (gnus-summary-article-number))
7664 (id (mail-header-id (gnus-summary-article-header)))
7665 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
7667 (error "No article on the current line"))
7668 (gnus-rebuild-thread id)
7669 (gnus-summary-goto-subject article)))
7671 (defun gnus-summary-reparent-thread ()
7672 "Make current article child of the marked (or previous) article.
7674 Note that the re-threading will only work if `gnus-thread-ignore-subject'
7675 is non-nil or the Subject: of both articles are the same."
7677 (unless (not (gnus-group-read-only-p))
7678 (error "The current newsgroup does not support article editing."))
7679 (unless (<= (length gnus-newsgroup-processable) 1)
7680 (error "No more than one article may be marked."))
7681 (save-window-excursion
7682 (let ((gnus-article-buffer " *reparent*")
7683 (current-article (gnus-summary-article-number))
7684 ; first grab the marked article, otherwise one line up.
7685 (parent-article (if (not (null gnus-newsgroup-processable))
7686 (car gnus-newsgroup-processable)
7688 (if (eq (forward-line -1) 0)
7689 (gnus-summary-article-number)
7690 (error "Beginning of summary buffer."))))))
7691 (unless (not (eq current-article parent-article))
7692 (error "An article may not be self-referential."))
7693 (let ((message-id (mail-header-id
7694 (gnus-summary-article-header parent-article))))
7695 (unless (and message-id (not (equal message-id "")))
7696 (error "No message-id in desired parent."))
7697 (gnus-summary-select-article t t nil current-article)
7698 (set-buffer gnus-article-buffer)
7699 (setq buffer-read-only nil)
7700 (let ((buf (format "%s" (buffer-string))))
7703 (goto-char (point-min))
7704 (if (search-forward-regexp "^References: " nil t)
7705 (insert message-id " " )
7706 (insert "References: " message-id "\n"))
7707 (unless (gnus-request-replace-article current-article
7708 (car gnus-article-current)
7709 gnus-article-buffer)
7710 (error "Couldn't replace article."))
7711 (set-buffer gnus-summary-buffer)
7712 (gnus-summary-unmark-all-processable)
7713 (gnus-summary-rethread-current)
7714 (gnus-message 3 "Article %d is now the child of article %d."
7715 current-article parent-article)))))
7717 (defun gnus-summary-toggle-threads (&optional arg)
7718 "Toggle showing conversation threads.
7719 If ARG is positive number, turn showing conversation threads on."
7721 (gnus-set-global-variables)
7722 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
7723 (setq gnus-show-threads
7724 (if (null arg) (not gnus-show-threads)
7725 (> (prefix-numeric-value arg) 0)))
7726 (gnus-summary-prepare)
7727 (gnus-summary-goto-subject current)
7728 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
7729 (gnus-summary-position-point)))
7731 (defun gnus-summary-show-all-threads ()
7734 (gnus-set-global-variables)
7736 (let ((buffer-read-only nil))
7737 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
7738 (gnus-summary-position-point))
7740 (defun gnus-summary-show-thread ()
7741 "Show thread subtrees.
7742 Returns nil if no thread was there to be shown."
7744 (gnus-set-global-variables)
7745 (let ((buffer-read-only nil)
7747 ;; first goto end then to beg, to have point at beg after let
7748 (end (progn (end-of-line) (point)))
7749 (beg (progn (beginning-of-line) (point))))
7751 ;; Any hidden lines here?
7752 (search-forward "\r" end t)
7753 (subst-char-in-region beg end ?\^M ?\n t)
7755 (gnus-summary-position-point))))
7757 (defun gnus-summary-hide-all-threads ()
7758 "Hide all thread subtrees."
7760 (gnus-set-global-variables)
7762 (goto-char (point-min))
7763 (gnus-summary-hide-thread)
7764 (while (zerop (gnus-summary-next-thread 1 t))
7765 (gnus-summary-hide-thread)))
7766 (gnus-summary-position-point))
7768 (defun gnus-summary-hide-thread ()
7769 "Hide thread subtrees.
7770 Returns nil if no threads were there to be hidden."
7772 (gnus-set-global-variables)
7773 (let ((buffer-read-only nil)
7775 (article (gnus-summary-article-number)))
7777 ;; Go forward until either the buffer ends or the subthread
7779 (when (and (not (eobp))
7780 (or (zerop (gnus-summary-next-thread 1 t))
7781 (goto-char (point-max))))
7783 (if (and (> (point) start)
7784 (search-backward "\n" start t))
7786 (subst-char-in-region start (point) ?\n ?\^M)
7787 (gnus-summary-goto-subject article))
7790 ;;(gnus-summary-position-point)
7793 (defun gnus-summary-go-to-next-thread (&optional previous)
7794 "Go to the same level (or less) next thread.
7795 If PREVIOUS is non-nil, go to previous thread instead.
7796 Return the article number moved to, or nil if moving was impossible."
7797 (let ((level (gnus-summary-thread-level))
7798 (way (if previous -1 1))
7801 (while (and (not (eobp))
7802 (< level (gnus-summary-thread-level)))
7810 (gnus-summary-article-number)
7813 (defun gnus-summary-next-thread (n &optional silent)
7814 "Go to the same level next N'th thread.
7815 If N is negative, search backward instead.
7816 Returns the difference between N and the number of skips actually
7819 If SILENT, don't output messages."
7821 (gnus-set-global-variables)
7822 (let ((backward (< n 0))
7825 (gnus-summary-go-to-next-thread backward))
7828 (gnus-summary-position-point))
7829 (when (and (not silent) (/= 0 n))
7830 (gnus-message 7 "No more threads"))
7833 (defun gnus-summary-prev-thread (n)
7834 "Go to the same level previous N'th thread.
7835 Returns the difference between N and the number of skips actually
7838 (gnus-set-global-variables)
7839 (gnus-summary-next-thread (- n)))
7841 (defun gnus-summary-go-down-thread ()
7842 "Go down one level in the current thread."
7843 (let ((children (gnus-summary-article-children)))
7845 (gnus-summary-goto-subject (car children)))))
7847 (defun gnus-summary-go-up-thread ()
7848 "Go up one level in the current thread."
7849 (let ((parent (gnus-summary-article-parent)))
7851 (gnus-summary-goto-subject parent))))
7853 (defun gnus-summary-down-thread (n)
7854 "Go down thread N steps.
7855 If N is negative, go up instead.
7856 Returns the difference between N and how many steps down that were
7859 (gnus-set-global-variables)
7863 (if up (gnus-summary-go-up-thread)
7864 (gnus-summary-go-down-thread)))
7866 (gnus-summary-position-point)
7868 (gnus-message 7 "Can't go further"))
7871 (defun gnus-summary-up-thread (n)
7872 "Go up thread N steps.
7873 If N is negative, go up instead.
7874 Returns the difference between N and how many steps down that were
7877 (gnus-set-global-variables)
7878 (gnus-summary-down-thread (- n)))
7880 (defun gnus-summary-top-thread ()
7881 "Go to the top of the thread."
7883 (gnus-set-global-variables)
7884 (while (gnus-summary-go-up-thread))
7885 (gnus-summary-article-number))
7887 (defun gnus-summary-kill-thread (&optional unmark)
7888 "Mark articles under current thread as read.
7889 If the prefix argument is positive, remove any kinds of marks.
7890 If the prefix argument is negative, tick articles instead."
7892 (gnus-set-global-variables)
7894 (setq unmark (prefix-numeric-value unmark)))
7895 (let ((articles (gnus-summary-articles-in-thread)))
7897 ;; Expand the thread.
7898 (gnus-summary-show-thread)
7899 ;; Mark all the articles.
7901 (gnus-summary-goto-subject (car articles))
7902 (cond ((null unmark)
7903 (gnus-summary-mark-article-as-read gnus-killed-mark))
7905 (gnus-summary-mark-article-as-unread gnus-unread-mark))
7907 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
7908 (setq articles (cdr articles))))
7909 ;; Hide killed subtrees.
7911 gnus-thread-hide-killed
7912 (gnus-summary-hide-thread))
7913 ;; If marked as read, go to next unread subject.
7915 ;; Go to next unread subject.
7916 (gnus-summary-next-subject 1 t)))
7917 (gnus-set-mode-line 'summary))
7919 ;; Summary sorting commands
7921 (defun gnus-summary-sort-by-number (&optional reverse)
7922 "Sort the summary buffer by article number.
7923 Argument REVERSE means reverse order."
7925 (gnus-summary-sort 'number reverse))
7927 (defun gnus-summary-sort-by-author (&optional reverse)
7928 "Sort the summary buffer by author name alphabetically.
7929 If case-fold-search is non-nil, case of letters is ignored.
7930 Argument REVERSE means reverse order."
7932 (gnus-summary-sort 'author reverse))
7934 (defun gnus-summary-sort-by-subject (&optional reverse)
7935 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
7936 If case-fold-search is non-nil, case of letters is ignored.
7937 Argument REVERSE means reverse order."
7939 (gnus-summary-sort 'subject reverse))
7941 (defun gnus-summary-sort-by-date (&optional reverse)
7942 "Sort the summary buffer by date.
7943 Argument REVERSE means reverse order."
7945 (gnus-summary-sort 'date reverse))
7947 (defun gnus-summary-sort-by-score (&optional reverse)
7948 "Sort the summary buffer by score.
7949 Argument REVERSE means reverse order."
7951 (gnus-summary-sort 'score reverse))
7953 (defun gnus-summary-sort-by-lines (&optional reverse)
7954 "Sort the summary buffer by article length.
7955 Argument REVERSE means reverse order."
7957 (gnus-summary-sort 'lines reverse))
7959 (defun gnus-summary-sort (predicate reverse)
7960 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
7961 (gnus-set-global-variables)
7962 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
7963 (article (intern (format "gnus-article-sort-by-%s" predicate)))
7964 (gnus-thread-sort-functions
7970 (gnus-article-sort-functions
7975 (,article t2 t1)))))
7977 (gnus-summary-prepare-hook nil))
7978 ;; We do the sorting by regenerating the threads.
7979 (gnus-summary-prepare)
7980 ;; Hide subthreads if needed.
7981 (when (and gnus-show-threads gnus-thread-hide-subtree)
7982 (gnus-summary-hide-all-threads))))
7984 ;; Summary saving commands.
7986 (defun gnus-summary-save-article (&optional n not-saved)
7987 "Save the current article using the default saver function.
7988 If N is a positive number, save the N next articles.
7989 If N is a negative number, save the N previous articles.
7990 If N is nil and any articles have been marked with the process mark,
7991 save those articles instead.
7992 The variable `gnus-default-article-saver' specifies the saver function."
7994 (gnus-set-global-variables)
7995 (let* ((articles (gnus-summary-work-articles n))
7996 (save-buffer (save-excursion
7997 (nnheader-set-temp-buffer " *Gnus Save*")))
7998 (num (length articles))
7999 header article file)
8001 (setq header (gnus-summary-article-header
8002 (setq article (pop articles))))
8003 (if (not (vectorp header))
8004 ;; This is a pseudo-article.
8005 (if (assq 'name header)
8006 (gnus-copy-file (cdr (assq 'name header)))
8007 (gnus-message 1 "Article %d is unsaveable" article))
8008 ;; This is a real article.
8009 (save-window-excursion
8010 (gnus-summary-select-article t nil nil article))
8012 (set-buffer save-buffer)
8014 (insert-buffer-substring gnus-original-article-buffer))
8015 (setq file (gnus-article-save save-buffer file num))
8016 (gnus-summary-remove-process-mark article)
8018 (gnus-summary-set-saved-mark article))))
8019 (gnus-kill-buffer save-buffer)
8020 (gnus-summary-position-point)
8023 (defun gnus-summary-pipe-output (&optional arg)
8024 "Pipe the current article to a subprocess.
8025 If N is a positive number, pipe the N next articles.
8026 If N is a negative number, pipe the N previous articles.
8027 If N is nil and any articles have been marked with the process mark,
8028 pipe those articles instead."
8030 (gnus-set-global-variables)
8031 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8032 (gnus-summary-save-article arg t))
8033 (gnus-configure-windows 'pipe))
8035 (defun gnus-summary-save-article-mail (&optional arg)
8036 "Append the current article to an mail file.
8037 If N is a positive number, save the N next articles.
8038 If N is a negative number, save the N previous articles.
8039 If N is nil and any articles have been marked with the process mark,
8040 save those articles instead."
8042 (gnus-set-global-variables)
8043 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8044 (gnus-summary-save-article arg)))
8046 (defun gnus-summary-save-article-rmail (&optional arg)
8047 "Append the current article to an rmail file.
8048 If N is a positive number, save the N next articles.
8049 If N is a negative number, save the N previous articles.
8050 If N is nil and any articles have been marked with the process mark,
8051 save those articles instead."
8053 (gnus-set-global-variables)
8054 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
8055 (gnus-summary-save-article arg)))
8057 (defun gnus-summary-save-article-file (&optional arg)
8058 "Append the current article to a file.
8059 If N is a positive number, save the N next articles.
8060 If N is a negative number, save the N previous articles.
8061 If N is nil and any articles have been marked with the process mark,
8062 save those articles instead."
8064 (gnus-set-global-variables)
8065 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8066 (gnus-summary-save-article arg)))
8068 (defun gnus-summary-write-article-file (&optional arg)
8069 "Write the current article to a file, deleting the previous file.
8070 If N is a positive number, save the N next articles.
8071 If N is a negative number, save the N previous articles.
8072 If N is nil and any articles have been marked with the process mark,
8073 save those articles instead."
8075 (gnus-set-global-variables)
8076 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
8077 (gnus-summary-save-article arg)))
8079 (defun gnus-summary-save-article-body-file (&optional arg)
8080 "Append the current article body to a file.
8081 If N is a positive number, save the N next articles.
8082 If N is a negative number, save the N previous articles.
8083 If N is nil and any articles have been marked with the process mark,
8084 save those articles instead."
8086 (gnus-set-global-variables)
8087 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
8088 (gnus-summary-save-article arg)))
8090 (defun gnus-get-split-value (methods)
8091 "Return a value based on the split METHODS."
8092 (let (split-name method result match)
8095 (set-buffer gnus-original-article-buffer)
8097 (nnheader-narrow-to-headers)
8099 (goto-char (point-min))
8100 (setq method (pop methods))
8101 (setq match (car method))
8104 ;; Regular expression.
8106 (re-search-forward match nil t)))
8107 ((gnus-functionp match)
8111 (setq result (funcall match gnus-newsgroup-name))))
8116 (setq result (eval match)))))
8117 (setq split-name (append (cdr method) split-name))
8118 (cond ((stringp result)
8119 (push result split-name))
8121 (setq split-name (append result split-name)))))))))
8124 (defun gnus-valid-move-group-p (group)
8129 (car (gnus-find-method-for-group
8130 (symbol-name group))))
8131 gnus-valid-select-methods))))
8133 (defun gnus-read-move-group-name (prompt default articles prefix)
8134 "Read a group name."
8135 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
8136 (minibuffer-confirm-incomplete nil) ; XEmacs
8140 (if (> (length articles) 1)
8141 (format "these %d articles" (length articles))
8146 (gnus-completing-read default prom
8148 'gnus-valid-move-group-p
8150 'gnus-group-history))
8151 ((= 1 (length split-name))
8152 (gnus-completing-read (car split-name) prom
8154 'gnus-valid-move-group-p
8156 'gnus-group-history))
8158 (gnus-completing-read nil prom
8159 (mapcar (lambda (el) (list el))
8160 (nreverse split-name))
8162 'gnus-group-history)))))
8164 (if (or (string= to-newsgroup "")
8165 (string= to-newsgroup prefix))
8166 (setq to-newsgroup (or default "")))
8167 (or (gnus-active to-newsgroup)
8168 (gnus-activate-group to-newsgroup)
8169 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
8171 (or (and (gnus-request-create-group
8172 to-newsgroup (gnus-group-name-to-method to-newsgroup))
8173 (gnus-activate-group to-newsgroup nil nil
8174 (gnus-group-name-to-method
8176 (error "Couldn't create group %s" to-newsgroup)))
8177 (error "No such group: %s" to-newsgroup)))
8180 ;; Summary extract commands
8182 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
8183 (let ((buffer-read-only nil)
8184 (article (gnus-summary-article-number))
8186 (unless (gnus-summary-goto-subject article)
8187 (error "No such article: %d" article))
8188 (gnus-summary-position-point)
8189 ;; If all commands are to be bunched up on one line, we collect
8191 (unless gnus-view-pseudos-separately
8192 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
8195 (setq action (cdr (assq 'action (car ps))))
8196 (setq files (list (cdr (assq 'name (car ps)))))
8197 (while (and ps (cdr ps)
8198 (string= (or action "1")
8199 (or (cdr (assq 'action (cadr ps))) "2")))
8200 (push (cdr (assq 'name (cadr ps))) files)
8201 (setcdr ps (cddr ps)))
8203 (when (not (string-match "%s" action))
8206 (when (assq 'execute (car ps))
8207 (setcdr (assq 'execute (car ps))
8208 (funcall (if (string-match "%s" action)
8211 (mapconcat (lambda (f) f) files " ")))))
8212 (setq ps (cdr ps)))))
8213 (if (and gnus-view-pseudos (not not-view))
8215 (when (assq 'execute (car pslist))
8216 (gnus-execute-command (cdr (assq 'execute (car pslist)))
8217 (eq gnus-view-pseudos 'not-confirm)))
8218 (setq pslist (cdr pslist)))
8221 (setq after-article (or (cdr (assq 'article (car pslist)))
8222 (gnus-summary-article-number)))
8223 (gnus-summary-goto-subject after-article)
8226 (insert " " (file-name-nondirectory
8227 (cdr (assq 'name (car pslist))))
8228 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
8230 (forward-line -1) ; back to `b'
8231 (gnus-add-text-properties
8232 b (1- e) (list 'gnus-number gnus-reffed-article-number
8233 gnus-mouse-face-prop gnus-mouse-face))
8235 after-article gnus-reffed-article-number
8236 gnus-unread-mark b (car pslist) 0 (- e b))
8237 (push gnus-reffed-article-number gnus-newsgroup-unreads)
8238 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
8239 (setq pslist (cdr pslist)))))))
8241 (defun gnus-pseudos< (p1 p2)
8242 (let ((c1 (cdr (assq 'action p1)))
8243 (c2 (cdr (assq 'action p2))))
8244 (and c1 c2 (string< c1 c2))))
8246 (defun gnus-request-pseudo-article (props)
8247 (cond ((assq 'execute props)
8248 (gnus-execute-command (cdr (assq 'execute props)))))
8249 (let ((gnus-current-article (gnus-summary-article-number)))
8250 (run-hooks 'gnus-mark-article-hook)))
8252 (defun gnus-execute-command (command &optional automatic)
8254 (gnus-article-setup-buffer)
8255 (set-buffer gnus-article-buffer)
8256 (setq buffer-read-only nil)
8257 (let ((command (if automatic command (read-string "Command: " command)))
8258 ;; Just binding this here doesn't help, because there might
8259 ;; be output from the process after exiting the scope of
8261 ;; (buffer-read-only nil)
8264 (insert "$ " command "\n\n")
8265 (if gnus-view-pseudo-asynchronously
8266 (start-process "gnus-execute" nil shell-file-name
8267 shell-command-switch command)
8268 (call-process shell-file-name nil t nil
8269 shell-command-switch command)))))
8271 ;; Summary kill commands.
8273 (defun gnus-summary-edit-global-kill (article)
8274 "Edit the \"global\" kill file."
8275 (interactive (list (gnus-summary-article-number)))
8276 (gnus-set-global-variables)
8277 (gnus-group-edit-global-kill article))
8279 (defun gnus-summary-edit-local-kill ()
8280 "Edit a local kill file applied to the current newsgroup."
8282 (gnus-set-global-variables)
8283 (setq gnus-current-headers (gnus-summary-article-header))
8284 (gnus-set-global-variables)
8285 (gnus-group-edit-local-kill
8286 (gnus-summary-article-number) gnus-newsgroup-name))
8290 (defun gnus-read-header (id &optional header)
8291 "Read the headers of article ID and enter them into the Gnus system."
8292 (let ((group gnus-newsgroup-name)
8293 (gnus-override-method
8294 (and (gnus-news-group-p gnus-newsgroup-name)
8295 gnus-refer-article-method))
8297 ;; First we check to see whether the header in question is already
8300 ;; This is a Message-ID.
8301 (setq header (or header (gnus-id-to-header id)))
8302 ;; This is an article number.
8303 (setq header (or header (gnus-summary-article-header id))))
8305 (not (gnus-summary-article-sparse-p (mail-header-number header))))
8306 ;; We have found the header.
8308 ;; We have to really fetch the header to this article.
8310 (set-buffer nntp-server-buffer)
8311 (when (setq where (gnus-request-head id group))
8312 (goto-char (point-max))
8314 (goto-char (point-min))
8318 ((cdr where) (cdr where))
8319 (header (mail-header-number header))
8320 (t gnus-reffed-article-number))
8322 (insert " Article retrieved.\n"))
8323 (if (not (setq header (car (gnus-get-newsgroup-headers nil t))))
8324 () ; Malformed head.
8325 (unless (gnus-summary-article-sparse-p (mail-header-number header))
8326 (when (and (stringp id)
8327 (not (string= (gnus-group-real-name group)
8329 ;; If we fetched by Message-ID and the article came
8330 ;; from a different group, we fudge some bogus article
8331 ;; numbers for this article.
8332 (mail-header-set-number header gnus-reffed-article-number))
8334 (set-buffer gnus-summary-buffer)
8335 (decf gnus-reffed-article-number)
8336 (gnus-remove-header (mail-header-number header))
8337 (push header gnus-newsgroup-headers)
8338 (setq gnus-current-headers header)
8339 (push (mail-header-number header) gnus-newsgroup-limit)))
8342 (defun gnus-remove-header (number)
8343 "Remove header NUMBER from `gnus-newsgroup-headers'."
8344 (if (and gnus-newsgroup-headers
8345 (= number (mail-header-number (car gnus-newsgroup-headers))))
8346 (pop gnus-newsgroup-headers)
8347 (let ((headers gnus-newsgroup-headers))
8348 (while (and (cdr headers)
8349 (not (= number (mail-header-number (cadr headers)))))
8352 (setcdr headers (cddr headers))))))
8355 ;;; summary highlights
8358 (defun gnus-highlight-selected-summary ()
8359 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8360 ;; Highlight selected article in summary buffer
8361 (when gnus-summary-selected-face
8363 (let* ((beg (progn (beginning-of-line) (point)))
8364 (end (progn (end-of-line) (point)))
8365 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
8366 (from (if (get-text-property beg gnus-mouse-face-prop)
8368 (or (next-single-property-change
8369 beg gnus-mouse-face-prop nil end)
8374 (or (next-single-property-change
8375 from gnus-mouse-face-prop nil end)
8377 ;; If no mouse-face prop on line we will have to = from = end,
8378 ;; so we highlight the entire line instead.
8379 (when (= (+ to 2) from)
8382 (if gnus-newsgroup-selected-overlay
8383 ;; Move old overlay.
8385 gnus-newsgroup-selected-overlay from to (current-buffer))
8386 ;; Create new overlay.
8388 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
8389 'face gnus-summary-selected-face))))))
8391 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
8392 (defun gnus-summary-highlight-line ()
8393 "Highlight current line according to `gnus-summary-highlight'."
8394 (let* ((list gnus-summary-highlight)
8396 (end (progn (end-of-line) (point)))
8397 ;; now find out where the line starts and leave point there.
8398 (beg (progn (beginning-of-line) (point)))
8399 (article (gnus-summary-article-number))
8400 (score (or (cdr (assq (or article gnus-current-article)
8401 gnus-newsgroup-scored))
8402 gnus-summary-default-score 0))
8403 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
8404 (inhibit-read-only t))
8405 ;; Eval the cars of the lists until we find a match.
8406 (let ((default gnus-summary-default-score))
8408 (not (eval (caar list))))
8409 (setq list (cdr list))))
8410 (let ((face (cdar list)))
8411 (unless (eq face (get-text-property beg 'face))
8412 (gnus-put-text-property
8414 (setq face (if (boundp face) (symbol-value face) face)))
8415 (when gnus-summary-highlight-line-function
8416 (funcall gnus-summary-highlight-line-function article face))))
8419 (defun gnus-update-read-articles (group unread)
8420 "Update the list of read articles in GROUP."
8421 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
8422 (entry (gnus-gethash group gnus-newsrc-hashtb))
8423 (info (nth 2 entry))
8425 (unread (sort (copy-sequence unread) '<))
8427 (if (or (not info) (not active))
8428 ;; There is no info on this group if it was, in fact,
8429 ;; killed. Gnus stores no information on killed groups, so
8430 ;; there's nothing to be done.
8431 ;; One could store the information somewhere temporarily,
8432 ;; perhaps... Hmmm...
8434 ;; Remove any negative articles numbers.
8435 (while (and unread (< (car unread) 0))
8436 (setq unread (cdr unread)))
8437 ;; Remove any expired article numbers
8438 (while (and unread (< (car unread) (car active)))
8439 (setq unread (cdr unread)))
8440 ;; Compute the ranges of read articles by looking at the list of
8443 (when (/= (car unread) prev)
8444 (push (if (= prev (1- (car unread))) prev
8445 (cons prev (1- (car unread))))
8447 (setq prev (1+ (car unread)))
8448 (setq unread (cdr unread)))
8449 (when (<= prev (cdr active))
8450 (push (cons prev (cdr active)) read))
8452 (set-buffer gnus-group-buffer)
8455 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
8456 (gnus-info-set-read ',info ',(gnus-info-read info))
8457 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
8458 (gnus-group-update-group ,group t))))
8459 ;; Enter this list into the group info.
8461 info (if (> (length read) 1) (nreverse read) read))
8462 ;; Set the number of unread articles in gnus-newsrc-hashtb.
8463 (gnus-get-unread-articles-in-group info (gnus-active group))
8468 (run-hooks 'gnus-sum-load-hook)
8470 ;;; gnus-sum.el ends here