1 ;;; gnus-sum.el --- summary mode commands for Gnus
2 ;; Copyright (C) 1996,97 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.
28 (eval-when-compile (require 'cl))
38 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
39 (autoload 'gnus-set-summary-default-charset "gnus-i18n" nil t)
41 (defcustom gnus-kill-summary-on-exit t
42 "*If non-nil, kill the summary buffer when you exit from it.
43 If nil, the summary will become a \"*Dead Summary*\" buffer, and
44 it will be killed sometime later."
45 :group 'gnus-summary-exit
48 (defcustom gnus-fetch-old-headers nil
49 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
50 If an unread article in the group refers to an older, already read (or
51 just marked as read) article, the old article will not normally be
52 displayed in the Summary buffer. If this variable is non-nil, Gnus
53 will attempt to grab the headers to the old articles, and thereby
54 build complete threads. If it has the value `some', only enough
55 headers to connect otherwise loose threads will be displayed. This
56 variable can also be a number. In that case, no more than that number
57 of old headers will be fetched. If it has the value `invisible', all
58 old headers will be fetched, but none will be displayed.
60 The server has to support NOV for any of this to work."
62 :type '(choice (const :tag "off" nil)
65 (sexp :menu-tag "other" t)))
67 (defcustom gnus-refer-thread-limit 200
68 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
69 If t, fetch all the available old headers."
72 (sexp :menu-tag "other" t)))
74 (defcustom gnus-summary-make-false-root 'adopt
75 "*nil means that Gnus won't gather loose threads.
76 If the root of a thread has expired or been read in a previous
77 session, the information necessary to build a complete thread has been
78 lost. Instead of having many small sub-threads from this original thread
79 scattered all over the summary buffer, Gnus can gather them.
81 If non-nil, Gnus will try to gather all loose sub-threads from an
82 original thread into one large thread.
84 If this variable is non-nil, it should be one of `none', `adopt',
87 If this variable is `none', Gnus will not make a false root, but just
88 present the sub-threads after another.
89 If this variable is `dummy', Gnus will create a dummy root that will
90 have all the sub-threads as children.
91 If this variable is `adopt', Gnus will make one of the \"children\"
92 the parent and mark all the step-children as such.
93 If this variable is `empty', the \"children\" are printed with empty
94 subject fields. (Or rather, they will be printed with a string
95 given by the `gnus-summary-same-subject' variable.)"
97 :type '(choice (const :tag "off" nil)
103 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
104 "*A regexp to match subjects to be excluded from loose thread gathering.
105 As loose thread gathering is done on subjects only, that means that
106 there can be many false gatherings performed. By rooting out certain
107 common subjects, gathering might become saner."
111 (defcustom gnus-summary-gather-subject-limit nil
112 "*Maximum length of subject comparisons when gathering loose threads.
113 Use nil to compare full subjects. Setting this variable to a low
114 number will help gather threads that have been corrupted by
115 newsreaders chopping off subject lines, but it might also mean that
116 unrelated articles that have subject that happen to begin with the
117 same few characters will be incorrectly gathered.
119 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
122 :type '(choice (const :tag "off" nil)
124 (sexp :menu-tag "on" t)))
126 (defcustom gnus-simplify-subject-functions nil
127 "List of functions taking a string argument that simplify subjects.
128 The functions are applied recursively."
130 :type '(repeat (list function)))
132 (defcustom gnus-simplify-ignored-prefixes nil
133 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
135 :type '(choice (const :tag "off" nil)
138 (defcustom gnus-build-sparse-threads nil
139 "*If non-nil, fill in the gaps in threads.
140 If `some', only fill in the gaps that are needed to tie loose threads
141 together. If `more', fill in all leaf nodes that Gnus can find. If
142 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
144 :type '(choice (const :tag "off" nil)
147 (sexp :menu-tag "all" t)))
149 (defcustom gnus-summary-thread-gathering-function
150 'gnus-gather-threads-by-subject
151 "Function used for gathering loose threads.
152 There are two pre-defined functions: `gnus-gather-threads-by-subject',
153 which only takes Subjects into consideration; and
154 `gnus-gather-threads-by-references', which compared the References
155 headers of the articles to find matches."
157 :type '(radio (function-item gnus-gather-threads-by-subject)
158 (function-item gnus-gather-threads-by-references)
159 (function :tag "other")))
161 (defcustom gnus-summary-same-subject ""
162 "*String indicating that the current article has the same subject as the previous.
163 This variable will only be used if the value of
164 `gnus-summary-make-false-root' is `empty'."
165 :group 'gnus-summary-format
168 (defcustom gnus-summary-goto-unread t
169 "*If t, marking commands will go to the next unread article.
170 If `never', commands that usually go to the next unread article, will
171 go to the next article, whether it is read or not.
172 If nil, only the marking commands will go to the next (un)read article."
173 :group 'gnus-summary-marks
174 :link '(custom-manual "(gnus)Setting Marks")
175 :type '(choice (const :tag "off" nil)
177 (sexp :menu-tag "on" t)))
179 (defcustom gnus-summary-default-score 0
180 "*Default article score level.
181 All scores generated by the score files will be added to this score.
182 If this variable is nil, scoring will be disabled."
183 :group 'gnus-score-default
184 :type '(choice (const :tag "disable")
187 (defcustom gnus-summary-zcore-fuzz 0
188 "*Fuzziness factor for the zcore in the summary buffer.
189 Articles with scores closer than this to `gnus-summary-default-score'
191 :group 'gnus-summary-format
194 (defcustom gnus-simplify-subject-fuzzy-regexp nil
195 "*Strings to be removed when doing fuzzy matches.
196 This can either be a regular expression or list of regular expressions
197 that will be removed from subject strings if fuzzy subject
198 simplification is selected."
200 :type '(repeat regexp))
202 (defcustom gnus-show-threads t
203 "*If non-nil, display threads in summary mode."
207 (defcustom gnus-thread-hide-subtree nil
208 "*If non-nil, hide all threads initially.
209 If threads are hidden, you have to run the command
210 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
211 to expose hidden threads."
215 (defcustom gnus-thread-hide-killed t
216 "*If non-nil, hide killed threads automatically."
220 (defcustom gnus-thread-ignore-subject nil
221 "*If non-nil, ignore subjects and do all threading based on the Reference header.
222 If nil, which is the default, articles that have different subjects
223 from their parents will start separate threads."
227 (defcustom gnus-thread-operation-ignore-subject t
228 "*If non-nil, subjects will be ignored when doing thread commands.
229 This affects commands like `gnus-summary-kill-thread' and
230 `gnus-summary-lower-thread'.
232 If this variable is nil, articles in the same thread with different
233 subjects will not be included in the operation in question. If this
234 variable is `fuzzy', only articles that have subjects that are fuzzily
235 equal will be included."
237 :type '(choice (const :tag "off" nil)
241 (defcustom gnus-thread-indent-level 4
242 "*Number that says how much each sub-thread should be indented."
246 (defcustom gnus-auto-extend-newsgroup t
247 "*If non-nil, extend newsgroup forward and backward when requested."
248 :group 'gnus-summary-choose
251 (defcustom gnus-auto-select-first t
252 "*If nil, don't select the first unread article when entering a group.
253 If this variable is `best', select the highest-scored unread article
254 in the group. If neither nil nor `best', select the first unread
257 If you want to prevent automatic selection of the first unread article
258 in some newsgroups, set the variable to nil in
259 `gnus-select-group-hook'."
260 :group 'gnus-group-select
261 :type '(choice (const :tag "none" nil)
263 (sexp :menu-tag "first" t)))
265 (defcustom gnus-auto-select-next t
266 "*If non-nil, offer to go to the next group from the end of the previous.
267 If the value is t and the next newsgroup is empty, Gnus will exit
268 summary mode and go back to group mode. If the value is neither nil
269 nor t, Gnus will select the following unread newsgroup. In
270 particular, if the value is the symbol `quietly', the next unread
271 newsgroup will be selected without any confirmation, and if it is
272 `almost-quietly', the next group will be selected without any
273 confirmation if you are located on the last article in the group.
274 Finally, if this variable is `slightly-quietly', the `Z n' command
275 will go to the next group without confirmation."
276 :group 'gnus-summary-maneuvering
277 :type '(choice (const :tag "off" nil)
279 (const almost-quietly)
280 (const slightly-quietly)
281 (sexp :menu-tag "on" t)))
283 (defcustom gnus-auto-select-same nil
284 "*If non-nil, select the next article with the same subject."
285 :group 'gnus-summary-maneuvering
288 (defcustom gnus-summary-check-current nil
289 "*If non-nil, consider the current article when moving.
290 The \"unread\" movement commands will stay on the same line if the
291 current article is unread."
292 :group 'gnus-summary-maneuvering
295 (defcustom gnus-auto-center-summary t
296 "*If non-nil, always center the current summary buffer.
297 In particular, if `vertical' do only vertical recentering. If non-nil
298 and non-`vertical', do both horizontal and vertical recentering."
299 :group 'gnus-summary-maneuvering
300 :type '(choice (const :tag "none" nil)
302 (sexp :menu-tag "both" t)))
304 (defcustom gnus-show-all-headers nil
305 "*If non-nil, don't hide any headers."
306 :group 'gnus-article-hiding
307 :group 'gnus-article-headers
310 (defcustom gnus-summary-ignore-duplicates nil
311 "*If non-nil, ignore articles with identical Message-ID headers."
315 (defcustom gnus-single-article-buffer t
316 "*If non-nil, display all articles in the same buffer.
317 If nil, each group will get its own article buffer."
318 :group 'gnus-article-various
321 (defcustom gnus-break-pages t
322 "*If non-nil, do page breaking on articles.
323 The page delimiter is specified by the `gnus-page-delimiter'
325 :group 'gnus-article-various
328 (defcustom gnus-show-mime t
329 "*If non-nil, do mime processing of articles.
330 The articles will simply be fed to the function given by
331 `gnus-show-mime-method'."
332 :group 'gnus-article-mime
335 (defcustom gnus-move-split-methods nil
336 "*Variable used to suggest where articles are to be moved to.
337 It uses the same syntax as the `gnus-split-methods' variable."
338 :group 'gnus-summary-mail
339 :type '(repeat (choice (list function)
340 (cons regexp (repeat string))
343 (defcustom gnus-unread-mark ?
344 "*Mark used for unread articles."
345 :group 'gnus-summary-marks
348 (defcustom gnus-ticked-mark ?!
349 "*Mark used for ticked articles."
350 :group 'gnus-summary-marks
353 (defcustom gnus-dormant-mark ??
354 "*Mark used for dormant articles."
355 :group 'gnus-summary-marks
358 (defcustom gnus-del-mark ?r
359 "*Mark used for del'd articles."
360 :group 'gnus-summary-marks
363 (defcustom gnus-read-mark ?R
364 "*Mark used for read articles."
365 :group 'gnus-summary-marks
368 (defcustom gnus-expirable-mark ?E
369 "*Mark used for expirable articles."
370 :group 'gnus-summary-marks
373 (defcustom gnus-killed-mark ?K
374 "*Mark used for killed articles."
375 :group 'gnus-summary-marks
378 (defcustom gnus-souped-mark ?F
379 "*Mark used for killed articles."
380 :group 'gnus-summary-marks
383 (defcustom gnus-kill-file-mark ?X
384 "*Mark used for articles killed by kill files."
385 :group 'gnus-summary-marks
388 (defcustom gnus-low-score-mark ?Y
389 "*Mark used for articles with a low score."
390 :group 'gnus-summary-marks
393 (defcustom gnus-catchup-mark ?C
394 "*Mark used for articles that are caught up."
395 :group 'gnus-summary-marks
398 (defcustom gnus-replied-mark ?A
399 "*Mark used for articles that have been replied to."
400 :group 'gnus-summary-marks
403 (defcustom gnus-cached-mark ?*
404 "*Mark used for articles that are in the cache."
405 :group 'gnus-summary-marks
408 (defcustom gnus-saved-mark ?S
409 "*Mark used for articles that have been saved to."
410 :group 'gnus-summary-marks
413 (defcustom gnus-ancient-mark ?O
414 "*Mark used for ancient articles."
415 :group 'gnus-summary-marks
418 (defcustom gnus-sparse-mark ?Q
419 "*Mark used for sparsely reffed articles."
420 :group 'gnus-summary-marks
423 (defcustom gnus-canceled-mark ?G
424 "*Mark used for canceled articles."
425 :group 'gnus-summary-marks
428 (defcustom gnus-duplicate-mark ?M
429 "*Mark used for duplicate articles."
430 :group 'gnus-summary-marks
433 (defcustom gnus-undownloaded-mark ?@
434 "*Mark used for articles that weren't downloaded."
435 :group 'gnus-summary-marks
438 (defcustom gnus-downloadable-mark ?%
439 "*Mark used for articles that are to be downloaded."
440 :group 'gnus-summary-marks
443 (defcustom gnus-unsendable-mark ?=
444 "*Mark used for articles that won't be sent."
445 :group 'gnus-summary-marks
448 (defcustom gnus-score-over-mark ?+
449 "*Score mark used for articles with high scores."
450 :group 'gnus-summary-marks
453 (defcustom gnus-score-below-mark ?-
454 "*Score mark used for articles with low scores."
455 :group 'gnus-summary-marks
458 (defcustom gnus-empty-thread-mark ?
459 "*There is no thread under the article."
460 :group 'gnus-summary-marks
463 (defcustom gnus-not-empty-thread-mark ?=
464 "*There is a thread under the article."
465 :group 'gnus-summary-marks
468 (defcustom gnus-view-pseudo-asynchronously nil
469 "*If non-nil, Gnus will view pseudo-articles asynchronously."
470 :group 'gnus-extract-view
473 (defcustom gnus-view-pseudos nil
474 "*If `automatic', pseudo-articles will be viewed automatically.
475 If `not-confirm', pseudos will be viewed automatically, and the user
476 will not be asked to confirm the command."
477 :group 'gnus-extract-view
478 :type '(choice (const :tag "off" nil)
480 (const not-confirm)))
482 (defcustom gnus-view-pseudos-separately t
483 "*If non-nil, one pseudo-article will be created for each file to be viewed.
484 If nil, all files that use the same viewing command will be given as a
485 list of parameters to that command."
486 :group 'gnus-extract-view
489 (defcustom gnus-insert-pseudo-articles t
490 "*If non-nil, insert pseudo-articles when decoding articles."
491 :group 'gnus-extract-view
494 (defcustom gnus-summary-dummy-line-format
496 "*The format specification for the dummy roots in the summary buffer.
497 It works along the same lines as a normal formatting string,
498 with some simple extensions.
501 :group 'gnus-threading
504 (defcustom gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
505 "*The format specification for the summary mode line.
506 It works along the same lines as a normal formatting string,
507 with some simple extensions:
510 %p Unprefixed group name
511 %A Current article number
513 %U Number of unread articles in the group
514 %e Number of unselected articles in the group
515 %Z A string with unread/unselected article counts
516 %g Shortish group name
517 %S Subject of the current article
519 %s Current score file name
520 %d Number of dormant articles
521 %r Number of articles that have been marked as read in this session
522 %E Number of articles expunged by the score files"
523 :group 'gnus-summary-format
526 (defcustom gnus-summary-mark-below 0
527 "*Mark all articles with a score below this variable as read.
528 This variable is local to each summary buffer and usually set by the
530 :group 'gnus-score-default
533 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
534 "*List of functions used for sorting articles in the summary buffer.
535 This variable is only used when not using a threaded display."
536 :group 'gnus-summary-sort
537 :type '(repeat (choice (function-item gnus-article-sort-by-number)
538 (function-item gnus-article-sort-by-author)
539 (function-item gnus-article-sort-by-subject)
540 (function-item gnus-article-sort-by-date)
541 (function-item gnus-article-sort-by-score)
542 (function :tag "other"))))
544 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
545 "*List of functions used for sorting threads in the summary buffer.
546 By default, threads are sorted by article number.
548 Each function takes two threads and return non-nil if the first thread
549 should be sorted before the other. If you use more than one function,
550 the primary sort function should be the last. You should probably
551 always include `gnus-thread-sort-by-number' in the list of sorting
552 functions -- preferably first.
554 Ready-made functions include `gnus-thread-sort-by-number',
555 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
556 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
557 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
558 :group 'gnus-summary-sort
559 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
560 (function-item gnus-thread-sort-by-author)
561 (function-item gnus-thread-sort-by-subject)
562 (function-item gnus-thread-sort-by-date)
563 (function-item gnus-thread-sort-by-score)
564 (function-item gnus-thread-sort-by-total-score)
565 (function :tag "other"))))
567 (defcustom gnus-thread-score-function '+
568 "*Function used for calculating the total score of a thread.
570 The function is called with the scores of the article and each
571 subthread and should then return the score of the thread.
573 Some functions you can use are `+', `max', or `min'."
574 :group 'gnus-summary-sort
577 (defcustom gnus-summary-expunge-below nil
578 "All articles that have a score less than this variable will be expunged.
579 This variable is local to the summary buffers."
580 :group 'gnus-score-default
581 :type '(choice (const :tag "off" nil)
584 (defcustom gnus-thread-expunge-below nil
585 "All threads that have a total score less than this variable will be expunged.
586 See `gnus-thread-score-function' for en explanation of what a
589 This variable is local to the summary buffers."
590 :group 'gnus-treading
591 :group 'gnus-score-default
592 :type '(choice (const :tag "off" nil)
595 (defcustom gnus-summary-mode-hook nil
596 "*A hook for Gnus summary mode.
597 This hook is run before any variables are set in the summary buffer."
598 :group 'gnus-summary-various
601 (defcustom gnus-summary-menu-hook nil
602 "*Hook run after the creation of the summary mode menu."
603 :group 'gnus-summary-visual
606 (defcustom gnus-summary-exit-hook nil
607 "*A hook called on exit from the summary buffer.
608 It will be called with point in the group buffer."
609 :group 'gnus-summary-exit
612 (defcustom gnus-summary-prepare-hook nil
613 "*A hook called after the summary buffer has been generated.
614 If you want to modify the summary buffer, you can use this hook."
615 :group 'gnus-summary-various
618 (defcustom gnus-summary-generate-hook nil
619 "*A hook run just before generating the summary buffer.
620 This hook is commonly used to customize threading variables and the
622 :group 'gnus-summary-various
625 (defcustom gnus-select-group-hook nil
626 "*A hook called when a newsgroup is selected.
628 If you'd like to simplify subjects like the
629 `gnus-summary-next-same-subject' command does, you can use the
632 (setq gnus-select-group-hook
635 (mapcar (lambda (header)
636 (mail-header-set-subject
638 (gnus-simplify-subject
639 (mail-header-subject header) 're-only)))
640 gnus-newsgroup-headers))))"
641 :group 'gnus-group-select
644 (defcustom gnus-select-article-hook nil
645 "*A hook called when an article is selected."
646 :group 'gnus-summary-choose
649 (defcustom gnus-visual-mark-article-hook
650 (list 'gnus-highlight-selected-summary)
651 "*Hook run after selecting an article in the summary buffer.
652 It is meant to be used for highlighting the article in some way. It
653 is not run if `gnus-visual' is nil."
654 :group 'gnus-summary-visual
657 ;; 1997/5/4 by MORIOKA Tomohiko <morioka@jaist.ac.jp>
658 (defcustom gnus-structured-field-decoder
661 (eword-decode-structured-field-body
662 (std11-unfold-string string) 'must-unfold)
664 "Function to decode non-ASCII characters in structured field for summary."
668 (defcustom gnus-unstructured-field-decoder
671 (eword-decode-unstructured-field-body
672 (std11-unfold-string string) 'must-unfold)
674 "Function to decode non-ASCII characters in unstructured field for summary."
678 (defcustom gnus-parse-headers-hook
679 '(gnus-set-summary-default-charset)
680 "*A hook called before parsing the headers."
684 (defcustom gnus-exit-group-hook nil
685 "*A hook called when exiting (not quitting) summary mode."
689 (defcustom gnus-summary-update-hook
690 (list 'gnus-summary-highlight-line)
691 "*A hook called when a summary line is changed.
692 The hook will not be called if `gnus-visual' is nil.
694 The default function `gnus-summary-highlight-line' will
695 highlight the line according to the `gnus-summary-highlight'
697 :group 'gnus-summary-visual
700 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
701 "*A hook called when an article is selected for the first time.
702 The hook is intended to mark an article as read (or unread)
703 automatically when it is selected."
704 :group 'gnus-summary-choose
707 (defcustom gnus-group-no-more-groups-hook nil
708 "*A hook run when returning to group mode having no more (unread) groups."
709 :group 'gnus-group-select
712 (defcustom gnus-ps-print-hook nil
713 "*A hook run before ps-printing something from Gnus."
717 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
718 "Face used for highlighting the current article in the summary buffer."
719 :group 'gnus-summary-visual
722 (defcustom gnus-summary-highlight
723 '(((= mark gnus-canceled-mark)
724 . gnus-summary-cancelled-face)
725 ((and (> score default)
726 (or (= mark gnus-dormant-mark)
727 (= mark gnus-ticked-mark)))
728 . gnus-summary-high-ticked-face)
729 ((and (< score default)
730 (or (= mark gnus-dormant-mark)
731 (= mark gnus-ticked-mark)))
732 . gnus-summary-low-ticked-face)
733 ((or (= mark gnus-dormant-mark)
734 (= mark gnus-ticked-mark))
735 . gnus-summary-normal-ticked-face)
736 ((and (> score default) (= mark gnus-ancient-mark))
737 . gnus-summary-high-ancient-face)
738 ((and (< score default) (= mark gnus-ancient-mark))
739 . gnus-summary-low-ancient-face)
740 ((= mark gnus-ancient-mark)
741 . gnus-summary-normal-ancient-face)
742 ((and (> score default) (= mark gnus-unread-mark))
743 . gnus-summary-high-unread-face)
744 ((and (< score default) (= mark gnus-unread-mark))
745 . gnus-summary-low-unread-face)
746 ((and (= mark gnus-unread-mark))
747 . gnus-summary-normal-unread-face)
749 . gnus-summary-high-read-face)
751 . gnus-summary-low-read-face)
753 . gnus-summary-normal-read-face))
754 "Controls the highlighting of summary buffer lines.
756 A list of (FORM . FACE) pairs. When deciding how a a particular
757 summary line should be displayed, each form is evaluated. The content
758 of the face field after the first true form is used. You can change
759 how those summary lines are displayed, by editing the face field.
761 You can use the following variables in the FORM field.
763 score: The articles score
764 default: The default article score.
765 below: The score below which articles are automatically marked as read.
766 mark: The articles mark."
767 :group 'gnus-summary-visual
768 :type '(repeat (cons (sexp :tag "Form" nil)
771 (defcustom gnus-alter-header-function nil
772 "Function called to allow alteration of article header structures.
773 The function is called with one parameter, the article header vector,
774 which it may alter in any way.")
776 ;;; Internal variables
778 (defvar gnus-scores-exclude-files nil)
779 (defvar gnus-page-broken nil)
781 (defvar gnus-original-article nil)
782 (defvar gnus-article-internal-prepare-hook nil)
783 (defvar gnus-newsgroup-process-stack nil)
785 (defvar gnus-thread-indent-array nil)
786 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
788 ;; Avoid highlighting in kill files.
789 (defvar gnus-summary-inhibit-highlight nil)
790 (defvar gnus-newsgroup-selected-overlay nil)
791 (defvar gnus-inhibit-limiting nil)
792 (defvar gnus-newsgroup-adaptive-score-file nil)
793 (defvar gnus-current-score-file nil)
794 (defvar gnus-current-move-group nil)
795 (defvar gnus-current-copy-group nil)
796 (defvar gnus-current-crosspost-group nil)
798 (defvar gnus-newsgroup-dependencies nil)
799 (defvar gnus-newsgroup-adaptive nil)
800 (defvar gnus-summary-display-article-function nil)
801 (defvar gnus-summary-highlight-line-function nil
802 "Function called after highlighting a summary line.")
804 (defvar gnus-summary-line-format-alist
805 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
806 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
807 (?s gnus-tmp-subject-or-nil ?s)
808 (?n gnus-tmp-name ?s)
809 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
811 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
813 (?F gnus-tmp-from ?s)
814 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
815 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
816 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
817 (?o (gnus-date-iso8601 gnus-tmp-header) ?s)
818 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
819 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
820 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
821 (?L gnus-tmp-lines ?d)
822 (?I gnus-tmp-indentation ?s)
823 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
824 (?R gnus-tmp-replied ?c)
825 (?\[ gnus-tmp-opening-bracket ?c)
826 (?\] gnus-tmp-closing-bracket ?c)
827 (?\> (make-string gnus-tmp-level ? ) ?s)
828 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
829 (?i gnus-tmp-score ?d)
830 (?z gnus-tmp-score-char ?c)
831 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
832 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
833 (?U gnus-tmp-unread ?c)
834 (?t (gnus-summary-number-of-articles-in-thread
835 (and (boundp 'thread) (car thread)) gnus-tmp-level)
837 (?e (gnus-summary-number-of-articles-in-thread
838 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
840 (?u gnus-tmp-user-defined ?s)
841 (?P (gnus-pick-line-number) ?d))
842 "An alist of format specifications that can appear in summary lines,
843 and what variables they correspond with, along with the type of the
844 variable (string, integer, character, etc).")
846 (defvar gnus-summary-dummy-line-format-alist
847 `((?S gnus-tmp-subject ?s)
848 (?N gnus-tmp-number ?d)
849 (?u gnus-tmp-user-defined ?s)))
851 (defvar gnus-summary-mode-line-format-alist
852 `((?G gnus-tmp-group-name ?s)
853 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
854 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
855 (?A gnus-tmp-article-number ?d)
856 (?Z gnus-tmp-unread-and-unselected ?s)
858 (?U gnus-tmp-unread-and-unticked ?d)
859 (?S gnus-tmp-subject ?s)
860 (?e gnus-tmp-unselected ?d)
861 (?u gnus-tmp-user-defined ?s)
862 (?d (length gnus-newsgroup-dormant) ?d)
863 (?t (length gnus-newsgroup-marked) ?d)
864 (?r (length gnus-newsgroup-reads) ?d)
865 (?E gnus-newsgroup-expunged-tally ?d)
866 (?s (gnus-current-score-file-nondirectory) ?s)))
868 (defvar gnus-last-search-regexp nil
869 "Default regexp for article search command.")
871 (defvar gnus-last-shell-command nil
872 "Default shell command on article.")
874 (defvar gnus-newsgroup-begin nil)
875 (defvar gnus-newsgroup-end nil)
876 (defvar gnus-newsgroup-last-rmail nil)
877 (defvar gnus-newsgroup-last-mail nil)
878 (defvar gnus-newsgroup-last-folder nil)
879 (defvar gnus-newsgroup-last-file nil)
880 (defvar gnus-newsgroup-auto-expire nil)
881 (defvar gnus-newsgroup-active nil)
883 (defvar gnus-newsgroup-data nil)
884 (defvar gnus-newsgroup-data-reverse nil)
885 (defvar gnus-newsgroup-limit nil)
886 (defvar gnus-newsgroup-limits nil)
888 (defvar gnus-newsgroup-unreads nil
889 "List of unread articles in the current newsgroup.")
891 (defvar gnus-newsgroup-unselected nil
892 "List of unselected unread articles in the current newsgroup.")
894 (defvar gnus-newsgroup-reads nil
895 "Alist of read articles and article marks in the current newsgroup.")
897 (defvar gnus-newsgroup-expunged-tally nil)
899 (defvar gnus-newsgroup-marked nil
900 "List of ticked articles in the current newsgroup (a subset of unread art).")
902 (defvar gnus-newsgroup-killed nil
903 "List of ranges of articles that have been through the scoring process.")
905 (defvar gnus-newsgroup-cached nil
906 "List of articles that come from the article cache.")
908 (defvar gnus-newsgroup-saved nil
909 "List of articles that have been saved.")
911 (defvar gnus-newsgroup-kill-headers nil)
913 (defvar gnus-newsgroup-replied nil
914 "List of articles that have been replied to in the current newsgroup.")
916 (defvar gnus-newsgroup-expirable nil
917 "List of articles in the current newsgroup that can be expired.")
919 (defvar gnus-newsgroup-processable nil
920 "List of articles in the current newsgroup that can be processed.")
922 (defvar gnus-newsgroup-downloadable nil
923 "List of articles in the current newsgroup that can be processed.")
925 (defvar gnus-newsgroup-undownloaded nil
926 "List of articles in the current newsgroup that haven't been downloaded..")
928 (defvar gnus-newsgroup-unsendable nil
929 "List of articles in the current newsgroup that won't be sent.")
931 (defvar gnus-newsgroup-bookmarks nil
932 "List of articles in the current newsgroup that have bookmarks.")
934 (defvar gnus-newsgroup-dormant nil
935 "List of dormant articles in the current newsgroup.")
937 (defvar gnus-newsgroup-scored nil
938 "List of scored articles in the current newsgroup.")
940 (defvar gnus-newsgroup-headers nil
941 "List of article headers in the current newsgroup.")
943 (defvar gnus-newsgroup-threads nil)
945 (defvar gnus-newsgroup-prepared nil
946 "Whether the current group has been prepared properly.")
948 (defvar gnus-newsgroup-ancient nil
949 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
951 (defvar gnus-newsgroup-sparse nil)
953 (defvar gnus-current-article nil)
954 (defvar gnus-article-current nil)
955 (defvar gnus-current-headers nil)
956 (defvar gnus-have-all-headers nil)
957 (defvar gnus-last-article nil)
958 (defvar gnus-newsgroup-history nil)
960 (defconst gnus-summary-local-variables
961 '(gnus-newsgroup-name
962 gnus-newsgroup-begin gnus-newsgroup-end
963 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
964 gnus-newsgroup-last-folder gnus-newsgroup-last-file
965 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
966 gnus-newsgroup-unselected gnus-newsgroup-marked
967 gnus-newsgroup-reads gnus-newsgroup-saved
968 gnus-newsgroup-replied gnus-newsgroup-expirable
969 gnus-newsgroup-processable gnus-newsgroup-killed
970 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
971 gnus-newsgroup-unsendable
972 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
973 gnus-newsgroup-headers gnus-newsgroup-threads
974 gnus-newsgroup-prepared gnus-summary-highlight-line-function
975 gnus-current-article gnus-current-headers gnus-have-all-headers
976 gnus-last-article gnus-article-internal-prepare-hook
977 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
978 gnus-newsgroup-scored gnus-newsgroup-kill-headers
979 gnus-thread-expunge-below
980 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
981 (gnus-summary-mark-below . global)
982 gnus-newsgroup-active gnus-scores-exclude-files
983 gnus-newsgroup-history gnus-newsgroup-ancient
984 gnus-newsgroup-sparse gnus-newsgroup-process-stack
985 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
986 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
987 (gnus-newsgroup-expunged-tally . 0)
988 gnus-cache-removable-articles gnus-newsgroup-cached
989 gnus-newsgroup-data gnus-newsgroup-data-reverse
990 gnus-newsgroup-limit gnus-newsgroup-limits)
991 "Variables that are buffer-local to the summary buffers.")
993 ;; Byte-compiler warning.
994 (defvar gnus-article-mode-map)
996 ;; Subject simplification.
998 (defun gnus-simplify-whitespace (str)
999 "Remove excessive whitespace."
1002 (while (string-match "[ \t][ \t]+" mystr)
1003 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1005 (substring mystr (match-end 0)))))
1007 (when (string-match "^[ \t]+" mystr)
1008 (setq mystr (substring mystr (match-end 0))))
1010 (when (string-match "[ \t]+$" mystr)
1011 (setq mystr (substring mystr 0 (match-beginning 0))))
1014 (defsubst gnus-simplify-subject-re (subject)
1015 "Remove \"Re:\" from subject lines."
1016 (if (string-match "^[Rr][Ee]: *" subject)
1017 (substring subject (match-end 0))
1020 (defun gnus-simplify-subject (subject &optional re-only)
1021 "Remove `Re:' and words in parentheses.
1022 If RE-ONLY is non-nil, strip leading `Re:'s only."
1023 (let ((case-fold-search t)) ;Ignore case.
1024 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1025 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1026 (setq subject (substring subject (match-end 0))))
1027 ;; Remove uninteresting prefixes.
1028 (when (and (not re-only)
1029 gnus-simplify-ignored-prefixes
1030 (string-match gnus-simplify-ignored-prefixes subject))
1031 (setq subject (substring subject (match-end 0))))
1032 ;; Remove words in parentheses from end.
1034 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1035 (setq subject (substring subject 0 (match-beginning 0)))))
1036 ;; Return subject string.
1039 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1041 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1042 (goto-char (point-min))
1043 (while (re-search-forward regexp nil t)
1044 (replace-match (or newtext ""))))
1046 (defun gnus-simplify-buffer-fuzzy ()
1047 "Simplify string in the buffer fuzzily.
1048 The string in the accessible portion of the current buffer is simplified.
1049 It is assumed to be a single-line subject.
1050 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1051 matter is removed. Additional things can be deleted by setting
1052 gnus-simplify-subject-fuzzy-regexp."
1053 (let ((case-fold-search t)
1055 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1057 (while (not (eq modified-tick (buffer-modified-tick)))
1058 (setq modified-tick (buffer-modified-tick))
1060 ((listp gnus-simplify-subject-fuzzy-regexp)
1061 (mapcar 'gnus-simplify-buffer-fuzzy-step
1062 gnus-simplify-subject-fuzzy-regexp))
1063 (gnus-simplify-subject-fuzzy-regexp
1064 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1065 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1066 (gnus-simplify-buffer-fuzzy-step
1067 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1068 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1070 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1071 (gnus-simplify-buffer-fuzzy-step " +" " ")
1072 (gnus-simplify-buffer-fuzzy-step " $")
1073 (gnus-simplify-buffer-fuzzy-step "^ +")))
1075 (defun gnus-simplify-subject-fuzzy (subject)
1076 "Simplify a subject string fuzzily.
1077 See `gnus-simplify-buffer-fuzzy' for details."
1079 (gnus-set-work-buffer)
1080 (let ((case-fold-search t))
1082 (inline (gnus-simplify-buffer-fuzzy))
1085 (defsubst gnus-simplify-subject-fully (subject)
1086 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1088 (gnus-simplify-subject-functions
1089 (gnus-map-function gnus-simplify-subject-functions subject))
1090 ((null gnus-summary-gather-subject-limit)
1091 (gnus-simplify-subject-re subject))
1092 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1093 (gnus-simplify-subject-fuzzy subject))
1094 ((numberp gnus-summary-gather-subject-limit)
1095 (gnus-limit-string (gnus-simplify-subject-re subject)
1096 gnus-summary-gather-subject-limit))
1100 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1101 "Check whether two subjects are equal.
1102 If optional argument simple-first is t, first argument is already
1105 ((null simple-first)
1106 (equal (gnus-simplify-subject-fully s1)
1107 (gnus-simplify-subject-fully s2)))
1110 (gnus-simplify-subject-fully s2)))))
1112 (defun gnus-summary-bubble-group ()
1113 "Increase the score of the current group.
1114 This is a handy function to add to `gnus-summary-exit-hook' to
1115 increase the score of each group you read."
1116 (gnus-group-add-score gnus-newsgroup-name))
1120 ;;; Gnus summary mode
1123 (put 'gnus-summary-mode 'mode-class 'special)
1126 ;; Non-orthogonal keys
1128 (gnus-define-keys gnus-summary-mode-map
1129 " " gnus-summary-next-page
1130 "\177" gnus-summary-prev-page
1131 [delete] gnus-summary-prev-page
1132 "\r" gnus-summary-scroll-up
1133 "\e\r" gnus-summary-scroll-down
1134 "n" gnus-summary-next-unread-article
1135 "p" gnus-summary-prev-unread-article
1136 "N" gnus-summary-next-article
1137 "P" gnus-summary-prev-article
1138 "\M-\C-n" gnus-summary-next-same-subject
1139 "\M-\C-p" gnus-summary-prev-same-subject
1140 "\M-n" gnus-summary-next-unread-subject
1141 "\M-p" gnus-summary-prev-unread-subject
1142 "." gnus-summary-first-unread-article
1143 "," gnus-summary-best-unread-article
1144 "\M-s" gnus-summary-search-article-forward
1145 "\M-r" gnus-summary-search-article-backward
1146 "<" gnus-summary-beginning-of-article
1147 ">" gnus-summary-end-of-article
1148 "j" gnus-summary-goto-article
1149 "^" gnus-summary-refer-parent-article
1150 "\M-^" gnus-summary-refer-article
1151 "u" gnus-summary-tick-article-forward
1152 "!" gnus-summary-tick-article-forward
1153 "U" gnus-summary-tick-article-backward
1154 "d" gnus-summary-mark-as-read-forward
1155 "D" gnus-summary-mark-as-read-backward
1156 "E" gnus-summary-mark-as-expirable
1157 "\M-u" gnus-summary-clear-mark-forward
1158 "\M-U" gnus-summary-clear-mark-backward
1159 "k" gnus-summary-kill-same-subject-and-select
1160 "\C-k" gnus-summary-kill-same-subject
1161 "\M-\C-k" gnus-summary-kill-thread
1162 "\M-\C-l" gnus-summary-lower-thread
1163 "e" gnus-summary-edit-article
1164 "#" gnus-summary-mark-as-processable
1165 "\M-#" gnus-summary-unmark-as-processable
1166 "\M-\C-t" gnus-summary-toggle-threads
1167 "\M-\C-s" gnus-summary-show-thread
1168 "\M-\C-h" gnus-summary-hide-thread
1169 "\M-\C-f" gnus-summary-next-thread
1170 "\M-\C-b" gnus-summary-prev-thread
1171 "\M-\C-u" gnus-summary-up-thread
1172 "\M-\C-d" gnus-summary-down-thread
1173 "&" gnus-summary-execute-command
1174 "c" gnus-summary-catchup-and-exit
1175 "\C-w" gnus-summary-mark-region-as-read
1176 "\C-t" gnus-summary-toggle-truncation
1177 "?" gnus-summary-mark-as-dormant
1178 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1179 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1180 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1181 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1182 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1183 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1184 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1185 "=" gnus-summary-expand-window
1186 "\C-x\C-s" gnus-summary-reselect-current-group
1187 "\M-g" gnus-summary-rescan-group
1188 "w" gnus-summary-stop-page-breaking
1189 "\C-c\C-r" gnus-summary-caesar-message
1190 "\M-t" gnus-summary-toggle-mime
1191 "f" gnus-summary-followup
1192 "F" gnus-summary-followup-with-original
1193 "C" gnus-summary-cancel-article
1194 "r" gnus-summary-reply
1195 "R" gnus-summary-reply-with-original
1196 "\C-c\C-f" gnus-summary-mail-forward
1197 "o" gnus-summary-save-article
1198 "\C-o" gnus-summary-save-article-mail
1199 "|" gnus-summary-pipe-output
1200 "\M-k" gnus-summary-edit-local-kill
1201 "\M-K" gnus-summary-edit-global-kill
1203 "\C-c\C-d" gnus-summary-describe-group
1204 "q" gnus-summary-exit
1205 "Q" gnus-summary-exit-no-update
1206 "\C-c\C-i" gnus-info-find-node
1207 gnus-mouse-2 gnus-mouse-pick-article
1208 "m" gnus-summary-mail-other-window
1209 "a" gnus-summary-post-news
1210 "x" gnus-summary-limit-to-unread
1211 "s" gnus-summary-isearch-article
1212 "t" gnus-article-hide-headers
1213 "g" gnus-summary-show-article
1214 "l" gnus-summary-goto-last-article
1215 "v" gnus-summary-preview-mime-message
1216 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1217 "\C-d" gnus-summary-enter-digest-group
1218 "\M-\C-d" gnus-summary-read-document
1220 "*" gnus-cache-enter-article
1221 "\M-*" gnus-cache-remove-article
1222 "\M-&" gnus-summary-universal-argument
1223 "\C-l" gnus-recenter
1224 "I" gnus-summary-increase-score
1225 "L" gnus-summary-lower-score
1226 "\M-i" gnus-symbolic-argument
1227 "h" gnus-summary-select-article-buffer
1229 "V" gnus-summary-score-map
1230 "X" gnus-uu-extract-map
1231 "S" gnus-summary-send-map)
1233 ;; Sort of orthogonal keymap
1234 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1235 "t" gnus-summary-tick-article-forward
1236 "!" gnus-summary-tick-article-forward
1237 "d" gnus-summary-mark-as-read-forward
1238 "r" gnus-summary-mark-as-read-forward
1239 "c" gnus-summary-clear-mark-forward
1240 " " gnus-summary-clear-mark-forward
1241 "e" gnus-summary-mark-as-expirable
1242 "x" gnus-summary-mark-as-expirable
1243 "?" gnus-summary-mark-as-dormant
1244 "b" gnus-summary-set-bookmark
1245 "B" gnus-summary-remove-bookmark
1246 "#" gnus-summary-mark-as-processable
1247 "\M-#" gnus-summary-unmark-as-processable
1248 "S" gnus-summary-limit-include-expunged
1249 "C" gnus-summary-catchup
1250 "H" gnus-summary-catchup-to-here
1251 "\C-c" gnus-summary-catchup-all
1252 "k" gnus-summary-kill-same-subject-and-select
1253 "K" gnus-summary-kill-same-subject
1254 "P" gnus-uu-mark-map)
1256 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1257 "c" gnus-summary-clear-above
1258 "u" gnus-summary-tick-above
1259 "m" gnus-summary-mark-above
1260 "k" gnus-summary-kill-below)
1262 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1263 "/" gnus-summary-limit-to-subject
1264 "n" gnus-summary-limit-to-articles
1265 "w" gnus-summary-pop-limit
1266 "s" gnus-summary-limit-to-subject
1267 "a" gnus-summary-limit-to-author
1268 "u" gnus-summary-limit-to-unread
1269 "m" gnus-summary-limit-to-marks
1270 "v" gnus-summary-limit-to-score
1271 "*" gnus-summary-limit-include-cached
1272 "D" gnus-summary-limit-include-dormant
1273 "T" gnus-summary-limit-include-thread
1274 "d" gnus-summary-limit-exclude-dormant
1275 "t" gnus-summary-limit-to-age
1276 "E" gnus-summary-limit-include-expunged
1277 "c" gnus-summary-limit-exclude-childless-dormant
1278 "C" gnus-summary-limit-mark-excluded-as-read)
1280 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1281 "n" gnus-summary-next-unread-article
1282 "p" gnus-summary-prev-unread-article
1283 "N" gnus-summary-next-article
1284 "P" gnus-summary-prev-article
1285 "\C-n" gnus-summary-next-same-subject
1286 "\C-p" gnus-summary-prev-same-subject
1287 "\M-n" gnus-summary-next-unread-subject
1288 "\M-p" gnus-summary-prev-unread-subject
1289 "f" gnus-summary-first-unread-article
1290 "b" gnus-summary-best-unread-article
1291 "j" gnus-summary-goto-article
1292 "g" gnus-summary-goto-subject
1293 "l" gnus-summary-goto-last-article
1294 "o" gnus-summary-pop-article)
1296 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1297 "k" gnus-summary-kill-thread
1298 "l" gnus-summary-lower-thread
1299 "i" gnus-summary-raise-thread
1300 "T" gnus-summary-toggle-threads
1301 "t" gnus-summary-rethread-current
1302 "^" gnus-summary-reparent-thread
1303 "s" gnus-summary-show-thread
1304 "S" gnus-summary-show-all-threads
1305 "h" gnus-summary-hide-thread
1306 "H" gnus-summary-hide-all-threads
1307 "n" gnus-summary-next-thread
1308 "p" gnus-summary-prev-thread
1309 "u" gnus-summary-up-thread
1310 "o" gnus-summary-top-thread
1311 "d" gnus-summary-down-thread
1312 "#" gnus-uu-mark-thread
1313 "\M-#" gnus-uu-unmark-thread)
1315 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1316 "g" gnus-summary-prepare
1317 "c" gnus-summary-insert-cached-articles)
1319 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1320 "c" gnus-summary-catchup-and-exit
1321 "C" gnus-summary-catchup-all-and-exit
1322 "E" gnus-summary-exit-no-update
1323 "Q" gnus-summary-exit
1324 "Z" gnus-summary-exit
1325 "n" gnus-summary-catchup-and-goto-next-group
1326 "R" gnus-summary-reselect-current-group
1327 "G" gnus-summary-rescan-group
1328 "N" gnus-summary-next-group
1329 "s" gnus-summary-save-newsrc
1330 "P" gnus-summary-prev-group)
1332 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1333 " " gnus-summary-next-page
1334 "n" gnus-summary-next-page
1335 "\177" gnus-summary-prev-page
1336 [delete] gnus-summary-prev-page
1337 "p" gnus-summary-prev-page
1338 "\r" gnus-summary-scroll-up
1339 "<" gnus-summary-beginning-of-article
1340 ">" gnus-summary-end-of-article
1341 "b" gnus-summary-beginning-of-article
1342 "e" gnus-summary-end-of-article
1343 "^" gnus-summary-refer-parent-article
1344 "r" gnus-summary-refer-parent-article
1345 "R" gnus-summary-refer-references
1346 "T" gnus-summary-refer-thread
1347 "g" gnus-summary-show-article
1348 "s" gnus-summary-isearch-article
1349 "P" gnus-summary-print-article)
1351 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1352 "b" gnus-article-add-buttons
1353 "B" gnus-article-add-buttons-to-head
1354 "o" gnus-article-treat-overstrike
1355 "e" gnus-article-emphasize
1356 "w" gnus-article-fill-cited-article
1357 "c" gnus-article-remove-cr
1358 "q" gnus-article-de-quoted-unreadable
1359 "f" gnus-article-display-x-face
1360 "l" gnus-summary-stop-page-breaking
1361 "r" gnus-summary-caesar-message
1362 "t" gnus-article-hide-headers
1363 "v" gnus-summary-verbose-headers
1364 "m" gnus-summary-toggle-mime
1365 "h" gnus-article-treat-html
1366 "d" gnus-article-treat-dumbquotes)
1368 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1369 "a" gnus-article-hide
1370 "h" gnus-article-hide-headers
1371 "b" gnus-article-hide-boring-headers
1372 "s" gnus-article-hide-signature
1373 "c" gnus-article-hide-citation
1374 "p" gnus-article-hide-pgp
1375 "P" gnus-article-hide-pem
1376 "\C-c" gnus-article-hide-citation-maybe)
1378 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1379 "a" gnus-article-highlight
1380 "h" gnus-article-highlight-headers
1381 "c" gnus-article-highlight-citation
1382 "s" gnus-article-highlight-signature)
1384 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1385 "z" gnus-article-date-ut
1386 "u" gnus-article-date-ut
1387 "l" gnus-article-date-local
1388 "e" gnus-article-date-lapsed
1389 "o" gnus-article-date-original
1390 "s" gnus-article-date-user)
1392 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1393 "t" gnus-article-remove-trailing-blank-lines
1394 "l" gnus-article-strip-leading-blank-lines
1395 "m" gnus-article-strip-multiple-blank-lines
1396 "a" gnus-article-strip-blank-lines
1397 "s" gnus-article-strip-leading-space)
1399 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1401 "f" gnus-summary-fetch-faq
1402 "d" gnus-summary-describe-group
1403 "h" gnus-summary-describe-briefly
1404 "i" gnus-info-find-node)
1406 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1407 "e" gnus-summary-expire-articles
1408 "\M-\C-e" gnus-summary-expire-articles-now
1409 "\177" gnus-summary-delete-article
1410 [delete] gnus-summary-delete-article
1411 "m" gnus-summary-move-article
1412 "r" gnus-summary-respool-article
1413 "w" gnus-summary-edit-article
1414 "c" gnus-summary-copy-article
1415 "B" gnus-summary-crosspost-article
1416 "q" gnus-summary-respool-query
1417 "i" gnus-summary-import-article
1418 "p" gnus-summary-article-posted-p)
1420 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1421 "o" gnus-summary-save-article
1422 "m" gnus-summary-save-article-mail
1423 "F" gnus-summary-write-article-file
1424 "r" gnus-summary-save-article-rmail
1425 "f" gnus-summary-save-article-file
1426 "b" gnus-summary-save-article-body-file
1427 "h" gnus-summary-save-article-folder
1428 "v" gnus-summary-save-article-vm
1429 "p" gnus-summary-pipe-output
1430 "s" gnus-soup-add-article))
1432 (defun gnus-summary-make-menu-bar ()
1433 (gnus-turn-off-edit-menu 'summary)
1435 (unless (boundp 'gnus-summary-misc-menu)
1438 gnus-summary-kill-menu gnus-summary-mode-map ""
1443 ["Enter score..." gnus-summary-score-entry t]
1444 ["Customize" gnus-score-customize t])
1445 (gnus-make-score-map 'increase)
1446 (gnus-make-score-map 'lower)
1448 ["Kill below" gnus-summary-kill-below t]
1449 ["Mark above" gnus-summary-mark-above t]
1450 ["Tick above" gnus-summary-tick-above t]
1451 ["Clear above" gnus-summary-clear-above t])
1452 ["Current score" gnus-summary-current-score t]
1453 ["Set score" gnus-summary-set-score t]
1454 ["Switch current score file..." gnus-score-change-score-file t]
1455 ["Set mark below..." gnus-score-set-mark-below t]
1456 ["Set expunge below..." gnus-score-set-expunge-below t]
1457 ["Edit current score file" gnus-score-edit-current-scores t]
1458 ["Edit score file" gnus-score-edit-file t]
1459 ["Trace score" gnus-score-find-trace t]
1460 ["Find words" gnus-score-find-favourite-words t]
1461 ["Rescore buffer" gnus-summary-rescore t]
1462 ["Increase score..." gnus-summary-increase-score t]
1463 ["Lower score..." gnus-summary-lower-score t]))))
1466 ["Ask" (gnus-score-set-default 'gnus-score-default-header nil)
1468 :selected (null gnus-score-default-header)]
1469 ["From" (gnus-score-set-default 'gnus-score-default-header 'a)
1471 :selected (eq gnus-score-default-header 'a)]
1472 ["Subject" (gnus-score-set-default 'gnus-score-default-header 's)
1474 :selected (eq gnus-score-default-header 's)]
1476 (gnus-score-set-default 'gnus-score-default-header 'b)
1478 :selected (eq gnus-score-default-header 'b )]
1480 (gnus-score-set-default 'gnus-score-default-header 'h)
1482 :selected (eq gnus-score-default-header 'h )]
1483 ["Message-ID" (gnus-score-set-default 'gnus-score-default-header 'i)
1485 :selected (eq gnus-score-default-header 'i )]
1486 ["Thread" (gnus-score-set-default 'gnus-score-default-header 't)
1488 :selected (eq gnus-score-default-header 't )]
1490 (gnus-score-set-default 'gnus-score-default-header 'x)
1492 :selected (eq gnus-score-default-header 'x )]
1493 ["Lines" (gnus-score-set-default 'gnus-score-default-header 'l)
1495 :selected (eq gnus-score-default-header 'l )]
1496 ["Date" (gnus-score-set-default 'gnus-score-default-header 'd)
1498 :selected (eq gnus-score-default-header 'd )]
1499 ["Followups to author"
1500 (gnus-score-set-default 'gnus-score-default-header 'f)
1502 :selected (eq gnus-score-default-header 'f )])
1504 ["Ask" (gnus-score-set-default 'gnus-score-default-type nil)
1506 :selected (null gnus-score-default-type)]
1507 ;; The `:active' key is commented out in the following,
1508 ;; because the GNU Emacs hack to support radio buttons use
1509 ;; active to indicate which button is selected.
1510 ["Substring" (gnus-score-set-default 'gnus-score-default-type 's)
1512 ;; :active (not (memq gnus-score-default-header '(l d)))
1513 :selected (eq gnus-score-default-type 's)]
1514 ["Regexp" (gnus-score-set-default 'gnus-score-default-type 'r)
1516 ;; :active (not (memq gnus-score-default-header '(l d)))
1517 :selected (eq gnus-score-default-type 'r)]
1518 ["Exact" (gnus-score-set-default 'gnus-score-default-type 'e)
1520 ;; :active (not (memq gnus-score-default-header '(l d)))
1521 :selected (eq gnus-score-default-type 'e)]
1522 ["Fuzzy" (gnus-score-set-default 'gnus-score-default-type 'f)
1524 ;; :active (not (memq gnus-score-default-header '(l d)))
1525 :selected (eq gnus-score-default-type 'f)]
1526 ["Before date" (gnus-score-set-default 'gnus-score-default-type 'b)
1528 ;; :active (eq (gnus-score-default-header 'd))
1529 :selected (eq gnus-score-default-type 'b)]
1530 ["At date" (gnus-score-set-default 'gnus-score-default-type 'n)
1532 ;; :active (eq (gnus-score-default-header 'd))
1533 :selected (eq gnus-score-default-type 'n)]
1534 ["After date" (gnus-score-set-default 'gnus-score-default-type 'a)
1536 ;; :active (eq (gnus-score-default-header 'd))
1537 :selected (eq gnus-score-default-type 'a)]
1539 (gnus-score-set-default 'gnus-score-default-type '<)
1541 ;; :active (eq (gnus-score-default-header 'l))
1542 :selected (eq gnus-score-default-type '<)]
1544 (gnus-score-set-default 'gnus-score-default-type '=)
1546 ;; :active (eq (gnus-score-default-header 'l))
1547 :selected (eq gnus-score-default-type '=)]
1548 ["Greater than number"
1549 (gnus-score-set-default 'gnus-score-default-type '>)
1551 ;; :active (eq (gnus-score-default-header 'l))
1552 :selected (eq gnus-score-default-type '>)])
1553 ["Default fold" gnus-score-default-fold-toggle
1555 :selected gnus-score-default-fold]
1557 ["Ask" (gnus-score-set-default 'gnus-score-default-duration nil)
1559 :selected (null gnus-score-default-duration)]
1561 (gnus-score-set-default 'gnus-score-default-duration 'p)
1563 :selected (eq gnus-score-default-duration 'p)]
1565 (gnus-score-set-default 'gnus-score-default-duration 't)
1567 :selected (eq gnus-score-default-duration 't)]
1569 (gnus-score-set-default 'gnus-score-default-duration 'i)
1571 :selected (eq gnus-score-default-duration 'i)]))
1574 gnus-summary-article-menu gnus-summary-mode-map ""
1577 ["All" gnus-article-hide t]
1578 ["Headers" gnus-article-hide-headers t]
1579 ["Signature" gnus-article-hide-signature t]
1580 ["Citation" gnus-article-hide-citation t]
1581 ["PGP" gnus-article-hide-pgp t]
1582 ["Boring headers" gnus-article-hide-boring-headers t])
1584 ["All" gnus-article-highlight t]
1585 ["Headers" gnus-article-highlight-headers t]
1586 ["Signature" gnus-article-highlight-signature t]
1587 ["Citation" gnus-article-highlight-citation t])
1589 ["Local" gnus-article-date-local t]
1590 ["UT" gnus-article-date-ut t]
1591 ["Original" gnus-article-date-original t]
1592 ["Lapsed" gnus-article-date-lapsed t]
1593 ["User-defined" gnus-article-date-user t])
1596 ["Leading" gnus-article-strip-leading-blank-lines t]
1597 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1598 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1599 ["All of the above" gnus-article-strip-blank-lines t]
1600 ["Leading space" gnus-article-strip-leading-space t])
1601 ["Overstrike" gnus-article-treat-overstrike t]
1602 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1603 ["Emphasis" gnus-article-emphasize t]
1604 ["Word wrap" gnus-article-fill-cited-article t]
1605 ["CR" gnus-article-remove-cr t]
1606 ["Show X-Face" gnus-article-display-x-face t]
1607 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1608 ["UnHTMLize" gnus-article-treat-html t]
1609 ["Rot 13" gnus-summary-caesar-message t]
1610 ["Unix pipe" gnus-summary-pipe-message t]
1611 ["Add buttons" gnus-article-add-buttons t]
1612 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1613 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1614 ["Toggle MIME" gnus-summary-toggle-mime t]
1615 ["Verbose header" gnus-summary-verbose-headers t]
1616 ["Toggle header" gnus-summary-toggle-header t])
1618 ["Save in default format" gnus-summary-save-article t]
1619 ["Save in file" gnus-summary-save-article-file t]
1620 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1621 ["Save in MH folder" gnus-summary-save-article-folder t]
1622 ["Save in VM folder" gnus-summary-save-article-vm t]
1623 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1624 ["Save body in file" gnus-summary-save-article-body-file t]
1625 ["Pipe through a filter" gnus-summary-pipe-output t]
1626 ["Add to SOUP packet" gnus-soup-add-article t]
1627 ["Print" gnus-summary-print-article t])
1629 ["Respool article..." gnus-summary-respool-article t]
1630 ["Move article..." gnus-summary-move-article
1631 (gnus-check-backend-function
1632 'request-move-article gnus-newsgroup-name)]
1633 ["Copy article..." gnus-summary-copy-article t]
1634 ["Crosspost article..." gnus-summary-crosspost-article
1635 (gnus-check-backend-function
1636 'request-replace-article gnus-newsgroup-name)]
1637 ["Import file..." gnus-summary-import-article t]
1638 ["Check if posted" gnus-summary-article-posted-p t]
1639 ["Edit article" gnus-summary-edit-article
1640 (not (gnus-group-read-only-p))]
1641 ["Delete article" gnus-summary-delete-article
1642 (gnus-check-backend-function
1643 'request-expire-articles gnus-newsgroup-name)]
1644 ["Query respool" gnus-summary-respool-query t]
1645 ["Delete expirable articles" gnus-summary-expire-articles-now
1646 (gnus-check-backend-function
1647 'request-expire-articles gnus-newsgroup-name)])
1649 ["Uudecode" gnus-uu-decode-uu t]
1650 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1651 ["Unshar" gnus-uu-decode-unshar t]
1652 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1653 ["Save" gnus-uu-decode-save t]
1654 ["Binhex" gnus-uu-decode-binhex t]
1655 ["Postscript" gnus-uu-decode-postscript t])
1657 ["Enter article" gnus-cache-enter-article t]
1658 ["Remove article" gnus-cache-remove-article t])
1659 ["Select article buffer" gnus-summary-select-article-buffer t]
1660 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1661 ["Isearch article..." gnus-summary-isearch-article t]
1662 ["Beginning of the article" gnus-summary-beginning-of-article t]
1663 ["End of the article" gnus-summary-end-of-article t]
1664 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1665 ["Fetch referenced articles" gnus-summary-refer-references t]
1666 ["Fetch current thread" gnus-summary-refer-thread t]
1667 ["Fetch article with id..." gnus-summary-refer-article t]
1668 ["Redisplay" gnus-summary-show-article t]))
1671 gnus-summary-thread-menu gnus-summary-mode-map ""
1673 ["Toggle threading" gnus-summary-toggle-threads t]
1674 ["Hide threads" gnus-summary-hide-all-threads t]
1675 ["Show threads" gnus-summary-show-all-threads t]
1676 ["Hide thread" gnus-summary-hide-thread t]
1677 ["Show thread" gnus-summary-show-thread t]
1678 ["Go to next thread" gnus-summary-next-thread t]
1679 ["Go to previous thread" gnus-summary-prev-thread t]
1680 ["Go down thread" gnus-summary-down-thread t]
1681 ["Go up thread" gnus-summary-up-thread t]
1682 ["Top of thread" gnus-summary-top-thread t]
1683 ["Mark thread as read" gnus-summary-kill-thread t]
1684 ["Lower thread score" gnus-summary-lower-thread t]
1685 ["Raise thread score" gnus-summary-raise-thread t]
1686 ["Rethread current" gnus-summary-rethread-current t]
1690 gnus-summary-post-menu gnus-summary-mode-map ""
1692 ["Post an article" gnus-summary-post-news t]
1693 ["Followup" gnus-summary-followup t]
1694 ["Followup and yank" gnus-summary-followup-with-original t]
1695 ["Supersede article" gnus-summary-supersede-article t]
1696 ["Cancel article" gnus-summary-cancel-article t]
1697 ["Reply" gnus-summary-reply t]
1698 ["Reply and yank" gnus-summary-reply-with-original t]
1699 ["Wide reply" gnus-summary-wide-reply t]
1700 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1701 ["Mail forward" gnus-summary-mail-forward t]
1702 ["Post forward" gnus-summary-post-forward t]
1703 ["Digest and mail" gnus-uu-digest-mail-forward t]
1704 ["Digest and post" gnus-uu-digest-post-forward t]
1705 ["Resend message" gnus-summary-resend-message t]
1706 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1707 ["Send a mail" gnus-summary-mail-other-window t]
1708 ["Uuencode and post" gnus-uu-post-news t]
1709 ["Followup via news" gnus-summary-followup-to-mail t]
1710 ["Followup via news and yank"
1711 gnus-summary-followup-to-mail-with-original t]
1713 ;;["Send" gnus-summary-send-draft t]
1714 ;;["Send bounced" gnus-resend-bounced-mail t])
1718 gnus-summary-misc-menu gnus-summary-mode-map ""
1721 ["Mark as read" gnus-summary-mark-as-read-forward t]
1722 ["Mark same subject and select"
1723 gnus-summary-kill-same-subject-and-select t]
1724 ["Mark same subject" gnus-summary-kill-same-subject t]
1725 ["Catchup" gnus-summary-catchup t]
1726 ["Catchup all" gnus-summary-catchup-all t]
1727 ["Catchup to here" gnus-summary-catchup-to-here t]
1728 ["Catchup region" gnus-summary-mark-region-as-read t]
1729 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1731 ["Tick" gnus-summary-tick-article-forward t]
1732 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1733 ["Remove marks" gnus-summary-clear-mark-forward t]
1734 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1735 ["Set bookmark" gnus-summary-set-bookmark t]
1736 ["Remove bookmark" gnus-summary-remove-bookmark t])
1738 ["Marks..." gnus-summary-limit-to-marks t]
1739 ["Subject..." gnus-summary-limit-to-subject t]
1740 ["Author..." gnus-summary-limit-to-author t]
1741 ["Age..." gnus-summary-limit-to-age t]
1742 ["Score" gnus-summary-limit-to-score t]
1743 ["Unread" gnus-summary-limit-to-unread t]
1744 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1745 ["Articles" gnus-summary-limit-to-articles t]
1746 ["Pop limit" gnus-summary-pop-limit t]
1747 ["Show dormant" gnus-summary-limit-include-dormant t]
1748 ["Hide childless dormant"
1749 gnus-summary-limit-exclude-childless-dormant t]
1750 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1751 ["Show expunged" gnus-summary-show-all-expunged t])
1753 ["Set mark" gnus-summary-mark-as-processable t]
1754 ["Remove mark" gnus-summary-unmark-as-processable t]
1755 ["Remove all marks" gnus-summary-unmark-all-processable t]
1756 ["Mark above" gnus-uu-mark-over t]
1757 ["Mark series" gnus-uu-mark-series t]
1758 ["Mark region" gnus-uu-mark-region t]
1759 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1760 ["Mark all" gnus-uu-mark-all t]
1761 ["Mark buffer" gnus-uu-mark-buffer t]
1762 ["Mark sparse" gnus-uu-mark-sparse t]
1763 ["Mark thread" gnus-uu-mark-thread t]
1764 ["Unmark thread" gnus-uu-unmark-thread t]
1765 ("Process Mark Sets"
1766 ["Kill" gnus-summary-kill-process-mark t]
1767 ["Yank" gnus-summary-yank-process-mark
1768 gnus-newsgroup-process-stack]
1769 ["Save" gnus-summary-save-process-mark t]))
1771 ["Page forward" gnus-summary-next-page t]
1772 ["Page backward" gnus-summary-prev-page t]
1773 ["Line forward" gnus-summary-scroll-up t])
1775 ["Next unread article" gnus-summary-next-unread-article t]
1776 ["Previous unread article" gnus-summary-prev-unread-article t]
1777 ["Next article" gnus-summary-next-article t]
1778 ["Previous article" gnus-summary-prev-article t]
1779 ["Next unread subject" gnus-summary-next-unread-subject t]
1780 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1781 ["Next article same subject" gnus-summary-next-same-subject t]
1782 ["Previous article same subject" gnus-summary-prev-same-subject t]
1783 ["First unread article" gnus-summary-first-unread-article t]
1784 ["Best unread article" gnus-summary-best-unread-article t]
1785 ["Go to subject number..." gnus-summary-goto-subject t]
1786 ["Go to article number..." gnus-summary-goto-article t]
1787 ["Go to the last article" gnus-summary-goto-last-article t]
1788 ["Pop article off history" gnus-summary-pop-article t])
1790 ["Sort by number" gnus-summary-sort-by-number t]
1791 ["Sort by author" gnus-summary-sort-by-author t]
1792 ["Sort by subject" gnus-summary-sort-by-subject t]
1793 ["Sort by date" gnus-summary-sort-by-date t]
1794 ["Sort by score" gnus-summary-sort-by-score t]
1795 ["Sort by lines" gnus-summary-sort-by-lines t])
1797 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1798 ["Describe group" gnus-summary-describe-group t]
1799 ["Read manual" gnus-info-find-node t])
1801 ["Pick and read" gnus-pick-mode t]
1802 ["Binary" gnus-binary-mode t])
1804 ["Regenerate" gnus-summary-prepare t]
1805 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1806 ["Toggle threading" gnus-summary-toggle-threads t])
1807 ["Filter articles..." gnus-summary-execute-command t]
1808 ["Run command on subjects..." gnus-summary-universal-argument t]
1809 ["Search articles forward..." gnus-summary-search-article-forward t]
1810 ["Search articles backward..." gnus-summary-search-article-backward t]
1811 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1812 ["Expand window" gnus-summary-expand-window t]
1813 ["Expire expirable articles" gnus-summary-expire-articles
1814 (gnus-check-backend-function
1815 'request-expire-articles gnus-newsgroup-name)]
1816 ["Edit local kill file" gnus-summary-edit-local-kill t]
1817 ["Edit main kill file" gnus-summary-edit-global-kill t]
1819 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1820 ["Catchup all and exit" gnus-summary-catchup-and-exit t]
1821 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1822 ["Exit group" gnus-summary-exit t]
1823 ["Exit group without updating" gnus-summary-exit-no-update t]
1824 ["Exit and goto next group" gnus-summary-next-group t]
1825 ["Exit and goto prev group" gnus-summary-prev-group t]
1826 ["Reselect group" gnus-summary-reselect-current-group t]
1827 ["Rescan group" gnus-summary-rescan-group t]
1828 ["Update dribble" gnus-summary-save-newsrc t])))
1830 (run-hooks 'gnus-summary-menu-hook)))
1832 (defun gnus-score-set-default (var value)
1833 "A version of set that updates the GNU Emacs menu-bar."
1835 ;; It is the message that forces the active status to be updated.
1838 (defun gnus-make-score-map (type)
1839 "Make a summary score map of type TYPE."
1842 (let ((headers '(("author" "from" string)
1843 ("subject" "subject" string)
1844 ("article body" "body" string)
1845 ("article head" "head" string)
1846 ("xref" "xref" string)
1847 ("lines" "lines" number)
1848 ("followups to author" "followup" string)))
1849 (types '((number ("less than" <)
1852 (string ("substring" s)
1856 (perms '(("temporary" (current-time-string))
1864 (if (eq type 'lower)
1869 (setq header (car headers))
1875 (let ((ts (cdr (assoc (nth 2 header) types)))
1891 'gnus-summary-score-entry
1893 (if (or (string= (nth 1 header)
1895 (string= (nth 1 header)
1898 (list 'gnus-summary-header
1900 (list 'quote (nth 1 (car ts)))
1901 (list 'gnus-score-default nil)
1907 (list (nreverse outp))))
1910 (list (nreverse outt))))
1912 (setq headers (cdr headers)))
1913 (list (nreverse outh))))))))
1917 (defun gnus-summary-mode (&optional group)
1918 "Major mode for reading articles.
1920 All normal editing commands are switched off.
1921 \\<gnus-summary-mode-map>
1922 Each line in this buffer represents one article. To read an
1923 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
1924 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
1927 You can also post articles and send mail from this buffer. To
1928 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
1929 of an article, type `\\[gnus-summary-reply]'.
1931 There are approx. one gazillion commands you can execute in this
1932 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
1934 The following commands are available:
1936 \\{gnus-summary-mode-map}"
1938 (when (gnus-visual-p 'summary-menu 'menu)
1939 (gnus-summary-make-menu-bar))
1940 (kill-all-local-variables)
1941 (gnus-summary-make-local-variables)
1942 (gnus-make-thread-indent-array)
1943 (gnus-simplify-mode-line)
1944 (setq major-mode 'gnus-summary-mode)
1945 (setq mode-name "Summary")
1946 (make-local-variable 'minor-mode-alist)
1947 (use-local-map gnus-summary-mode-map)
1948 (buffer-disable-undo (current-buffer))
1949 (setq buffer-read-only t) ;Disable modification
1950 (setq truncate-lines t)
1951 (setq selective-display t)
1952 (setq selective-display-ellipses t) ;Display `...'
1953 (gnus-summary-set-display-table)
1954 (gnus-set-default-directory)
1955 (setq gnus-newsgroup-name group)
1956 (make-local-variable 'gnus-summary-line-format)
1957 (make-local-variable 'gnus-summary-line-format-spec)
1958 (make-local-variable 'gnus-summary-mark-positions)
1959 (make-local-hook 'post-command-hook)
1960 (add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
1961 (make-local-hook 'pre-command-hook)
1962 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
1963 (run-hooks 'gnus-summary-mode-hook)
1964 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
1965 (gnus-update-summary-mark-positions))
1967 (defun gnus-summary-make-local-variables ()
1968 "Make all the local summary buffer variables."
1969 (let ((locals gnus-summary-local-variables)
1971 (while (setq local (pop locals))
1974 (if (eq (cdr local) 'global)
1975 ;; Copy the global value of the variable.
1976 (setq global (symbol-value (car local)))
1977 ;; Use the value from the list.
1978 (setq global (eval (cdr local))))
1979 (make-local-variable (car local))
1980 (set (car local) global))
1981 ;; Simple nil-valued local variable.
1982 (make-local-variable local)
1985 (defun gnus-summary-clear-local-variables ()
1986 (let ((locals gnus-summary-local-variables))
1988 (if (consp (car locals))
1989 (and (vectorp (caar locals))
1990 (set (caar locals) nil))
1991 (and (vectorp (car locals))
1992 (set (car locals) nil)))
1993 (setq locals (cdr locals)))))
1995 ;; Summary data functions.
1997 (defmacro gnus-data-number (data)
2000 (defmacro gnus-data-set-number (data number)
2001 `(setcar ,data ,number))
2003 (defmacro gnus-data-mark (data)
2006 (defmacro gnus-data-set-mark (data mark)
2007 `(setcar (nthcdr 1 ,data) ,mark))
2009 (defmacro gnus-data-pos (data)
2012 (defmacro gnus-data-set-pos (data pos)
2013 `(setcar (nthcdr 2 ,data) ,pos))
2015 (defmacro gnus-data-header (data)
2018 (defmacro gnus-data-set-header (data header)
2019 `(setf (nth 3 ,data) ,header))
2021 (defmacro gnus-data-level (data)
2024 (defmacro gnus-data-unread-p (data)
2025 `(= (nth 1 ,data) gnus-unread-mark))
2027 (defmacro gnus-data-read-p (data)
2028 `(/= (nth 1 ,data) gnus-unread-mark))
2030 (defmacro gnus-data-pseudo-p (data)
2031 `(consp (nth 3 ,data)))
2033 (defmacro gnus-data-find (number)
2034 `(assq ,number gnus-newsgroup-data))
2036 (defmacro gnus-data-find-list (number &optional data)
2037 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2038 (memq (assq ,number bdata)
2041 (defmacro gnus-data-make (number mark pos header level)
2042 `(list ,number ,mark ,pos ,header ,level))
2044 (defun gnus-data-enter (after-article number mark pos header level offset)
2045 (let ((data (gnus-data-find-list after-article)))
2047 (error "No such article: %d" after-article))
2048 (setcdr data (cons (gnus-data-make number mark pos header level)
2050 (setq gnus-newsgroup-data-reverse nil)
2051 (gnus-data-update-list (cddr data) offset)))
2053 (defun gnus-data-enter-list (after-article list &optional offset)
2055 (let ((data (and after-article (gnus-data-find-list after-article)))
2057 (or data (not after-article) (error "No such article: %d" after-article))
2058 ;; Find the last element in the list to be spliced into the main
2061 (setq list (cdr list)))
2064 (setcdr list gnus-newsgroup-data)
2065 (setq gnus-newsgroup-data ilist)
2067 (gnus-data-update-list (cdr list) offset)))
2068 (setcdr list (cdr data))
2071 (gnus-data-update-list (cdr list) offset)))
2072 (setq gnus-newsgroup-data-reverse nil))))
2074 (defun gnus-data-remove (article &optional offset)
2075 (let ((data gnus-newsgroup-data))
2076 (if (= (gnus-data-number (car data)) article)
2078 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2079 gnus-newsgroup-data-reverse nil)
2081 (gnus-data-update-list gnus-newsgroup-data offset)))
2083 (when (= (gnus-data-number (cadr data)) article)
2084 (setcdr data (cddr data))
2086 (gnus-data-update-list (cdr data) offset))
2088 gnus-newsgroup-data-reverse nil))
2089 (setq data (cdr data))))))
2091 (defmacro gnus-data-list (backward)
2093 (or gnus-newsgroup-data-reverse
2094 (setq gnus-newsgroup-data-reverse
2095 (reverse gnus-newsgroup-data)))
2096 gnus-newsgroup-data))
2098 (defun gnus-data-update-list (data offset)
2099 "Add OFFSET to the POS of all data entries in DATA."
2101 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2102 (setq data (cdr data))))
2104 (defun gnus-data-compute-positions ()
2105 "Compute the positions of all articles."
2106 (let ((data gnus-newsgroup-data)
2109 (when (setq pos (text-property-any
2110 (point-min) (point-max)
2111 'gnus-number (gnus-data-number (car data))))
2112 (gnus-data-set-pos (car data) (+ pos 3)))
2113 (setq data (cdr data)))))
2115 (defun gnus-summary-article-pseudo-p (article)
2116 "Say whether this article is a pseudo article or not."
2117 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2119 (defmacro gnus-summary-article-sparse-p (article)
2120 "Say whether this article is a sparse article or not."
2121 `(memq ,article gnus-newsgroup-sparse))
2123 (defmacro gnus-summary-article-ancient-p (article)
2124 "Say whether this article is a sparse article or not."
2125 `(memq ,article gnus-newsgroup-ancient))
2127 (defun gnus-article-parent-p (number)
2128 "Say whether this article is a parent or not."
2129 (let ((data (gnus-data-find-list number)))
2130 (and (cdr data) ; There has to be an article after...
2131 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2132 (gnus-data-level (nth 1 data))))))
2134 (defun gnus-article-children (number)
2135 "Return a list of all children to NUMBER."
2136 (let* ((data (gnus-data-find-list number))
2137 (level (gnus-data-level (car data)))
2139 (setq data (cdr data))
2141 (= (gnus-data-level (car data)) (1+ level)))
2142 (push (gnus-data-number (car data)) children)
2143 (setq data (cdr data)))
2146 (defmacro gnus-summary-skip-intangible ()
2147 "If the current article is intangible, then jump to a different article."
2148 '(let ((to (get-text-property (point) 'gnus-intangible)))
2149 (and to (gnus-summary-goto-subject to))))
2151 (defmacro gnus-summary-article-intangible-p ()
2152 "Say whether this article is intangible or not."
2153 '(get-text-property (point) 'gnus-intangible))
2155 (defun gnus-article-read-p (article)
2156 "Say whether ARTICLE is read or not."
2157 (not (or (memq article gnus-newsgroup-marked)
2158 (memq article gnus-newsgroup-unreads)
2159 (memq article gnus-newsgroup-unselected)
2160 (memq article gnus-newsgroup-dormant))))
2162 ;; Some summary mode macros.
2164 (defmacro gnus-summary-article-number ()
2165 "The article number of the article on the current line.
2166 If there isn's an article number here, then we return the current
2169 (gnus-summary-skip-intangible)
2170 (or (get-text-property (point) 'gnus-number)
2171 (gnus-summary-last-subject))))
2173 (defmacro gnus-summary-article-header (&optional number)
2174 `(gnus-data-header (gnus-data-find
2175 ,(or number '(gnus-summary-article-number)))))
2177 (defmacro gnus-summary-thread-level (&optional number)
2178 `(if (and (eq gnus-summary-make-false-root 'dummy)
2179 (get-text-property (point) 'gnus-intangible))
2181 (gnus-data-level (gnus-data-find
2182 ,(or number '(gnus-summary-article-number))))))
2184 (defmacro gnus-summary-article-mark (&optional number)
2185 `(gnus-data-mark (gnus-data-find
2186 ,(or number '(gnus-summary-article-number)))))
2188 (defmacro gnus-summary-article-pos (&optional number)
2189 `(gnus-data-pos (gnus-data-find
2190 ,(or number '(gnus-summary-article-number)))))
2192 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2193 (defmacro gnus-summary-article-subject (&optional number)
2194 "Return current subject string or nil if nothing."
2197 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2198 '(gnus-data-header (assq (gnus-summary-article-number)
2199 gnus-newsgroup-data)))))
2202 (mail-header-subject headers))))
2204 (defmacro gnus-summary-article-score (&optional number)
2205 "Return current article score."
2206 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2207 gnus-newsgroup-scored))
2208 gnus-summary-default-score 0))
2210 (defun gnus-summary-article-children (&optional number)
2211 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2212 (level (gnus-data-level (car data)))
2214 (while (and (setq data (cdr data))
2215 (> (setq l (gnus-data-level (car data))) level))
2216 (and (= (1+ level) l)
2217 (push (gnus-data-number (car data))
2219 (nreverse children)))
2221 (defun gnus-summary-article-parent (&optional number)
2222 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2223 (gnus-data-list t)))
2224 (level (gnus-data-level (car data))))
2226 () ; This is a root.
2227 ;; We search until we find an article with a level less than
2228 ;; this one. That function has to be the parent.
2229 (while (and (setq data (cdr data))
2230 (not (< (gnus-data-level (car data)) level))))
2231 (and data (gnus-data-number (car data))))))
2233 (defun gnus-unread-mark-p (mark)
2234 "Say whether MARK is the unread mark."
2235 (= mark gnus-unread-mark))
2237 (defun gnus-read-mark-p (mark)
2238 "Say whether MARK is one of the marks that mark as read.
2239 This is all marks except unread, ticked, dormant, and expirable."
2240 (not (or (= mark gnus-unread-mark)
2241 (= mark gnus-ticked-mark)
2242 (= mark gnus-dormant-mark)
2243 (= mark gnus-expirable-mark))))
2245 (defmacro gnus-article-mark (number)
2247 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2248 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2249 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2250 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2251 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2252 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2253 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2254 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2255 gnus-ancient-mark))))
2257 ;; Saving hidden threads.
2259 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2260 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2262 (defmacro gnus-save-hidden-threads (&rest forms)
2263 "Save hidden threads, eval FORMS, and restore the hidden threads."
2264 (let ((config (make-symbol "config")))
2265 `(let ((,config (gnus-hidden-threads-configuration)))
2269 (gnus-restore-hidden-threads-configuration ,config)))))
2271 (defun gnus-hidden-threads-configuration ()
2272 "Return the current hidden threads configuration."
2275 (goto-char (point-min))
2276 (while (search-forward "\r" nil t)
2277 (push (1- (point)) config))
2280 (defun gnus-restore-hidden-threads-configuration (config)
2281 "Restore hidden threads configuration from CONFIG."
2282 (let (point buffer-read-only)
2283 (while (setq point (pop config))
2284 (when (and (< point (point-max))
2286 (= (following-char) ?\n))
2287 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2289 ;; Various summary mode internalish functions.
2291 (defun gnus-mouse-pick-article (e)
2294 (gnus-summary-next-page nil t))
2296 (defun gnus-summary-set-display-table ()
2297 ;; Change the display table. Odd characters have a tendency to mess
2298 ;; up nicely formatted displays - we make all possible glyphs
2299 ;; display only a single character.
2301 ;; We start from the standard display table, if any.
2302 (let ((table (or (copy-sequence standard-display-table)
2303 (make-display-table)))
2305 ;; Nix out all the control chars...
2306 (while (>= (setq i (1- i)) 0)
2307 (aset table i [??]))
2308 ;; ... but not newline and cr, of course. (cr is necessary for the
2309 ;; selective display).
2310 (aset table ?\n nil)
2311 (aset table ?\r nil)
2312 ;; We nix out any glyphs over 126 that are not set already.
2314 (while (>= (setq i (1- i)) 127)
2315 ;; Only modify if the entry is nil.
2316 (unless (aref table i)
2317 (aset table i [??]))))
2318 (setq buffer-display-table table)))
2320 (defun gnus-summary-setup-buffer (group)
2321 "Initialize summary buffer."
2322 (let ((buffer (concat "*Summary " group "*")))
2323 (if (get-buffer buffer)
2326 (setq gnus-summary-buffer (current-buffer))
2327 (not gnus-newsgroup-prepared))
2328 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2329 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
2330 (gnus-add-current-to-buffer-list)
2331 (gnus-summary-mode group)
2333 (gnus-carpal-setup-buffer 'summary))
2334 (unless gnus-single-article-buffer
2335 (make-local-variable 'gnus-article-buffer)
2336 (make-local-variable 'gnus-article-current)
2337 (make-local-variable 'gnus-original-article-buffer))
2338 (setq gnus-newsgroup-name group)
2341 (defun gnus-set-global-variables ()
2342 ;; Set the global equivalents of the summary buffer-local variables
2343 ;; to the latest values they had. These reflect the summary buffer
2344 ;; that was in action when the last article was fetched.
2345 (when (eq major-mode 'gnus-summary-mode)
2346 (setq gnus-summary-buffer (current-buffer))
2347 (let ((name gnus-newsgroup-name)
2348 (marked gnus-newsgroup-marked)
2349 (unread gnus-newsgroup-unreads)
2350 (headers gnus-current-headers)
2351 (data gnus-newsgroup-data)
2352 (summary gnus-summary-buffer)
2353 (article-buffer gnus-article-buffer)
2354 (original gnus-original-article-buffer)
2355 (gac gnus-article-current)
2356 (reffed gnus-reffed-article-number)
2357 (score-file gnus-current-score-file))
2359 (set-buffer gnus-group-buffer)
2360 (setq gnus-newsgroup-name name
2361 gnus-newsgroup-marked marked
2362 gnus-newsgroup-unreads unread
2363 gnus-current-headers headers
2364 gnus-newsgroup-data data
2365 gnus-article-current gac
2366 gnus-summary-buffer summary
2367 gnus-article-buffer article-buffer
2368 gnus-original-article-buffer original
2369 gnus-reffed-article-number reffed
2370 gnus-current-score-file score-file)
2371 ;; The article buffer also has local variables.
2372 (when (gnus-buffer-live-p gnus-article-buffer)
2373 (set-buffer gnus-article-buffer)
2374 (setq gnus-summary-buffer summary))))))
2376 (defun gnus-summary-article-unread-p (article)
2377 "Say whether ARTICLE is unread or not."
2378 (memq article gnus-newsgroup-unreads))
2380 (defun gnus-summary-first-article-p (&optional article)
2381 "Return whether ARTICLE is the first article in the buffer."
2382 (if (not (setq article (or article (gnus-summary-article-number))))
2384 (eq article (caar gnus-newsgroup-data))))
2386 (defun gnus-summary-last-article-p (&optional article)
2387 "Return whether ARTICLE is the last article in the buffer."
2388 (if (not (setq article (or article (gnus-summary-article-number))))
2389 t ; All non-existent numbers are the last article. :-)
2390 (not (cdr (gnus-data-find-list article)))))
2392 (defun gnus-make-thread-indent-array ()
2394 (unless (and gnus-thread-indent-array
2395 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2396 (setq gnus-thread-indent-array (make-vector 201 "")
2397 gnus-thread-indent-array-level gnus-thread-indent-level)
2399 (aset gnus-thread-indent-array n
2400 (make-string (* n gnus-thread-indent-level) ? ))
2403 (defun gnus-update-summary-mark-positions ()
2404 "Compute where the summary marks are to go."
2406 (when (and gnus-summary-buffer
2407 (get-buffer gnus-summary-buffer)
2408 (buffer-name (get-buffer gnus-summary-buffer)))
2409 (set-buffer gnus-summary-buffer))
2410 (let ((gnus-replied-mark 129)
2411 (gnus-score-below-mark 130)
2412 (gnus-score-over-mark 130)
2413 (gnus-download-mark 131)
2414 (spec gnus-summary-line-format-spec)
2415 thread gnus-visual pos)
2417 (gnus-set-work-buffer)
2418 (let ((gnus-summary-line-format-spec spec)
2419 (gnus-newsgroup-downloadable '((0 . t))))
2420 (gnus-summary-insert-line
2421 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2422 (goto-char (point-min))
2423 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2425 (goto-char (point-min))
2426 (push (cons 'replied (and (search-forward "\201" nil t)
2429 (goto-char (point-min))
2430 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2432 (goto-char (point-min))
2433 (push (cons 'download
2434 (and (search-forward "\203" nil t) (- (point) 2)))
2436 (setq gnus-summary-mark-positions pos))))
2438 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2439 "Insert a dummy root in the summary buffer."
2441 (gnus-add-text-properties
2442 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2443 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2445 (defun gnus-summary-insert-line (gnus-tmp-header
2446 gnus-tmp-level gnus-tmp-current
2447 gnus-tmp-unread gnus-tmp-replied
2448 gnus-tmp-expirable gnus-tmp-subject-or-nil
2449 &optional gnus-tmp-dummy gnus-tmp-score
2451 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2452 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2453 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2454 (gnus-tmp-score-char
2455 (if (or (null gnus-summary-default-score)
2456 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2457 gnus-summary-zcore-fuzz))
2459 (if (< gnus-tmp-score gnus-summary-default-score)
2460 gnus-score-below-mark gnus-score-over-mark)))
2462 (cond (gnus-tmp-process gnus-process-mark)
2463 ((memq gnus-tmp-current gnus-newsgroup-cached)
2465 (gnus-tmp-replied gnus-replied-mark)
2466 ((memq gnus-tmp-current gnus-newsgroup-saved)
2468 (t gnus-unread-mark)))
2469 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2472 ((string-match "<[^>]+> *$" gnus-tmp-from)
2473 (let ((beg (match-beginning 0)))
2474 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2475 (substring gnus-tmp-from (1+ (match-beginning 0))
2476 (1- (match-end 0))))
2477 (substring gnus-tmp-from 0 beg))))
2478 ((string-match "(.+)" gnus-tmp-from)
2479 (substring gnus-tmp-from
2480 (1+ (match-beginning 0)) (1- (match-end 0))))
2482 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2483 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2484 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2485 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2486 (buffer-read-only nil))
2487 (when (string= gnus-tmp-name "")
2488 (setq gnus-tmp-name gnus-tmp-from))
2489 (unless (numberp gnus-tmp-lines)
2490 (setq gnus-tmp-lines 0))
2491 (gnus-put-text-property
2493 (progn (eval gnus-summary-line-format-spec) (point))
2494 'gnus-number gnus-tmp-number)
2495 (when (gnus-visual-p 'summary-highlight 'highlight)
2497 (run-hooks 'gnus-summary-update-hook)
2500 (defun gnus-summary-update-line (&optional dont-update)
2501 ;; Update summary line after change.
2502 (when (and gnus-summary-default-score
2503 (not gnus-summary-inhibit-highlight))
2504 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2505 (article (gnus-summary-article-number))
2506 (score (gnus-summary-article-score article)))
2508 (if (and gnus-summary-mark-below
2509 (< (gnus-summary-article-score)
2510 gnus-summary-mark-below))
2511 ;; This article has a low score, so we mark it as read.
2512 (when (memq article gnus-newsgroup-unreads)
2513 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2514 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2515 ;; This article was previously marked as read on account
2516 ;; of a low score, but now it has risen, so we mark it as
2518 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2519 (gnus-summary-update-mark
2520 (if (or (null gnus-summary-default-score)
2521 (<= (abs (- score gnus-summary-default-score))
2522 gnus-summary-zcore-fuzz))
2524 (if (< score gnus-summary-default-score)
2525 gnus-score-below-mark gnus-score-over-mark))
2527 ;; Do visual highlighting.
2528 (when (gnus-visual-p 'summary-highlight 'highlight)
2529 (run-hooks 'gnus-summary-update-hook)))))
2531 (defvar gnus-tmp-new-adopts nil)
2533 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2534 "Return the number of articles in THREAD.
2535 This may be 0 in some cases -- if none of the articles in
2536 the thread are to be displayed."
2538 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2540 ((not (listp thread))
2542 ((and (consp thread) (cdr thread))
2545 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2548 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2551 (when (and level (zerop level) gnus-tmp-new-adopts)
2554 'gnus-summary-number-of-articles-in-thread
2555 gnus-tmp-new-adopts))))
2557 (if (> number 1) gnus-not-empty-thread-mark
2558 gnus-empty-thread-mark)
2561 (defun gnus-summary-set-local-parameters (group)
2562 "Go through the local params of GROUP and set all variable specs in that list."
2563 (let ((params (gnus-group-find-parameter group))
2566 (setq elem (car params)
2567 params (cdr params))
2568 (and (consp elem) ; Has to be a cons.
2569 (consp (cdr elem)) ; The cdr has to be a list.
2570 (symbolp (car elem)) ; Has to be a symbol in there.
2571 (not (memq (car elem)
2572 '(quit-config to-address to-list to-group)))
2573 (ignore-errors ; So we set it.
2574 (make-local-variable (car elem))
2575 (set (car elem) (eval (nth 1 elem))))))))
2577 (defun gnus-summary-read-group (group &optional show-all no-article
2578 kill-buffer no-display)
2579 "Start reading news in newsgroup GROUP.
2580 If SHOW-ALL is non-nil, already read articles are also listed.
2581 If NO-ARTICLE is non-nil, no article is selected initially.
2582 If NO-DISPLAY, don't generate a summary buffer."
2586 (let ((gnus-auto-select-next nil))
2587 (or (gnus-summary-read-group-1
2588 group show-all no-article
2589 kill-buffer no-display)
2590 (setq show-all nil)))))
2591 (eq gnus-auto-select-next 'quietly))
2592 (set-buffer gnus-group-buffer)
2593 (if (not (equal group (gnus-group-group-name)))
2594 (setq group (gnus-group-group-name))
2598 (defun gnus-summary-read-group-1 (group show-all no-article
2599 kill-buffer no-display)
2600 ;; Killed foreign groups can't be entered.
2601 (when (and (not (gnus-group-native-p group))
2602 (not (gnus-gethash group gnus-newsrc-hashtb)))
2603 (error "Dead non-native groups can't be entered"))
2604 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2605 (let* ((new-group (gnus-summary-setup-buffer group))
2606 (quit-config (gnus-group-quit-config group))
2607 (did-select (and new-group (gnus-select-newsgroup group show-all))))
2609 ;; This summary buffer exists already, so we just select it.
2611 (gnus-set-global-variables)
2613 (gnus-kill-or-deaden-summary kill-buffer))
2614 (gnus-configure-windows 'summary 'force)
2615 (gnus-set-mode-line 'summary)
2616 (gnus-summary-position-point)
2619 ;; We couldn't select this group.
2621 (when (and (eq major-mode 'gnus-summary-mode)
2622 (not (equal (current-buffer) kill-buffer)))
2623 (kill-buffer (current-buffer))
2624 (if (not quit-config)
2626 ;; Update the info -- marks might need to be removed,
2628 (gnus-summary-update-info)
2629 (set-buffer gnus-group-buffer)
2630 (gnus-group-jump-to-group group)
2631 (gnus-group-next-unread-group 1))
2632 (gnus-handle-ephemeral-exit quit-config)))
2633 (gnus-message 3 "Can't select group")
2635 ;; The user did a `C-g' while prompting for number of articles,
2636 ;; so we exit this group.
2637 ((eq did-select 'quit)
2638 (and (eq major-mode 'gnus-summary-mode)
2639 (not (equal (current-buffer) kill-buffer))
2640 (kill-buffer (current-buffer)))
2642 (gnus-kill-or-deaden-summary kill-buffer))
2643 (if (not quit-config)
2645 (set-buffer gnus-group-buffer)
2646 (gnus-group-jump-to-group group)
2647 (gnus-group-next-unread-group 1)
2648 (gnus-configure-windows 'group 'force))
2649 (gnus-handle-ephemeral-exit quit-config))
2650 ;; Finally signal the quit.
2652 ;; The group was successfully selected.
2654 (gnus-set-global-variables)
2655 ;; Save the active value in effect when the group was entered.
2656 (setq gnus-newsgroup-active
2658 (gnus-active gnus-newsgroup-name)))
2659 ;; You can change the summary buffer in some way with this hook.
2660 (run-hooks 'gnus-select-group-hook)
2661 ;; Set any local variables in the group parameters.
2662 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2663 (gnus-update-format-specifications
2664 nil 'summary 'summary-mode 'summary-dummy)
2665 ;; Do score processing.
2666 (when gnus-use-scoring
2667 (gnus-possibly-score-headers))
2668 ;; Check whether to fill in the gaps in the threads.
2669 (when gnus-build-sparse-threads
2670 (gnus-build-sparse-threads))
2671 ;; Find the initial limit.
2672 (if gnus-show-threads
2674 (let ((gnus-newsgroup-dormant nil))
2675 (gnus-summary-initial-limit show-all))
2676 (gnus-summary-initial-limit show-all))
2677 (setq gnus-newsgroup-limit
2679 (lambda (header) (mail-header-number header))
2680 gnus-newsgroup-headers)))
2681 ;; Generate the summary buffer.
2683 (gnus-summary-prepare))
2684 (when gnus-use-trees
2685 (gnus-tree-open group)
2686 (setq gnus-summary-highlight-line-function
2687 'gnus-tree-highlight-article))
2688 ;; If the summary buffer is empty, but there are some low-scored
2689 ;; articles or some excluded dormants, we include these in the
2691 (when (and (zerop (buffer-size))
2693 (cond (gnus-newsgroup-dormant
2694 (gnus-summary-limit-include-dormant))
2695 ((and gnus-newsgroup-scored show-all)
2696 (gnus-summary-limit-include-expunged t))))
2697 ;; Function `gnus-apply-kill-file' must be called in this hook.
2698 (run-hooks 'gnus-apply-kill-hook)
2699 (if (and (zerop (buffer-size))
2702 ;; This newsgroup is empty.
2703 (gnus-summary-catchup-and-exit nil t)
2704 (gnus-message 6 "No unread news")
2706 (gnus-kill-or-deaden-summary kill-buffer))
2707 ;; Return nil from this function.
2709 ;; Hide conversation thread subtrees. We cannot do this in
2710 ;; gnus-summary-prepare-hook since kill processing may not
2711 ;; work with hidden articles.
2712 (and gnus-show-threads
2713 gnus-thread-hide-subtree
2714 (gnus-summary-hide-all-threads))
2716 (gnus-kill-or-deaden-summary kill-buffer))
2717 ;; Show first unread article if requested.
2718 (if (and (not no-article)
2720 gnus-newsgroup-unreads
2721 gnus-auto-select-first)
2722 (unless (if (eq gnus-auto-select-first 'best)
2723 (gnus-summary-best-unread-article)
2724 (gnus-summary-first-unread-article))
2725 (gnus-configure-windows 'summary))
2726 ;; Don't select any articles, just move point to the first
2727 ;; article in the group.
2728 (goto-char (point-min))
2729 (gnus-summary-position-point)
2730 (gnus-set-mode-line 'summary)
2731 (gnus-configure-windows 'summary 'force))
2732 (when (get-buffer-window gnus-group-buffer t)
2733 ;; Gotta use windows, because recenter does weird stuff if
2734 ;; the current buffer ain't the displayed window.
2735 (let ((owin (selected-window)))
2736 (select-window (get-buffer-window gnus-group-buffer t))
2737 (when (gnus-group-goto-group group)
2739 (select-window owin)))
2740 ;; Mark this buffer as "prepared".
2741 (setq gnus-newsgroup-prepared t)
2744 (defun gnus-summary-prepare ()
2745 "Generate the summary buffer."
2747 (let ((buffer-read-only nil))
2749 (setq gnus-newsgroup-data nil
2750 gnus-newsgroup-data-reverse nil)
2751 (run-hooks 'gnus-summary-generate-hook)
2752 ;; Generate the buffer, either with threads or without.
2753 (when gnus-newsgroup-headers
2754 (gnus-summary-prepare-threads
2755 (if gnus-show-threads
2756 (gnus-sort-gathered-threads
2757 (funcall gnus-summary-thread-gathering-function
2759 (gnus-cut-threads (gnus-make-threads)))))
2760 ;; Unthreaded display.
2761 (gnus-sort-articles gnus-newsgroup-headers))))
2762 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2763 ;; Call hooks for modifying summary buffer.
2764 (goto-char (point-min))
2765 (run-hooks 'gnus-summary-prepare-hook)))
2767 (defsubst gnus-general-simplify-subject (subject)
2768 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2771 ;; Truncate the subject.
2772 (gnus-simplify-subject-functions
2773 (gnus-map-function gnus-simplify-subject-functions subject))
2774 ((numberp gnus-summary-gather-subject-limit)
2775 (setq subject (gnus-simplify-subject-re subject))
2776 (if (> (length subject) gnus-summary-gather-subject-limit)
2777 (substring subject 0 gnus-summary-gather-subject-limit)
2779 ;; Fuzzily simplify it.
2780 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2781 (gnus-simplify-subject-fuzzy subject))
2782 ;; Just remove the leading "Re:".
2784 (gnus-simplify-subject-re subject))))
2786 (if (and gnus-summary-gather-exclude-subject
2787 (string-match gnus-summary-gather-exclude-subject subject))
2788 nil ; This article shouldn't be gathered
2791 (defun gnus-summary-simplify-subject-query ()
2792 "Query where the respool algorithm would put this article."
2794 (gnus-summary-select-article)
2795 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2797 (defun gnus-gather-threads-by-subject (threads)
2798 "Gather threads by looking at Subject headers."
2799 (if (not gnus-summary-make-false-root)
2801 (let ((hashtb (gnus-make-hashtable 1024))
2804 subject hthread whole-subject)
2806 (setq subject (gnus-general-simplify-subject
2807 (setq whole-subject (mail-header-subject
2810 (if (setq hthread (gnus-gethash subject hashtb))
2812 ;; We enter a dummy root into the thread, if we
2813 ;; haven't done that already.
2814 (unless (stringp (caar hthread))
2815 (setcar hthread (list whole-subject (car hthread))))
2816 ;; We add this new gathered thread to this gathered
2818 (setcdr (car hthread)
2819 (nconc (cdar hthread) (list (car threads))))
2820 ;; Remove it from the list of threads.
2821 (setcdr prev (cdr threads))
2822 (setq threads prev))
2823 ;; Enter this thread into the hash table.
2824 (gnus-sethash subject threads hashtb)))
2826 (setq threads (cdr threads)))
2829 (defun gnus-gather-threads-by-references (threads)
2830 "Gather threads by looking at References headers."
2831 (let ((idhashtb (gnus-make-hashtable 1024))
2832 (thhashtb (gnus-make-hashtable 1024))
2835 ids references id gthread gid entered ref)
2837 (when (setq references (mail-header-references (caar threads)))
2838 (setq id (mail-header-id (caar threads))
2839 ids (gnus-split-references references)
2841 (while (setq ref (pop ids))
2842 (setq ids (delete ref ids))
2843 (if (not (setq gid (gnus-gethash ref idhashtb)))
2845 (gnus-sethash ref id idhashtb)
2846 (gnus-sethash id threads thhashtb))
2847 (setq gthread (gnus-gethash gid thhashtb))
2849 ;; We enter a dummy root into the thread, if we
2850 ;; haven't done that already.
2851 (unless (stringp (caar gthread))
2852 (setcar gthread (list (mail-header-subject (caar gthread))
2854 ;; We add this new gathered thread to this gathered
2856 (setcdr (car gthread)
2857 (nconc (cdar gthread) (list (car threads)))))
2858 ;; Add it into the thread hash table.
2859 (gnus-sethash id gthread thhashtb)
2861 ;; Remove it from the list of threads.
2862 (setcdr prev (cdr threads))
2863 (setq threads prev))))
2865 (setq threads (cdr threads)))
2868 (defun gnus-sort-gathered-threads (threads)
2869 "Sort subtreads inside each gathered thread by article number."
2870 (let ((result threads))
2872 (when (stringp (caar threads))
2873 (setcdr (car threads)
2874 (sort (cdar threads) 'gnus-thread-sort-by-number)))
2875 (setq threads (cdr threads)))
2878 (defun gnus-thread-loop-p (root thread)
2879 "Say whether ROOT is in THREAD."
2880 (let ((stack (list thread))
2883 (while (setq thread (pop stack))
2884 (setq th (cdr thread))
2886 (not (eq (caar th) root)))
2889 ;; We have found a loop.
2891 (setcdr thread (delq (car th) (cdr thread)))
2892 (if (boundp (setq ref-dep (intern "none"
2893 gnus-newsgroup-dependencies)))
2894 (setcdr (symbol-value ref-dep)
2895 (nconc (cdr (symbol-value ref-dep))
2897 (set ref-dep (list nil (car th))))
2900 ;; Push all the subthreads onto the stack.
2901 (push (cdr thread) stack)))
2904 (defun gnus-make-threads ()
2905 "Go through the dependency hashtb and find the roots. Return all threads."
2907 (while (catch 'infloop
2910 ;; Deal with self-referencing References loops.
2911 (when (and (car (symbol-value refs))
2918 (car (symbol-value refs)) thread))
2919 (cdr (symbol-value refs)))))))
2922 (unless (car (symbol-value refs))
2923 ;; These threads do not refer back to any other articles,
2924 ;; so they're roots.
2925 (setq threads (append (cdr (symbol-value refs)) threads))))
2926 gnus-newsgroup-dependencies)))
2929 (defun gnus-build-sparse-threads ()
2930 (let ((headers gnus-newsgroup-headers)
2931 (deps gnus-newsgroup-dependencies)
2932 header references generation relations
2933 cthread subject child end pthread relation new-child)
2934 ;; First we create an alist of generations/relations, where
2935 ;; generations is how much we trust the relation, and the relation
2937 (gnus-message 7 "Making sparse threads...")
2939 (nnheader-set-temp-buffer " *gnus sparse threads*")
2940 (while (setq header (pop headers))
2941 (when (and (setq references (mail-header-references header))
2942 (not (string= references "")))
2944 (setq child (mail-header-id header)
2945 subject (mail-header-subject header))
2947 (while (search-backward ">" nil t)
2948 (setq end (1+ (point)))
2949 (when (search-backward "<" nil t)
2950 (unless (string= (setq new-child (buffer-substring (point) end))
2952 (push (list (incf generation)
2953 child (setq child new-child)
2956 (push (list (1+ generation) child nil subject) relations)
2958 (kill-buffer (current-buffer)))
2959 ;; Sort over trustworthiness.
2960 (setq relations (sort relations 'car-less-than-car))
2961 (while (setq relation (pop relations))
2962 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
2963 (unless (car (symbol-value cthread))
2964 ;; Make this article the parent of these threads.
2965 (setcar (symbol-value cthread)
2966 (vector gnus-reffed-article-number
2970 (or (caddr relation) "") 0 0 "")))
2971 (set cthread (list (vector gnus-reffed-article-number
2973 "" "" (cadr relation)
2974 (or (caddr relation) "") 0 0 ""))))
2975 (push gnus-reffed-article-number gnus-newsgroup-limit)
2976 (push gnus-reffed-article-number gnus-newsgroup-sparse)
2977 (push (cons gnus-reffed-article-number gnus-sparse-mark)
2978 gnus-newsgroup-reads)
2979 (decf gnus-reffed-article-number)
2980 ;; Make this new thread the child of its parent.
2981 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
2982 (setcdr (symbol-value pthread)
2983 (nconc (cdr (symbol-value pthread))
2984 (list (symbol-value cthread))))
2985 (set pthread (list nil (symbol-value cthread))))))
2986 (gnus-message 7 "Making sparse threads...done")))
2988 (defun gnus-build-old-threads ()
2989 ;; Look at all the articles that refer back to old articles, and
2990 ;; fetch the headers for the articles that aren't there. This will
2991 ;; build complete threads - if the roots haven't been expired by the
2996 (when (not (car (symbol-value refs)))
2997 (setq heads (cdr (symbol-value refs)))
2999 (if (memq (mail-header-number (caar heads))
3000 gnus-newsgroup-dormant)
3001 (setq heads (cdr heads))
3002 (setq id (symbol-name refs))
3003 (while (and (setq id (gnus-build-get-header id))
3004 (not (car (gnus-gethash
3005 id gnus-newsgroup-dependencies)))))
3006 (setq heads nil)))))
3007 gnus-newsgroup-dependencies)))
3009 (defun gnus-build-get-header (id)
3010 ;; Look through the buffer of NOV lines and find the header to
3011 ;; ID. Enter this line into the dependencies hash table, and return
3012 ;; the id of the parent article (if any).
3013 (let ((deps gnus-newsgroup-dependencies)
3017 (set-buffer nntp-server-buffer)
3018 (let ((case-fold-search nil))
3019 (goto-char (point-min))
3020 (while (and (not found)
3021 (search-forward id nil t))
3023 (setq found (looking-at
3024 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3025 (regexp-quote id))))
3026 (or found (beginning-of-line 2)))
3030 (setq header (gnus-nov-parse-line
3031 (read (current-buffer)) deps))
3032 (gnus-parent-id (mail-header-references header))))))
3034 (let ((number (mail-header-number header)))
3035 (push number gnus-newsgroup-limit)
3036 (push header gnus-newsgroup-headers)
3037 (if (memq number gnus-newsgroup-unselected)
3039 (push number gnus-newsgroup-unreads)
3040 (setq gnus-newsgroup-unselected
3041 (delq number gnus-newsgroup-unselected)))
3042 (push number gnus-newsgroup-ancient)))))))
3044 (defun gnus-build-all-threads ()
3045 "Read all the headers."
3046 (let ((deps gnus-newsgroup-dependencies)
3047 (gnus-summary-ignore-duplicates t)
3048 found header article)
3050 (set-buffer nntp-server-buffer)
3051 (let ((case-fold-search nil))
3052 (goto-char (point-min))
3055 (setq article (read (current-buffer)))
3056 (setq header (gnus-nov-parse-line article deps)))
3058 (push header gnus-newsgroup-headers)
3059 (if (memq (setq article (mail-header-number header))
3060 gnus-newsgroup-unselected)
3062 (push article gnus-newsgroup-unreads)
3063 (setq gnus-newsgroup-unselected
3064 (delq article gnus-newsgroup-unselected)))
3065 (push article gnus-newsgroup-ancient))
3066 (forward-line 1)))))))
3068 (defun gnus-summary-update-article-line (article header)
3069 "Update the line for ARTICLE using HEADERS."
3070 (let* ((id (mail-header-id header))
3071 (thread (gnus-id-to-thread id)))
3073 (error "Article in no thread"))
3074 ;; Update the thread.
3075 (setcar thread header)
3076 (gnus-summary-goto-subject article)
3077 (let* ((datal (gnus-data-find-list article))
3079 (length (when (cdr datal)
3080 (- (gnus-data-pos data)
3081 (gnus-data-pos (cadr datal)))))
3082 (buffer-read-only nil)
3083 (level (gnus-summary-thread-level)))
3085 (gnus-summary-insert-line
3086 header level nil (gnus-article-mark article)
3087 (memq article gnus-newsgroup-replied)
3088 (memq article gnus-newsgroup-expirable)
3089 ;; Only insert the Subject string when it's different
3090 ;; from the previous Subject string.
3091 (if (gnus-subject-equal
3093 (mail-header-subject
3096 (gnus-data-find-list
3098 (gnus-data-list t)))))
3099 ;; Error on the side of excessive subjects.
3101 (mail-header-subject header))
3103 (mail-header-subject header))
3104 nil (cdr (assq article gnus-newsgroup-scored))
3105 (memq article gnus-newsgroup-processable))
3107 (gnus-data-update-list
3108 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3110 (defun gnus-summary-update-article (article &optional iheader)
3111 "Update ARTICLE in the summary buffer."
3112 (set-buffer gnus-summary-buffer)
3113 (let* ((header (or iheader (gnus-summary-article-header article)))
3114 (id (mail-header-id header))
3115 (data (gnus-data-find article))
3116 (thread (gnus-id-to-thread id))
3117 (references (mail-header-references header))
3121 (when (and references
3122 (not (equal "" references)))
3125 (buffer-read-only nil)
3127 (number (mail-header-number header))
3130 ;; !!! Should this be in or not?
3132 (setcar thread nil))
3134 (delq thread parent))
3135 (if (gnus-summary-insert-subject id header iheader)
3136 ;; Set the (possibly) new article number in the data structure.
3137 (gnus-data-set-number data (gnus-id-to-article id))
3141 (defun gnus-rebuild-thread (id)
3142 "Rebuild the thread containing ID."
3143 (let ((buffer-read-only nil)
3144 old-pos current thread data)
3145 (if (not gnus-show-threads)
3146 (setq thread (list (car (gnus-id-to-thread id))))
3147 ;; Get the thread this article is part of.
3148 (setq thread (gnus-remove-thread id)))
3149 (setq old-pos (gnus-point-at-bol))
3150 (setq current (save-excursion
3151 (and (zerop (forward-line -1))
3152 (gnus-summary-article-number))))
3153 ;; If this is a gathered thread, we have to go some re-gathering.
3154 (when (stringp (car thread))
3155 (let ((subject (car thread))
3157 (setq thread (cdr thread))
3159 (unless (memq (setq thr (gnus-id-to-thread
3161 (mail-header-id (caar thread)))))
3164 (setq thread (cdr thread)))
3165 ;; We now have all (unique) roots.
3166 (if (= (length roots) 1)
3167 ;; All the loose roots are now one solid root.
3168 (setq thread (car roots))
3169 (setq thread (cons subject (gnus-sort-threads roots))))))
3171 ;; We then insert this thread into the summary buffer.
3172 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3173 (if gnus-show-threads
3174 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3175 (gnus-summary-prepare-unthreaded thread))
3176 (setq data (nreverse gnus-newsgroup-data))
3177 (setq threads gnus-newsgroup-threads))
3178 ;; We splice the new data into the data structure.
3179 (gnus-data-enter-list current data (- (point) old-pos))
3180 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
3182 (defun gnus-number-to-header (number)
3183 "Return the header for article NUMBER."
3184 (let ((headers gnus-newsgroup-headers))
3186 (not (= number (mail-header-number (car headers)))))
3191 (defun gnus-parent-headers (headers &optional generation)
3192 "Return the headers of the GENERATIONeth parent of HEADERS."
3194 (setq generation 1))
3197 (while (and parent headers (not (zerop generation)))
3198 (setq references (mail-header-references headers))
3199 (when (and references
3200 (setq parent (gnus-parent-id references))
3201 (setq headers (car (gnus-id-to-thread parent))))
3205 (defun gnus-id-to-thread (id)
3206 "Return the (sub-)thread where ID appears."
3207 (gnus-gethash id gnus-newsgroup-dependencies))
3209 (defun gnus-id-to-article (id)
3210 "Return the article number of ID."
3211 (let ((thread (gnus-id-to-thread id)))
3214 (mail-header-number (car thread)))))
3216 (defun gnus-id-to-header (id)
3217 "Return the article headers of ID."
3218 (car (gnus-id-to-thread id)))
3220 (defun gnus-article-displayed-root-p (article)
3221 "Say whether ARTICLE is a root(ish) article."
3222 (let ((level (gnus-summary-thread-level article))
3223 (refs (mail-header-references (gnus-summary-article-header article)))
3229 ((null (gnus-parent-id refs)) t)
3231 (null (setq particle (gnus-id-to-article
3232 (gnus-parent-id refs))))
3233 (null (gnus-summary-thread-level particle)))))))
3235 (defun gnus-root-id (id)
3236 "Return the id of the root of the thread where ID appears."
3238 (while (and id (setq prev (car (gnus-gethash
3239 id gnus-newsgroup-dependencies))))
3241 id (gnus-parent-id (mail-header-references prev))))
3244 (defun gnus-articles-in-thread (thread)
3245 "Return the list of articles in THREAD."
3246 (cons (mail-header-number (car thread))
3247 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3249 (defun gnus-remove-thread (id &optional dont-remove)
3250 "Remove the thread that has ID in it."
3251 (let ((dep gnus-newsgroup-dependencies)
3252 headers thread last-id)
3253 ;; First go up in this thread until we find the root.
3254 (setq last-id (gnus-root-id id))
3255 (setq headers (list (car (gnus-id-to-thread last-id))
3256 (caadr (gnus-id-to-thread last-id))))
3257 ;; We have now found the real root of this thread. It might have
3258 ;; been gathered into some loose thread, so we have to search
3259 ;; through the threads to find the thread we wanted.
3260 (let ((threads gnus-newsgroup-threads)
3263 (setq sub (car threads))
3264 (if (stringp (car sub))
3265 ;; This is a gathered thread, so we look at the roots
3266 ;; below it to find whether this article is in this
3269 (setq sub (cdr sub))
3271 (when (member (caar sub) headers)
3272 (setq thread (car threads)
3275 (setq sub (cdr sub))))
3276 ;; It's an ordinary thread, so we check it.
3277 (when (eq (car sub) (car headers))
3280 (setq threads (cdr threads)))
3281 ;; If this article is in no thread, then it's a root.
3284 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3285 (setq thread (gnus-gethash last-id dep)))
3288 thread ; We return this thread.
3290 (if (stringp (car thread))
3292 ;; If we use dummy roots, then we have to remove the
3293 ;; dummy root as well.
3294 (when (eq gnus-summary-make-false-root 'dummy)
3296 (gnus-data-compute-positions))
3297 (setq thread (cdr thread))
3299 (gnus-remove-thread-1 (car thread))
3300 (setq thread (cdr thread))))
3301 (gnus-remove-thread-1 thread))))))))
3303 (defun gnus-remove-thread-1 (thread)
3304 "Remove the thread THREAD recursively."
3305 (let ((number (mail-header-number (pop thread)))
3307 (setq thread (reverse thread))
3309 (gnus-remove-thread-1 (pop thread)))
3310 (when (setq d (gnus-data-find number))
3311 (goto-char (gnus-data-pos d))
3314 (- (gnus-point-at-bol)
3316 (1+ (gnus-point-at-eol))
3317 (gnus-delete-line)))))))
3319 (defun gnus-sort-threads (threads)
3321 (if (not gnus-thread-sort-functions)
3323 (gnus-message 7 "Sorting threads...")
3325 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3326 (gnus-message 7 "Sorting threads...done"))))
3328 (defun gnus-sort-articles (articles)
3330 (when gnus-article-sort-functions
3331 (gnus-message 7 "Sorting articles...")
3333 (setq gnus-newsgroup-headers
3334 (sort articles (gnus-make-sort-function
3335 gnus-article-sort-functions)))
3336 (gnus-message 7 "Sorting articles...done"))))
3338 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3339 (defmacro gnus-thread-header (thread)
3340 ;; Return header of first article in THREAD.
3341 ;; Note that THREAD must never, ever be anything else than a variable -
3342 ;; using some other form will lead to serious barfage.
3343 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3344 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3345 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
3348 (defsubst gnus-article-sort-by-number (h1 h2)
3349 "Sort articles by article number."
3350 (< (mail-header-number h1)
3351 (mail-header-number h2)))
3353 (defun gnus-thread-sort-by-number (h1 h2)
3354 "Sort threads by root article number."
3355 (gnus-article-sort-by-number
3356 (gnus-thread-header h1) (gnus-thread-header h2)))
3358 (defsubst gnus-article-sort-by-lines (h1 h2)
3359 "Sort articles by article Lines header."
3360 (< (mail-header-lines h1)
3361 (mail-header-lines h2)))
3363 (defun gnus-thread-sort-by-lines (h1 h2)
3364 "Sort threads by root article Lines header."
3365 (gnus-article-sort-by-lines
3366 (gnus-thread-header h1) (gnus-thread-header h2)))
3368 (defsubst gnus-article-sort-by-author (h1 h2)
3369 "Sort articles by root author."
3371 (let ((extract (funcall
3372 gnus-extract-address-components
3373 (mail-header-from h1))))
3374 (or (car extract) (cadr extract) ""))
3375 (let ((extract (funcall
3376 gnus-extract-address-components
3377 (mail-header-from h2))))
3378 (or (car extract) (cadr extract) ""))))
3380 (defun gnus-thread-sort-by-author (h1 h2)
3381 "Sort threads by root author."
3382 (gnus-article-sort-by-author
3383 (gnus-thread-header h1) (gnus-thread-header h2)))
3385 (defsubst gnus-article-sort-by-subject (h1 h2)
3386 "Sort articles by root subject."
3388 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3389 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3391 (defun gnus-thread-sort-by-subject (h1 h2)
3392 "Sort threads by root subject."
3393 (gnus-article-sort-by-subject
3394 (gnus-thread-header h1) (gnus-thread-header h2)))
3396 (defsubst gnus-article-sort-by-date (h1 h2)
3397 "Sort articles by root article date."
3399 (gnus-date-get-time (mail-header-date h1))
3400 (gnus-date-get-time (mail-header-date h2))))
3402 (defun gnus-thread-sort-by-date (h1 h2)
3403 "Sort threads by root article date."
3404 (gnus-article-sort-by-date
3405 (gnus-thread-header h1) (gnus-thread-header h2)))
3407 (defsubst gnus-article-sort-by-score (h1 h2)
3408 "Sort articles by root article score.
3409 Unscored articles will be counted as having a score of zero."
3410 (> (or (cdr (assq (mail-header-number h1)
3411 gnus-newsgroup-scored))
3412 gnus-summary-default-score 0)
3413 (or (cdr (assq (mail-header-number h2)
3414 gnus-newsgroup-scored))
3415 gnus-summary-default-score 0)))
3417 (defun gnus-thread-sort-by-score (h1 h2)
3418 "Sort threads by root article score."
3419 (gnus-article-sort-by-score
3420 (gnus-thread-header h1) (gnus-thread-header h2)))
3422 (defun gnus-thread-sort-by-total-score (h1 h2)
3423 "Sort threads by the sum of all scores in the thread.
3424 Unscored articles will be counted as having a score of zero."
3425 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3427 (defun gnus-thread-total-score (thread)
3428 ;; This function find the total score of THREAD.
3429 (cond ((null thread)
3432 (if (stringp (car thread))
3433 (apply gnus-thread-score-function 0
3434 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3435 (gnus-thread-total-score-1 thread)))
3437 (gnus-thread-total-score-1 (list thread)))))
3439 (defun gnus-thread-total-score-1 (root)
3440 ;; This function find the total score of the thread below ROOT.
3441 (setq root (car root))
3442 (apply gnus-thread-score-function
3444 (mapcar 'gnus-thread-total-score
3445 (cdr (gnus-gethash (mail-header-id root)
3446 gnus-newsgroup-dependencies)))
3447 (when (> (mail-header-number root) 0)
3448 (list (or (cdr (assq (mail-header-number root)
3449 gnus-newsgroup-scored))
3450 gnus-summary-default-score 0))))
3451 (list gnus-summary-default-score)
3454 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3455 (defvar gnus-tmp-prev-subject nil)
3456 (defvar gnus-tmp-false-parent nil)
3457 (defvar gnus-tmp-root-expunged nil)
3458 (defvar gnus-tmp-dummy-line nil)
3460 (defun gnus-summary-prepare-threads (threads)
3461 "Prepare summary buffer from THREADS and indentation LEVEL.
3462 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3463 or a straight list of headers."
3464 (gnus-message 7 "Generating summary...")
3466 (setq gnus-newsgroup-threads threads)
3469 (let ((gnus-tmp-level 0)
3470 (default-score (or gnus-summary-default-score 0))
3471 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3472 thread number subject stack state gnus-tmp-gathered beg-match
3473 new-roots gnus-tmp-new-adopts thread-end
3474 gnus-tmp-header gnus-tmp-unread
3475 gnus-tmp-replied gnus-tmp-subject-or-nil
3476 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3477 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3478 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3480 (setq gnus-tmp-prev-subject nil)
3482 (if (vectorp (car threads))
3483 ;; If this is a straight (sic) list of headers, then a
3484 ;; threaded summary display isn't required, so we just create
3485 ;; an unthreaded one.
3486 (gnus-summary-prepare-unthreaded threads)
3488 ;; Do the threaded display.
3490 (while (or threads stack gnus-tmp-new-adopts new-roots)
3492 (if (and (= gnus-tmp-level 0)
3493 (not (setq gnus-tmp-dummy-line nil))
3496 (not gnus-tmp-false-parent)
3497 (or gnus-tmp-new-adopts new-roots))
3498 (if gnus-tmp-new-adopts
3499 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3500 thread (list (car gnus-tmp-new-adopts))
3501 gnus-tmp-header (caar thread)
3502 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3504 (setq thread (list (car new-roots))
3505 gnus-tmp-header (caar thread)
3506 new-roots (cdr new-roots))))
3509 ;; If there are some threads, we do them before the
3510 ;; threads on the stack.
3511 (setq thread threads
3512 gnus-tmp-header (caar thread))
3513 ;; There were no current threads, so we pop something off
3515 (setq state (car stack)
3516 gnus-tmp-level (car state)
3519 gnus-tmp-header (caar thread))))
3521 (setq gnus-tmp-false-parent nil)
3522 (setq gnus-tmp-root-expunged nil)
3523 (setq thread-end nil)
3525 (if (stringp gnus-tmp-header)
3526 ;; The header is a dummy root.
3528 ((eq gnus-summary-make-false-root 'adopt)
3529 ;; We let the first article adopt the rest.
3530 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3532 (setq gnus-tmp-gathered
3534 (lambda (h) (mail-header-number (car h)))
3537 (setq thread (cons (list (caar thread)
3540 (setq gnus-tmp-level -1
3541 gnus-tmp-false-parent t))
3542 ((eq gnus-summary-make-false-root 'empty)
3543 ;; We print adopted articles with empty subject fields.
3544 (setq gnus-tmp-gathered
3546 (lambda (h) (mail-header-number (car h)))
3549 (setq gnus-tmp-level -1))
3550 ((eq gnus-summary-make-false-root 'dummy)
3551 ;; We remember that we probably want to output a dummy
3553 (setq gnus-tmp-dummy-line gnus-tmp-header)
3554 (setq gnus-tmp-prev-subject gnus-tmp-header))
3556 ;; We do not make a root for the gathered
3557 ;; sub-threads at all.
3558 (setq gnus-tmp-level -1)))
3560 (setq number (mail-header-number gnus-tmp-header)
3561 subject (mail-header-subject gnus-tmp-header))
3564 ;; If the thread has changed subject, we might want to make
3565 ;; this subthread into a root.
3566 ((and (null gnus-thread-ignore-subject)
3567 (not (zerop gnus-tmp-level))
3568 gnus-tmp-prev-subject
3570 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3571 (setq new-roots (nconc new-roots (list (car thread)))
3573 gnus-tmp-header nil))
3574 ;; If the article lies outside the current limit,
3575 ;; then we do not display it.
3576 ((not (memq number gnus-newsgroup-limit))
3577 (setq gnus-tmp-gathered
3579 (lambda (h) (mail-header-number (car h)))
3582 (setq gnus-tmp-new-adopts (if (cdar thread)
3583 (append gnus-tmp-new-adopts
3585 gnus-tmp-new-adopts)
3587 gnus-tmp-header nil)
3588 (when (zerop gnus-tmp-level)
3589 (setq gnus-tmp-root-expunged t)))
3590 ;; Perhaps this article is to be marked as read?
3591 ((and gnus-summary-mark-below
3592 (< (or (cdr (assq number gnus-newsgroup-scored))
3594 gnus-summary-mark-below)
3595 ;; Don't touch sparse articles.
3596 (not (gnus-summary-article-sparse-p number))
3597 (not (gnus-summary-article-ancient-p number)))
3598 (setq gnus-newsgroup-unreads
3599 (delq number gnus-newsgroup-unreads))
3600 (if gnus-newsgroup-auto-expire
3601 (push number gnus-newsgroup-expirable)
3602 (push (cons number gnus-low-score-mark)
3603 gnus-newsgroup-reads))))
3605 (when gnus-tmp-header
3606 ;; We may have an old dummy line to output before this
3608 (when gnus-tmp-dummy-line
3609 (gnus-summary-insert-dummy-line
3610 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3611 (setq gnus-tmp-dummy-line nil))
3613 ;; Compute the mark.
3614 (setq gnus-tmp-unread (gnus-article-mark number))
3616 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3617 gnus-tmp-header gnus-tmp-level)
3618 gnus-newsgroup-data)
3620 ;; Actually insert the line.
3622 gnus-tmp-subject-or-nil
3624 ((and gnus-thread-ignore-subject
3625 gnus-tmp-prev-subject
3626 (not (inline (gnus-subject-equal
3627 gnus-tmp-prev-subject subject))))
3629 ((zerop gnus-tmp-level)
3630 (if (and (eq gnus-summary-make-false-root 'empty)
3631 (memq number gnus-tmp-gathered)
3632 gnus-tmp-prev-subject
3633 (inline (gnus-subject-equal
3634 gnus-tmp-prev-subject subject)))
3635 gnus-summary-same-subject
3637 (t gnus-summary-same-subject)))
3638 (if (and (eq gnus-summary-make-false-root 'adopt)
3639 (= gnus-tmp-level 1)
3640 (memq number gnus-tmp-gathered))
3641 (setq gnus-tmp-opening-bracket ?\<
3642 gnus-tmp-closing-bracket ?\>)
3643 (setq gnus-tmp-opening-bracket ?\[
3644 gnus-tmp-closing-bracket ?\]))
3646 gnus-tmp-indentation
3647 (aref gnus-thread-indent-array gnus-tmp-level)
3648 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3649 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3650 gnus-summary-default-score 0)
3652 (if (or (null gnus-summary-default-score)
3653 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3654 gnus-summary-zcore-fuzz))
3656 (if (< gnus-tmp-score gnus-summary-default-score)
3657 gnus-score-below-mark gnus-score-over-mark))
3659 (cond ((memq number gnus-newsgroup-processable)
3661 ((memq number gnus-newsgroup-cached)
3663 ((memq number gnus-newsgroup-replied)
3665 ((memq number gnus-newsgroup-saved)
3667 (t gnus-unread-mark))
3668 gnus-tmp-from (mail-header-from gnus-tmp-header)
3671 ((string-match "<[^>]+> *$" gnus-tmp-from)
3672 (setq beg-match (match-beginning 0))
3673 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3674 (substring gnus-tmp-from (1+ (match-beginning 0))
3675 (1- (match-end 0))))
3676 (substring gnus-tmp-from 0 beg-match)))
3677 ((string-match "(.+)" gnus-tmp-from)
3678 (substring gnus-tmp-from
3679 (1+ (match-beginning 0)) (1- (match-end 0))))
3681 (when (string= gnus-tmp-name "")
3682 (setq gnus-tmp-name gnus-tmp-from))
3683 (unless (numberp gnus-tmp-lines)
3684 (setq gnus-tmp-lines 0))
3685 (gnus-put-text-property
3687 (progn (eval gnus-summary-line-format-spec) (point))
3688 'gnus-number number)
3691 (run-hooks 'gnus-summary-update-hook)
3694 (setq gnus-tmp-prev-subject subject)))
3696 (when (nth 1 thread)
3697 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3698 (incf gnus-tmp-level)
3699 (setq threads (if thread-end nil (cdar thread)))
3701 (setq gnus-tmp-level 0)))))
3702 (gnus-message 7 "Generating summary...done"))
3704 (defun gnus-summary-prepare-unthreaded (headers)
3705 "Generate an unthreaded summary buffer based on HEADERS."
3706 (let (header number mark)
3711 ;; We may have to root out some bad articles...
3712 (when (memq (setq number (mail-header-number
3713 (setq header (pop headers))))
3714 gnus-newsgroup-limit)
3715 ;; Mark article as read when it has a low score.
3716 (when (and gnus-summary-mark-below
3717 (< (or (cdr (assq number gnus-newsgroup-scored))
3718 gnus-summary-default-score 0)
3719 gnus-summary-mark-below)
3720 (not (gnus-summary-article-ancient-p number)))
3721 (setq gnus-newsgroup-unreads
3722 (delq number gnus-newsgroup-unreads))
3723 (if gnus-newsgroup-auto-expire
3724 (push number gnus-newsgroup-expirable)
3725 (push (cons number gnus-low-score-mark)
3726 gnus-newsgroup-reads)))
3728 (setq mark (gnus-article-mark number))
3729 (push (gnus-data-make number mark (1+ (point)) header 0)
3730 gnus-newsgroup-data)
3731 (gnus-summary-insert-line
3733 mark (memq number gnus-newsgroup-replied)
3734 (memq number gnus-newsgroup-expirable)
3735 (mail-header-subject header) nil
3736 (cdr (assq number gnus-newsgroup-scored))
3737 (memq number gnus-newsgroup-processable))))))
3739 (defun gnus-select-newsgroup (group &optional read-all)
3740 "Select newsgroup GROUP.
3741 If READ-ALL is non-nil, all articles in the group are selected."
3742 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3743 ;;!!! Dirty hack; should be removed.
3744 (gnus-summary-ignore-duplicates
3745 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
3747 gnus-summary-ignore-duplicates))
3748 (info (nth 2 entry))
3749 articles fetched-articles cached)
3751 (unless (gnus-check-server
3752 (setq gnus-current-select-method
3753 (gnus-find-method-for-group group)))
3754 (error "Couldn't open server"))
3756 (or (and entry (not (eq (car entry) t))) ; Either it's active...
3757 (gnus-activate-group group) ; Or we can activate it...
3758 (progn ; Or we bug out.
3759 (when (equal major-mode 'gnus-summary-mode)
3760 (kill-buffer (current-buffer)))
3761 (error "Couldn't request group %s: %s"
3762 group (gnus-status-message group))))
3764 (unless (gnus-request-group group t)
3765 (when (equal major-mode 'gnus-summary-mode)
3766 (kill-buffer (current-buffer)))
3767 (error "Couldn't request group %s: %s"
3768 group (gnus-status-message group)))
3770 (setq gnus-newsgroup-name group)
3771 (setq gnus-newsgroup-unselected nil)
3772 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
3774 ;; Adjust and set lists of article marks.
3776 (gnus-adjust-marked-articles info))
3778 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3779 (when (gnus-virtual-group-p group)
3780 (setq cached gnus-newsgroup-cached))
3782 (setq gnus-newsgroup-unreads
3783 (gnus-set-difference
3784 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
3785 gnus-newsgroup-dormant))
3787 (setq gnus-newsgroup-processable nil)
3789 (gnus-update-read-articles group gnus-newsgroup-unreads)
3790 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
3791 (gnus-group-update-group group))
3793 (setq articles (gnus-articles-to-read group read-all))
3797 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
3799 ((eq articles 0) nil)
3801 ;; Init the dependencies hash table.
3802 (setq gnus-newsgroup-dependencies
3803 (gnus-make-hashtable (length articles)))
3804 ;; Retrieve the headers and read them in.
3805 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
3806 (setq gnus-newsgroup-headers
3808 (setq gnus-headers-retrieved-by
3809 (gnus-retrieve-headers
3810 articles gnus-newsgroup-name
3811 ;; We might want to fetch old headers, but
3812 ;; not if there is only 1 article.
3813 (and gnus-fetch-old-headers
3815 (not (eq gnus-fetch-old-headers 'some))
3816 (not (numberp gnus-fetch-old-headers)))
3817 (> (length articles) 1))))))
3818 (gnus-get-newsgroup-headers-xover
3819 articles nil nil gnus-newsgroup-name t)
3820 (gnus-get-newsgroup-headers)))
3821 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
3823 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3825 (setq gnus-newsgroup-cached cached))
3827 ;; Suppress duplicates?
3828 (when gnus-suppress-duplicates
3829 (gnus-dup-suppress-articles))
3831 ;; Set the initial limit.
3832 (setq gnus-newsgroup-limit (copy-sequence articles))
3833 ;; Remove canceled articles from the list of unread articles.
3834 (setq gnus-newsgroup-unreads
3835 (gnus-set-sorted-intersection
3836 gnus-newsgroup-unreads
3837 (setq fetched-articles
3838 (mapcar (lambda (headers) (mail-header-number headers))
3839 gnus-newsgroup-headers))))
3840 ;; Removed marked articles that do not exist.
3841 (gnus-update-missing-marks
3842 (gnus-sorted-complement fetched-articles articles))
3843 ;; Let the Gnus agent mark articles as read.
3845 (gnus-agent-get-undownloaded-list))
3846 ;; We might want to build some more threads first.
3847 (when (and gnus-fetch-old-headers
3848 (eq gnus-headers-retrieved-by 'nov))
3849 (if (eq gnus-fetch-old-headers 'invisible)
3850 (gnus-build-all-threads)
3851 (gnus-build-old-threads)))
3852 ;; Check whether auto-expire is to be done in this group.
3853 (setq gnus-newsgroup-auto-expire
3854 (gnus-group-auto-expirable-p group))
3855 ;; Set up the article buffer now, if necessary.
3856 (unless gnus-single-article-buffer
3857 (gnus-article-setup-buffer))
3858 ;; First and last article in this newsgroup.
3859 (when gnus-newsgroup-headers
3860 (setq gnus-newsgroup-begin
3861 (mail-header-number (car gnus-newsgroup-headers))
3864 (gnus-last-element gnus-newsgroup-headers))))
3865 ;; GROUP is successfully selected.
3866 (or gnus-newsgroup-headers t)))))
3868 (defun gnus-articles-to-read (group &optional read-all)
3869 ;; Find out what articles the user wants to read.
3871 ;; Select all articles if `read-all' is non-nil, or if there
3872 ;; are no unread articles.
3874 (and (zerop (length gnus-newsgroup-marked))
3875 (zerop (length gnus-newsgroup-unreads)))
3876 (eq (gnus-group-find-parameter group 'display)
3878 (gnus-uncompress-range (gnus-active group))
3879 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
3880 (copy-sequence gnus-newsgroup-unreads))
3882 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
3883 (scored (length scored-list))
3884 (number (length articles))
3885 (marked (+ (length gnus-newsgroup-marked)
3886 (length gnus-newsgroup-dormant)))
3894 ((and (or (<= scored marked) (= scored number))
3895 (numberp gnus-large-newsgroup)
3896 (> number gnus-large-newsgroup))
3900 "How many articles from %s (default %d): "
3901 (gnus-limit-string gnus-newsgroup-name 35)
3903 (if (string-match "^[ \t]*$" input) number input)))
3904 ((and (> scored marked) (< scored number)
3905 (> (- scored number) 20))
3908 (format "%s %s (%d scored, %d total): "
3909 "How many articles from"
3910 group scored number))))
3911 (if (string-match "^[ \t]*$" input)
3915 (setq select (if (stringp select) (string-to-number select) select))
3916 (if (or (null select) (zerop select))
3918 (if (and (not (zerop scored)) (<= (abs select) scored))
3920 (setq articles (sort scored-list '<))
3921 (setq number (length articles)))
3922 (setq articles (copy-sequence articles)))
3924 (when (< (abs select) number)
3926 ;; Select the N oldest articles.
3927 (setcdr (nthcdr (1- (abs select)) articles) nil)
3928 ;; Select the N most recent articles.
3929 (setq articles (nthcdr (- number select) articles))))
3930 (setq gnus-newsgroup-unselected
3931 (gnus-sorted-intersection
3932 gnus-newsgroup-unreads
3933 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
3936 (defun gnus-killed-articles (killed articles)
3939 (when (inline (gnus-member-of-range (car articles) killed))
3940 (push (car articles) out))
3941 (setq articles (cdr articles)))
3944 (defun gnus-uncompress-marks (marks)
3945 "Uncompress the mark ranges in MARKS."
3946 (let ((uncompressed '(score bookmark))
3949 (if (memq (caar marks) uncompressed)
3950 (push (car marks) out)
3951 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
3952 (setq marks (cdr marks)))
3955 (defun gnus-adjust-marked-articles (info)
3956 "Set all article lists and remove all marks that are no longer legal."
3957 (let* ((marked-lists (gnus-info-marks info))
3958 (active (gnus-active (gnus-info-group info)))
3961 (types gnus-article-mark-lists)
3962 (uncompressed '(score bookmark killed))
3963 marks var articles article mark)
3966 (setq marks (pop marked-lists))
3967 (set (setq var (intern (format "gnus-newsgroup-%s"
3968 (car (rassq (setq mark (car marks))
3970 (if (memq (car marks) uncompressed) (cdr marks)
3971 (gnus-uncompress-range (cdr marks))))
3973 (setq articles (symbol-value var))
3975 ;; All articles have to be subsets of the active articles.
3977 ;; Adjust "simple" lists.
3978 ((memq mark '(tick dormant expire reply save))
3980 (when (or (< (setq article (pop articles)) min) (> article max))
3981 (set var (delq article (symbol-value var))))))
3983 ((memq mark uncompressed)
3984 (when (not (listp (cdr (symbol-value var))))
3985 (set var (list (symbol-value var))))
3986 (when (not (listp (cdr articles)))
3987 (setq articles (list articles)))
3989 (when (or (not (consp (setq article (pop articles))))
3990 (< (car article) min)
3991 (> (car article) max))
3992 (set var (delq article (symbol-value var))))))))))
3994 (defun gnus-update-missing-marks (missing)
3995 "Go through the list of MISSING articles and remove them from the mark lists."
3997 (let ((types gnus-article-mark-lists)
3999 ;; Go through all types.
4001 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4002 (when (symbol-value var)
4003 ;; This list has articles. So we delete all missing articles
4007 (set var (delq (pop m) (symbol-value var)))))))))
4009 (defun gnus-update-marks ()
4010 "Enter the various lists of marked articles into the newsgroup info list."
4011 (let ((types gnus-article-mark-lists)
4012 (info (gnus-get-info gnus-newsgroup-name))
4013 (uncompressed '(score bookmark killed))
4014 type list newmarked symbol)
4016 ;; Add all marks lists that are non-nil to the list of marks lists.
4017 (while (setq type (pop types))
4018 (when (setq list (symbol-value
4020 (intern (format "gnus-newsgroup-%s"
4023 ;; Get rid of the entries of the articles that have the
4025 (when (and (eq (cdr type) 'score)
4029 (prev (cons nil list))
4032 (if (or (not (consp (car arts)))
4033 (= (cdar arts) gnus-summary-default-score))
4034 (setcdr prev (cdr arts))
4036 (setq arts (cdr arts)))
4037 (setq list (cdr all))))
4039 (push (cons (cdr type)
4040 (if (memq (cdr type) uncompressed) list
4041 (gnus-compress-sequence
4042 (set symbol (sort list '<)) t)))
4045 ;; Enter these new marks into the info of the group.
4047 (setcar (nthcdr 3 info) newmarked)
4048 ;; Add the marks lists to the end of the info.
4050 (setcdr (nthcdr 2 info) (list newmarked))))
4052 ;; Cut off the end of the info if there's nothing else there.
4056 (when (nthcdr (decf i) info)
4057 (setcdr (nthcdr i info) nil)))))))
4059 (defun gnus-set-mode-line (where)
4060 "This function sets the mode line of the article or summary buffers.
4061 If WHERE is `summary', the summary mode line format will be used."
4062 ;; Is this mode line one we keep updated?
4063 (when (memq where gnus-updated-mode-lines)
4066 ;; We evaluate this in the summary buffer since these
4067 ;; variables are buffer-local to that buffer.
4068 (set-buffer gnus-summary-buffer)
4069 ;; We bind all these variables that are used in the `eval' form
4071 (let* ((mformat (symbol-value
4073 (format "gnus-%s-mode-line-format-spec" where))))
4074 (gnus-tmp-group-name gnus-newsgroup-name)
4075 (gnus-tmp-article-number (or gnus-current-article 0))
4076 (gnus-tmp-unread gnus-newsgroup-unreads)
4077 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4078 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4079 (gnus-tmp-unread-and-unselected
4080 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4081 (zerop gnus-tmp-unselected))
4083 ((zerop gnus-tmp-unselected)
4084 (format "{%d more}" gnus-tmp-unread-and-unticked))
4085 (t (format "{%d(+%d) more}"
4086 gnus-tmp-unread-and-unticked
4087 gnus-tmp-unselected))))
4089 (if (and gnus-current-headers
4090 (vectorp gnus-current-headers))
4091 (gnus-mode-string-quote
4092 (mail-header-subject gnus-current-headers))
4094 bufname-length max-len
4095 gnus-tmp-header);; passed as argument to any user-format-funcs
4096 (setq mode-string (eval mformat))
4097 (setq bufname-length (if (string-match "%b" mode-string)
4100 (if (eq where 'summary)
4102 (get-buffer gnus-article-buffer))))
4105 (setq max-len (max 4 (if gnus-mode-non-string-length
4107 gnus-mode-non-string-length
4109 (length mode-string))))
4110 ;; We might have to chop a bit of the string off...
4111 (when (> (length mode-string) max-len)
4113 (concat (gnus-truncate-string mode-string (- max-len 3))
4115 ;; Pad the mode string a bit.
4116 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4117 ;; Update the mode line.
4118 (setq mode-line-buffer-identification
4119 (gnus-mode-line-buffer-identification (list mode-string)))
4120 (set-buffer-modified-p t))))
4122 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4123 "Go through the HEADERS list and add all Xrefs to a hash table.
4124 The resulting hash table is returned, or nil if no Xrefs were found."
4125 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4126 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4127 (xref-hashtb (gnus-make-hashtable))
4128 start group entry number xrefs header)
4130 (setq header (pop headers))
4131 (when (and (setq xrefs (mail-header-xref header))
4132 (not (memq (setq number (mail-header-number header))
4135 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4136 (setq start (match-end 0))
4137 (setq group (if prefix
4138 (concat prefix (substring xrefs (match-beginning 1)
4140 (substring xrefs (match-beginning 1) (match-end 1))))
4142 (string-to-int (substring xrefs (match-beginning 2)
4144 (if (setq entry (gnus-gethash group xref-hashtb))
4145 (setcdr entry (cons number (cdr entry)))
4146 (gnus-sethash group (cons number nil) xref-hashtb)))))
4147 (and start xref-hashtb)))
4149 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4150 "Look through all the headers and mark the Xrefs as read."
4151 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4152 name entry info xref-hashtb idlist method nth4)
4154 (set-buffer gnus-group-buffer)
4155 (when (setq xref-hashtb
4156 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4159 (unless (string= from-newsgroup (setq name (symbol-name group)))
4160 (setq idlist (symbol-value group))
4161 ;; Dead groups are not updated.
4163 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4165 (when (stringp (setq nth4 (gnus-info-method info)))
4166 (setq nth4 (gnus-server-to-method nth4))))
4167 ;; Only do the xrefs if the group has the same
4168 ;; select method as the group we have just read.
4169 (or (gnus-methods-equal-p
4170 nth4 (gnus-find-method-for-group from-newsgroup))
4172 (equal nth4 (setq method (gnus-find-method-for-group
4174 (and (equal (car nth4) (car method))
4175 (equal (nth 1 nth4) (nth 1 method))))
4176 gnus-use-cross-reference
4177 (or (not (eq gnus-use-cross-reference t))
4179 ;; Only do cross-references on subscribed
4180 ;; groups, if that is what is wanted.
4181 (<= (gnus-info-level info) gnus-level-subscribed))
4182 (gnus-group-make-articles-read name idlist))))
4185 (defun gnus-compute-read-articles (group articles)
4186 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4187 (info (nth 2 entry))
4188 (active (gnus-active group))
4191 ;; First peel off all illegal article numbers.
4193 (let ((ids articles)
4195 (while (setq id (pop ids))
4196 (when (and first (> id (cdr active)))
4197 ;; We'll end up in this situation in one particular
4198 ;; obscure situation. If you re-scan a group and get
4199 ;; a new article that is cross-posted to a different
4200 ;; group that has not been re-scanned, you might get
4201 ;; crossposted article that has a higher number than
4202 ;; Gnus believes possible. So we re-activate this
4203 ;; group as well. This might mean doing the
4204 ;; crossposting thingy will *increase* the number
4205 ;; of articles in some groups. Tsk, tsk.
4206 (setq active (or (gnus-activate-group group) active)))
4207 (when (or (> id (cdr active))
4208 (< id (car active)))
4209 (setq articles (delq id articles))))))
4210 ;; If the read list is nil, we init it.
4212 (null (gnus-info-read info))
4214 (setq ninfo (cons 1 (1- (car active))))
4215 (setq ninfo (gnus-info-read info)))
4216 ;; Then we add the read articles to the range.
4218 ninfo (setq articles (sort articles '<))))))
4220 (defun gnus-group-make-articles-read (group articles)
4221 "Update the info of GROUP to say that ARTICLES are read."
4223 (entry (gnus-gethash group gnus-newsrc-hashtb))
4224 (info (nth 2 entry))
4225 (active (gnus-active group))
4228 (setq range (gnus-compute-read-articles group articles))
4230 (set-buffer gnus-group-buffer)
4233 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4234 (gnus-info-set-read ',info ',(gnus-info-read info))
4235 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4236 (gnus-group-update-group ,group t))))
4237 ;; Add the read articles to the range.
4238 (gnus-info-set-read info range)
4239 ;; Then we have to re-compute how many unread
4240 ;; articles there are in this group.
4244 (setq num (- (1+ (cdr active)) (car active))))
4245 ((not (listp (cdr range)))
4246 (setq num (- (cdr active) (- (1+ (cdr range))
4250 (if (numberp (car range))
4252 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4253 (setq range (cdr range)))
4254 (setq num (- (cdr active) num))))
4255 ;; Update the number of unread articles.
4257 ;; Update the group buffer.
4258 (gnus-group-update-group group t)))))
4260 (defun gnus-methods-equal-p (m1 m2)
4261 (let ((m1 (or m1 gnus-select-method))
4262 (m2 (or m2 gnus-select-method)))
4264 (and (eq (car m1) (car m2))
4265 (or (not (memq 'address (assoc (symbol-name (car m1))
4266 gnus-valid-select-methods)))
4267 (equal (nth 1 m1) (nth 1 m2)))))))
4269 (defvar gnus-newsgroup-none-id 0)
4271 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4272 (let ((cur nntp-server-buffer)
4275 (save-excursion (set-buffer gnus-summary-buffer)
4276 gnus-newsgroup-dependencies)))
4277 headers id id-dep ref-dep end ref)
4279 (set-buffer nntp-server-buffer)
4280 ;; Translate all TAB characters into SPACE characters.
4281 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4282 (run-hooks 'gnus-parse-headers-hook)
4283 (let ((case-fold-search t)
4284 in-reply-to header p lines)
4285 (goto-char (point-min))
4286 ;; Search to the beginning of the next header. Error messages
4287 ;; do not begin with 2 or 3.
4288 (while (re-search-forward "^[23][0-9]+ " nil t)
4291 ;; This implementation of this function, with nine
4292 ;; search-forwards instead of the one re-search-forward and
4293 ;; a case (which basically was the old function) is actually
4294 ;; about twice as fast, even though it looks messier. You
4295 ;; can't have everything, I guess. Speed and elegance
4296 ;; doesn't always go hand in hand.
4305 (narrow-to-region (point)
4306 (or (and (search-forward "\n.\n" nil t)
4312 (if (search-forward "\nsubject: " nil t)
4313 ;; 1997/5/4 by MORIOKA Tomohiko <morioka@jaist.ac.jp>
4315 gnus-unstructured-field-decoder (nnheader-header-value))
4320 (if (search-forward "\nfrom: " nil t)
4321 ;; 1997/5/4 by MORIOKA Tomohiko <morioka@jaist.ac.jp>
4323 gnus-structured-field-decoder (nnheader-header-value))
4328 (if (search-forward "\ndate: " nil t)
4329 (nnheader-header-value) ""))
4333 (setq id (if (search-forward "\nmessage-id:" nil t)
4335 (1- (or (search-forward "<" nil t) (point)))
4336 (or (search-forward ">" nil t) (point)))
4337 ;; If there was no message-id, we just fake one
4338 ;; to make subsequent routines simpler.
4339 (nnheader-generate-fake-message-id))))
4343 (if (search-forward "\nreferences: " nil t)
4347 (nnheader-header-value)
4352 (search-backward ">" end t)
4355 (search-backward "<" end t)
4357 ;; Get the references from the in-reply-to header if there
4358 ;; were no references and the in-reply-to header looks
4360 (if (and (search-forward "\nin-reply-to: " nil t)
4361 (setq in-reply-to (nnheader-header-value))
4362 (string-match "<[^>]+>" in-reply-to))
4363 (setq ref (substring in-reply-to (match-beginning 0)
4371 (if (search-forward "\nlines: " nil t)
4372 (if (numberp (setq lines (ignore-errors (read cur))))
4378 (and (search-forward "\nxref: " nil t)
4379 (nnheader-header-value)))))
4380 (when (equal id ref)
4383 (when gnus-alter-header-function
4384 (funcall gnus-alter-header-function header)
4385 (setq id (mail-header-id header)
4386 ref (gnus-parent-id (mail-header-references header))))
4388 ;; We do the threading while we read the headers. The
4389 ;; message-id and the last reference are both entered into
4390 ;; the same hash table. Some tippy-toeing around has to be
4391 ;; done in case an article has arrived before the article
4392 ;; which it refers to.
4393 (if (boundp (setq id-dep (intern id dependencies)))
4394 (if (and (car (symbol-value id-dep))
4396 ;; An article with this Message-ID has already been seen.
4397 (if gnus-summary-ignore-duplicates
4398 ;; We ignore this one, except we add
4399 ;; any additional Xrefs (in case the two articles
4400 ;; came from different servers).
4402 (mail-header-set-xref
4403 (car (symbol-value id-dep))
4404 (concat (or (mail-header-xref
4405 (car (symbol-value id-dep)))
4407 (or (mail-header-xref header) "")))
4409 ;; We rename the Message-ID.
4411 (setq id-dep (intern (setq id (nnmail-message-id))
4414 (mail-header-set-id header id))
4415 (setcar (symbol-value id-dep) header))
4416 (set id-dep (list header)))
4418 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
4419 (setcdr (symbol-value ref-dep)
4420 (nconc (cdr (symbol-value ref-dep))
4421 (list (symbol-value id-dep))))
4422 (set ref-dep (list nil (symbol-value id-dep))))
4423 (push header headers))
4424 (goto-char (point-max))
4426 (nreverse headers)))))
4428 ;; The following macros and functions were written by Felix Lee
4429 ;; <flee@cse.psu.edu>.
4431 (defmacro gnus-nov-read-integer ()
4433 (if (= (following-char) ?\t)
4435 (let ((num (ignore-errors (read buffer))))
4436 (if (numberp num) num 0)))
4438 (search-forward "\t" eol 'move))))
4440 (defmacro gnus-nov-skip-field ()
4441 '(search-forward "\t" eol 'move))
4443 (defmacro gnus-nov-field ()
4444 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
4446 ;; (defvar gnus-nov-none-counter 0)
4448 ;; This function has to be called with point after the article number
4449 ;; on the beginning of the line.
4450 (defun gnus-nov-parse-line (number dependencies &optional force-new)
4451 (let ((eol (gnus-point-at-eol))
4452 (buffer (current-buffer))
4453 header ref id id-dep ref-dep)
4455 ;; overview: [num subject from date id refs chars lines misc]
4458 (narrow-to-region (point) eol)
4466 gnus-unstructured-field-decoder (gnus-nov-field)) ; subject
4468 gnus-structured-field-decoder (gnus-nov-field)) ; from
4469 (gnus-nov-field) ; date
4470 (setq id (or (gnus-nov-field)
4471 (nnheader-generate-fake-message-id))) ; id
4473 (let ((beg (point)))
4474 (search-forward "\t" eol)
4475 (if (search-backward ">" beg t)
4479 (search-backward "<" beg t)))
4482 (gnus-nov-field)) ; refs
4483 (gnus-nov-read-integer) ; chars
4484 (gnus-nov-read-integer) ; lines
4485 (if (= (following-char) ?\n)
4487 (gnus-nov-field))))) ; misc
4491 (when gnus-alter-header-function
4492 (funcall gnus-alter-header-function header)
4493 (setq id (mail-header-id header)
4494 ref (gnus-parent-id (mail-header-references header))))
4496 ;; We build the thread tree.
4497 (when (equal id ref)
4498 ;; This article refers back to itself. Naughty, naughty.
4500 (if (boundp (setq id-dep (intern id dependencies)))
4501 (if (and (car (symbol-value id-dep))
4503 ;; An article with this Message-ID has already been seen.
4504 (if gnus-summary-ignore-duplicates
4505 ;; We ignore this one, except we add any additional
4506 ;; Xrefs (in case the two articles came from different
4509 (mail-header-set-xref
4510 (car (symbol-value id-dep))
4511 (concat (or (mail-header-xref
4512 (car (symbol-value id-dep)))
4514 (or (mail-header-xref header) "")))
4516 ;; We rename the Message-ID.
4518 (setq id-dep (intern (setq id (nnmail-message-id))
4521 (mail-header-set-id header id))
4522 (setcar (symbol-value id-dep) header))
4523 (set id-dep (list header)))
4525 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
4526 (setcdr (symbol-value ref-dep)
4527 (nconc (cdr (symbol-value ref-dep))
4528 (list (symbol-value id-dep))))
4529 (set ref-dep (list nil (symbol-value id-dep)))))
4532 ;; Goes through the xover lines and returns a list of vectors
4533 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4534 force-new dependencies
4535 group also-fetch-heads)
4536 "Parse the news overview data in the server buffer, and return a
4537 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4538 ;; Get the Xref when the users reads the articles since most/some
4539 ;; NNTP servers do not include Xrefs when using XOVER.
4540 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4541 (let ((cur nntp-server-buffer)
4542 (dependencies (or dependencies gnus-newsgroup-dependencies))
4543 number headers header)
4545 (set-buffer nntp-server-buffer)
4546 ;; Allow the user to mangle the headers before parsing them.
4547 (run-hooks 'gnus-parse-headers-hook)
4548 (goto-char (point-min))
4551 (while (and sequence (not (eobp)))
4552 (setq number (read cur))
4553 (while (and sequence
4554 (< (car sequence) number))
4555 (setq sequence (cdr sequence)))
4557 (eq number (car sequence))
4559 (setq sequence (cdr sequence))
4560 (setq header (inline
4561 (gnus-nov-parse-line
4562 number dependencies force-new))))
4563 (push header headers))
4566 (gnus-error 4 "Strange nov line (%d)"
4567 (count-lines (point-min) (point)))))
4569 ;; A common bug in inn is that if you have posted an article and
4570 ;; then retrieves the active file, it will answer correctly --
4571 ;; the new article is included. However, a NOV entry for the
4572 ;; article may not have been generated yet, so this may fail.
4573 ;; We work around this problem by retrieving the last few
4574 ;; headers using HEAD.
4575 (if (or (not also-fetch-heads)
4577 ;; We (probably) got all the headers.
4579 (let ((gnus-nov-is-evil t))
4582 (when (gnus-retrieve-headers sequence group)
4583 (gnus-get-newsgroup-headers))))))))
4585 (defun gnus-article-get-xrefs ()
4586 "Fill in the Xref value in `gnus-current-headers', if necessary.
4587 This is meant to be called in `gnus-article-internal-prepare-hook'."
4588 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4589 gnus-current-headers)))
4590 (or (not gnus-use-cross-reference)
4592 (and (mail-header-xref headers)
4593 (not (string= (mail-header-xref headers) "")))
4594 (let ((case-fold-search t)
4597 (nnheader-narrow-to-headers)
4598 (goto-char (point-min))
4599 (when (or (and (eq (downcase (following-char)) ?x)
4600 (looking-at "Xref:"))
4601 (search-forward "\nXref:" nil t))
4602 (goto-char (1+ (match-end 0)))
4603 (setq xref (buffer-substring (point)
4604 (progn (end-of-line) (point))))
4605 (mail-header-set-xref headers xref)))))))
4607 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4608 "Find article ID and insert the summary line for that article."
4609 (let ((header (if (and old-header use-old-header)
4610 old-header (gnus-read-header id)))
4611 (number (and (numberp id) id))
4614 ;; Rebuild the thread that this article is part of and go to the
4615 ;; article we have fetched.
4616 (when (and (not gnus-show-threads)
4618 (when (setq d (gnus-data-find (mail-header-number old-header)))
4619 (goto-char (gnus-data-pos d))
4622 (- (gnus-point-at-bol)
4624 (1+ (gnus-point-at-eol))
4625 (gnus-delete-line))))))
4627 (mail-header-set-number header (mail-header-number old-header)))
4628 (setq gnus-newsgroup-sparse
4629 (delq (setq number (mail-header-number header))
4630 gnus-newsgroup-sparse))
4631 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4632 (gnus-rebuild-thread (mail-header-id header))
4633 (gnus-summary-goto-subject number nil t))
4634 (when (and (numberp number)
4636 ;; We have to update the boundaries even if we can't fetch the
4637 ;; article if ID is a number -- so that the next `P' or `N'
4638 ;; command will fetch the previous (or next) article even
4639 ;; if the one we tried to fetch this time has been canceled.
4640 (when (> number gnus-newsgroup-end)
4641 (setq gnus-newsgroup-end number))
4642 (when (< number gnus-newsgroup-begin)
4643 (setq gnus-newsgroup-begin number))
4644 (setq gnus-newsgroup-unselected
4645 (delq number gnus-newsgroup-unselected)))
4646 ;; Report back a success?
4647 (and header (mail-header-number header))))
4649 ;;; Process/prefix in the summary buffer
4651 (defun gnus-summary-work-articles (n)
4652 "Return a list of articles to be worked upon. The prefix argument,
4653 the list of process marked articles, and the current article will be
4654 taken into consideration."
4657 ;; A numerical prefix has been given.
4658 (setq n (prefix-numeric-value n))
4659 (let ((backward (< n 0))
4660 (n (abs (prefix-numeric-value n)))
4665 (push (setq article (gnus-summary-article-number))
4668 (gnus-summary-find-prev nil article)
4669 (gnus-summary-find-next nil article)))
4671 (nreverse articles)))
4672 ((gnus-region-active-p)
4673 ;; Work on the region between point and mark.
4674 (let ((max (max (point) (mark)))
4677 (goto-char (min (point) (mark)))
4680 (push (setq article (gnus-summary-article-number)) articles)
4681 (gnus-summary-find-next nil article)
4683 (nreverse articles))))
4684 (gnus-newsgroup-processable
4685 ;; There are process-marked articles present.
4686 ;; Save current state.
4687 (gnus-summary-save-process-mark)
4689 (reverse gnus-newsgroup-processable))
4691 ;; Just return the current article.
4692 (list (gnus-summary-article-number)))))
4694 (defun gnus-summary-save-process-mark ()
4695 "Push the current set of process marked articles on the stack."
4697 (push (copy-sequence gnus-newsgroup-processable)
4698 gnus-newsgroup-process-stack))
4700 (defun gnus-summary-kill-process-mark ()
4701 "Push the current set of process marked articles on the stack and unmark."
4703 (gnus-summary-save-process-mark)
4704 (gnus-summary-unmark-all-processable))
4706 (defun gnus-summary-yank-process-mark ()
4707 "Pop the last process mark state off the stack and restore it."
4709 (unless gnus-newsgroup-process-stack
4710 (error "Empty mark stack"))
4711 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4713 (defun gnus-summary-process-mark-set (set)
4714 "Make SET into the current process marked articles."
4715 (gnus-summary-unmark-all-processable)
4717 (gnus-summary-set-process-mark (pop set))))
4719 ;;; Searching and stuff
4721 (defun gnus-summary-search-group (&optional backward use-level)
4722 "Search for next unread newsgroup.
4723 If optional argument BACKWARD is non-nil, search backward instead."
4725 (set-buffer gnus-group-buffer)
4726 (when (gnus-group-search-forward
4727 backward nil (if use-level (gnus-group-group-level) nil))
4728 (gnus-group-group-name))))
4730 (defun gnus-summary-best-group (&optional exclude-group)
4731 "Find the name of the best unread group.
4732 If EXCLUDE-GROUP, do not go to this group."
4734 (set-buffer gnus-group-buffer)
4736 (gnus-group-best-unread-group exclude-group))))
4738 (defun gnus-summary-find-next (&optional unread article backward)
4739 (if backward (gnus-summary-find-prev)
4740 (let* ((dummy (gnus-summary-article-intangible-p))
4741 (article (or article (gnus-summary-article-number)))
4742 (arts (gnus-data-find-list article))
4744 (when (and (not dummy)
4745 (or (not gnus-summary-check-current)
4747 (not (gnus-data-unread-p (car arts)))))
4748 (setq arts (cdr arts)))
4753 (when (gnus-data-unread-p (car arts))
4754 (setq result (car arts)
4756 (setq arts (cdr arts)))
4759 (goto-char (gnus-data-pos result))
4760 (gnus-data-number result)))))
4762 (defun gnus-summary-find-prev (&optional unread article)
4763 (let* ((eobp (eobp))
4764 (article (or article (gnus-summary-article-number)))
4765 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
4767 (when (and (not eobp)
4768 (or (not gnus-summary-check-current)
4770 (not (gnus-data-unread-p (car arts)))))
4771 (setq arts (cdr arts)))
4776 (when (gnus-data-unread-p (car arts))
4777 (setq result (car arts)
4779 (setq arts (cdr arts)))
4782 (goto-char (gnus-data-pos result))
4783 (gnus-data-number result))))
4785 (defun gnus-summary-find-subject (subject &optional unread backward article)
4786 (let* ((simp-subject (gnus-simplify-subject-fully subject))
4787 (article (or article (gnus-summary-article-number)))
4788 (articles (gnus-data-list backward))
4789 (arts (gnus-data-find-list article articles))
4791 (when (or (not gnus-summary-check-current)
4793 (not (gnus-data-unread-p (car arts))))
4794 (setq arts (cdr arts)))
4796 (and (or (not unread)
4797 (gnus-data-unread-p (car arts)))
4798 (vectorp (gnus-data-header (car arts)))
4800 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
4801 (setq result (car arts)
4803 (setq arts (cdr arts)))
4805 (goto-char (gnus-data-pos result))
4806 (gnus-data-number result))))
4808 (defun gnus-summary-search-forward (&optional unread subject backward)
4809 "Search forward for an article.
4810 If UNREAD, look for unread articles. If SUBJECT, look for
4811 articles with that subject. If BACKWARD, search backward instead."
4812 (cond (subject (gnus-summary-find-subject subject unread backward))
4813 (backward (gnus-summary-find-prev unread))
4814 (t (gnus-summary-find-next unread))))
4816 (defun gnus-recenter (&optional n)
4817 "Center point in window and redisplay frame.
4818 Also do horizontal recentering."
4820 (when (and gnus-auto-center-summary
4821 (not (eq gnus-auto-center-summary 'vertical)))
4822 (gnus-horizontal-recenter))
4825 (defun gnus-summary-recenter ()
4826 "Center point in the summary window.
4827 If `gnus-auto-center-summary' is nil, or the article buffer isn't
4828 displayed, no centering will be performed."
4829 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
4830 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
4831 (let* ((top (cond ((< (window-height) 4) 0)
4832 ((< (window-height) 7) 1)
4834 (height (1- (window-height)))
4835 (bottom (save-excursion (goto-char (point-max))
4836 (forward-line (- height))
4838 (window (get-buffer-window (current-buffer))))
4839 ;; The user has to want it.
4840 (when gnus-auto-center-summary
4841 (when (get-buffer-window gnus-article-buffer)
4842 ;; Only do recentering when the article buffer is displayed,
4843 ;; Set the window start to either `bottom', which is the biggest
4844 ;; possible valid number, or the second line from the top,
4845 ;; whichever is the least.
4847 window (min bottom (save-excursion
4848 (forward-line (- top)) (point)))))
4849 ;; Do horizontal recentering while we're at it.
4850 (when (and (get-buffer-window (current-buffer) t)
4851 (not (eq gnus-auto-center-summary 'vertical)))
4852 (let ((selected (selected-window)))
4853 (select-window (get-buffer-window (current-buffer) t))
4854 (gnus-summary-position-point)
4855 (gnus-horizontal-recenter)
4856 (select-window selected))))))
4858 (defun gnus-summary-jump-to-group (newsgroup)
4859 "Move point to NEWSGROUP in group mode buffer."
4860 ;; Keep update point of group mode buffer if visible.
4861 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
4862 (save-window-excursion
4863 ;; Take care of tree window mode.
4864 (when (get-buffer-window gnus-group-buffer)
4865 (pop-to-buffer gnus-group-buffer))
4866 (gnus-group-jump-to-group newsgroup))
4868 ;; Take care of tree window mode.
4869 (if (get-buffer-window gnus-group-buffer)
4870 (pop-to-buffer gnus-group-buffer)
4871 (set-buffer gnus-group-buffer))
4872 (gnus-group-jump-to-group newsgroup))))
4874 ;; This function returns a list of article numbers based on the
4875 ;; difference between the ranges of read articles in this group and
4876 ;; the range of active articles.
4877 (defun gnus-list-of-unread-articles (group)
4878 (let* ((read (gnus-info-read (gnus-get-info group)))
4879 (active (or (gnus-active group) (gnus-activate-group group)))
4882 ;; If none are read, then all are unread.
4884 (setq first (car active))
4885 ;; If the range of read articles is a single range, then the
4886 ;; first unread article is the article after the last read
4887 ;; article. Sounds logical, doesn't it?
4888 (if (not (listp (cdr read)))
4889 (setq first (1+ (cdr read)))
4890 ;; `read' is a list of ranges.
4891 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
4897 (while (< first nlast)
4899 (setq first (1+ first))))
4900 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
4901 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
4902 (setq read (cdr read)))))
4903 ;; And add the last unread articles.
4904 (while (<= first last)
4906 (setq first (1+ first)))
4907 ;; Return the list of unread articles.
4908 (delq 0 (nreverse unread))))
4910 (defun gnus-list-of-read-articles (group)
4911 "Return a list of unread, unticked and non-dormant articles."
4912 (let* ((info (gnus-get-info group))
4913 (marked (gnus-info-marks info))
4914 (active (gnus-active group)))
4916 (gnus-set-difference
4917 (gnus-sorted-complement
4918 (gnus-uncompress-range active)
4919 (gnus-list-of-unread-articles group))
4921 (gnus-uncompress-range (cdr (assq 'dormant marked)))
4922 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
4924 ;; Various summary commands
4926 (defun gnus-summary-select-article-buffer ()
4927 "Reconfigure windows to show article buffer."
4929 (if (not (gnus-buffer-live-p gnus-article-buffer))
4930 (error "There is no article buffer for this summary buffer")
4931 (gnus-configure-windows 'article)
4932 (select-window (get-buffer-window gnus-article-buffer))))
4934 (defun gnus-summary-universal-argument (arg)
4935 "Perform any operation on all articles that are process/prefixed."
4937 (let ((articles (gnus-summary-work-articles arg))
4944 (substitute-command-keys
4945 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
4948 (gnus-error 1 "Undefined key")
4951 (gnus-summary-goto-subject (setq article (pop articles)))
4952 (let (gnus-newsgroup-processable)
4953 (command-execute func))
4954 (gnus-summary-remove-process-mark article)))))
4955 (gnus-summary-position-point))
4957 (defun gnus-summary-toggle-truncation (&optional arg)
4958 "Toggle truncation of summary lines.
4959 With arg, turn line truncation on iff arg is positive."
4961 (setq truncate-lines
4962 (if (null arg) (not truncate-lines)
4963 (> (prefix-numeric-value arg) 0)))
4966 (defun gnus-summary-reselect-current-group (&optional all rescan)
4967 "Exit and then reselect the current newsgroup.
4968 The prefix argument ALL means to select all articles."
4970 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
4971 (error "Ephemeral groups can't be reselected"))
4972 (let ((current-subject (gnus-summary-article-number))
4973 (group gnus-newsgroup-name))
4974 (setq gnus-newsgroup-begin nil)
4976 ;; We have to adjust the point of group mode buffer because
4977 ;; point was moved to the next unread newsgroup by exiting.
4978 (gnus-summary-jump-to-group group)
4981 (gnus-group-get-new-news-this-group 1)))
4982 (gnus-group-read-group all t)
4983 (gnus-summary-goto-subject current-subject nil t)))
4985 (defun gnus-summary-rescan-group (&optional all)
4986 "Exit the newsgroup, ask for new articles, and select the newsgroup."
4988 (gnus-summary-reselect-current-group all t))
4990 (defun gnus-summary-update-info (&optional non-destructive)
4992 (let ((group gnus-newsgroup-name))
4993 (when gnus-newsgroup-kill-headers
4994 (setq gnus-newsgroup-killed
4995 (gnus-compress-sequence
4997 (gnus-set-sorted-intersection
4998 (gnus-uncompress-range gnus-newsgroup-killed)
4999 (setq gnus-newsgroup-unselected
5000 (sort gnus-newsgroup-unselected '<)))
5001 (setq gnus-newsgroup-unreads
5002 (sort gnus-newsgroup-unreads '<)))
5004 (unless (listp (cdr gnus-newsgroup-killed))
5005 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5006 (let ((headers gnus-newsgroup-headers))
5007 (when (and (not gnus-save-score)
5008 (not non-destructive))
5009 (setq gnus-newsgroup-scored nil))
5010 ;; Set the new ranges of read articles.
5012 (set-buffer gnus-group-buffer)
5013 (gnus-undo-force-boundary))
5014 (gnus-update-read-articles
5015 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5016 ;; Set the current article marks.
5018 ;; Do the cross-ref thing.
5019 (when gnus-use-cross-reference
5020 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5021 ;; Do not switch windows but change the buffer to work.
5022 (set-buffer gnus-group-buffer)
5023 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5024 (gnus-group-update-group group))))))
5026 (defun gnus-summary-save-newsrc (&optional force)
5027 "Save the current number of read/marked articles in the dribble buffer.
5028 The dribble buffer will then be saved.
5029 If FORCE (the prefix), also save the .newsrc file(s)."
5031 (gnus-summary-update-info t)
5033 (gnus-save-newsrc-file)
5034 (gnus-dribble-save)))
5036 (defun gnus-summary-exit (&optional temporary)
5037 "Exit reading current newsgroup, and then return to group selection mode.
5038 gnus-exit-group-hook is called with no arguments if that value is non-nil."
5040 (gnus-kill-save-kill-buffer)
5041 (let* ((group gnus-newsgroup-name)
5042 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5045 (buf (current-buffer)))
5046 (run-hooks 'gnus-summary-prepare-exit-hook)
5047 ;; If we have several article buffers, we kill them at exit.
5048 (unless gnus-single-article-buffer
5049 (gnus-kill-buffer gnus-original-article-buffer)
5050 (setq gnus-article-current nil))
5051 (when gnus-use-cache
5052 (gnus-cache-possibly-remove-articles)
5053 (gnus-cache-save-buffers))
5054 (gnus-async-prefetch-remove-group group)
5055 (when gnus-suppress-duplicates
5056 (gnus-dup-enter-articles))
5057 (when gnus-use-trees
5058 (gnus-tree-close group))
5059 ;; Make all changes in this group permanent.
5061 (run-hooks 'gnus-exit-group-hook)
5062 (gnus-summary-update-info)
5063 ;; Do adaptive scoring, and possibly save score files.
5064 (when gnus-newsgroup-adaptive
5065 (gnus-score-adaptive))
5066 (when gnus-use-scoring
5068 (gnus-close-group group)
5069 ;; Make sure where we were, and go to next newsgroup.
5070 (set-buffer gnus-group-buffer)
5072 (gnus-group-jump-to-group group))
5073 (run-hooks 'gnus-summary-exit-hook)
5074 (unless (or quit-config
5075 ;; If this group has disappeared from the summary
5076 ;; buffer, don't skip forwards.
5077 (not (string= group (gnus-group-group-name))))
5078 (gnus-group-next-unread-group 1))
5079 (setq group-point (point))
5082 ;; If we have several article buffers, we kill them at exit.
5083 (unless gnus-single-article-buffer
5084 (gnus-kill-buffer gnus-article-buffer)
5085 (gnus-kill-buffer gnus-original-article-buffer)
5086 (setq gnus-article-current nil))
5088 (if (not gnus-kill-summary-on-exit)
5089 (gnus-deaden-summary)
5090 ;; We set all buffer-local variables to nil. It is unclear why
5091 ;; this is needed, but if we don't, buffer-local variables are
5092 ;; not garbage-collected, it seems. This would the lead to en
5093 ;; ever-growing Emacs.
5094 (gnus-summary-clear-local-variables)
5095 (when (get-buffer gnus-article-buffer)
5096 (bury-buffer gnus-article-buffer))
5097 ;; We clear the global counterparts of the buffer-local
5098 ;; variables as well, just to be on the safe side.
5099 (set-buffer gnus-group-buffer)
5100 (gnus-summary-clear-local-variables)
5101 ;; Return to group mode buffer.
5102 (when (eq mode 'gnus-summary-mode)
5103 (gnus-kill-buffer buf)))
5104 (setq gnus-current-select-method gnus-select-method)
5105 (pop-to-buffer gnus-group-buffer)
5106 ;; Clear the current group name.
5107 (if (not quit-config)
5109 (goto-char group-point)
5110 (gnus-configure-windows 'group 'force))
5111 (gnus-handle-ephemeral-exit quit-config))
5113 (setq gnus-newsgroup-name nil)))))
5115 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5116 (defun gnus-summary-exit-no-update (&optional no-questions)
5117 "Quit reading current newsgroup without updating read article info."
5119 (let* ((group gnus-newsgroup-name)
5120 (quit-config (gnus-group-quit-config group)))
5121 (when (or no-questions
5123 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5124 ;; If we have several article buffers, we kill them at exit.
5125 (unless gnus-single-article-buffer
5126 (gnus-kill-buffer gnus-article-buffer)
5127 (gnus-kill-buffer gnus-original-article-buffer)
5128 (setq gnus-article-current nil))
5129 (if (not gnus-kill-summary-on-exit)
5130 (gnus-deaden-summary)
5131 (gnus-close-group group)
5132 (gnus-summary-clear-local-variables)
5133 (set-buffer gnus-group-buffer)
5134 (gnus-summary-clear-local-variables)
5135 (when (get-buffer gnus-summary-buffer)
5136 (kill-buffer gnus-summary-buffer)))
5137 (unless gnus-single-article-buffer
5138 (setq gnus-article-current nil))
5139 (when gnus-use-trees
5140 (gnus-tree-close group))
5141 (gnus-async-prefetch-remove-group group)
5142 (when (get-buffer gnus-article-buffer)
5143 (bury-buffer gnus-article-buffer))
5144 ;; Return to the group buffer.
5145 (gnus-configure-windows 'group 'force)
5146 ;; Clear the current group name.
5147 (setq gnus-newsgroup-name nil)
5148 (when (equal (gnus-group-group-name) group)
5149 (gnus-group-next-unread-group 1))
5151 (gnus-handle-ephemeral-exit quit-config)))))
5153 (defun gnus-handle-ephemeral-exit (quit-config)
5154 "Handle movement when leaving an ephemeral group. The state
5155 which existed when entering the ephemeral is reset."
5156 (if (not (buffer-name (car quit-config)))
5157 (gnus-configure-windows 'group 'force)
5158 (set-buffer (car quit-config))
5159 (cond ((eq major-mode 'gnus-summary-mode)
5160 (gnus-set-global-variables))
5161 ((eq major-mode 'gnus-article-mode)
5163 ;; The `gnus-summary-buffer' variable may point
5164 ;; to the old summary buffer when using a single
5166 (unless (gnus-buffer-live-p gnus-summary-buffer)
5167 (set-buffer gnus-group-buffer))
5168 (set-buffer gnus-summary-buffer)
5169 (gnus-set-global-variables))))
5170 (if (or (eq (cdr quit-config) 'article)
5171 (eq (cdr quit-config) 'pick))
5173 ;; The current article may be from the ephemeral group
5174 ;; thus it is best that we reload this article
5175 (gnus-summary-show-article)
5176 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5177 (gnus-configure-windows 'pick 'force)
5178 (gnus-configure-windows (cdr quit-config) 'force)))
5179 (gnus-configure-windows (cdr quit-config) 'force))
5180 (when (eq major-mode 'gnus-summary-mode)
5181 (gnus-summary-next-subject 1 nil t)
5182 (gnus-summary-recenter)
5183 (gnus-summary-position-point))))
5185 (defun gnus-summary-preview-mime-message (arg)
5186 "MIME decode and play this message."
5188 (let ((gnus-break-pages nil))
5189 (gnus-summary-select-article t t)
5191 (pop-to-buffer gnus-original-article-buffer t)
5192 (let (buffer-read-only)
5193 (if (text-property-any (point-min) (point-max) 'invisible t)
5194 (remove-text-properties (point-min) (point-max)
5195 gnus-hidden-properties)
5197 (mime-view-mode nil nil nil gnus-original-article-buffer
5198 gnus-article-buffer)
5201 (defun gnus-summary-scroll-down ()
5202 "Scroll down one line current article."
5204 (gnus-summary-scroll-up -1)
5209 (defvar gnus-dead-summary-mode-map nil)
5211 (unless gnus-dead-summary-mode-map
5212 (setq gnus-dead-summary-mode-map (make-keymap))
5213 (suppress-keymap gnus-dead-summary-mode-map)
5214 (substitute-key-definition
5215 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5216 (let ((keys '("\C-d" "\r" "\177" [delete])))
5218 (define-key gnus-dead-summary-mode-map
5219 (pop keys) 'gnus-summary-wake-up-the-dead))))
5221 (defvar gnus-dead-summary-mode nil
5222 "Minor mode for Gnus summary buffers.")
5224 (defun gnus-dead-summary-mode (&optional arg)
5225 "Minor mode for Gnus summary buffers."
5227 (when (eq major-mode 'gnus-summary-mode)
5228 (make-local-variable 'gnus-dead-summary-mode)
5229 (setq gnus-dead-summary-mode
5230 (if (null arg) (not gnus-dead-summary-mode)
5231 (> (prefix-numeric-value arg) 0)))
5232 (when gnus-dead-summary-mode
5233 (gnus-add-minor-mode
5234 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5236 (defun gnus-deaden-summary ()
5237 "Make the current summary buffer into a dead summary buffer."
5238 ;; Kill any previous dead summary buffer.
5239 (when (and gnus-dead-summary
5240 (buffer-name gnus-dead-summary))
5242 (set-buffer gnus-dead-summary)
5243 (when gnus-dead-summary-mode
5244 (kill-buffer (current-buffer)))))
5245 ;; Make this the current dead summary.
5246 (setq gnus-dead-summary (current-buffer))
5247 (gnus-dead-summary-mode 1)
5248 (let ((name (buffer-name)))
5249 (when (string-match "Summary" name)
5251 (concat (substring name 0 (match-beginning 0)) "Dead "
5252 (substring name (match-beginning 0)))
5255 (defun gnus-kill-or-deaden-summary (buffer)
5256 "Kill or deaden the summary BUFFER."
5257 (when (and (buffer-name buffer)
5258 (not gnus-single-article-buffer))
5261 (gnus-kill-buffer gnus-article-buffer)
5262 (gnus-kill-buffer gnus-original-article-buffer)))
5263 (cond (gnus-kill-summary-on-exit
5264 (when (and gnus-use-trees
5265 (and (get-buffer buffer)
5266 (buffer-name (get-buffer buffer))))
5268 (set-buffer (get-buffer buffer))
5269 (gnus-tree-close gnus-newsgroup-name)))
5270 (gnus-kill-buffer buffer))
5271 ((and (get-buffer buffer)
5272 (buffer-name (get-buffer buffer)))
5275 (gnus-deaden-summary)))))
5277 (defun gnus-summary-wake-up-the-dead (&rest args)
5278 "Wake up the dead summary buffer."
5280 (gnus-dead-summary-mode -1)
5281 (let ((name (buffer-name)))
5282 (when (string-match "Dead " name)
5284 (concat (substring name 0 (match-beginning 0))
5285 (substring name (match-end 0)))
5287 (gnus-message 3 "This dead summary is now alive again"))
5289 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5290 (defun gnus-summary-fetch-faq (&optional faq-dir)
5291 "Fetch the FAQ for the current group.
5292 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5296 (when current-prefix-arg
5298 "Faq dir: " (and (listp gnus-group-faq-directory)
5299 (mapcar (lambda (file) (list file))
5300 gnus-group-faq-directory))))))
5301 (let (gnus-faq-buffer)
5302 (when (setq gnus-faq-buffer
5303 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5304 (gnus-configure-windows 'summary-faq))))
5306 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5307 (defun gnus-summary-describe-group (&optional force)
5308 "Describe the current newsgroup."
5310 (gnus-group-describe-group force gnus-newsgroup-name))
5312 (defun gnus-summary-describe-briefly ()
5313 "Describe summary mode commands briefly."
5316 (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")))
5318 ;; Walking around group mode buffer from summary mode.
5320 (defun gnus-summary-next-group (&optional no-article target-group backward)
5321 "Exit current newsgroup and then select next unread newsgroup.
5322 If prefix argument NO-ARTICLE is non-nil, no article is selected
5323 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5324 previous group instead."
5326 ;; Stop pre-fetching.
5327 (gnus-async-halt-prefetch)
5328 (let ((current-group gnus-newsgroup-name)
5329 (current-buffer (current-buffer))
5331 ;; First we semi-exit this group to update Xrefs and all variables.
5332 ;; We can't do a real exit, because the window conf must remain
5333 ;; the same in case the user is prompted for info, and we don't
5334 ;; want the window conf to change before that...
5335 (gnus-summary-exit t)
5336 (while (not entered)
5337 ;; Then we find what group we are supposed to enter.
5338 (set-buffer gnus-group-buffer)
5339 (gnus-group-jump-to-group current-group)
5342 (if (eq gnus-keep-same-level 'best)
5343 (gnus-summary-best-group gnus-newsgroup-name)
5344 (gnus-summary-search-group backward gnus-keep-same-level))))
5345 (if (not target-group)
5346 ;; There are no further groups, so we return to the group
5349 (gnus-message 5 "Returning to the group buffer")
5351 (when (gnus-buffer-live-p current-buffer)
5352 (set-buffer current-buffer)
5353 (gnus-summary-exit))
5354 (run-hooks 'gnus-group-no-more-groups-hook))
5355 ;; We try to enter the target group.
5356 (gnus-group-jump-to-group target-group)
5357 (let ((unreads (gnus-group-group-unread)))
5358 (if (and (or (eq t unreads)
5359 (and unreads (not (zerop unreads))))
5360 (gnus-summary-read-group
5361 target-group nil no-article
5362 (and (buffer-name current-buffer) current-buffer)))
5364 (setq current-group target-group
5365 target-group nil)))))))
5367 (defun gnus-summary-prev-group (&optional no-article)
5368 "Exit current newsgroup and then select previous unread newsgroup.
5369 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5371 (gnus-summary-next-group no-article nil t))
5373 ;; Walking around summary lines.
5375 (defun gnus-summary-first-subject (&optional unread)
5376 "Go to the first unread subject.
5377 If UNREAD is non-nil, go to the first unread article.
5378 Returns the article selected or nil if there are no unread articles."
5383 ((null gnus-newsgroup-data)
5384 (gnus-message 3 "No articles in the group")
5386 ;; Pick the first article.
5388 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5389 (gnus-data-number (car gnus-newsgroup-data)))
5390 ;; No unread articles.
5391 ((null gnus-newsgroup-unreads)
5392 (gnus-message 3 "No more unread articles")
5394 ;; Find the first unread article.
5396 (let ((data gnus-newsgroup-data))
5398 (not (gnus-data-unread-p (car data))))
5399 (setq data (cdr data)))
5401 (goto-char (gnus-data-pos (car data)))
5402 (gnus-data-number (car data))))))
5403 (gnus-summary-position-point)))
5405 (defun gnus-summary-next-subject (n &optional unread dont-display)
5406 "Go to next N'th summary line.
5407 If N is negative, go to the previous N'th subject line.
5408 If UNREAD is non-nil, only unread articles are selected.
5409 The difference between N and the actual number of steps taken is
5412 (let ((backward (< n 0))
5416 (gnus-summary-find-prev unread)
5417 (gnus-summary-find-next unread)))
5420 (gnus-message 7 "No more%s articles"
5421 (if unread " unread" "")))
5422 (unless dont-display
5423 (gnus-summary-recenter)
5424 (gnus-summary-position-point))
5427 (defun gnus-summary-next-unread-subject (n)
5428 "Go to next N'th unread summary line."
5430 (gnus-summary-next-subject n t))
5432 (defun gnus-summary-prev-subject (n &optional unread)
5433 "Go to previous N'th summary line.
5434 If optional argument UNREAD is non-nil, only unread article is selected."
5436 (gnus-summary-next-subject (- n) unread))
5438 (defun gnus-summary-prev-unread-subject (n)
5439 "Go to previous N'th unread summary line."
5441 (gnus-summary-next-subject (- n) t))
5443 (defun gnus-summary-goto-subject (article &optional force silent)
5444 "Go the subject line of ARTICLE.
5445 If FORCE, also allow jumping to articles not currently shown."
5446 (interactive "nArticle number: ")
5448 (data (gnus-data-find article)))
5449 ;; We read in the article if we have to.
5452 (gnus-summary-insert-subject article (and (vectorp force) force) t)
5453 (setq data (gnus-data-find article)))
5458 (gnus-message 3 "Can't find article %d" article))
5460 (goto-char (gnus-data-pos data))
5463 ;; Walking around summary lines with displaying articles.
5465 (defun gnus-summary-expand-window (&optional arg)
5466 "Make the summary buffer take up the entire Emacs frame.
5467 Given a prefix, will force an `article' buffer configuration."
5470 (gnus-configure-windows 'article 'force)
5471 (gnus-configure-windows 'summary 'force)))
5473 (defun gnus-summary-display-article (article &optional all-header)
5474 "Display ARTICLE in article buffer."
5475 (gnus-set-global-variables)
5479 (if gnus-summary-display-article-function
5480 (funcall gnus-summary-display-article-function article all-header)
5481 (gnus-article-prepare article all-header))
5482 (run-hooks 'gnus-select-article-hook)
5483 (when (and gnus-current-article
5484 (not (zerop gnus-current-article)))
5485 (gnus-summary-goto-subject gnus-current-article))
5486 (gnus-summary-recenter)
5487 (when (and gnus-use-trees gnus-show-threads)
5488 (gnus-possibly-generate-tree article)
5489 (gnus-highlight-selected-tree article))
5490 ;; Successfully display article.
5491 (gnus-article-set-window-start
5492 (cdr (assq article gnus-newsgroup-bookmarks))))))
5494 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5495 "Select the current article.
5496 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5497 non-nil, the article will be re-fetched even if it already present in
5498 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5500 ;; Make sure we are in the summary buffer to work around bbdb bug.
5501 (unless (eq major-mode 'gnus-summary-mode)
5502 (set-buffer gnus-summary-buffer))
5503 (let ((article (or article (gnus-summary-article-number)))
5504 (all-headers (not (not all-headers))) ;Must be T or NIL.
5505 gnus-summary-display-article-function
5508 (gnus-summary-article-pseudo-p article)
5509 (error "This is a pseudo-article"))
5512 (set-buffer gnus-summary-buffer)
5513 (if (or (and gnus-single-article-buffer
5514 (or (null gnus-current-article)
5515 (null gnus-article-current)
5516 (null (get-buffer gnus-article-buffer))
5517 (not (eq article (cdr gnus-article-current)))
5518 (not (equal (car gnus-article-current)
5519 gnus-newsgroup-name))))
5520 (and (not gnus-single-article-buffer)
5521 (or (null gnus-current-article)
5522 (not (eq gnus-current-article article))))
5524 ;; The requested article is different from the current article.
5526 (gnus-summary-display-article article all-headers)
5528 (when (or all-headers gnus-show-all-headers)
5529 (gnus-article-show-all-headers))
5532 (gnus-article-set-window-start
5533 (cdr (assq article gnus-newsgroup-bookmarks)))))))
5535 (defun gnus-summary-set-current-mark (&optional current-mark)
5536 "Obsolete function."
5539 (defun gnus-summary-next-article (&optional unread subject backward push)
5540 "Select the next article.
5541 If UNREAD, only unread articles are selected.
5542 If SUBJECT, only articles with SUBJECT are selected.
5543 If BACKWARD, the previous article is selected instead of the next."
5546 ;; Is there such an article?
5547 ((and (gnus-summary-search-forward unread subject backward)
5548 (or (gnus-summary-display-article (gnus-summary-article-number))
5549 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5550 (gnus-summary-position-point))
5551 ;; If not, we try the first unread, if that is wanted.
5553 gnus-auto-select-same
5554 (gnus-summary-first-unread-article))
5555 (gnus-summary-position-point)
5556 (gnus-message 6 "Wrapped"))
5557 ;; Try to get next/previous article not displayed in this group.
5558 ((and gnus-auto-extend-newsgroup
5559 (not unread) (not subject))
5560 (gnus-summary-goto-article
5561 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5563 ;; Go to next/previous group.
5565 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5566 (gnus-summary-jump-to-group gnus-newsgroup-name))
5567 (let ((cmd last-command-char)
5570 (set-buffer gnus-group-buffer)
5573 (if (eq gnus-keep-same-level 'best)
5574 (gnus-summary-best-group gnus-newsgroup-name)
5575 (gnus-summary-search-group backward gnus-keep-same-level))))
5576 ;; For some reason, the group window gets selected. We change
5578 (select-window (get-buffer-window (current-buffer)))
5579 ;; Select next unread newsgroup automagically.
5581 ((or (not gnus-auto-select-next)
5583 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5584 ((or (eq gnus-auto-select-next 'quietly)
5585 (and (eq gnus-auto-select-next 'slightly-quietly)
5587 (and (eq gnus-auto-select-next 'almost-quietly)
5588 (gnus-summary-last-article-p)))
5590 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5592 (gnus-message 7 "No more%s articles (%s)..."
5593 (if unread " unread" "")
5594 (if group (concat "selecting " group)
5596 (gnus-summary-next-group nil group backward)))
5598 (when (gnus-key-press-event-p last-input-event)
5599 (gnus-summary-walk-group-buffer
5600 gnus-newsgroup-name cmd unread backward point))))))))
5602 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5603 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5604 (?\C-p (gnus-group-prev-unread-group 1))))
5605 (cursor-in-echo-area t)
5606 keve key group ended)
5608 (set-buffer gnus-group-buffer)
5611 (if (eq gnus-keep-same-level 'best)
5612 (gnus-summary-best-group gnus-newsgroup-name)
5613 (gnus-summary-search-group backward gnus-keep-same-level))))
5616 5 "No more%s articles%s" (if unread " unread" "")
5618 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5619 (format " (Type %s for %s [%s])"
5620 (single-key-description cmd) group
5621 (car (gnus-gethash group gnus-newsrc-hashtb)))
5622 (format " (Type %s to exit %s)"
5623 (single-key-description cmd)
5624 gnus-newsgroup-name)))
5625 ;; Confirm auto selection.
5626 (setq key (car (setq keve (gnus-read-event-char))))
5629 ((assq key keystrokes)
5630 (let ((obuf (current-buffer)))
5631 (switch-to-buffer gnus-group-buffer)
5633 (gnus-group-jump-to-group group))
5634 (eval (cadr (assq key keystrokes)))
5635 (setq group (gnus-group-group-name))
5636 (switch-to-buffer obuf))
5640 (gnus-ephemeral-group-p gnus-newsgroup-name))
5642 (gnus-summary-next-group nil group backward)))
5644 (push (cdr keve) unread-command-events))))))
5646 (defun gnus-summary-next-unread-article ()
5647 "Select unread article after current one."
5649 (gnus-summary-next-article
5650 (or (not (eq gnus-summary-goto-unread 'never))
5651 (gnus-summary-last-article-p (gnus-summary-article-number)))
5652 (and gnus-auto-select-same
5653 (gnus-summary-article-subject))))
5655 (defun gnus-summary-prev-article (&optional unread subject)
5656 "Select the article after the current one.
5657 If UNREAD is non-nil, only unread articles are selected."
5659 (gnus-summary-next-article unread subject t))
5661 (defun gnus-summary-prev-unread-article ()
5662 "Select unread article before current one."
5664 (gnus-summary-prev-article
5665 (or (not (eq gnus-summary-goto-unread 'never))
5666 (gnus-summary-first-article-p (gnus-summary-article-number)))
5667 (and gnus-auto-select-same
5668 (gnus-summary-article-subject))))
5670 (defun gnus-summary-next-page (&optional lines circular)
5671 "Show next page of the selected article.
5672 If at the end of the current article, select the next article.
5673 LINES says how many lines should be scrolled up.
5675 If CIRCULAR is non-nil, go to the start of the article instead of
5676 selecting the next article when reaching the end of the current
5679 (setq gnus-summary-buffer (current-buffer))
5680 (gnus-set-global-variables)
5681 (let ((article (gnus-summary-article-number))
5682 (article-window (get-buffer-window gnus-article-buffer t))
5684 (gnus-configure-windows 'article)
5685 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
5686 (if (and (eq gnus-summary-goto-unread 'never)
5687 (not (gnus-summary-last-article-p article)))
5688 (gnus-summary-next-article)
5689 (gnus-summary-next-unread-article))
5690 (if (or (null gnus-current-article)
5691 (null gnus-article-current)
5692 (/= article (cdr gnus-article-current))
5693 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5694 ;; Selected subject is different from current article's.
5695 (gnus-summary-display-article article)
5696 (when article-window
5697 (gnus-eval-in-buffer-window gnus-article-buffer
5698 (setq endp (gnus-article-next-page lines)))
5701 (gnus-summary-beginning-of-article))
5703 (gnus-message 3 "End of message"))
5705 (if (and (eq gnus-summary-goto-unread 'never)
5706 (not (gnus-summary-last-article-p article)))
5707 (gnus-summary-next-article)
5708 (gnus-summary-next-unread-article))))))))
5709 (gnus-summary-recenter)
5710 (gnus-summary-position-point)))
5712 (defun gnus-summary-prev-page (&optional lines move)
5713 "Show previous page of selected article.
5714 Argument LINES specifies lines to be scrolled down.
5715 If MOVE, move to the previous unread article if point is at
5716 the beginning of the buffer."
5718 (let ((article (gnus-summary-article-number))
5719 (article-window (get-buffer-window gnus-article-buffer t))
5721 (gnus-configure-windows 'article)
5722 (if (or (null gnus-current-article)
5723 (null gnus-article-current)
5724 (/= article (cdr gnus-article-current))
5725 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5726 ;; Selected subject is different from current article's.
5727 (gnus-summary-display-article article)
5728 (gnus-summary-recenter)
5729 (when article-window
5730 (gnus-eval-in-buffer-window gnus-article-buffer
5731 (setq endp (gnus-article-prev-page lines)))
5732 (when (and move endp)
5734 (gnus-message 3 "Beginning of message"))
5736 (if (and (eq gnus-summary-goto-unread 'never)
5737 (not (gnus-summary-first-article-p article)))
5738 (gnus-summary-prev-article)
5739 (gnus-summary-prev-unread-article))))))))
5740 (gnus-summary-position-point))
5742 (defun gnus-summary-prev-page-or-article (&optional lines)
5743 "Show previous page of selected article.
5744 Argument LINES specifies lines to be scrolled down.
5745 If at the beginning of the article, go to the next article."
5747 (gnus-summary-prev-page lines t))
5749 (defun gnus-summary-scroll-up (lines)
5750 "Scroll up (or down) one line current article.
5751 Argument LINES specifies lines to be scrolled up (or down if negative)."
5753 (gnus-configure-windows 'article)
5754 (gnus-summary-show-thread)
5755 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
5756 (gnus-eval-in-buffer-window gnus-article-buffer
5758 (when (gnus-article-next-page lines)
5759 (gnus-message 3 "End of message")))
5761 (gnus-article-prev-page (- lines))))))
5762 (gnus-summary-recenter)
5763 (gnus-summary-position-point))
5765 (defun gnus-summary-next-same-subject ()
5766 "Select next article which has the same subject as current one."
5768 (gnus-summary-next-article nil (gnus-summary-article-subject)))
5770 (defun gnus-summary-prev-same-subject ()
5771 "Select previous article which has the same subject as current one."
5773 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
5775 (defun gnus-summary-next-unread-same-subject ()
5776 "Select next unread article which has the same subject as current one."
5778 (gnus-summary-next-article t (gnus-summary-article-subject)))
5780 (defun gnus-summary-prev-unread-same-subject ()
5781 "Select previous unread article which has the same subject as current one."
5783 (gnus-summary-prev-article t (gnus-summary-article-subject)))
5785 (defun gnus-summary-first-unread-article ()
5786 "Select the first unread article.
5787 Return nil if there are no unread articles."
5790 (when (gnus-summary-first-subject t)
5791 (gnus-summary-show-thread)
5792 (gnus-summary-first-subject t)
5793 (gnus-summary-display-article (gnus-summary-article-number)))
5794 (gnus-summary-position-point)))
5796 (defun gnus-summary-first-article ()
5797 "Select the first article.
5798 Return nil if there are no articles."
5801 (when (gnus-summary-first-subject)
5802 (gnus-summary-show-thread)
5803 (gnus-summary-first-subject)
5804 (gnus-summary-display-article (gnus-summary-article-number)))
5805 (gnus-summary-position-point)))
5807 (defun gnus-summary-best-unread-article ()
5808 "Select the unread article with the highest score."
5810 (let ((best -1000000)
5811 (data gnus-newsgroup-data)
5814 (and (gnus-data-unread-p (car data))
5816 (gnus-summary-article-score (gnus-data-number (car data))))
5819 article (gnus-data-number (car data))))
5820 (setq data (cdr data)))
5823 (gnus-summary-goto-article article)
5824 (error "No unread articles"))
5825 (gnus-summary-position-point))))
5827 (defun gnus-summary-last-subject ()
5828 "Go to the last displayed subject line in the group."
5829 (let ((article (gnus-data-number (car (gnus-data-list t)))))
5831 (gnus-summary-goto-subject article))))
5833 (defun gnus-summary-goto-article (article &optional all-headers force)
5834 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
5835 If ALL-HEADERS is non-nil, no header lines are hidden."
5839 "Article number or Message-ID: "
5840 (mapcar (lambda (number) (list (int-to-string number)))
5841 gnus-newsgroup-limit))
5845 (if (and (stringp article)
5846 (string-match "@" article))
5847 (gnus-summary-refer-article article)
5848 (when (stringp article)
5849 (setq article (string-to-number article)))
5850 (if (gnus-summary-goto-subject article force)
5851 (gnus-summary-display-article article all-headers)
5852 (gnus-message 4 "Couldn't go to article %s" article) nil))
5853 (gnus-summary-position-point)))
5855 (defun gnus-summary-goto-last-article ()
5856 "Go to the previously read article."
5859 (when gnus-last-article
5860 (gnus-summary-goto-article gnus-last-article))
5861 (gnus-summary-position-point)))
5863 (defun gnus-summary-pop-article (number)
5864 "Pop one article off the history and go to the previous.
5865 NUMBER articles will be popped off."
5868 (setq gnus-newsgroup-history
5869 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
5871 (gnus-summary-goto-article (car to) nil t)
5872 (error "Article history empty")))
5873 (gnus-summary-position-point))
5875 ;; Summary commands and functions for limiting the summary buffer.
5877 (defun gnus-summary-limit-to-articles (n)
5878 "Limit the summary buffer to the next N articles.
5879 If not given a prefix, use the process marked articles instead."
5882 (let ((articles (gnus-summary-work-articles n)))
5883 (setq gnus-newsgroup-processable nil)
5884 (gnus-summary-limit articles))
5885 (gnus-summary-position-point)))
5887 (defun gnus-summary-pop-limit (&optional total)
5888 "Restore the previous limit.
5889 If given a prefix, remove all limits."
5892 (setq gnus-newsgroup-limits
5893 (list (mapcar (lambda (h) (mail-header-number h))
5894 gnus-newsgroup-headers))))
5895 (unless gnus-newsgroup-limits
5896 (error "No limit to pop"))
5898 (gnus-summary-limit nil 'pop)
5899 (gnus-summary-position-point)))
5901 (defun gnus-summary-limit-to-subject (subject &optional header)
5902 "Limit the summary buffer to articles that have subjects that match a regexp."
5903 (interactive "sLimit to subject (regexp): ")
5905 (setq header "subject"))
5906 (when (not (equal "" subject))
5908 (let ((articles (gnus-summary-find-matching
5909 (or header "subject") subject 'all)))
5911 (error "Found no matches for \"%s\"" subject))
5912 (gnus-summary-limit articles))
5913 (gnus-summary-position-point))))
5915 (defun gnus-summary-limit-to-author (from)
5916 "Limit the summary buffer to articles that have authors that match a regexp."
5917 (interactive "sLimit to author (regexp): ")
5918 (gnus-summary-limit-to-subject from "from"))
5920 (defun gnus-summary-limit-to-age (age &optional younger-p)
5921 "Limit the summary buffer to articles that are older than (or equal) AGE days.
5922 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
5923 articles that are younger than AGE days."
5924 (interactive "nTime in days: \nP")
5926 (let ((data gnus-newsgroup-data)
5927 (cutoff (nnmail-days-to-time age))
5928 articles d date is-younger)
5929 (while (setq d (pop data))
5930 (when (and (vectorp (gnus-data-header d))
5931 (setq date (mail-header-date (gnus-data-header d))))
5932 (setq is-younger (nnmail-time-less
5933 (nnmail-time-since (nnmail-date-to-time date))
5935 (when (if younger-p is-younger (not is-younger))
5936 (push (gnus-data-number d) articles))))
5937 (gnus-summary-limit (nreverse articles)))
5938 (gnus-summary-position-point)))
5940 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5942 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5944 (defun gnus-summary-limit-to-unread (&optional all)
5945 "Limit the summary buffer to articles that are not marked as read.
5946 If ALL is non-nil, limit strictly to unread articles."
5949 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
5950 (gnus-summary-limit-to-marks
5951 ;; Concat all the marks that say that an article is read and have
5953 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
5954 gnus-killed-mark gnus-kill-file-mark
5955 gnus-low-score-mark gnus-expirable-mark
5956 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
5957 gnus-duplicate-mark gnus-souped-mark)
5960 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
5961 (make-obsolete 'gnus-summary-delete-marked-with
5962 'gnus-summary-limit-exlude-marks)
5964 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
5965 "Exclude articles that are marked with MARKS (e.g. \"DK\").
5966 If REVERSE, limit the summary buffer to articles that are marked
5967 with MARKS. MARKS can either be a string of marks or a list of marks.
5968 Returns how many articles were removed."
5969 (interactive "sMarks: ")
5970 (gnus-summary-limit-to-marks marks t))
5972 (defun gnus-summary-limit-to-marks (marks &optional reverse)
5973 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
5974 If REVERSE (the prefix), limit the summary buffer to articles that are
5975 not marked with MARKS. MARKS can either be a string of marks or a
5977 Returns how many articles were removed."
5978 (interactive "sMarks: \nP")
5980 (let ((data gnus-newsgroup-data)
5981 (marks (if (listp marks) marks
5982 (append marks nil))) ; Transform to list.
5985 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
5986 (memq (gnus-data-mark (car data)) marks))
5987 (push (gnus-data-number (car data)) articles))
5988 (setq data (cdr data)))
5989 (gnus-summary-limit articles))
5990 (gnus-summary-position-point)))
5992 (defun gnus-summary-limit-to-score (&optional score)
5993 "Limit to articles with score at or above SCORE."
5995 (setq score (if score
5996 (prefix-numeric-value score)
5997 (or gnus-summary-default-score 0)))
5998 (let ((data gnus-newsgroup-data)
6001 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6003 (push (gnus-data-number (car data)) articles))
6004 (setq data (cdr data)))
6006 (gnus-summary-limit articles)
6007 (gnus-summary-position-point))))
6009 (defun gnus-summary-limit-include-thread (id)
6010 "Display all the hidden articles that in the current thread."
6011 (interactive (list (mail-header-id (gnus-summary-article-header))))
6012 (let ((articles (gnus-articles-in-thread
6013 (gnus-id-to-thread (gnus-root-id id)))))
6015 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6016 (gnus-summary-position-point))))
6018 (defun gnus-summary-limit-include-dormant ()
6019 "Display all the hidden articles that are marked as dormant.
6020 Note that this command only works on a subset of the articles currently
6021 fetched for this group."
6023 (unless gnus-newsgroup-dormant
6024 (error "There are no dormant articles in this group"))
6026 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6027 (gnus-summary-position-point)))
6029 (defun gnus-summary-limit-exclude-dormant ()
6030 "Hide all dormant articles."
6033 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6034 (gnus-summary-position-point)))
6036 (defun gnus-summary-limit-exclude-childless-dormant ()
6037 "Hide all dormant articles that have no children."
6039 (let ((data (gnus-data-list t))
6040 articles d children)
6041 ;; Find all articles that are either not dormant or have
6043 (while (setq d (pop data))
6044 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6046 (gnus-article-children (gnus-data-number d)))
6049 (when (memq (car children) articles)
6054 (push (gnus-data-number d) articles)))
6057 (gnus-summary-limit articles)
6058 (gnus-summary-position-point))))
6060 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6061 "Mark all unread excluded articles as read.
6062 If ALL, mark even excluded ticked and dormants as read."
6064 (let ((articles (gnus-sorted-complement
6066 (mapcar (lambda (h) (mail-header-number h))
6067 gnus-newsgroup-headers)
6069 (sort gnus-newsgroup-limit '<)))
6071 (setq gnus-newsgroup-unreads gnus-newsgroup-limit)
6073 (setq gnus-newsgroup-dormant nil
6074 gnus-newsgroup-marked nil
6075 gnus-newsgroup-reads
6077 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6078 gnus-newsgroup-reads))
6079 (while (setq article (pop articles))
6080 (unless (or (memq article gnus-newsgroup-dormant)
6081 (memq article gnus-newsgroup-marked))
6082 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6084 (defun gnus-summary-limit (articles &optional pop)
6086 ;; We pop the previous limit off the stack and use that.
6087 (setq articles (car gnus-newsgroup-limits)
6088 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6089 ;; We use the new limit, so we push the old limit on the stack.
6090 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6092 (setq gnus-newsgroup-limit articles)
6093 (let ((total (length gnus-newsgroup-data))
6094 (data (gnus-data-find-list (gnus-summary-article-number)))
6095 (gnus-summary-mark-below nil) ; Inhibit this.
6097 ;; This will do all the work of generating the new summary buffer
6098 ;; according to the new limit.
6099 (gnus-summary-prepare)
6100 ;; Hide any threads, possibly.
6101 (and gnus-show-threads
6102 gnus-thread-hide-subtree
6103 (gnus-summary-hide-all-threads))
6104 ;; Try to return to the article you were at, or one in the
6107 ;; We try to find some article after the current one.
6109 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6112 (setq data (cdr data))))
6114 ;; If there is no data, that means that we were after the last
6115 ;; article. The same goes when we can't find any articles
6116 ;; after the current one.
6117 (goto-char (point-max))
6118 (gnus-summary-find-prev))
6119 ;; We return how many articles were removed from the summary
6120 ;; buffer as a result of the new limit.
6121 (- total (length gnus-newsgroup-data))))
6123 (defsubst gnus-invisible-cut-children (threads)
6126 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6131 (defsubst gnus-cut-thread (thread)
6132 "Go forwards in the thread until we find an article that we want to display."
6133 (when (or (eq gnus-fetch-old-headers 'some)
6134 (eq gnus-fetch-old-headers 'invisible)
6135 (eq gnus-build-sparse-threads 'some)
6136 (eq gnus-build-sparse-threads 'more))
6137 ;; Deal with old-fetched headers and sparse threads.
6141 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6142 (gnus-summary-article-ancient-p
6143 (mail-header-number (car thread))))
6144 (if (or (<= (length (cdr thread)) 1)
6145 (eq gnus-fetch-old-headers 'invisible))
6146 (setq gnus-newsgroup-limit
6147 (delq (mail-header-number (car thread))
6148 gnus-newsgroup-limit)
6149 thread (cadr thread))
6150 (when (gnus-invisible-cut-children (cdr thread))
6151 (let ((th (cdr thread)))
6153 (if (memq (mail-header-number (caar th))
6154 gnus-newsgroup-limit)
6155 (setq thread (car th)
6157 (setq th (cdr th))))))))))
6160 (defun gnus-cut-threads (threads)
6161 "Cut off all uninteresting articles from the beginning of threads."
6162 (when (or (eq gnus-fetch-old-headers 'some)
6163 (eq gnus-fetch-old-headers 'invisible)
6164 (eq gnus-build-sparse-threads 'some)
6165 (eq gnus-build-sparse-threads 'more))
6168 (setcar th (gnus-cut-thread (car th)))
6169 (setq th (cdr th)))))
6170 ;; Remove nixed out threads.
6173 (defun gnus-summary-initial-limit (&optional show-if-empty)
6174 "Figure out what the initial limit is supposed to be on group entry.
6175 This entails weeding out unwanted dormants, low-scored articles,
6176 fetch-old-headers verbiage, and so on."
6177 ;; Most groups have nothing to remove.
6178 (if (or gnus-inhibit-limiting
6179 (and (null gnus-newsgroup-dormant)
6180 (not (eq gnus-fetch-old-headers 'some))
6181 (not (eq gnus-fetch-old-headers 'invisible))
6182 (null gnus-summary-expunge-below)
6183 (not (eq gnus-build-sparse-threads 'some))
6184 (not (eq gnus-build-sparse-threads 'more))
6185 (null gnus-thread-expunge-below)
6186 (not gnus-use-nocem)))
6188 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6189 (setq gnus-newsgroup-limit nil)
6192 (unless (car (symbol-value node))
6193 ;; These threads have no parents -- they are roots.
6194 (let ((nodes (cdr (symbol-value node)))
6197 (if (and gnus-thread-expunge-below
6198 (< (gnus-thread-total-score (car nodes))
6199 gnus-thread-expunge-below))
6200 (gnus-expunge-thread (pop nodes))
6201 (setq thread (pop nodes))
6202 (gnus-summary-limit-children thread))))))
6203 gnus-newsgroup-dependencies)
6204 ;; If this limitation resulted in an empty group, we might
6205 ;; pop the previous limit and use it instead.
6206 (when (and (not gnus-newsgroup-limit)
6208 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6209 gnus-newsgroup-limit))
6211 (defun gnus-summary-limit-children (thread)
6212 "Return 1 if this subthread is visible and 0 if it is not."
6213 ;; First we get the number of visible children to this thread. This
6214 ;; is done by recursing down the thread using this function, so this
6215 ;; will really go down to a leaf article first, before slowly
6216 ;; working its way up towards the root.
6220 (apply '+ (mapcar 'gnus-summary-limit-children
6223 (number (mail-header-number (car thread)))
6226 (not (memq number gnus-newsgroup-marked))
6228 ;; If this article is dormant and has absolutely no visible
6229 ;; children, then this article isn't visible.
6230 (and (memq number gnus-newsgroup-dormant)
6232 ;; If this is "fetch-old-headered" and there is no
6233 ;; visible children, then we don't want this article.
6234 (and (eq gnus-fetch-old-headers 'some)
6235 (gnus-summary-article-ancient-p number)
6237 ;; If this is "fetch-old-headered" and `invisible', then
6238 ;; we don't want this article.
6239 (and (eq gnus-fetch-old-headers 'invisible)
6240 (gnus-summary-article-ancient-p number))
6241 ;; If this is a sparsely inserted article with no children,
6242 ;; we don't want it.
6243 (and (eq gnus-build-sparse-threads 'some)
6244 (gnus-summary-article-sparse-p number)
6246 ;; If we use expunging, and this article is really
6247 ;; low-scored, then we don't want this article.
6248 (when (and gnus-summary-expunge-below
6250 (or (cdr (assq number gnus-newsgroup-scored))
6251 gnus-summary-default-score))
6252 gnus-summary-expunge-below))
6253 ;; We increase the expunge-tally here, but that has
6254 ;; nothing to do with the limits, really.
6255 (incf gnus-newsgroup-expunged-tally)
6256 ;; We also mark as read here, if that's wanted.
6257 (when (and gnus-summary-mark-below
6258 (< score gnus-summary-mark-below))
6259 (setq gnus-newsgroup-unreads
6260 (delq number gnus-newsgroup-unreads))
6261 (if gnus-newsgroup-auto-expire
6262 (push number gnus-newsgroup-expirable)
6263 (push (cons number gnus-low-score-mark)
6264 gnus-newsgroup-reads)))
6266 ;; Check NoCeM things.
6267 (if (and gnus-use-nocem
6268 (gnus-nocem-unwanted-article-p
6269 (mail-header-id (car thread))))
6271 (setq gnus-newsgroup-unreads
6272 (delq number gnus-newsgroup-unreads))
6274 ;; Nope, invisible article.
6276 ;; Ok, this article is to be visible, so we add it to the limit
6278 (push number gnus-newsgroup-limit)
6281 (defun gnus-expunge-thread (thread)
6282 "Mark all articles in THREAD as read."
6283 (let* ((number (mail-header-number (car thread))))
6284 (incf gnus-newsgroup-expunged-tally)
6285 ;; We also mark as read here, if that's wanted.
6286 (setq gnus-newsgroup-unreads
6287 (delq number gnus-newsgroup-unreads))
6288 (if gnus-newsgroup-auto-expire
6289 (push number gnus-newsgroup-expirable)
6290 (push (cons number gnus-low-score-mark)
6291 gnus-newsgroup-reads)))
6292 ;; Go recursively through all subthreads.
6293 (mapcar 'gnus-expunge-thread (cdr thread)))
6295 ;; Summary article oriented commands
6297 (defun gnus-summary-refer-parent-article (n)
6298 "Refer parent article N times.
6299 If N is negative, go to ancestor -N instead.
6300 The difference between N and the number of articles fetched is returned."
6304 (when (not (natnump n))
6309 (setq header (gnus-summary-article-header))
6310 (if (and (eq (mail-header-number header)
6311 (cdr gnus-article-current))
6312 (equal gnus-newsgroup-name
6313 (car gnus-article-current)))
6314 ;; If we try to find the parent of the currently
6315 ;; displayed article, then we take a look at the actual
6316 ;; References header, since this is slightly more
6317 ;; reliable than the References field we got from the
6320 (set-buffer gnus-original-article-buffer)
6321 (nnheader-narrow-to-headers)
6322 (unless (setq ref (message-fetch-field "references"))
6323 (setq ref (message-fetch-field "in-reply-to")))
6326 ;; It's not the current article, so we take a bet on
6327 ;; the value we got from the server.
6328 (mail-header-references header)))
6330 (not (equal ref "")))
6331 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6332 (gnus-message 1 "Couldn't find parent"))
6333 (gnus-message 1 "No references in article %d"
6334 (gnus-summary-article-number))
6337 (gnus-summary-position-point)
6340 (defun gnus-summary-refer-references ()
6341 "Fetch all articles mentioned in the References header.
6342 Return the number of articles fetched."
6344 (let ((ref (mail-header-references (gnus-summary-article-header)))
6345 (current (gnus-summary-article-number))
6349 (error "No References in the current article")
6350 ;; For each Message-ID in the References header...
6351 (while (string-match "<[^>]*>" ref)
6353 ;; ... fetch that article.
6354 (gnus-summary-refer-article
6355 (prog1 (match-string 0 ref)
6356 (setq ref (substring ref (match-end 0))))))
6357 (gnus-summary-goto-subject current)
6358 (gnus-summary-position-point)
6361 (defun gnus-summary-refer-thread (&optional limit)
6362 "Fetch all articles in the current thread.
6363 If LIMIT (the numerical prefix), fetch that many old headers instead
6364 of what's specified by the `gnus-refer-thread-limit' variable."
6366 (let ((id (mail-header-id (gnus-summary-article-header)))
6367 (limit (if limit (prefix-numeric-value limit)
6368 gnus-refer-thread-limit))
6370 ;; We want to fetch LIMIT *old* headers, but we also have to
6371 ;; re-fetch all the headers in the current buffer, because many of
6372 ;; them may be undisplayed. So we adjust LIMIT.
6373 (when (numberp limit)
6374 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6375 (unless (eq gnus-fetch-old-headers 'invisible)
6376 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6377 ;; Retrieve the headers and read them in.
6378 (if (eq (gnus-retrieve-headers
6379 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6381 (gnus-build-all-threads)
6382 (error "Can't fetch thread from backends that don't support NOV"))
6383 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6384 (gnus-summary-limit-include-thread id)))
6386 (defun gnus-summary-refer-article (message-id &optional arg)
6387 "Fetch an article specified by MESSAGE-ID.
6388 If ARG (the prefix), fetch the article using `gnus-refer-article-method'
6389 or `gnus-select-method', no matter what backend the article comes from."
6390 (interactive "sMessage-ID: \nP")
6391 (when (and (stringp message-id)
6392 (not (zerop (length message-id))))
6393 ;; Construct the correct Message-ID if necessary.
6394 ;; Suggested by tale@pawl.rpi.edu.
6395 (unless (string-match "^<" message-id)
6396 (setq message-id (concat "<" message-id)))
6397 (unless (string-match ">$" message-id)
6398 (setq message-id (concat message-id ">")))
6399 (let* ((header (gnus-id-to-header message-id))
6401 (gnus-summary-article-sparse-p
6402 (mail-header-number header))
6403 (memq (mail-header-number header)
6404 gnus-newsgroup-limit)))
6407 ;; If the article is present in the buffer we just go to it.
6409 (or (not (gnus-summary-article-sparse-p
6410 (mail-header-number header)))
6413 (gnus-summary-goto-article
6414 (mail-header-number header) nil t)
6416 (gnus-summary-update-article (mail-header-number header)))))
6418 ;; We fetch the article
6419 (let ((gnus-override-method
6420 (cond ((gnus-news-group-p gnus-newsgroup-name)
6421 gnus-refer-article-method)
6423 (or gnus-refer-article-method gnus-select-method))
6426 ;; Start the special refer-article method, if necessary.
6427 (when (and gnus-refer-article-method
6428 (gnus-news-group-p gnus-newsgroup-name))
6429 (gnus-check-server gnus-refer-article-method))
6430 ;; Fetch the header, and display the article.
6431 (if (setq number (gnus-summary-insert-subject message-id))
6432 (gnus-summary-select-article nil nil nil number)
6433 (gnus-message 3 "Couldn't fetch article %s" message-id))))))))
6435 (defun gnus-summary-enter-digest-group (&optional force)
6436 "Enter an nndoc group based on the current article.
6437 If FORCE, force a digest interpretation. If not, try
6438 to guess what the document format is."
6440 (let ((conf gnus-current-window-configuration))
6442 (gnus-summary-select-article))
6443 (setq gnus-current-window-configuration conf)
6444 (let* ((name (format "%s-%d"
6445 (gnus-group-prefixed-name
6446 gnus-newsgroup-name (list 'nndoc ""))
6448 (set-buffer gnus-summary-buffer)
6449 gnus-current-article)))
6450 (ogroup gnus-newsgroup-name)
6451 (params (append (gnus-info-params (gnus-get-info ogroup))
6452 (list (cons 'to-group ogroup))
6453 (list (cons 'save-article-group ogroup))))
6454 (case-fold-search t)
6455 (buf (current-buffer))
6458 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6459 (insert-buffer-substring gnus-original-article-buffer)
6460 ;; Remove lines that may lead nndoc to misinterpret the
6463 (goto-char (point-min))
6464 (or (search-forward "\n\n" nil t) (point)))
6465 (goto-char (point-min))
6466 (delete-matching-lines "^\\(Path\\):\\|^From ")
6469 (if (gnus-group-read-ephemeral-group
6470 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6472 ,(if force 'digest 'guess))) t)
6473 ;; Make all postings to this group go to the parent group.
6474 (nconc (gnus-info-params (gnus-get-info name))
6476 ;; Couldn't select this doc group.
6477 (switch-to-buffer buf)
6478 (gnus-set-global-variables)
6479 (gnus-configure-windows 'summary)
6480 (gnus-message 3 "Article couldn't be entered?"))
6481 (kill-buffer dig)))))
6483 (defun gnus-summary-read-document (n)
6484 "Open a new group based on the current article(s).
6485 This will allow you to read digests and other similar
6486 documents as newsgroups.
6487 Obeys the standard process/prefix convention."
6489 (let* ((articles (gnus-summary-work-articles n))
6490 (ogroup gnus-newsgroup-name)
6491 (params (append (gnus-info-params (gnus-get-info ogroup))
6492 (list (cons 'to-group ogroup))))
6493 article group egroup groups vgroup)
6494 (while (setq article (pop articles))
6495 (setq group (format "%s-%d" gnus-newsgroup-name article))
6496 (gnus-summary-remove-process-mark article)
6497 (when (gnus-summary-display-article article)
6499 (nnheader-temp-write nil
6500 (insert-buffer-substring gnus-original-article-buffer)
6501 ;; Remove some headers that may lead nndoc to make
6503 (message-narrow-to-head)
6504 (goto-char (point-min))
6505 (delete-matching-lines "^\\(Path\\):\\|^From ")
6508 (gnus-group-read-ephemeral-group
6509 group `(nndoc ,group (nndoc-address ,(current-buffer))
6510 (nndoc-article-type guess))
6513 ;; Make all postings to this group go to the parent group.
6514 (nconc (gnus-info-params (gnus-get-info egroup))
6516 (push egroup groups))
6517 ;; Couldn't select this doc group.
6518 (gnus-error 3 "Article couldn't be entered"))))))
6519 ;; Now we have selected all the documents.
6522 (error "None of the articles could be interpreted as documents"))
6523 ((gnus-group-read-ephemeral-group
6524 (setq vgroup (format
6525 "nnvirtual:%s-%s" gnus-newsgroup-name
6526 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6527 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6529 (cons (current-buffer) 'summary)))
6531 (error "Couldn't select virtual nndoc group")))))
6533 (defun gnus-summary-isearch-article (&optional regexp-p)
6534 "Do incremental search forward on the current article.
6535 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6537 (gnus-summary-select-article)
6538 (gnus-configure-windows 'article)
6539 (gnus-eval-in-buffer-window gnus-article-buffer
6542 (isearch-forward regexp-p))))
6544 (defun gnus-summary-search-article-forward (regexp &optional backward)
6545 "Search for an article containing REGEXP forward.
6546 If BACKWARD, search backward instead."
6549 (format "Search article %s (regexp%s): "
6550 (if current-prefix-arg "backward" "forward")
6551 (if gnus-last-search-regexp
6552 (concat ", default " gnus-last-search-regexp)
6554 current-prefix-arg))
6555 (if (string-equal regexp "")
6556 (setq regexp (or gnus-last-search-regexp ""))
6557 (setq gnus-last-search-regexp regexp))
6558 (if (gnus-summary-search-article regexp backward)
6559 (gnus-summary-show-thread)
6560 (error "Search failed: \"%s\"" regexp)))
6562 (defun gnus-summary-search-article-backward (regexp)
6563 "Search for an article containing REGEXP backward."
6566 (format "Search article backward (regexp%s): "
6567 (if gnus-last-search-regexp
6568 (concat ", default " gnus-last-search-regexp)
6570 (gnus-summary-search-article-forward regexp 'backward))
6572 (defun gnus-summary-search-article (regexp &optional backward)
6573 "Search for an article containing REGEXP.
6574 Optional argument BACKWARD means do search for backward.
6575 `gnus-select-article-hook' is not called during the search."
6576 ;; We have to require this here to make sure that the following
6577 ;; dynamic binding isn't shadowed by autoloading.
6578 (require 'gnus-async)
6579 (let ((gnus-select-article-hook nil) ;Disable hook.
6580 (gnus-article-display-hook nil)
6581 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6582 (gnus-use-article-prefetch nil)
6583 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
6584 (gnus-use-trees nil) ;Inhibit updating tree buffer.
6585 (sum (current-buffer))
6588 (gnus-save-hidden-threads
6589 (gnus-summary-select-article)
6590 (set-buffer gnus-article-buffer)
6594 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
6596 (re-search-backward regexp nil t)
6597 (re-search-forward regexp nil t))
6598 ;; We found the regexp.
6603 (get-buffer-window (current-buffer))
6607 (setq point (point)))
6608 ;; We didn't find it, so we go to the next article.
6611 (while (eq found 'not)
6612 (if (not (if backward (gnus-summary-find-prev)
6613 (gnus-summary-find-next)))
6614 ;; No more articles.
6616 ;; Select the next article and adjust point.
6617 (unless (gnus-summary-article-sparse-p
6618 (gnus-summary-article-number))
6620 (gnus-summary-select-article)
6621 (set-buffer gnus-article-buffer)
6623 (goto-char (if backward (point-max) (point-min))))))))
6624 (gnus-message 7 ""))
6625 ;; Return whether we found the regexp.
6626 (when (eq found 'found)
6628 (gnus-summary-show-thread)
6629 (gnus-summary-goto-subject gnus-current-article)
6630 (gnus-summary-position-point)
6633 (defun gnus-summary-find-matching (header regexp &optional backward unread
6635 "Return a list of all articles that match REGEXP on HEADER.
6636 The search stars on the current article and goes forwards unless
6637 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
6638 If UNREAD is non-nil, only unread articles will
6639 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
6640 in the comparisons."
6641 (let ((data (if (eq backward 'all) gnus-newsgroup-data
6642 (gnus-data-find-list
6643 (gnus-summary-article-number) (gnus-data-list backward))))
6644 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
6645 (case-fold-search (not not-case-fold))
6647 (unless (fboundp (intern (concat "mail-header-" header)))
6648 (error "%s is not a valid header" header))
6651 (and (or (not unread) ; We want all articles...
6652 (gnus-data-unread-p d)) ; Or just unreads.
6653 (vectorp (gnus-data-header d)) ; It's not a pseudo.
6654 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
6655 (push (gnus-data-number d) articles)) ; Success!
6656 (setq data (cdr data)))
6657 (nreverse articles)))
6659 (defun gnus-summary-execute-command (header regexp command &optional backward)
6660 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
6661 If HEADER is an empty string (or nil), the match is done on the entire
6662 article. If BACKWARD (the prefix) is non-nil, search backward instead."
6664 (list (let ((completion-ignore-case t))
6667 (mapcar (lambda (string) (list string))
6668 '("Number" "Subject" "From" "Lines" "Date"
6669 "Message-ID" "Xref" "References" "Body"))
6670 nil 'require-match))
6671 (read-string "Regexp: ")
6672 (read-key-sequence "Command: ")
6673 current-prefix-arg))
6674 (when (equal header "Body")
6676 ;; Hidden thread subtrees must be searched as well.
6677 (gnus-summary-show-all-threads)
6678 ;; We don't want to change current point nor window configuration.
6680 (save-window-excursion
6681 (gnus-message 6 "Executing %s..." (key-description command))
6682 ;; We'd like to execute COMMAND interactively so as to give arguments.
6683 (gnus-execute header regexp
6684 `(call-interactively ',(key-binding command))
6686 (gnus-message 6 "Executing %s...done" (key-description command)))))
6688 (defun gnus-summary-beginning-of-article ()
6689 "Scroll the article back to the beginning."
6691 (gnus-summary-select-article)
6692 (gnus-configure-windows 'article)
6693 (gnus-eval-in-buffer-window gnus-article-buffer
6695 (goto-char (point-min))
6696 (when gnus-page-broken
6697 (gnus-narrow-to-page))))
6699 (defun gnus-summary-end-of-article ()
6700 "Scroll to the end of the article."
6702 (gnus-summary-select-article)
6703 (gnus-configure-windows 'article)
6704 (gnus-eval-in-buffer-window gnus-article-buffer
6706 (goto-char (point-max))
6708 (when gnus-page-broken
6709 (gnus-narrow-to-page))))
6711 (defun gnus-summary-print-article (&optional filename)
6712 "Generate and print a PostScript image of the article buffer.
6714 If the optional argument FILENAME is nil, send the image to the printer.
6715 If FILENAME is a string, save the PostScript image in a file with that
6716 name. If FILENAME is a number, prompt the user for the name of the file
6718 (interactive (list (ps-print-preprint current-prefix-arg)))
6719 (gnus-summary-select-article)
6720 (gnus-eval-in-buffer-window gnus-article-buffer
6721 (let ((buffer (generate-new-buffer " *print*")))
6724 (copy-to-buffer buffer (point-min) (point-max))
6726 (gnus-article-delete-invisible-text)
6727 (run-hooks 'gnus-ps-print-hook)
6728 (ps-print-buffer-with-faces filename))
6729 (kill-buffer buffer)))))
6731 (defun gnus-summary-show-article (&optional arg)
6732 "Force re-fetching of the current article.
6733 If ARG (the prefix) is non-nil, show the raw article without any
6734 article massaging functions being run."
6737 ;; Select the article the normal way.
6738 (gnus-summary-select-article nil 'force)
6739 ;; Bind the article treatment functions to nil.
6740 (let ((gnus-have-all-headers t)
6741 gnus-article-display-hook
6742 gnus-article-prepare-hook
6746 (gnus-summary-select-article nil 'force)))
6747 (gnus-summary-goto-subject gnus-current-article)
6748 (gnus-summary-position-point))
6750 (defun gnus-summary-verbose-headers (&optional arg)
6751 "Toggle permanent full header display.
6752 If ARG is a positive number, turn header display on.
6753 If ARG is a negative number, turn header display off."
6755 (setq gnus-show-all-headers
6756 (cond ((or (not (numberp arg))
6758 (not gnus-show-all-headers))
6761 (gnus-summary-show-article))
6763 (defun gnus-summary-toggle-header (&optional arg)
6764 "Show the headers if they are hidden, or hide them if they are shown.
6765 If ARG is a positive number, show the entire header.
6766 If ARG is a negative number, hide the unwanted header lines."
6769 (set-buffer gnus-article-buffer)
6770 (let* ((buffer-read-only nil)
6771 (inhibit-point-motion-hooks t)
6772 (hidden (text-property-any
6773 (goto-char (point-min)) (search-forward "\n\n")
6776 (goto-char (point-min))
6777 (when (search-forward "\n\n" nil t)
6778 (delete-region (point-min) (1- (point))))
6779 (goto-char (point-min))
6781 (set-buffer gnus-original-article-buffer)
6782 (goto-char (point-min))
6783 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
6784 (insert-buffer-substring gnus-original-article-buffer 1 e)
6785 (let ((article-inhibit-hiding t))
6786 (run-hooks 'gnus-article-display-hook))
6787 (when (or (not hidden) (and (numberp arg) (< arg 0)))
6788 (gnus-article-hide-headers)))))
6790 (defun gnus-summary-show-all-headers ()
6791 "Make all header lines visible."
6793 (gnus-article-show-all-headers))
6795 (defun gnus-summary-toggle-mime (&optional arg)
6796 "Toggle MIME processing.
6797 If ARG is a positive number, turn MIME processing on."
6799 (setq gnus-show-mime
6800 (if (null arg) (not gnus-show-mime)
6801 (> (prefix-numeric-value arg) 0)))
6802 (gnus-summary-select-article t 'force))
6804 (defun gnus-summary-caesar-message (&optional arg)
6805 "Caesar rotate the current article by 13.
6806 The numerical prefix specifies how many places to rotate each letter
6809 (gnus-summary-select-article)
6810 (let ((mail-header-separator ""))
6811 (gnus-eval-in-buffer-window gnus-article-buffer
6814 (let ((start (window-start))
6816 (message-caesar-buffer-body arg)
6817 (set-window-start (get-buffer-window (current-buffer)) start))))))
6819 (defun gnus-summary-stop-page-breaking ()
6820 "Stop page breaking in the current article."
6822 (gnus-summary-select-article)
6823 (gnus-eval-in-buffer-window gnus-article-buffer
6825 (when (gnus-visual-p 'page-marker)
6826 (let ((buffer-read-only nil))
6827 (gnus-remove-text-with-property 'gnus-prev)
6828 (gnus-remove-text-with-property 'gnus-next)))))
6830 (defun gnus-summary-move-article (&optional n to-newsgroup
6831 select-method action)
6832 "Move the current article to a different newsgroup.
6833 If N is a positive number, move the N next articles.
6834 If N is a negative number, move the N previous articles.
6835 If N is nil and any articles have been marked with the process mark,
6836 move those articles instead.
6837 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6838 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6839 re-spool using this method.
6841 For this function to work, both the current newsgroup and the
6842 newsgroup that you want to move to have to support the `request-move'
6843 and `request-accept' functions."
6846 (setq action 'move))
6847 ;; Disable marking as read.
6848 (let (gnus-mark-article-hook)
6849 (save-window-excursion
6850 (gnus-summary-select-article)))
6851 ;; Check whether the source group supports the required functions.
6852 (cond ((and (eq action 'move)
6853 (not (gnus-check-backend-function
6854 'request-move-article gnus-newsgroup-name)))
6855 (error "The current group does not support article moving"))
6856 ((and (eq action 'crosspost)
6857 (not (gnus-check-backend-function
6858 'request-replace-article gnus-newsgroup-name)))
6859 (error "The current group does not support article editing")))
6860 (let ((articles (gnus-summary-work-articles n))
6861 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
6862 (names '((move "Move" "Moving")
6863 (copy "Copy" "Copying")
6864 (crosspost "Crosspost" "Crossposting")))
6865 (copy-buf (save-excursion
6866 (nnheader-set-temp-buffer " *copy article*")))
6867 art-group to-method new-xref article to-groups)
6868 (unless (assq action names)
6869 (error "Unknown action %s" action))
6870 ;; Read the newsgroup name.
6871 (when (and (not to-newsgroup)
6872 (not select-method))
6874 (gnus-read-move-group-name
6875 (cadr (assq action names))
6876 (symbol-value (intern (format "gnus-current-%s-group" action)))
6878 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
6879 (setq to-method (or select-method
6880 (gnus-group-name-to-method to-newsgroup)))
6881 ;; Check the method we are to move this article to...
6882 (unless (gnus-check-backend-function
6883 'request-accept-article (car to-method))
6884 (error "%s does not support article copying" (car to-method)))
6885 (unless (gnus-check-server to-method)
6886 (error "Can't open server %s" (car to-method)))
6887 (gnus-message 6 "%s to %s: %s..."
6888 (caddr (assq action names))
6889 (or (car select-method) to-newsgroup) articles)
6891 (setq article (pop articles))
6895 ;; Move the article.
6897 ;; Remove this article from future suppression.
6898 (gnus-dup-unsuppress-article article)
6899 (gnus-request-move-article
6900 article ; Article to move
6901 gnus-newsgroup-name ; From newsgroup
6902 (nth 1 (gnus-find-method-for-group
6903 gnus-newsgroup-name)) ; Server
6904 (list 'gnus-request-accept-article
6905 to-newsgroup (list 'quote select-method)
6906 (not articles)) ; Accept form
6907 (not articles))) ; Only save nov last time
6908 ;; Copy the article.
6911 (set-buffer copy-buf)
6912 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6913 (gnus-request-accept-article
6914 to-newsgroup select-method (not articles))))
6915 ;; Crosspost the article.
6916 ((eq action 'crosspost)
6917 (let ((xref (message-tokenize-header
6918 (mail-header-xref (gnus-summary-article-header article))
6920 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
6923 (setq xref (list (system-name))))
6926 (mapconcat 'identity
6927 (delete "Xref:" (delete new-xref xref))
6931 (set-buffer copy-buf)
6932 ;; First put the article in the destination group.
6933 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6934 (when (consp (setq art-group
6935 (gnus-request-accept-article
6936 to-newsgroup select-method (not articles))))
6937 (setq new-xref (concat new-xref " " (car art-group)
6938 ":" (cdr art-group)))
6939 ;; Now we have the new Xrefs header, so we insert
6940 ;; it and replace the new article.
6941 (nnheader-replace-header "Xref" new-xref)
6942 (gnus-request-replace-article
6943 (cdr art-group) to-newsgroup (current-buffer))
6947 (gnus-message 1 "Couldn't %s article %s"
6948 (cadr (assq action names)) article))
6949 ((and (eq art-group 'junk)
6951 (gnus-summary-mark-article article gnus-canceled-mark)
6952 (gnus-message 4 "Deleted article %s" article))
6956 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
6958 (gnus-group-prefixed-name
6961 (gnus-find-method-for-group to-newsgroup)))
6962 gnus-newsrc-hashtb)))
6963 (info (nth 2 entry))
6964 (to-group (gnus-info-group info)))
6965 ;; Update the group that has been moved to.
6967 (memq action '(move copy)))
6968 (unless (member to-group to-groups)
6969 (push to-group to-groups))
6971 (unless (memq article gnus-newsgroup-unreads)
6973 info (gnus-add-to-range (gnus-info-read info)
6974 (list (cdr art-group)))))
6976 ;; Copy any marks over to the new group.
6977 (let ((marks gnus-article-mark-lists)
6978 (to-article (cdr art-group)))
6980 ;; See whether the article is to be put in the cache.
6981 (when gnus-use-cache
6982 (gnus-cache-possibly-enter-article
6984 (let ((header (copy-sequence
6985 (gnus-summary-article-header article))))
6986 (mail-header-set-number header to-article)
6988 (memq article gnus-newsgroup-marked)
6989 (memq article gnus-newsgroup-dormant)
6990 (memq article gnus-newsgroup-unreads)))
6992 (when (and (equal to-group gnus-newsgroup-name)
6993 (not (memq article gnus-newsgroup-unreads)))
6994 ;; Mark this article as read in this group.
6995 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
6996 (setcdr (gnus-active to-group) to-article)
6997 (setcdr gnus-newsgroup-active to-article))
7000 (when (memq article (symbol-value
7001 (intern (format "gnus-newsgroup-%s"
7003 ;; If the other group is the same as this group,
7004 ;; then we have to add the mark to the list.
7005 (when (equal to-group gnus-newsgroup-name)
7006 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7009 (intern (format "gnus-newsgroup-%s"
7011 ;; Copy the marks to other group.
7012 (gnus-add-marked-articles
7013 to-group (cdar marks) (list to-article) info))
7014 (setq marks (cdr marks)))
7017 (concat "(gnus-group-set-info '"
7018 (gnus-prin1-to-string (gnus-get-info to-group))
7021 ;; Update the Xref header in this article to point to
7022 ;; the new crossposted article we have just created.
7023 (when (eq action 'crosspost)
7025 (set-buffer copy-buf)
7026 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7027 (nnheader-replace-header "Xref" new-xref)
7028 (gnus-request-replace-article
7029 article gnus-newsgroup-name (current-buffer)))))
7031 (gnus-summary-goto-subject article)
7032 (when (eq action 'move)
7033 (gnus-summary-mark-article article gnus-canceled-mark))))
7034 (gnus-summary-remove-process-mark article))
7035 ;; Re-activate all groups that have been moved to.
7038 (set-buffer gnus-group-buffer)
7039 (when (gnus-group-goto-group (car to-groups) t)
7040 (gnus-group-get-new-news-this-group 1 t))
7043 (gnus-kill-buffer copy-buf)
7044 (gnus-summary-position-point)
7045 (gnus-set-mode-line 'summary)))
7047 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7048 "Move the current article to a different newsgroup.
7049 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7050 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7051 re-spool using this method."
7053 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7055 (defun gnus-summary-crosspost-article (&optional n)
7056 "Crosspost the current article to some other group."
7058 (gnus-summary-move-article n nil nil 'crosspost))
7060 (defcustom gnus-summary-respool-default-method nil
7061 "Default method for respooling an article.
7062 If nil, use to the current newsgroup method."
7063 :type `(choice (gnus-select-method :value (nnml ""))
7065 :group 'gnus-summary-mail)
7067 (defun gnus-summary-respool-article (&optional n method)
7068 "Respool the current article.
7069 The article will be squeezed through the mail spooling process again,
7070 which means that it will be put in some mail newsgroup or other
7071 depending on `nnmail-split-methods'.
7072 If N is a positive number, respool the N next articles.
7073 If N is a negative number, respool the N previous articles.
7074 If N is nil and any articles have been marked with the process mark,
7075 respool those articles instead.
7077 Respooling can be done both from mail groups and \"real\" newsgroups.
7078 In the former case, the articles in question will be moved from the
7079 current group into whatever groups they are destined to. In the
7080 latter case, they will be copied into the relevant groups."
7082 (list current-prefix-arg
7083 (let* ((methods (gnus-methods-using 'respool))
7085 (symbol-name (or gnus-summary-respool-default-method
7086 (car (gnus-find-method-for-group
7087 gnus-newsgroup-name)))))
7089 (gnus-completing-read
7090 methname "What backend do you want to use when respooling?"
7091 methods nil t nil 'gnus-mail-method-history))
7094 ((zerop (length (setq ms (gnus-servers-using-backend
7096 (list (intern method) ""))
7100 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7101 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7104 (error "No method given for respooling"))
7105 (if (assoc (symbol-name
7106 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7107 (gnus-methods-using 'respool))
7108 (gnus-summary-move-article n nil method)
7109 (gnus-summary-copy-article n nil method)))
7111 (defun gnus-summary-import-article (file)
7112 "Import a random file into a mail newsgroup."
7113 (interactive "fImport file: ")
7114 (let ((group gnus-newsgroup-name)
7115 (now (current-time))
7117 (unless (gnus-check-backend-function 'request-accept-article group)
7118 (error "%s does not support article importing" group))
7119 (or (file-readable-p file)
7120 (not (file-regular-p file))
7121 (error "Can't read %s" file))
7123 (set-buffer (get-buffer-create " *import file*"))
7124 (buffer-disable-undo (current-buffer))
7126 (insert-file-contents file)
7127 (goto-char (point-min))
7128 (unless (nnheader-article-p)
7129 ;; This doesn't look like an article, so we fudge some headers.
7130 (setq atts (file-attributes file)
7131 lines (count-lines (point-min) (point-max)))
7132 (insert "From: " (read-string "From: ") "\n"
7133 "Subject: " (read-string "Subject: ") "\n"
7134 "Date: " (timezone-make-date-arpa-standard
7135 (current-time-string (nth 5 atts))
7136 (current-time-zone now)
7137 (current-time-zone now))
7139 "Message-ID: " (message-make-message-id) "\n"
7140 "Lines: " (int-to-string lines) "\n"
7141 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7142 (gnus-request-accept-article group nil t)
7143 (kill-buffer (current-buffer)))))
7145 (defun gnus-summary-article-posted-p ()
7146 "Say whether the current (mail) article is available from `gnus-select-method' as well.
7147 This will be the case if the article has both been mailed and posted."
7149 (let ((id (mail-header-references (gnus-summary-article-header)))
7150 (gnus-override-method
7151 (or gnus-refer-article-method gnus-select-method)))
7152 (if (gnus-request-head id "")
7153 (gnus-message 2 "The current message was found on %s"
7154 gnus-override-method)
7155 (gnus-message 2 "The current message couldn't be found on %s"
7156 gnus-override-method)
7159 (defun gnus-summary-expire-articles (&optional now)
7160 "Expire all articles that are marked as expirable in the current group."
7162 (when (gnus-check-backend-function
7163 'request-expire-articles gnus-newsgroup-name)
7164 ;; This backend supports expiry.
7165 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7166 (expirable (if total
7168 ;; We need to update the info for
7169 ;; this group for `gnus-list-of-read-articles'
7170 ;; to give us the right answer.
7171 (run-hooks 'gnus-exit-group-hook)
7172 (gnus-summary-update-info)
7173 (gnus-list-of-read-articles gnus-newsgroup-name))
7174 (setq gnus-newsgroup-expirable
7175 (sort gnus-newsgroup-expirable '<))))
7176 (expiry-wait (if now 'immediate
7177 (gnus-group-find-parameter
7178 gnus-newsgroup-name 'expiry-wait)))
7181 ;; There are expirable articles in this group, so we run them
7182 ;; through the expiry process.
7183 (gnus-message 6 "Expiring articles...")
7184 ;; The list of articles that weren't expired is returned.
7186 (let ((nnmail-expiry-wait-function nil)
7187 (nnmail-expiry-wait expiry-wait))
7188 (setq es (gnus-request-expire-articles
7189 expirable gnus-newsgroup-name)))
7190 (setq es (gnus-request-expire-articles
7191 expirable gnus-newsgroup-name)))
7193 (setq gnus-newsgroup-expirable es))
7194 ;; We go through the old list of expirable, and mark all
7195 ;; really expired articles as nonexistent.
7196 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7197 (let ((gnus-use-cache nil))
7199 (unless (memq (car expirable) es)
7200 (when (gnus-data-find (car expirable))
7201 (gnus-summary-mark-article
7202 (car expirable) gnus-canceled-mark)))
7203 (setq expirable (cdr expirable)))))
7204 (gnus-message 6 "Expiring articles...done")))))
7206 (defun gnus-summary-expire-articles-now ()
7207 "Expunge all expirable articles in the current group.
7208 This means that *all* articles that are marked as expirable will be
7209 deleted forever, right now."
7211 (or gnus-expert-user
7213 "Are you really, really, really sure you want to delete all these messages? ")
7215 (gnus-summary-expire-articles t))
7217 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7218 (defun gnus-summary-delete-article (&optional n)
7219 "Delete the N next (mail) articles.
7220 This command actually deletes articles. This is not a marking
7221 command. The article will disappear forever from your life, never to
7223 If N is negative, delete backwards.
7224 If N is nil and articles have been marked with the process mark,
7225 delete these instead."
7227 (unless (gnus-check-backend-function 'request-expire-articles
7228 gnus-newsgroup-name)
7229 (error "The current newsgroup does not support article deletion"))
7230 ;; Compute the list of articles to delete.
7231 (let ((articles (gnus-summary-work-articles n))
7233 (if (and gnus-novice-user
7234 (not (gnus-yes-or-no-p
7235 (format "Do you really want to delete %s forever? "
7236 (if (> (length articles) 1)
7237 (format "these %s articles" (length articles))
7240 ;; Delete the articles.
7241 (setq not-deleted (gnus-request-expire-articles
7242 articles gnus-newsgroup-name 'force))
7244 (gnus-summary-remove-process-mark (car articles))
7245 ;; The backend might not have been able to delete the article
7247 (unless (memq (car articles) not-deleted)
7248 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7249 (setq articles (cdr articles)))
7251 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7252 (gnus-summary-position-point)
7253 (gnus-set-mode-line 'summary)
7256 (defun gnus-summary-edit-article (&optional force)
7257 "Edit the current article.
7258 This will have permanent effect only in mail groups.
7259 If FORCE is non-nil, allow editing of articles even in read-only
7263 (set-buffer gnus-summary-buffer)
7264 (gnus-set-global-variables)
7265 (when (and (not force)
7266 (gnus-group-read-only-p))
7267 (error "The current newsgroup does not support article editing"))
7268 ;; Select article if needed.
7269 (unless (eq (gnus-summary-article-number)
7270 gnus-current-article)
7271 (gnus-summary-select-article t))
7272 (gnus-article-date-original)
7273 (gnus-article-edit-article
7274 `(lambda (no-highlight)
7275 (gnus-summary-edit-article-done
7276 ,(or (mail-header-references gnus-current-headers) "")
7277 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))
7279 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7281 (defun gnus-summary-edit-article-done (&optional references read-only buffer
7283 "Make edits to the current article permanent."
7285 ;; Replace the article.
7286 (if (and (not read-only)
7287 (not (gnus-request-replace-article
7288 (cdr gnus-article-current) (car gnus-article-current)
7290 (error "Couldn't replace article")
7291 ;; Update the summary buffer.
7293 (equal (message-tokenize-header references " ")
7294 (message-tokenize-header
7295 (or (message-fetch-field "references") "") " ")))
7296 ;; We only have to update this line.
7299 (message-narrow-to-head)
7300 (let ((head (buffer-string))
7302 (nnheader-temp-write nil
7303 (insert (format "211 %d Article retrieved.\n"
7304 (cdr gnus-article-current)))
7307 (let ((nntp-server-buffer (current-buffer)))
7308 (setq header (car (gnus-get-newsgroup-headers
7310 (set-buffer gnus-summary-buffer)
7311 gnus-newsgroup-dependencies)
7314 (set-buffer gnus-summary-buffer)
7315 (gnus-data-set-header
7316 (gnus-data-find (cdr gnus-article-current))
7318 (gnus-summary-update-article-line
7319 (cdr gnus-article-current) header))))))
7321 (set-buffer (or buffer gnus-summary-buffer))
7322 (gnus-summary-update-article (cdr gnus-article-current)))
7323 ;; Prettify the article buffer again.
7324 (unless no-highlight
7326 (set-buffer gnus-article-buffer)
7327 (run-hooks 'gnus-article-display-hook)
7328 (set-buffer gnus-original-article-buffer)
7329 (gnus-request-article
7330 (cdr gnus-article-current)
7331 (car gnus-article-current) (current-buffer))))
7332 ;; Prettify the summary buffer line.
7333 (when (gnus-visual-p 'summary-highlight 'highlight)
7334 (run-hooks 'gnus-visual-mark-article-hook))))
7336 (defun gnus-summary-edit-wash (key)
7337 "Perform editing command in the article buffer."
7341 (message "%s" (concat (this-command-keys) "- "))
7344 (gnus-summary-edit-article)
7345 (execute-kbd-macro (concat (this-command-keys) key))
7346 (gnus-article-edit-done))
7350 (defun gnus-summary-respool-query (&optional silent)
7351 "Query where the respool algorithm would put this article."
7353 (let (gnus-mark-article-hook)
7354 (gnus-summary-select-article)
7356 (set-buffer gnus-original-article-buffer)
7358 (message-narrow-to-head)
7359 (let ((groups (nnmail-article-group 'identity)))
7362 (message "This message would go to %s"
7363 (mapconcat 'car groups ", "))
7364 (message "This message would go to no groups"))
7367 ;; Summary marking commands.
7369 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
7370 "Mark articles which has the same subject as read, and then select the next.
7371 If UNMARK is positive, remove any kind of mark.
7372 If UNMARK is negative, tick articles."
7375 (setq unmark (prefix-numeric-value unmark)))
7377 (gnus-summary-mark-same-subject
7378 (gnus-summary-article-subject) unmark)))
7379 ;; Select next unread article. If auto-select-same mode, should
7380 ;; select the first unread article.
7381 (gnus-summary-next-article t (and gnus-auto-select-same
7382 (gnus-summary-article-subject)))
7383 (gnus-message 7 "%d article%s marked as %s"
7384 count (if (= count 1) " is" "s are")
7385 (if unmark "unread" "read"))))
7387 (defun gnus-summary-kill-same-subject (&optional unmark)
7388 "Mark articles which has the same subject as read.
7389 If UNMARK is positive, remove any kind of mark.
7390 If UNMARK is negative, tick articles."
7393 (setq unmark (prefix-numeric-value unmark)))
7395 (gnus-summary-mark-same-subject
7396 (gnus-summary-article-subject) unmark)))
7397 ;; If marked as read, go to next unread subject.
7399 ;; Go to next unread subject.
7400 (gnus-summary-next-subject 1 t))
7401 (gnus-message 7 "%d articles are marked as %s"
7402 count (if unmark "unread" "read"))))
7404 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7405 "Mark articles with same SUBJECT as read, and return marked number.
7406 If optional argument UNMARK is positive, remove any kinds of marks.
7407 If optional argument UNMARK is negative, mark articles as unread instead."
7411 ((null unmark) ; Mark as read.
7414 (gnus-summary-mark-article-as-read gnus-killed-mark)
7415 (gnus-summary-show-thread) t)
7416 (gnus-summary-find-subject subject))
7417 (setq count (1+ count))))
7418 ((> unmark 0) ; Tick.
7421 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
7422 (gnus-summary-show-thread) t)
7423 (gnus-summary-find-subject subject))
7424 (setq count (1+ count))))
7425 (t ; Mark as unread.
7428 (gnus-summary-mark-article-as-unread gnus-unread-mark)
7429 (gnus-summary-show-thread) t)
7430 (gnus-summary-find-subject subject))
7431 (setq count (1+ count)))))
7432 (gnus-set-mode-line 'summary)
7433 ;; Return the number of marked articles.
7436 (defun gnus-summary-mark-as-processable (n &optional unmark)
7437 "Set the process mark on the next N articles.
7438 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7439 the process mark instead. The difference between N and the actual
7440 number of articles marked is returned."
7442 (let ((backward (< n 0))
7447 (gnus-summary-remove-process-mark
7448 (gnus-summary-article-number))
7449 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7450 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7453 (gnus-message 7 "No more articles"))
7454 (gnus-summary-recenter)
7455 (gnus-summary-position-point)
7458 (defun gnus-summary-unmark-as-processable (n)
7459 "Remove the process mark from the next N articles.
7460 If N is negative, unmark backward instead. The difference between N and
7461 the actual number of articles unmarked is returned."
7463 (gnus-summary-mark-as-processable n t))
7465 (defun gnus-summary-unmark-all-processable ()
7466 "Remove the process mark from all articles."
7469 (while gnus-newsgroup-processable
7470 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7471 (gnus-summary-position-point))
7473 (defun gnus-summary-mark-as-expirable (n)
7474 "Mark N articles forward as expirable.
7475 If N is negative, mark backward instead. The difference between N and
7476 the actual number of articles marked is returned."
7478 (gnus-summary-mark-forward n gnus-expirable-mark))
7480 (defun gnus-summary-mark-article-as-replied (article)
7481 "Mark ARTICLE replied and update the summary line."
7482 (push article gnus-newsgroup-replied)
7483 (let ((buffer-read-only nil))
7484 (when (gnus-summary-goto-subject article)
7485 (gnus-summary-update-secondary-mark article))))
7487 (defun gnus-summary-set-bookmark (article)
7488 "Set a bookmark in current article."
7489 (interactive (list (gnus-summary-article-number)))
7490 (when (or (not (get-buffer gnus-article-buffer))
7491 (not gnus-current-article)
7492 (not gnus-article-current)
7493 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7494 (error "No current article selected"))
7495 ;; Remove old bookmark, if one exists.
7496 (let ((old (assq article gnus-newsgroup-bookmarks)))
7498 (setq gnus-newsgroup-bookmarks
7499 (delq old gnus-newsgroup-bookmarks))))
7500 ;; Set the new bookmark, which is on the form
7501 ;; (article-number . line-number-in-body).
7505 (set-buffer gnus-article-buffer)
7509 (goto-char (point-min))
7510 (search-forward "\n\n" nil t)
7513 gnus-newsgroup-bookmarks)
7514 (gnus-message 6 "A bookmark has been added to the current article."))
7516 (defun gnus-summary-remove-bookmark (article)
7517 "Remove the bookmark from the current article."
7518 (interactive (list (gnus-summary-article-number)))
7519 ;; Remove old bookmark, if one exists.
7520 (let ((old (assq article gnus-newsgroup-bookmarks)))
7523 (setq gnus-newsgroup-bookmarks
7524 (delq old gnus-newsgroup-bookmarks))
7525 (gnus-message 6 "Removed bookmark."))
7526 (gnus-message 6 "No bookmark in current article."))))
7528 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7529 (defun gnus-summary-mark-as-dormant (n)
7530 "Mark N articles forward as dormant.
7531 If N is negative, mark backward instead. The difference between N and
7532 the actual number of articles marked is returned."
7534 (gnus-summary-mark-forward n gnus-dormant-mark))
7536 (defun gnus-summary-set-process-mark (article)
7537 "Set the process mark on ARTICLE and update the summary line."
7538 (setq gnus-newsgroup-processable
7540 (delq article gnus-newsgroup-processable)))
7541 (when (gnus-summary-goto-subject article)
7542 (gnus-summary-show-thread)
7543 (gnus-summary-update-secondary-mark article)))
7545 (defun gnus-summary-remove-process-mark (article)
7546 "Remove the process mark from ARTICLE and update the summary line."
7547 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7548 (when (gnus-summary-goto-subject article)
7549 (gnus-summary-show-thread)
7550 (gnus-summary-update-secondary-mark article)))
7552 (defun gnus-summary-set-saved-mark (article)
7553 "Set the process mark on ARTICLE and update the summary line."
7554 (push article gnus-newsgroup-saved)
7555 (when (gnus-summary-goto-subject article)
7556 (gnus-summary-update-secondary-mark article)))
7558 (defun gnus-summary-mark-forward (n &optional mark no-expire)
7559 "Mark N articles as read forwards.
7560 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
7561 The difference between N and the actual number of articles marked is
7564 (let ((backward (< n 0))
7565 (gnus-summary-goto-unread
7566 (and gnus-summary-goto-unread
7567 (not (eq gnus-summary-goto-unread 'never))
7568 (not (memq mark (list gnus-unread-mark
7569 gnus-ticked-mark gnus-dormant-mark)))))
7571 (mark (or mark gnus-del-mark)))
7573 (gnus-summary-mark-article nil mark no-expire)
7574 (zerop (gnus-summary-next-subject
7576 (and gnus-summary-goto-unread
7577 (not (eq gnus-summary-goto-unread 'never)))
7581 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
7582 (gnus-summary-recenter)
7583 (gnus-summary-position-point)
7584 (gnus-set-mode-line 'summary)
7587 (defun gnus-summary-mark-article-as-read (mark)
7588 "Mark the current article quickly as read with MARK."
7589 (let ((article (gnus-summary-article-number)))
7590 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7591 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7592 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7593 (push (cons article mark) gnus-newsgroup-reads)
7594 ;; Possibly remove from cache, if that is used.
7595 (when gnus-use-cache
7596 (gnus-cache-enter-remove-article article))
7597 ;; Allow the backend to change the mark.
7598 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7599 ;; Check for auto-expiry.
7600 (when (and gnus-newsgroup-auto-expire
7601 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7602 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7603 (= mark gnus-ancient-mark)
7604 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7605 (= mark gnus-duplicate-mark)))
7606 (setq mark gnus-expirable-mark)
7607 (push article gnus-newsgroup-expirable))
7608 ;; Set the mark in the buffer.
7609 (gnus-summary-update-mark mark 'unread)
7612 (defun gnus-summary-mark-article-as-unread (mark)
7613 "Mark the current article quickly as unread with MARK."
7614 (let ((article (gnus-summary-article-number)))
7617 (gnus-error 1 "Can't mark negative article numbers")
7619 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7620 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7621 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
7622 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
7623 (cond ((= mark gnus-ticked-mark)
7624 (push article gnus-newsgroup-marked))
7625 ((= mark gnus-dormant-mark)
7626 (push article gnus-newsgroup-dormant))
7628 (push article gnus-newsgroup-unreads)))
7629 (setq gnus-newsgroup-reads
7630 (delq (assq article gnus-newsgroup-reads)
7631 gnus-newsgroup-reads))
7633 ;; See whether the article is to be put in the cache.
7635 (vectorp (gnus-summary-article-header article))
7637 (gnus-cache-possibly-enter-article
7638 gnus-newsgroup-name article
7639 (gnus-summary-article-header article)
7640 (= mark gnus-ticked-mark)
7641 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7644 (gnus-summary-update-mark mark 'unread)
7647 (defun gnus-summary-mark-article (&optional article mark no-expire)
7648 "Mark ARTICLE with MARK. MARK can be any character.
7649 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
7650 `??' (dormant) and `?E' (expirable).
7651 If MARK is nil, then the default character `?D' is used.
7652 If ARTICLE is nil, then the article on the current line will be
7654 ;; The mark might be a string.
7655 (when (stringp mark)
7656 (setq mark (aref mark 0)))
7657 ;; If no mark is given, then we check auto-expiring.
7658 (and (not no-expire)
7659 gnus-newsgroup-auto-expire
7661 (and (gnus-characterp mark)
7662 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7663 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7664 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7665 (= mark gnus-duplicate-mark))))
7666 (setq mark gnus-expirable-mark))
7667 (let* ((mark (or mark gnus-del-mark))
7668 (article (or article (gnus-summary-article-number))))
7670 (error "No article on current line"))
7671 (if (not (if (or (= mark gnus-unread-mark)
7672 (= mark gnus-ticked-mark)
7673 (= mark gnus-dormant-mark))
7674 (gnus-mark-article-as-unread article mark)
7675 (gnus-mark-article-as-read article mark)))
7677 ;; See whether the article is to be put in the cache.
7679 (not (= mark gnus-canceled-mark))
7680 (vectorp (gnus-summary-article-header article))
7682 (gnus-cache-possibly-enter-article
7683 gnus-newsgroup-name article
7684 (gnus-summary-article-header article)
7685 (= mark gnus-ticked-mark)
7686 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7688 (when (gnus-summary-goto-subject article nil t)
7689 (let ((buffer-read-only nil))
7690 (gnus-summary-show-thread)
7692 (gnus-summary-update-mark mark 'unread)
7695 (defun gnus-summary-update-secondary-mark (article)
7696 "Update the secondary (read, process, cache) mark."
7697 (gnus-summary-update-mark
7698 (cond ((memq article gnus-newsgroup-processable)
7700 ((memq article gnus-newsgroup-cached)
7702 ((memq article gnus-newsgroup-replied)
7704 ((memq article gnus-newsgroup-saved)
7706 (t gnus-unread-mark))
7708 (when (gnus-visual-p 'summary-highlight 'highlight)
7709 (run-hooks 'gnus-summary-update-hook))
7712 (defun gnus-summary-update-mark (mark type)
7713 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
7714 (buffer-read-only nil))
7715 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
7716 (when (looking-at "\r")
7719 (<= (+ forward (point)) (point-max)))
7720 ;; Go to the right position on the line.
7721 (goto-char (+ forward (point)))
7722 ;; Replace the old mark with the new mark.
7723 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
7724 ;; Optionally update the marks by some user rule.
7725 (when (eq type 'unread)
7727 (gnus-data-find (gnus-summary-article-number)) mark)
7728 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
7730 (defun gnus-mark-article-as-read (article &optional mark)
7731 "Enter ARTICLE in the pertinent lists and remove it from others."
7732 ;; Make the article expirable.
7733 (let ((mark (or mark gnus-del-mark)))
7734 (if (= mark gnus-expirable-mark)
7735 (push article gnus-newsgroup-expirable)
7736 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
7737 ;; Remove from unread and marked lists.
7738 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7739 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7740 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7741 (push (cons article mark) gnus-newsgroup-reads)
7742 ;; Possibly remove from cache, if that is used.
7743 (when gnus-use-cache
7744 (gnus-cache-enter-remove-article article))))
7746 (defun gnus-mark-article-as-unread (article &optional mark)
7747 "Enter ARTICLE in the pertinent lists and remove it from others."
7748 (let ((mark (or mark gnus-ticked-mark)))
7751 (gnus-error 1 "Can't mark negative article numbers")
7753 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
7754 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
7755 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
7756 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7758 ;; Unsuppress duplicates?
7759 (when gnus-suppress-duplicates
7760 (gnus-dup-unsuppress-article article))
7762 (cond ((= mark gnus-ticked-mark)
7763 (push article gnus-newsgroup-marked))
7764 ((= mark gnus-dormant-mark)
7765 (push article gnus-newsgroup-dormant))
7767 (push article gnus-newsgroup-unreads)))
7768 (setq gnus-newsgroup-reads
7769 (delq (assq article gnus-newsgroup-reads)
7770 gnus-newsgroup-reads))
7773 (defalias 'gnus-summary-mark-as-unread-forward
7774 'gnus-summary-tick-article-forward)
7775 (make-obsolete 'gnus-summary-mark-as-unread-forward
7776 'gnus-summary-tick-article-forward)
7777 (defun gnus-summary-tick-article-forward (n)
7778 "Tick N articles forwards.
7779 If N is negative, tick backwards instead.
7780 The difference between N and the number of articles ticked is returned."
7782 (gnus-summary-mark-forward n gnus-ticked-mark))
7784 (defalias 'gnus-summary-mark-as-unread-backward
7785 'gnus-summary-tick-article-backward)
7786 (make-obsolete 'gnus-summary-mark-as-unread-backward
7787 'gnus-summary-tick-article-backward)
7788 (defun gnus-summary-tick-article-backward (n)
7789 "Tick N articles backwards.
7790 The difference between N and the number of articles ticked is returned."
7792 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
7794 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7795 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7796 (defun gnus-summary-tick-article (&optional article clear-mark)
7797 "Mark current article as unread.
7798 Optional 1st argument ARTICLE specifies article number to be marked as unread.
7799 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
7801 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
7804 (defun gnus-summary-mark-as-read-forward (n)
7805 "Mark N articles as read forwards.
7806 If N is negative, mark backwards instead.
7807 The difference between N and the actual number of articles marked is
7810 (gnus-summary-mark-forward n gnus-del-mark t))
7812 (defun gnus-summary-mark-as-read-backward (n)
7813 "Mark the N articles as read backwards.
7814 The difference between N and the actual number of articles marked is
7817 (gnus-summary-mark-forward (- n) gnus-del-mark t))
7819 (defun gnus-summary-mark-as-read (&optional article mark)
7820 "Mark current article as read.
7821 ARTICLE specifies the article to be marked as read.
7822 MARK specifies a string to be inserted at the beginning of the line."
7823 (gnus-summary-mark-article article mark))
7825 (defun gnus-summary-clear-mark-forward (n)
7826 "Clear marks from N articles forward.
7827 If N is negative, clear backward instead.
7828 The difference between N and the number of marks cleared is returned."
7830 (gnus-summary-mark-forward n gnus-unread-mark))
7832 (defun gnus-summary-clear-mark-backward (n)
7833 "Clear marks from N articles backward.
7834 The difference between N and the number of marks cleared is returned."
7836 (gnus-summary-mark-forward (- n) gnus-unread-mark))
7838 (defun gnus-summary-mark-unread-as-read ()
7839 "Intended to be used by `gnus-summary-mark-article-hook'."
7840 (when (memq gnus-current-article gnus-newsgroup-unreads)
7841 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
7843 (defun gnus-summary-mark-read-and-unread-as-read ()
7844 "Intended to be used by `gnus-summary-mark-article-hook'."
7845 (let ((mark (gnus-summary-article-mark)))
7846 (when (or (gnus-unread-mark-p mark)
7847 (gnus-read-mark-p mark))
7848 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
7850 (defun gnus-summary-mark-region-as-read (point mark all)
7851 "Mark all unread articles between point and mark as read.
7852 If given a prefix, mark all articles between point and mark as read,
7853 even ticked and dormant ones."
7854 (interactive "r\nP")
7863 (memq (setq article (gnus-summary-article-number))
7864 gnus-newsgroup-unreads))
7865 (gnus-summary-mark-article article gnus-del-mark))
7867 (gnus-summary-find-next))))))
7869 (defun gnus-summary-mark-below (score mark)
7870 "Mark articles with score less than SCORE with MARK."
7871 (interactive "P\ncMark: ")
7872 (setq score (if score
7873 (prefix-numeric-value score)
7874 (or gnus-summary-default-score 0)))
7876 (set-buffer gnus-summary-buffer)
7877 (goto-char (point-min))
7880 (and (< (gnus-summary-article-score) score)
7881 (gnus-summary-mark-article nil mark))
7882 (gnus-summary-find-next)))))
7884 (defun gnus-summary-kill-below (&optional score)
7885 "Mark articles with score below SCORE as read."
7887 (gnus-summary-mark-below score gnus-killed-mark))
7889 (defun gnus-summary-clear-above (&optional score)
7890 "Clear all marks from articles with score above SCORE."
7892 (gnus-summary-mark-above score gnus-unread-mark))
7894 (defun gnus-summary-tick-above (&optional score)
7895 "Tick all articles with score above SCORE."
7897 (gnus-summary-mark-above score gnus-ticked-mark))
7899 (defun gnus-summary-mark-above (score mark)
7900 "Mark articles with score over SCORE with MARK."
7901 (interactive "P\ncMark: ")
7902 (setq score (if score
7903 (prefix-numeric-value score)
7904 (or gnus-summary-default-score 0)))
7906 (set-buffer gnus-summary-buffer)
7907 (goto-char (point-min))
7909 (when (> (gnus-summary-article-score) score)
7910 (gnus-summary-mark-article nil mark))
7912 (gnus-summary-find-next)))))
7914 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7915 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
7916 (defun gnus-summary-limit-include-expunged (&optional no-error)
7917 "Display all the hidden articles that were expunged for low scores."
7919 (let ((buffer-read-only nil))
7920 (let ((scored gnus-newsgroup-scored)
7923 (unless (gnus-summary-goto-subject (caar scored))
7924 (and (setq h (gnus-summary-article-header (caar scored)))
7925 (< (cdar scored) gnus-summary-expunge-below)
7927 (setq scored (cdr scored)))
7929 (when (not no-error)
7930 (error "No expunged articles hidden"))
7931 (goto-char (point-min))
7932 (gnus-summary-prepare-unthreaded (nreverse headers))
7933 (goto-char (point-min))
7934 (gnus-summary-position-point)
7937 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
7938 "Mark all unread articles in this newsgroup as read.
7939 If prefix argument ALL is non-nil, ticked and dormant articles will
7940 also be marked as read.
7941 If QUIETLY is non-nil, no questions will be asked.
7942 If TO-HERE is non-nil, it should be a point in the buffer. All
7943 articles before this point will be marked as read.
7944 Note that this function will only catch up the unread article
7945 in the current summary buffer limitation.
7946 The number of articles marked as read is returned."
7951 (not gnus-interactive-catchup) ;Without confirmation?
7955 "Mark absolutely all articles as read? "
7956 "Mark all unread articles as read? ")))
7958 (not gnus-newsgroup-adaptive)
7959 (not gnus-newsgroup-auto-expire)
7960 (not gnus-suppress-duplicates)
7961 (or (not gnus-use-cache)
7962 (eq gnus-use-cache 'passive)))
7965 (setq gnus-newsgroup-marked nil
7966 gnus-newsgroup-dormant nil))
7967 (setq gnus-newsgroup-unreads nil))
7968 ;; We actually mark all articles as canceled, which we
7969 ;; have to do when using auto-expiry or adaptive scoring.
7970 (gnus-summary-show-all-threads)
7971 (when (gnus-summary-first-subject (not all))
7973 (if to-here (< (point) to-here) t)
7974 (gnus-summary-mark-article-as-read gnus-catchup-mark)
7975 (gnus-summary-find-next (not all)))))
7976 (gnus-set-mode-line 'summary))
7978 (gnus-summary-position-point)))
7980 (defun gnus-summary-catchup-to-here (&optional all)
7981 "Mark all unticked articles before the current one as read.
7982 If ALL is non-nil, also mark ticked and dormant articles as read."
7985 (gnus-save-hidden-threads
7986 (let ((beg (point)))
7987 ;; We check that there are unread articles.
7988 (when (or all (gnus-summary-find-prev))
7989 (gnus-summary-catchup all t beg)))))
7990 (gnus-summary-position-point))
7992 (defun gnus-summary-catchup-all (&optional quietly)
7993 "Mark all articles in this newsgroup as read."
7995 (gnus-summary-catchup t quietly))
7997 (defun gnus-summary-catchup-and-exit (&optional all quietly)
7998 "Mark all articles not marked as unread in this newsgroup as read, then exit.
7999 If prefix argument ALL is non-nil, all articles are marked as read."
8001 (when (gnus-summary-catchup all quietly nil 'fast)
8002 ;; Select next newsgroup or exit.
8003 (if (eq gnus-auto-select-next 'quietly)
8004 (gnus-summary-next-group nil)
8005 (gnus-summary-exit))))
8007 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8008 "Mark all articles in this newsgroup as read, and then exit."
8010 (gnus-summary-catchup-and-exit t quietly))
8012 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
8013 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8014 "Mark all articles in this group as read and select the next group.
8015 If given a prefix, mark all articles, unread as well as ticked, as
8019 (gnus-summary-catchup all))
8020 (gnus-summary-next-article t nil nil t))
8022 ;; Thread-based commands.
8024 (defun gnus-summary-articles-in-thread (&optional article)
8025 "Return a list of all articles in the current thread.
8026 If ARTICLE is non-nil, return all articles in the thread that starts
8028 (let* ((article (or article (gnus-summary-article-number)))
8029 (data (gnus-data-find-list article))
8030 (top-level (gnus-data-level (car data)))
8032 (cond ((null gnus-thread-operation-ignore-subject)
8033 (gnus-simplify-subject-re
8034 (mail-header-subject (gnus-data-header (car data)))))
8035 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8036 (gnus-simplify-subject-fuzzy
8037 (mail-header-subject (gnus-data-header (car data)))))
8039 (end-point (save-excursion
8040 (if (gnus-summary-go-to-next-thread)
8041 (point) (point-max))))
8044 (< (gnus-data-pos (car data)) end-point))
8045 (when (or (not top-subject)
8046 (string= top-subject
8047 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8048 (gnus-simplify-subject-fuzzy
8049 (mail-header-subject
8050 (gnus-data-header (car data))))
8051 (gnus-simplify-subject-re
8052 (mail-header-subject
8053 (gnus-data-header (car data)))))))
8054 (push (gnus-data-number (car data)) articles))
8055 (unless (and (setq data (cdr data))
8056 (> (gnus-data-level (car data)) top-level))
8058 ;; Return the list of articles.
8059 (nreverse articles)))
8061 (defun gnus-summary-rethread-current ()
8062 "Rethread the thread the current article is part of."
8064 (let* ((gnus-show-threads t)
8065 (article (gnus-summary-article-number))
8066 (id (mail-header-id (gnus-summary-article-header)))
8067 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8069 (error "No article on the current line"))
8070 (gnus-rebuild-thread id)
8071 (gnus-summary-goto-subject article)))
8073 (defun gnus-summary-reparent-thread ()
8074 "Make the current article child of the marked (or previous) article.
8076 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8077 is non-nil or the Subject: of both articles are the same."
8079 (unless (not (gnus-group-read-only-p))
8080 (error "The current newsgroup does not support article editing"))
8081 (unless (<= (length gnus-newsgroup-processable) 1)
8082 (error "No more than one article may be marked"))
8083 (save-window-excursion
8084 (let ((gnus-article-buffer " *reparent*")
8085 (current-article (gnus-summary-article-number))
8086 ;; First grab the marked article, otherwise one line up.
8087 (parent-article (if (not (null gnus-newsgroup-processable))
8088 (car gnus-newsgroup-processable)
8090 (if (eq (forward-line -1) 0)
8091 (gnus-summary-article-number)
8092 (error "Beginning of summary buffer"))))))
8093 (unless (not (eq current-article parent-article))
8094 (error "An article may not be self-referential"))
8095 (let ((message-id (mail-header-id
8096 (gnus-summary-article-header parent-article))))
8097 (unless (and message-id (not (equal message-id "")))
8098 (error "No message-id in desired parent"))
8099 (gnus-summary-select-article t t nil current-article)
8100 (set-buffer gnus-original-article-buffer)
8101 (let ((buf (format "%s" (buffer-string))))
8102 (nnheader-temp-write nil
8104 (goto-char (point-min))
8105 (if (re-search-forward "^References: " nil t)
8107 (re-search-forward "^[^ \t]" nil t)
8110 (insert " " message-id))
8111 (insert "References: " message-id "\n"))
8112 (unless (gnus-request-replace-article
8113 current-article (car gnus-article-current)
8115 (error "Couldn't replace article"))))
8116 (set-buffer gnus-summary-buffer)
8117 (gnus-summary-unmark-all-processable)
8118 (gnus-summary-update-article current-article)
8119 (gnus-summary-rethread-current)
8120 (gnus-message 3 "Article %d is now the child of article %d"
8121 current-article parent-article)))))
8123 (defun gnus-summary-toggle-threads (&optional arg)
8124 "Toggle showing conversation threads.
8125 If ARG is positive number, turn showing conversation threads on."
8127 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8128 (setq gnus-show-threads
8129 (if (null arg) (not gnus-show-threads)
8130 (> (prefix-numeric-value arg) 0)))
8131 (gnus-summary-prepare)
8132 (gnus-summary-goto-subject current)
8133 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8134 (gnus-summary-position-point)))
8136 (defun gnus-summary-show-all-threads ()
8140 (let ((buffer-read-only nil))
8141 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8142 (gnus-summary-position-point))
8144 (defun gnus-summary-show-thread ()
8145 "Show thread subtrees.
8146 Returns nil if no thread was there to be shown."
8148 (let ((buffer-read-only nil)
8150 ;; first goto end then to beg, to have point at beg after let
8151 (end (progn (end-of-line) (point)))
8152 (beg (progn (beginning-of-line) (point))))
8154 ;; Any hidden lines here?
8155 (search-forward "\r" end t)
8156 (subst-char-in-region beg end ?\^M ?\n t)
8158 (gnus-summary-position-point))))
8160 (defun gnus-summary-hide-all-threads ()
8161 "Hide all thread subtrees."
8164 (goto-char (point-min))
8165 (gnus-summary-hide-thread)
8166 (while (zerop (gnus-summary-next-thread 1 t))
8167 (gnus-summary-hide-thread)))
8168 (gnus-summary-position-point))
8170 (defun gnus-summary-hide-thread ()
8171 "Hide thread subtrees.
8172 Returns nil if no threads were there to be hidden."
8174 (let ((buffer-read-only nil)
8176 (article (gnus-summary-article-number)))
8178 ;; Go forward until either the buffer ends or the subthread
8180 (when (and (not (eobp))
8181 (or (zerop (gnus-summary-next-thread 1 t))
8182 (goto-char (point-max))))
8184 (if (and (> (point) start)
8185 (search-backward "\n" start t))
8187 (subst-char-in-region start (point) ?\n ?\^M)
8188 (gnus-summary-goto-subject article))
8191 ;;(gnus-summary-position-point)
8194 (defun gnus-summary-go-to-next-thread (&optional previous)
8195 "Go to the same level (or less) next thread.
8196 If PREVIOUS is non-nil, go to previous thread instead.
8197 Return the article number moved to, or nil if moving was impossible."
8198 (let ((level (gnus-summary-thread-level))
8199 (way (if previous -1 1))
8202 (while (and (not (eobp))
8203 (< level (gnus-summary-thread-level)))
8211 (gnus-summary-article-number)
8214 (defun gnus-summary-next-thread (n &optional silent)
8215 "Go to the same level next N'th thread.
8216 If N is negative, search backward instead.
8217 Returns the difference between N and the number of skips actually
8220 If SILENT, don't output messages."
8222 (let ((backward (< n 0))
8225 (gnus-summary-go-to-next-thread backward))
8228 (gnus-summary-position-point))
8229 (when (and (not silent) (/= 0 n))
8230 (gnus-message 7 "No more threads"))
8233 (defun gnus-summary-prev-thread (n)
8234 "Go to the same level previous N'th thread.
8235 Returns the difference between N and the number of skips actually
8238 (gnus-summary-next-thread (- n)))
8240 (defun gnus-summary-go-down-thread ()
8241 "Go down one level in the current thread."
8242 (let ((children (gnus-summary-article-children)))
8244 (gnus-summary-goto-subject (car children)))))
8246 (defun gnus-summary-go-up-thread ()
8247 "Go up one level in the current thread."
8248 (let ((parent (gnus-summary-article-parent)))
8250 (gnus-summary-goto-subject parent))))
8252 (defun gnus-summary-down-thread (n)
8253 "Go down thread N steps.
8254 If N is negative, go up instead.
8255 Returns the difference between N and how many steps down that were
8261 (if up (gnus-summary-go-up-thread)
8262 (gnus-summary-go-down-thread)))
8264 (gnus-summary-position-point)
8266 (gnus-message 7 "Can't go further"))
8269 (defun gnus-summary-up-thread (n)
8270 "Go up thread N steps.
8271 If N is negative, go up instead.
8272 Returns the difference between N and how many steps down that were
8275 (gnus-summary-down-thread (- n)))
8277 (defun gnus-summary-top-thread ()
8278 "Go to the top of the thread."
8280 (while (gnus-summary-go-up-thread))
8281 (gnus-summary-article-number))
8283 (defun gnus-summary-kill-thread (&optional unmark)
8284 "Mark articles under current thread as read.
8285 If the prefix argument is positive, remove any kinds of marks.
8286 If the prefix argument is negative, tick articles instead."
8289 (setq unmark (prefix-numeric-value unmark)))
8290 (let ((articles (gnus-summary-articles-in-thread)))
8292 ;; Expand the thread.
8293 (gnus-summary-show-thread)
8294 ;; Mark all the articles.
8296 (gnus-summary-goto-subject (car articles))
8297 (cond ((null unmark)
8298 (gnus-summary-mark-article-as-read gnus-killed-mark))
8300 (gnus-summary-mark-article-as-unread gnus-unread-mark))
8302 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
8303 (setq articles (cdr articles))))
8304 ;; Hide killed subtrees.
8306 gnus-thread-hide-killed
8307 (gnus-summary-hide-thread))
8308 ;; If marked as read, go to next unread subject.
8310 ;; Go to next unread subject.
8311 (gnus-summary-next-subject 1 t)))
8312 (gnus-set-mode-line 'summary))
8314 ;; Summary sorting commands
8316 (defun gnus-summary-sort-by-number (&optional reverse)
8317 "Sort the summary buffer by article number.
8318 Argument REVERSE means reverse order."
8320 (gnus-summary-sort 'number reverse))
8322 (defun gnus-summary-sort-by-author (&optional reverse)
8323 "Sort the summary buffer by author name alphabetically.
8324 If case-fold-search is non-nil, case of letters is ignored.
8325 Argument REVERSE means reverse order."
8327 (gnus-summary-sort 'author reverse))
8329 (defun gnus-summary-sort-by-subject (&optional reverse)
8330 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8331 If case-fold-search is non-nil, case of letters is ignored.
8332 Argument REVERSE means reverse order."
8334 (gnus-summary-sort 'subject reverse))
8336 (defun gnus-summary-sort-by-date (&optional reverse)
8337 "Sort the summary buffer by date.
8338 Argument REVERSE means reverse order."
8340 (gnus-summary-sort 'date reverse))
8342 (defun gnus-summary-sort-by-score (&optional reverse)
8343 "Sort the summary buffer by score.
8344 Argument REVERSE means reverse order."
8346 (gnus-summary-sort 'score reverse))
8348 (defun gnus-summary-sort-by-lines (&optional reverse)
8349 "Sort the summary buffer by article length.
8350 Argument REVERSE means reverse order."
8352 (gnus-summary-sort 'lines reverse))
8354 (defun gnus-summary-sort (predicate reverse)
8355 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
8356 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
8357 (article (intern (format "gnus-article-sort-by-%s" predicate)))
8358 (gnus-thread-sort-functions
8364 (gnus-article-sort-functions
8369 (,article t2 t1)))))
8371 (gnus-summary-prepare-hook nil))
8372 ;; We do the sorting by regenerating the threads.
8373 (gnus-summary-prepare)
8374 ;; Hide subthreads if needed.
8375 (when (and gnus-show-threads gnus-thread-hide-subtree)
8376 (gnus-summary-hide-all-threads))))
8378 ;; Summary saving commands.
8380 (defun gnus-summary-save-article (&optional n not-saved)
8381 "Save the current article using the default saver function.
8382 If N is a positive number, save the N next articles.
8383 If N is a negative number, save the N previous articles.
8384 If N is nil and any articles have been marked with the process mark,
8385 save those articles instead.
8386 The variable `gnus-default-article-saver' specifies the saver function."
8388 (let* ((articles (gnus-summary-work-articles n))
8389 (save-buffer (save-excursion
8390 (nnheader-set-temp-buffer " *Gnus Save*")))
8391 (num (length articles))
8392 header article file)
8394 (setq header (gnus-summary-article-header
8395 (setq article (pop articles))))
8396 (if (not (vectorp header))
8397 ;; This is a pseudo-article.
8398 (if (assq 'name header)
8399 (gnus-copy-file (cdr (assq 'name header)))
8400 (gnus-message 1 "Article %d is unsaveable" article))
8401 ;; This is a real article.
8402 (save-window-excursion
8403 (gnus-summary-select-article t nil nil article))
8405 (set-buffer save-buffer)
8407 (insert-buffer-substring gnus-original-article-buffer))
8408 (setq file (gnus-article-save save-buffer file num))
8409 (gnus-summary-remove-process-mark article)
8411 (gnus-summary-set-saved-mark article))))
8412 (gnus-kill-buffer save-buffer)
8413 (gnus-summary-position-point)
8414 (gnus-set-mode-line 'summary)
8417 (defun gnus-summary-pipe-output (&optional arg)
8418 "Pipe the current article to a subprocess.
8419 If N is a positive number, pipe the N next articles.
8420 If N is a negative number, pipe the N previous articles.
8421 If N is nil and any articles have been marked with the process mark,
8422 pipe those articles instead."
8424 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8425 (gnus-summary-save-article arg t))
8426 (gnus-configure-windows 'pipe))
8428 (defun gnus-summary-save-article-mail (&optional arg)
8429 "Append the current article to an mail file.
8430 If N is a positive number, save the N next articles.
8431 If N is a negative number, save the N previous articles.
8432 If N is nil and any articles have been marked with the process mark,
8433 save those articles instead."
8435 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8436 (gnus-summary-save-article arg)))
8438 (defun gnus-summary-save-article-rmail (&optional arg)
8439 "Append the current article to an rmail file.
8440 If N is a positive number, save the N next articles.
8441 If N is a negative number, save the N previous articles.
8442 If N is nil and any articles have been marked with the process mark,
8443 save those articles instead."
8445 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
8446 (gnus-summary-save-article arg)))
8448 (defun gnus-summary-save-article-file (&optional arg)
8449 "Append the current article to a file.
8450 If N is a positive number, save the N next articles.
8451 If N is a negative number, save the N previous articles.
8452 If N is nil and any articles have been marked with the process mark,
8453 save those articles instead."
8455 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8456 (gnus-summary-save-article arg)))
8458 (defun gnus-summary-write-article-file (&optional arg)
8459 "Write the current article to a file, deleting the previous file.
8460 If N is a positive number, save the N next articles.
8461 If N is a negative number, save the N previous articles.
8462 If N is nil and any articles have been marked with the process mark,
8463 save those articles instead."
8465 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
8466 (gnus-summary-save-article arg)))
8468 (defun gnus-summary-save-article-body-file (&optional arg)
8469 "Append the current article body to a file.
8470 If N is a positive number, save the N next articles.
8471 If N is a negative number, save the N previous articles.
8472 If N is nil and any articles have been marked with the process mark,
8473 save those articles instead."
8475 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
8476 (gnus-summary-save-article arg)))
8478 (defun gnus-summary-pipe-message (program)
8479 "Pipe the current article through PROGRAM."
8480 (interactive "sProgram: ")
8481 (gnus-summary-select-article)
8482 (let ((mail-header-separator "")
8483 (art-buf (get-buffer gnus-article-buffer)))
8484 (gnus-eval-in-buffer-window gnus-article-buffer
8487 (let ((start (window-start))
8489 (message-pipe-buffer-body program)
8490 (set-window-start (get-buffer-window (current-buffer)) start))))))
8492 (defun gnus-get-split-value (methods)
8493 "Return a value based on the split METHODS."
8494 (let (split-name method result match)
8497 (set-buffer gnus-original-article-buffer)
8499 (nnheader-narrow-to-headers)
8501 (goto-char (point-min))
8502 (setq method (pop methods))
8503 (setq match (car method))
8506 ;; Regular expression.
8508 (re-search-forward match nil t)))
8509 ((gnus-functionp match)
8513 (setq result (funcall match gnus-newsgroup-name))))
8518 (setq result (eval match)))))
8519 (setq split-name (append (cdr method) split-name))
8520 (cond ((stringp result)
8521 (push (expand-file-name
8522 result gnus-article-save-directory)
8525 (setq split-name (append result split-name)))))))))
8528 (defun gnus-valid-move-group-p (group)
8533 (car (gnus-find-method-for-group
8534 (symbol-name group))))
8535 gnus-valid-select-methods))))
8537 (defun gnus-read-move-group-name (prompt default articles prefix)
8538 "Read a group name."
8539 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
8540 (minibuffer-confirm-incomplete nil) ; XEmacs
8544 (if (> (length articles) 1)
8545 (format "these %d articles" (length articles))
8550 (gnus-completing-read default prom
8552 'gnus-valid-move-group-p
8554 'gnus-group-history))
8555 ((= 1 (length split-name))
8556 (gnus-completing-read (car split-name) prom
8558 'gnus-valid-move-group-p
8560 'gnus-group-history))
8562 (gnus-completing-read nil prom
8563 (mapcar (lambda (el) (list el))
8564 (nreverse split-name))
8566 'gnus-group-history)))))
8568 (if (or (string= to-newsgroup "")
8569 (string= to-newsgroup prefix))
8570 (setq to-newsgroup default))
8571 (unless to-newsgroup
8572 (error "No group name entered"))
8573 (or (gnus-active to-newsgroup)
8574 (gnus-activate-group to-newsgroup)
8575 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
8577 (or (and (gnus-request-create-group
8578 to-newsgroup (gnus-group-name-to-method to-newsgroup))
8579 (gnus-activate-group to-newsgroup nil nil
8580 (gnus-group-name-to-method
8582 (error "Couldn't create group %s" to-newsgroup)))
8583 (error "No such group: %s" to-newsgroup)))
8586 ;; Summary extract commands
8588 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
8589 (let ((buffer-read-only nil)
8590 (article (gnus-summary-article-number))
8592 (unless (gnus-summary-goto-subject article)
8593 (error "No such article: %d" article))
8594 (gnus-summary-position-point)
8595 ;; If all commands are to be bunched up on one line, we collect
8597 (unless gnus-view-pseudos-separately
8598 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
8601 (setq action (cdr (assq 'action (car ps))))
8602 (setq files (list (cdr (assq 'name (car ps)))))
8603 (while (and ps (cdr ps)
8604 (string= (or action "1")
8605 (or (cdr (assq 'action (cadr ps))) "2")))
8606 (push (cdr (assq 'name (cadr ps))) files)
8607 (setcdr ps (cddr ps)))
8609 (when (not (string-match "%s" action))
8612 (when (assq 'execute (car ps))
8613 (setcdr (assq 'execute (car ps))
8614 (funcall (if (string-match "%s" action)
8621 (gnus-quote-arg-for-sh-or-csh f)))
8623 (setq ps (cdr ps)))))
8624 (if (and gnus-view-pseudos (not not-view))
8626 (when (assq 'execute (car pslist))
8627 (gnus-execute-command (cdr (assq 'execute (car pslist)))
8628 (eq gnus-view-pseudos 'not-confirm)))
8629 (setq pslist (cdr pslist)))
8632 (setq after-article (or (cdr (assq 'article (car pslist)))
8633 (gnus-summary-article-number)))
8634 (gnus-summary-goto-subject after-article)
8637 (insert " " (file-name-nondirectory
8638 (cdr (assq 'name (car pslist))))
8639 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
8641 (forward-line -1) ; back to `b'
8642 (gnus-add-text-properties
8643 b (1- e) (list 'gnus-number gnus-reffed-article-number
8644 gnus-mouse-face-prop gnus-mouse-face))
8646 after-article gnus-reffed-article-number
8647 gnus-unread-mark b (car pslist) 0 (- e b))
8648 (push gnus-reffed-article-number gnus-newsgroup-unreads)
8649 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
8650 (setq pslist (cdr pslist)))))))
8652 (defun gnus-pseudos< (p1 p2)
8653 (let ((c1 (cdr (assq 'action p1)))
8654 (c2 (cdr (assq 'action p2))))
8655 (and c1 c2 (string< c1 c2))))
8657 (defun gnus-request-pseudo-article (props)
8658 (cond ((assq 'execute props)
8659 (gnus-execute-command (cdr (assq 'execute props)))))
8660 (let ((gnus-current-article (gnus-summary-article-number)))
8661 (run-hooks 'gnus-mark-article-hook)))
8663 (defun gnus-execute-command (command &optional automatic)
8665 (gnus-article-setup-buffer)
8666 (set-buffer gnus-article-buffer)
8667 (setq buffer-read-only nil)
8668 (let ((command (if automatic command
8669 (read-string "Command: " (cons command 0)))))
8671 (insert "$ " command "\n\n")
8672 (if gnus-view-pseudo-asynchronously
8673 (start-process "gnus-execute" (current-buffer) shell-file-name
8674 shell-command-switch command)
8675 (call-process shell-file-name nil t nil
8676 shell-command-switch command)))))
8678 ;; Summary kill commands.
8680 (defun gnus-summary-edit-global-kill (article)
8681 "Edit the \"global\" kill file."
8682 (interactive (list (gnus-summary-article-number)))
8683 (gnus-group-edit-global-kill article))
8685 (defun gnus-summary-edit-local-kill ()
8686 "Edit a local kill file applied to the current newsgroup."
8688 (setq gnus-current-headers (gnus-summary-article-header))
8689 (gnus-group-edit-local-kill
8690 (gnus-summary-article-number) gnus-newsgroup-name))
8694 (defun gnus-read-header (id &optional header)
8695 "Read the headers of article ID and enter them into the Gnus system."
8696 (let ((group gnus-newsgroup-name)
8697 (gnus-override-method
8698 (and (gnus-news-group-p gnus-newsgroup-name)
8699 gnus-refer-article-method))
8701 ;; First we check to see whether the header in question is already
8704 ;; This is a Message-ID.
8705 (setq header (or header (gnus-id-to-header id)))
8706 ;; This is an article number.
8707 (setq header (or header (gnus-summary-article-header id))))
8709 (not (gnus-summary-article-sparse-p (mail-header-number header))))
8710 ;; We have found the header.
8712 ;; If this is a sparse article, we have to nix out its
8713 ;; previous entry in the thread hashtb.
8715 (gnus-summary-article-sparse-p (mail-header-number header)))
8716 (let ((thread (gnus-gethash
8717 (gnus-parent-id (mail-header-references header))
8718 gnus-newsgroup-dependencies)))
8719 (delq (assq header thread) thread)))
8720 ;; We have to really fetch the header to this article.
8722 (set-buffer nntp-server-buffer)
8723 (when (setq where (gnus-request-head id group))
8724 (nnheader-fold-continuation-lines)
8725 (goto-char (point-max))
8727 (goto-char (point-min))
8731 ((cdr where) (cdr where))
8732 (header (mail-header-number header))
8733 (t gnus-reffed-article-number))
8735 (insert " Article retrieved.\n"))
8737 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
8738 () ; Malformed head.
8739 (unless (gnus-summary-article-sparse-p (mail-header-number header))
8740 (when (and (stringp id)
8741 (not (string= (gnus-group-real-name group)
8743 ;; If we fetched by Message-ID and the article came
8744 ;; from a different group, we fudge some bogus article
8745 ;; numbers for this article.
8746 (mail-header-set-number header gnus-reffed-article-number))
8748 (set-buffer gnus-summary-buffer)
8749 (decf gnus-reffed-article-number)
8750 (gnus-remove-header (mail-header-number header))
8751 (push header gnus-newsgroup-headers)
8752 (setq gnus-current-headers header)
8753 (push (mail-header-number header) gnus-newsgroup-limit)))
8756 (defun gnus-remove-header (number)
8757 "Remove header NUMBER from `gnus-newsgroup-headers'."
8758 (if (and gnus-newsgroup-headers
8759 (= number (mail-header-number (car gnus-newsgroup-headers))))
8760 (pop gnus-newsgroup-headers)
8761 (let ((headers gnus-newsgroup-headers))
8762 (while (and (cdr headers)
8763 (not (= number (mail-header-number (cadr headers)))))
8766 (setcdr headers (cddr headers))))))
8769 ;;; summary highlights
8772 (defun gnus-highlight-selected-summary ()
8773 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8774 ;; Highlight selected article in summary buffer
8775 (when gnus-summary-selected-face
8777 (let* ((beg (progn (beginning-of-line) (point)))
8778 (end (progn (end-of-line) (point)))
8779 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
8780 (from (if (get-text-property beg gnus-mouse-face-prop)
8782 (or (next-single-property-change
8783 beg gnus-mouse-face-prop nil end)
8788 (or (next-single-property-change
8789 from gnus-mouse-face-prop nil end)
8791 ;; If no mouse-face prop on line we will have to = from = end,
8792 ;; so we highlight the entire line instead.
8793 (when (= (+ to 2) from)
8796 (if gnus-newsgroup-selected-overlay
8797 ;; Move old overlay.
8799 gnus-newsgroup-selected-overlay from to (current-buffer))
8800 ;; Create new overlay.
8802 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
8803 'face gnus-summary-selected-face))))))
8805 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
8806 (defun gnus-summary-highlight-line ()
8807 "Highlight current line according to `gnus-summary-highlight'."
8808 (let* ((list gnus-summary-highlight)
8810 (end (progn (end-of-line) (point)))
8811 ;; now find out where the line starts and leave point there.
8812 (beg (progn (beginning-of-line) (point)))
8813 (article (gnus-summary-article-number))
8814 (score (or (cdr (assq (or article gnus-current-article)
8815 gnus-newsgroup-scored))
8816 gnus-summary-default-score 0))
8817 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
8818 (inhibit-read-only t))
8819 ;; Eval the cars of the lists until we find a match.
8820 (let ((default gnus-summary-default-score))
8822 (not (eval (caar list))))
8823 (setq list (cdr list))))
8824 (let ((face (cdar list)))
8825 (unless (eq face (get-text-property beg 'face))
8826 (gnus-put-text-property
8828 (setq face (if (boundp face) (symbol-value face) face)))
8829 (when gnus-summary-highlight-line-function
8830 (funcall gnus-summary-highlight-line-function article face))))
8833 (defun gnus-update-read-articles (group unread &optional compute)
8834 "Update the list of read articles in GROUP."
8835 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
8836 (entry (gnus-gethash group gnus-newsrc-hashtb))
8837 (info (nth 2 entry))
8839 (unread (sort (copy-sequence unread) '<))
8841 (if (or (not info) (not active))
8842 ;; There is no info on this group if it was, in fact,
8843 ;; killed. Gnus stores no information on killed groups, so
8844 ;; there's nothing to be done.
8845 ;; One could store the information somewhere temporarily,
8846 ;; perhaps... Hmmm...
8848 ;; Remove any negative articles numbers.
8849 (while (and unread (< (car unread) 0))
8850 (setq unread (cdr unread)))
8851 ;; Remove any expired article numbers
8852 (while (and unread (< (car unread) (car active)))
8853 (setq unread (cdr unread)))
8854 ;; Compute the ranges of read articles by looking at the list of
8857 (when (/= (car unread) prev)
8858 (push (if (= prev (1- (car unread))) prev
8859 (cons prev (1- (car unread))))
8861 (setq prev (1+ (car unread)))
8862 (setq unread (cdr unread)))
8863 (when (<= prev (cdr active))
8864 (push (cons prev (cdr active)) read))
8866 (if (> (length read) 1) (nreverse read) read)
8868 (set-buffer gnus-group-buffer)
8871 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
8872 (gnus-info-set-read ',info ',(gnus-info-read info))
8873 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
8874 (gnus-group-update-group ,group t))))
8875 ;; Enter this list into the group info.
8877 info (if (> (length read) 1) (nreverse read) read))
8878 ;; Set the number of unread articles in gnus-newsrc-hashtb.
8879 (gnus-get-unread-articles-in-group info (gnus-active group))
8882 (defun gnus-offer-save-summaries ()
8883 "Offer to save all active summary buffers."
8885 (let ((buflist (buffer-list))
8887 ;; Go through all buffers and find all summaries.
8889 (and (setq bufname (buffer-name (car buflist)))
8890 (string-match "Summary" bufname)
8892 (set-buffer bufname)
8893 ;; We check that this is, indeed, a summary buffer.
8894 (and (eq major-mode 'gnus-summary-mode)
8895 ;; Also make sure this isn't bogus.
8896 gnus-newsgroup-prepared
8897 ;; Also make sure that this isn't a dead summary buffer.
8898 (not gnus-dead-summary-mode)))
8899 (push bufname buffers))
8900 (setq buflist (cdr buflist)))
8901 ;; Go through all these summary buffers and offer to save them.
8904 "Update summary buffer %s? "
8905 (lambda (buf) (switch-to-buffer buf) (gnus-summary-exit))
8909 ;;; @ for mime-partial
8912 (defun gnus-mime-partial-preview-function ()
8913 (gnus-summary-preview-mime-message (gnus-summary-article-number))
8916 (autoload 'mime-combine-message/partials-automatically
8918 "Internal method to combine message/partial messages automatically.")
8920 (set-atype 'mime-acting-condition
8921 '((type . "message/partial")
8922 (method . mime-combine-message/partials-automatically)
8923 (major-mode . gnus-original-article-mode)
8924 (summary-buffer-exp . gnus-summary-buffer)
8927 (set-alist 'mime-view-partial-message-method-alist
8928 'gnus-original-article-mode
8929 'gnus-mime-partial-preview-function)
8939 (run-hooks 'gnus-sum-load-hook)
8941 ;;; gnus-sum.el ends here