1 ;;; gnus-sum.el --- summary mode commands for Semi-gnus
2 ;; Copyright (C) 1996,97,98 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
5 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Keywords: mail, news, MIME
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
39 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
40 (autoload 'gnus-set-summary-default-charset "gnus-i18n" nil t)
42 (defcustom gnus-kill-summary-on-exit t
43 "*If non-nil, kill the summary buffer when you exit from it.
44 If nil, the summary will become a \"*Dead Summary*\" buffer, and
45 it will be killed sometime later."
46 :group 'gnus-summary-exit
49 (defcustom gnus-fetch-old-headers nil
50 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
51 If an unread article in the group refers to an older, already read (or
52 just marked as read) article, the old article will not normally be
53 displayed in the Summary buffer. If this variable is non-nil, Gnus
54 will attempt to grab the headers to the old articles, and thereby
55 build complete threads. If it has the value `some', only enough
56 headers to connect otherwise loose threads will be displayed. This
57 variable can also be a number. In that case, no more than that number
58 of old headers will be fetched. If it has the value `invisible', all
59 old headers will be fetched, but none will be displayed.
61 The server has to support NOV for any of this to work."
63 :type '(choice (const :tag "off" nil)
66 (sexp :menu-tag "other" t)))
68 (defcustom gnus-refer-thread-limit 200
69 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
70 If t, fetch all the available old headers."
73 (sexp :menu-tag "other" t)))
75 (defcustom gnus-summary-make-false-root 'adopt
76 "*nil means that Gnus won't gather loose threads.
77 If the root of a thread has expired or been read in a previous
78 session, the information necessary to build a complete thread has been
79 lost. Instead of having many small sub-threads from this original thread
80 scattered all over the summary buffer, Gnus can gather them.
82 If non-nil, Gnus will try to gather all loose sub-threads from an
83 original thread into one large thread.
85 If this variable is non-nil, it should be one of `none', `adopt',
88 If this variable is `none', Gnus will not make a false root, but just
89 present the sub-threads after another.
90 If this variable is `dummy', Gnus will create a dummy root that will
91 have all the sub-threads as children.
92 If this variable is `adopt', Gnus will make one of the \"children\"
93 the parent and mark all the step-children as such.
94 If this variable is `empty', the \"children\" are printed with empty
95 subject fields. (Or rather, they will be printed with a string
96 given by the `gnus-summary-same-subject' variable.)"
98 :type '(choice (const :tag "off" nil)
104 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
105 "*A regexp to match subjects to be excluded from loose thread gathering.
106 As loose thread gathering is done on subjects only, that means that
107 there can be many false gatherings performed. By rooting out certain
108 common subjects, gathering might become saner."
112 (defcustom gnus-summary-gather-subject-limit nil
113 "*Maximum length of subject comparisons when gathering loose threads.
114 Use nil to compare full subjects. Setting this variable to a low
115 number will help gather threads that have been corrupted by
116 newsreaders chopping off subject lines, but it might also mean that
117 unrelated articles that have subject that happen to begin with the
118 same few characters will be incorrectly gathered.
120 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
123 :type '(choice (const :tag "off" nil)
125 (sexp :menu-tag "on" t)))
127 (defcustom gnus-simplify-subject-functions nil
128 "List of functions taking a string argument that simplify subjects.
129 The functions are applied recursively.
131 Useful functions to put in this list include: `gnus-simplify-subject-re',
132 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
134 :type '(repeat function))
136 (defcustom gnus-simplify-ignored-prefixes nil
137 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
139 :type '(choice (const :tag "off" nil)
142 (defcustom gnus-build-sparse-threads nil
143 "*If non-nil, fill in the gaps in threads.
144 If `some', only fill in the gaps that are needed to tie loose threads
145 together. If `more', fill in all leaf nodes that Gnus can find. If
146 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
148 :type '(choice (const :tag "off" nil)
151 (sexp :menu-tag "all" t)))
153 (defcustom gnus-summary-thread-gathering-function
154 'gnus-gather-threads-by-subject
155 "*Function used for gathering loose threads.
156 There are two pre-defined functions: `gnus-gather-threads-by-subject',
157 which only takes Subjects into consideration; and
158 `gnus-gather-threads-by-references', which compared the References
159 headers of the articles to find matches."
161 :type '(radio (function-item gnus-gather-threads-by-subject)
162 (function-item gnus-gather-threads-by-references)
163 (function :tag "other")))
165 (defcustom gnus-summary-same-subject ""
166 "*String indicating that the current article has the same subject as the previous.
167 This variable will only be used if the value of
168 `gnus-summary-make-false-root' is `empty'."
169 :group 'gnus-summary-format
172 (defcustom gnus-summary-goto-unread t
173 "*If t, marking commands will go to the next unread article.
174 If `never', commands that usually go to the next unread article, will
175 go to the next article, whether it is read or not.
176 If nil, only the marking commands will go to the next (un)read article."
177 :group 'gnus-summary-marks
178 :link '(custom-manual "(gnus)Setting Marks")
179 :type '(choice (const :tag "off" nil)
181 (sexp :menu-tag "on" t)))
183 (defcustom gnus-summary-default-score 0
184 "*Default article score level.
185 All scores generated by the score files will be added to this score.
186 If this variable is nil, scoring will be disabled."
187 :group 'gnus-score-default
188 :type '(choice (const :tag "disable")
191 (defcustom gnus-summary-zcore-fuzz 0
192 "*Fuzziness factor for the zcore in the summary buffer.
193 Articles with scores closer than this to `gnus-summary-default-score'
195 :group 'gnus-summary-format
198 (defcustom gnus-simplify-subject-fuzzy-regexp nil
199 "*Strings to be removed when doing fuzzy matches.
200 This can either be a regular expression or list of regular expressions
201 that will be removed from subject strings if fuzzy subject
202 simplification is selected."
204 :type '(repeat regexp))
206 (defcustom gnus-show-threads t
207 "*If non-nil, display threads in summary mode."
211 (defcustom gnus-thread-hide-subtree nil
212 "*If non-nil, hide all threads initially.
213 If threads are hidden, you have to run the command
214 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
215 to expose hidden threads."
219 (defcustom gnus-thread-hide-killed t
220 "*If non-nil, hide killed threads automatically."
224 (defcustom gnus-thread-ignore-subject nil
225 "*If non-nil, ignore subjects and do all threading based on the Reference header.
226 If nil, which is the default, articles that have different subjects
227 from their parents will start separate threads."
231 (defcustom gnus-thread-operation-ignore-subject t
232 "*If non-nil, subjects will be ignored when doing thread commands.
233 This affects commands like `gnus-summary-kill-thread' and
234 `gnus-summary-lower-thread'.
236 If this variable is nil, articles in the same thread with different
237 subjects will not be included in the operation in question. If this
238 variable is `fuzzy', only articles that have subjects that are fuzzily
239 equal will be included."
241 :type '(choice (const :tag "off" nil)
245 (defcustom gnus-thread-indent-level 4
246 "*Number that says how much each sub-thread should be indented."
250 (defcustom gnus-auto-extend-newsgroup t
251 "*If non-nil, extend newsgroup forward and backward when requested."
252 :group 'gnus-summary-choose
255 (defcustom gnus-auto-select-first t
256 "*If nil, don't select the first unread article when entering a group.
257 If this variable is `best', select the highest-scored unread article
258 in the group. If neither nil nor `best', select the first unread
261 If you want to prevent automatic selection of the first unread article
262 in some newsgroups, set the variable to nil in
263 `gnus-select-group-hook'."
264 :group 'gnus-group-select
265 :type '(choice (const :tag "none" nil)
267 (sexp :menu-tag "first" t)))
269 (defcustom gnus-auto-select-next t
270 "*If non-nil, offer to go to the next group from the end of the previous.
271 If the value is t and the next newsgroup is empty, Gnus will exit
272 summary mode and go back to group mode. If the value is neither nil
273 nor t, Gnus will select the following unread newsgroup. In
274 particular, if the value is the symbol `quietly', the next unread
275 newsgroup will be selected without any confirmation, and if it is
276 `almost-quietly', the next group will be selected without any
277 confirmation if you are located on the last article in the group.
278 Finally, if this variable is `slightly-quietly', the `Z n' command
279 will go to the next group without confirmation."
280 :group 'gnus-summary-maneuvering
281 :type '(choice (const :tag "off" nil)
283 (const almost-quietly)
284 (const slightly-quietly)
285 (sexp :menu-tag "on" t)))
287 (defcustom gnus-auto-select-same nil
288 "*If non-nil, select the next article with the same subject."
289 :group 'gnus-summary-maneuvering
292 (defcustom gnus-summary-check-current nil
293 "*If non-nil, consider the current article when moving.
294 The \"unread\" movement commands will stay on the same line if the
295 current article is unread."
296 :group 'gnus-summary-maneuvering
299 (defcustom gnus-auto-center-summary t
300 "*If non-nil, always center the current summary buffer.
301 In particular, if `vertical' do only vertical recentering. If non-nil
302 and non-`vertical', do both horizontal and vertical recentering."
303 :group 'gnus-summary-maneuvering
304 :type '(choice (const :tag "none" nil)
306 (sexp :menu-tag "both" t)))
308 (defcustom gnus-show-all-headers nil
309 "*If non-nil, don't hide any headers."
310 :group 'gnus-article-hiding
311 :group 'gnus-article-headers
314 (defcustom gnus-summary-ignore-duplicates nil
315 "*If non-nil, ignore articles with identical Message-ID headers."
319 (defcustom gnus-single-article-buffer t
320 "*If non-nil, display all articles in the same buffer.
321 If nil, each group will get its own article buffer."
322 :group 'gnus-article-various
325 (defcustom gnus-break-pages t
326 "*If non-nil, do page breaking on articles.
327 The page delimiter is specified by the `gnus-page-delimiter'
329 :group 'gnus-article-various
332 (defcustom gnus-show-mime t
333 "*If non-nil, do mime processing of articles.
334 The articles will simply be fed to the function given by
335 `gnus-show-mime-method'."
336 :group 'gnus-article-mime
339 (defcustom gnus-move-split-methods nil
340 "*Variable used to suggest where articles are to be moved to.
341 It uses the same syntax as the `gnus-split-methods' variable."
342 :group 'gnus-summary-mail
343 :type '(repeat (choice (list :value (fun) function)
344 (cons :value ("" "") regexp (repeat string))
347 (defcustom gnus-unread-mark ?
348 "*Mark used for unread articles."
349 :group 'gnus-summary-marks
352 (defcustom gnus-ticked-mark ?!
353 "*Mark used for ticked articles."
354 :group 'gnus-summary-marks
357 (defcustom gnus-dormant-mark ??
358 "*Mark used for dormant articles."
359 :group 'gnus-summary-marks
362 (defcustom gnus-del-mark ?r
363 "*Mark used for del'd articles."
364 :group 'gnus-summary-marks
367 (defcustom gnus-read-mark ?R
368 "*Mark used for read articles."
369 :group 'gnus-summary-marks
372 (defcustom gnus-expirable-mark ?E
373 "*Mark used for expirable articles."
374 :group 'gnus-summary-marks
377 (defcustom gnus-killed-mark ?K
378 "*Mark used for killed articles."
379 :group 'gnus-summary-marks
382 (defcustom gnus-souped-mark ?F
383 "*Mark used for killed articles."
384 :group 'gnus-summary-marks
387 (defcustom gnus-kill-file-mark ?X
388 "*Mark used for articles killed by kill files."
389 :group 'gnus-summary-marks
392 (defcustom gnus-low-score-mark ?Y
393 "*Mark used for articles with a low score."
394 :group 'gnus-summary-marks
397 (defcustom gnus-catchup-mark ?C
398 "*Mark used for articles that are caught up."
399 :group 'gnus-summary-marks
402 (defcustom gnus-replied-mark ?A
403 "*Mark used for articles that have been replied to."
404 :group 'gnus-summary-marks
407 (defcustom gnus-cached-mark ?*
408 "*Mark used for articles that are in the cache."
409 :group 'gnus-summary-marks
412 (defcustom gnus-saved-mark ?S
413 "*Mark used for articles that have been saved to."
414 :group 'gnus-summary-marks
417 (defcustom gnus-ancient-mark ?O
418 "*Mark used for ancient articles."
419 :group 'gnus-summary-marks
422 (defcustom gnus-sparse-mark ?Q
423 "*Mark used for sparsely reffed articles."
424 :group 'gnus-summary-marks
427 (defcustom gnus-canceled-mark ?G
428 "*Mark used for canceled articles."
429 :group 'gnus-summary-marks
432 (defcustom gnus-duplicate-mark ?M
433 "*Mark used for duplicate articles."
434 :group 'gnus-summary-marks
437 (defcustom gnus-undownloaded-mark ?@
438 "*Mark used for articles that weren't downloaded."
439 :group 'gnus-summary-marks
442 (defcustom gnus-downloadable-mark ?%
443 "*Mark used for articles that are to be downloaded."
444 :group 'gnus-summary-marks
447 (defcustom gnus-unsendable-mark ?=
448 "*Mark used for articles that won't be sent."
449 :group 'gnus-summary-marks
452 (defcustom gnus-score-over-mark ?+
453 "*Score mark used for articles with high scores."
454 :group 'gnus-summary-marks
457 (defcustom gnus-score-below-mark ?-
458 "*Score mark used for articles with low scores."
459 :group 'gnus-summary-marks
462 (defcustom gnus-empty-thread-mark ?
463 "*There is no thread under the article."
464 :group 'gnus-summary-marks
467 (defcustom gnus-not-empty-thread-mark ?=
468 "*There is a thread under the article."
469 :group 'gnus-summary-marks
472 (defcustom gnus-view-pseudo-asynchronously nil
473 "*If non-nil, Gnus will view pseudo-articles asynchronously."
474 :group 'gnus-extract-view
477 (defcustom gnus-view-pseudos nil
478 "*If `automatic', pseudo-articles will be viewed automatically.
479 If `not-confirm', pseudos will be viewed automatically, and the user
480 will not be asked to confirm the command."
481 :group 'gnus-extract-view
482 :type '(choice (const :tag "off" nil)
484 (const not-confirm)))
486 (defcustom gnus-view-pseudos-separately t
487 "*If non-nil, one pseudo-article will be created for each file to be viewed.
488 If nil, all files that use the same viewing command will be given as a
489 list of parameters to that command."
490 :group 'gnus-extract-view
493 (defcustom gnus-insert-pseudo-articles t
494 "*If non-nil, insert pseudo-articles when decoding articles."
495 :group 'gnus-extract-view
498 (defcustom gnus-summary-dummy-line-format
500 "*The format specification for the dummy roots in the summary buffer.
501 It works along the same lines as a normal formatting string,
502 with some simple extensions.
505 :group 'gnus-threading
508 (defcustom gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
509 "*The format specification for the summary mode line.
510 It works along the same lines as a normal formatting string,
511 with some simple extensions:
514 %p Unprefixed group name
515 %A Current article number
516 %z Current article score
518 %U Number of unread articles in the group
519 %e Number of unselected articles in the group
520 %Z A string with unread/unselected article counts
521 %g Shortish group name
522 %S Subject of the current article
524 %s Current score file name
525 %d Number of dormant articles
526 %r Number of articles that have been marked as read in this session
527 %E Number of articles expunged by the score files"
528 :group 'gnus-summary-format
531 (defcustom gnus-summary-mark-below 0
532 "*Mark all articles with a score below this variable as read.
533 This variable is local to each summary buffer and usually set by the
535 :group 'gnus-score-default
538 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
539 "*List of functions used for sorting articles in the summary buffer.
540 This variable is only used when not using a threaded display."
541 :group 'gnus-summary-sort
542 :type '(repeat (choice (function-item gnus-article-sort-by-number)
543 (function-item gnus-article-sort-by-author)
544 (function-item gnus-article-sort-by-subject)
545 (function-item gnus-article-sort-by-date)
546 (function-item gnus-article-sort-by-score)
547 (function :tag "other"))))
549 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
550 "*List of functions used for sorting threads in the summary buffer.
551 By default, threads are sorted by article number.
553 Each function takes two threads and return non-nil if the first thread
554 should be sorted before the other. If you use more than one function,
555 the primary sort function should be the last. You should probably
556 always include `gnus-thread-sort-by-number' in the list of sorting
557 functions -- preferably first.
559 Ready-made functions include `gnus-thread-sort-by-number',
560 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
561 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
562 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
563 :group 'gnus-summary-sort
564 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
565 (function-item gnus-thread-sort-by-author)
566 (function-item gnus-thread-sort-by-subject)
567 (function-item gnus-thread-sort-by-date)
568 (function-item gnus-thread-sort-by-score)
569 (function-item gnus-thread-sort-by-total-score)
570 (function :tag "other"))))
572 (defcustom gnus-thread-score-function '+
573 "*Function used for calculating the total score of a thread.
575 The function is called with the scores of the article and each
576 subthread and should then return the score of the thread.
578 Some functions you can use are `+', `max', or `min'."
579 :group 'gnus-summary-sort
582 (defcustom gnus-summary-expunge-below nil
583 "All articles that have a score less than this variable will be expunged.
584 This variable is local to the summary buffers."
585 :group 'gnus-score-default
586 :type '(choice (const :tag "off" nil)
589 (defcustom gnus-thread-expunge-below nil
590 "All threads that have a total score less than this variable will be expunged.
591 See `gnus-thread-score-function' for en explanation of what a
594 This variable is local to the summary buffers."
595 :group 'gnus-treading
596 :group 'gnus-score-default
597 :type '(choice (const :tag "off" nil)
600 (defcustom gnus-summary-mode-hook nil
601 "*A hook for Gnus summary mode.
602 This hook is run before any variables are set in the summary buffer."
603 :group 'gnus-summary-various
606 (defcustom gnus-summary-menu-hook nil
607 "*Hook run after the creation of the summary mode menu."
608 :group 'gnus-summary-visual
611 (defcustom gnus-summary-exit-hook nil
612 "*A hook called on exit from the summary buffer.
613 It will be called with point in the group buffer."
614 :group 'gnus-summary-exit
617 (defcustom gnus-summary-prepare-hook nil
618 "*A hook called after the summary buffer has been generated.
619 If you want to modify the summary buffer, you can use this hook."
620 :group 'gnus-summary-various
623 (defcustom gnus-summary-prepared-hook nil
624 "*A hook called as the last thing after the summary buffer has been generated."
625 :group 'gnus-summary-various
628 (defcustom gnus-summary-generate-hook nil
629 "*A hook run just before generating the summary buffer.
630 This hook is commonly used to customize threading variables and the
632 :group 'gnus-summary-various
635 (defcustom gnus-select-group-hook nil
636 "*A hook called when a newsgroup is selected.
638 If you'd like to simplify subjects like the
639 `gnus-summary-next-same-subject' command does, you can use the
642 (setq gnus-select-group-hook
645 (mapcar (lambda (header)
646 (mail-header-set-subject
648 (gnus-simplify-subject
649 (mail-header-subject header) 're-only)))
650 gnus-newsgroup-headers))))"
651 :group 'gnus-group-select
654 (defcustom gnus-select-article-hook nil
655 "*A hook called when an article is selected."
656 :group 'gnus-summary-choose
659 (defcustom gnus-visual-mark-article-hook
660 (list 'gnus-highlight-selected-summary)
661 "*Hook run after selecting an article in the summary buffer.
662 It is meant to be used for highlighting the article in some way. It
663 is not run if `gnus-visual' is nil."
664 :group 'gnus-summary-visual
667 (defcustom gnus-structured-field-decoder
668 #'eword-decode-and-unfold-structured-field
669 "Function to decode non-ASCII characters in structured field for summary."
673 (defcustom gnus-unstructured-field-decoder
676 (eword-decode-unstructured-field-body
677 (std11-unfold-string string) 'must-unfold)
679 "Function to decode non-ASCII characters in unstructured field for summary."
683 (defcustom gnus-parse-headers-hook
684 '(gnus-set-summary-default-charset)
685 "*A hook called before parsing the headers."
689 (defcustom gnus-exit-group-hook nil
690 "*A hook called when exiting (not quitting) summary mode."
694 (defcustom gnus-summary-update-hook
695 (list 'gnus-summary-highlight-line)
696 "*A hook called when a summary line is changed.
697 The hook will not be called if `gnus-visual' is nil.
699 The default function `gnus-summary-highlight-line' will
700 highlight the line according to the `gnus-summary-highlight'
702 :group 'gnus-summary-visual
705 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
706 "*A hook called when an article is selected for the first time.
707 The hook is intended to mark an article as read (or unread)
708 automatically when it is selected."
709 :group 'gnus-summary-choose
712 (defcustom gnus-group-no-more-groups-hook nil
713 "*A hook run when returning to group mode having no more (unread) groups."
714 :group 'gnus-group-select
717 (defcustom gnus-ps-print-hook nil
718 "*A hook run before ps-printing something from Gnus."
722 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
723 "Face used for highlighting the current article in the summary buffer."
724 :group 'gnus-summary-visual
727 (defcustom gnus-summary-highlight
728 '(((= mark gnus-canceled-mark)
729 . gnus-summary-cancelled-face)
730 ((and (> score default)
731 (or (= mark gnus-dormant-mark)
732 (= mark gnus-ticked-mark)))
733 . gnus-summary-high-ticked-face)
734 ((and (< score default)
735 (or (= mark gnus-dormant-mark)
736 (= mark gnus-ticked-mark)))
737 . gnus-summary-low-ticked-face)
738 ((or (= mark gnus-dormant-mark)
739 (= mark gnus-ticked-mark))
740 . gnus-summary-normal-ticked-face)
741 ((and (> score default) (= mark gnus-ancient-mark))
742 . gnus-summary-high-ancient-face)
743 ((and (< score default) (= mark gnus-ancient-mark))
744 . gnus-summary-low-ancient-face)
745 ((= mark gnus-ancient-mark)
746 . gnus-summary-normal-ancient-face)
747 ((and (> score default) (= mark gnus-unread-mark))
748 . gnus-summary-high-unread-face)
749 ((and (< score default) (= mark gnus-unread-mark))
750 . gnus-summary-low-unread-face)
751 ((= mark gnus-unread-mark)
752 . gnus-summary-normal-unread-face)
753 ((and (> score default) (memq mark (list gnus-downloadable-mark
754 gnus-undownloaded-mark)))
755 . gnus-summary-high-unread-face)
756 ((and (< score default) (memq mark (list gnus-downloadable-mark
757 gnus-undownloaded-mark)))
758 . gnus-summary-low-unread-face)
759 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
760 . gnus-summary-normal-unread-face)
762 . gnus-summary-high-read-face)
764 . gnus-summary-low-read-face)
766 . gnus-summary-normal-read-face))
767 "*Controls the highlighting of summary buffer lines.
769 A list of (FORM . FACE) pairs. When deciding how a a particular
770 summary line should be displayed, each form is evaluated. The content
771 of the face field after the first true form is used. You can change
772 how those summary lines are displayed, by editing the face field.
774 You can use the following variables in the FORM field.
776 score: The articles score
777 default: The default article score.
778 below: The score below which articles are automatically marked as read.
779 mark: The articles mark."
780 :group 'gnus-summary-visual
781 :type '(repeat (cons (sexp :tag "Form" nil)
784 (defcustom gnus-alter-header-function nil
785 "Function called to allow alteration of article header structures.
786 The function is called with one parameter, the article header vector,
787 which it may alter in any way.")
789 ;;; Internal variables
791 (defvar gnus-scores-exclude-files nil)
792 (defvar gnus-page-broken nil)
794 (defvar gnus-original-article nil)
795 (defvar gnus-article-internal-prepare-hook nil)
796 (defvar gnus-newsgroup-process-stack nil)
798 (defvar gnus-thread-indent-array nil)
799 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
801 ;; Avoid highlighting in kill files.
802 (defvar gnus-summary-inhibit-highlight nil)
803 (defvar gnus-newsgroup-selected-overlay nil)
804 (defvar gnus-inhibit-limiting nil)
805 (defvar gnus-newsgroup-adaptive-score-file nil)
806 (defvar gnus-current-score-file nil)
807 (defvar gnus-current-move-group nil)
808 (defvar gnus-current-copy-group nil)
809 (defvar gnus-current-crosspost-group nil)
811 (defvar gnus-newsgroup-dependencies nil)
812 (defvar gnus-newsgroup-adaptive nil)
813 (defvar gnus-summary-display-article-function nil)
814 (defvar gnus-summary-highlight-line-function nil
815 "Function called after highlighting a summary line.")
817 (defvar gnus-summary-line-format-alist
818 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
819 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
820 (?s gnus-tmp-subject-or-nil ?s)
821 (?n gnus-tmp-name ?s)
822 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
824 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
826 (?F gnus-tmp-from ?s)
827 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
828 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
829 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
830 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
831 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
832 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
833 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
834 (?L gnus-tmp-lines ?d)
835 (?I gnus-tmp-indentation ?s)
836 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
837 (?R gnus-tmp-replied ?c)
838 (?\[ gnus-tmp-opening-bracket ?c)
839 (?\] gnus-tmp-closing-bracket ?c)
840 (?\> (make-string gnus-tmp-level ? ) ?s)
841 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
842 (?i gnus-tmp-score ?d)
843 (?z gnus-tmp-score-char ?c)
844 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
845 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
846 (?U gnus-tmp-unread ?c)
847 (?t (gnus-summary-number-of-articles-in-thread
848 (and (boundp 'thread) (car thread)) gnus-tmp-level)
850 (?e (gnus-summary-number-of-articles-in-thread
851 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
853 (?u gnus-tmp-user-defined ?s)
854 (?P (gnus-pick-line-number) ?d))
855 "An alist of format specifications that can appear in summary lines,
856 and what variables they correspond with, along with the type of the
857 variable (string, integer, character, etc).")
859 (defvar gnus-summary-dummy-line-format-alist
860 `((?S gnus-tmp-subject ?s)
861 (?N gnus-tmp-number ?d)
862 (?u gnus-tmp-user-defined ?s)))
864 (defvar gnus-summary-mode-line-format-alist
865 `((?G gnus-tmp-group-name ?s)
866 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
867 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
868 (?A gnus-tmp-article-number ?d)
869 (?Z gnus-tmp-unread-and-unselected ?s)
871 (?U gnus-tmp-unread-and-unticked ?d)
872 (?S gnus-tmp-subject ?s)
873 (?e gnus-tmp-unselected ?d)
874 (?u gnus-tmp-user-defined ?s)
875 (?d (length gnus-newsgroup-dormant) ?d)
876 (?t (length gnus-newsgroup-marked) ?d)
877 (?r (length gnus-newsgroup-reads) ?d)
878 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
879 (?E gnus-newsgroup-expunged-tally ?d)
880 (?s (gnus-current-score-file-nondirectory) ?s)))
882 (defvar gnus-last-search-regexp nil
883 "Default regexp for article search command.")
885 (defvar gnus-last-shell-command nil
886 "Default shell command on article.")
888 (defvar gnus-newsgroup-begin nil)
889 (defvar gnus-newsgroup-end nil)
890 (defvar gnus-newsgroup-last-rmail nil)
891 (defvar gnus-newsgroup-last-mail nil)
892 (defvar gnus-newsgroup-last-folder nil)
893 (defvar gnus-newsgroup-last-file nil)
894 (defvar gnus-newsgroup-auto-expire nil)
895 (defvar gnus-newsgroup-active nil)
897 (defvar gnus-newsgroup-data nil)
898 (defvar gnus-newsgroup-data-reverse nil)
899 (defvar gnus-newsgroup-limit nil)
900 (defvar gnus-newsgroup-limits nil)
902 (defvar gnus-newsgroup-unreads nil
903 "List of unread articles in the current newsgroup.")
905 (defvar gnus-newsgroup-unselected nil
906 "List of unselected unread articles in the current newsgroup.")
908 (defvar gnus-newsgroup-reads nil
909 "Alist of read articles and article marks in the current newsgroup.")
911 (defvar gnus-newsgroup-expunged-tally nil)
913 (defvar gnus-newsgroup-marked nil
914 "List of ticked articles in the current newsgroup (a subset of unread art).")
916 (defvar gnus-newsgroup-killed nil
917 "List of ranges of articles that have been through the scoring process.")
919 (defvar gnus-newsgroup-cached nil
920 "List of articles that come from the article cache.")
922 (defvar gnus-newsgroup-saved nil
923 "List of articles that have been saved.")
925 (defvar gnus-newsgroup-kill-headers nil)
927 (defvar gnus-newsgroup-replied nil
928 "List of articles that have been replied to in the current newsgroup.")
930 (defvar gnus-newsgroup-expirable nil
931 "List of articles in the current newsgroup that can be expired.")
933 (defvar gnus-newsgroup-processable nil
934 "List of articles in the current newsgroup that can be processed.")
936 (defvar gnus-newsgroup-downloadable nil
937 "List of articles in the current newsgroup that can be processed.")
939 (defvar gnus-newsgroup-undownloaded nil
940 "List of articles in the current newsgroup that haven't been downloaded..")
942 (defvar gnus-newsgroup-unsendable nil
943 "List of articles in the current newsgroup that won't be sent.")
945 (defvar gnus-newsgroup-bookmarks nil
946 "List of articles in the current newsgroup that have bookmarks.")
948 (defvar gnus-newsgroup-dormant nil
949 "List of dormant articles in the current newsgroup.")
951 (defvar gnus-newsgroup-scored nil
952 "List of scored articles in the current newsgroup.")
954 (defvar gnus-newsgroup-headers nil
955 "List of article headers in the current newsgroup.")
957 (defvar gnus-newsgroup-threads nil)
959 (defvar gnus-newsgroup-prepared nil
960 "Whether the current group has been prepared properly.")
962 (defvar gnus-newsgroup-ancient nil
963 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
965 (defvar gnus-newsgroup-sparse nil)
967 (defvar gnus-current-article nil)
968 (defvar gnus-article-current nil)
969 (defvar gnus-current-headers nil)
970 (defvar gnus-have-all-headers nil)
971 (defvar gnus-last-article nil)
972 (defvar gnus-newsgroup-history nil)
974 (defconst gnus-summary-local-variables
975 '(gnus-newsgroup-name
976 gnus-newsgroup-begin gnus-newsgroup-end
977 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
978 gnus-newsgroup-last-folder gnus-newsgroup-last-file
979 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
980 gnus-newsgroup-unselected gnus-newsgroup-marked
981 gnus-newsgroup-reads gnus-newsgroup-saved
982 gnus-newsgroup-replied gnus-newsgroup-expirable
983 gnus-newsgroup-processable gnus-newsgroup-killed
984 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
985 gnus-newsgroup-unsendable
986 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
987 gnus-newsgroup-headers gnus-newsgroup-threads
988 gnus-newsgroup-prepared gnus-summary-highlight-line-function
989 gnus-current-article gnus-current-headers gnus-have-all-headers
990 gnus-last-article gnus-article-internal-prepare-hook
991 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
992 gnus-newsgroup-scored gnus-newsgroup-kill-headers
993 gnus-thread-expunge-below
994 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
995 (gnus-summary-mark-below . global)
996 gnus-newsgroup-active gnus-scores-exclude-files
997 gnus-newsgroup-history gnus-newsgroup-ancient
998 gnus-newsgroup-sparse gnus-newsgroup-process-stack
999 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1000 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1001 (gnus-newsgroup-expunged-tally . 0)
1002 gnus-cache-removable-articles gnus-newsgroup-cached
1003 gnus-newsgroup-data gnus-newsgroup-data-reverse
1004 gnus-newsgroup-limit gnus-newsgroup-limits)
1005 "Variables that are buffer-local to the summary buffers.")
1007 ;; Byte-compiler warning.
1008 (defvar gnus-article-mode-map)
1010 ;; Subject simplification.
1012 (defun gnus-simplify-whitespace (str)
1013 "Remove excessive whitespace."
1016 (while (string-match "[ \t][ \t]+" mystr)
1017 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1019 (substring mystr (match-end 0)))))
1021 (when (string-match "^[ \t]+" mystr)
1022 (setq mystr (substring mystr (match-end 0))))
1024 (when (string-match "[ \t]+$" mystr)
1025 (setq mystr (substring mystr 0 (match-beginning 0))))
1028 (defsubst gnus-simplify-subject-re (subject)
1029 "Remove \"Re:\" from subject lines."
1030 (if (string-match "^[Rr][Ee]: *" subject)
1031 (substring subject (match-end 0))
1034 (defun gnus-simplify-subject (subject &optional re-only)
1035 "Remove `Re:' and words in parentheses.
1036 If RE-ONLY is non-nil, strip leading `Re:'s only."
1037 (let ((case-fold-search t)) ;Ignore case.
1038 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1039 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1040 (setq subject (substring subject (match-end 0))))
1041 ;; Remove uninteresting prefixes.
1042 (when (and (not re-only)
1043 gnus-simplify-ignored-prefixes
1044 (string-match gnus-simplify-ignored-prefixes subject))
1045 (setq subject (substring subject (match-end 0))))
1046 ;; Remove words in parentheses from end.
1048 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1049 (setq subject (substring subject 0 (match-beginning 0)))))
1050 ;; Return subject string.
1053 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1055 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1056 (goto-char (point-min))
1057 (while (re-search-forward regexp nil t)
1058 (replace-match (or newtext ""))))
1060 (defun gnus-simplify-buffer-fuzzy ()
1061 "Simplify string in the buffer fuzzily.
1062 The string in the accessible portion of the current buffer is simplified.
1063 It is assumed to be a single-line subject.
1064 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1065 matter is removed. Additional things can be deleted by setting
1066 gnus-simplify-subject-fuzzy-regexp."
1067 (let ((case-fold-search t)
1069 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1071 (while (not (eq modified-tick (buffer-modified-tick)))
1072 (setq modified-tick (buffer-modified-tick))
1074 ((listp gnus-simplify-subject-fuzzy-regexp)
1075 (mapcar 'gnus-simplify-buffer-fuzzy-step
1076 gnus-simplify-subject-fuzzy-regexp))
1077 (gnus-simplify-subject-fuzzy-regexp
1078 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1079 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1080 (gnus-simplify-buffer-fuzzy-step
1081 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1082 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1084 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1085 (gnus-simplify-buffer-fuzzy-step " +" " ")
1086 (gnus-simplify-buffer-fuzzy-step " $")
1087 (gnus-simplify-buffer-fuzzy-step "^ +")))
1089 (defun gnus-simplify-subject-fuzzy (subject)
1090 "Simplify a subject string fuzzily.
1091 See `gnus-simplify-buffer-fuzzy' for details."
1093 (gnus-set-work-buffer)
1094 (let ((case-fold-search t))
1095 ;; Remove uninteresting prefixes.
1096 (when (and gnus-simplify-ignored-prefixes
1097 (string-match gnus-simplify-ignored-prefixes subject))
1098 (setq subject (substring subject (match-end 0))))
1100 (inline (gnus-simplify-buffer-fuzzy))
1103 (defsubst gnus-simplify-subject-fully (subject)
1104 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1106 (gnus-simplify-subject-functions
1107 (gnus-map-function gnus-simplify-subject-functions subject))
1108 ((null gnus-summary-gather-subject-limit)
1109 (gnus-simplify-subject-re subject))
1110 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1111 (gnus-simplify-subject-fuzzy subject))
1112 ((numberp gnus-summary-gather-subject-limit)
1113 (gnus-limit-string (gnus-simplify-subject-re subject)
1114 gnus-summary-gather-subject-limit))
1118 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1119 "Check whether two subjects are equal.
1120 If optional argument simple-first is t, first argument is already
1123 ((null simple-first)
1124 (equal (gnus-simplify-subject-fully s1)
1125 (gnus-simplify-subject-fully s2)))
1128 (gnus-simplify-subject-fully s2)))))
1130 (defun gnus-summary-bubble-group ()
1131 "Increase the score of the current group.
1132 This is a handy function to add to `gnus-summary-exit-hook' to
1133 increase the score of each group you read."
1134 (gnus-group-add-score gnus-newsgroup-name))
1138 ;;; Gnus summary mode
1141 (put 'gnus-summary-mode 'mode-class 'special)
1144 ;; Non-orthogonal keys
1146 (gnus-define-keys gnus-summary-mode-map
1147 " " gnus-summary-next-page
1148 "\177" gnus-summary-prev-page
1149 [delete] gnus-summary-prev-page
1150 [backspace] gnus-summary-prev-page
1151 "\r" gnus-summary-scroll-up
1152 "\e\r" gnus-summary-scroll-down
1153 "n" gnus-summary-next-unread-article
1154 "p" gnus-summary-prev-unread-article
1155 "N" gnus-summary-next-article
1156 "P" gnus-summary-prev-article
1157 "\M-\C-n" gnus-summary-next-same-subject
1158 "\M-\C-p" gnus-summary-prev-same-subject
1159 "\M-n" gnus-summary-next-unread-subject
1160 "\M-p" gnus-summary-prev-unread-subject
1161 "." gnus-summary-first-unread-article
1162 "," gnus-summary-best-unread-article
1163 "\M-s" gnus-summary-search-article-forward
1164 "\M-r" gnus-summary-search-article-backward
1165 "<" gnus-summary-beginning-of-article
1166 ">" gnus-summary-end-of-article
1167 "j" gnus-summary-goto-article
1168 "^" gnus-summary-refer-parent-article
1169 "\M-^" gnus-summary-refer-article
1170 "u" gnus-summary-tick-article-forward
1171 "!" gnus-summary-tick-article-forward
1172 "U" gnus-summary-tick-article-backward
1173 "d" gnus-summary-mark-as-read-forward
1174 "D" gnus-summary-mark-as-read-backward
1175 "E" gnus-summary-mark-as-expirable
1176 "\M-u" gnus-summary-clear-mark-forward
1177 "\M-U" gnus-summary-clear-mark-backward
1178 "k" gnus-summary-kill-same-subject-and-select
1179 "\C-k" gnus-summary-kill-same-subject
1180 "\M-\C-k" gnus-summary-kill-thread
1181 "\M-\C-l" gnus-summary-lower-thread
1182 "e" gnus-summary-edit-article
1183 "#" gnus-summary-mark-as-processable
1184 "\M-#" gnus-summary-unmark-as-processable
1185 "\M-\C-t" gnus-summary-toggle-threads
1186 "\M-\C-s" gnus-summary-show-thread
1187 "\M-\C-h" gnus-summary-hide-thread
1188 "\M-\C-f" gnus-summary-next-thread
1189 "\M-\C-b" gnus-summary-prev-thread
1190 "\M-\C-u" gnus-summary-up-thread
1191 "\M-\C-d" gnus-summary-down-thread
1192 "&" gnus-summary-execute-command
1193 "c" gnus-summary-catchup-and-exit
1194 "\C-w" gnus-summary-mark-region-as-read
1195 "\C-t" gnus-summary-toggle-truncation
1196 "?" gnus-summary-mark-as-dormant
1197 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1198 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1199 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1200 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1201 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1202 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1203 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1204 "=" gnus-summary-expand-window
1205 "\C-x\C-s" gnus-summary-reselect-current-group
1206 "\M-g" gnus-summary-rescan-group
1207 "w" gnus-summary-stop-page-breaking
1208 "\C-c\C-r" gnus-summary-caesar-message
1209 "\M-t" gnus-summary-toggle-mime
1210 "f" gnus-summary-followup
1211 "F" gnus-summary-followup-with-original
1212 "C" gnus-summary-cancel-article
1213 "r" gnus-summary-reply
1214 "R" gnus-summary-reply-with-original
1215 "\C-c\C-f" gnus-summary-mail-forward
1216 "o" gnus-summary-save-article
1217 "\C-o" gnus-summary-save-article-mail
1218 "|" gnus-summary-pipe-output
1219 "\M-k" gnus-summary-edit-local-kill
1220 "\M-K" gnus-summary-edit-global-kill
1222 "\C-c\C-d" gnus-summary-describe-group
1223 "q" gnus-summary-exit
1224 "Q" gnus-summary-exit-no-update
1225 "\C-c\C-i" gnus-info-find-node
1226 gnus-mouse-2 gnus-mouse-pick-article
1227 "m" gnus-summary-mail-other-window
1228 "a" gnus-summary-post-news
1229 "x" gnus-summary-limit-to-unread
1230 "s" gnus-summary-isearch-article
1231 "t" gnus-article-hide-headers
1232 "g" gnus-summary-show-article
1233 "l" gnus-summary-goto-last-article
1234 "v" gnus-summary-preview-mime-message
1235 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1236 "\C-d" gnus-summary-enter-digest-group
1237 "\M-\C-d" gnus-summary-read-document
1238 "\M-\C-e" gnus-summary-edit-parameters
1240 "*" gnus-cache-enter-article
1241 "\M-*" gnus-cache-remove-article
1242 "\M-&" gnus-summary-universal-argument
1243 "\C-l" gnus-recenter
1244 "I" gnus-summary-increase-score
1245 "L" gnus-summary-lower-score
1246 "\M-i" gnus-symbolic-argument
1247 "h" gnus-summary-select-article-buffer
1249 "V" gnus-summary-score-map
1250 "X" gnus-uu-extract-map
1251 "S" gnus-summary-send-map)
1253 ;; Sort of orthogonal keymap
1254 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1255 "t" gnus-summary-tick-article-forward
1256 "!" gnus-summary-tick-article-forward
1257 "d" gnus-summary-mark-as-read-forward
1258 "r" gnus-summary-mark-as-read-forward
1259 "c" gnus-summary-clear-mark-forward
1260 " " gnus-summary-clear-mark-forward
1261 "e" gnus-summary-mark-as-expirable
1262 "x" gnus-summary-mark-as-expirable
1263 "?" gnus-summary-mark-as-dormant
1264 "b" gnus-summary-set-bookmark
1265 "B" gnus-summary-remove-bookmark
1266 "#" gnus-summary-mark-as-processable
1267 "\M-#" gnus-summary-unmark-as-processable
1268 "S" gnus-summary-limit-include-expunged
1269 "C" gnus-summary-catchup
1270 "H" gnus-summary-catchup-to-here
1271 "\C-c" gnus-summary-catchup-all
1272 "k" gnus-summary-kill-same-subject-and-select
1273 "K" gnus-summary-kill-same-subject
1274 "P" gnus-uu-mark-map)
1276 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1277 "c" gnus-summary-clear-above
1278 "u" gnus-summary-tick-above
1279 "m" gnus-summary-mark-above
1280 "k" gnus-summary-kill-below)
1282 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1283 "/" gnus-summary-limit-to-subject
1284 "n" gnus-summary-limit-to-articles
1285 "w" gnus-summary-pop-limit
1286 "s" gnus-summary-limit-to-subject
1287 "a" gnus-summary-limit-to-author
1288 "u" gnus-summary-limit-to-unread
1289 "m" gnus-summary-limit-to-marks
1290 "v" gnus-summary-limit-to-score
1291 "*" gnus-summary-limit-include-cached
1292 "D" gnus-summary-limit-include-dormant
1293 "T" gnus-summary-limit-include-thread
1294 "d" gnus-summary-limit-exclude-dormant
1295 "t" gnus-summary-limit-to-age
1296 "E" gnus-summary-limit-include-expunged
1297 "c" gnus-summary-limit-exclude-childless-dormant
1298 "C" gnus-summary-limit-mark-excluded-as-read)
1300 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1301 "n" gnus-summary-next-unread-article
1302 "p" gnus-summary-prev-unread-article
1303 "N" gnus-summary-next-article
1304 "P" gnus-summary-prev-article
1305 "\C-n" gnus-summary-next-same-subject
1306 "\C-p" gnus-summary-prev-same-subject
1307 "\M-n" gnus-summary-next-unread-subject
1308 "\M-p" gnus-summary-prev-unread-subject
1309 "f" gnus-summary-first-unread-article
1310 "b" gnus-summary-best-unread-article
1311 "j" gnus-summary-goto-article
1312 "g" gnus-summary-goto-subject
1313 "l" gnus-summary-goto-last-article
1314 "o" gnus-summary-pop-article)
1316 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1317 "k" gnus-summary-kill-thread
1318 "l" gnus-summary-lower-thread
1319 "i" gnus-summary-raise-thread
1320 "T" gnus-summary-toggle-threads
1321 "t" gnus-summary-rethread-current
1322 "^" gnus-summary-reparent-thread
1323 "s" gnus-summary-show-thread
1324 "S" gnus-summary-show-all-threads
1325 "h" gnus-summary-hide-thread
1326 "H" gnus-summary-hide-all-threads
1327 "n" gnus-summary-next-thread
1328 "p" gnus-summary-prev-thread
1329 "u" gnus-summary-up-thread
1330 "o" gnus-summary-top-thread
1331 "d" gnus-summary-down-thread
1332 "#" gnus-uu-mark-thread
1333 "\M-#" gnus-uu-unmark-thread)
1335 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1336 "g" gnus-summary-prepare
1337 "c" gnus-summary-insert-cached-articles)
1339 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1340 "c" gnus-summary-catchup-and-exit
1341 "C" gnus-summary-catchup-all-and-exit
1342 "E" gnus-summary-exit-no-update
1343 "Q" gnus-summary-exit
1344 "Z" gnus-summary-exit
1345 "n" gnus-summary-catchup-and-goto-next-group
1346 "R" gnus-summary-reselect-current-group
1347 "G" gnus-summary-rescan-group
1348 "N" gnus-summary-next-group
1349 "s" gnus-summary-save-newsrc
1350 "P" gnus-summary-prev-group)
1352 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1353 " " gnus-summary-next-page
1354 "n" gnus-summary-next-page
1355 "\177" gnus-summary-prev-page
1356 [delete] gnus-summary-prev-page
1357 "p" gnus-summary-prev-page
1358 "\r" gnus-summary-scroll-up
1359 "<" gnus-summary-beginning-of-article
1360 ">" gnus-summary-end-of-article
1361 "b" gnus-summary-beginning-of-article
1362 "e" gnus-summary-end-of-article
1363 "^" gnus-summary-refer-parent-article
1364 "r" gnus-summary-refer-parent-article
1365 "R" gnus-summary-refer-references
1366 "T" gnus-summary-refer-thread
1367 "g" gnus-summary-show-article
1368 "s" gnus-summary-isearch-article
1369 "P" gnus-summary-print-article)
1371 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1372 "b" gnus-article-add-buttons
1373 "B" gnus-article-add-buttons-to-head
1374 "o" gnus-article-treat-overstrike
1375 "e" gnus-article-emphasize
1376 "w" gnus-article-fill-cited-article
1377 "c" gnus-article-remove-cr
1378 "f" gnus-article-display-x-face
1379 "l" gnus-summary-stop-page-breaking
1380 "r" gnus-summary-caesar-message
1381 "t" gnus-article-hide-headers
1382 "v" gnus-summary-verbose-headers
1383 "m" gnus-summary-toggle-mime
1384 "h" gnus-article-treat-html
1385 "d" gnus-article-treat-dumbquotes)
1387 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1388 "a" gnus-article-hide
1389 "h" gnus-article-hide-headers
1390 "b" gnus-article-hide-boring-headers
1391 "s" gnus-article-hide-signature
1392 "c" gnus-article-hide-citation
1393 "p" gnus-article-hide-pgp
1394 "P" gnus-article-hide-pem
1395 "\C-c" gnus-article-hide-citation-maybe)
1397 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1398 "a" gnus-article-highlight
1399 "h" gnus-article-highlight-headers
1400 "c" gnus-article-highlight-citation
1401 "s" gnus-article-highlight-signature)
1403 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1404 "z" gnus-article-date-ut
1405 "u" gnus-article-date-ut
1406 "l" gnus-article-date-local
1407 "e" gnus-article-date-lapsed
1408 "o" gnus-article-date-original
1409 "i" gnus-article-date-iso8601
1410 "s" gnus-article-date-user)
1412 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1413 "t" gnus-article-remove-trailing-blank-lines
1414 "l" gnus-article-strip-leading-blank-lines
1415 "m" gnus-article-strip-multiple-blank-lines
1416 "a" gnus-article-strip-blank-lines
1417 "A" gnus-article-strip-all-blank-lines
1418 "s" gnus-article-strip-leading-space)
1420 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1422 "f" gnus-summary-fetch-faq
1423 "d" gnus-summary-describe-group
1424 "h" gnus-summary-describe-briefly
1425 "i" gnus-info-find-node)
1427 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1428 "e" gnus-summary-expire-articles
1429 "\M-\C-e" gnus-summary-expire-articles-now
1430 "\177" gnus-summary-delete-article
1431 [delete] gnus-summary-delete-article
1432 "m" gnus-summary-move-article
1433 "r" gnus-summary-respool-article
1434 "w" gnus-summary-edit-article
1435 "c" gnus-summary-copy-article
1436 "B" gnus-summary-crosspost-article
1437 "q" gnus-summary-respool-query
1438 "t" gnus-summary-respool-trace
1439 "i" gnus-summary-import-article
1440 "p" gnus-summary-article-posted-p)
1442 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1443 "o" gnus-summary-save-article
1444 "m" gnus-summary-save-article-mail
1445 "F" gnus-summary-write-article-file
1446 "r" gnus-summary-save-article-rmail
1447 "f" gnus-summary-save-article-file
1448 "b" gnus-summary-save-article-body-file
1449 "h" gnus-summary-save-article-folder
1450 "v" gnus-summary-save-article-vm
1451 "p" gnus-summary-pipe-output
1452 "s" gnus-soup-add-article))
1454 (defun gnus-summary-make-menu-bar ()
1455 (gnus-turn-off-edit-menu 'summary)
1457 (unless (boundp 'gnus-summary-misc-menu)
1460 gnus-summary-kill-menu gnus-summary-mode-map ""
1465 ["Enter score..." gnus-summary-score-entry t]
1466 ["Customize" gnus-score-customize t])
1467 (gnus-make-score-map 'increase)
1468 (gnus-make-score-map 'lower)
1470 ["Kill below" gnus-summary-kill-below t]
1471 ["Mark above" gnus-summary-mark-above t]
1472 ["Tick above" gnus-summary-tick-above t]
1473 ["Clear above" gnus-summary-clear-above t])
1474 ["Current score" gnus-summary-current-score t]
1475 ["Set score" gnus-summary-set-score t]
1476 ["Switch current score file..." gnus-score-change-score-file t]
1477 ["Set mark below..." gnus-score-set-mark-below t]
1478 ["Set expunge below..." gnus-score-set-expunge-below t]
1479 ["Edit current score file" gnus-score-edit-current-scores t]
1480 ["Edit score file" gnus-score-edit-file t]
1481 ["Trace score" gnus-score-find-trace t]
1482 ["Find words" gnus-score-find-favourite-words t]
1483 ["Rescore buffer" gnus-summary-rescore t]
1484 ["Increase score..." gnus-summary-increase-score t]
1485 ["Lower score..." gnus-summary-lower-score t]))))
1487 ;; Define both the Article menu in the summary buffer and the equivalent
1488 ;; Commands menu in the article buffer here for consistency.
1491 ["All" gnus-article-hide t]
1492 ["Headers" gnus-article-hide-headers t]
1493 ["Signature" gnus-article-hide-signature t]
1494 ["Citation" gnus-article-hide-citation t]
1495 ["PGP" gnus-article-hide-pgp t]
1496 ["Boring headers" gnus-article-hide-boring-headers t])
1498 ["All" gnus-article-highlight t]
1499 ["Headers" gnus-article-highlight-headers t]
1500 ["Signature" gnus-article-highlight-signature t]
1501 ["Citation" gnus-article-highlight-citation t])
1503 ["Local" gnus-article-date-local t]
1504 ["ISO8601" gnus-article-date-iso8601 t]
1505 ["UT" gnus-article-date-ut t]
1506 ["Original" gnus-article-date-original t]
1507 ["Lapsed" gnus-article-date-lapsed t]
1508 ["User-defined" gnus-article-date-user t])
1511 ["Leading" gnus-article-strip-leading-blank-lines t]
1512 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1513 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1514 ["All of the above" gnus-article-strip-blank-lines t]
1515 ["All" gnus-article-strip-all-blank-lines t]
1516 ["Leading space" gnus-article-strip-leading-space t])
1517 ["Overstrike" gnus-article-treat-overstrike t]
1518 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1519 ["Emphasis" gnus-article-emphasize t]
1520 ["Word wrap" gnus-article-fill-cited-article t]
1521 ["CR" gnus-article-remove-cr t]
1522 ["Show X-Face" gnus-article-display-x-face t]
1523 ["UnHTMLize" gnus-article-treat-html t]
1524 ["Rot 13" gnus-summary-caesar-message t]
1525 ["Unix pipe" gnus-summary-pipe-message t]
1526 ["Add buttons" gnus-article-add-buttons t]
1527 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1528 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1529 ["Toggle MIME" gnus-summary-toggle-mime t]
1530 ["Verbose header" gnus-summary-verbose-headers t]
1531 ["Toggle header" gnus-summary-toggle-header t])
1533 ["Save in default format" gnus-summary-save-article t]
1534 ["Save in file" gnus-summary-save-article-file t]
1535 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1536 ["Save in MH folder" gnus-summary-save-article-folder t]
1537 ["Save in VM folder" gnus-summary-save-article-vm t]
1538 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1539 ["Save body in file" gnus-summary-save-article-body-file t]
1540 ["Pipe through a filter" gnus-summary-pipe-output t]
1541 ["Add to SOUP packet" gnus-soup-add-article t]
1542 ["Print" gnus-summary-print-article t])
1544 ["Respool article..." gnus-summary-respool-article t]
1545 ["Move article..." gnus-summary-move-article
1546 (gnus-check-backend-function
1547 'request-move-article gnus-newsgroup-name)]
1548 ["Copy article..." gnus-summary-copy-article t]
1549 ["Crosspost article..." gnus-summary-crosspost-article
1550 (gnus-check-backend-function
1551 'request-replace-article gnus-newsgroup-name)]
1552 ["Import file..." gnus-summary-import-article t]
1553 ["Check if posted" gnus-summary-article-posted-p t]
1554 ["Edit article" gnus-summary-edit-article
1555 (not (gnus-group-read-only-p))]
1556 ["Delete article" gnus-summary-delete-article
1557 (gnus-check-backend-function
1558 'request-expire-articles gnus-newsgroup-name)]
1559 ["Query respool" gnus-summary-respool-query t]
1560 ["Trace respool" gnus-summary-respool-trace t]
1561 ["Delete expirable articles" gnus-summary-expire-articles-now
1562 (gnus-check-backend-function
1563 'request-expire-articles gnus-newsgroup-name)])
1565 ["Uudecode" gnus-uu-decode-uu t]
1566 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1567 ["Unshar" gnus-uu-decode-unshar t]
1568 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1569 ["Save" gnus-uu-decode-save t]
1570 ["Binhex" gnus-uu-decode-binhex t]
1571 ["Postscript" gnus-uu-decode-postscript t])
1573 ["Enter article" gnus-cache-enter-article t]
1574 ["Remove article" gnus-cache-remove-article t])
1575 ["Select article buffer" gnus-summary-select-article-buffer t]
1576 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1577 ["Isearch article..." gnus-summary-isearch-article t]
1578 ["Beginning of the article" gnus-summary-beginning-of-article t]
1579 ["End of the article" gnus-summary-end-of-article t]
1580 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1581 ["Fetch referenced articles" gnus-summary-refer-references t]
1582 ["Fetch current thread" gnus-summary-refer-thread t]
1583 ["Fetch article with id..." gnus-summary-refer-article t]
1584 ["Redisplay" gnus-summary-show-article t])))
1586 gnus-summary-article-menu gnus-summary-mode-map ""
1587 (cons "Article" innards))
1590 gnus-article-commands-menu gnus-article-mode-map ""
1591 (cons "Commands" innards)))
1594 gnus-summary-thread-menu gnus-summary-mode-map ""
1596 ["Toggle threading" gnus-summary-toggle-threads t]
1597 ["Hide threads" gnus-summary-hide-all-threads t]
1598 ["Show threads" gnus-summary-show-all-threads t]
1599 ["Hide thread" gnus-summary-hide-thread t]
1600 ["Show thread" gnus-summary-show-thread t]
1601 ["Go to next thread" gnus-summary-next-thread t]
1602 ["Go to previous thread" gnus-summary-prev-thread t]
1603 ["Go down thread" gnus-summary-down-thread t]
1604 ["Go up thread" gnus-summary-up-thread t]
1605 ["Top of thread" gnus-summary-top-thread t]
1606 ["Mark thread as read" gnus-summary-kill-thread t]
1607 ["Lower thread score" gnus-summary-lower-thread t]
1608 ["Raise thread score" gnus-summary-raise-thread t]
1609 ["Rethread current" gnus-summary-rethread-current t]
1613 gnus-summary-post-menu gnus-summary-mode-map ""
1615 ["Post an article" gnus-summary-post-news t]
1616 ["Followup" gnus-summary-followup t]
1617 ["Followup and yank" gnus-summary-followup-with-original t]
1618 ["Supersede article" gnus-summary-supersede-article t]
1619 ["Cancel article" gnus-summary-cancel-article t]
1620 ["Reply" gnus-summary-reply t]
1621 ["Reply and yank" gnus-summary-reply-with-original t]
1622 ["Wide reply" gnus-summary-wide-reply t]
1623 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1624 ["Mail forward" gnus-summary-mail-forward t]
1625 ["Post forward" gnus-summary-post-forward t]
1626 ["Digest and mail" gnus-uu-digest-mail-forward t]
1627 ["Digest and post" gnus-uu-digest-post-forward t]
1628 ["Resend message" gnus-summary-resend-message t]
1629 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1630 ["Send a mail" gnus-summary-mail-other-window t]
1631 ["Uuencode and post" gnus-uu-post-news t]
1632 ["Followup via news" gnus-summary-followup-to-mail t]
1633 ["Followup via news and yank"
1634 gnus-summary-followup-to-mail-with-original t]
1636 ;;["Send" gnus-summary-send-draft t]
1637 ;;["Send bounced" gnus-resend-bounced-mail t])
1641 gnus-summary-misc-menu gnus-summary-mode-map ""
1644 ["Mark as read" gnus-summary-mark-as-read-forward t]
1645 ["Mark same subject and select"
1646 gnus-summary-kill-same-subject-and-select t]
1647 ["Mark same subject" gnus-summary-kill-same-subject t]
1648 ["Catchup" gnus-summary-catchup t]
1649 ["Catchup all" gnus-summary-catchup-all t]
1650 ["Catchup to here" gnus-summary-catchup-to-here t]
1651 ["Catchup region" gnus-summary-mark-region-as-read t]
1652 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1654 ["Tick" gnus-summary-tick-article-forward t]
1655 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1656 ["Remove marks" gnus-summary-clear-mark-forward t]
1657 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1658 ["Set bookmark" gnus-summary-set-bookmark t]
1659 ["Remove bookmark" gnus-summary-remove-bookmark t])
1661 ["Marks..." gnus-summary-limit-to-marks t]
1662 ["Subject..." gnus-summary-limit-to-subject t]
1663 ["Author..." gnus-summary-limit-to-author t]
1664 ["Age..." gnus-summary-limit-to-age t]
1665 ["Score" gnus-summary-limit-to-score t]
1666 ["Unread" gnus-summary-limit-to-unread t]
1667 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1668 ["Articles" gnus-summary-limit-to-articles t]
1669 ["Pop limit" gnus-summary-pop-limit t]
1670 ["Show dormant" gnus-summary-limit-include-dormant t]
1671 ["Hide childless dormant"
1672 gnus-summary-limit-exclude-childless-dormant t]
1673 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1674 ["Show expunged" gnus-summary-show-all-expunged t])
1676 ["Set mark" gnus-summary-mark-as-processable t]
1677 ["Remove mark" gnus-summary-unmark-as-processable t]
1678 ["Remove all marks" gnus-summary-unmark-all-processable t]
1679 ["Mark above" gnus-uu-mark-over t]
1680 ["Mark series" gnus-uu-mark-series t]
1681 ["Mark region" gnus-uu-mark-region t]
1682 ["Unmark region" gnus-uu-unmark-region t]
1683 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1684 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1685 ["Mark all" gnus-uu-mark-all t]
1686 ["Mark buffer" gnus-uu-mark-buffer t]
1687 ["Mark sparse" gnus-uu-mark-sparse t]
1688 ["Mark thread" gnus-uu-mark-thread t]
1689 ["Unmark thread" gnus-uu-unmark-thread t]
1690 ("Process Mark Sets"
1691 ["Kill" gnus-summary-kill-process-mark t]
1692 ["Yank" gnus-summary-yank-process-mark
1693 gnus-newsgroup-process-stack]
1694 ["Save" gnus-summary-save-process-mark t]))
1696 ["Page forward" gnus-summary-next-page t]
1697 ["Page backward" gnus-summary-prev-page t]
1698 ["Line forward" gnus-summary-scroll-up t])
1700 ["Next unread article" gnus-summary-next-unread-article t]
1701 ["Previous unread article" gnus-summary-prev-unread-article t]
1702 ["Next article" gnus-summary-next-article t]
1703 ["Previous article" gnus-summary-prev-article t]
1704 ["Next unread subject" gnus-summary-next-unread-subject t]
1705 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1706 ["Next article same subject" gnus-summary-next-same-subject t]
1707 ["Previous article same subject" gnus-summary-prev-same-subject t]
1708 ["First unread article" gnus-summary-first-unread-article t]
1709 ["Best unread article" gnus-summary-best-unread-article t]
1710 ["Go to subject number..." gnus-summary-goto-subject t]
1711 ["Go to article number..." gnus-summary-goto-article t]
1712 ["Go to the last article" gnus-summary-goto-last-article t]
1713 ["Pop article off history" gnus-summary-pop-article t])
1715 ["Sort by number" gnus-summary-sort-by-number t]
1716 ["Sort by author" gnus-summary-sort-by-author t]
1717 ["Sort by subject" gnus-summary-sort-by-subject t]
1718 ["Sort by date" gnus-summary-sort-by-date t]
1719 ["Sort by score" gnus-summary-sort-by-score t]
1720 ["Sort by lines" gnus-summary-sort-by-lines t])
1722 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1723 ["Describe group" gnus-summary-describe-group t]
1724 ["Read manual" gnus-info-find-node t])
1726 ["Pick and read" gnus-pick-mode t]
1727 ["Binary" gnus-binary-mode t])
1729 ["Regenerate" gnus-summary-prepare t]
1730 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1731 ["Toggle threading" gnus-summary-toggle-threads t])
1732 ["Filter articles..." gnus-summary-execute-command t]
1733 ["Run command on subjects..." gnus-summary-universal-argument t]
1734 ["Search articles forward..." gnus-summary-search-article-forward t]
1735 ["Search articles backward..." gnus-summary-search-article-backward t]
1736 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1737 ["Expand window" gnus-summary-expand-window t]
1738 ["Expire expirable articles" gnus-summary-expire-articles
1739 (gnus-check-backend-function
1740 'request-expire-articles gnus-newsgroup-name)]
1741 ["Edit local kill file" gnus-summary-edit-local-kill t]
1742 ["Edit main kill file" gnus-summary-edit-global-kill t]
1743 ["Edit group parameters" gnus-summary-edit-parameters t]
1745 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1746 ["Catchup all and exit" gnus-summary-catchup-and-exit t]
1747 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1748 ["Exit group" gnus-summary-exit t]
1749 ["Exit group without updating" gnus-summary-exit-no-update t]
1750 ["Exit and goto next group" gnus-summary-next-group t]
1751 ["Exit and goto prev group" gnus-summary-prev-group t]
1752 ["Reselect group" gnus-summary-reselect-current-group t]
1753 ["Rescan group" gnus-summary-rescan-group t]
1754 ["Update dribble" gnus-summary-save-newsrc t])))
1756 (gnus-run-hooks 'gnus-summary-menu-hook)))
1758 (defun gnus-score-set-default (var value)
1759 "A version of set that updates the GNU Emacs menu-bar."
1761 ;; It is the message that forces the active status to be updated.
1764 (defun gnus-make-score-map (type)
1765 "Make a summary score map of type TYPE."
1768 (let ((headers '(("author" "from" string)
1769 ("subject" "subject" string)
1770 ("article body" "body" string)
1771 ("article head" "head" string)
1772 ("xref" "xref" string)
1773 ("lines" "lines" number)
1774 ("followups to author" "followup" string)))
1775 (types '((number ("less than" <)
1778 (string ("substring" s)
1782 (perms '(("temporary" (current-time-string))
1790 (if (eq type 'lower)
1795 (setq header (car headers))
1801 (let ((ts (cdr (assoc (nth 2 header) types)))
1817 'gnus-summary-score-entry
1819 (if (or (string= (nth 1 header)
1821 (string= (nth 1 header)
1824 (list 'gnus-summary-header
1826 (list 'quote (nth 1 (car ts)))
1827 (list 'gnus-score-default nil)
1833 (list (nreverse outp))))
1836 (list (nreverse outt))))
1838 (setq headers (cdr headers)))
1839 (list (nreverse outh))))))))
1843 (defun gnus-summary-mode (&optional group)
1844 "Major mode for reading articles.
1846 All normal editing commands are switched off.
1847 \\<gnus-summary-mode-map>
1848 Each line in this buffer represents one article. To read an
1849 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
1850 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
1853 You can also post articles and send mail from this buffer. To
1854 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
1855 of an article, type `\\[gnus-summary-reply]'.
1857 There are approx. one gazillion commands you can execute in this
1858 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
1860 The following commands are available:
1862 \\{gnus-summary-mode-map}"
1864 (when (gnus-visual-p 'summary-menu 'menu)
1865 (gnus-summary-make-menu-bar))
1866 (kill-all-local-variables)
1867 (gnus-summary-make-local-variables)
1868 (gnus-make-thread-indent-array)
1869 (gnus-simplify-mode-line)
1870 (setq major-mode 'gnus-summary-mode)
1871 (setq mode-name "Summary")
1872 (make-local-variable 'minor-mode-alist)
1873 (use-local-map gnus-summary-mode-map)
1874 (buffer-disable-undo (current-buffer))
1875 (setq buffer-read-only t) ;Disable modification
1876 (setq truncate-lines t)
1877 (setq selective-display t)
1878 (setq selective-display-ellipses t) ;Display `...'
1879 (gnus-summary-set-display-table)
1880 (gnus-set-default-directory)
1881 (setq gnus-newsgroup-name group)
1882 (make-local-variable 'gnus-summary-line-format)
1883 (make-local-variable 'gnus-summary-line-format-spec)
1884 (make-local-variable 'gnus-summary-dummy-line-format)
1885 (make-local-variable 'gnus-summary-dummy-line-format-spec)
1886 (make-local-variable 'gnus-summary-mark-positions)
1887 (make-local-hook 'post-command-hook)
1888 (add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
1889 (make-local-hook 'pre-command-hook)
1890 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
1891 (gnus-run-hooks 'gnus-summary-mode-hook)
1892 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
1893 (gnus-update-summary-mark-positions))
1895 (defun gnus-summary-make-local-variables ()
1896 "Make all the local summary buffer variables."
1897 (let ((locals gnus-summary-local-variables)
1899 (while (setq local (pop locals))
1902 (if (eq (cdr local) 'global)
1903 ;; Copy the global value of the variable.
1904 (setq global (symbol-value (car local)))
1905 ;; Use the value from the list.
1906 (setq global (eval (cdr local))))
1907 (make-local-variable (car local))
1908 (set (car local) global))
1909 ;; Simple nil-valued local variable.
1910 (make-local-variable local)
1913 (defun gnus-summary-clear-local-variables ()
1914 (let ((locals gnus-summary-local-variables))
1916 (if (consp (car locals))
1917 (and (vectorp (caar locals))
1918 (set (caar locals) nil))
1919 (and (vectorp (car locals))
1920 (set (car locals) nil)))
1921 (setq locals (cdr locals)))))
1923 ;; Summary data functions.
1925 (defmacro gnus-data-number (data)
1928 (defmacro gnus-data-set-number (data number)
1929 `(setcar ,data ,number))
1931 (defmacro gnus-data-mark (data)
1934 (defmacro gnus-data-set-mark (data mark)
1935 `(setcar (nthcdr 1 ,data) ,mark))
1937 (defmacro gnus-data-pos (data)
1940 (defmacro gnus-data-set-pos (data pos)
1941 `(setcar (nthcdr 2 ,data) ,pos))
1943 (defmacro gnus-data-header (data)
1946 (defmacro gnus-data-set-header (data header)
1947 `(setf (nth 3 ,data) ,header))
1949 (defmacro gnus-data-level (data)
1952 (defmacro gnus-data-unread-p (data)
1953 `(= (nth 1 ,data) gnus-unread-mark))
1955 (defmacro gnus-data-read-p (data)
1956 `(/= (nth 1 ,data) gnus-unread-mark))
1958 (defmacro gnus-data-pseudo-p (data)
1959 `(consp (nth 3 ,data)))
1961 (defmacro gnus-data-find (number)
1962 `(assq ,number gnus-newsgroup-data))
1964 (defmacro gnus-data-find-list (number &optional data)
1965 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
1966 (memq (assq ,number bdata)
1969 (defmacro gnus-data-make (number mark pos header level)
1970 `(list ,number ,mark ,pos ,header ,level))
1972 (defun gnus-data-enter (after-article number mark pos header level offset)
1973 (let ((data (gnus-data-find-list after-article)))
1975 (error "No such article: %d" after-article))
1976 (setcdr data (cons (gnus-data-make number mark pos header level)
1978 (setq gnus-newsgroup-data-reverse nil)
1979 (gnus-data-update-list (cddr data) offset)))
1981 (defun gnus-data-enter-list (after-article list &optional offset)
1983 (let ((data (and after-article (gnus-data-find-list after-article)))
1985 (or data (not after-article) (error "No such article: %d" after-article))
1986 ;; Find the last element in the list to be spliced into the main
1989 (setq list (cdr list)))
1992 (setcdr list gnus-newsgroup-data)
1993 (setq gnus-newsgroup-data ilist)
1995 (gnus-data-update-list (cdr list) offset)))
1996 (setcdr list (cdr data))
1999 (gnus-data-update-list (cdr list) offset)))
2000 (setq gnus-newsgroup-data-reverse nil))))
2002 (defun gnus-data-remove (article &optional offset)
2003 (let ((data gnus-newsgroup-data))
2004 (if (= (gnus-data-number (car data)) article)
2006 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2007 gnus-newsgroup-data-reverse nil)
2009 (gnus-data-update-list gnus-newsgroup-data offset)))
2011 (when (= (gnus-data-number (cadr data)) article)
2012 (setcdr data (cddr data))
2014 (gnus-data-update-list (cdr data) offset))
2016 gnus-newsgroup-data-reverse nil))
2017 (setq data (cdr data))))))
2019 (defmacro gnus-data-list (backward)
2021 (or gnus-newsgroup-data-reverse
2022 (setq gnus-newsgroup-data-reverse
2023 (reverse gnus-newsgroup-data)))
2024 gnus-newsgroup-data))
2026 (defun gnus-data-update-list (data offset)
2027 "Add OFFSET to the POS of all data entries in DATA."
2029 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2030 (setq data (cdr data))))
2032 (defun gnus-data-compute-positions ()
2033 "Compute the positions of all articles."
2034 (let ((data gnus-newsgroup-data)
2037 (when (setq pos (text-property-any
2038 (point-min) (point-max)
2039 'gnus-number (gnus-data-number (car data))))
2040 (gnus-data-set-pos (car data) (+ pos 3)))
2041 (setq data (cdr data)))))
2043 (defun gnus-summary-article-pseudo-p (article)
2044 "Say whether this article is a pseudo article or not."
2045 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2047 (defmacro gnus-summary-article-sparse-p (article)
2048 "Say whether this article is a sparse article or not."
2049 `(memq ,article gnus-newsgroup-sparse))
2051 (defmacro gnus-summary-article-ancient-p (article)
2052 "Say whether this article is a sparse article or not."
2053 `(memq ,article gnus-newsgroup-ancient))
2055 (defun gnus-article-parent-p (number)
2056 "Say whether this article is a parent or not."
2057 (let ((data (gnus-data-find-list number)))
2058 (and (cdr data) ; There has to be an article after...
2059 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2060 (gnus-data-level (nth 1 data))))))
2062 (defun gnus-article-children (number)
2063 "Return a list of all children to NUMBER."
2064 (let* ((data (gnus-data-find-list number))
2065 (level (gnus-data-level (car data)))
2067 (setq data (cdr data))
2069 (= (gnus-data-level (car data)) (1+ level)))
2070 (push (gnus-data-number (car data)) children)
2071 (setq data (cdr data)))
2074 (defmacro gnus-summary-skip-intangible ()
2075 "If the current article is intangible, then jump to a different article."
2076 '(let ((to (get-text-property (point) 'gnus-intangible)))
2077 (and to (gnus-summary-goto-subject to))))
2079 (defmacro gnus-summary-article-intangible-p ()
2080 "Say whether this article is intangible or not."
2081 '(get-text-property (point) 'gnus-intangible))
2083 (defun gnus-article-read-p (article)
2084 "Say whether ARTICLE is read or not."
2085 (not (or (memq article gnus-newsgroup-marked)
2086 (memq article gnus-newsgroup-unreads)
2087 (memq article gnus-newsgroup-unselected)
2088 (memq article gnus-newsgroup-dormant))))
2090 ;; Some summary mode macros.
2092 (defmacro gnus-summary-article-number ()
2093 "The article number of the article on the current line.
2094 If there isn's an article number here, then we return the current
2097 (gnus-summary-skip-intangible)
2098 (or (get-text-property (point) 'gnus-number)
2099 (gnus-summary-last-subject))))
2101 (defmacro gnus-summary-article-header (&optional number)
2102 "Return the header of article NUMBER."
2103 `(gnus-data-header (gnus-data-find
2104 ,(or number '(gnus-summary-article-number)))))
2106 (defmacro gnus-summary-thread-level (&optional number)
2107 "Return the level of thread that starts with article NUMBER."
2108 `(if (and (eq gnus-summary-make-false-root 'dummy)
2109 (get-text-property (point) 'gnus-intangible))
2111 (gnus-data-level (gnus-data-find
2112 ,(or number '(gnus-summary-article-number))))))
2114 (defmacro gnus-summary-article-mark (&optional number)
2115 "Return the mark of article NUMBER."
2116 `(gnus-data-mark (gnus-data-find
2117 ,(or number '(gnus-summary-article-number)))))
2119 (defmacro gnus-summary-article-pos (&optional number)
2120 "Return the position of the line of article NUMBER."
2121 `(gnus-data-pos (gnus-data-find
2122 ,(or number '(gnus-summary-article-number)))))
2124 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2125 (defmacro gnus-summary-article-subject (&optional number)
2126 "Return current subject string or nil if nothing."
2129 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2130 '(gnus-data-header (assq (gnus-summary-article-number)
2131 gnus-newsgroup-data)))))
2134 (mail-header-subject headers))))
2136 (defmacro gnus-summary-article-score (&optional number)
2137 "Return current article score."
2138 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2139 gnus-newsgroup-scored))
2140 gnus-summary-default-score 0))
2142 (defun gnus-summary-article-children (&optional number)
2143 "Return a list of article numbers that are children of article NUMBER."
2144 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2145 (level (gnus-data-level (car data)))
2147 (while (and (setq data (cdr data))
2148 (> (setq l (gnus-data-level (car data))) level))
2149 (and (= (1+ level) l)
2150 (push (gnus-data-number (car data))
2152 (nreverse children)))
2154 (defun gnus-summary-article-parent (&optional number)
2155 "Return the article number of the parent of article NUMBER."
2156 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2157 (gnus-data-list t)))
2158 (level (gnus-data-level (car data))))
2160 () ; This is a root.
2161 ;; We search until we find an article with a level less than
2162 ;; this one. That function has to be the parent.
2163 (while (and (setq data (cdr data))
2164 (not (< (gnus-data-level (car data)) level))))
2165 (and data (gnus-data-number (car data))))))
2167 (defun gnus-unread-mark-p (mark)
2168 "Say whether MARK is the unread mark."
2169 (= mark gnus-unread-mark))
2171 (defun gnus-read-mark-p (mark)
2172 "Say whether MARK is one of the marks that mark as read.
2173 This is all marks except unread, ticked, dormant, and expirable."
2174 (not (or (= mark gnus-unread-mark)
2175 (= mark gnus-ticked-mark)
2176 (= mark gnus-dormant-mark)
2177 (= mark gnus-expirable-mark))))
2179 (defmacro gnus-article-mark (number)
2180 "Return the MARK of article NUMBER.
2181 This macro should only be used when computing the mark the \"first\"
2182 time; i.e., when generating the summary lines. After that,
2183 `gnus-summary-article-mark' should be used to examine the
2186 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2187 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2188 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2189 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2190 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2191 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2192 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2193 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2194 gnus-ancient-mark))))
2196 ;; Saving hidden threads.
2198 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2199 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2201 (defmacro gnus-save-hidden-threads (&rest forms)
2202 "Save hidden threads, eval FORMS, and restore the hidden threads."
2203 (let ((config (make-symbol "config")))
2204 `(let ((,config (gnus-hidden-threads-configuration)))
2208 (gnus-restore-hidden-threads-configuration ,config)))))
2210 (defun gnus-hidden-threads-configuration ()
2211 "Return the current hidden threads configuration."
2214 (goto-char (point-min))
2215 (while (search-forward "\r" nil t)
2216 (push (1- (point)) config))
2219 (defun gnus-restore-hidden-threads-configuration (config)
2220 "Restore hidden threads configuration from CONFIG."
2221 (let (point buffer-read-only)
2222 (while (setq point (pop config))
2223 (when (and (< point (point-max))
2225 (= (following-char) ?\n))
2226 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2228 ;; Various summary mode internalish functions.
2230 (defun gnus-mouse-pick-article (e)
2233 (gnus-summary-next-page nil t))
2235 (defun gnus-summary-set-display-table ()
2236 ;; Change the display table. Odd characters have a tendency to mess
2237 ;; up nicely formatted displays - we make all possible glyphs
2238 ;; display only a single character.
2240 ;; We start from the standard display table, if any.
2241 (let ((table (or (copy-sequence standard-display-table)
2242 (make-display-table)))
2244 ;; Nix out all the control chars...
2245 (while (>= (setq i (1- i)) 0)
2246 (aset table i [??]))
2247 ;; ... but not newline and cr, of course. (cr is necessary for the
2248 ;; selective display).
2249 (aset table ?\n nil)
2250 (aset table ?\r nil)
2251 ;; We keep TAB as well.
2252 (aset table ?\t nil)
2253 ;; We nix out any glyphs over 126 that are not set already.
2255 (while (>= (setq i (1- i)) 127)
2256 ;; Only modify if the entry is nil.
2257 (unless (aref table i)
2258 (aset table i [??]))))
2259 (setq buffer-display-table table)))
2261 (defun gnus-summary-setup-buffer (group)
2262 "Initialize summary buffer."
2263 (let ((buffer (concat "*Summary " group "*")))
2264 (if (get-buffer buffer)
2267 (setq gnus-summary-buffer (current-buffer))
2268 (not gnus-newsgroup-prepared))
2269 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2270 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
2271 (gnus-add-current-to-buffer-list)
2272 (gnus-summary-mode group)
2274 (gnus-carpal-setup-buffer 'summary))
2275 (unless gnus-single-article-buffer
2276 (make-local-variable 'gnus-article-buffer)
2277 (make-local-variable 'gnus-article-current)
2278 (make-local-variable 'gnus-original-article-buffer))
2279 (setq gnus-newsgroup-name group)
2282 (defun gnus-set-global-variables ()
2283 ;; Set the global equivalents of the summary buffer-local variables
2284 ;; to the latest values they had. These reflect the summary buffer
2285 ;; that was in action when the last article was fetched.
2286 (when (eq major-mode 'gnus-summary-mode)
2287 (setq gnus-summary-buffer (current-buffer))
2288 (let ((name gnus-newsgroup-name)
2289 (marked gnus-newsgroup-marked)
2290 (unread gnus-newsgroup-unreads)
2291 (headers gnus-current-headers)
2292 (data gnus-newsgroup-data)
2293 (summary gnus-summary-buffer)
2294 (article-buffer gnus-article-buffer)
2295 (original gnus-original-article-buffer)
2296 (gac gnus-article-current)
2297 (reffed gnus-reffed-article-number)
2298 (score-file gnus-current-score-file))
2300 (set-buffer gnus-group-buffer)
2301 (setq gnus-newsgroup-name name
2302 gnus-newsgroup-marked marked
2303 gnus-newsgroup-unreads unread
2304 gnus-current-headers headers
2305 gnus-newsgroup-data data
2306 gnus-article-current gac
2307 gnus-summary-buffer summary
2308 gnus-article-buffer article-buffer
2309 gnus-original-article-buffer original
2310 gnus-reffed-article-number reffed
2311 gnus-current-score-file score-file)
2312 ;; The article buffer also has local variables.
2313 (when (gnus-buffer-live-p gnus-article-buffer)
2314 (set-buffer gnus-article-buffer)
2315 (setq gnus-summary-buffer summary))))))
2317 (defun gnus-summary-article-unread-p (article)
2318 "Say whether ARTICLE is unread or not."
2319 (memq article gnus-newsgroup-unreads))
2321 (defun gnus-summary-first-article-p (&optional article)
2322 "Return whether ARTICLE is the first article in the buffer."
2323 (if (not (setq article (or article (gnus-summary-article-number))))
2325 (eq article (caar gnus-newsgroup-data))))
2327 (defun gnus-summary-last-article-p (&optional article)
2328 "Return whether ARTICLE is the last article in the buffer."
2329 (if (not (setq article (or article (gnus-summary-article-number))))
2330 t ; All non-existent numbers are the last article. :-)
2331 (not (cdr (gnus-data-find-list article)))))
2333 (defun gnus-make-thread-indent-array ()
2335 (unless (and gnus-thread-indent-array
2336 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2337 (setq gnus-thread-indent-array (make-vector 201 "")
2338 gnus-thread-indent-array-level gnus-thread-indent-level)
2340 (aset gnus-thread-indent-array n
2341 (make-string (* n gnus-thread-indent-level) ? ))
2344 (defun gnus-update-summary-mark-positions ()
2345 "Compute where the summary marks are to go."
2347 (when (gnus-buffer-exists-p gnus-summary-buffer)
2348 (set-buffer gnus-summary-buffer))
2349 (let ((gnus-replied-mark 129)
2350 (gnus-score-below-mark 130)
2351 (gnus-score-over-mark 130)
2352 (gnus-download-mark 131)
2353 (spec gnus-summary-line-format-spec)
2354 thread gnus-visual pos)
2356 (gnus-set-work-buffer)
2357 (let ((gnus-summary-line-format-spec spec)
2358 (gnus-newsgroup-downloadable '((0 . t))))
2359 (gnus-summary-insert-line
2360 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2361 (goto-char (point-min))
2362 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2364 (goto-char (point-min))
2365 (push (cons 'replied (and (search-forward "\201" nil t)
2368 (goto-char (point-min))
2369 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2371 (goto-char (point-min))
2372 (push (cons 'download
2373 (and (search-forward "\203" nil t) (- (point) 2)))
2375 (setq gnus-summary-mark-positions pos))))
2377 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2378 "Insert a dummy root in the summary buffer."
2380 (gnus-add-text-properties
2381 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2382 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2384 (defun gnus-summary-insert-line (gnus-tmp-header
2385 gnus-tmp-level gnus-tmp-current
2386 gnus-tmp-unread gnus-tmp-replied
2387 gnus-tmp-expirable gnus-tmp-subject-or-nil
2388 &optional gnus-tmp-dummy gnus-tmp-score
2390 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2391 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2392 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2393 (gnus-tmp-score-char
2394 (if (or (null gnus-summary-default-score)
2395 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2396 gnus-summary-zcore-fuzz))
2398 (if (< gnus-tmp-score gnus-summary-default-score)
2399 gnus-score-below-mark gnus-score-over-mark)))
2401 (cond (gnus-tmp-process gnus-process-mark)
2402 ((memq gnus-tmp-current gnus-newsgroup-cached)
2404 (gnus-tmp-replied gnus-replied-mark)
2405 ((memq gnus-tmp-current gnus-newsgroup-saved)
2407 (t gnus-unread-mark)))
2408 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2411 ((string-match "<[^>]+> *$" gnus-tmp-from)
2412 (let ((beg (match-beginning 0)))
2413 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2414 (substring gnus-tmp-from (1+ (match-beginning 0))
2415 (1- (match-end 0))))
2416 (substring gnus-tmp-from 0 beg))))
2417 ((string-match "(.+)" gnus-tmp-from)
2418 (substring gnus-tmp-from
2419 (1+ (match-beginning 0)) (1- (match-end 0))))
2421 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2422 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2423 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2424 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2425 (buffer-read-only nil))
2426 (when (string= gnus-tmp-name "")
2427 (setq gnus-tmp-name gnus-tmp-from))
2428 (unless (numberp gnus-tmp-lines)
2429 (setq gnus-tmp-lines 0))
2430 (gnus-put-text-property-excluding-characters-with-faces
2432 (progn (eval gnus-summary-line-format-spec) (point))
2433 'gnus-number gnus-tmp-number)
2434 (when (gnus-visual-p 'summary-highlight 'highlight)
2436 (gnus-run-hooks 'gnus-summary-update-hook)
2439 (defun gnus-summary-update-line (&optional dont-update)
2440 ;; Update summary line after change.
2441 (when (and gnus-summary-default-score
2442 (not gnus-summary-inhibit-highlight))
2443 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2444 (article (gnus-summary-article-number))
2445 (score (gnus-summary-article-score article)))
2447 (if (and gnus-summary-mark-below
2448 (< (gnus-summary-article-score)
2449 gnus-summary-mark-below))
2450 ;; This article has a low score, so we mark it as read.
2451 (when (memq article gnus-newsgroup-unreads)
2452 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2453 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2454 ;; This article was previously marked as read on account
2455 ;; of a low score, but now it has risen, so we mark it as
2457 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2458 (gnus-summary-update-mark
2459 (if (or (null gnus-summary-default-score)
2460 (<= (abs (- score gnus-summary-default-score))
2461 gnus-summary-zcore-fuzz))
2463 (if (< score gnus-summary-default-score)
2464 gnus-score-below-mark gnus-score-over-mark))
2466 ;; Do visual highlighting.
2467 (when (gnus-visual-p 'summary-highlight 'highlight)
2468 (gnus-run-hooks 'gnus-summary-update-hook)))))
2470 (defvar gnus-tmp-new-adopts nil)
2472 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2473 "Return the number of articles in THREAD.
2474 This may be 0 in some cases -- if none of the articles in
2475 the thread are to be displayed."
2477 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2479 ((not (listp thread))
2481 ((and (consp thread) (cdr thread))
2484 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2487 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2490 (when (and level (zerop level) gnus-tmp-new-adopts)
2493 'gnus-summary-number-of-articles-in-thread
2494 gnus-tmp-new-adopts))))
2496 (if (> number 1) gnus-not-empty-thread-mark
2497 gnus-empty-thread-mark)
2500 (defun gnus-summary-set-local-parameters (group)
2501 "Go through the local params of GROUP and set all variable specs in that list."
2502 (let ((params (gnus-group-find-parameter group))
2505 (setq elem (car params)
2506 params (cdr params))
2507 (and (consp elem) ; Has to be a cons.
2508 (consp (cdr elem)) ; The cdr has to be a list.
2509 (symbolp (car elem)) ; Has to be a symbol in there.
2510 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2511 (ignore-errors ; So we set it.
2512 (make-local-variable (car elem))
2513 (set (car elem) (eval (nth 1 elem))))))))
2515 (defun gnus-summary-read-group (group &optional show-all no-article
2516 kill-buffer no-display backward)
2517 "Start reading news in newsgroup GROUP.
2518 If SHOW-ALL is non-nil, already read articles are also listed.
2519 If NO-ARTICLE is non-nil, no article is selected initially.
2520 If NO-DISPLAY, don't generate a summary buffer."
2524 (let ((gnus-auto-select-next nil))
2525 (or (gnus-summary-read-group-1
2526 group show-all no-article
2527 kill-buffer no-display)
2528 (setq show-all nil)))))
2529 (eq gnus-auto-select-next 'quietly))
2530 (set-buffer gnus-group-buffer)
2531 ;; The entry function called above goes to the next
2532 ;; group automatically, so we go two groups back
2533 ;; if we are searching for the previous group.
2535 (gnus-group-prev-unread-group 2))
2536 (if (not (equal group (gnus-group-group-name)))
2537 (setq group (gnus-group-group-name))
2541 (defun gnus-summary-read-group-1 (group show-all no-article
2542 kill-buffer no-display)
2543 ;; Killed foreign groups can't be entered.
2544 (when (and (not (gnus-group-native-p group))
2545 (not (gnus-gethash group gnus-newsrc-hashtb)))
2546 (error "Dead non-native groups can't be entered"))
2547 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2548 (let* ((new-group (gnus-summary-setup-buffer group))
2549 (quit-config (gnus-group-quit-config group))
2550 (did-select (and new-group (gnus-select-newsgroup group show-all))))
2552 ;; This summary buffer exists already, so we just select it.
2554 (gnus-set-global-variables)
2556 (gnus-kill-or-deaden-summary kill-buffer))
2557 (gnus-configure-windows 'summary 'force)
2558 (gnus-set-mode-line 'summary)
2559 (gnus-summary-position-point)
2562 ;; We couldn't select this group.
2564 (when (and (eq major-mode 'gnus-summary-mode)
2565 (not (equal (current-buffer) kill-buffer)))
2566 (kill-buffer (current-buffer))
2567 (if (not quit-config)
2569 ;; Update the info -- marks might need to be removed,
2571 (gnus-summary-update-info)
2572 (set-buffer gnus-group-buffer)
2573 (gnus-group-jump-to-group group)
2574 (gnus-group-next-unread-group 1))
2575 (gnus-handle-ephemeral-exit quit-config)))
2576 (gnus-message 3 "Can't select group")
2578 ;; The user did a `C-g' while prompting for number of articles,
2579 ;; so we exit this group.
2580 ((eq did-select 'quit)
2581 (and (eq major-mode 'gnus-summary-mode)
2582 (not (equal (current-buffer) kill-buffer))
2583 (kill-buffer (current-buffer)))
2585 (gnus-kill-or-deaden-summary kill-buffer))
2586 (if (not quit-config)
2588 (set-buffer gnus-group-buffer)
2589 (gnus-group-jump-to-group group)
2590 (gnus-group-next-unread-group 1)
2591 (gnus-configure-windows 'group 'force))
2592 (gnus-handle-ephemeral-exit quit-config))
2593 ;; Finally signal the quit.
2595 ;; The group was successfully selected.
2597 (gnus-set-global-variables)
2598 ;; Save the active value in effect when the group was entered.
2599 (setq gnus-newsgroup-active
2601 (gnus-active gnus-newsgroup-name)))
2602 ;; You can change the summary buffer in some way with this hook.
2603 (gnus-run-hooks 'gnus-select-group-hook)
2604 ;; Set any local variables in the group parameters.
2605 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2606 (gnus-update-format-specifications
2607 nil 'summary 'summary-mode 'summary-dummy)
2608 ;; Do score processing.
2609 (when gnus-use-scoring
2610 (gnus-possibly-score-headers))
2611 ;; Check whether to fill in the gaps in the threads.
2612 (when gnus-build-sparse-threads
2613 (gnus-build-sparse-threads))
2614 ;; Find the initial limit.
2615 (if gnus-show-threads
2617 (let ((gnus-newsgroup-dormant nil))
2618 (gnus-summary-initial-limit show-all))
2619 (gnus-summary-initial-limit show-all))
2620 (setq gnus-newsgroup-limit
2622 (lambda (header) (mail-header-number header))
2623 gnus-newsgroup-headers)))
2624 ;; Generate the summary buffer.
2626 (gnus-summary-prepare))
2627 (when gnus-use-trees
2628 (gnus-tree-open group)
2629 (setq gnus-summary-highlight-line-function
2630 'gnus-tree-highlight-article))
2631 ;; If the summary buffer is empty, but there are some low-scored
2632 ;; articles or some excluded dormants, we include these in the
2634 (when (and (zerop (buffer-size))
2636 (cond (gnus-newsgroup-dormant
2637 (gnus-summary-limit-include-dormant))
2638 ((and gnus-newsgroup-scored show-all)
2639 (gnus-summary-limit-include-expunged t))))
2640 ;; Function `gnus-apply-kill-file' must be called in this hook.
2641 (gnus-run-hooks 'gnus-apply-kill-hook)
2642 (if (and (zerop (buffer-size))
2645 ;; This newsgroup is empty.
2646 (gnus-summary-catchup-and-exit nil t)
2647 (gnus-message 6 "No unread news")
2649 (gnus-kill-or-deaden-summary kill-buffer))
2650 ;; Return nil from this function.
2652 ;; Hide conversation thread subtrees. We cannot do this in
2653 ;; gnus-summary-prepare-hook since kill processing may not
2654 ;; work with hidden articles.
2655 (and gnus-show-threads
2656 gnus-thread-hide-subtree
2657 (gnus-summary-hide-all-threads))
2659 (gnus-kill-or-deaden-summary kill-buffer))
2660 ;; Show first unread article if requested.
2661 (if (and (not no-article)
2663 gnus-newsgroup-unreads
2664 gnus-auto-select-first)
2665 (unless (if (eq gnus-auto-select-first 'best)
2666 (gnus-summary-best-unread-article)
2667 (gnus-summary-first-unread-article))
2668 (gnus-configure-windows 'summary))
2669 ;; Don't select any articles, just move point to the first
2670 ;; article in the group.
2671 (goto-char (point-min))
2672 (gnus-summary-position-point)
2673 (gnus-configure-windows 'summary 'force)
2674 (gnus-set-mode-line 'summary))
2675 (when (get-buffer-window gnus-group-buffer t)
2676 ;; Gotta use windows, because recenter does weird stuff if
2677 ;; the current buffer ain't the displayed window.
2678 (let ((owin (selected-window)))
2679 (select-window (get-buffer-window gnus-group-buffer t))
2680 (when (gnus-group-goto-group group)
2682 (select-window owin)))
2683 ;; Mark this buffer as "prepared".
2684 (setq gnus-newsgroup-prepared t)
2685 (gnus-run-hooks 'gnus-summary-prepared-hook)
2688 (defun gnus-summary-prepare ()
2689 "Generate the summary buffer."
2691 (let ((buffer-read-only nil))
2693 (setq gnus-newsgroup-data nil
2694 gnus-newsgroup-data-reverse nil)
2695 (gnus-run-hooks 'gnus-summary-generate-hook)
2696 ;; Generate the buffer, either with threads or without.
2697 (when gnus-newsgroup-headers
2698 (gnus-summary-prepare-threads
2699 (if gnus-show-threads
2700 (gnus-sort-gathered-threads
2701 (funcall gnus-summary-thread-gathering-function
2703 (gnus-cut-threads (gnus-make-threads)))))
2704 ;; Unthreaded display.
2705 (gnus-sort-articles gnus-newsgroup-headers))))
2706 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2707 ;; Call hooks for modifying summary buffer.
2708 (goto-char (point-min))
2709 (gnus-run-hooks 'gnus-summary-prepare-hook)))
2711 (defsubst gnus-general-simplify-subject (subject)
2712 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2715 ;; Truncate the subject.
2716 (gnus-simplify-subject-functions
2717 (gnus-map-function gnus-simplify-subject-functions subject))
2718 ((numberp gnus-summary-gather-subject-limit)
2719 (setq subject (gnus-simplify-subject-re subject))
2720 (if (> (length subject) gnus-summary-gather-subject-limit)
2721 (substring subject 0 gnus-summary-gather-subject-limit)
2723 ;; Fuzzily simplify it.
2724 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2725 (gnus-simplify-subject-fuzzy subject))
2726 ;; Just remove the leading "Re:".
2728 (gnus-simplify-subject-re subject))))
2730 (if (and gnus-summary-gather-exclude-subject
2731 (string-match gnus-summary-gather-exclude-subject subject))
2732 nil ; This article shouldn't be gathered
2735 (defun gnus-summary-simplify-subject-query ()
2736 "Query where the respool algorithm would put this article."
2738 (gnus-summary-select-article)
2739 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2741 (defun gnus-gather-threads-by-subject (threads)
2742 "Gather threads by looking at Subject headers."
2743 (if (not gnus-summary-make-false-root)
2745 (let ((hashtb (gnus-make-hashtable 1024))
2748 subject hthread whole-subject)
2750 (setq subject (gnus-general-simplify-subject
2751 (setq whole-subject (mail-header-subject
2754 (if (setq hthread (gnus-gethash subject hashtb))
2756 ;; We enter a dummy root into the thread, if we
2757 ;; haven't done that already.
2758 (unless (stringp (caar hthread))
2759 (setcar hthread (list whole-subject (car hthread))))
2760 ;; We add this new gathered thread to this gathered
2762 (setcdr (car hthread)
2763 (nconc (cdar hthread) (list (car threads))))
2764 ;; Remove it from the list of threads.
2765 (setcdr prev (cdr threads))
2766 (setq threads prev))
2767 ;; Enter this thread into the hash table.
2768 (gnus-sethash subject threads hashtb)))
2770 (setq threads (cdr threads)))
2773 (defun gnus-gather-threads-by-references (threads)
2774 "Gather threads by looking at References headers."
2775 (let ((idhashtb (gnus-make-hashtable 1024))
2776 (thhashtb (gnus-make-hashtable 1024))
2779 ids references id gthread gid entered ref)
2781 (when (setq references (mail-header-references (caar threads)))
2782 (setq id (mail-header-id (caar threads))
2783 ids (gnus-split-references references)
2785 (while (setq ref (pop ids))
2786 (setq ids (delete ref ids))
2787 (if (not (setq gid (gnus-gethash ref idhashtb)))
2789 (gnus-sethash ref id idhashtb)
2790 (gnus-sethash id threads thhashtb))
2791 (setq gthread (gnus-gethash gid thhashtb))
2793 ;; We enter a dummy root into the thread, if we
2794 ;; haven't done that already.
2795 (unless (stringp (caar gthread))
2796 (setcar gthread (list (mail-header-subject (caar gthread))
2798 ;; We add this new gathered thread to this gathered
2800 (setcdr (car gthread)
2801 (nconc (cdar gthread) (list (car threads)))))
2802 ;; Add it into the thread hash table.
2803 (gnus-sethash id gthread thhashtb)
2805 ;; Remove it from the list of threads.
2806 (setcdr prev (cdr threads))
2807 (setq threads prev))))
2809 (setq threads (cdr threads)))
2812 (defun gnus-sort-gathered-threads (threads)
2813 "Sort subtreads inside each gathered thread by article number."
2814 (let ((result threads))
2816 (when (stringp (caar threads))
2817 (setcdr (car threads)
2818 (sort (cdar threads) 'gnus-thread-sort-by-number)))
2819 (setq threads (cdr threads)))
2822 (defun gnus-thread-loop-p (root thread)
2823 "Say whether ROOT is in THREAD."
2824 (let ((stack (list thread))
2827 (while (setq thread (pop stack))
2828 (setq th (cdr thread))
2830 (not (eq (caar th) root)))
2833 ;; We have found a loop.
2835 (setcdr thread (delq (car th) (cdr thread)))
2836 (if (boundp (setq ref-dep (intern "none"
2837 gnus-newsgroup-dependencies)))
2838 (setcdr (symbol-value ref-dep)
2839 (nconc (cdr (symbol-value ref-dep))
2841 (set ref-dep (list nil (car th))))
2844 ;; Push all the subthreads onto the stack.
2845 (push (cdr thread) stack)))
2848 (defun gnus-make-threads ()
2849 "Go through the dependency hashtb and find the roots. Return all threads."
2851 (while (catch 'infloop
2854 ;; Deal with self-referencing References loops.
2855 (when (and (car (symbol-value refs))
2862 (car (symbol-value refs)) thread))
2863 (cdr (symbol-value refs)))))))
2866 (unless (car (symbol-value refs))
2867 ;; These threads do not refer back to any other articles,
2868 ;; so they're roots.
2869 (setq threads (append (cdr (symbol-value refs)) threads))))
2870 gnus-newsgroup-dependencies)))
2873 ;; Build the thread tree.
2874 (defun gnus-dependencies-add-header (header dependencies force-new)
2875 "Enter HEADER into the DEPENDENCIES table if it is not already there.
2877 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
2878 if it was already present.
2880 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
2881 will not be entered in the DEPENDENCIES table. Otherwise duplicate
2882 Message-IDs will be renamed be renamed to a unique Message-ID before
2885 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
2886 (let* ((id (mail-header-id header))
2887 (id-dep (and id (intern id dependencies)))
2888 ref ref-dep ref-header)
2889 ;; Enter this `header' in the `dependencies' table.
2893 ;; The first two cases do the normal part: enter a new `header'
2894 ;; in the `dependencies' table.
2895 ((not (boundp id-dep))
2896 (set id-dep (list header)))
2897 ((null (car (symbol-value id-dep)))
2898 (setcar (symbol-value id-dep) header))
2900 ;; From here the `header' was already present in the
2901 ;; `dependencies' table.
2903 ;; Overrides an existing entry;
2904 ;; just set the header part of the entry.
2905 (setcar (symbol-value id-dep) header))
2907 ;; Renames the existing `header' to a unique Message-ID.
2908 ((not gnus-summary-ignore-duplicates)
2909 ;; An article with this Message-ID has already been seen.
2910 ;; We rename the Message-ID.
2911 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
2913 (mail-header-set-id header id))
2915 ;; The last case ignores an existing entry, except it adds any
2916 ;; additional Xrefs (in case the two articles came from different
2918 ;; Also sets `header' to `nil' meaning that the `dependencies'
2919 ;; table was *not* modified.
2921 (mail-header-set-xref
2922 (car (symbol-value id-dep))
2923 (concat (or (mail-header-xref (car (symbol-value id-dep)))
2925 (or (mail-header-xref header) "")))
2929 ;; First check if that we are not creating a References loop.
2930 (setq ref (gnus-parent-id (mail-header-references header)))
2932 (setq ref-dep (intern-soft ref dependencies))
2934 (setq ref-header (car (symbol-value ref-dep))))
2935 (if (string= id ref)
2936 ;; Yuk! This is a reference loop. Make the article be a
2939 (mail-header-set-references (car (symbol-value id-dep)) "none")
2941 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
2942 (setq ref (gnus-parent-id (mail-header-references header)))
2943 (setq ref-dep (intern (or ref "none") dependencies))
2944 (if (boundp ref-dep)
2945 (setcdr (symbol-value ref-dep)
2946 (nconc (cdr (symbol-value ref-dep))
2947 (list (symbol-value id-dep))))
2948 (set ref-dep (list nil (symbol-value id-dep)))))
2951 (defun gnus-build-sparse-threads ()
2952 (let ((headers gnus-newsgroup-headers)
2953 (gnus-summary-ignore-duplicates t)
2954 header references generation relations
2955 cthread subject child end pthread relation new-child date)
2956 ;; First we create an alist of generations/relations, where
2957 ;; generations is how much we trust the relation, and the relation
2959 (gnus-message 7 "Making sparse threads...")
2961 (nnheader-set-temp-buffer " *gnus sparse threads*")
2962 (while (setq header (pop headers))
2963 (when (and (setq references (mail-header-references header))
2964 (not (string= references "")))
2966 (setq child (mail-header-id header)
2967 subject (mail-header-subject header)
2968 date (mail-header-date header)
2970 (while (search-backward ">" nil t)
2971 (setq end (1+ (point)))
2972 (when (search-backward "<" nil t)
2973 (setq new-child (buffer-substring (point) end))
2974 (push (list (incf generation)
2975 child (setq child new-child)
2979 (push (list (1+ generation) child nil subject) relations))
2981 (kill-buffer (current-buffer)))
2982 ;; Sort over trustworthiness.
2985 (when (gnus-dependencies-add-header
2986 (make-full-mail-header
2987 gnus-reffed-article-number
2988 (nth 3 relation) "" (or (nth 4 relation) "")
2990 (or (nth 2 relation) "") 0 0 "")
2991 gnus-newsgroup-dependencies nil)
2992 (push gnus-reffed-article-number gnus-newsgroup-limit)
2993 (push gnus-reffed-article-number gnus-newsgroup-sparse)
2994 (push (cons gnus-reffed-article-number gnus-sparse-mark)
2995 gnus-newsgroup-reads)
2996 (decf gnus-reffed-article-number)))
2997 (sort relations 'car-less-than-car))
2998 (gnus-message 7 "Making sparse threads...done")))
3000 (defun gnus-build-old-threads ()
3001 ;; Look at all the articles that refer back to old articles, and
3002 ;; fetch the headers for the articles that aren't there. This will
3003 ;; build complete threads - if the roots haven't been expired by the
3008 (when (not (car (symbol-value refs)))
3009 (setq heads (cdr (symbol-value refs)))
3011 (if (memq (mail-header-number (caar heads))
3012 gnus-newsgroup-dormant)
3013 (setq heads (cdr heads))
3014 (setq id (symbol-name refs))
3015 (while (and (setq id (gnus-build-get-header id))
3016 (not (car (gnus-id-to-thread id)))))
3017 (setq heads nil)))))
3018 gnus-newsgroup-dependencies)))
3020 ;; The following macros and functions were written by Felix Lee
3021 ;; <flee@cse.psu.edu>.
3023 (defmacro gnus-nov-read-integer ()
3025 (if (= (following-char) ?\t)
3027 (let ((num (ignore-errors (read buffer))))
3028 (if (numberp num) num 0)))
3030 (search-forward "\t" eol 'move))))
3032 (defmacro gnus-nov-skip-field ()
3033 '(search-forward "\t" eol 'move))
3035 (defmacro gnus-nov-field ()
3036 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
3038 ;; This function has to be called with point after the article number
3039 ;; on the beginning of the line.
3040 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3041 (let ((eol (gnus-point-at-eol))
3042 (buffer (current-buffer))
3045 ;; overview: [num subject from date id refs chars lines misc]
3048 (narrow-to-region (point) eol)
3053 (make-full-mail-header
3056 gnus-unstructured-field-decoder (gnus-nov-field)) ; subject
3058 gnus-structured-field-decoder (gnus-nov-field)) ; from
3059 (gnus-nov-field) ; date
3060 (or (gnus-nov-field)
3061 (nnheader-generate-fake-message-id)) ; id
3062 (gnus-nov-field) ; refs
3063 (gnus-nov-read-integer) ; chars
3064 (gnus-nov-read-integer) ; lines
3065 (unless (= (following-char) ?\n)
3066 (gnus-nov-field))))) ; misc
3070 (when gnus-alter-header-function
3071 (funcall gnus-alter-header-function header))
3072 (gnus-dependencies-add-header header dependencies force-new)))
3074 (defun gnus-build-get-header (id)
3075 ;; Look through the buffer of NOV lines and find the header to
3076 ;; ID. Enter this line into the dependencies hash table, and return
3077 ;; the id of the parent article (if any).
3078 (let ((deps gnus-newsgroup-dependencies)
3082 (set-buffer nntp-server-buffer)
3083 (let ((case-fold-search nil))
3084 (goto-char (point-min))
3085 (while (and (not found)
3086 (search-forward id nil t))
3088 (setq found (looking-at
3089 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3090 (regexp-quote id))))
3091 (or found (beginning-of-line 2)))
3095 (setq header (gnus-nov-parse-line
3096 (read (current-buffer)) deps))
3097 (gnus-parent-id (mail-header-references header))))))
3099 (let ((number (mail-header-number header)))
3100 (push number gnus-newsgroup-limit)
3101 (push header gnus-newsgroup-headers)
3102 (if (memq number gnus-newsgroup-unselected)
3104 (push number gnus-newsgroup-unreads)
3105 (setq gnus-newsgroup-unselected
3106 (delq number gnus-newsgroup-unselected)))
3107 (push number gnus-newsgroup-ancient)))))))
3109 (defun gnus-build-all-threads ()
3110 "Read all the headers."
3111 (let ((gnus-summary-ignore-duplicates t)
3112 (dependencies gnus-newsgroup-dependencies)
3113 found header article)
3115 (set-buffer nntp-server-buffer)
3116 (let ((case-fold-search nil))
3117 (goto-char (point-min))
3120 (setq article (read (current-buffer))
3121 header (gnus-nov-parse-line
3122 article dependencies)))
3124 (push header gnus-newsgroup-headers)
3125 (if (memq (setq article (mail-header-number header))
3126 gnus-newsgroup-unselected)
3128 (push article gnus-newsgroup-unreads)
3129 (setq gnus-newsgroup-unselected
3130 (delq article gnus-newsgroup-unselected)))
3131 (push article gnus-newsgroup-ancient))
3132 (forward-line 1)))))))
3134 (defun gnus-summary-update-article-line (article header)
3135 "Update the line for ARTICLE using HEADERS."
3136 (let* ((id (mail-header-id header))
3137 (thread (gnus-id-to-thread id)))
3139 (error "Article in no thread"))
3140 ;; Update the thread.
3141 (setcar thread header)
3142 (gnus-summary-goto-subject article)
3143 (let* ((datal (gnus-data-find-list article))
3145 (length (when (cdr datal)
3146 (- (gnus-data-pos data)
3147 (gnus-data-pos (cadr datal)))))
3148 (buffer-read-only nil)
3149 (level (gnus-summary-thread-level)))
3151 (gnus-summary-insert-line
3152 header level nil (gnus-article-mark article)
3153 (memq article gnus-newsgroup-replied)
3154 (memq article gnus-newsgroup-expirable)
3155 ;; Only insert the Subject string when it's different
3156 ;; from the previous Subject string.
3157 (if (gnus-subject-equal
3159 (mail-header-subject
3162 (gnus-data-find-list
3164 (gnus-data-list t)))))
3165 ;; Error on the side of excessive subjects.
3167 (mail-header-subject header))
3169 (mail-header-subject header))
3170 nil (cdr (assq article gnus-newsgroup-scored))
3171 (memq article gnus-newsgroup-processable))
3173 (gnus-data-update-list
3174 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3176 (defun gnus-summary-update-article (article &optional iheader)
3177 "Update ARTICLE in the summary buffer."
3178 (set-buffer gnus-summary-buffer)
3179 (let* ((header (or iheader (gnus-summary-article-header article)))
3180 (id (mail-header-id header))
3181 (data (gnus-data-find article))
3182 (thread (gnus-id-to-thread id))
3183 (references (mail-header-references header))
3187 (when (and references
3188 (not (equal "" references)))
3191 (buffer-read-only nil)
3193 (number (mail-header-number header))
3196 ;; !!! Should this be in or not?
3198 (setcar thread nil))
3200 (delq thread parent))
3201 (if (gnus-summary-insert-subject id header iheader)
3202 ;; Set the (possibly) new article number in the data structure.
3203 (gnus-data-set-number data (gnus-id-to-article id))
3207 (defun gnus-rebuild-thread (id &optional line)
3208 "Rebuild the thread containing ID.
3209 If LINE, insert the rebuilt thread starting on line LINE."
3210 (let ((buffer-read-only nil)
3211 old-pos current thread data)
3212 (if (not gnus-show-threads)
3213 (setq thread (list (car (gnus-id-to-thread id))))
3214 ;; Get the thread this article is part of.
3215 (setq thread (gnus-remove-thread id)))
3216 (setq old-pos (gnus-point-at-bol))
3217 (setq current (save-excursion
3218 (and (zerop (forward-line -1))
3219 (gnus-summary-article-number))))
3220 ;; If this is a gathered thread, we have to go some re-gathering.
3221 (when (stringp (car thread))
3222 (let ((subject (car thread))
3224 (setq thread (cdr thread))
3226 (unless (memq (setq thr (gnus-id-to-thread
3228 (mail-header-id (caar thread)))))
3231 (setq thread (cdr thread)))
3232 ;; We now have all (unique) roots.
3233 (if (= (length roots) 1)
3234 ;; All the loose roots are now one solid root.
3235 (setq thread (car roots))
3236 (setq thread (cons subject (gnus-sort-threads roots))))))
3238 ;; We then insert this thread into the summary buffer.
3240 (goto-char (point-min))
3241 (forward-line (1- line)))
3242 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3243 (if gnus-show-threads
3244 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3245 (gnus-summary-prepare-unthreaded thread))
3246 (setq data (nreverse gnus-newsgroup-data))
3247 (setq threads gnus-newsgroup-threads))
3248 ;; We splice the new data into the data structure.
3249 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3250 ;;!!! then we want to insert at the beginning of the buffer.
3251 ;;!!! That happens to be true with Gnus now, but that may
3252 ;;!!! change in the future. Perhaps.
3253 (gnus-data-enter-list (if line nil current) data (- (point) old-pos))
3254 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads))
3256 (gnus-data-compute-positions)))))
3258 (defun gnus-number-to-header (number)
3259 "Return the header for article NUMBER."
3260 (let ((headers gnus-newsgroup-headers))
3262 (not (= number (mail-header-number (car headers)))))
3267 (defun gnus-parent-headers (in-headers &optional generation)
3268 "Return the headers of the GENERATIONeth parent of HEADERS."
3270 (setq generation 1))
3272 (headers in-headers)
3275 (not (zerop generation))
3276 (setq references (mail-header-references headers)))
3277 (setq headers (if (and references
3278 (setq parent (gnus-parent-id references)))
3279 (car (gnus-id-to-thread parent))
3282 (and (not (eq headers in-headers))
3285 (defun gnus-id-to-thread (id)
3286 "Return the (sub-)thread where ID appears."
3287 (gnus-gethash id gnus-newsgroup-dependencies))
3289 (defun gnus-id-to-article (id)
3290 "Return the article number of ID."
3291 (let ((thread (gnus-id-to-thread id)))
3294 (mail-header-number (car thread)))))
3296 (defun gnus-id-to-header (id)
3297 "Return the article headers of ID."
3298 (car (gnus-id-to-thread id)))
3300 (defun gnus-article-displayed-root-p (article)
3301 "Say whether ARTICLE is a root(ish) article."
3302 (let ((level (gnus-summary-thread-level article))
3303 (refs (mail-header-references (gnus-summary-article-header article)))
3309 ((null (gnus-parent-id refs)) t)
3311 (null (setq particle (gnus-id-to-article
3312 (gnus-parent-id refs))))
3313 (null (gnus-summary-thread-level particle)))))))
3315 (defun gnus-root-id (id)
3316 "Return the id of the root of the thread where ID appears."
3318 (while (and id (setq prev (car (gnus-id-to-thread id))))
3320 id (gnus-parent-id (mail-header-references prev))))
3323 (defun gnus-articles-in-thread (thread)
3324 "Return the list of articles in THREAD."
3325 (cons (mail-header-number (car thread))
3326 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3328 (defun gnus-remove-thread (id &optional dont-remove)
3329 "Remove the thread that has ID in it."
3330 (let (headers thread last-id)
3331 ;; First go up in this thread until we find the root.
3332 (setq last-id (gnus-root-id id))
3333 (setq headers (list (car (gnus-id-to-thread last-id))
3334 (caadr (gnus-id-to-thread last-id))))
3335 ;; We have now found the real root of this thread. It might have
3336 ;; been gathered into some loose thread, so we have to search
3337 ;; through the threads to find the thread we wanted.
3338 (let ((threads gnus-newsgroup-threads)
3341 (setq sub (car threads))
3342 (if (stringp (car sub))
3343 ;; This is a gathered thread, so we look at the roots
3344 ;; below it to find whether this article is in this
3347 (setq sub (cdr sub))
3349 (when (member (caar sub) headers)
3350 (setq thread (car threads)
3353 (setq sub (cdr sub))))
3354 ;; It's an ordinary thread, so we check it.
3355 (when (eq (car sub) (car headers))
3358 (setq threads (cdr threads)))
3359 ;; If this article is in no thread, then it's a root.
3362 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3363 (setq thread (gnus-id-to-thread last-id)))
3366 thread ; We return this thread.
3368 (if (stringp (car thread))
3370 ;; If we use dummy roots, then we have to remove the
3371 ;; dummy root as well.
3372 (when (eq gnus-summary-make-false-root 'dummy)
3373 ;; We go to the dummy root by going to
3374 ;; the first sub-"thread", and then one line up.
3375 (gnus-summary-goto-article
3376 (mail-header-number (caadr thread)))
3379 (gnus-data-compute-positions))
3380 (setq thread (cdr thread))
3382 (gnus-remove-thread-1 (car thread))
3383 (setq thread (cdr thread))))
3384 (gnus-remove-thread-1 thread))))))))
3386 (defun gnus-remove-thread-1 (thread)
3387 "Remove the thread THREAD recursively."
3388 (let ((number (mail-header-number (pop thread)))
3390 (setq thread (reverse thread))
3392 (gnus-remove-thread-1 (pop thread)))
3393 (when (setq d (gnus-data-find number))
3394 (goto-char (gnus-data-pos d))
3397 (- (gnus-point-at-bol)
3399 (1+ (gnus-point-at-eol))
3400 (gnus-delete-line)))))))
3402 (defun gnus-sort-threads (threads)
3404 (if (not gnus-thread-sort-functions)
3406 (gnus-message 7 "Sorting threads...")
3408 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3409 (gnus-message 7 "Sorting threads...done"))))
3411 (defun gnus-sort-articles (articles)
3413 (when gnus-article-sort-functions
3414 (gnus-message 7 "Sorting articles...")
3416 (setq gnus-newsgroup-headers
3417 (sort articles (gnus-make-sort-function
3418 gnus-article-sort-functions)))
3419 (gnus-message 7 "Sorting articles...done"))))
3421 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3422 (defmacro gnus-thread-header (thread)
3423 ;; Return header of first article in THREAD.
3424 ;; Note that THREAD must never, ever be anything else than a variable -
3425 ;; using some other form will lead to serious barfage.
3426 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3427 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3428 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
3431 (defsubst gnus-article-sort-by-number (h1 h2)
3432 "Sort articles by article number."
3433 (< (mail-header-number h1)
3434 (mail-header-number h2)))
3436 (defun gnus-thread-sort-by-number (h1 h2)
3437 "Sort threads by root article number."
3438 (gnus-article-sort-by-number
3439 (gnus-thread-header h1) (gnus-thread-header h2)))
3441 (defsubst gnus-article-sort-by-lines (h1 h2)
3442 "Sort articles by article Lines header."
3443 (< (mail-header-lines h1)
3444 (mail-header-lines h2)))
3446 (defun gnus-thread-sort-by-lines (h1 h2)
3447 "Sort threads by root article Lines header."
3448 (gnus-article-sort-by-lines
3449 (gnus-thread-header h1) (gnus-thread-header h2)))
3451 (defsubst gnus-article-sort-by-author (h1 h2)
3452 "Sort articles by root author."
3454 (let ((extract (funcall
3455 gnus-extract-address-components
3456 (mail-header-from h1))))
3457 (or (car extract) (cadr extract) ""))
3458 (let ((extract (funcall
3459 gnus-extract-address-components
3460 (mail-header-from h2))))
3461 (or (car extract) (cadr extract) ""))))
3463 (defun gnus-thread-sort-by-author (h1 h2)
3464 "Sort threads by root author."
3465 (gnus-article-sort-by-author
3466 (gnus-thread-header h1) (gnus-thread-header h2)))
3468 (defsubst gnus-article-sort-by-subject (h1 h2)
3469 "Sort articles by root subject."
3471 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3472 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3474 (defun gnus-thread-sort-by-subject (h1 h2)
3475 "Sort threads by root subject."
3476 (gnus-article-sort-by-subject
3477 (gnus-thread-header h1) (gnus-thread-header h2)))
3479 (defsubst gnus-article-sort-by-date (h1 h2)
3480 "Sort articles by root article date."
3482 (gnus-date-get-time (mail-header-date h1))
3483 (gnus-date-get-time (mail-header-date h2))))
3485 (defun gnus-thread-sort-by-date (h1 h2)
3486 "Sort threads by root article date."
3487 (gnus-article-sort-by-date
3488 (gnus-thread-header h1) (gnus-thread-header h2)))
3490 (defsubst gnus-article-sort-by-score (h1 h2)
3491 "Sort articles by root article score.
3492 Unscored articles will be counted as having a score of zero."
3493 (> (or (cdr (assq (mail-header-number h1)
3494 gnus-newsgroup-scored))
3495 gnus-summary-default-score 0)
3496 (or (cdr (assq (mail-header-number h2)
3497 gnus-newsgroup-scored))
3498 gnus-summary-default-score 0)))
3500 (defun gnus-thread-sort-by-score (h1 h2)
3501 "Sort threads by root article score."
3502 (gnus-article-sort-by-score
3503 (gnus-thread-header h1) (gnus-thread-header h2)))
3505 (defun gnus-thread-sort-by-total-score (h1 h2)
3506 "Sort threads by the sum of all scores in the thread.
3507 Unscored articles will be counted as having a score of zero."
3508 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3510 (defun gnus-thread-total-score (thread)
3511 ;; This function find the total score of THREAD.
3512 (cond ((null thread)
3515 (if (stringp (car thread))
3516 (apply gnus-thread-score-function 0
3517 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3518 (gnus-thread-total-score-1 thread)))
3520 (gnus-thread-total-score-1 (list thread)))))
3522 (defun gnus-thread-total-score-1 (root)
3523 ;; This function find the total score of the thread below ROOT.
3524 (setq root (car root))
3525 (apply gnus-thread-score-function
3527 (mapcar 'gnus-thread-total-score
3528 (cdr (gnus-id-to-thread (mail-header-id root))))
3529 (when (> (mail-header-number root) 0)
3530 (list (or (cdr (assq (mail-header-number root)
3531 gnus-newsgroup-scored))
3532 gnus-summary-default-score 0))))
3533 (list gnus-summary-default-score)
3536 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3537 (defvar gnus-tmp-prev-subject nil)
3538 (defvar gnus-tmp-false-parent nil)
3539 (defvar gnus-tmp-root-expunged nil)
3540 (defvar gnus-tmp-dummy-line nil)
3542 (defun gnus-summary-prepare-threads (threads)
3543 "Prepare summary buffer from THREADS and indentation LEVEL.
3544 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3545 or a straight list of headers."
3546 (gnus-message 7 "Generating summary...")
3548 (setq gnus-newsgroup-threads threads)
3551 (let ((gnus-tmp-level 0)
3552 (default-score (or gnus-summary-default-score 0))
3553 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3554 thread number subject stack state gnus-tmp-gathered beg-match
3555 new-roots gnus-tmp-new-adopts thread-end
3556 gnus-tmp-header gnus-tmp-unread
3557 gnus-tmp-replied gnus-tmp-subject-or-nil
3558 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3559 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3560 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3562 (setq gnus-tmp-prev-subject nil)
3564 (if (vectorp (car threads))
3565 ;; If this is a straight (sic) list of headers, then a
3566 ;; threaded summary display isn't required, so we just create
3567 ;; an unthreaded one.
3568 (gnus-summary-prepare-unthreaded threads)
3570 ;; Do the threaded display.
3572 (while (or threads stack gnus-tmp-new-adopts new-roots)
3574 (if (and (= gnus-tmp-level 0)
3577 (not gnus-tmp-false-parent)
3578 (or gnus-tmp-new-adopts new-roots))
3579 (if gnus-tmp-new-adopts
3580 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3581 thread (list (car gnus-tmp-new-adopts))
3582 gnus-tmp-header (caar thread)
3583 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3585 (setq thread (list (car new-roots))
3586 gnus-tmp-header (caar thread)
3587 new-roots (cdr new-roots))))
3590 ;; If there are some threads, we do them before the
3591 ;; threads on the stack.
3592 (setq thread threads
3593 gnus-tmp-header (caar thread))
3594 ;; There were no current threads, so we pop something off
3596 (setq state (car stack)
3597 gnus-tmp-level (car state)
3600 gnus-tmp-header (caar thread))))
3602 (setq gnus-tmp-false-parent nil)
3603 (setq gnus-tmp-root-expunged nil)
3604 (setq thread-end nil)
3606 (if (stringp gnus-tmp-header)
3607 ;; The header is a dummy root.
3609 ((eq gnus-summary-make-false-root 'adopt)
3610 ;; We let the first article adopt the rest.
3611 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3613 (setq gnus-tmp-gathered
3615 (lambda (h) (mail-header-number (car h)))
3618 (setq thread (cons (list (caar thread)
3621 (setq gnus-tmp-level -1
3622 gnus-tmp-false-parent t))
3623 ((eq gnus-summary-make-false-root 'empty)
3624 ;; We print adopted articles with empty subject fields.
3625 (setq gnus-tmp-gathered
3627 (lambda (h) (mail-header-number (car h)))
3630 (setq gnus-tmp-level -1))
3631 ((eq gnus-summary-make-false-root 'dummy)
3632 ;; We remember that we probably want to output a dummy
3634 (setq gnus-tmp-dummy-line gnus-tmp-header)
3635 (setq gnus-tmp-prev-subject gnus-tmp-header))
3637 ;; We do not make a root for the gathered
3638 ;; sub-threads at all.
3639 (setq gnus-tmp-level -1)))
3641 (setq number (mail-header-number gnus-tmp-header)
3642 subject (mail-header-subject gnus-tmp-header))
3645 ;; If the thread has changed subject, we might want to make
3646 ;; this subthread into a root.
3647 ((and (null gnus-thread-ignore-subject)
3648 (not (zerop gnus-tmp-level))
3649 gnus-tmp-prev-subject
3651 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3652 (setq new-roots (nconc new-roots (list (car thread)))
3654 gnus-tmp-header nil))
3655 ;; If the article lies outside the current limit,
3656 ;; then we do not display it.
3657 ((not (memq number gnus-newsgroup-limit))
3658 (setq gnus-tmp-gathered
3660 (lambda (h) (mail-header-number (car h)))
3663 (setq gnus-tmp-new-adopts (if (cdar thread)
3664 (append gnus-tmp-new-adopts
3666 gnus-tmp-new-adopts)
3668 gnus-tmp-header nil)
3669 (when (zerop gnus-tmp-level)
3670 (setq gnus-tmp-root-expunged t)))
3671 ;; Perhaps this article is to be marked as read?
3672 ((and gnus-summary-mark-below
3673 (< (or (cdr (assq number gnus-newsgroup-scored))
3675 gnus-summary-mark-below)
3676 ;; Don't touch sparse articles.
3677 (not (gnus-summary-article-sparse-p number))
3678 (not (gnus-summary-article-ancient-p number)))
3679 (setq gnus-newsgroup-unreads
3680 (delq number gnus-newsgroup-unreads))
3681 (if gnus-newsgroup-auto-expire
3682 (push number gnus-newsgroup-expirable)
3683 (push (cons number gnus-low-score-mark)
3684 gnus-newsgroup-reads))))
3686 (when gnus-tmp-header
3687 ;; We may have an old dummy line to output before this
3689 (when (and gnus-tmp-dummy-line
3692 (mail-header-subject gnus-tmp-header)))
3693 (gnus-summary-insert-dummy-line
3694 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3695 (setq gnus-tmp-dummy-line nil))
3697 ;; Compute the mark.
3698 (setq gnus-tmp-unread (gnus-article-mark number))
3700 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3701 gnus-tmp-header gnus-tmp-level)
3702 gnus-newsgroup-data)
3704 ;; Actually insert the line.
3706 gnus-tmp-subject-or-nil
3708 ((and gnus-thread-ignore-subject
3709 gnus-tmp-prev-subject
3710 (not (inline (gnus-subject-equal
3711 gnus-tmp-prev-subject subject))))
3713 ((zerop gnus-tmp-level)
3714 (if (and (eq gnus-summary-make-false-root 'empty)
3715 (memq number gnus-tmp-gathered)
3716 gnus-tmp-prev-subject
3717 (inline (gnus-subject-equal
3718 gnus-tmp-prev-subject subject)))
3719 gnus-summary-same-subject
3721 (t gnus-summary-same-subject)))
3722 (if (and (eq gnus-summary-make-false-root 'adopt)
3723 (= gnus-tmp-level 1)
3724 (memq number gnus-tmp-gathered))
3725 (setq gnus-tmp-opening-bracket ?\<
3726 gnus-tmp-closing-bracket ?\>)
3727 (setq gnus-tmp-opening-bracket ?\[
3728 gnus-tmp-closing-bracket ?\]))
3730 gnus-tmp-indentation
3731 (aref gnus-thread-indent-array gnus-tmp-level)
3732 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3733 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3734 gnus-summary-default-score 0)
3736 (if (or (null gnus-summary-default-score)
3737 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3738 gnus-summary-zcore-fuzz))
3740 (if (< gnus-tmp-score gnus-summary-default-score)
3741 gnus-score-below-mark gnus-score-over-mark))
3743 (cond ((memq number gnus-newsgroup-processable)
3745 ((memq number gnus-newsgroup-cached)
3747 ((memq number gnus-newsgroup-replied)
3749 ((memq number gnus-newsgroup-saved)
3751 (t gnus-unread-mark))
3752 gnus-tmp-from (mail-header-from gnus-tmp-header)
3755 ((string-match "<[^>]+> *$" gnus-tmp-from)
3756 (setq beg-match (match-beginning 0))
3757 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3758 (substring gnus-tmp-from (1+ (match-beginning 0))
3759 (1- (match-end 0))))
3760 (substring gnus-tmp-from 0 beg-match)))
3761 ((string-match "(.+)" gnus-tmp-from)
3762 (substring gnus-tmp-from
3763 (1+ (match-beginning 0)) (1- (match-end 0))))
3765 (when (string= gnus-tmp-name "")
3766 (setq gnus-tmp-name gnus-tmp-from))
3767 (unless (numberp gnus-tmp-lines)
3768 (setq gnus-tmp-lines 0))
3769 (gnus-put-text-property-excluding-characters-with-faces
3771 (progn (eval gnus-summary-line-format-spec) (point))
3772 'gnus-number number)
3775 (gnus-run-hooks 'gnus-summary-update-hook)
3778 (setq gnus-tmp-prev-subject subject)))
3780 (when (nth 1 thread)
3781 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3782 (incf gnus-tmp-level)
3783 (setq threads (if thread-end nil (cdar thread)))
3785 (setq gnus-tmp-level 0)))))
3786 (gnus-message 7 "Generating summary...done"))
3788 (defun gnus-summary-prepare-unthreaded (headers)
3789 "Generate an unthreaded summary buffer based on HEADERS."
3790 (let (header number mark)
3795 ;; We may have to root out some bad articles...
3796 (when (memq (setq number (mail-header-number
3797 (setq header (pop headers))))
3798 gnus-newsgroup-limit)
3799 ;; Mark article as read when it has a low score.
3800 (when (and gnus-summary-mark-below
3801 (< (or (cdr (assq number gnus-newsgroup-scored))
3802 gnus-summary-default-score 0)
3803 gnus-summary-mark-below)
3804 (not (gnus-summary-article-ancient-p number)))
3805 (setq gnus-newsgroup-unreads
3806 (delq number gnus-newsgroup-unreads))
3807 (if gnus-newsgroup-auto-expire
3808 (push number gnus-newsgroup-expirable)
3809 (push (cons number gnus-low-score-mark)
3810 gnus-newsgroup-reads)))
3812 (setq mark (gnus-article-mark number))
3813 (push (gnus-data-make number mark (1+ (point)) header 0)
3814 gnus-newsgroup-data)
3815 (gnus-summary-insert-line
3817 mark (memq number gnus-newsgroup-replied)
3818 (memq number gnus-newsgroup-expirable)
3819 (mail-header-subject header) nil
3820 (cdr (assq number gnus-newsgroup-scored))
3821 (memq number gnus-newsgroup-processable))))))
3823 (defun gnus-select-newsgroup (group &optional read-all)
3824 "Select newsgroup GROUP.
3825 If READ-ALL is non-nil, all articles in the group are selected."
3826 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3827 ;;!!! Dirty hack; should be removed.
3828 (gnus-summary-ignore-duplicates
3829 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
3831 gnus-summary-ignore-duplicates))
3832 (info (nth 2 entry))
3833 articles fetched-articles cached)
3835 (unless (gnus-check-server
3836 (setq gnus-current-select-method
3837 (gnus-find-method-for-group group)))
3838 (error "Couldn't open server"))
3840 (or (and entry (not (eq (car entry) t))) ; Either it's active...
3841 (gnus-activate-group group) ; Or we can activate it...
3842 (progn ; Or we bug out.
3843 (when (equal major-mode 'gnus-summary-mode)
3844 (kill-buffer (current-buffer)))
3845 (error "Couldn't request group %s: %s"
3846 group (gnus-status-message group))))
3848 (unless (gnus-request-group group t)
3849 (when (equal major-mode 'gnus-summary-mode)
3850 (kill-buffer (current-buffer)))
3851 (error "Couldn't request group %s: %s"
3852 group (gnus-status-message group)))
3854 (setq gnus-newsgroup-name group)
3855 (setq gnus-newsgroup-unselected nil)
3856 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
3858 ;; Adjust and set lists of article marks.
3860 (gnus-adjust-marked-articles info))
3862 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3863 (when (gnus-virtual-group-p group)
3864 (setq cached gnus-newsgroup-cached))
3866 (setq gnus-newsgroup-unreads
3867 (gnus-set-difference
3868 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
3869 gnus-newsgroup-dormant))
3871 (setq gnus-newsgroup-processable nil)
3873 (gnus-update-read-articles group gnus-newsgroup-unreads)
3874 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
3875 (gnus-group-update-group group))
3877 (setq articles (gnus-articles-to-read group read-all))
3881 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
3883 ((eq articles 0) nil)
3885 ;; Init the dependencies hash table.
3886 (setq gnus-newsgroup-dependencies
3887 (gnus-make-hashtable (length articles)))
3888 ;; Retrieve the headers and read them in.
3889 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
3890 (setq gnus-newsgroup-headers
3892 (setq gnus-headers-retrieved-by
3893 (gnus-retrieve-headers
3894 articles gnus-newsgroup-name
3895 ;; We might want to fetch old headers, but
3896 ;; not if there is only 1 article.
3898 (not (eq gnus-fetch-old-headers 'some))
3899 (not (numberp gnus-fetch-old-headers)))
3900 (> (length articles) 1))
3901 gnus-fetch-old-headers))))
3902 (gnus-get-newsgroup-headers-xover
3903 articles nil nil gnus-newsgroup-name t)
3904 (gnus-get-newsgroup-headers)))
3905 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
3907 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3909 (setq gnus-newsgroup-cached cached))
3911 ;; Suppress duplicates?
3912 (when gnus-suppress-duplicates
3913 (gnus-dup-suppress-articles))
3915 ;; Set the initial limit.
3916 (setq gnus-newsgroup-limit (copy-sequence articles))
3917 ;; Remove canceled articles from the list of unread articles.
3918 (setq gnus-newsgroup-unreads
3919 (gnus-set-sorted-intersection
3920 gnus-newsgroup-unreads
3921 (setq fetched-articles
3922 (mapcar (lambda (headers) (mail-header-number headers))
3923 gnus-newsgroup-headers))))
3924 ;; Removed marked articles that do not exist.
3925 (gnus-update-missing-marks
3926 (gnus-sorted-complement fetched-articles articles))
3927 ;; Let the Gnus agent mark articles as read.
3929 (gnus-agent-get-undownloaded-list))
3930 ;; We might want to build some more threads first.
3931 (when (and gnus-fetch-old-headers
3932 (eq gnus-headers-retrieved-by 'nov))
3933 (if (eq gnus-fetch-old-headers 'invisible)
3934 (gnus-build-all-threads)
3935 (gnus-build-old-threads)))
3936 ;; Check whether auto-expire is to be done in this group.
3937 (setq gnus-newsgroup-auto-expire
3938 (gnus-group-auto-expirable-p group))
3939 ;; Set up the article buffer now, if necessary.
3940 (unless gnus-single-article-buffer
3941 (gnus-article-setup-buffer))
3942 ;; First and last article in this newsgroup.
3943 (when gnus-newsgroup-headers
3944 (setq gnus-newsgroup-begin
3945 (mail-header-number (car gnus-newsgroup-headers))
3948 (gnus-last-element gnus-newsgroup-headers))))
3949 ;; GROUP is successfully selected.
3950 (or gnus-newsgroup-headers t)))))
3952 (defun gnus-articles-to-read (group &optional read-all)
3953 ;; Find out what articles the user wants to read.
3955 ;; Select all articles if `read-all' is non-nil, or if there
3956 ;; are no unread articles.
3958 (and (zerop (length gnus-newsgroup-marked))
3959 (zerop (length gnus-newsgroup-unreads)))
3960 (eq (gnus-group-find-parameter group 'display)
3962 (gnus-uncompress-range (gnus-active group))
3963 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
3964 (copy-sequence gnus-newsgroup-unreads))
3966 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
3967 (scored (length scored-list))
3968 (number (length articles))
3969 (marked (+ (length gnus-newsgroup-marked)
3970 (length gnus-newsgroup-dormant)))
3978 ((and (or (<= scored marked) (= scored number))
3979 (numberp gnus-large-newsgroup)
3980 (> number gnus-large-newsgroup))
3984 "How many articles from %s (default %d): "
3985 (gnus-limit-string gnus-newsgroup-name 35)
3987 (if (string-match "^[ \t]*$" input) number input)))
3988 ((and (> scored marked) (< scored number)
3989 (> (- scored number) 20))
3992 (format "%s %s (%d scored, %d total): "
3993 "How many articles from"
3994 group scored number))))
3995 (if (string-match "^[ \t]*$" input)
3999 (setq select (if (stringp select) (string-to-number select) select))
4000 (if (or (null select) (zerop select))
4002 (if (and (not (zerop scored)) (<= (abs select) scored))
4004 (setq articles (sort scored-list '<))
4005 (setq number (length articles)))
4006 (setq articles (copy-sequence articles)))
4008 (when (< (abs select) number)
4010 ;; Select the N oldest articles.
4011 (setcdr (nthcdr (1- (abs select)) articles) nil)
4012 ;; Select the N most recent articles.
4013 (setq articles (nthcdr (- number select) articles))))
4014 (setq gnus-newsgroup-unselected
4015 (gnus-sorted-intersection
4016 gnus-newsgroup-unreads
4017 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4020 (defun gnus-killed-articles (killed articles)
4023 (when (inline (gnus-member-of-range (car articles) killed))
4024 (push (car articles) out))
4025 (setq articles (cdr articles)))
4028 (defun gnus-uncompress-marks (marks)
4029 "Uncompress the mark ranges in MARKS."
4030 (let ((uncompressed '(score bookmark))
4033 (if (memq (caar marks) uncompressed)
4034 (push (car marks) out)
4035 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4036 (setq marks (cdr marks)))
4039 (defun gnus-adjust-marked-articles (info)
4040 "Set all article lists and remove all marks that are no longer legal."
4041 (let* ((marked-lists (gnus-info-marks info))
4042 (active (gnus-active (gnus-info-group info)))
4045 (types gnus-article-mark-lists)
4046 (uncompressed '(score bookmark killed))
4047 marks var articles article mark)
4050 (setq marks (pop marked-lists))
4051 (set (setq var (intern (format "gnus-newsgroup-%s"
4052 (car (rassq (setq mark (car marks))
4054 (if (memq (car marks) uncompressed) (cdr marks)
4055 (gnus-uncompress-range (cdr marks))))
4057 (setq articles (symbol-value var))
4059 ;; All articles have to be subsets of the active articles.
4061 ;; Adjust "simple" lists.
4062 ((memq mark '(tick dormant expire reply save))
4064 (when (or (< (setq article (pop articles)) min) (> article max))
4065 (set var (delq article (symbol-value var))))))
4067 ((memq mark uncompressed)
4068 (when (not (listp (cdr (symbol-value var))))
4069 (set var (list (symbol-value var))))
4070 (when (not (listp (cdr articles)))
4071 (setq articles (list articles)))
4073 (when (or (not (consp (setq article (pop articles))))
4074 (< (car article) min)
4075 (> (car article) max))
4076 (set var (delq article (symbol-value var))))))))))
4078 (defun gnus-update-missing-marks (missing)
4079 "Go through the list of MISSING articles and remove them from the mark lists."
4081 (let ((types gnus-article-mark-lists)
4083 ;; Go through all types.
4085 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4086 (when (symbol-value var)
4087 ;; This list has articles. So we delete all missing articles
4091 (set var (delq (pop m) (symbol-value var)))))))))
4093 (defun gnus-update-marks ()
4094 "Enter the various lists of marked articles into the newsgroup info list."
4095 (let ((types gnus-article-mark-lists)
4096 (info (gnus-get-info gnus-newsgroup-name))
4097 (uncompressed '(score bookmark killed))
4098 type list newmarked symbol)
4100 ;; Add all marks lists that are non-nil to the list of marks lists.
4101 (while (setq type (pop types))
4102 (when (setq list (symbol-value
4104 (intern (format "gnus-newsgroup-%s"
4107 ;; Get rid of the entries of the articles that have the
4109 (when (and (eq (cdr type) 'score)
4113 (prev (cons nil list))
4116 (if (or (not (consp (car arts)))
4117 (= (cdar arts) gnus-summary-default-score))
4118 (setcdr prev (cdr arts))
4120 (setq arts (cdr arts)))
4121 (setq list (cdr all))))
4123 (push (cons (cdr type)
4124 (if (memq (cdr type) uncompressed) list
4125 (gnus-compress-sequence
4126 (set symbol (sort list '<)) t)))
4129 ;; Enter these new marks into the info of the group.
4131 (setcar (nthcdr 3 info) newmarked)
4132 ;; Add the marks lists to the end of the info.
4134 (setcdr (nthcdr 2 info) (list newmarked))))
4136 ;; Cut off the end of the info if there's nothing else there.
4140 (when (nthcdr (decf i) info)
4141 (setcdr (nthcdr i info) nil)))))))
4143 (defun gnus-set-mode-line (where)
4144 "This function sets the mode line of the article or summary buffers.
4145 If WHERE is `summary', the summary mode line format will be used."
4146 ;; Is this mode line one we keep updated?
4147 (when (memq where gnus-updated-mode-lines)
4150 ;; We evaluate this in the summary buffer since these
4151 ;; variables are buffer-local to that buffer.
4152 (set-buffer gnus-summary-buffer)
4153 ;; We bind all these variables that are used in the `eval' form
4155 (let* ((mformat (symbol-value
4157 (format "gnus-%s-mode-line-format-spec" where))))
4158 (gnus-tmp-group-name gnus-newsgroup-name)
4159 (gnus-tmp-article-number (or gnus-current-article 0))
4160 (gnus-tmp-unread gnus-newsgroup-unreads)
4161 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4162 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4163 (gnus-tmp-unread-and-unselected
4164 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4165 (zerop gnus-tmp-unselected))
4167 ((zerop gnus-tmp-unselected)
4168 (format "{%d more}" gnus-tmp-unread-and-unticked))
4169 (t (format "{%d(+%d) more}"
4170 gnus-tmp-unread-and-unticked
4171 gnus-tmp-unselected))))
4173 (if (and gnus-current-headers
4174 (vectorp gnus-current-headers))
4175 (gnus-mode-string-quote
4176 (mail-header-subject gnus-current-headers))
4178 bufname-length max-len
4179 gnus-tmp-header);; passed as argument to any user-format-funcs
4180 (setq mode-string (eval mformat))
4181 (setq bufname-length (if (string-match "%b" mode-string)
4184 (if (eq where 'summary)
4186 (get-buffer gnus-article-buffer))))
4189 (setq max-len (max 4 (if gnus-mode-non-string-length
4191 gnus-mode-non-string-length
4193 (length mode-string))))
4194 ;; We might have to chop a bit of the string off...
4195 (when (> (length mode-string) max-len)
4197 (concat (gnus-truncate-string mode-string (- max-len 3))
4199 ;; Pad the mode string a bit.
4200 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4201 ;; Update the mode line.
4202 (setq mode-line-buffer-identification
4203 (gnus-mode-line-buffer-identification (list mode-string)))
4204 (set-buffer-modified-p t))))
4206 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4207 "Go through the HEADERS list and add all Xrefs to a hash table.
4208 The resulting hash table is returned, or nil if no Xrefs were found."
4209 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4210 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4211 (xref-hashtb (gnus-make-hashtable))
4212 start group entry number xrefs header)
4214 (setq header (pop headers))
4215 (when (and (setq xrefs (mail-header-xref header))
4216 (not (memq (setq number (mail-header-number header))
4219 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4220 (setq start (match-end 0))
4221 (setq group (if prefix
4222 (concat prefix (substring xrefs (match-beginning 1)
4224 (substring xrefs (match-beginning 1) (match-end 1))))
4226 (string-to-int (substring xrefs (match-beginning 2)
4228 (if (setq entry (gnus-gethash group xref-hashtb))
4229 (setcdr entry (cons number (cdr entry)))
4230 (gnus-sethash group (cons number nil) xref-hashtb)))))
4231 (and start xref-hashtb)))
4233 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4234 "Look through all the headers and mark the Xrefs as read."
4235 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4236 name entry info xref-hashtb idlist method nth4)
4238 (set-buffer gnus-group-buffer)
4239 (when (setq xref-hashtb
4240 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4243 (unless (string= from-newsgroup (setq name (symbol-name group)))
4244 (setq idlist (symbol-value group))
4245 ;; Dead groups are not updated.
4247 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4249 (when (stringp (setq nth4 (gnus-info-method info)))
4250 (setq nth4 (gnus-server-to-method nth4))))
4251 ;; Only do the xrefs if the group has the same
4252 ;; select method as the group we have just read.
4253 (or (gnus-methods-equal-p
4254 nth4 (gnus-find-method-for-group from-newsgroup))
4256 (equal nth4 (setq method (gnus-find-method-for-group
4258 (and (equal (car nth4) (car method))
4259 (equal (nth 1 nth4) (nth 1 method))))
4260 gnus-use-cross-reference
4261 (or (not (eq gnus-use-cross-reference t))
4263 ;; Only do cross-references on subscribed
4264 ;; groups, if that is what is wanted.
4265 (<= (gnus-info-level info) gnus-level-subscribed))
4266 (gnus-group-make-articles-read name idlist))))
4269 (defun gnus-compute-read-articles (group articles)
4270 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4271 (info (nth 2 entry))
4272 (active (gnus-active group))
4275 ;; First peel off all illegal article numbers.
4277 (let ((ids articles)
4279 (while (setq id (pop ids))
4280 (when (and first (> id (cdr active)))
4281 ;; We'll end up in this situation in one particular
4282 ;; obscure situation. If you re-scan a group and get
4283 ;; a new article that is cross-posted to a different
4284 ;; group that has not been re-scanned, you might get
4285 ;; crossposted article that has a higher number than
4286 ;; Gnus believes possible. So we re-activate this
4287 ;; group as well. This might mean doing the
4288 ;; crossposting thingy will *increase* the number
4289 ;; of articles in some groups. Tsk, tsk.
4290 (setq active (or (gnus-activate-group group) active)))
4291 (when (or (> id (cdr active))
4292 (< id (car active)))
4293 (setq articles (delq id articles))))))
4294 ;; If the read list is nil, we init it.
4296 (null (gnus-info-read info))
4298 (setq ninfo (cons 1 (1- (car active))))
4299 (setq ninfo (gnus-info-read info)))
4300 ;; Then we add the read articles to the range.
4302 ninfo (setq articles (sort articles '<))))))
4304 (defun gnus-group-make-articles-read (group articles)
4305 "Update the info of GROUP to say that ARTICLES are read."
4307 (entry (gnus-gethash group gnus-newsrc-hashtb))
4308 (info (nth 2 entry))
4309 (active (gnus-active group))
4312 (setq range (gnus-compute-read-articles group articles))
4314 (set-buffer gnus-group-buffer)
4317 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4318 (gnus-info-set-read ',info ',(gnus-info-read info))
4319 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4320 (gnus-group-update-group ,group t))))
4321 ;; Add the read articles to the range.
4322 (gnus-info-set-read info range)
4323 ;; Then we have to re-compute how many unread
4324 ;; articles there are in this group.
4328 (setq num (- (1+ (cdr active)) (car active))))
4329 ((not (listp (cdr range)))
4330 (setq num (- (cdr active) (- (1+ (cdr range))
4334 (if (numberp (car range))
4336 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4337 (setq range (cdr range)))
4338 (setq num (- (cdr active) num))))
4339 ;; Update the number of unread articles.
4341 ;; Update the group buffer.
4342 (gnus-group-update-group group t)))))
4344 (defun gnus-methods-equal-p (m1 m2)
4345 (let ((m1 (or m1 gnus-select-method))
4346 (m2 (or m2 gnus-select-method)))
4348 (and (eq (car m1) (car m2))
4349 (or (not (memq 'address (assoc (symbol-name (car m1))
4350 gnus-valid-select-methods)))
4351 (equal (nth 1 m1) (nth 1 m2)))))))
4353 (defvar gnus-newsgroup-none-id 0)
4355 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4356 (let ((cur nntp-server-buffer)
4359 (save-excursion (set-buffer gnus-summary-buffer)
4360 gnus-newsgroup-dependencies)))
4361 headers id id-dep ref-dep end ref)
4363 (set-buffer nntp-server-buffer)
4364 ;; Translate all TAB characters into SPACE characters.
4365 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4366 (gnus-run-hooks 'gnus-parse-headers-hook)
4367 (let ((case-fold-search t)
4368 in-reply-to header p lines chars)
4369 (goto-char (point-min))
4370 ;; Search to the beginning of the next header. Error messages
4371 ;; do not begin with 2 or 3.
4372 (while (re-search-forward "^[23][0-9]+ " nil t)
4375 ;; This implementation of this function, with nine
4376 ;; search-forwards instead of the one re-search-forward and
4377 ;; a case (which basically was the old function) is actually
4378 ;; about twice as fast, even though it looks messier. You
4379 ;; can't have everything, I guess. Speed and elegance
4380 ;; doesn't always go hand in hand.
4389 (narrow-to-region (point)
4390 (or (and (search-forward "\n.\n" nil t)
4396 (if (search-forward "\nsubject: " nil t)
4398 gnus-unstructured-field-decoder (nnheader-header-value))
4403 (if (search-forward "\nfrom: " nil t)
4405 gnus-structured-field-decoder (nnheader-header-value))
4410 (if (search-forward "\ndate: " nil t)
4411 (nnheader-header-value) ""))
4415 (setq id (if (re-search-forward
4416 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4417 ;; We do it this way to make sure the Message-ID
4418 ;; is (somewhat) syntactically valid.
4419 (buffer-substring (match-beginning 1)
4421 ;; If there was no message-id, we just fake one
4422 ;; to make subsequent routines simpler.
4423 (nnheader-generate-fake-message-id))))
4427 (if (search-forward "\nreferences: " nil t)
4431 (nnheader-header-value)
4436 (search-backward ">" end t)
4439 (search-backward "<" end t)
4441 ;; Get the references from the in-reply-to header if there
4442 ;; were no references and the in-reply-to header looks
4444 (if (and (search-forward "\nin-reply-to: " nil t)
4445 (setq in-reply-to (nnheader-header-value))
4446 (string-match "<[^>]+>" in-reply-to))
4448 (setq ref (substring in-reply-to (match-beginning 0)
4450 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4451 (setq ref2 (substring in-reply-to (match-beginning 0)
4453 (when (> (length ref2) (length ref))
4459 (if (search-forward "\nchars: " nil t)
4460 (if (numberp (setq chars (ignore-errors (read cur))))
4466 (if (search-forward "\nlines: " nil t)
4467 (if (numberp (setq lines (ignore-errors (read cur))))
4473 (and (search-forward "\nxref: " nil t)
4474 (nnheader-header-value)))))
4475 (when (equal id ref)
4478 (when gnus-alter-header-function
4479 (funcall gnus-alter-header-function header)
4480 (setq id (mail-header-id header)
4481 ref (gnus-parent-id (mail-header-references header))))
4484 (gnus-dependencies-add-header
4485 header dependencies force-new))
4486 (push header headers))
4487 (goto-char (point-max))
4489 (nreverse headers)))))
4491 ;; Goes through the xover lines and returns a list of vectors
4492 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4493 force-new dependencies
4494 group also-fetch-heads)
4495 "Parse the news overview data in the server buffer, and return a
4496 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4497 ;; Get the Xref when the users reads the articles since most/some
4498 ;; NNTP servers do not include Xrefs when using XOVER.
4499 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4500 (let ((cur nntp-server-buffer)
4501 (dependencies (or dependencies gnus-newsgroup-dependencies))
4502 number headers header)
4504 (set-buffer nntp-server-buffer)
4505 ;; Allow the user to mangle the headers before parsing them.
4506 (gnus-run-hooks 'gnus-parse-headers-hook)
4507 (goto-char (point-min))
4510 (while (and sequence (not (eobp)))
4511 (setq number (read cur))
4512 (while (and sequence
4513 (< (car sequence) number))
4514 (setq sequence (cdr sequence)))
4516 (eq number (car sequence))
4518 (setq sequence (cdr sequence))
4519 (setq header (inline
4520 (gnus-nov-parse-line
4521 number dependencies force-new))))
4522 (push header headers))
4525 (gnus-error 4 "Strange nov line (%d)"
4526 (count-lines (point-min) (point)))))
4528 ;; A common bug in inn is that if you have posted an article and
4529 ;; then retrieves the active file, it will answer correctly --
4530 ;; the new article is included. However, a NOV entry for the
4531 ;; article may not have been generated yet, so this may fail.
4532 ;; We work around this problem by retrieving the last few
4533 ;; headers using HEAD.
4534 (if (or (not also-fetch-heads)
4536 ;; We (probably) got all the headers.
4538 (let ((gnus-nov-is-evil t))
4541 (when (gnus-retrieve-headers sequence group)
4542 (gnus-get-newsgroup-headers))))))))
4544 (defun gnus-article-get-xrefs ()
4545 "Fill in the Xref value in `gnus-current-headers', if necessary.
4546 This is meant to be called in `gnus-article-internal-prepare-hook'."
4547 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4548 gnus-current-headers)))
4549 (or (not gnus-use-cross-reference)
4551 (and (mail-header-xref headers)
4552 (not (string= (mail-header-xref headers) "")))
4553 (let ((case-fold-search t)
4556 (nnheader-narrow-to-headers)
4557 (goto-char (point-min))
4558 (when (or (and (eq (downcase (following-char)) ?x)
4559 (looking-at "Xref:"))
4560 (search-forward "\nXref:" nil t))
4561 (goto-char (1+ (match-end 0)))
4562 (setq xref (buffer-substring (point)
4563 (progn (end-of-line) (point))))
4564 (mail-header-set-xref headers xref)))))))
4566 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4567 "Find article ID and insert the summary line for that article.
4568 OLD-HEADER can either be a header or a line number to insert
4569 the subject line on."
4570 (let* ((line (and (numberp old-header) old-header))
4571 (old-header (and (vectorp old-header) old-header))
4572 (header (cond ((and old-header use-old-header)
4575 (gnus-number-to-header id))
4576 (gnus-number-to-header id))
4578 (gnus-read-header id))))
4579 (number (and (numberp id) id))
4582 ;; Rebuild the thread that this article is part of and go to the
4583 ;; article we have fetched.
4584 (when (and (not gnus-show-threads)
4587 (setq d (gnus-data-find (mail-header-number old-header))))
4588 (goto-char (gnus-data-pos d))
4591 (- (gnus-point-at-bol)
4593 (1+ (gnus-point-at-eol))
4594 (gnus-delete-line))))))
4596 (mail-header-set-number header (mail-header-number old-header)))
4597 (setq gnus-newsgroup-sparse
4598 (delq (setq number (mail-header-number header))
4599 gnus-newsgroup-sparse))
4600 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4601 (push number gnus-newsgroup-limit)
4602 (gnus-rebuild-thread (mail-header-id header) line)
4603 (gnus-summary-goto-subject number nil t))
4604 (when (and (numberp number)
4606 ;; We have to update the boundaries even if we can't fetch the
4607 ;; article if ID is a number -- so that the next `P' or `N'
4608 ;; command will fetch the previous (or next) article even
4609 ;; if the one we tried to fetch this time has been canceled.
4610 (when (> number gnus-newsgroup-end)
4611 (setq gnus-newsgroup-end number))
4612 (when (< number gnus-newsgroup-begin)
4613 (setq gnus-newsgroup-begin number))
4614 (setq gnus-newsgroup-unselected
4615 (delq number gnus-newsgroup-unselected)))
4616 ;; Report back a success?
4617 (and header (mail-header-number header))))
4619 ;;; Process/prefix in the summary buffer
4621 (defun gnus-summary-work-articles (n)
4622 "Return a list of articles to be worked upon.
4623 The prefix argument, the list of process marked articles, and the
4624 current article will be taken into consideration."
4626 (set-buffer gnus-summary-buffer)
4629 ;; A numerical prefix has been given.
4630 (setq n (prefix-numeric-value n))
4631 (let ((backward (< n 0))
4632 (n (abs (prefix-numeric-value n)))
4637 (push (setq article (gnus-summary-article-number))
4640 (gnus-summary-find-prev nil article)
4641 (gnus-summary-find-next nil article)))
4643 (nreverse articles)))
4644 ((and (gnus-region-active-p) (mark))
4645 (message "region active")
4646 ;; Work on the region between point and mark.
4647 (let ((max (max (point) (mark)))
4650 (goto-char (min (point) (mark)))
4653 (push (setq article (gnus-summary-article-number)) articles)
4654 (gnus-summary-find-next nil article)
4656 (nreverse articles))))
4657 (gnus-newsgroup-processable
4658 ;; There are process-marked articles present.
4659 ;; Save current state.
4660 (gnus-summary-save-process-mark)
4662 (reverse gnus-newsgroup-processable))
4664 ;; Just return the current article.
4665 (list (gnus-summary-article-number))))))
4667 (defmacro gnus-summary-iterate (arg &rest forms)
4668 "Iterate over the process/prefixed articles and do FORMS.
4669 ARG is the interactive prefix given to the command. FORMS will be
4670 executed with point over the summary line of the articles."
4671 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
4672 `(let ((,articles (gnus-summary-work-articles ,arg)))
4674 (gnus-summary-goto-subject (car ,articles))
4677 (put 'gnus-summary-iterate 'lisp-indent-function 1)
4678 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
4680 (defun gnus-summary-save-process-mark ()
4681 "Push the current set of process marked articles on the stack."
4683 (push (copy-sequence gnus-newsgroup-processable)
4684 gnus-newsgroup-process-stack))
4686 (defun gnus-summary-kill-process-mark ()
4687 "Push the current set of process marked articles on the stack and unmark."
4689 (gnus-summary-save-process-mark)
4690 (gnus-summary-unmark-all-processable))
4692 (defun gnus-summary-yank-process-mark ()
4693 "Pop the last process mark state off the stack and restore it."
4695 (unless gnus-newsgroup-process-stack
4696 (error "Empty mark stack"))
4697 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4699 (defun gnus-summary-process-mark-set (set)
4700 "Make SET into the current process marked articles."
4701 (gnus-summary-unmark-all-processable)
4703 (gnus-summary-set-process-mark (pop set))))
4705 ;;; Searching and stuff
4707 (defun gnus-summary-search-group (&optional backward use-level)
4708 "Search for next unread newsgroup.
4709 If optional argument BACKWARD is non-nil, search backward instead."
4711 (set-buffer gnus-group-buffer)
4712 (when (gnus-group-search-forward
4713 backward nil (if use-level (gnus-group-group-level) nil))
4714 (gnus-group-group-name))))
4716 (defun gnus-summary-best-group (&optional exclude-group)
4717 "Find the name of the best unread group.
4718 If EXCLUDE-GROUP, do not go to this group."
4720 (set-buffer gnus-group-buffer)
4722 (gnus-group-best-unread-group exclude-group))))
4724 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
4725 (if backward (gnus-summary-find-prev)
4726 (let* ((dummy (gnus-summary-article-intangible-p))
4727 (article (or article (gnus-summary-article-number)))
4728 (arts (gnus-data-find-list article))
4730 (when (and (not dummy)
4731 (or (not gnus-summary-check-current)
4733 (not (gnus-data-unread-p (car arts)))))
4734 (setq arts (cdr arts)))
4739 (when (or (and undownloaded
4740 (eq gnus-undownloaded-mark
4741 (gnus-data-mark (car arts))))
4742 (gnus-data-unread-p (car arts)))
4743 (setq result (car arts)
4745 (setq arts (cdr arts)))
4748 (goto-char (gnus-data-pos result))
4749 (gnus-data-number result)))))
4751 (defun gnus-summary-find-prev (&optional unread article)
4752 (let* ((eobp (eobp))
4753 (article (or article (gnus-summary-article-number)))
4754 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
4756 (when (and (not eobp)
4757 (or (not gnus-summary-check-current)
4759 (not (gnus-data-unread-p (car arts)))))
4760 (setq arts (cdr arts)))
4765 (when (gnus-data-unread-p (car arts))
4766 (setq result (car arts)
4768 (setq arts (cdr arts)))
4771 (goto-char (gnus-data-pos result))
4772 (gnus-data-number result))))
4774 (defun gnus-summary-find-subject (subject &optional unread backward article)
4775 (let* ((simp-subject (gnus-simplify-subject-fully subject))
4776 (article (or article (gnus-summary-article-number)))
4777 (articles (gnus-data-list backward))
4778 (arts (gnus-data-find-list article articles))
4780 (when (or (not gnus-summary-check-current)
4782 (not (gnus-data-unread-p (car arts))))
4783 (setq arts (cdr arts)))
4785 (and (or (not unread)
4786 (gnus-data-unread-p (car arts)))
4787 (vectorp (gnus-data-header (car arts)))
4789 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
4790 (setq result (car arts)
4792 (setq arts (cdr arts)))
4794 (goto-char (gnus-data-pos result))
4795 (gnus-data-number result))))
4797 (defun gnus-summary-search-forward (&optional unread subject backward)
4798 "Search forward for an article.
4799 If UNREAD, look for unread articles. If SUBJECT, look for
4800 articles with that subject. If BACKWARD, search backward instead."
4801 (cond (subject (gnus-summary-find-subject subject unread backward))
4802 (backward (gnus-summary-find-prev unread))
4803 (t (gnus-summary-find-next unread))))
4805 (defun gnus-recenter (&optional n)
4806 "Center point in window and redisplay frame.
4807 Also do horizontal recentering."
4809 (when (and gnus-auto-center-summary
4810 (not (eq gnus-auto-center-summary 'vertical)))
4811 (gnus-horizontal-recenter))
4814 (defun gnus-summary-recenter ()
4815 "Center point in the summary window.
4816 If `gnus-auto-center-summary' is nil, or the article buffer isn't
4817 displayed, no centering will be performed."
4818 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
4819 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
4820 (let* ((top (cond ((< (window-height) 4) 0)
4821 ((< (window-height) 7) 1)
4823 (height (1- (window-height)))
4824 (bottom (save-excursion (goto-char (point-max))
4825 (forward-line (- height))
4827 (window (get-buffer-window (current-buffer))))
4828 ;; The user has to want it.
4829 (when gnus-auto-center-summary
4830 (when (get-buffer-window gnus-article-buffer)
4831 ;; Only do recentering when the article buffer is displayed,
4832 ;; Set the window start to either `bottom', which is the biggest
4833 ;; possible valid number, or the second line from the top,
4834 ;; whichever is the least.
4836 window (min bottom (save-excursion
4837 (forward-line (- top)) (point)))))
4838 ;; Do horizontal recentering while we're at it.
4839 (when (and (get-buffer-window (current-buffer) t)
4840 (not (eq gnus-auto-center-summary 'vertical)))
4841 (let ((selected (selected-window)))
4842 (select-window (get-buffer-window (current-buffer) t))
4843 (gnus-summary-position-point)
4844 (gnus-horizontal-recenter)
4845 (select-window selected))))))
4847 (defun gnus-summary-jump-to-group (newsgroup)
4848 "Move point to NEWSGROUP in group mode buffer."
4849 ;; Keep update point of group mode buffer if visible.
4850 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
4851 (save-window-excursion
4852 ;; Take care of tree window mode.
4853 (when (get-buffer-window gnus-group-buffer)
4854 (pop-to-buffer gnus-group-buffer))
4855 (gnus-group-jump-to-group newsgroup))
4857 ;; Take care of tree window mode.
4858 (if (get-buffer-window gnus-group-buffer)
4859 (pop-to-buffer gnus-group-buffer)
4860 (set-buffer gnus-group-buffer))
4861 (gnus-group-jump-to-group newsgroup))))
4863 ;; This function returns a list of article numbers based on the
4864 ;; difference between the ranges of read articles in this group and
4865 ;; the range of active articles.
4866 (defun gnus-list-of-unread-articles (group)
4867 (let* ((read (gnus-info-read (gnus-get-info group)))
4868 (active (or (gnus-active group) (gnus-activate-group group)))
4871 ;; If none are read, then all are unread.
4873 (setq first (car active))
4874 ;; If the range of read articles is a single range, then the
4875 ;; first unread article is the article after the last read
4876 ;; article. Sounds logical, doesn't it?
4877 (if (not (listp (cdr read)))
4878 (setq first (1+ (cdr read)))
4879 ;; `read' is a list of ranges.
4880 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
4886 (while (< first nlast)
4888 (setq first (1+ first))))
4889 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
4890 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
4891 (setq read (cdr read)))))
4892 ;; And add the last unread articles.
4893 (while (<= first last)
4895 (setq first (1+ first)))
4896 ;; Return the list of unread articles.
4897 (delq 0 (nreverse unread))))
4899 (defun gnus-list-of-read-articles (group)
4900 "Return a list of unread, unticked and non-dormant articles."
4901 (let* ((info (gnus-get-info group))
4902 (marked (gnus-info-marks info))
4903 (active (gnus-active group)))
4905 (gnus-set-difference
4906 (gnus-sorted-complement
4907 (gnus-uncompress-range active)
4908 (gnus-list-of-unread-articles group))
4910 (gnus-uncompress-range (cdr (assq 'dormant marked)))
4911 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
4913 ;; Various summary commands
4915 (defun gnus-summary-select-article-buffer ()
4916 "Reconfigure windows to show article buffer."
4918 (if (not (gnus-buffer-live-p gnus-article-buffer))
4919 (error "There is no article buffer for this summary buffer")
4920 (gnus-configure-windows 'article)
4921 (select-window (get-buffer-window gnus-article-buffer))))
4923 (defun gnus-summary-universal-argument (arg)
4924 "Perform any operation on all articles that are process/prefixed."
4926 (let ((articles (gnus-summary-work-articles arg))
4933 (substitute-command-keys
4934 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
4937 (gnus-error 1 "Undefined key")
4940 (gnus-summary-goto-subject (setq article (pop articles)))
4941 (let (gnus-newsgroup-processable)
4942 (command-execute func))
4943 (gnus-summary-remove-process-mark article)))))
4944 (gnus-summary-position-point))
4946 (defun gnus-summary-toggle-truncation (&optional arg)
4947 "Toggle truncation of summary lines.
4948 With arg, turn line truncation on iff arg is positive."
4950 (setq truncate-lines
4951 (if (null arg) (not truncate-lines)
4952 (> (prefix-numeric-value arg) 0)))
4955 (defun gnus-summary-reselect-current-group (&optional all rescan)
4956 "Exit and then reselect the current newsgroup.
4957 The prefix argument ALL means to select all articles."
4959 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
4960 (error "Ephemeral groups can't be reselected"))
4961 (let ((current-subject (gnus-summary-article-number))
4962 (group gnus-newsgroup-name))
4963 (setq gnus-newsgroup-begin nil)
4965 ;; We have to adjust the point of group mode buffer because
4966 ;; point was moved to the next unread newsgroup by exiting.
4967 (gnus-summary-jump-to-group group)
4970 (gnus-group-get-new-news-this-group 1)))
4971 (gnus-group-read-group all t)
4972 (gnus-summary-goto-subject current-subject nil t)))
4974 (defun gnus-summary-rescan-group (&optional all)
4975 "Exit the newsgroup, ask for new articles, and select the newsgroup."
4977 (gnus-summary-reselect-current-group all t))
4979 (defun gnus-summary-update-info (&optional non-destructive)
4981 (let ((group gnus-newsgroup-name))
4983 (when gnus-newsgroup-kill-headers
4984 (setq gnus-newsgroup-killed
4985 (gnus-compress-sequence
4987 (gnus-set-sorted-intersection
4988 (gnus-uncompress-range gnus-newsgroup-killed)
4989 (setq gnus-newsgroup-unselected
4990 (sort gnus-newsgroup-unselected '<)))
4991 (setq gnus-newsgroup-unreads
4992 (sort gnus-newsgroup-unreads '<)))
4994 (unless (listp (cdr gnus-newsgroup-killed))
4995 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
4996 (let ((headers gnus-newsgroup-headers))
4997 ;; Set the new ranges of read articles.
4999 (set-buffer gnus-group-buffer)
5000 (gnus-undo-force-boundary))
5001 (gnus-update-read-articles
5002 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5003 ;; Set the current article marks.
5004 (let ((gnus-newsgroup-scored
5005 (if (and (not gnus-save-score)
5006 (not non-destructive))
5008 gnus-newsgroup-scored)))
5010 (gnus-update-marks)))
5011 ;; Do the cross-ref thing.
5012 (when gnus-use-cross-reference
5013 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5014 ;; Do not switch windows but change the buffer to work.
5015 (set-buffer gnus-group-buffer)
5016 (unless (gnus-ephemeral-group-p group)
5017 (gnus-group-update-group group)))))))
5019 (defun gnus-summary-save-newsrc (&optional force)
5020 "Save the current number of read/marked articles in the dribble buffer.
5021 The dribble buffer will then be saved.
5022 If FORCE (the prefix), also save the .newsrc file(s)."
5024 (gnus-summary-update-info t)
5026 (gnus-save-newsrc-file)
5027 (gnus-dribble-save)))
5029 (defun gnus-summary-exit (&optional temporary)
5030 "Exit reading current newsgroup, and then return to group selection mode.
5031 gnus-exit-group-hook is called with no arguments if that value is non-nil."
5033 (gnus-set-global-variables)
5034 (gnus-kill-save-kill-buffer)
5035 (gnus-async-halt-prefetch)
5036 (let* ((group gnus-newsgroup-name)
5037 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5040 (buf (current-buffer)))
5041 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5042 ;; If we have several article buffers, we kill them at exit.
5043 (unless gnus-single-article-buffer
5044 (gnus-kill-buffer gnus-original-article-buffer)
5045 (setq gnus-article-current nil))
5046 (when gnus-use-cache
5047 (gnus-cache-possibly-remove-articles)
5048 (gnus-cache-save-buffers))
5049 (gnus-async-prefetch-remove-group group)
5050 (when gnus-suppress-duplicates
5051 (gnus-dup-enter-articles))
5052 (when gnus-use-trees
5053 (gnus-tree-close group))
5054 ;; Remove entries for this group.
5055 (nnmail-purge-split-history (gnus-group-real-name group))
5056 ;; Make all changes in this group permanent.
5058 (gnus-run-hooks 'gnus-exit-group-hook)
5059 (gnus-summary-update-info)
5060 ;; Do adaptive scoring, and possibly save score files.
5061 (when gnus-newsgroup-adaptive
5062 (gnus-score-adaptive))
5063 (when gnus-use-scoring
5065 (gnus-close-group group)
5066 ;; Make sure where we were, and go to next newsgroup.
5067 (set-buffer gnus-group-buffer)
5069 (gnus-group-jump-to-group group))
5070 (gnus-run-hooks 'gnus-summary-exit-hook)
5071 (unless (or quit-config
5072 ;; If this group has disappeared from the summary
5073 ;; buffer, don't skip forwards.
5074 (not (string= group (gnus-group-group-name))))
5075 (gnus-group-next-unread-group 1))
5076 (setq group-point (point))
5079 ;; If we have several article buffers, we kill them at exit.
5080 (unless gnus-single-article-buffer
5081 (gnus-kill-buffer gnus-article-buffer)
5082 (gnus-kill-buffer gnus-original-article-buffer)
5083 (setq gnus-article-current nil))
5085 (if (not gnus-kill-summary-on-exit)
5086 (gnus-deaden-summary)
5087 ;; We set all buffer-local variables to nil. It is unclear why
5088 ;; this is needed, but if we don't, buffer-local variables are
5089 ;; not garbage-collected, it seems. This would the lead to en
5090 ;; ever-growing Emacs.
5091 (gnus-summary-clear-local-variables)
5092 (when (get-buffer gnus-article-buffer)
5093 (bury-buffer gnus-article-buffer))
5094 ;; We clear the global counterparts of the buffer-local
5095 ;; variables as well, just to be on the safe side.
5096 (set-buffer gnus-group-buffer)
5097 (gnus-summary-clear-local-variables)
5098 ;; Return to group mode buffer.
5099 (when (eq mode 'gnus-summary-mode)
5100 (gnus-kill-buffer buf)))
5101 (setq gnus-current-select-method gnus-select-method)
5102 (pop-to-buffer gnus-group-buffer)
5103 ;; Clear the current group name.
5104 (if (not quit-config)
5106 (goto-char group-point)
5107 (gnus-configure-windows 'group 'force))
5108 (gnus-handle-ephemeral-exit quit-config))
5110 (setq gnus-newsgroup-name nil)))))
5112 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5113 (defun gnus-summary-exit-no-update (&optional no-questions)
5114 "Quit reading current newsgroup without updating read article info."
5116 (let* ((group gnus-newsgroup-name)
5117 (quit-config (gnus-group-quit-config group)))
5118 (when (or no-questions
5120 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5121 (gnus-async-halt-prefetch)
5122 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5123 ;; If we have several article buffers, we kill them at exit.
5124 (unless gnus-single-article-buffer
5125 (gnus-kill-buffer gnus-article-buffer)
5126 (gnus-kill-buffer gnus-original-article-buffer)
5127 (setq gnus-article-current nil))
5128 (if (not gnus-kill-summary-on-exit)
5129 (gnus-deaden-summary)
5130 (gnus-close-group group)
5131 (gnus-summary-clear-local-variables)
5132 (set-buffer gnus-group-buffer)
5133 (gnus-summary-clear-local-variables)
5134 (when (get-buffer gnus-summary-buffer)
5135 (kill-buffer gnus-summary-buffer)))
5136 (unless gnus-single-article-buffer
5137 (setq gnus-article-current nil))
5138 (when gnus-use-trees
5139 (gnus-tree-close group))
5140 (gnus-async-prefetch-remove-group group)
5141 (when (get-buffer gnus-article-buffer)
5142 (bury-buffer gnus-article-buffer))
5143 ;; Return to the group buffer.
5144 (gnus-configure-windows 'group 'force)
5145 ;; Clear the current group name.
5146 (setq gnus-newsgroup-name nil)
5147 (when (equal (gnus-group-group-name) group)
5148 (gnus-group-next-unread-group 1))
5150 (gnus-handle-ephemeral-exit quit-config)))))
5152 (defun gnus-handle-ephemeral-exit (quit-config)
5153 "Handle movement when leaving an ephemeral group.
5154 The state which existed when entering the ephemeral is reset."
5155 (if (not (buffer-name (car quit-config)))
5156 (gnus-configure-windows 'group 'force)
5157 (set-buffer (car quit-config))
5158 (cond ((eq major-mode 'gnus-summary-mode)
5159 (gnus-set-global-variables))
5160 ((eq major-mode 'gnus-article-mode)
5162 ;; The `gnus-summary-buffer' variable may point
5163 ;; to the old summary buffer when using a single
5165 (unless (gnus-buffer-live-p gnus-summary-buffer)
5166 (set-buffer gnus-group-buffer))
5167 (set-buffer gnus-summary-buffer)
5168 (gnus-set-global-variables))))
5169 (if (or (eq (cdr quit-config) 'article)
5170 (eq (cdr quit-config) 'pick))
5172 ;; The current article may be from the ephemeral group
5173 ;; thus it is best that we reload this article
5174 (gnus-summary-show-article)
5175 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5176 (gnus-configure-windows 'pick 'force)
5177 (gnus-configure-windows (cdr quit-config) 'force)))
5178 (gnus-configure-windows (cdr quit-config) 'force))
5179 (when (eq major-mode 'gnus-summary-mode)
5180 (gnus-summary-next-subject 1 nil t)
5181 (gnus-summary-recenter)
5182 (gnus-summary-position-point))))
5184 (defun gnus-summary-preview-mime-message (arg)
5185 "MIME decode and play this message."
5188 (let ((gnus-break-pages nil)
5190 (gnus-summary-select-article t t)
5192 (select-window (get-buffer-window gnus-article-buffer))
5195 (defun gnus-summary-scroll-down ()
5196 "Scroll down one line current article."
5198 (gnus-summary-scroll-up -1)
5203 (defvar gnus-dead-summary-mode-map nil)
5205 (unless gnus-dead-summary-mode-map
5206 (setq gnus-dead-summary-mode-map (make-keymap))
5207 (suppress-keymap gnus-dead-summary-mode-map)
5208 (substitute-key-definition
5209 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5210 (let ((keys '("\C-d" "\r" "\177" [delete])))
5212 (define-key gnus-dead-summary-mode-map
5213 (pop keys) 'gnus-summary-wake-up-the-dead))))
5215 (defvar gnus-dead-summary-mode nil
5216 "Minor mode for Gnus summary buffers.")
5218 (defun gnus-dead-summary-mode (&optional arg)
5219 "Minor mode for Gnus summary buffers."
5221 (when (eq major-mode 'gnus-summary-mode)
5222 (make-local-variable 'gnus-dead-summary-mode)
5223 (setq gnus-dead-summary-mode
5224 (if (null arg) (not gnus-dead-summary-mode)
5225 (> (prefix-numeric-value arg) 0)))
5226 (when gnus-dead-summary-mode
5227 (gnus-add-minor-mode
5228 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5230 (defun gnus-deaden-summary ()
5231 "Make the current summary buffer into a dead summary buffer."
5232 ;; Kill any previous dead summary buffer.
5233 (when (and gnus-dead-summary
5234 (buffer-name gnus-dead-summary))
5236 (set-buffer gnus-dead-summary)
5237 (when gnus-dead-summary-mode
5238 (kill-buffer (current-buffer)))))
5239 ;; Make this the current dead summary.
5240 (setq gnus-dead-summary (current-buffer))
5241 (gnus-dead-summary-mode 1)
5242 (let ((name (buffer-name)))
5243 (when (string-match "Summary" name)
5245 (concat (substring name 0 (match-beginning 0)) "Dead "
5246 (substring name (match-beginning 0)))
5249 (defun gnus-kill-or-deaden-summary (buffer)
5250 "Kill or deaden the summary BUFFER."
5252 (when (and (buffer-name buffer)
5253 (not gnus-single-article-buffer))
5256 (gnus-kill-buffer gnus-article-buffer)
5257 (gnus-kill-buffer gnus-original-article-buffer)))
5258 (cond (gnus-kill-summary-on-exit
5259 (when (and gnus-use-trees
5260 (gnus-buffer-exists-p buffer))
5263 (gnus-tree-close gnus-newsgroup-name)))
5264 (gnus-kill-buffer buffer))
5265 ((gnus-buffer-exists-p buffer)
5268 (gnus-deaden-summary))))))
5270 (defun gnus-summary-wake-up-the-dead (&rest args)
5271 "Wake up the dead summary buffer."
5273 (gnus-dead-summary-mode -1)
5274 (let ((name (buffer-name)))
5275 (when (string-match "Dead " name)
5277 (concat (substring name 0 (match-beginning 0))
5278 (substring name (match-end 0)))
5280 (gnus-message 3 "This dead summary is now alive again"))
5282 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5283 (defun gnus-summary-fetch-faq (&optional faq-dir)
5284 "Fetch the FAQ for the current group.
5285 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5289 (when current-prefix-arg
5291 "Faq dir: " (and (listp gnus-group-faq-directory)
5292 (mapcar (lambda (file) (list file))
5293 gnus-group-faq-directory))))))
5294 (let (gnus-faq-buffer)
5295 (when (setq gnus-faq-buffer
5296 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5297 (gnus-configure-windows 'summary-faq))))
5299 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5300 (defun gnus-summary-describe-group (&optional force)
5301 "Describe the current newsgroup."
5303 (gnus-group-describe-group force gnus-newsgroup-name))
5305 (defun gnus-summary-describe-briefly ()
5306 "Describe summary mode commands briefly."
5309 (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")))
5311 ;; Walking around group mode buffer from summary mode.
5313 (defun gnus-summary-next-group (&optional no-article target-group backward)
5314 "Exit current newsgroup and then select next unread newsgroup.
5315 If prefix argument NO-ARTICLE is non-nil, no article is selected
5316 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5317 previous group instead."
5319 ;; Stop pre-fetching.
5320 (gnus-async-halt-prefetch)
5321 (let ((current-group gnus-newsgroup-name)
5322 (current-buffer (current-buffer))
5324 ;; First we semi-exit this group to update Xrefs and all variables.
5325 ;; We can't do a real exit, because the window conf must remain
5326 ;; the same in case the user is prompted for info, and we don't
5327 ;; want the window conf to change before that...
5328 (gnus-summary-exit t)
5329 (while (not entered)
5330 ;; Then we find what group we are supposed to enter.
5331 (set-buffer gnus-group-buffer)
5332 (gnus-group-jump-to-group current-group)
5335 (if (eq gnus-keep-same-level 'best)
5336 (gnus-summary-best-group gnus-newsgroup-name)
5337 (gnus-summary-search-group backward gnus-keep-same-level))))
5338 (if (not target-group)
5339 ;; There are no further groups, so we return to the group
5342 (gnus-message 5 "Returning to the group buffer")
5344 (when (gnus-buffer-live-p current-buffer)
5345 (set-buffer current-buffer)
5346 (gnus-summary-exit))
5347 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5348 ;; We try to enter the target group.
5349 (gnus-group-jump-to-group target-group)
5350 (let ((unreads (gnus-group-group-unread)))
5351 (if (and (or (eq t unreads)
5352 (and unreads (not (zerop unreads))))
5353 (gnus-summary-read-group
5354 target-group nil no-article
5355 (and (buffer-name current-buffer) current-buffer)
5358 (setq current-group target-group
5359 target-group nil)))))))
5361 (defun gnus-summary-prev-group (&optional no-article)
5362 "Exit current newsgroup and then select previous unread newsgroup.
5363 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5365 (gnus-summary-next-group no-article nil t))
5367 ;; Walking around summary lines.
5369 (defun gnus-summary-first-subject (&optional unread undownloaded)
5370 "Go to the first unread subject.
5371 If UNREAD is non-nil, go to the first unread article.
5372 Returns the article selected or nil if there are no unread articles."
5377 ((null gnus-newsgroup-data)
5378 (gnus-message 3 "No articles in the group")
5380 ;; Pick the first article.
5382 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5383 (gnus-data-number (car gnus-newsgroup-data)))
5384 ;; No unread articles.
5385 ((null gnus-newsgroup-unreads)
5386 (gnus-message 3 "No more unread articles")
5388 ;; Find the first unread article.
5390 (let ((data gnus-newsgroup-data))
5392 (and (not (and undownloaded
5393 (eq gnus-undownloaded-mark
5394 (gnus-data-mark (car data)))))
5395 (not (gnus-data-unread-p (car data)))))
5396 (setq data (cdr data)))
5398 (goto-char (gnus-data-pos (car data)))
5399 (gnus-data-number (car data))))))
5400 (gnus-summary-position-point)))
5402 (defun gnus-summary-next-subject (n &optional unread dont-display)
5403 "Go to next N'th summary line.
5404 If N is negative, go to the previous N'th subject line.
5405 If UNREAD is non-nil, only unread articles are selected.
5406 The difference between N and the actual number of steps taken is
5409 (let ((backward (< n 0))
5413 (gnus-summary-find-prev unread)
5414 (gnus-summary-find-next unread)))
5415 (gnus-summary-show-thread)
5418 (gnus-message 7 "No more%s articles"
5419 (if unread " unread" "")))
5420 (unless dont-display
5421 (gnus-summary-recenter)
5422 (gnus-summary-position-point))
5425 (defun gnus-summary-next-unread-subject (n)
5426 "Go to next N'th unread summary line."
5428 (gnus-summary-next-subject n t))
5430 (defun gnus-summary-prev-subject (n &optional unread)
5431 "Go to previous N'th summary line.
5432 If optional argument UNREAD is non-nil, only unread article is selected."
5434 (gnus-summary-next-subject (- n) unread))
5436 (defun gnus-summary-prev-unread-subject (n)
5437 "Go to previous N'th unread summary line."
5439 (gnus-summary-next-subject (- n) t))
5441 (defun gnus-summary-goto-subject (article &optional force silent)
5442 "Go the subject line of ARTICLE.
5443 If FORCE, also allow jumping to articles not currently shown."
5444 (interactive "nArticle number: ")
5446 (data (gnus-data-find article)))
5447 ;; We read in the article if we have to.
5450 (gnus-summary-insert-subject
5452 (if (or (numberp force) (vectorp force)) force)
5454 (setq data (gnus-data-find article)))
5459 (gnus-message 3 "Can't find article %d" article))
5461 (goto-char (gnus-data-pos data))
5462 (gnus-summary-position-point)
5465 ;; Walking around summary lines with displaying articles.
5467 (defun gnus-summary-expand-window (&optional arg)
5468 "Make the summary buffer take up the entire Emacs frame.
5469 Given a prefix, will force an `article' buffer configuration."
5472 (gnus-configure-windows 'article 'force)
5473 (gnus-configure-windows 'summary 'force)))
5475 (defun gnus-summary-display-article (article &optional all-header)
5476 "Display ARTICLE in article buffer."
5477 (gnus-set-global-variables)
5481 (if gnus-summary-display-article-function
5482 (funcall gnus-summary-display-article-function article all-header)
5483 (gnus-article-prepare article all-header))
5484 (gnus-run-hooks 'gnus-select-article-hook)
5485 (when (and gnus-current-article
5486 (not (zerop gnus-current-article)))
5487 (gnus-summary-goto-subject gnus-current-article))
5488 (gnus-summary-recenter)
5489 (when (and gnus-use-trees gnus-show-threads)
5490 (gnus-possibly-generate-tree article)
5491 (gnus-highlight-selected-tree article))
5492 ;; Successfully display article.
5493 (gnus-article-set-window-start
5494 (cdr (assq article gnus-newsgroup-bookmarks))))))
5496 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5497 "Select the current article.
5498 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5499 non-nil, the article will be re-fetched even if it already present in
5500 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5502 ;; Make sure we are in the summary buffer to work around bbdb bug.
5503 (unless (eq major-mode 'gnus-summary-mode)
5504 (set-buffer gnus-summary-buffer))
5505 (let ((article (or article (gnus-summary-article-number)))
5506 (all-headers (not (not all-headers))) ;Must be T or NIL.
5507 gnus-summary-display-article-function
5510 (gnus-summary-article-pseudo-p article)
5511 (error "This is a pseudo-article"))
5514 (set-buffer gnus-summary-buffer)
5515 (if (or (and gnus-single-article-buffer
5516 (or (null gnus-current-article)
5517 (null gnus-article-current)
5518 (null (get-buffer gnus-article-buffer))
5519 (not (eq article (cdr gnus-article-current)))
5520 (not (equal (car gnus-article-current)
5521 gnus-newsgroup-name))))
5522 (and (not gnus-single-article-buffer)
5523 (or (null gnus-current-article)
5524 (not (eq gnus-current-article article))))
5526 ;; The requested article is different from the current article.
5528 (gnus-summary-display-article article all-headers)
5530 (when (or all-headers gnus-show-all-headers)
5531 (gnus-article-show-all-headers))
5534 (gnus-article-set-window-start
5535 (cdr (assq article gnus-newsgroup-bookmarks)))))))
5537 (defun gnus-summary-set-current-mark (&optional current-mark)
5538 "Obsolete function."
5541 (defun gnus-summary-next-article (&optional unread subject backward push)
5542 "Select the next article.
5543 If UNREAD, only unread articles are selected.
5544 If SUBJECT, only articles with SUBJECT are selected.
5545 If BACKWARD, the previous article is selected instead of the next."
5548 ;; Is there such an article?
5549 ((and (gnus-summary-search-forward unread subject backward)
5550 (or (gnus-summary-display-article (gnus-summary-article-number))
5551 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5552 (gnus-summary-position-point))
5553 ;; If not, we try the first unread, if that is wanted.
5555 gnus-auto-select-same
5556 (gnus-summary-first-unread-article))
5557 (gnus-summary-position-point)
5558 (gnus-message 6 "Wrapped"))
5559 ;; Try to get next/previous article not displayed in this group.
5560 ((and gnus-auto-extend-newsgroup
5561 (not unread) (not subject))
5562 (gnus-summary-goto-article
5563 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5564 nil (count-lines (point-min) (point))))
5565 ;; Go to next/previous group.
5567 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5568 (gnus-summary-jump-to-group gnus-newsgroup-name))
5569 (let ((cmd last-command-char)
5572 (set-buffer gnus-group-buffer)
5575 (if (eq gnus-keep-same-level 'best)
5576 (gnus-summary-best-group gnus-newsgroup-name)
5577 (gnus-summary-search-group backward gnus-keep-same-level))))
5578 ;; For some reason, the group window gets selected. We change
5580 (select-window (get-buffer-window (current-buffer)))
5581 ;; Select next unread newsgroup automagically.
5583 ((or (not gnus-auto-select-next)
5585 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5586 ((or (eq gnus-auto-select-next 'quietly)
5587 (and (eq gnus-auto-select-next 'slightly-quietly)
5589 (and (eq gnus-auto-select-next 'almost-quietly)
5590 (gnus-summary-last-article-p)))
5592 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5594 (gnus-message 7 "No more%s articles (%s)..."
5595 (if unread " unread" "")
5596 (if group (concat "selecting " group)
5598 (gnus-summary-next-group nil group backward)))
5600 (when (gnus-key-press-event-p last-input-event)
5601 (gnus-summary-walk-group-buffer
5602 gnus-newsgroup-name cmd unread backward point))))))))
5604 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5605 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5606 (?\C-p (gnus-group-prev-unread-group 1))))
5607 (cursor-in-echo-area t)
5608 keve key group ended)
5610 (set-buffer gnus-group-buffer)
5613 (if (eq gnus-keep-same-level 'best)
5614 (gnus-summary-best-group gnus-newsgroup-name)
5615 (gnus-summary-search-group backward gnus-keep-same-level))))
5618 5 "No more%s articles%s" (if unread " unread" "")
5620 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5621 (format " (Type %s for %s [%s])"
5622 (single-key-description cmd) group
5623 (car (gnus-gethash group gnus-newsrc-hashtb)))
5624 (format " (Type %s to exit %s)"
5625 (single-key-description cmd)
5626 gnus-newsgroup-name)))
5627 ;; Confirm auto selection.
5628 (setq key (car (setq keve (gnus-read-event-char))))
5631 ((assq key keystrokes)
5632 (let ((obuf (current-buffer)))
5633 (switch-to-buffer gnus-group-buffer)
5635 (gnus-group-jump-to-group group))
5636 (eval (cadr (assq key keystrokes)))
5637 (setq group (gnus-group-group-name))
5638 (switch-to-buffer obuf))
5642 (gnus-ephemeral-group-p gnus-newsgroup-name))
5644 (gnus-summary-next-group nil group backward)))
5646 (push (cdr keve) unread-command-events))))))
5648 (defun gnus-summary-next-unread-article ()
5649 "Select unread article after current one."
5651 (gnus-summary-next-article
5652 (or (not (eq gnus-summary-goto-unread 'never))
5653 (gnus-summary-last-article-p (gnus-summary-article-number)))
5654 (and gnus-auto-select-same
5655 (gnus-summary-article-subject))))
5657 (defun gnus-summary-prev-article (&optional unread subject)
5658 "Select the article after the current one.
5659 If UNREAD is non-nil, only unread articles are selected."
5661 (gnus-summary-next-article unread subject t))
5663 (defun gnus-summary-prev-unread-article ()
5664 "Select unread article before current one."
5666 (gnus-summary-prev-article
5667 (or (not (eq gnus-summary-goto-unread 'never))
5668 (gnus-summary-first-article-p (gnus-summary-article-number)))
5669 (and gnus-auto-select-same
5670 (gnus-summary-article-subject))))
5672 (defun gnus-summary-next-page (&optional lines circular)
5673 "Show next page of the selected article.
5674 If at the end of the current article, select the next article.
5675 LINES says how many lines should be scrolled up.
5677 If CIRCULAR is non-nil, go to the start of the article instead of
5678 selecting the next article when reaching the end of the current
5681 (setq gnus-summary-buffer (current-buffer))
5682 (gnus-set-global-variables)
5683 (let ((article (gnus-summary-article-number))
5684 (article-window (get-buffer-window gnus-article-buffer t))
5686 ;; If the buffer is empty, we have no article.
5688 (error "No article to select"))
5689 (gnus-configure-windows 'article)
5690 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
5691 (if (and (eq gnus-summary-goto-unread 'never)
5692 (not (gnus-summary-last-article-p article)))
5693 (gnus-summary-next-article)
5694 (gnus-summary-next-unread-article))
5695 (if (or (null gnus-current-article)
5696 (null gnus-article-current)
5697 (/= article (cdr gnus-article-current))
5698 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5699 ;; Selected subject is different from current article's.
5700 (gnus-summary-display-article article)
5701 (when article-window
5702 (gnus-eval-in-buffer-window gnus-article-buffer
5703 (setq endp (gnus-article-next-page lines)))
5706 (gnus-summary-beginning-of-article))
5708 (gnus-message 3 "End of message"))
5710 (if (and (eq gnus-summary-goto-unread 'never)
5711 (not (gnus-summary-last-article-p article)))
5712 (gnus-summary-next-article)
5713 (gnus-summary-next-unread-article))))))))
5714 (gnus-summary-recenter)
5715 (gnus-summary-position-point)))
5717 (defun gnus-summary-prev-page (&optional lines move)
5718 "Show previous page of selected article.
5719 Argument LINES specifies lines to be scrolled down.
5720 If MOVE, move to the previous unread article if point is at
5721 the beginning of the buffer."
5723 (let ((article (gnus-summary-article-number))
5724 (article-window (get-buffer-window gnus-article-buffer t))
5726 (gnus-configure-windows 'article)
5727 (if (or (null gnus-current-article)
5728 (null gnus-article-current)
5729 (/= article (cdr gnus-article-current))
5730 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5731 ;; Selected subject is different from current article's.
5732 (gnus-summary-display-article article)
5733 (gnus-summary-recenter)
5734 (when article-window
5735 (gnus-eval-in-buffer-window gnus-article-buffer
5736 (setq endp (gnus-article-prev-page lines)))
5737 (when (and move endp)
5739 (gnus-message 3 "Beginning of message"))
5741 (if (and (eq gnus-summary-goto-unread 'never)
5742 (not (gnus-summary-first-article-p article)))
5743 (gnus-summary-prev-article)
5744 (gnus-summary-prev-unread-article))))))))
5745 (gnus-summary-position-point))
5747 (defun gnus-summary-prev-page-or-article (&optional lines)
5748 "Show previous page of selected article.
5749 Argument LINES specifies lines to be scrolled down.
5750 If at the beginning of the article, go to the next article."
5752 (gnus-summary-prev-page lines t))
5754 (defun gnus-summary-scroll-up (lines)
5755 "Scroll up (or down) one line current article.
5756 Argument LINES specifies lines to be scrolled up (or down if negative)."
5758 (gnus-configure-windows 'article)
5759 (gnus-summary-show-thread)
5760 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
5761 (gnus-eval-in-buffer-window gnus-article-buffer
5763 (when (gnus-article-next-page lines)
5764 (gnus-message 3 "End of message")))
5766 (gnus-article-prev-page (- lines))))))
5767 (gnus-summary-recenter)
5768 (gnus-summary-position-point))
5770 (defun gnus-summary-next-same-subject ()
5771 "Select next article which has the same subject as current one."
5773 (gnus-summary-next-article nil (gnus-summary-article-subject)))
5775 (defun gnus-summary-prev-same-subject ()
5776 "Select previous article which has the same subject as current one."
5778 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
5780 (defun gnus-summary-next-unread-same-subject ()
5781 "Select next unread article which has the same subject as current one."
5783 (gnus-summary-next-article t (gnus-summary-article-subject)))
5785 (defun gnus-summary-prev-unread-same-subject ()
5786 "Select previous unread article which has the same subject as current one."
5788 (gnus-summary-prev-article t (gnus-summary-article-subject)))
5790 (defun gnus-summary-first-unread-article ()
5791 "Select the first unread article.
5792 Return nil if there are no unread articles."
5795 (when (gnus-summary-first-subject t)
5796 (gnus-summary-show-thread)
5797 (gnus-summary-first-subject t)
5798 (gnus-summary-display-article (gnus-summary-article-number)))
5799 (gnus-summary-position-point)))
5801 (defun gnus-summary-first-article ()
5802 "Select the first article.
5803 Return nil if there are no articles."
5806 (when (gnus-summary-first-subject)
5807 (gnus-summary-show-thread)
5808 (gnus-summary-first-subject)
5809 (gnus-summary-display-article (gnus-summary-article-number)))
5810 (gnus-summary-position-point)))
5812 (defun gnus-summary-best-unread-article ()
5813 "Select the unread article with the highest score."
5815 (let ((best -1000000)
5816 (data gnus-newsgroup-data)
5819 (and (gnus-data-unread-p (car data))
5821 (gnus-summary-article-score (gnus-data-number (car data))))
5824 article (gnus-data-number (car data))))
5825 (setq data (cdr data)))
5828 (gnus-summary-goto-article article)
5829 (error "No unread articles"))
5830 (gnus-summary-position-point))))
5832 (defun gnus-summary-last-subject ()
5833 "Go to the last displayed subject line in the group."
5834 (let ((article (gnus-data-number (car (gnus-data-list t)))))
5836 (gnus-summary-goto-subject article))))
5838 (defun gnus-summary-goto-article (article &optional all-headers force)
5839 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
5840 If ALL-HEADERS is non-nil, no header lines are hidden.
5841 If FORCE, go to the article even if it isn't displayed. If FORCE
5842 is a number, it is the line the article is to be displayed on."
5846 "Article number or Message-ID: "
5847 (mapcar (lambda (number) (list (int-to-string number)))
5848 gnus-newsgroup-limit))
5852 (if (and (stringp article)
5853 (string-match "@" article))
5854 (gnus-summary-refer-article article)
5855 (when (stringp article)
5856 (setq article (string-to-number article)))
5857 (if (gnus-summary-goto-subject article force)
5858 (gnus-summary-display-article article all-headers)
5859 (gnus-message 4 "Couldn't go to article %s" article) nil))
5860 (gnus-summary-position-point)))
5862 (defun gnus-summary-goto-last-article ()
5863 "Go to the previously read article."
5866 (when gnus-last-article
5867 (gnus-summary-goto-article gnus-last-article nil t))
5868 (gnus-summary-position-point)))
5870 (defun gnus-summary-pop-article (number)
5871 "Pop one article off the history and go to the previous.
5872 NUMBER articles will be popped off."
5875 (setq gnus-newsgroup-history
5876 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
5878 (gnus-summary-goto-article (car to) nil t)
5879 (error "Article history empty")))
5880 (gnus-summary-position-point))
5882 ;; Summary commands and functions for limiting the summary buffer.
5884 (defun gnus-summary-limit-to-articles (n)
5885 "Limit the summary buffer to the next N articles.
5886 If not given a prefix, use the process marked articles instead."
5889 (let ((articles (gnus-summary-work-articles n)))
5890 (setq gnus-newsgroup-processable nil)
5891 (gnus-summary-limit articles))
5892 (gnus-summary-position-point)))
5894 (defun gnus-summary-pop-limit (&optional total)
5895 "Restore the previous limit.
5896 If given a prefix, remove all limits."
5899 (setq gnus-newsgroup-limits
5900 (list (mapcar (lambda (h) (mail-header-number h))
5901 gnus-newsgroup-headers))))
5902 (unless gnus-newsgroup-limits
5903 (error "No limit to pop"))
5905 (gnus-summary-limit nil 'pop)
5906 (gnus-summary-position-point)))
5908 (defun gnus-summary-limit-to-subject (subject &optional header)
5909 "Limit the summary buffer to articles that have subjects that match a regexp."
5910 (interactive "sLimit to subject (regexp): ")
5912 (setq header "subject"))
5913 (when (not (equal "" subject))
5915 (let ((articles (gnus-summary-find-matching
5916 (or header "subject") subject 'all)))
5918 (error "Found no matches for \"%s\"" subject))
5919 (gnus-summary-limit articles))
5920 (gnus-summary-position-point))))
5922 (defun gnus-summary-limit-to-author (from)
5923 "Limit the summary buffer to articles that have authors that match a regexp."
5924 (interactive "sLimit to author (regexp): ")
5925 (gnus-summary-limit-to-subject from "from"))
5927 (defun gnus-summary-limit-to-age (age &optional younger-p)
5928 "Limit the summary buffer to articles that are older than (or equal) AGE days.
5929 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
5930 articles that are younger than AGE days."
5931 (interactive "nTime in days: \nP")
5933 (let ((data gnus-newsgroup-data)
5934 (cutoff (nnmail-days-to-time age))
5935 articles d date is-younger)
5936 (while (setq d (pop data))
5937 (when (and (vectorp (gnus-data-header d))
5938 (setq date (mail-header-date (gnus-data-header d))))
5939 (setq is-younger (nnmail-time-less
5940 (nnmail-time-since (nnmail-date-to-time date))
5945 (push (gnus-data-number d) articles))))
5946 (gnus-summary-limit (nreverse articles)))
5947 (gnus-summary-position-point)))
5949 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5951 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5953 (defun gnus-summary-limit-to-unread (&optional all)
5954 "Limit the summary buffer to articles that are not marked as read.
5955 If ALL is non-nil, limit strictly to unread articles."
5958 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
5959 (gnus-summary-limit-to-marks
5960 ;; Concat all the marks that say that an article is read and have
5962 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
5963 gnus-killed-mark gnus-kill-file-mark
5964 gnus-low-score-mark gnus-expirable-mark
5965 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
5966 gnus-duplicate-mark gnus-souped-mark)
5969 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
5970 (make-obsolete 'gnus-summary-delete-marked-with
5971 'gnus-summary-limit-exlude-marks)
5973 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
5974 "Exclude articles that are marked with MARKS (e.g. \"DK\").
5975 If REVERSE, limit the summary buffer to articles that are marked
5976 with MARKS. MARKS can either be a string of marks or a list of marks.
5977 Returns how many articles were removed."
5978 (interactive "sMarks: ")
5979 (gnus-summary-limit-to-marks marks t))
5981 (defun gnus-summary-limit-to-marks (marks &optional reverse)
5982 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
5983 If REVERSE (the prefix), limit the summary buffer to articles that are
5984 not marked with MARKS. MARKS can either be a string of marks or a
5986 Returns how many articles were removed."
5987 (interactive "sMarks: \nP")
5989 (let ((data gnus-newsgroup-data)
5990 (marks (if (listp marks) marks
5991 (append marks nil))) ; Transform to list.
5994 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
5995 (memq (gnus-data-mark (car data)) marks))
5996 (push (gnus-data-number (car data)) articles))
5997 (setq data (cdr data)))
5998 (gnus-summary-limit articles))
5999 (gnus-summary-position-point)))
6001 (defun gnus-summary-limit-to-score (&optional score)
6002 "Limit to articles with score at or above SCORE."
6004 (setq score (if score
6005 (prefix-numeric-value score)
6006 (or gnus-summary-default-score 0)))
6007 (let ((data gnus-newsgroup-data)
6010 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6012 (push (gnus-data-number (car data)) articles))
6013 (setq data (cdr data)))
6015 (gnus-summary-limit articles)
6016 (gnus-summary-position-point))))
6018 (defun gnus-summary-limit-include-thread (id)
6019 "Display all the hidden articles that in the current thread."
6020 (interactive (list (mail-header-id (gnus-summary-article-header))))
6021 (let ((articles (gnus-articles-in-thread
6022 (gnus-id-to-thread (gnus-root-id id)))))
6024 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6025 (gnus-summary-position-point))))
6027 (defun gnus-summary-limit-include-dormant ()
6028 "Display all the hidden articles that are marked as dormant.
6029 Note that this command only works on a subset of the articles currently
6030 fetched for this group."
6032 (unless gnus-newsgroup-dormant
6033 (error "There are no dormant articles in this group"))
6035 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6036 (gnus-summary-position-point)))
6038 (defun gnus-summary-limit-exclude-dormant ()
6039 "Hide all dormant articles."
6042 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6043 (gnus-summary-position-point)))
6045 (defun gnus-summary-limit-exclude-childless-dormant ()
6046 "Hide all dormant articles that have no children."
6048 (let ((data (gnus-data-list t))
6049 articles d children)
6050 ;; Find all articles that are either not dormant or have
6052 (while (setq d (pop data))
6053 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6055 (gnus-article-children (gnus-data-number d)))
6058 (when (memq (car children) articles)
6063 (push (gnus-data-number d) articles)))
6066 (gnus-summary-limit articles)
6067 (gnus-summary-position-point))))
6069 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6070 "Mark all unread excluded articles as read.
6071 If ALL, mark even excluded ticked and dormants as read."
6073 (let ((articles (gnus-sorted-complement
6075 (mapcar (lambda (h) (mail-header-number h))
6076 gnus-newsgroup-headers)
6078 (sort gnus-newsgroup-limit '<)))
6080 (setq gnus-newsgroup-unreads
6081 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6083 (setq gnus-newsgroup-dormant nil
6084 gnus-newsgroup-marked nil
6085 gnus-newsgroup-reads
6087 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6088 gnus-newsgroup-reads))
6089 (while (setq article (pop articles))
6090 (unless (or (memq article gnus-newsgroup-dormant)
6091 (memq article gnus-newsgroup-marked))
6092 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6094 (defun gnus-summary-limit (articles &optional pop)
6096 ;; We pop the previous limit off the stack and use that.
6097 (setq articles (car gnus-newsgroup-limits)
6098 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6099 ;; We use the new limit, so we push the old limit on the stack.
6100 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6102 (setq gnus-newsgroup-limit articles)
6103 (let ((total (length gnus-newsgroup-data))
6104 (data (gnus-data-find-list (gnus-summary-article-number)))
6105 (gnus-summary-mark-below nil) ; Inhibit this.
6107 ;; This will do all the work of generating the new summary buffer
6108 ;; according to the new limit.
6109 (gnus-summary-prepare)
6110 ;; Hide any threads, possibly.
6111 (and gnus-show-threads
6112 gnus-thread-hide-subtree
6113 (gnus-summary-hide-all-threads))
6114 ;; Try to return to the article you were at, or one in the
6117 ;; We try to find some article after the current one.
6119 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6122 (setq data (cdr data))))
6124 ;; If there is no data, that means that we were after the last
6125 ;; article. The same goes when we can't find any articles
6126 ;; after the current one.
6127 (goto-char (point-max))
6128 (gnus-summary-find-prev))
6129 ;; We return how many articles were removed from the summary
6130 ;; buffer as a result of the new limit.
6131 (- total (length gnus-newsgroup-data))))
6133 (defsubst gnus-invisible-cut-children (threads)
6136 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6141 (defsubst gnus-cut-thread (thread)
6142 "Go forwards in the thread until we find an article that we want to display."
6143 (when (or (eq gnus-fetch-old-headers 'some)
6144 (eq gnus-fetch-old-headers 'invisible)
6145 (eq gnus-build-sparse-threads 'some)
6146 (eq gnus-build-sparse-threads 'more))
6147 ;; Deal with old-fetched headers and sparse threads.
6151 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6152 (gnus-summary-article-ancient-p
6153 (mail-header-number (car thread))))
6154 (if (or (<= (length (cdr thread)) 1)
6155 (eq gnus-fetch-old-headers 'invisible))
6156 (setq gnus-newsgroup-limit
6157 (delq (mail-header-number (car thread))
6158 gnus-newsgroup-limit)
6159 thread (cadr thread))
6160 (when (gnus-invisible-cut-children (cdr thread))
6161 (let ((th (cdr thread)))
6163 (if (memq (mail-header-number (caar th))
6164 gnus-newsgroup-limit)
6165 (setq thread (car th)
6167 (setq th (cdr th))))))))))
6170 (defun gnus-cut-threads (threads)
6171 "Cut off all uninteresting articles from the beginning of threads."
6172 (when (or (eq gnus-fetch-old-headers 'some)
6173 (eq gnus-fetch-old-headers 'invisible)
6174 (eq gnus-build-sparse-threads 'some)
6175 (eq gnus-build-sparse-threads 'more))
6178 (setcar th (gnus-cut-thread (car th)))
6179 (setq th (cdr th)))))
6180 ;; Remove nixed out threads.
6183 (defun gnus-summary-initial-limit (&optional show-if-empty)
6184 "Figure out what the initial limit is supposed to be on group entry.
6185 This entails weeding out unwanted dormants, low-scored articles,
6186 fetch-old-headers verbiage, and so on."
6187 ;; Most groups have nothing to remove.
6188 (if (or gnus-inhibit-limiting
6189 (and (null gnus-newsgroup-dormant)
6190 (not (eq gnus-fetch-old-headers 'some))
6191 (not (eq gnus-fetch-old-headers 'invisible))
6192 (null gnus-summary-expunge-below)
6193 (not (eq gnus-build-sparse-threads 'some))
6194 (not (eq gnus-build-sparse-threads 'more))
6195 (null gnus-thread-expunge-below)
6196 (not gnus-use-nocem)))
6198 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6199 (setq gnus-newsgroup-limit nil)
6202 (unless (car (symbol-value node))
6203 ;; These threads have no parents -- they are roots.
6204 (let ((nodes (cdr (symbol-value node)))
6207 (if (and gnus-thread-expunge-below
6208 (< (gnus-thread-total-score (car nodes))
6209 gnus-thread-expunge-below))
6210 (gnus-expunge-thread (pop nodes))
6211 (setq thread (pop nodes))
6212 (gnus-summary-limit-children thread))))))
6213 gnus-newsgroup-dependencies)
6214 ;; If this limitation resulted in an empty group, we might
6215 ;; pop the previous limit and use it instead.
6216 (when (and (not gnus-newsgroup-limit)
6218 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6219 gnus-newsgroup-limit))
6221 (defun gnus-summary-limit-children (thread)
6222 "Return 1 if this subthread is visible and 0 if it is not."
6223 ;; First we get the number of visible children to this thread. This
6224 ;; is done by recursing down the thread using this function, so this
6225 ;; will really go down to a leaf article first, before slowly
6226 ;; working its way up towards the root.
6230 (apply '+ (mapcar 'gnus-summary-limit-children
6233 (number (mail-header-number (car thread)))
6236 (not (memq number gnus-newsgroup-marked))
6238 ;; If this article is dormant and has absolutely no visible
6239 ;; children, then this article isn't visible.
6240 (and (memq number gnus-newsgroup-dormant)
6242 ;; If this is "fetch-old-headered" and there is no
6243 ;; visible children, then we don't want this article.
6244 (and (eq gnus-fetch-old-headers 'some)
6245 (gnus-summary-article-ancient-p number)
6247 ;; If this is "fetch-old-headered" and `invisible', then
6248 ;; we don't want this article.
6249 (and (eq gnus-fetch-old-headers 'invisible)
6250 (gnus-summary-article-ancient-p number))
6251 ;; If this is a sparsely inserted article with no children,
6252 ;; we don't want it.
6253 (and (eq gnus-build-sparse-threads 'some)
6254 (gnus-summary-article-sparse-p number)
6256 ;; If we use expunging, and this article is really
6257 ;; low-scored, then we don't want this article.
6258 (when (and gnus-summary-expunge-below
6260 (or (cdr (assq number gnus-newsgroup-scored))
6261 gnus-summary-default-score))
6262 gnus-summary-expunge-below))
6263 ;; We increase the expunge-tally here, but that has
6264 ;; nothing to do with the limits, really.
6265 (incf gnus-newsgroup-expunged-tally)
6266 ;; We also mark as read here, if that's wanted.
6267 (when (and gnus-summary-mark-below
6268 (< score gnus-summary-mark-below))
6269 (setq gnus-newsgroup-unreads
6270 (delq number gnus-newsgroup-unreads))
6271 (if gnus-newsgroup-auto-expire
6272 (push number gnus-newsgroup-expirable)
6273 (push (cons number gnus-low-score-mark)
6274 gnus-newsgroup-reads)))
6276 ;; Check NoCeM things.
6277 (if (and gnus-use-nocem
6278 (gnus-nocem-unwanted-article-p
6279 (mail-header-id (car thread))))
6281 (setq gnus-newsgroup-unreads
6282 (delq number gnus-newsgroup-unreads))
6284 ;; Nope, invisible article.
6286 ;; Ok, this article is to be visible, so we add it to the limit
6288 (push number gnus-newsgroup-limit)
6291 (defun gnus-expunge-thread (thread)
6292 "Mark all articles in THREAD as read."
6293 (let* ((number (mail-header-number (car thread))))
6294 (incf gnus-newsgroup-expunged-tally)
6295 ;; We also mark as read here, if that's wanted.
6296 (setq gnus-newsgroup-unreads
6297 (delq number gnus-newsgroup-unreads))
6298 (if gnus-newsgroup-auto-expire
6299 (push number gnus-newsgroup-expirable)
6300 (push (cons number gnus-low-score-mark)
6301 gnus-newsgroup-reads)))
6302 ;; Go recursively through all subthreads.
6303 (mapcar 'gnus-expunge-thread (cdr thread)))
6305 ;; Summary article oriented commands
6307 (defun gnus-summary-refer-parent-article (n)
6308 "Refer parent article N times.
6309 If N is negative, go to ancestor -N instead.
6310 The difference between N and the number of articles fetched is returned."
6314 (when (not (natnump n))
6319 (setq header (gnus-summary-article-header))
6320 (if (and (eq (mail-header-number header)
6321 (cdr gnus-article-current))
6322 (equal gnus-newsgroup-name
6323 (car gnus-article-current)))
6324 ;; If we try to find the parent of the currently
6325 ;; displayed article, then we take a look at the actual
6326 ;; References header, since this is slightly more
6327 ;; reliable than the References field we got from the
6330 (set-buffer gnus-original-article-buffer)
6331 (nnheader-narrow-to-headers)
6332 (unless (setq ref (message-fetch-field "references"))
6333 (setq ref (message-fetch-field "in-reply-to")))
6336 ;; It's not the current article, so we take a bet on
6337 ;; the value we got from the server.
6338 (mail-header-references header)))
6340 (not (equal ref "")))
6341 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6342 (gnus-message 1 "Couldn't find parent"))
6343 (gnus-message 1 "No references in article %d"
6344 (gnus-summary-article-number))
6347 (gnus-summary-position-point)
6350 (defun gnus-summary-refer-references ()
6351 "Fetch all articles mentioned in the References header.
6352 Return the number of articles fetched."
6354 (let ((ref (mail-header-references (gnus-summary-article-header)))
6355 (current (gnus-summary-article-number))
6359 (error "No References in the current article")
6360 ;; For each Message-ID in the References header...
6361 (while (string-match "<[^>]*>" ref)
6363 ;; ... fetch that article.
6364 (gnus-summary-refer-article
6365 (prog1 (match-string 0 ref)
6366 (setq ref (substring ref (match-end 0))))))
6367 (gnus-summary-goto-subject current)
6368 (gnus-summary-position-point)
6371 (defun gnus-summary-refer-thread (&optional limit)
6372 "Fetch all articles in the current thread.
6373 If LIMIT (the numerical prefix), fetch that many old headers instead
6374 of what's specified by the `gnus-refer-thread-limit' variable."
6376 (let ((id (mail-header-id (gnus-summary-article-header)))
6377 (limit (if limit (prefix-numeric-value limit)
6378 gnus-refer-thread-limit))
6380 ;; We want to fetch LIMIT *old* headers, but we also have to
6381 ;; re-fetch all the headers in the current buffer, because many of
6382 ;; them may be undisplayed. So we adjust LIMIT.
6383 (when (numberp limit)
6384 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6385 (unless (eq gnus-fetch-old-headers 'invisible)
6386 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6387 ;; Retrieve the headers and read them in.
6388 (if (eq (gnus-retrieve-headers
6389 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6391 (gnus-build-all-threads)
6392 (error "Can't fetch thread from backends that don't support NOV"))
6393 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6394 (gnus-summary-limit-include-thread id)))
6396 (defun gnus-summary-refer-article (message-id &optional arg)
6397 "Fetch an article specified by MESSAGE-ID.
6398 If ARG (the prefix), fetch the article using `gnus-refer-article-method'
6399 or `gnus-select-method', no matter what backend the article comes from."
6400 (interactive "sMessage-ID: \nP")
6401 (when (and (stringp message-id)
6402 (not (zerop (length message-id))))
6403 ;; Construct the correct Message-ID if necessary.
6404 ;; Suggested by tale@pawl.rpi.edu.
6405 (unless (string-match "^<" message-id)
6406 (setq message-id (concat "<" message-id)))
6407 (unless (string-match ">$" message-id)
6408 (setq message-id (concat message-id ">")))
6409 (let* ((header (gnus-id-to-header message-id))
6411 (gnus-summary-article-sparse-p
6412 (mail-header-number header))
6413 (memq (mail-header-number header)
6414 gnus-newsgroup-limit)))
6417 ;; If the article is present in the buffer we just go to it.
6419 (or (not (gnus-summary-article-sparse-p
6420 (mail-header-number header)))
6423 (gnus-summary-goto-article
6424 (mail-header-number header) nil t)
6426 (gnus-summary-update-article (mail-header-number header)))))
6428 ;; We fetch the article
6429 (let ((gnus-override-method
6430 (cond ((gnus-news-group-p gnus-newsgroup-name)
6431 gnus-refer-article-method)
6433 (or gnus-refer-article-method gnus-select-method))
6436 ;; Start the special refer-article method, if necessary.
6437 (when (and gnus-refer-article-method
6438 (gnus-news-group-p gnus-newsgroup-name))
6439 (gnus-check-server gnus-refer-article-method))
6440 ;; Fetch the header, and display the article.
6441 (if (setq number (gnus-summary-insert-subject message-id))
6442 (gnus-summary-select-article nil nil nil number)
6443 (gnus-message 3 "Couldn't fetch article %s" message-id))))))))
6445 (defun gnus-summary-edit-parameters ()
6446 "Edit the group parameters of the current group."
6448 (gnus-group-edit-group gnus-newsgroup-name 'params))
6450 (defun gnus-summary-enter-digest-group (&optional force)
6451 "Enter an nndoc group based on the current article.
6452 If FORCE, force a digest interpretation. If not, try
6453 to guess what the document format is."
6455 (let ((conf gnus-current-window-configuration))
6457 (gnus-summary-select-article))
6458 (setq gnus-current-window-configuration conf)
6459 (let* ((name (format "%s-%d"
6460 (gnus-group-prefixed-name
6461 gnus-newsgroup-name (list 'nndoc ""))
6463 (set-buffer gnus-summary-buffer)
6464 gnus-current-article)))
6465 (ogroup gnus-newsgroup-name)
6466 (params (append (gnus-info-params (gnus-get-info ogroup))
6467 (list (cons 'to-group ogroup))
6468 (list (cons 'save-article-group ogroup))))
6469 (case-fold-search t)
6470 (buf (current-buffer))
6473 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6474 (insert-buffer-substring gnus-original-article-buffer)
6475 ;; Remove lines that may lead nndoc to misinterpret the
6478 (goto-char (point-min))
6479 (or (search-forward "\n\n" nil t) (point)))
6480 (goto-char (point-min))
6481 (delete-matching-lines "^\\(Path\\):\\|^From ")
6484 (if (gnus-group-read-ephemeral-group
6485 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6487 ,(if force 'digest 'guess))) t)
6488 ;; Make all postings to this group go to the parent group.
6489 (nconc (gnus-info-params (gnus-get-info name))
6491 ;; Couldn't select this doc group.
6492 (switch-to-buffer buf)
6493 (gnus-set-global-variables)
6494 (gnus-configure-windows 'summary)
6495 (gnus-message 3 "Article couldn't be entered?"))
6496 (kill-buffer dig)))))
6498 (defun gnus-summary-read-document (n)
6499 "Open a new group based on the current article(s).
6500 This will allow you to read digests and other similar
6501 documents as newsgroups.
6502 Obeys the standard process/prefix convention."
6504 (let* ((articles (gnus-summary-work-articles n))
6505 (ogroup gnus-newsgroup-name)
6506 (params (append (gnus-info-params (gnus-get-info ogroup))
6507 (list (cons 'to-group ogroup))))
6508 article group egroup groups vgroup)
6509 (while (setq article (pop articles))
6510 (setq group (format "%s-%d" gnus-newsgroup-name article))
6511 (gnus-summary-remove-process-mark article)
6512 (when (gnus-summary-display-article article)
6514 (nnheader-temp-write nil
6515 (insert-buffer-substring gnus-original-article-buffer)
6516 ;; Remove some headers that may lead nndoc to make
6518 (message-narrow-to-head)
6519 (goto-char (point-min))
6520 (delete-matching-lines "^\\(Path\\):\\|^From ")
6523 (gnus-group-read-ephemeral-group
6524 group `(nndoc ,group (nndoc-address ,(current-buffer))
6525 (nndoc-article-type guess))
6528 ;; Make all postings to this group go to the parent group.
6529 (nconc (gnus-info-params (gnus-get-info egroup))
6531 (push egroup groups))
6532 ;; Couldn't select this doc group.
6533 (gnus-error 3 "Article couldn't be entered"))))))
6534 ;; Now we have selected all the documents.
6537 (error "None of the articles could be interpreted as documents"))
6538 ((gnus-group-read-ephemeral-group
6539 (setq vgroup (format
6540 "nnvirtual:%s-%s" gnus-newsgroup-name
6541 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6542 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6544 (cons (current-buffer) 'summary)))
6546 (error "Couldn't select virtual nndoc group")))))
6548 (defun gnus-summary-isearch-article (&optional regexp-p)
6549 "Do incremental search forward on the current article.
6550 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6552 (gnus-summary-select-article)
6553 (gnus-configure-windows 'article)
6554 (gnus-eval-in-buffer-window gnus-article-buffer
6557 (isearch-forward regexp-p))))
6559 (defun gnus-summary-search-article-forward (regexp &optional backward)
6560 "Search for an article containing REGEXP forward.
6561 If BACKWARD, search backward instead."
6564 (format "Search article %s (regexp%s): "
6565 (if current-prefix-arg "backward" "forward")
6566 (if gnus-last-search-regexp
6567 (concat ", default " gnus-last-search-regexp)
6569 current-prefix-arg))
6570 (if (string-equal regexp "")
6571 (setq regexp (or gnus-last-search-regexp ""))
6572 (setq gnus-last-search-regexp regexp))
6573 (if (gnus-summary-search-article regexp backward)
6574 (gnus-summary-show-thread)
6575 (error "Search failed: \"%s\"" regexp)))
6577 (defun gnus-summary-search-article-backward (regexp)
6578 "Search for an article containing REGEXP backward."
6581 (format "Search article backward (regexp%s): "
6582 (if gnus-last-search-regexp
6583 (concat ", default " gnus-last-search-regexp)
6585 (gnus-summary-search-article-forward regexp 'backward))
6587 (defun gnus-summary-search-article (regexp &optional backward)
6588 "Search for an article containing REGEXP.
6589 Optional argument BACKWARD means do search for backward.
6590 `gnus-select-article-hook' is not called during the search."
6591 ;; We have to require this here to make sure that the following
6592 ;; dynamic binding isn't shadowed by autoloading.
6593 (require 'gnus-async)
6594 (let ((gnus-select-article-hook nil) ;Disable hook.
6595 (gnus-article-display-hook nil)
6596 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6597 (gnus-use-article-prefetch nil)
6598 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
6599 (gnus-use-trees nil) ;Inhibit updating tree buffer.
6600 (sum (current-buffer))
6603 (gnus-save-hidden-threads
6604 (gnus-summary-select-article)
6605 (set-buffer gnus-article-buffer)
6609 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
6611 (re-search-backward regexp nil t)
6612 (re-search-forward regexp nil t))
6613 ;; We found the regexp.
6618 (get-buffer-window (current-buffer))
6622 (setq point (point)))
6623 ;; We didn't find it, so we go to the next article.
6626 (while (eq found 'not)
6627 (if (not (if backward (gnus-summary-find-prev)
6628 (gnus-summary-find-next)))
6629 ;; No more articles.
6631 ;; Select the next article and adjust point.
6632 (unless (gnus-summary-article-sparse-p
6633 (gnus-summary-article-number))
6635 (gnus-summary-select-article)
6636 (set-buffer gnus-article-buffer)
6638 (goto-char (if backward (point-max) (point-min))))))))
6639 (gnus-message 7 ""))
6640 ;; Return whether we found the regexp.
6641 (when (eq found 'found)
6643 (gnus-summary-show-thread)
6644 (gnus-summary-goto-subject gnus-current-article)
6645 (gnus-summary-position-point)
6648 (defun gnus-summary-find-matching (header regexp &optional backward unread
6650 "Return a list of all articles that match REGEXP on HEADER.
6651 The search stars on the current article and goes forwards unless
6652 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
6653 If UNREAD is non-nil, only unread articles will
6654 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
6655 in the comparisons."
6656 (let ((data (if (eq backward 'all) gnus-newsgroup-data
6657 (gnus-data-find-list
6658 (gnus-summary-article-number) (gnus-data-list backward))))
6659 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
6660 (case-fold-search (not not-case-fold))
6662 (unless (fboundp (intern (concat "mail-header-" header)))
6663 (error "%s is not a valid header" header))
6666 (and (or (not unread) ; We want all articles...
6667 (gnus-data-unread-p d)) ; Or just unreads.
6668 (vectorp (gnus-data-header d)) ; It's not a pseudo.
6669 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
6670 (push (gnus-data-number d) articles)) ; Success!
6671 (setq data (cdr data)))
6672 (nreverse articles)))
6674 (defun gnus-summary-execute-command (header regexp command &optional backward)
6675 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
6676 If HEADER is an empty string (or nil), the match is done on the entire
6677 article. If BACKWARD (the prefix) is non-nil, search backward instead."
6679 (list (let ((completion-ignore-case t))
6682 (mapcar (lambda (string) (list string))
6683 '("Number" "Subject" "From" "Lines" "Date"
6684 "Message-ID" "Xref" "References" "Body"))
6685 nil 'require-match))
6686 (read-string "Regexp: ")
6687 (read-key-sequence "Command: ")
6688 current-prefix-arg))
6689 (when (equal header "Body")
6691 ;; Hidden thread subtrees must be searched as well.
6692 (gnus-summary-show-all-threads)
6693 ;; We don't want to change current point nor window configuration.
6695 (save-window-excursion
6696 (gnus-message 6 "Executing %s..." (key-description command))
6697 ;; We'd like to execute COMMAND interactively so as to give arguments.
6698 (gnus-execute header regexp
6699 `(call-interactively ',(key-binding command))
6701 (gnus-message 6 "Executing %s...done" (key-description command)))))
6703 (defun gnus-summary-beginning-of-article ()
6704 "Scroll the article back to the beginning."
6706 (gnus-summary-select-article)
6707 (gnus-configure-windows 'article)
6708 (gnus-eval-in-buffer-window gnus-article-buffer
6710 (goto-char (point-min))
6711 (when gnus-page-broken
6712 (gnus-narrow-to-page))))
6714 (defun gnus-summary-end-of-article ()
6715 "Scroll to the end of the article."
6717 (gnus-summary-select-article)
6718 (gnus-configure-windows 'article)
6719 (gnus-eval-in-buffer-window gnus-article-buffer
6721 (goto-char (point-max))
6723 (when gnus-page-broken
6724 (gnus-narrow-to-page))))
6726 (defun gnus-summary-print-article (&optional filename n)
6727 "Generate and print a PostScript image of the N next (mail) articles.
6729 If N is negative, print the N previous articles. If N is nil and articles
6730 have been marked with the process mark, print these instead.
6732 If the optional second argument FILENAME is nil, send the image to the
6733 printer. If FILENAME is a string, save the PostScript image in a file with
6734 that name. If FILENAME is a number, prompt the user for the name of the file
6736 (interactive (list (ps-print-preprint current-prefix-arg)
6737 current-prefix-arg))
6738 (dolist (article (gnus-summary-work-articles n))
6739 (gnus-summary-select-article nil nil 'pseudo article)
6740 (gnus-eval-in-buffer-window gnus-article-buffer
6741 (let ((buffer (generate-new-buffer " *print*")))
6744 (copy-to-buffer buffer (point-min) (point-max))
6746 (gnus-article-delete-invisible-text)
6747 (let ((ps-left-header
6750 (mail-header-subject gnus-current-headers) ")")
6752 (mail-header-from gnus-current-headers) ")")))
6755 "/pagenumberstring load"
6757 (mail-header-date gnus-current-headers) ")"))))
6758 (gnus-run-hooks 'gnus-ps-print-hook)
6760 (ps-print-buffer-with-faces filename))))
6761 (kill-buffer buffer))))))
6763 (defun gnus-summary-show-article (&optional arg)
6764 "Force re-fetching of the current article.
6765 If ARG (the prefix) is non-nil, show the raw article without any
6766 article massaging functions being run."
6769 ;; Select the article the normal way.
6770 (gnus-summary-select-article nil 'force)
6771 ;; Bind the article treatment functions to nil.
6772 (let ((gnus-have-all-headers t)
6773 gnus-article-display-hook
6774 gnus-article-prepare-hook
6778 (gnus-summary-select-article nil 'force)))
6779 (gnus-summary-goto-subject gnus-current-article)
6780 (gnus-summary-position-point))
6782 (defun gnus-summary-verbose-headers (&optional arg)
6783 "Toggle permanent full header display.
6784 If ARG is a positive number, turn header display on.
6785 If ARG is a negative number, turn header display off."
6787 (setq gnus-show-all-headers
6788 (cond ((or (not (numberp arg))
6790 (not gnus-show-all-headers))
6793 (gnus-summary-show-article))
6795 (defun gnus-summary-toggle-header (&optional arg)
6796 "Show the headers if they are hidden, or hide them if they are shown.
6797 If ARG is a positive number, show the entire header.
6798 If ARG is a negative number, hide the unwanted header lines."
6801 (set-buffer gnus-article-buffer)
6802 (let* ((buffer-read-only nil)
6803 (inhibit-point-motion-hooks t)
6804 (hidden (text-property-any
6805 (goto-char (point-min)) (search-forward "\n\n")
6808 (goto-char (point-min))
6809 (when (search-forward "\n\n" nil t)
6810 (delete-region (point-min) (1- (point))))
6811 (goto-char (point-min))
6813 (set-buffer gnus-original-article-buffer)
6814 (goto-char (point-min))
6815 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
6816 (insert-buffer-substring gnus-original-article-buffer 1 e)
6817 (let ((article-inhibit-hiding t))
6818 (gnus-run-hooks 'gnus-article-display-hook))
6819 (when (or (not hidden) (and (numberp arg) (< arg 0)))
6820 (gnus-article-hide-headers)))))
6822 (defun gnus-summary-show-all-headers ()
6823 "Make all header lines visible."
6825 (gnus-article-show-all-headers))
6827 (defun gnus-summary-toggle-mime (&optional arg)
6828 "Toggle MIME processing.
6829 If ARG is a positive number, turn MIME processing on."
6831 (setq gnus-show-mime
6832 (if (null arg) (not gnus-show-mime)
6833 (> (prefix-numeric-value arg) 0)))
6834 (gnus-summary-select-article t 'force))
6836 (defun gnus-summary-caesar-message (&optional arg)
6837 "Caesar rotate the current article by 13.
6838 The numerical prefix specifies how many places to rotate each letter
6841 (gnus-summary-select-article)
6842 (let ((mail-header-separator ""))
6843 (gnus-eval-in-buffer-window gnus-article-buffer
6846 (let ((start (window-start))
6848 (message-caesar-buffer-body arg)
6849 (set-window-start (get-buffer-window (current-buffer)) start))))))
6851 (defun gnus-summary-stop-page-breaking ()
6852 "Stop page breaking in the current article."
6854 (gnus-summary-select-article)
6855 (gnus-eval-in-buffer-window gnus-article-buffer
6857 (when (gnus-visual-p 'page-marker)
6858 (let ((buffer-read-only nil))
6859 (gnus-remove-text-with-property 'gnus-prev)
6860 (gnus-remove-text-with-property 'gnus-next))
6861 (setq gnus-page-broken nil))))
6863 (defun gnus-summary-move-article (&optional n to-newsgroup
6864 select-method action)
6865 "Move the current article to a different newsgroup.
6866 If N is a positive number, move the N next articles.
6867 If N is a negative number, move the N previous articles.
6868 If N is nil and any articles have been marked with the process mark,
6869 move those articles instead.
6870 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6871 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6872 re-spool using this method.
6874 For this function to work, both the current newsgroup and the
6875 newsgroup that you want to move to have to support the `request-move'
6876 and `request-accept' functions."
6879 (setq action 'move))
6880 ;; Disable marking as read.
6881 (let (gnus-mark-article-hook)
6882 (save-window-excursion
6883 (gnus-summary-select-article)))
6884 ;; Check whether the source group supports the required functions.
6885 (cond ((and (eq action 'move)
6886 (not (gnus-check-backend-function
6887 'request-move-article gnus-newsgroup-name)))
6888 (error "The current group does not support article moving"))
6889 ((and (eq action 'crosspost)
6890 (not (gnus-check-backend-function
6891 'request-replace-article gnus-newsgroup-name)))
6892 (error "The current group does not support article editing")))
6893 (let ((articles (gnus-summary-work-articles n))
6894 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
6895 (names '((move "Move" "Moving")
6896 (copy "Copy" "Copying")
6897 (crosspost "Crosspost" "Crossposting")))
6898 (copy-buf (save-excursion
6899 (nnheader-set-temp-buffer " *copy article*")))
6900 art-group to-method new-xref article to-groups)
6901 (unless (assq action names)
6902 (error "Unknown action %s" action))
6903 ;; Read the newsgroup name.
6904 (when (and (not to-newsgroup)
6905 (not select-method))
6907 (gnus-read-move-group-name
6908 (cadr (assq action names))
6909 (symbol-value (intern (format "gnus-current-%s-group" action)))
6911 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
6912 (setq to-method (or select-method
6913 (gnus-group-name-to-method to-newsgroup)))
6914 ;; Check the method we are to move this article to...
6915 (unless (gnus-check-backend-function
6916 'request-accept-article (car to-method))
6917 (error "%s does not support article copying" (car to-method)))
6918 (unless (gnus-check-server to-method)
6919 (error "Can't open server %s" (car to-method)))
6920 (gnus-message 6 "%s to %s: %s..."
6921 (caddr (assq action names))
6922 (or (car select-method) to-newsgroup) articles)
6924 (setq article (pop articles))
6928 ;; Move the article.
6930 ;; Remove this article from future suppression.
6931 (gnus-dup-unsuppress-article article)
6932 (gnus-request-move-article
6933 article ; Article to move
6934 gnus-newsgroup-name ; From newsgroup
6935 (nth 1 (gnus-find-method-for-group
6936 gnus-newsgroup-name)) ; Server
6937 (list 'gnus-request-accept-article
6938 to-newsgroup (list 'quote select-method)
6939 (not articles)) ; Accept form
6940 (not articles))) ; Only save nov last time
6941 ;; Copy the article.
6944 (set-buffer copy-buf)
6945 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
6946 (gnus-request-accept-article
6947 to-newsgroup select-method (not articles)))))
6948 ;; Crosspost the article.
6949 ((eq action 'crosspost)
6950 (let ((xref (message-tokenize-header
6951 (mail-header-xref (gnus-summary-article-header article))
6953 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
6956 (setq xref (list (system-name))))
6959 (mapconcat 'identity
6960 (delete "Xref:" (delete new-xref xref))
6964 (set-buffer copy-buf)
6965 ;; First put the article in the destination group.
6966 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6967 (when (consp (setq art-group
6968 (gnus-request-accept-article
6969 to-newsgroup select-method (not articles))))
6970 (setq new-xref (concat new-xref " " (car art-group)
6971 ":" (cdr art-group)))
6972 ;; Now we have the new Xrefs header, so we insert
6973 ;; it and replace the new article.
6974 (nnheader-replace-header "Xref" new-xref)
6975 (gnus-request-replace-article
6976 (cdr art-group) to-newsgroup (current-buffer))
6980 (gnus-message 1 "Couldn't %s article %s"
6981 (cadr (assq action names)) article))
6982 ((and (eq art-group 'junk)
6984 (gnus-summary-mark-article article gnus-canceled-mark)
6985 (gnus-message 4 "Deleted article %s" article))
6989 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
6991 (gnus-group-prefixed-name
6994 (gnus-find-method-for-group to-newsgroup)))
6995 gnus-newsrc-hashtb)))
6996 (info (nth 2 entry))
6997 (to-group (gnus-info-group info)))
6998 ;; Update the group that has been moved to.
7000 (memq action '(move copy)))
7001 (unless (member to-group to-groups)
7002 (push to-group to-groups))
7004 (unless (memq article gnus-newsgroup-unreads)
7006 info (gnus-add-to-range (gnus-info-read info)
7007 (list (cdr art-group)))))
7009 ;; Copy any marks over to the new group.
7010 (let ((marks gnus-article-mark-lists)
7011 (to-article (cdr art-group)))
7013 ;; See whether the article is to be put in the cache.
7014 (when gnus-use-cache
7015 (gnus-cache-possibly-enter-article
7017 (let ((header (copy-sequence
7018 (gnus-summary-article-header article))))
7019 (mail-header-set-number header to-article)
7021 (memq article gnus-newsgroup-marked)
7022 (memq article gnus-newsgroup-dormant)
7023 (memq article gnus-newsgroup-unreads)))
7025 (when (and (equal to-group gnus-newsgroup-name)
7026 (not (memq article gnus-newsgroup-unreads)))
7027 ;; Mark this article as read in this group.
7028 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7029 (setcdr (gnus-active to-group) to-article)
7030 (setcdr gnus-newsgroup-active to-article))
7033 (when (memq article (symbol-value
7034 (intern (format "gnus-newsgroup-%s"
7036 ;; If the other group is the same as this group,
7037 ;; then we have to add the mark to the list.
7038 (when (equal to-group gnus-newsgroup-name)
7039 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7042 (intern (format "gnus-newsgroup-%s"
7044 ;; Copy the marks to other group.
7045 (gnus-add-marked-articles
7046 to-group (cdar marks) (list to-article) info))
7047 (setq marks (cdr marks)))
7050 (concat "(gnus-group-set-info '"
7051 (gnus-prin1-to-string (gnus-get-info to-group))
7054 ;; Update the Xref header in this article to point to
7055 ;; the new crossposted article we have just created.
7056 (when (eq action 'crosspost)
7058 (set-buffer copy-buf)
7059 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7060 (nnheader-replace-header "Xref" new-xref)
7061 (gnus-request-replace-article
7062 article gnus-newsgroup-name (current-buffer)))))
7064 ;;;!!!Why is this necessary?
7065 (set-buffer gnus-summary-buffer)
7067 (gnus-summary-goto-subject article)
7068 (when (eq action 'move)
7069 (gnus-summary-mark-article article gnus-canceled-mark))))
7070 (gnus-summary-remove-process-mark article))
7071 ;; Re-activate all groups that have been moved to.
7074 (set-buffer gnus-group-buffer)
7075 (when (gnus-group-goto-group (car to-groups) t)
7076 (gnus-group-get-new-news-this-group 1 t))
7079 (gnus-kill-buffer copy-buf)
7080 (gnus-summary-position-point)
7081 (gnus-set-mode-line 'summary)))
7083 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7084 "Move the current article to a different newsgroup.
7085 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7086 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7087 re-spool using this method."
7089 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7091 (defun gnus-summary-crosspost-article (&optional n)
7092 "Crosspost the current article to some other group."
7094 (gnus-summary-move-article n nil nil 'crosspost))
7096 (defcustom gnus-summary-respool-default-method nil
7097 "Default method for respooling an article.
7098 If nil, use to the current newsgroup method."
7099 :type `(choice (gnus-select-method :value (nnml ""))
7101 :group 'gnus-summary-mail)
7103 (defun gnus-summary-respool-article (&optional n method)
7104 "Respool the current article.
7105 The article will be squeezed through the mail spooling process again,
7106 which means that it will be put in some mail newsgroup or other
7107 depending on `nnmail-split-methods'.
7108 If N is a positive number, respool the N next articles.
7109 If N is a negative number, respool the N previous articles.
7110 If N is nil and any articles have been marked with the process mark,
7111 respool those articles instead.
7113 Respooling can be done both from mail groups and \"real\" newsgroups.
7114 In the former case, the articles in question will be moved from the
7115 current group into whatever groups they are destined to. In the
7116 latter case, they will be copied into the relevant groups."
7118 (list current-prefix-arg
7119 (let* ((methods (gnus-methods-using 'respool))
7121 (symbol-name (or gnus-summary-respool-default-method
7122 (car (gnus-find-method-for-group
7123 gnus-newsgroup-name)))))
7125 (gnus-completing-read
7126 methname "What backend do you want to use when respooling?"
7127 methods nil t nil 'gnus-mail-method-history))
7130 ((zerop (length (setq ms (gnus-servers-using-backend
7132 (list (intern method) ""))
7136 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7137 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7140 (error "No method given for respooling"))
7141 (if (assoc (symbol-name
7142 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7143 (gnus-methods-using 'respool))
7144 (gnus-summary-move-article n nil method)
7145 (gnus-summary-copy-article n nil method)))
7147 (defun gnus-summary-import-article (file)
7148 "Import an arbitrary file into a mail newsgroup."
7149 (interactive "fImport file: ")
7150 (let ((group gnus-newsgroup-name)
7151 (now (current-time))
7153 (unless (gnus-check-backend-function 'request-accept-article group)
7154 (error "%s does not support article importing" group))
7155 (or (file-readable-p file)
7156 (not (file-regular-p file))
7157 (error "Can't read %s" file))
7159 (set-buffer (get-buffer-create " *import file*"))
7160 (buffer-disable-undo (current-buffer))
7162 (nnheader-insert-file-contents file)
7163 (goto-char (point-min))
7164 (unless (nnheader-article-p)
7165 ;; This doesn't look like an article, so we fudge some headers.
7166 (setq atts (file-attributes file)
7167 lines (count-lines (point-min) (point-max)))
7168 (insert "From: " (read-string "From: ") "\n"
7169 "Subject: " (read-string "Subject: ") "\n"
7170 "Date: " (timezone-make-date-arpa-standard
7171 (current-time-string (nth 5 atts))
7172 (current-time-zone now)
7173 (current-time-zone now))
7175 "Message-ID: " (message-make-message-id) "\n"
7176 "Lines: " (int-to-string lines) "\n"
7177 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7178 (gnus-request-accept-article group nil t)
7179 (kill-buffer (current-buffer)))))
7181 (defun gnus-summary-article-posted-p ()
7182 "Say whether the current (mail) article is available from `gnus-select-method' as well.
7183 This will be the case if the article has both been mailed and posted."
7185 (let ((id (mail-header-references (gnus-summary-article-header)))
7186 (gnus-override-method
7187 (or gnus-refer-article-method gnus-select-method)))
7188 (if (gnus-request-head id "")
7189 (gnus-message 2 "The current message was found on %s"
7190 gnus-override-method)
7191 (gnus-message 2 "The current message couldn't be found on %s"
7192 gnus-override-method)
7195 (defun gnus-summary-expire-articles (&optional now)
7196 "Expire all articles that are marked as expirable in the current group."
7198 (when (gnus-check-backend-function
7199 'request-expire-articles gnus-newsgroup-name)
7200 ;; This backend supports expiry.
7201 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7202 (expirable (if total
7204 ;; We need to update the info for
7205 ;; this group for `gnus-list-of-read-articles'
7206 ;; to give us the right answer.
7207 (gnus-run-hooks 'gnus-exit-group-hook)
7208 (gnus-summary-update-info)
7209 (gnus-list-of-read-articles gnus-newsgroup-name))
7210 (setq gnus-newsgroup-expirable
7211 (sort gnus-newsgroup-expirable '<))))
7212 (expiry-wait (if now 'immediate
7213 (gnus-group-find-parameter
7214 gnus-newsgroup-name 'expiry-wait)))
7217 ;; There are expirable articles in this group, so we run them
7218 ;; through the expiry process.
7219 (gnus-message 6 "Expiring articles...")
7220 ;; The list of articles that weren't expired is returned.
7223 (let ((nnmail-expiry-wait-function nil)
7224 (nnmail-expiry-wait expiry-wait))
7225 (setq es (gnus-request-expire-articles
7226 expirable gnus-newsgroup-name)))
7227 (setq es (gnus-request-expire-articles
7228 expirable gnus-newsgroup-name))))
7230 (setq gnus-newsgroup-expirable es))
7231 ;; We go through the old list of expirable, and mark all
7232 ;; really expired articles as nonexistent.
7233 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7234 (let ((gnus-use-cache nil))
7236 (unless (memq (car expirable) es)
7237 (when (gnus-data-find (car expirable))
7238 (gnus-summary-mark-article
7239 (car expirable) gnus-canceled-mark)))
7240 (setq expirable (cdr expirable)))))
7241 (gnus-message 6 "Expiring articles...done")))))
7243 (defun gnus-summary-expire-articles-now ()
7244 "Expunge all expirable articles in the current group.
7245 This means that *all* articles that are marked as expirable will be
7246 deleted forever, right now."
7248 (or gnus-expert-user
7250 "Are you really, really, really sure you want to delete all these messages? ")
7252 (gnus-summary-expire-articles t))
7254 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7255 (defun gnus-summary-delete-article (&optional n)
7256 "Delete the N next (mail) articles.
7257 This command actually deletes articles. This is not a marking
7258 command. The article will disappear forever from your life, never to
7260 If N is negative, delete backwards.
7261 If N is nil and articles have been marked with the process mark,
7262 delete these instead."
7264 (unless (gnus-check-backend-function 'request-expire-articles
7265 gnus-newsgroup-name)
7266 (error "The current newsgroup does not support article deletion"))
7267 ;; Compute the list of articles to delete.
7268 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
7270 (if (and gnus-novice-user
7271 (not (gnus-yes-or-no-p
7272 (format "Do you really want to delete %s forever? "
7273 (if (> (length articles) 1)
7274 (format "these %s articles" (length articles))
7277 ;; Delete the articles.
7278 (setq not-deleted (gnus-request-expire-articles
7279 articles gnus-newsgroup-name 'force))
7281 (gnus-summary-remove-process-mark (car articles))
7282 ;; The backend might not have been able to delete the article
7284 (unless (memq (car articles) not-deleted)
7285 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7286 (setq articles (cdr articles)))
7288 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7289 (gnus-summary-position-point)
7290 (gnus-set-mode-line 'summary)
7293 (defun gnus-summary-edit-article (&optional force)
7294 "Edit the current article.
7295 This will have permanent effect only in mail groups.
7296 If FORCE is non-nil, allow editing of articles even in read-only
7300 (set-buffer gnus-summary-buffer)
7301 (gnus-set-global-variables)
7302 (when (and (not force)
7303 (gnus-group-read-only-p))
7304 (error "The current newsgroup does not support article editing"))
7305 ;; Select article if needed.
7306 (unless (eq (gnus-summary-article-number)
7307 gnus-current-article)
7308 (gnus-summary-select-article t))
7309 (gnus-article-date-original)
7310 (gnus-article-edit-article
7311 `(lambda (no-highlight)
7312 (gnus-summary-edit-article-done
7313 ,(or (mail-header-references gnus-current-headers) "")
7314 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))
7316 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7318 (defun gnus-summary-edit-article-done (&optional references read-only buffer
7320 "Make edits to the current article permanent."
7322 ;; Replace the article.
7323 (let ((buf (current-buffer)))
7324 (nnheader-temp-write nil
7326 (if (and (not read-only)
7327 (not (gnus-request-replace-article
7328 (cdr gnus-article-current) (car gnus-article-current)
7330 (error "Couldn't replace article")
7331 ;; Update the summary buffer.
7333 (equal (message-tokenize-header references " ")
7334 (message-tokenize-header
7335 (or (message-fetch-field "references") "") " ")))
7336 ;; We only have to update this line.
7339 (message-narrow-to-head)
7340 (let ((head (buffer-string))
7342 (nnheader-temp-write nil
7343 (insert (format "211 %d Article retrieved.\n"
7344 (cdr gnus-article-current)))
7347 (let ((nntp-server-buffer (current-buffer)))
7348 (setq header (car (gnus-get-newsgroup-headers
7350 (set-buffer gnus-summary-buffer)
7351 gnus-newsgroup-dependencies)
7354 (set-buffer gnus-summary-buffer)
7355 (gnus-data-set-header
7356 (gnus-data-find (cdr gnus-article-current))
7358 (gnus-summary-update-article-line
7359 (cdr gnus-article-current) header))))))
7361 (set-buffer (or buffer gnus-summary-buffer))
7362 (gnus-summary-update-article (cdr gnus-article-current)))
7363 ;; Prettify the article buffer again.
7364 (unless no-highlight
7366 (set-buffer gnus-article-buffer)
7367 (gnus-run-hooks 'gnus-article-display-hook)
7368 (set-buffer gnus-original-article-buffer)
7369 (gnus-request-article
7370 (cdr gnus-article-current)
7371 (car gnus-article-current) (current-buffer))))
7372 ;; Prettify the summary buffer line.
7373 (when (gnus-visual-p 'summary-highlight 'highlight)
7374 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
7376 (defun gnus-summary-edit-wash (key)
7377 "Perform editing command KEY in the article buffer."
7381 (message "%s" (concat (this-command-keys) "- "))
7384 (gnus-summary-edit-article)
7385 (execute-kbd-macro (concat (this-command-keys) key))
7386 (gnus-article-edit-done))
7390 (defun gnus-summary-respool-query (&optional silent trace)
7391 "Query where the respool algorithm would put this article."
7393 (let (gnus-mark-article-hook)
7394 (gnus-summary-select-article)
7396 (set-buffer gnus-original-article-buffer)
7398 (message-narrow-to-head)
7399 (let ((groups (nnmail-article-group 'identity trace)))
7402 (message "This message would go to %s"
7403 (mapconcat 'car groups ", "))
7404 (message "This message would go to no groups"))
7407 (defun gnus-summary-respool-trace ()
7408 "Trace where the respool algorithm would put this article.
7409 Display a buffer showing all fancy splitting patterns which matched."
7411 (gnus-summary-respool-query nil t))
7413 ;; Summary marking commands.
7415 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
7416 "Mark articles which has the same subject as read, and then select the next.
7417 If UNMARK is positive, remove any kind of mark.
7418 If UNMARK is negative, tick articles."
7421 (setq unmark (prefix-numeric-value unmark)))
7423 (gnus-summary-mark-same-subject
7424 (gnus-summary-article-subject) unmark)))
7425 ;; Select next unread article. If auto-select-same mode, should
7426 ;; select the first unread article.
7427 (gnus-summary-next-article t (and gnus-auto-select-same
7428 (gnus-summary-article-subject)))
7429 (gnus-message 7 "%d article%s marked as %s"
7430 count (if (= count 1) " is" "s are")
7431 (if unmark "unread" "read"))))
7433 (defun gnus-summary-kill-same-subject (&optional unmark)
7434 "Mark articles which has the same subject as read.
7435 If UNMARK is positive, remove any kind of mark.
7436 If UNMARK is negative, tick articles."
7439 (setq unmark (prefix-numeric-value unmark)))
7441 (gnus-summary-mark-same-subject
7442 (gnus-summary-article-subject) unmark)))
7443 ;; If marked as read, go to next unread subject.
7445 ;; Go to next unread subject.
7446 (gnus-summary-next-subject 1 t))
7447 (gnus-message 7 "%d articles are marked as %s"
7448 count (if unmark "unread" "read"))))
7450 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7451 "Mark articles with same SUBJECT as read, and return marked number.
7452 If optional argument UNMARK is positive, remove any kinds of marks.
7453 If optional argument UNMARK is negative, mark articles as unread instead."
7457 ((null unmark) ; Mark as read.
7460 (gnus-summary-mark-article-as-read gnus-killed-mark)
7461 (gnus-summary-show-thread) t)
7462 (gnus-summary-find-subject subject))
7463 (setq count (1+ count))))
7464 ((> unmark 0) ; Tick.
7467 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
7468 (gnus-summary-show-thread) t)
7469 (gnus-summary-find-subject subject))
7470 (setq count (1+ count))))
7471 (t ; Mark as unread.
7474 (gnus-summary-mark-article-as-unread gnus-unread-mark)
7475 (gnus-summary-show-thread) t)
7476 (gnus-summary-find-subject subject))
7477 (setq count (1+ count)))))
7478 (gnus-set-mode-line 'summary)
7479 ;; Return the number of marked articles.
7482 (defun gnus-summary-mark-as-processable (n &optional unmark)
7483 "Set the process mark on the next N articles.
7484 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7485 the process mark instead. The difference between N and the actual
7486 number of articles marked is returned."
7488 (let ((backward (< n 0))
7493 (gnus-summary-remove-process-mark
7494 (gnus-summary-article-number))
7495 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7496 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7499 (gnus-message 7 "No more articles"))
7500 (gnus-summary-recenter)
7501 (gnus-summary-position-point)
7504 (defun gnus-summary-unmark-as-processable (n)
7505 "Remove the process mark from the next N articles.
7506 If N is negative, unmark backward instead. The difference between N and
7507 the actual number of articles unmarked is returned."
7509 (gnus-summary-mark-as-processable n t))
7511 (defun gnus-summary-unmark-all-processable ()
7512 "Remove the process mark from all articles."
7515 (while gnus-newsgroup-processable
7516 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7517 (gnus-summary-position-point))
7519 (defun gnus-summary-mark-as-expirable (n)
7520 "Mark N articles forward as expirable.
7521 If N is negative, mark backward instead. The difference between N and
7522 the actual number of articles marked is returned."
7524 (gnus-summary-mark-forward n gnus-expirable-mark))
7526 (defun gnus-summary-mark-article-as-replied (article)
7527 "Mark ARTICLE replied and update the summary line."
7528 (push article gnus-newsgroup-replied)
7529 (let ((buffer-read-only nil))
7530 (when (gnus-summary-goto-subject article)
7531 (gnus-summary-update-secondary-mark article))))
7533 (defun gnus-summary-set-bookmark (article)
7534 "Set a bookmark in current article."
7535 (interactive (list (gnus-summary-article-number)))
7536 (when (or (not (get-buffer gnus-article-buffer))
7537 (not gnus-current-article)
7538 (not gnus-article-current)
7539 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7540 (error "No current article selected"))
7541 ;; Remove old bookmark, if one exists.
7542 (let ((old (assq article gnus-newsgroup-bookmarks)))
7544 (setq gnus-newsgroup-bookmarks
7545 (delq old gnus-newsgroup-bookmarks))))
7546 ;; Set the new bookmark, which is on the form
7547 ;; (article-number . line-number-in-body).
7551 (set-buffer gnus-article-buffer)
7555 (goto-char (point-min))
7556 (search-forward "\n\n" nil t)
7559 gnus-newsgroup-bookmarks)
7560 (gnus-message 6 "A bookmark has been added to the current article."))
7562 (defun gnus-summary-remove-bookmark (article)
7563 "Remove the bookmark from the current article."
7564 (interactive (list (gnus-summary-article-number)))
7565 ;; Remove old bookmark, if one exists.
7566 (let ((old (assq article gnus-newsgroup-bookmarks)))
7569 (setq gnus-newsgroup-bookmarks
7570 (delq old gnus-newsgroup-bookmarks))
7571 (gnus-message 6 "Removed bookmark."))
7572 (gnus-message 6 "No bookmark in current article."))))
7574 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7575 (defun gnus-summary-mark-as-dormant (n)
7576 "Mark N articles forward as dormant.
7577 If N is negative, mark backward instead. The difference between N and
7578 the actual number of articles marked is returned."
7580 (gnus-summary-mark-forward n gnus-dormant-mark))
7582 (defun gnus-summary-set-process-mark (article)
7583 "Set the process mark on ARTICLE and update the summary line."
7584 (setq gnus-newsgroup-processable
7586 (delq article gnus-newsgroup-processable)))
7587 (when (gnus-summary-goto-subject article)
7588 (gnus-summary-show-thread)
7589 (gnus-summary-update-secondary-mark article)))
7591 (defun gnus-summary-remove-process-mark (article)
7592 "Remove the process mark from ARTICLE and update the summary line."
7593 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7594 (when (gnus-summary-goto-subject article)
7595 (gnus-summary-show-thread)
7596 (gnus-summary-update-secondary-mark article)))
7598 (defun gnus-summary-set-saved-mark (article)
7599 "Set the process mark on ARTICLE and update the summary line."
7600 (push article gnus-newsgroup-saved)
7601 (when (gnus-summary-goto-subject article)
7602 (gnus-summary-update-secondary-mark article)))
7604 (defun gnus-summary-mark-forward (n &optional mark no-expire)
7605 "Mark N articles as read forwards.
7606 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
7607 The difference between N and the actual number of articles marked is
7610 (let ((backward (< n 0))
7611 (gnus-summary-goto-unread
7612 (and gnus-summary-goto-unread
7613 (not (eq gnus-summary-goto-unread 'never))
7614 (not (memq mark (list gnus-unread-mark
7615 gnus-ticked-mark gnus-dormant-mark)))))
7617 (mark (or mark gnus-del-mark)))
7619 (gnus-summary-mark-article nil mark no-expire)
7620 (zerop (gnus-summary-next-subject
7622 (and gnus-summary-goto-unread
7623 (not (eq gnus-summary-goto-unread 'never)))
7627 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
7628 (gnus-summary-recenter)
7629 (gnus-summary-position-point)
7630 (gnus-set-mode-line 'summary)
7633 (defun gnus-summary-mark-article-as-read (mark)
7634 "Mark the current article quickly as read with MARK."
7635 (let ((article (gnus-summary-article-number)))
7636 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7637 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7638 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7639 (push (cons article mark) gnus-newsgroup-reads)
7640 ;; Possibly remove from cache, if that is used.
7641 (when gnus-use-cache
7642 (gnus-cache-enter-remove-article article))
7643 ;; Allow the backend to change the mark.
7644 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7645 ;; Check for auto-expiry.
7646 (when (and gnus-newsgroup-auto-expire
7647 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7648 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7649 (= mark gnus-ancient-mark)
7650 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7651 (= mark gnus-duplicate-mark)))
7652 (setq mark gnus-expirable-mark)
7653 (push article gnus-newsgroup-expirable))
7654 ;; Set the mark in the buffer.
7655 (gnus-summary-update-mark mark 'unread)
7658 (defun gnus-summary-mark-article-as-unread (mark)
7659 "Mark the current article quickly as unread with MARK."
7660 (let* ((article (gnus-summary-article-number))
7661 (old-mark (gnus-summary-article-mark article)))
7662 (if (eq mark old-mark)
7666 (gnus-error 1 "Can't mark negative article numbers")
7668 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7669 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7670 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
7671 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
7672 (cond ((= mark gnus-ticked-mark)
7673 (push article gnus-newsgroup-marked))
7674 ((= mark gnus-dormant-mark)
7675 (push article gnus-newsgroup-dormant))
7677 (push article gnus-newsgroup-unreads)))
7678 (gnus-pull article gnus-newsgroup-reads)
7680 ;; See whether the article is to be put in the cache.
7682 (vectorp (gnus-summary-article-header article))
7684 (gnus-cache-possibly-enter-article
7685 gnus-newsgroup-name article
7686 (gnus-summary-article-header article)
7687 (= mark gnus-ticked-mark)
7688 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7691 (gnus-summary-update-mark mark 'unread)
7694 (defun gnus-summary-mark-article (&optional article mark no-expire)
7695 "Mark ARTICLE with MARK. MARK can be any character.
7696 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
7697 `??' (dormant) and `?E' (expirable).
7698 If MARK is nil, then the default character `?D' is used.
7699 If ARTICLE is nil, then the article on the current line will be
7701 ;; The mark might be a string.
7702 (when (stringp mark)
7703 (setq mark (aref mark 0)))
7704 ;; If no mark is given, then we check auto-expiring.
7705 (and (not no-expire)
7706 gnus-newsgroup-auto-expire
7708 (and (gnus-characterp mark)
7709 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7710 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7711 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7712 (= mark gnus-duplicate-mark))))
7713 (setq mark gnus-expirable-mark))
7714 (let* ((mark (or mark gnus-del-mark))
7715 (article (or article (gnus-summary-article-number)))
7716 (old-mark (gnus-summary-article-mark article)))
7717 (if (eq mark old-mark)
7720 (error "No article on current line"))
7721 (if (not (if (or (= mark gnus-unread-mark)
7722 (= mark gnus-ticked-mark)
7723 (= mark gnus-dormant-mark))
7724 (gnus-mark-article-as-unread article mark)
7725 (gnus-mark-article-as-read article mark)))
7727 ;; See whether the article is to be put in the cache.
7729 (not (= mark gnus-canceled-mark))
7730 (vectorp (gnus-summary-article-header article))
7732 (gnus-cache-possibly-enter-article
7733 gnus-newsgroup-name article
7734 (gnus-summary-article-header article)
7735 (= mark gnus-ticked-mark)
7736 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7738 (when (gnus-summary-goto-subject article nil t)
7739 (let ((buffer-read-only nil))
7740 (gnus-summary-show-thread)
7742 (gnus-summary-update-mark mark 'unread)
7745 (defun gnus-summary-update-secondary-mark (article)
7746 "Update the secondary (read, process, cache) mark."
7747 (gnus-summary-update-mark
7748 (cond ((memq article gnus-newsgroup-processable)
7750 ((memq article gnus-newsgroup-cached)
7752 ((memq article gnus-newsgroup-replied)
7754 ((memq article gnus-newsgroup-saved)
7756 (t gnus-unread-mark))
7758 (when (gnus-visual-p 'summary-highlight 'highlight)
7759 (gnus-run-hooks 'gnus-summary-update-hook))
7762 (defun gnus-summary-update-mark (mark type)
7763 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
7764 (buffer-read-only nil))
7765 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
7766 (when (looking-at "\r")
7769 (<= (+ forward (point)) (point-max)))
7770 ;; Go to the right position on the line.
7771 (goto-char (+ forward (point)))
7772 ;; Replace the old mark with the new mark.
7773 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
7774 ;; Optionally update the marks by some user rule.
7775 (when (eq type 'unread)
7777 (gnus-data-find (gnus-summary-article-number)) mark)
7778 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
7780 (defun gnus-mark-article-as-read (article &optional mark)
7781 "Enter ARTICLE in the pertinent lists and remove it from others."
7782 ;; Make the article expirable.
7783 (let ((mark (or mark gnus-del-mark)))
7784 (if (= mark gnus-expirable-mark)
7785 (push article gnus-newsgroup-expirable)
7786 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
7787 ;; Remove from unread and marked lists.
7788 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7789 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7790 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7791 (push (cons article mark) gnus-newsgroup-reads)
7792 ;; Possibly remove from cache, if that is used.
7793 (when gnus-use-cache
7794 (gnus-cache-enter-remove-article article))
7797 (defun gnus-mark-article-as-unread (article &optional mark)
7798 "Enter ARTICLE in the pertinent lists and remove it from others."
7799 (let ((mark (or mark gnus-ticked-mark)))
7802 (gnus-error 1 "Can't mark negative article numbers")
7804 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
7805 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
7806 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
7807 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7809 ;; Unsuppress duplicates?
7810 (when gnus-suppress-duplicates
7811 (gnus-dup-unsuppress-article article))
7813 (cond ((= mark gnus-ticked-mark)
7814 (push article gnus-newsgroup-marked))
7815 ((= mark gnus-dormant-mark)
7816 (push article gnus-newsgroup-dormant))
7818 (push article gnus-newsgroup-unreads)))
7819 (gnus-pull article gnus-newsgroup-reads)
7822 (defalias 'gnus-summary-mark-as-unread-forward
7823 'gnus-summary-tick-article-forward)
7824 (make-obsolete 'gnus-summary-mark-as-unread-forward
7825 'gnus-summary-tick-article-forward)
7826 (defun gnus-summary-tick-article-forward (n)
7827 "Tick N articles forwards.
7828 If N is negative, tick backwards instead.
7829 The difference between N and the number of articles ticked is returned."
7831 (gnus-summary-mark-forward n gnus-ticked-mark))
7833 (defalias 'gnus-summary-mark-as-unread-backward
7834 'gnus-summary-tick-article-backward)
7835 (make-obsolete 'gnus-summary-mark-as-unread-backward
7836 'gnus-summary-tick-article-backward)
7837 (defun gnus-summary-tick-article-backward (n)
7838 "Tick N articles backwards.
7839 The difference between N and the number of articles ticked is returned."
7841 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
7843 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7844 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7845 (defun gnus-summary-tick-article (&optional article clear-mark)
7846 "Mark current article as unread.
7847 Optional 1st argument ARTICLE specifies article number to be marked as unread.
7848 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
7850 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
7853 (defun gnus-summary-mark-as-read-forward (n)
7854 "Mark N articles as read forwards.
7855 If N is negative, mark backwards instead.
7856 The difference between N and the actual number of articles marked is
7859 (gnus-summary-mark-forward n gnus-del-mark t))
7861 (defun gnus-summary-mark-as-read-backward (n)
7862 "Mark the N articles as read backwards.
7863 The difference between N and the actual number of articles marked is
7866 (gnus-summary-mark-forward (- n) gnus-del-mark t))
7868 (defun gnus-summary-mark-as-read (&optional article mark)
7869 "Mark current article as read.
7870 ARTICLE specifies the article to be marked as read.
7871 MARK specifies a string to be inserted at the beginning of the line."
7872 (gnus-summary-mark-article article mark))
7874 (defun gnus-summary-clear-mark-forward (n)
7875 "Clear marks from N articles forward.
7876 If N is negative, clear backward instead.
7877 The difference between N and the number of marks cleared is returned."
7879 (gnus-summary-mark-forward n gnus-unread-mark))
7881 (defun gnus-summary-clear-mark-backward (n)
7882 "Clear marks from N articles backward.
7883 The difference between N and the number of marks cleared is returned."
7885 (gnus-summary-mark-forward (- n) gnus-unread-mark))
7887 (defun gnus-summary-mark-unread-as-read ()
7888 "Intended to be used by `gnus-summary-mark-article-hook'."
7889 (when (memq gnus-current-article gnus-newsgroup-unreads)
7890 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
7892 (defun gnus-summary-mark-read-and-unread-as-read ()
7893 "Intended to be used by `gnus-summary-mark-article-hook'."
7894 (let ((mark (gnus-summary-article-mark)))
7895 (when (or (gnus-unread-mark-p mark)
7896 (gnus-read-mark-p mark))
7897 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
7899 (defun gnus-summary-mark-region-as-read (point mark all)
7900 "Mark all unread articles between point and mark as read.
7901 If given a prefix, mark all articles between point and mark as read,
7902 even ticked and dormant ones."
7903 (interactive "r\nP")
7912 (memq (setq article (gnus-summary-article-number))
7913 gnus-newsgroup-unreads))
7914 (gnus-summary-mark-article article gnus-del-mark))
7916 (gnus-summary-find-next))))))
7918 (defun gnus-summary-mark-below (score mark)
7919 "Mark articles with score less than SCORE with MARK."
7920 (interactive "P\ncMark: ")
7921 (setq score (if score
7922 (prefix-numeric-value score)
7923 (or gnus-summary-default-score 0)))
7925 (set-buffer gnus-summary-buffer)
7926 (goto-char (point-min))
7929 (and (< (gnus-summary-article-score) score)
7930 (gnus-summary-mark-article nil mark))
7931 (gnus-summary-find-next)))))
7933 (defun gnus-summary-kill-below (&optional score)
7934 "Mark articles with score below SCORE as read."
7936 (gnus-summary-mark-below score gnus-killed-mark))
7938 (defun gnus-summary-clear-above (&optional score)
7939 "Clear all marks from articles with score above SCORE."
7941 (gnus-summary-mark-above score gnus-unread-mark))
7943 (defun gnus-summary-tick-above (&optional score)
7944 "Tick all articles with score above SCORE."
7946 (gnus-summary-mark-above score gnus-ticked-mark))
7948 (defun gnus-summary-mark-above (score mark)
7949 "Mark articles with score over SCORE with MARK."
7950 (interactive "P\ncMark: ")
7951 (setq score (if score
7952 (prefix-numeric-value score)
7953 (or gnus-summary-default-score 0)))
7955 (set-buffer gnus-summary-buffer)
7956 (goto-char (point-min))
7958 (when (> (gnus-summary-article-score) score)
7959 (gnus-summary-mark-article nil mark))
7961 (gnus-summary-find-next)))))
7963 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7964 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
7965 (defun gnus-summary-limit-include-expunged (&optional no-error)
7966 "Display all the hidden articles that were expunged for low scores."
7968 (let ((buffer-read-only nil))
7969 (let ((scored gnus-newsgroup-scored)
7972 (unless (gnus-summary-goto-subject (caar scored))
7973 (and (setq h (gnus-summary-article-header (caar scored)))
7974 (< (cdar scored) gnus-summary-expunge-below)
7976 (setq scored (cdr scored)))
7978 (when (not no-error)
7979 (error "No expunged articles hidden"))
7980 (goto-char (point-min))
7981 (gnus-summary-prepare-unthreaded (nreverse headers))
7982 (goto-char (point-min))
7983 (gnus-summary-position-point)
7986 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
7987 "Mark all unread articles in this newsgroup as read.
7988 If prefix argument ALL is non-nil, ticked and dormant articles will
7989 also be marked as read.
7990 If QUIETLY is non-nil, no questions will be asked.
7991 If TO-HERE is non-nil, it should be a point in the buffer. All
7992 articles before this point will be marked as read.
7993 Note that this function will only catch up the unread article
7994 in the current summary buffer limitation.
7995 The number of articles marked as read is returned."
8000 (not gnus-interactive-catchup) ;Without confirmation?
8004 "Mark absolutely all articles as read? "
8005 "Mark all unread articles as read? ")))
8007 (not gnus-newsgroup-adaptive)
8008 (not gnus-newsgroup-auto-expire)
8009 (not gnus-suppress-duplicates)
8010 (or (not gnus-use-cache)
8011 (eq gnus-use-cache 'passive)))
8014 (setq gnus-newsgroup-marked nil
8015 gnus-newsgroup-dormant nil))
8016 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8017 ;; We actually mark all articles as canceled, which we
8018 ;; have to do when using auto-expiry or adaptive scoring.
8019 (gnus-summary-show-all-threads)
8020 (when (gnus-summary-first-subject (not all) t)
8022 (if to-here (< (point) to-here) t)
8023 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8024 (gnus-summary-find-next (not all) nil nil t))))
8025 (gnus-set-mode-line 'summary))
8027 (gnus-summary-position-point)))
8029 (defun gnus-summary-catchup-to-here (&optional all)
8030 "Mark all unticked articles before the current one as read.
8031 If ALL is non-nil, also mark ticked and dormant articles as read."
8034 (gnus-save-hidden-threads
8035 (let ((beg (point)))
8036 ;; We check that there are unread articles.
8037 (when (or all (gnus-summary-find-prev))
8038 (gnus-summary-catchup all t beg)))))
8039 (gnus-summary-position-point))
8041 (defun gnus-summary-catchup-all (&optional quietly)
8042 "Mark all articles in this newsgroup as read."
8044 (gnus-summary-catchup t quietly))
8046 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8047 "Mark all articles not marked as unread in this newsgroup as read, then exit.
8048 If prefix argument ALL is non-nil, all articles are marked as read."
8050 (when (gnus-summary-catchup all quietly nil 'fast)
8051 ;; Select next newsgroup or exit.
8052 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
8053 (eq gnus-auto-select-next 'quietly))
8054 (gnus-summary-next-group nil)
8055 (gnus-summary-exit))))
8057 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8058 "Mark all articles in this newsgroup as read, and then exit."
8060 (gnus-summary-catchup-and-exit t quietly))
8062 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
8063 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8064 "Mark all articles in this group as read and select the next group.
8065 If given a prefix, mark all articles, unread as well as ticked, as
8069 (gnus-summary-catchup all))
8070 (gnus-summary-next-article t nil nil t))
8072 ;; Thread-based commands.
8074 (defun gnus-summary-articles-in-thread (&optional article)
8075 "Return a list of all articles in the current thread.
8076 If ARTICLE is non-nil, return all articles in the thread that starts
8078 (let* ((article (or article (gnus-summary-article-number)))
8079 (data (gnus-data-find-list article))
8080 (top-level (gnus-data-level (car data)))
8082 (cond ((null gnus-thread-operation-ignore-subject)
8083 (gnus-simplify-subject-re
8084 (mail-header-subject (gnus-data-header (car data)))))
8085 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8086 (gnus-simplify-subject-fuzzy
8087 (mail-header-subject (gnus-data-header (car data)))))
8089 (end-point (save-excursion
8090 (if (gnus-summary-go-to-next-thread)
8091 (point) (point-max))))
8094 (< (gnus-data-pos (car data)) end-point))
8095 (when (or (not top-subject)
8096 (string= top-subject
8097 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8098 (gnus-simplify-subject-fuzzy
8099 (mail-header-subject
8100 (gnus-data-header (car data))))
8101 (gnus-simplify-subject-re
8102 (mail-header-subject
8103 (gnus-data-header (car data)))))))
8104 (push (gnus-data-number (car data)) articles))
8105 (unless (and (setq data (cdr data))
8106 (> (gnus-data-level (car data)) top-level))
8108 ;; Return the list of articles.
8109 (nreverse articles)))
8111 (defun gnus-summary-rethread-current ()
8112 "Rethread the thread the current article is part of."
8114 (let* ((gnus-show-threads t)
8115 (article (gnus-summary-article-number))
8116 (id (mail-header-id (gnus-summary-article-header)))
8117 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8119 (error "No article on the current line"))
8120 (gnus-rebuild-thread id)
8121 (gnus-summary-goto-subject article)))
8123 (defun gnus-summary-reparent-thread ()
8124 "Make the current article child of the marked (or previous) article.
8126 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8127 is non-nil or the Subject: of both articles are the same."
8129 (unless (not (gnus-group-read-only-p))
8130 (error "The current newsgroup does not support article editing"))
8131 (unless (<= (length gnus-newsgroup-processable) 1)
8132 (error "No more than one article may be marked"))
8133 (save-window-excursion
8134 (let ((gnus-article-buffer " *reparent*")
8135 (current-article (gnus-summary-article-number))
8136 ;; First grab the marked article, otherwise one line up.
8137 (parent-article (if (not (null gnus-newsgroup-processable))
8138 (car gnus-newsgroup-processable)
8140 (if (eq (forward-line -1) 0)
8141 (gnus-summary-article-number)
8142 (error "Beginning of summary buffer"))))))
8143 (unless (not (eq current-article parent-article))
8144 (error "An article may not be self-referential"))
8145 (let ((message-id (mail-header-id
8146 (gnus-summary-article-header parent-article))))
8147 (unless (and message-id (not (equal message-id "")))
8148 (error "No message-id in desired parent"))
8149 ;; We don't want the article to be marked as read.
8150 (let (gnus-mark-article-hook)
8151 (gnus-summary-select-article t t nil current-article))
8152 (set-buffer gnus-original-article-buffer)
8153 (let ((buf (format "%s" (buffer-string))))
8154 (nnheader-temp-write nil
8156 (goto-char (point-min))
8157 (if (re-search-forward "^References: " nil t)
8159 (re-search-forward "^[^ \t]" nil t)
8162 (insert " " message-id))
8163 (insert "References: " message-id "\n"))
8164 (unless (gnus-request-replace-article
8165 current-article (car gnus-article-current)
8167 (error "Couldn't replace article"))))
8168 (set-buffer gnus-summary-buffer)
8169 (gnus-summary-unmark-all-processable)
8170 (gnus-summary-update-article current-article)
8171 (gnus-summary-rethread-current)
8172 (gnus-message 3 "Article %d is now the child of article %d"
8173 current-article parent-article)))))
8175 (defun gnus-summary-toggle-threads (&optional arg)
8176 "Toggle showing conversation threads.
8177 If ARG is positive number, turn showing conversation threads on."
8179 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8180 (setq gnus-show-threads
8181 (if (null arg) (not gnus-show-threads)
8182 (> (prefix-numeric-value arg) 0)))
8183 (gnus-summary-prepare)
8184 (gnus-summary-goto-subject current)
8185 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8186 (gnus-summary-position-point)))
8188 (defun gnus-summary-show-all-threads ()
8192 (let ((buffer-read-only nil))
8193 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8194 (gnus-summary-position-point))
8196 (defun gnus-summary-show-thread ()
8197 "Show thread subtrees.
8198 Returns nil if no thread was there to be shown."
8200 (let ((buffer-read-only nil)
8202 ;; first goto end then to beg, to have point at beg after let
8203 (end (progn (end-of-line) (point)))
8204 (beg (progn (beginning-of-line) (point))))
8206 ;; Any hidden lines here?
8207 (search-forward "\r" end t)
8208 (subst-char-in-region beg end ?\^M ?\n t)
8210 (gnus-summary-position-point))))
8212 (defun gnus-summary-hide-all-threads ()
8213 "Hide all thread subtrees."
8216 (goto-char (point-min))
8217 (gnus-summary-hide-thread)
8218 (while (zerop (gnus-summary-next-thread 1 t))
8219 (gnus-summary-hide-thread)))
8220 (gnus-summary-position-point))
8222 (defun gnus-summary-hide-thread ()
8223 "Hide thread subtrees.
8224 Returns nil if no threads were there to be hidden."
8226 (let ((buffer-read-only nil)
8228 (article (gnus-summary-article-number)))
8230 ;; Go forward until either the buffer ends or the subthread
8232 (when (and (not (eobp))
8233 (or (zerop (gnus-summary-next-thread 1 t))
8234 (goto-char (point-max))))
8236 (if (and (> (point) start)
8237 (search-backward "\n" start t))
8239 (subst-char-in-region start (point) ?\n ?\^M)
8240 (gnus-summary-goto-subject article))
8243 ;;(gnus-summary-position-point)
8246 (defun gnus-summary-go-to-next-thread (&optional previous)
8247 "Go to the same level (or less) next thread.
8248 If PREVIOUS is non-nil, go to previous thread instead.
8249 Return the article number moved to, or nil if moving was impossible."
8250 (let ((level (gnus-summary-thread-level))
8251 (way (if previous -1 1))
8254 (while (and (not (eobp))
8255 (< level (gnus-summary-thread-level)))
8263 (gnus-summary-article-number)
8266 (defun gnus-summary-next-thread (n &optional silent)
8267 "Go to the same level next N'th thread.
8268 If N is negative, search backward instead.
8269 Returns the difference between N and the number of skips actually
8272 If SILENT, don't output messages."
8274 (let ((backward (< n 0))
8277 (gnus-summary-go-to-next-thread backward))
8280 (gnus-summary-position-point))
8281 (when (and (not silent) (/= 0 n))
8282 (gnus-message 7 "No more threads"))
8285 (defun gnus-summary-prev-thread (n)
8286 "Go to the same level previous N'th thread.
8287 Returns the difference between N and the number of skips actually
8290 (gnus-summary-next-thread (- n)))
8292 (defun gnus-summary-go-down-thread ()
8293 "Go down one level in the current thread."
8294 (let ((children (gnus-summary-article-children)))
8296 (gnus-summary-goto-subject (car children)))))
8298 (defun gnus-summary-go-up-thread ()
8299 "Go up one level in the current thread."
8300 (let ((parent (gnus-summary-article-parent)))
8302 (gnus-summary-goto-subject parent))))
8304 (defun gnus-summary-down-thread (n)
8305 "Go down thread N steps.
8306 If N is negative, go up instead.
8307 Returns the difference between N and how many steps down that were
8313 (if up (gnus-summary-go-up-thread)
8314 (gnus-summary-go-down-thread)))
8316 (gnus-summary-position-point)
8318 (gnus-message 7 "Can't go further"))
8321 (defun gnus-summary-up-thread (n)
8322 "Go up thread N steps.
8323 If N is negative, go up instead.
8324 Returns the difference between N and how many steps down that were
8327 (gnus-summary-down-thread (- n)))
8329 (defun gnus-summary-top-thread ()
8330 "Go to the top of the thread."
8332 (while (gnus-summary-go-up-thread))
8333 (gnus-summary-article-number))
8335 (defun gnus-summary-kill-thread (&optional unmark)
8336 "Mark articles under current thread as read.
8337 If the prefix argument is positive, remove any kinds of marks.
8338 If the prefix argument is negative, tick articles instead."
8341 (setq unmark (prefix-numeric-value unmark)))
8342 (let ((articles (gnus-summary-articles-in-thread)))
8344 ;; Expand the thread.
8345 (gnus-summary-show-thread)
8346 ;; Mark all the articles.
8348 (gnus-summary-goto-subject (car articles))
8349 (cond ((null unmark)
8350 (gnus-summary-mark-article-as-read gnus-killed-mark))
8352 (gnus-summary-mark-article-as-unread gnus-unread-mark))
8354 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
8355 (setq articles (cdr articles))))
8356 ;; Hide killed subtrees.
8358 gnus-thread-hide-killed
8359 (gnus-summary-hide-thread))
8360 ;; If marked as read, go to next unread subject.
8362 ;; Go to next unread subject.
8363 (gnus-summary-next-subject 1 t)))
8364 (gnus-set-mode-line 'summary))
8366 ;; Summary sorting commands
8368 (defun gnus-summary-sort-by-number (&optional reverse)
8369 "Sort the summary buffer by article number.
8370 Argument REVERSE means reverse order."
8372 (gnus-summary-sort 'number reverse))
8374 (defun gnus-summary-sort-by-author (&optional reverse)
8375 "Sort the summary buffer by author name alphabetically.
8376 If case-fold-search is non-nil, case of letters is ignored.
8377 Argument REVERSE means reverse order."
8379 (gnus-summary-sort 'author reverse))
8381 (defun gnus-summary-sort-by-subject (&optional reverse)
8382 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8383 If case-fold-search is non-nil, case of letters is ignored.
8384 Argument REVERSE means reverse order."
8386 (gnus-summary-sort 'subject reverse))
8388 (defun gnus-summary-sort-by-date (&optional reverse)
8389 "Sort the summary buffer by date.
8390 Argument REVERSE means reverse order."
8392 (gnus-summary-sort 'date reverse))
8394 (defun gnus-summary-sort-by-score (&optional reverse)
8395 "Sort the summary buffer by score.
8396 Argument REVERSE means reverse order."
8398 (gnus-summary-sort 'score reverse))
8400 (defun gnus-summary-sort-by-lines (&optional reverse)
8401 "Sort the summary buffer by article length.
8402 Argument REVERSE means reverse order."
8404 (gnus-summary-sort 'lines reverse))
8406 (defun gnus-summary-sort (predicate reverse)
8407 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
8408 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
8409 (article (intern (format "gnus-article-sort-by-%s" predicate)))
8410 (gnus-thread-sort-functions
8416 (gnus-article-sort-functions
8421 (,article t2 t1)))))
8423 (gnus-summary-prepare-hook nil))
8424 ;; We do the sorting by regenerating the threads.
8425 (gnus-summary-prepare)
8426 ;; Hide subthreads if needed.
8427 (when (and gnus-show-threads gnus-thread-hide-subtree)
8428 (gnus-summary-hide-all-threads))))
8430 ;; Summary saving commands.
8432 (defun gnus-summary-save-article (&optional n not-saved)
8433 "Save the current article using the default saver function.
8434 If N is a positive number, save the N next articles.
8435 If N is a negative number, save the N previous articles.
8436 If N is nil and any articles have been marked with the process mark,
8437 save those articles instead.
8438 The variable `gnus-default-article-saver' specifies the saver function."
8440 (let* ((articles (gnus-summary-work-articles n))
8441 (save-buffer (save-excursion
8442 (nnheader-set-temp-buffer " *Gnus Save*")))
8443 (num (length articles))
8444 header article file)
8446 (setq header (gnus-summary-article-header
8447 (setq article (pop articles))))
8448 (if (not (vectorp header))
8449 ;; This is a pseudo-article.
8450 (if (assq 'name header)
8451 (gnus-copy-file (cdr (assq 'name header)))
8452 (gnus-message 1 "Article %d is unsaveable" article))
8453 ;; This is a real article.
8454 (save-window-excursion
8455 (gnus-summary-select-article t nil nil article))
8457 (set-buffer save-buffer)
8459 (insert-buffer-substring gnus-original-article-buffer))
8460 (setq file (gnus-article-save save-buffer file num))
8461 (gnus-summary-remove-process-mark article)
8463 (gnus-summary-set-saved-mark article))))
8464 (gnus-kill-buffer save-buffer)
8465 (gnus-summary-position-point)
8466 (gnus-set-mode-line 'summary)
8469 (defun gnus-summary-pipe-output (&optional arg)
8470 "Pipe the current article to a subprocess.
8471 If N is a positive number, pipe the N next articles.
8472 If N is a negative number, pipe the N previous articles.
8473 If N is nil and any articles have been marked with the process mark,
8474 pipe those articles instead."
8476 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8477 (gnus-summary-save-article arg t))
8478 (gnus-configure-windows 'pipe))
8480 (defun gnus-summary-save-article-mail (&optional arg)
8481 "Append the current article to an mail file.
8482 If N is a positive number, save the N next articles.
8483 If N is a negative number, save the N previous articles.
8484 If N is nil and any articles have been marked with the process mark,
8485 save those articles instead."
8487 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8488 (gnus-summary-save-article arg)))
8490 (defun gnus-summary-save-article-rmail (&optional arg)
8491 "Append the current article to an rmail file.
8492 If N is a positive number, save the N next articles.
8493 If N is a negative number, save the N previous articles.
8494 If N is nil and any articles have been marked with the process mark,
8495 save those articles instead."
8497 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
8498 (gnus-summary-save-article arg)))
8500 (defun gnus-summary-save-article-file (&optional arg)
8501 "Append the current article to a file.
8502 If N is a positive number, save the N next articles.
8503 If N is a negative number, save the N previous articles.
8504 If N is nil and any articles have been marked with the process mark,
8505 save those articles instead."
8507 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8508 (gnus-summary-save-article arg)))
8510 (defun gnus-summary-write-article-file (&optional arg)
8511 "Write the current article to a file, deleting the previous file.
8512 If N is a positive number, save the N next articles.
8513 If N is a negative number, save the N previous articles.
8514 If N is nil and any articles have been marked with the process mark,
8515 save those articles instead."
8517 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
8518 (gnus-summary-save-article arg)))
8520 (defun gnus-summary-save-article-body-file (&optional arg)
8521 "Append the current article body to a file.
8522 If N is a positive number, save the N next articles.
8523 If N is a negative number, save the N previous articles.
8524 If N is nil and any articles have been marked with the process mark,
8525 save those articles instead."
8527 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
8528 (gnus-summary-save-article arg)))
8530 (defun gnus-summary-pipe-message (program)
8531 "Pipe the current article through PROGRAM."
8532 (interactive "sProgram: ")
8533 (gnus-summary-select-article)
8534 (let ((mail-header-separator "")
8535 (art-buf (get-buffer gnus-article-buffer)))
8536 (gnus-eval-in-buffer-window gnus-article-buffer
8539 (let ((start (window-start))
8541 (message-pipe-buffer-body program)
8542 (set-window-start (get-buffer-window (current-buffer)) start))))))
8544 (defun gnus-get-split-value (methods)
8545 "Return a value based on the split METHODS."
8546 (let (split-name method result match)
8549 (set-buffer gnus-original-article-buffer)
8551 (nnheader-narrow-to-headers)
8553 (goto-char (point-min))
8554 (setq method (pop methods))
8555 (setq match (car method))
8558 ;; Regular expression.
8560 (re-search-forward match nil t)))
8561 ((gnus-functionp match)
8565 (setq result (funcall match gnus-newsgroup-name))))
8570 (setq result (eval match)))))
8571 (setq split-name (append (cdr method) split-name))
8572 (cond ((stringp result)
8573 (push (expand-file-name
8574 result gnus-article-save-directory)
8577 (setq split-name (append result split-name)))))))))
8580 (defun gnus-valid-move-group-p (group)
8585 (car (gnus-find-method-for-group
8586 (symbol-name group))))
8587 gnus-valid-select-methods))))
8589 (defun gnus-read-move-group-name (prompt default articles prefix)
8590 "Read a group name."
8591 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
8592 (minibuffer-confirm-incomplete nil) ; XEmacs
8596 (if (> (length articles) 1)
8597 (format "these %d articles" (length articles))
8602 (gnus-completing-read default prom
8604 'gnus-valid-move-group-p
8606 'gnus-group-history))
8607 ((= 1 (length split-name))
8608 (gnus-completing-read (car split-name) prom
8610 'gnus-valid-move-group-p
8612 'gnus-group-history))
8614 (gnus-completing-read nil prom
8615 (mapcar (lambda (el) (list el))
8616 (nreverse split-name))
8618 'gnus-group-history)))))
8620 (if (or (string= to-newsgroup "")
8621 (string= to-newsgroup prefix))
8622 (setq to-newsgroup default))
8623 (unless to-newsgroup
8624 (error "No group name entered"))
8625 (or (gnus-active to-newsgroup)
8626 (gnus-activate-group to-newsgroup)
8627 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
8629 (or (and (gnus-request-create-group
8630 to-newsgroup (gnus-group-name-to-method to-newsgroup))
8631 (gnus-activate-group to-newsgroup nil nil
8632 (gnus-group-name-to-method
8634 (error "Couldn't create group %s" to-newsgroup)))
8635 (error "No such group: %s" to-newsgroup)))
8638 ;; Summary extract commands
8640 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
8641 (let ((buffer-read-only nil)
8642 (article (gnus-summary-article-number))
8644 (unless (gnus-summary-goto-subject article)
8645 (error "No such article: %d" article))
8646 (gnus-summary-position-point)
8647 ;; If all commands are to be bunched up on one line, we collect
8649 (unless gnus-view-pseudos-separately
8650 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
8653 (setq action (cdr (assq 'action (car ps))))
8654 (setq files (list (cdr (assq 'name (car ps)))))
8655 (while (and ps (cdr ps)
8656 (string= (or action "1")
8657 (or (cdr (assq 'action (cadr ps))) "2")))
8658 (push (cdr (assq 'name (cadr ps))) files)
8659 (setcdr ps (cddr ps)))
8661 (when (not (string-match "%s" action))
8664 (when (assq 'execute (car ps))
8665 (setcdr (assq 'execute (car ps))
8666 (funcall (if (string-match "%s" action)
8673 (gnus-quote-arg-for-sh-or-csh f)))
8675 (setq ps (cdr ps)))))
8676 (if (and gnus-view-pseudos (not not-view))
8678 (when (assq 'execute (car pslist))
8679 (gnus-execute-command (cdr (assq 'execute (car pslist)))
8680 (eq gnus-view-pseudos 'not-confirm)))
8681 (setq pslist (cdr pslist)))
8684 (setq after-article (or (cdr (assq 'article (car pslist)))
8685 (gnus-summary-article-number)))
8686 (gnus-summary-goto-subject after-article)
8689 (insert " " (file-name-nondirectory
8690 (cdr (assq 'name (car pslist))))
8691 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
8693 (forward-line -1) ; back to `b'
8694 (gnus-add-text-properties
8695 b (1- e) (list 'gnus-number gnus-reffed-article-number
8696 gnus-mouse-face-prop gnus-mouse-face))
8698 after-article gnus-reffed-article-number
8699 gnus-unread-mark b (car pslist) 0 (- e b))
8700 (push gnus-reffed-article-number gnus-newsgroup-unreads)
8701 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
8702 (setq pslist (cdr pslist)))))))
8704 (defun gnus-pseudos< (p1 p2)
8705 (let ((c1 (cdr (assq 'action p1)))
8706 (c2 (cdr (assq 'action p2))))
8707 (and c1 c2 (string< c1 c2))))
8709 (defun gnus-request-pseudo-article (props)
8710 (cond ((assq 'execute props)
8711 (gnus-execute-command (cdr (assq 'execute props)))))
8712 (let ((gnus-current-article (gnus-summary-article-number)))
8713 (gnus-run-hooks 'gnus-mark-article-hook)))
8715 (defun gnus-execute-command (command &optional automatic)
8717 (gnus-article-setup-buffer)
8718 (set-buffer gnus-article-buffer)
8719 (setq buffer-read-only nil)
8720 (let ((command (if automatic command
8721 (read-string "Command: " (cons command 0)))))
8723 (insert "$ " command "\n\n")
8724 (if gnus-view-pseudo-asynchronously
8725 (start-process "gnus-execute" (current-buffer) shell-file-name
8726 shell-command-switch command)
8727 (call-process shell-file-name nil t nil
8728 shell-command-switch command)))))
8730 ;; Summary kill commands.
8732 (defun gnus-summary-edit-global-kill (article)
8733 "Edit the \"global\" kill file."
8734 (interactive (list (gnus-summary-article-number)))
8735 (gnus-group-edit-global-kill article))
8737 (defun gnus-summary-edit-local-kill ()
8738 "Edit a local kill file applied to the current newsgroup."
8740 (setq gnus-current-headers (gnus-summary-article-header))
8741 (gnus-group-edit-local-kill
8742 (gnus-summary-article-number) gnus-newsgroup-name))
8746 (defun gnus-read-header (id &optional header)
8747 "Read the headers of article ID and enter them into the Gnus system."
8748 (let ((group gnus-newsgroup-name)
8749 (gnus-override-method
8750 (and (gnus-news-group-p gnus-newsgroup-name)
8751 gnus-refer-article-method))
8753 ;; First we check to see whether the header in question is already
8756 ;; This is a Message-ID.
8757 (setq header (or header (gnus-id-to-header id)))
8758 ;; This is an article number.
8759 (setq header (or header (gnus-summary-article-header id))))
8761 (not (gnus-summary-article-sparse-p (mail-header-number header))))
8762 ;; We have found the header.
8764 ;; If this is a sparse article, we have to nix out its
8765 ;; previous entry in the thread hashtb.
8767 (gnus-summary-article-sparse-p (mail-header-number header)))
8768 (let* ((parent (gnus-parent-id (mail-header-references header)))
8769 (thread (and parent (gnus-id-to-thread parent))))
8771 (delq (assq header thread) thread))))
8772 ;; We have to really fetch the header to this article.
8774 (set-buffer nntp-server-buffer)
8775 (when (setq where (gnus-request-head id group))
8776 (nnheader-fold-continuation-lines)
8777 (goto-char (point-max))
8779 (goto-char (point-min))
8783 ((cdr where) (cdr where))
8784 (header (mail-header-number header))
8785 (t gnus-reffed-article-number))
8787 (insert " Article retrieved.\n"))
8789 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
8790 () ; Malformed head.
8791 (unless (gnus-summary-article-sparse-p (mail-header-number header))
8792 (when (and (stringp id)
8793 (not (string= (gnus-group-real-name group)
8795 ;; If we fetched by Message-ID and the article came
8796 ;; from a different group, we fudge some bogus article
8797 ;; numbers for this article.
8798 (mail-header-set-number header gnus-reffed-article-number))
8800 (set-buffer gnus-summary-buffer)
8801 (decf gnus-reffed-article-number)
8802 (gnus-remove-header (mail-header-number header))
8803 (push header gnus-newsgroup-headers)
8804 (setq gnus-current-headers header)
8805 (push (mail-header-number header) gnus-newsgroup-limit)))
8808 (defun gnus-remove-header (number)
8809 "Remove header NUMBER from `gnus-newsgroup-headers'."
8810 (if (and gnus-newsgroup-headers
8811 (= number (mail-header-number (car gnus-newsgroup-headers))))
8812 (pop gnus-newsgroup-headers)
8813 (let ((headers gnus-newsgroup-headers))
8814 (while (and (cdr headers)
8815 (not (= number (mail-header-number (cadr headers)))))
8818 (setcdr headers (cddr headers))))))
8821 ;;; summary highlights
8824 (defun gnus-highlight-selected-summary ()
8825 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8826 ;; Highlight selected article in summary buffer
8827 (when gnus-summary-selected-face
8829 (let* ((beg (progn (beginning-of-line) (point)))
8830 (end (progn (end-of-line) (point)))
8831 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
8832 (from (if (get-text-property beg gnus-mouse-face-prop)
8834 (or (next-single-property-change
8835 beg gnus-mouse-face-prop nil end)
8840 (or (next-single-property-change
8841 from gnus-mouse-face-prop nil end)
8843 ;; If no mouse-face prop on line we will have to = from = end,
8844 ;; so we highlight the entire line instead.
8845 (when (= (+ to 2) from)
8848 (if gnus-newsgroup-selected-overlay
8849 ;; Move old overlay.
8851 gnus-newsgroup-selected-overlay from to (current-buffer))
8852 ;; Create new overlay.
8854 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
8855 'face gnus-summary-selected-face))))))
8857 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
8858 (defun gnus-summary-highlight-line ()
8859 "Highlight current line according to `gnus-summary-highlight'."
8860 (let* ((list gnus-summary-highlight)
8862 (end (progn (end-of-line) (point)))
8863 ;; now find out where the line starts and leave point there.
8864 (beg (progn (beginning-of-line) (point)))
8865 (article (gnus-summary-article-number))
8866 (score (or (cdr (assq (or article gnus-current-article)
8867 gnus-newsgroup-scored))
8868 gnus-summary-default-score 0))
8869 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
8870 (inhibit-read-only t))
8871 ;; Eval the cars of the lists until we find a match.
8872 (let ((default gnus-summary-default-score))
8874 (not (eval (caar list))))
8875 (setq list (cdr list))))
8876 (let ((face (cdar list)))
8877 (unless (eq face (get-text-property beg 'face))
8878 (gnus-put-text-property-excluding-characters-with-faces
8880 (setq face (if (boundp face) (symbol-value face) face)))
8881 (when gnus-summary-highlight-line-function
8882 (funcall gnus-summary-highlight-line-function article face))))
8885 (defun gnus-update-read-articles (group unread &optional compute)
8886 "Update the list of read articles in GROUP."
8887 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
8888 (entry (gnus-gethash group gnus-newsrc-hashtb))
8889 (info (nth 2 entry))
8891 (unread (sort (copy-sequence unread) '<))
8893 (if (or (not info) (not active))
8894 ;; There is no info on this group if it was, in fact,
8895 ;; killed. Gnus stores no information on killed groups, so
8896 ;; there's nothing to be done.
8897 ;; One could store the information somewhere temporarily,
8898 ;; perhaps... Hmmm...
8900 ;; Remove any negative articles numbers.
8901 (while (and unread (< (car unread) 0))
8902 (setq unread (cdr unread)))
8903 ;; Remove any expired article numbers
8904 (while (and unread (< (car unread) (car active)))
8905 (setq unread (cdr unread)))
8906 ;; Compute the ranges of read articles by looking at the list of
8909 (when (/= (car unread) prev)
8910 (push (if (= prev (1- (car unread))) prev
8911 (cons prev (1- (car unread))))
8913 (setq prev (1+ (car unread)))
8914 (setq unread (cdr unread)))
8915 (when (<= prev (cdr active))
8916 (push (cons prev (cdr active)) read))
8918 (if (> (length read) 1) (nreverse read) read)
8920 (set-buffer gnus-group-buffer)
8923 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
8924 (gnus-info-set-read ',info ',(gnus-info-read info))
8925 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
8926 (gnus-group-update-group ,group t))))
8927 ;; Enter this list into the group info.
8929 info (if (> (length read) 1) (nreverse read) read))
8930 ;; Set the number of unread articles in gnus-newsrc-hashtb.
8931 (gnus-get-unread-articles-in-group info (gnus-active group))
8934 (defun gnus-offer-save-summaries ()
8935 "Offer to save all active summary buffers."
8937 (let ((buflist (buffer-list))
8939 ;; Go through all buffers and find all summaries.
8941 (and (setq bufname (buffer-name (car buflist)))
8942 (string-match "Summary" bufname)
8944 (set-buffer bufname)
8945 ;; We check that this is, indeed, a summary buffer.
8946 (and (eq major-mode 'gnus-summary-mode)
8947 ;; Also make sure this isn't bogus.
8948 gnus-newsgroup-prepared
8949 ;; Also make sure that this isn't a dead summary buffer.
8950 (not gnus-dead-summary-mode)))
8951 (push bufname buffers))
8952 (setq buflist (cdr buflist)))
8953 ;; Go through all these summary buffers and offer to save them.
8956 "Update summary buffer %s? "
8958 (switch-to-buffer buf)
8959 (gnus-summary-exit))
8963 ;;; @ for mime-partial
8966 (defun gnus-request-partial-message ()
8968 (let ((number (gnus-summary-article-number))
8969 (group gnus-newsgroup-name)
8970 (mother gnus-article-buffer))
8971 (set-buffer (get-buffer-create " *Partial Article*"))
8973 (setq mime-preview-buffer mother)
8974 (gnus-request-article-this-buffer number group)
8978 (autoload 'mime-combine-message/partial-pieces-automatically
8980 "Internal method to combine message/partial messages automatically.")
8983 'action '((type . message)(subtype . partial)
8984 (major-mode . gnus-original-article-mode)
8985 (method . mime-combine-message/partial-pieces-automatically)
8986 (summary-buffer-exp . gnus-summary-buffer)
8987 (request-partial-message-method . gnus-request-partial-message)
8998 (run-hooks 'gnus-sum-load-hook)
9000 ;;; gnus-sum.el ends here