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 "i" gnus-summary-import-article
1439 "p" gnus-summary-article-posted-p)
1441 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1442 "o" gnus-summary-save-article
1443 "m" gnus-summary-save-article-mail
1444 "F" gnus-summary-write-article-file
1445 "r" gnus-summary-save-article-rmail
1446 "f" gnus-summary-save-article-file
1447 "b" gnus-summary-save-article-body-file
1448 "h" gnus-summary-save-article-folder
1449 "v" gnus-summary-save-article-vm
1450 "p" gnus-summary-pipe-output
1451 "s" gnus-soup-add-article))
1453 (defun gnus-summary-make-menu-bar ()
1454 (gnus-turn-off-edit-menu 'summary)
1456 (unless (boundp 'gnus-summary-misc-menu)
1459 gnus-summary-kill-menu gnus-summary-mode-map ""
1464 ["Enter score..." gnus-summary-score-entry t]
1465 ["Customize" gnus-score-customize t])
1466 (gnus-make-score-map 'increase)
1467 (gnus-make-score-map 'lower)
1469 ["Kill below" gnus-summary-kill-below t]
1470 ["Mark above" gnus-summary-mark-above t]
1471 ["Tick above" gnus-summary-tick-above t]
1472 ["Clear above" gnus-summary-clear-above t])
1473 ["Current score" gnus-summary-current-score t]
1474 ["Set score" gnus-summary-set-score t]
1475 ["Switch current score file..." gnus-score-change-score-file t]
1476 ["Set mark below..." gnus-score-set-mark-below t]
1477 ["Set expunge below..." gnus-score-set-expunge-below t]
1478 ["Edit current score file" gnus-score-edit-current-scores t]
1479 ["Edit score file" gnus-score-edit-file t]
1480 ["Trace score" gnus-score-find-trace t]
1481 ["Find words" gnus-score-find-favourite-words t]
1482 ["Rescore buffer" gnus-summary-rescore t]
1483 ["Increase score..." gnus-summary-increase-score t]
1484 ["Lower score..." gnus-summary-lower-score t]))))
1486 ;; Define both the Article menu in the summary buffer and the equivalent
1487 ;; Commands menu in the article buffer here for consistency.
1490 ["All" gnus-article-hide t]
1491 ["Headers" gnus-article-hide-headers t]
1492 ["Signature" gnus-article-hide-signature t]
1493 ["Citation" gnus-article-hide-citation t]
1494 ["PGP" gnus-article-hide-pgp t]
1495 ["Boring headers" gnus-article-hide-boring-headers t])
1497 ["All" gnus-article-highlight t]
1498 ["Headers" gnus-article-highlight-headers t]
1499 ["Signature" gnus-article-highlight-signature t]
1500 ["Citation" gnus-article-highlight-citation t])
1502 ["Local" gnus-article-date-local t]
1503 ["ISO8601" gnus-article-date-iso8601 t]
1504 ["UT" gnus-article-date-ut t]
1505 ["Original" gnus-article-date-original t]
1506 ["Lapsed" gnus-article-date-lapsed t]
1507 ["User-defined" gnus-article-date-user t])
1510 ["Leading" gnus-article-strip-leading-blank-lines t]
1511 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1512 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1513 ["All of the above" gnus-article-strip-blank-lines t]
1514 ["All" gnus-article-strip-all-blank-lines t]
1515 ["Leading space" gnus-article-strip-leading-space t])
1516 ["Overstrike" gnus-article-treat-overstrike t]
1517 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1518 ["Emphasis" gnus-article-emphasize t]
1519 ["Word wrap" gnus-article-fill-cited-article t]
1520 ["CR" gnus-article-remove-cr t]
1521 ["Show X-Face" gnus-article-display-x-face t]
1522 ["UnHTMLize" gnus-article-treat-html t]
1523 ["Rot 13" gnus-summary-caesar-message t]
1524 ["Unix pipe" gnus-summary-pipe-message t]
1525 ["Add buttons" gnus-article-add-buttons t]
1526 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1527 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1528 ["Toggle MIME" gnus-summary-toggle-mime t]
1529 ["Verbose header" gnus-summary-verbose-headers t]
1530 ["Toggle header" gnus-summary-toggle-header t])
1532 ["Save in default format" gnus-summary-save-article t]
1533 ["Save in file" gnus-summary-save-article-file t]
1534 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1535 ["Save in MH folder" gnus-summary-save-article-folder t]
1536 ["Save in VM folder" gnus-summary-save-article-vm t]
1537 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1538 ["Save body in file" gnus-summary-save-article-body-file t]
1539 ["Pipe through a filter" gnus-summary-pipe-output t]
1540 ["Add to SOUP packet" gnus-soup-add-article t]
1541 ["Print" gnus-summary-print-article t])
1543 ["Respool article..." gnus-summary-respool-article t]
1544 ["Move article..." gnus-summary-move-article
1545 (gnus-check-backend-function
1546 'request-move-article gnus-newsgroup-name)]
1547 ["Copy article..." gnus-summary-copy-article t]
1548 ["Crosspost article..." gnus-summary-crosspost-article
1549 (gnus-check-backend-function
1550 'request-replace-article gnus-newsgroup-name)]
1551 ["Import file..." gnus-summary-import-article t]
1552 ["Check if posted" gnus-summary-article-posted-p t]
1553 ["Edit article" gnus-summary-edit-article
1554 (not (gnus-group-read-only-p))]
1555 ["Delete article" gnus-summary-delete-article
1556 (gnus-check-backend-function
1557 'request-expire-articles gnus-newsgroup-name)]
1558 ["Query respool" gnus-summary-respool-query t]
1559 ["Delete expirable articles" gnus-summary-expire-articles-now
1560 (gnus-check-backend-function
1561 'request-expire-articles gnus-newsgroup-name)])
1563 ["Uudecode" gnus-uu-decode-uu t]
1564 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1565 ["Unshar" gnus-uu-decode-unshar t]
1566 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1567 ["Save" gnus-uu-decode-save t]
1568 ["Binhex" gnus-uu-decode-binhex t]
1569 ["Postscript" gnus-uu-decode-postscript t])
1571 ["Enter article" gnus-cache-enter-article t]
1572 ["Remove article" gnus-cache-remove-article t])
1573 ["Select article buffer" gnus-summary-select-article-buffer t]
1574 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1575 ["Isearch article..." gnus-summary-isearch-article t]
1576 ["Beginning of the article" gnus-summary-beginning-of-article t]
1577 ["End of the article" gnus-summary-end-of-article t]
1578 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1579 ["Fetch referenced articles" gnus-summary-refer-references t]
1580 ["Fetch current thread" gnus-summary-refer-thread t]
1581 ["Fetch article with id..." gnus-summary-refer-article t]
1582 ["Redisplay" gnus-summary-show-article t])))
1584 gnus-summary-article-menu gnus-summary-mode-map ""
1585 (cons "Article" innards))
1588 gnus-article-commands-menu gnus-article-mode-map ""
1589 (cons "Commands" innards)))
1592 gnus-summary-thread-menu gnus-summary-mode-map ""
1594 ["Toggle threading" gnus-summary-toggle-threads t]
1595 ["Hide threads" gnus-summary-hide-all-threads t]
1596 ["Show threads" gnus-summary-show-all-threads t]
1597 ["Hide thread" gnus-summary-hide-thread t]
1598 ["Show thread" gnus-summary-show-thread t]
1599 ["Go to next thread" gnus-summary-next-thread t]
1600 ["Go to previous thread" gnus-summary-prev-thread t]
1601 ["Go down thread" gnus-summary-down-thread t]
1602 ["Go up thread" gnus-summary-up-thread t]
1603 ["Top of thread" gnus-summary-top-thread t]
1604 ["Mark thread as read" gnus-summary-kill-thread t]
1605 ["Lower thread score" gnus-summary-lower-thread t]
1606 ["Raise thread score" gnus-summary-raise-thread t]
1607 ["Rethread current" gnus-summary-rethread-current t]
1611 gnus-summary-post-menu gnus-summary-mode-map ""
1613 ["Post an article" gnus-summary-post-news t]
1614 ["Followup" gnus-summary-followup t]
1615 ["Followup and yank" gnus-summary-followup-with-original t]
1616 ["Supersede article" gnus-summary-supersede-article t]
1617 ["Cancel article" gnus-summary-cancel-article t]
1618 ["Reply" gnus-summary-reply t]
1619 ["Reply and yank" gnus-summary-reply-with-original t]
1620 ["Wide reply" gnus-summary-wide-reply t]
1621 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1622 ["Mail forward" gnus-summary-mail-forward t]
1623 ["Post forward" gnus-summary-post-forward t]
1624 ["Digest and mail" gnus-uu-digest-mail-forward t]
1625 ["Digest and post" gnus-uu-digest-post-forward t]
1626 ["Resend message" gnus-summary-resend-message t]
1627 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1628 ["Send a mail" gnus-summary-mail-other-window t]
1629 ["Uuencode and post" gnus-uu-post-news t]
1630 ["Followup via news" gnus-summary-followup-to-mail t]
1631 ["Followup via news and yank"
1632 gnus-summary-followup-to-mail-with-original t]
1634 ;;["Send" gnus-summary-send-draft t]
1635 ;;["Send bounced" gnus-resend-bounced-mail t])
1639 gnus-summary-misc-menu gnus-summary-mode-map ""
1642 ["Mark as read" gnus-summary-mark-as-read-forward t]
1643 ["Mark same subject and select"
1644 gnus-summary-kill-same-subject-and-select t]
1645 ["Mark same subject" gnus-summary-kill-same-subject t]
1646 ["Catchup" gnus-summary-catchup t]
1647 ["Catchup all" gnus-summary-catchup-all t]
1648 ["Catchup to here" gnus-summary-catchup-to-here t]
1649 ["Catchup region" gnus-summary-mark-region-as-read t]
1650 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1652 ["Tick" gnus-summary-tick-article-forward t]
1653 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1654 ["Remove marks" gnus-summary-clear-mark-forward t]
1655 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1656 ["Set bookmark" gnus-summary-set-bookmark t]
1657 ["Remove bookmark" gnus-summary-remove-bookmark t])
1659 ["Marks..." gnus-summary-limit-to-marks t]
1660 ["Subject..." gnus-summary-limit-to-subject t]
1661 ["Author..." gnus-summary-limit-to-author t]
1662 ["Age..." gnus-summary-limit-to-age t]
1663 ["Score" gnus-summary-limit-to-score t]
1664 ["Unread" gnus-summary-limit-to-unread t]
1665 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1666 ["Articles" gnus-summary-limit-to-articles t]
1667 ["Pop limit" gnus-summary-pop-limit t]
1668 ["Show dormant" gnus-summary-limit-include-dormant t]
1669 ["Hide childless dormant"
1670 gnus-summary-limit-exclude-childless-dormant t]
1671 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1672 ["Show expunged" gnus-summary-show-all-expunged t])
1674 ["Set mark" gnus-summary-mark-as-processable t]
1675 ["Remove mark" gnus-summary-unmark-as-processable t]
1676 ["Remove all marks" gnus-summary-unmark-all-processable t]
1677 ["Mark above" gnus-uu-mark-over t]
1678 ["Mark series" gnus-uu-mark-series t]
1679 ["Mark region" gnus-uu-mark-region t]
1680 ["Unmark region" gnus-uu-unmark-region t]
1681 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1682 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1683 ["Mark all" gnus-uu-mark-all t]
1684 ["Mark buffer" gnus-uu-mark-buffer t]
1685 ["Mark sparse" gnus-uu-mark-sparse t]
1686 ["Mark thread" gnus-uu-mark-thread t]
1687 ["Unmark thread" gnus-uu-unmark-thread t]
1688 ("Process Mark Sets"
1689 ["Kill" gnus-summary-kill-process-mark t]
1690 ["Yank" gnus-summary-yank-process-mark
1691 gnus-newsgroup-process-stack]
1692 ["Save" gnus-summary-save-process-mark t]))
1694 ["Page forward" gnus-summary-next-page t]
1695 ["Page backward" gnus-summary-prev-page t]
1696 ["Line forward" gnus-summary-scroll-up t])
1698 ["Next unread article" gnus-summary-next-unread-article t]
1699 ["Previous unread article" gnus-summary-prev-unread-article t]
1700 ["Next article" gnus-summary-next-article t]
1701 ["Previous article" gnus-summary-prev-article t]
1702 ["Next unread subject" gnus-summary-next-unread-subject t]
1703 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1704 ["Next article same subject" gnus-summary-next-same-subject t]
1705 ["Previous article same subject" gnus-summary-prev-same-subject t]
1706 ["First unread article" gnus-summary-first-unread-article t]
1707 ["Best unread article" gnus-summary-best-unread-article t]
1708 ["Go to subject number..." gnus-summary-goto-subject t]
1709 ["Go to article number..." gnus-summary-goto-article t]
1710 ["Go to the last article" gnus-summary-goto-last-article t]
1711 ["Pop article off history" gnus-summary-pop-article t])
1713 ["Sort by number" gnus-summary-sort-by-number t]
1714 ["Sort by author" gnus-summary-sort-by-author t]
1715 ["Sort by subject" gnus-summary-sort-by-subject t]
1716 ["Sort by date" gnus-summary-sort-by-date t]
1717 ["Sort by score" gnus-summary-sort-by-score t]
1718 ["Sort by lines" gnus-summary-sort-by-lines t])
1720 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1721 ["Describe group" gnus-summary-describe-group t]
1722 ["Read manual" gnus-info-find-node t])
1724 ["Pick and read" gnus-pick-mode t]
1725 ["Binary" gnus-binary-mode t])
1727 ["Regenerate" gnus-summary-prepare t]
1728 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1729 ["Toggle threading" gnus-summary-toggle-threads t])
1730 ["Filter articles..." gnus-summary-execute-command t]
1731 ["Run command on subjects..." gnus-summary-universal-argument t]
1732 ["Search articles forward..." gnus-summary-search-article-forward t]
1733 ["Search articles backward..." gnus-summary-search-article-backward t]
1734 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1735 ["Expand window" gnus-summary-expand-window t]
1736 ["Expire expirable articles" gnus-summary-expire-articles
1737 (gnus-check-backend-function
1738 'request-expire-articles gnus-newsgroup-name)]
1739 ["Edit local kill file" gnus-summary-edit-local-kill t]
1740 ["Edit main kill file" gnus-summary-edit-global-kill t]
1741 ["Edit group parameters" gnus-summary-edit-parameters t]
1743 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1744 ["Catchup all and exit" gnus-summary-catchup-and-exit t]
1745 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1746 ["Exit group" gnus-summary-exit t]
1747 ["Exit group without updating" gnus-summary-exit-no-update t]
1748 ["Exit and goto next group" gnus-summary-next-group t]
1749 ["Exit and goto prev group" gnus-summary-prev-group t]
1750 ["Reselect group" gnus-summary-reselect-current-group t]
1751 ["Rescan group" gnus-summary-rescan-group t]
1752 ["Update dribble" gnus-summary-save-newsrc t])))
1754 (gnus-run-hooks 'gnus-summary-menu-hook)))
1756 (defun gnus-score-set-default (var value)
1757 "A version of set that updates the GNU Emacs menu-bar."
1759 ;; It is the message that forces the active status to be updated.
1762 (defun gnus-make-score-map (type)
1763 "Make a summary score map of type TYPE."
1766 (let ((headers '(("author" "from" string)
1767 ("subject" "subject" string)
1768 ("article body" "body" string)
1769 ("article head" "head" string)
1770 ("xref" "xref" string)
1771 ("lines" "lines" number)
1772 ("followups to author" "followup" string)))
1773 (types '((number ("less than" <)
1776 (string ("substring" s)
1780 (perms '(("temporary" (current-time-string))
1788 (if (eq type 'lower)
1793 (setq header (car headers))
1799 (let ((ts (cdr (assoc (nth 2 header) types)))
1815 'gnus-summary-score-entry
1817 (if (or (string= (nth 1 header)
1819 (string= (nth 1 header)
1822 (list 'gnus-summary-header
1824 (list 'quote (nth 1 (car ts)))
1825 (list 'gnus-score-default nil)
1831 (list (nreverse outp))))
1834 (list (nreverse outt))))
1836 (setq headers (cdr headers)))
1837 (list (nreverse outh))))))))
1841 (defun gnus-summary-mode (&optional group)
1842 "Major mode for reading articles.
1844 All normal editing commands are switched off.
1845 \\<gnus-summary-mode-map>
1846 Each line in this buffer represents one article. To read an
1847 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
1848 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
1851 You can also post articles and send mail from this buffer. To
1852 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
1853 of an article, type `\\[gnus-summary-reply]'.
1855 There are approx. one gazillion commands you can execute in this
1856 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
1858 The following commands are available:
1860 \\{gnus-summary-mode-map}"
1862 (when (gnus-visual-p 'summary-menu 'menu)
1863 (gnus-summary-make-menu-bar))
1864 (kill-all-local-variables)
1865 (gnus-summary-make-local-variables)
1866 (gnus-make-thread-indent-array)
1867 (gnus-simplify-mode-line)
1868 (setq major-mode 'gnus-summary-mode)
1869 (setq mode-name "Summary")
1870 (make-local-variable 'minor-mode-alist)
1871 (use-local-map gnus-summary-mode-map)
1872 (buffer-disable-undo (current-buffer))
1873 (setq buffer-read-only t) ;Disable modification
1874 (setq truncate-lines t)
1875 (setq selective-display t)
1876 (setq selective-display-ellipses t) ;Display `...'
1877 (gnus-summary-set-display-table)
1878 (gnus-set-default-directory)
1879 (setq gnus-newsgroup-name group)
1880 (make-local-variable 'gnus-summary-line-format)
1881 (make-local-variable 'gnus-summary-line-format-spec)
1882 (make-local-variable 'gnus-summary-dummy-line-format)
1883 (make-local-variable 'gnus-summary-dummy-line-format-spec)
1884 (make-local-variable 'gnus-summary-mark-positions)
1885 (make-local-hook 'post-command-hook)
1886 (add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
1887 (make-local-hook 'pre-command-hook)
1888 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
1889 (gnus-run-hooks 'gnus-summary-mode-hook)
1890 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
1891 (gnus-update-summary-mark-positions))
1893 (defun gnus-summary-make-local-variables ()
1894 "Make all the local summary buffer variables."
1895 (let ((locals gnus-summary-local-variables)
1897 (while (setq local (pop locals))
1900 (if (eq (cdr local) 'global)
1901 ;; Copy the global value of the variable.
1902 (setq global (symbol-value (car local)))
1903 ;; Use the value from the list.
1904 (setq global (eval (cdr local))))
1905 (make-local-variable (car local))
1906 (set (car local) global))
1907 ;; Simple nil-valued local variable.
1908 (make-local-variable local)
1911 (defun gnus-summary-clear-local-variables ()
1912 (let ((locals gnus-summary-local-variables))
1914 (if (consp (car locals))
1915 (and (vectorp (caar locals))
1916 (set (caar locals) nil))
1917 (and (vectorp (car locals))
1918 (set (car locals) nil)))
1919 (setq locals (cdr locals)))))
1921 ;; Summary data functions.
1923 (defmacro gnus-data-number (data)
1926 (defmacro gnus-data-set-number (data number)
1927 `(setcar ,data ,number))
1929 (defmacro gnus-data-mark (data)
1932 (defmacro gnus-data-set-mark (data mark)
1933 `(setcar (nthcdr 1 ,data) ,mark))
1935 (defmacro gnus-data-pos (data)
1938 (defmacro gnus-data-set-pos (data pos)
1939 `(setcar (nthcdr 2 ,data) ,pos))
1941 (defmacro gnus-data-header (data)
1944 (defmacro gnus-data-set-header (data header)
1945 `(setf (nth 3 ,data) ,header))
1947 (defmacro gnus-data-level (data)
1950 (defmacro gnus-data-unread-p (data)
1951 `(= (nth 1 ,data) gnus-unread-mark))
1953 (defmacro gnus-data-read-p (data)
1954 `(/= (nth 1 ,data) gnus-unread-mark))
1956 (defmacro gnus-data-pseudo-p (data)
1957 `(consp (nth 3 ,data)))
1959 (defmacro gnus-data-find (number)
1960 `(assq ,number gnus-newsgroup-data))
1962 (defmacro gnus-data-find-list (number &optional data)
1963 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
1964 (memq (assq ,number bdata)
1967 (defmacro gnus-data-make (number mark pos header level)
1968 `(list ,number ,mark ,pos ,header ,level))
1970 (defun gnus-data-enter (after-article number mark pos header level offset)
1971 (let ((data (gnus-data-find-list after-article)))
1973 (error "No such article: %d" after-article))
1974 (setcdr data (cons (gnus-data-make number mark pos header level)
1976 (setq gnus-newsgroup-data-reverse nil)
1977 (gnus-data-update-list (cddr data) offset)))
1979 (defun gnus-data-enter-list (after-article list &optional offset)
1981 (let ((data (and after-article (gnus-data-find-list after-article)))
1983 (or data (not after-article) (error "No such article: %d" after-article))
1984 ;; Find the last element in the list to be spliced into the main
1987 (setq list (cdr list)))
1990 (setcdr list gnus-newsgroup-data)
1991 (setq gnus-newsgroup-data ilist)
1993 (gnus-data-update-list (cdr list) offset)))
1994 (setcdr list (cdr data))
1997 (gnus-data-update-list (cdr list) offset)))
1998 (setq gnus-newsgroup-data-reverse nil))))
2000 (defun gnus-data-remove (article &optional offset)
2001 (let ((data gnus-newsgroup-data))
2002 (if (= (gnus-data-number (car data)) article)
2004 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2005 gnus-newsgroup-data-reverse nil)
2007 (gnus-data-update-list gnus-newsgroup-data offset)))
2009 (when (= (gnus-data-number (cadr data)) article)
2010 (setcdr data (cddr data))
2012 (gnus-data-update-list (cdr data) offset))
2014 gnus-newsgroup-data-reverse nil))
2015 (setq data (cdr data))))))
2017 (defmacro gnus-data-list (backward)
2019 (or gnus-newsgroup-data-reverse
2020 (setq gnus-newsgroup-data-reverse
2021 (reverse gnus-newsgroup-data)))
2022 gnus-newsgroup-data))
2024 (defun gnus-data-update-list (data offset)
2025 "Add OFFSET to the POS of all data entries in DATA."
2027 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2028 (setq data (cdr data))))
2030 (defun gnus-data-compute-positions ()
2031 "Compute the positions of all articles."
2032 (let ((data gnus-newsgroup-data)
2035 (when (setq pos (text-property-any
2036 (point-min) (point-max)
2037 'gnus-number (gnus-data-number (car data))))
2038 (gnus-data-set-pos (car data) (+ pos 3)))
2039 (setq data (cdr data)))))
2041 (defun gnus-summary-article-pseudo-p (article)
2042 "Say whether this article is a pseudo article or not."
2043 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2045 (defmacro gnus-summary-article-sparse-p (article)
2046 "Say whether this article is a sparse article or not."
2047 `(memq ,article gnus-newsgroup-sparse))
2049 (defmacro gnus-summary-article-ancient-p (article)
2050 "Say whether this article is a sparse article or not."
2051 `(memq ,article gnus-newsgroup-ancient))
2053 (defun gnus-article-parent-p (number)
2054 "Say whether this article is a parent or not."
2055 (let ((data (gnus-data-find-list number)))
2056 (and (cdr data) ; There has to be an article after...
2057 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2058 (gnus-data-level (nth 1 data))))))
2060 (defun gnus-article-children (number)
2061 "Return a list of all children to NUMBER."
2062 (let* ((data (gnus-data-find-list number))
2063 (level (gnus-data-level (car data)))
2065 (setq data (cdr data))
2067 (= (gnus-data-level (car data)) (1+ level)))
2068 (push (gnus-data-number (car data)) children)
2069 (setq data (cdr data)))
2072 (defmacro gnus-summary-skip-intangible ()
2073 "If the current article is intangible, then jump to a different article."
2074 '(let ((to (get-text-property (point) 'gnus-intangible)))
2075 (and to (gnus-summary-goto-subject to))))
2077 (defmacro gnus-summary-article-intangible-p ()
2078 "Say whether this article is intangible or not."
2079 '(get-text-property (point) 'gnus-intangible))
2081 (defun gnus-article-read-p (article)
2082 "Say whether ARTICLE is read or not."
2083 (not (or (memq article gnus-newsgroup-marked)
2084 (memq article gnus-newsgroup-unreads)
2085 (memq article gnus-newsgroup-unselected)
2086 (memq article gnus-newsgroup-dormant))))
2088 ;; Some summary mode macros.
2090 (defmacro gnus-summary-article-number ()
2091 "The article number of the article on the current line.
2092 If there isn's an article number here, then we return the current
2095 (gnus-summary-skip-intangible)
2096 (or (get-text-property (point) 'gnus-number)
2097 (gnus-summary-last-subject))))
2099 (defmacro gnus-summary-article-header (&optional number)
2100 "Return the header of article NUMBER."
2101 `(gnus-data-header (gnus-data-find
2102 ,(or number '(gnus-summary-article-number)))))
2104 (defmacro gnus-summary-thread-level (&optional number)
2105 "Return the level of thread that starts with article NUMBER."
2106 `(if (and (eq gnus-summary-make-false-root 'dummy)
2107 (get-text-property (point) 'gnus-intangible))
2109 (gnus-data-level (gnus-data-find
2110 ,(or number '(gnus-summary-article-number))))))
2112 (defmacro gnus-summary-article-mark (&optional number)
2113 "Return the mark of article NUMBER."
2114 `(gnus-data-mark (gnus-data-find
2115 ,(or number '(gnus-summary-article-number)))))
2117 (defmacro gnus-summary-article-pos (&optional number)
2118 "Return the position of the line of article NUMBER."
2119 `(gnus-data-pos (gnus-data-find
2120 ,(or number '(gnus-summary-article-number)))))
2122 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2123 (defmacro gnus-summary-article-subject (&optional number)
2124 "Return current subject string or nil if nothing."
2127 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2128 '(gnus-data-header (assq (gnus-summary-article-number)
2129 gnus-newsgroup-data)))))
2132 (mail-header-subject headers))))
2134 (defmacro gnus-summary-article-score (&optional number)
2135 "Return current article score."
2136 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2137 gnus-newsgroup-scored))
2138 gnus-summary-default-score 0))
2140 (defun gnus-summary-article-children (&optional number)
2141 "Return a list of article numbers that are children of article NUMBER."
2142 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2143 (level (gnus-data-level (car data)))
2145 (while (and (setq data (cdr data))
2146 (> (setq l (gnus-data-level (car data))) level))
2147 (and (= (1+ level) l)
2148 (push (gnus-data-number (car data))
2150 (nreverse children)))
2152 (defun gnus-summary-article-parent (&optional number)
2153 "Return the article number of the parent of article NUMBER."
2154 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2155 (gnus-data-list t)))
2156 (level (gnus-data-level (car data))))
2158 () ; This is a root.
2159 ;; We search until we find an article with a level less than
2160 ;; this one. That function has to be the parent.
2161 (while (and (setq data (cdr data))
2162 (not (< (gnus-data-level (car data)) level))))
2163 (and data (gnus-data-number (car data))))))
2165 (defun gnus-unread-mark-p (mark)
2166 "Say whether MARK is the unread mark."
2167 (= mark gnus-unread-mark))
2169 (defun gnus-read-mark-p (mark)
2170 "Say whether MARK is one of the marks that mark as read.
2171 This is all marks except unread, ticked, dormant, and expirable."
2172 (not (or (= mark gnus-unread-mark)
2173 (= mark gnus-ticked-mark)
2174 (= mark gnus-dormant-mark)
2175 (= mark gnus-expirable-mark))))
2177 (defmacro gnus-article-mark (number)
2178 "Return the MARK of article NUMBER.
2179 This macro should only be used when computing the mark the \"first\"
2180 time; i.e., when generating the summary lines. After that,
2181 `gnus-summary-article-mark' should be used to examine the
2184 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2185 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2186 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2187 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2188 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2189 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2190 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2191 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2192 gnus-ancient-mark))))
2194 ;; Saving hidden threads.
2196 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2197 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2199 (defmacro gnus-save-hidden-threads (&rest forms)
2200 "Save hidden threads, eval FORMS, and restore the hidden threads."
2201 (let ((config (make-symbol "config")))
2202 `(let ((,config (gnus-hidden-threads-configuration)))
2206 (gnus-restore-hidden-threads-configuration ,config)))))
2208 (defun gnus-hidden-threads-configuration ()
2209 "Return the current hidden threads configuration."
2212 (goto-char (point-min))
2213 (while (search-forward "\r" nil t)
2214 (push (1- (point)) config))
2217 (defun gnus-restore-hidden-threads-configuration (config)
2218 "Restore hidden threads configuration from CONFIG."
2219 (let (point buffer-read-only)
2220 (while (setq point (pop config))
2221 (when (and (< point (point-max))
2223 (= (following-char) ?\n))
2224 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2226 ;; Various summary mode internalish functions.
2228 (defun gnus-mouse-pick-article (e)
2231 (gnus-summary-next-page nil t))
2233 (defun gnus-summary-set-display-table ()
2234 ;; Change the display table. Odd characters have a tendency to mess
2235 ;; up nicely formatted displays - we make all possible glyphs
2236 ;; display only a single character.
2238 ;; We start from the standard display table, if any.
2239 (let ((table (or (copy-sequence standard-display-table)
2240 (make-display-table)))
2242 ;; Nix out all the control chars...
2243 (while (>= (setq i (1- i)) 0)
2244 (aset table i [??]))
2245 ;; ... but not newline and cr, of course. (cr is necessary for the
2246 ;; selective display).
2247 (aset table ?\n nil)
2248 (aset table ?\r nil)
2249 ;; We keep TAB as well.
2250 (aset table ?\t nil)
2251 ;; We nix out any glyphs over 126 that are not set already.
2253 (while (>= (setq i (1- i)) 127)
2254 ;; Only modify if the entry is nil.
2255 (unless (aref table i)
2256 (aset table i [??]))))
2257 (setq buffer-display-table table)))
2259 (defun gnus-summary-setup-buffer (group)
2260 "Initialize summary buffer."
2261 (let ((buffer (concat "*Summary " group "*")))
2262 (if (get-buffer buffer)
2265 (setq gnus-summary-buffer (current-buffer))
2266 (not gnus-newsgroup-prepared))
2267 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2268 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
2269 (gnus-add-current-to-buffer-list)
2270 (gnus-summary-mode group)
2272 (gnus-carpal-setup-buffer 'summary))
2273 (unless gnus-single-article-buffer
2274 (make-local-variable 'gnus-article-buffer)
2275 (make-local-variable 'gnus-article-current)
2276 (make-local-variable 'gnus-original-article-buffer))
2277 (setq gnus-newsgroup-name group)
2280 (defun gnus-set-global-variables ()
2281 ;; Set the global equivalents of the summary buffer-local variables
2282 ;; to the latest values they had. These reflect the summary buffer
2283 ;; that was in action when the last article was fetched.
2284 (when (eq major-mode 'gnus-summary-mode)
2285 (setq gnus-summary-buffer (current-buffer))
2286 (let ((name gnus-newsgroup-name)
2287 (marked gnus-newsgroup-marked)
2288 (unread gnus-newsgroup-unreads)
2289 (headers gnus-current-headers)
2290 (data gnus-newsgroup-data)
2291 (summary gnus-summary-buffer)
2292 (article-buffer gnus-article-buffer)
2293 (original gnus-original-article-buffer)
2294 (gac gnus-article-current)
2295 (reffed gnus-reffed-article-number)
2296 (score-file gnus-current-score-file))
2298 (set-buffer gnus-group-buffer)
2299 (setq gnus-newsgroup-name name
2300 gnus-newsgroup-marked marked
2301 gnus-newsgroup-unreads unread
2302 gnus-current-headers headers
2303 gnus-newsgroup-data data
2304 gnus-article-current gac
2305 gnus-summary-buffer summary
2306 gnus-article-buffer article-buffer
2307 gnus-original-article-buffer original
2308 gnus-reffed-article-number reffed
2309 gnus-current-score-file score-file)
2310 ;; The article buffer also has local variables.
2311 (when (gnus-buffer-live-p gnus-article-buffer)
2312 (set-buffer gnus-article-buffer)
2313 (setq gnus-summary-buffer summary))))))
2315 (defun gnus-summary-article-unread-p (article)
2316 "Say whether ARTICLE is unread or not."
2317 (memq article gnus-newsgroup-unreads))
2319 (defun gnus-summary-first-article-p (&optional article)
2320 "Return whether ARTICLE is the first article in the buffer."
2321 (if (not (setq article (or article (gnus-summary-article-number))))
2323 (eq article (caar gnus-newsgroup-data))))
2325 (defun gnus-summary-last-article-p (&optional article)
2326 "Return whether ARTICLE is the last article in the buffer."
2327 (if (not (setq article (or article (gnus-summary-article-number))))
2328 t ; All non-existent numbers are the last article. :-)
2329 (not (cdr (gnus-data-find-list article)))))
2331 (defun gnus-make-thread-indent-array ()
2333 (unless (and gnus-thread-indent-array
2334 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2335 (setq gnus-thread-indent-array (make-vector 201 "")
2336 gnus-thread-indent-array-level gnus-thread-indent-level)
2338 (aset gnus-thread-indent-array n
2339 (make-string (* n gnus-thread-indent-level) ? ))
2342 (defun gnus-update-summary-mark-positions ()
2343 "Compute where the summary marks are to go."
2345 (when (gnus-buffer-exists-p gnus-summary-buffer)
2346 (set-buffer gnus-summary-buffer))
2347 (let ((gnus-replied-mark 129)
2348 (gnus-score-below-mark 130)
2349 (gnus-score-over-mark 130)
2350 (gnus-download-mark 131)
2351 (spec gnus-summary-line-format-spec)
2352 thread gnus-visual pos)
2354 (gnus-set-work-buffer)
2355 (let ((gnus-summary-line-format-spec spec)
2356 (gnus-newsgroup-downloadable '((0 . t))))
2357 (gnus-summary-insert-line
2358 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2359 (goto-char (point-min))
2360 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2362 (goto-char (point-min))
2363 (push (cons 'replied (and (search-forward "\201" nil t)
2366 (goto-char (point-min))
2367 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2369 (goto-char (point-min))
2370 (push (cons 'download
2371 (and (search-forward "\203" nil t) (- (point) 2)))
2373 (setq gnus-summary-mark-positions pos))))
2375 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2376 "Insert a dummy root in the summary buffer."
2378 (gnus-add-text-properties
2379 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2380 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2382 (defun gnus-summary-insert-line (gnus-tmp-header
2383 gnus-tmp-level gnus-tmp-current
2384 gnus-tmp-unread gnus-tmp-replied
2385 gnus-tmp-expirable gnus-tmp-subject-or-nil
2386 &optional gnus-tmp-dummy gnus-tmp-score
2388 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2389 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2390 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2391 (gnus-tmp-score-char
2392 (if (or (null gnus-summary-default-score)
2393 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2394 gnus-summary-zcore-fuzz))
2396 (if (< gnus-tmp-score gnus-summary-default-score)
2397 gnus-score-below-mark gnus-score-over-mark)))
2399 (cond (gnus-tmp-process gnus-process-mark)
2400 ((memq gnus-tmp-current gnus-newsgroup-cached)
2402 (gnus-tmp-replied gnus-replied-mark)
2403 ((memq gnus-tmp-current gnus-newsgroup-saved)
2405 (t gnus-unread-mark)))
2406 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2409 ((string-match "<[^>]+> *$" gnus-tmp-from)
2410 (let ((beg (match-beginning 0)))
2411 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2412 (substring gnus-tmp-from (1+ (match-beginning 0))
2413 (1- (match-end 0))))
2414 (substring gnus-tmp-from 0 beg))))
2415 ((string-match "(.+)" gnus-tmp-from)
2416 (substring gnus-tmp-from
2417 (1+ (match-beginning 0)) (1- (match-end 0))))
2419 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2420 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2421 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2422 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2423 (buffer-read-only nil))
2424 (when (string= gnus-tmp-name "")
2425 (setq gnus-tmp-name gnus-tmp-from))
2426 (unless (numberp gnus-tmp-lines)
2427 (setq gnus-tmp-lines 0))
2428 (gnus-put-text-property
2430 (progn (eval gnus-summary-line-format-spec) (point))
2431 'gnus-number gnus-tmp-number)
2432 (when (gnus-visual-p 'summary-highlight 'highlight)
2434 (gnus-run-hooks 'gnus-summary-update-hook)
2437 (defun gnus-summary-update-line (&optional dont-update)
2438 ;; Update summary line after change.
2439 (when (and gnus-summary-default-score
2440 (not gnus-summary-inhibit-highlight))
2441 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2442 (article (gnus-summary-article-number))
2443 (score (gnus-summary-article-score article)))
2445 (if (and gnus-summary-mark-below
2446 (< (gnus-summary-article-score)
2447 gnus-summary-mark-below))
2448 ;; This article has a low score, so we mark it as read.
2449 (when (memq article gnus-newsgroup-unreads)
2450 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2451 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2452 ;; This article was previously marked as read on account
2453 ;; of a low score, but now it has risen, so we mark it as
2455 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2456 (gnus-summary-update-mark
2457 (if (or (null gnus-summary-default-score)
2458 (<= (abs (- score gnus-summary-default-score))
2459 gnus-summary-zcore-fuzz))
2461 (if (< score gnus-summary-default-score)
2462 gnus-score-below-mark gnus-score-over-mark))
2464 ;; Do visual highlighting.
2465 (when (gnus-visual-p 'summary-highlight 'highlight)
2466 (gnus-run-hooks 'gnus-summary-update-hook)))))
2468 (defvar gnus-tmp-new-adopts nil)
2470 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2471 "Return the number of articles in THREAD.
2472 This may be 0 in some cases -- if none of the articles in
2473 the thread are to be displayed."
2475 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2477 ((not (listp thread))
2479 ((and (consp thread) (cdr thread))
2482 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2485 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2488 (when (and level (zerop level) gnus-tmp-new-adopts)
2491 'gnus-summary-number-of-articles-in-thread
2492 gnus-tmp-new-adopts))))
2494 (if (> number 1) gnus-not-empty-thread-mark
2495 gnus-empty-thread-mark)
2498 (defun gnus-summary-set-local-parameters (group)
2499 "Go through the local params of GROUP and set all variable specs in that list."
2500 (let ((params (gnus-group-find-parameter group))
2503 (setq elem (car params)
2504 params (cdr params))
2505 (and (consp elem) ; Has to be a cons.
2506 (consp (cdr elem)) ; The cdr has to be a list.
2507 (symbolp (car elem)) ; Has to be a symbol in there.
2508 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2509 (ignore-errors ; So we set it.
2510 (make-local-variable (car elem))
2511 (set (car elem) (eval (nth 1 elem))))))))
2513 (defun gnus-summary-read-group (group &optional show-all no-article
2514 kill-buffer no-display backward)
2515 "Start reading news in newsgroup GROUP.
2516 If SHOW-ALL is non-nil, already read articles are also listed.
2517 If NO-ARTICLE is non-nil, no article is selected initially.
2518 If NO-DISPLAY, don't generate a summary buffer."
2522 (let ((gnus-auto-select-next nil))
2523 (or (gnus-summary-read-group-1
2524 group show-all no-article
2525 kill-buffer no-display)
2526 (setq show-all nil)))))
2527 (eq gnus-auto-select-next 'quietly))
2528 (set-buffer gnus-group-buffer)
2529 ;; The entry function called above goes to the next
2530 ;; group automatically, so we go two groups back
2531 ;; if we are searching for the previous group.
2533 (gnus-group-prev-unread-group 2))
2534 (if (not (equal group (gnus-group-group-name)))
2535 (setq group (gnus-group-group-name))
2539 (defun gnus-summary-read-group-1 (group show-all no-article
2540 kill-buffer no-display)
2541 ;; Killed foreign groups can't be entered.
2542 (when (and (not (gnus-group-native-p group))
2543 (not (gnus-gethash group gnus-newsrc-hashtb)))
2544 (error "Dead non-native groups can't be entered"))
2545 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2546 (let* ((new-group (gnus-summary-setup-buffer group))
2547 (quit-config (gnus-group-quit-config group))
2548 (did-select (and new-group (gnus-select-newsgroup group show-all))))
2550 ;; This summary buffer exists already, so we just select it.
2552 (gnus-set-global-variables)
2554 (gnus-kill-or-deaden-summary kill-buffer))
2555 (gnus-configure-windows 'summary 'force)
2556 (gnus-set-mode-line 'summary)
2557 (gnus-summary-position-point)
2560 ;; We couldn't select this group.
2562 (when (and (eq major-mode 'gnus-summary-mode)
2563 (not (equal (current-buffer) kill-buffer)))
2564 (kill-buffer (current-buffer))
2565 (if (not quit-config)
2567 ;; Update the info -- marks might need to be removed,
2569 (gnus-summary-update-info)
2570 (set-buffer gnus-group-buffer)
2571 (gnus-group-jump-to-group group)
2572 (gnus-group-next-unread-group 1))
2573 (gnus-handle-ephemeral-exit quit-config)))
2574 (gnus-message 3 "Can't select group")
2576 ;; The user did a `C-g' while prompting for number of articles,
2577 ;; so we exit this group.
2578 ((eq did-select 'quit)
2579 (and (eq major-mode 'gnus-summary-mode)
2580 (not (equal (current-buffer) kill-buffer))
2581 (kill-buffer (current-buffer)))
2583 (gnus-kill-or-deaden-summary kill-buffer))
2584 (if (not quit-config)
2586 (set-buffer gnus-group-buffer)
2587 (gnus-group-jump-to-group group)
2588 (gnus-group-next-unread-group 1)
2589 (gnus-configure-windows 'group 'force))
2590 (gnus-handle-ephemeral-exit quit-config))
2591 ;; Finally signal the quit.
2593 ;; The group was successfully selected.
2595 (gnus-set-global-variables)
2596 ;; Save the active value in effect when the group was entered.
2597 (setq gnus-newsgroup-active
2599 (gnus-active gnus-newsgroup-name)))
2600 ;; You can change the summary buffer in some way with this hook.
2601 (gnus-run-hooks 'gnus-select-group-hook)
2602 ;; Set any local variables in the group parameters.
2603 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2604 (gnus-update-format-specifications
2605 nil 'summary 'summary-mode 'summary-dummy)
2606 ;; Do score processing.
2607 (when gnus-use-scoring
2608 (gnus-possibly-score-headers))
2609 ;; Check whether to fill in the gaps in the threads.
2610 (when gnus-build-sparse-threads
2611 (gnus-build-sparse-threads))
2612 ;; Find the initial limit.
2613 (if gnus-show-threads
2615 (let ((gnus-newsgroup-dormant nil))
2616 (gnus-summary-initial-limit show-all))
2617 (gnus-summary-initial-limit show-all))
2618 (setq gnus-newsgroup-limit
2620 (lambda (header) (mail-header-number header))
2621 gnus-newsgroup-headers)))
2622 ;; Generate the summary buffer.
2624 (gnus-summary-prepare))
2625 (when gnus-use-trees
2626 (gnus-tree-open group)
2627 (setq gnus-summary-highlight-line-function
2628 'gnus-tree-highlight-article))
2629 ;; If the summary buffer is empty, but there are some low-scored
2630 ;; articles or some excluded dormants, we include these in the
2632 (when (and (zerop (buffer-size))
2634 (cond (gnus-newsgroup-dormant
2635 (gnus-summary-limit-include-dormant))
2636 ((and gnus-newsgroup-scored show-all)
2637 (gnus-summary-limit-include-expunged t))))
2638 ;; Function `gnus-apply-kill-file' must be called in this hook.
2639 (gnus-run-hooks 'gnus-apply-kill-hook)
2640 (if (and (zerop (buffer-size))
2643 ;; This newsgroup is empty.
2644 (gnus-summary-catchup-and-exit nil t)
2645 (gnus-message 6 "No unread news")
2647 (gnus-kill-or-deaden-summary kill-buffer))
2648 ;; Return nil from this function.
2650 ;; Hide conversation thread subtrees. We cannot do this in
2651 ;; gnus-summary-prepare-hook since kill processing may not
2652 ;; work with hidden articles.
2653 (and gnus-show-threads
2654 gnus-thread-hide-subtree
2655 (gnus-summary-hide-all-threads))
2657 (gnus-kill-or-deaden-summary kill-buffer))
2658 ;; Show first unread article if requested.
2659 (if (and (not no-article)
2661 gnus-newsgroup-unreads
2662 gnus-auto-select-first)
2663 (unless (if (eq gnus-auto-select-first 'best)
2664 (gnus-summary-best-unread-article)
2665 (gnus-summary-first-unread-article))
2666 (gnus-configure-windows 'summary))
2667 ;; Don't select any articles, just move point to the first
2668 ;; article in the group.
2669 (goto-char (point-min))
2670 (gnus-summary-position-point)
2671 (gnus-configure-windows 'summary 'force)
2672 (gnus-set-mode-line 'summary))
2673 (when (get-buffer-window gnus-group-buffer t)
2674 ;; Gotta use windows, because recenter does weird stuff if
2675 ;; the current buffer ain't the displayed window.
2676 (let ((owin (selected-window)))
2677 (select-window (get-buffer-window gnus-group-buffer t))
2678 (when (gnus-group-goto-group group)
2680 (select-window owin)))
2681 ;; Mark this buffer as "prepared".
2682 (setq gnus-newsgroup-prepared t)
2683 (gnus-run-hooks 'gnus-summary-prepared-hook)
2686 (defun gnus-summary-prepare ()
2687 "Generate the summary buffer."
2689 (let ((buffer-read-only nil))
2691 (setq gnus-newsgroup-data nil
2692 gnus-newsgroup-data-reverse nil)
2693 (gnus-run-hooks 'gnus-summary-generate-hook)
2694 ;; Generate the buffer, either with threads or without.
2695 (when gnus-newsgroup-headers
2696 (gnus-summary-prepare-threads
2697 (if gnus-show-threads
2698 (gnus-sort-gathered-threads
2699 (funcall gnus-summary-thread-gathering-function
2701 (gnus-cut-threads (gnus-make-threads)))))
2702 ;; Unthreaded display.
2703 (gnus-sort-articles gnus-newsgroup-headers))))
2704 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2705 ;; Call hooks for modifying summary buffer.
2706 (goto-char (point-min))
2707 (gnus-run-hooks 'gnus-summary-prepare-hook)))
2709 (defsubst gnus-general-simplify-subject (subject)
2710 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2713 ;; Truncate the subject.
2714 (gnus-simplify-subject-functions
2715 (gnus-map-function gnus-simplify-subject-functions subject))
2716 ((numberp gnus-summary-gather-subject-limit)
2717 (setq subject (gnus-simplify-subject-re subject))
2718 (if (> (length subject) gnus-summary-gather-subject-limit)
2719 (substring subject 0 gnus-summary-gather-subject-limit)
2721 ;; Fuzzily simplify it.
2722 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2723 (gnus-simplify-subject-fuzzy subject))
2724 ;; Just remove the leading "Re:".
2726 (gnus-simplify-subject-re subject))))
2728 (if (and gnus-summary-gather-exclude-subject
2729 (string-match gnus-summary-gather-exclude-subject subject))
2730 nil ; This article shouldn't be gathered
2733 (defun gnus-summary-simplify-subject-query ()
2734 "Query where the respool algorithm would put this article."
2736 (gnus-summary-select-article)
2737 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2739 (defun gnus-gather-threads-by-subject (threads)
2740 "Gather threads by looking at Subject headers."
2741 (if (not gnus-summary-make-false-root)
2743 (let ((hashtb (gnus-make-hashtable 1024))
2746 subject hthread whole-subject)
2748 (setq subject (gnus-general-simplify-subject
2749 (setq whole-subject (mail-header-subject
2752 (if (setq hthread (gnus-gethash subject hashtb))
2754 ;; We enter a dummy root into the thread, if we
2755 ;; haven't done that already.
2756 (unless (stringp (caar hthread))
2757 (setcar hthread (list whole-subject (car hthread))))
2758 ;; We add this new gathered thread to this gathered
2760 (setcdr (car hthread)
2761 (nconc (cdar hthread) (list (car threads))))
2762 ;; Remove it from the list of threads.
2763 (setcdr prev (cdr threads))
2764 (setq threads prev))
2765 ;; Enter this thread into the hash table.
2766 (gnus-sethash subject threads hashtb)))
2768 (setq threads (cdr threads)))
2771 (defun gnus-gather-threads-by-references (threads)
2772 "Gather threads by looking at References headers."
2773 (let ((idhashtb (gnus-make-hashtable 1024))
2774 (thhashtb (gnus-make-hashtable 1024))
2777 ids references id gthread gid entered ref)
2779 (when (setq references (mail-header-references (caar threads)))
2780 (setq id (mail-header-id (caar threads))
2781 ids (gnus-split-references references)
2783 (while (setq ref (pop ids))
2784 (setq ids (delete ref ids))
2785 (if (not (setq gid (gnus-gethash ref idhashtb)))
2787 (gnus-sethash ref id idhashtb)
2788 (gnus-sethash id threads thhashtb))
2789 (setq gthread (gnus-gethash gid thhashtb))
2791 ;; We enter a dummy root into the thread, if we
2792 ;; haven't done that already.
2793 (unless (stringp (caar gthread))
2794 (setcar gthread (list (mail-header-subject (caar gthread))
2796 ;; We add this new gathered thread to this gathered
2798 (setcdr (car gthread)
2799 (nconc (cdar gthread) (list (car threads)))))
2800 ;; Add it into the thread hash table.
2801 (gnus-sethash id gthread thhashtb)
2803 ;; Remove it from the list of threads.
2804 (setcdr prev (cdr threads))
2805 (setq threads prev))))
2807 (setq threads (cdr threads)))
2810 (defun gnus-sort-gathered-threads (threads)
2811 "Sort subtreads inside each gathered thread by article number."
2812 (let ((result threads))
2814 (when (stringp (caar threads))
2815 (setcdr (car threads)
2816 (sort (cdar threads) 'gnus-thread-sort-by-number)))
2817 (setq threads (cdr threads)))
2820 (defun gnus-thread-loop-p (root thread)
2821 "Say whether ROOT is in THREAD."
2822 (let ((stack (list thread))
2825 (while (setq thread (pop stack))
2826 (setq th (cdr thread))
2828 (not (eq (caar th) root)))
2831 ;; We have found a loop.
2833 (setcdr thread (delq (car th) (cdr thread)))
2834 (if (boundp (setq ref-dep (intern "none"
2835 gnus-newsgroup-dependencies)))
2836 (setcdr (symbol-value ref-dep)
2837 (nconc (cdr (symbol-value ref-dep))
2839 (set ref-dep (list nil (car th))))
2842 ;; Push all the subthreads onto the stack.
2843 (push (cdr thread) stack)))
2846 (defun gnus-make-threads ()
2847 "Go through the dependency hashtb and find the roots. Return all threads."
2849 (while (catch 'infloop
2852 ;; Deal with self-referencing References loops.
2853 (when (and (car (symbol-value refs))
2860 (car (symbol-value refs)) thread))
2861 (cdr (symbol-value refs)))))))
2864 (unless (car (symbol-value refs))
2865 ;; These threads do not refer back to any other articles,
2866 ;; so they're roots.
2867 (setq threads (append (cdr (symbol-value refs)) threads))))
2868 gnus-newsgroup-dependencies)))
2871 ;; Build the thread tree.
2872 (defun gnus-dependencies-add-header (header dependencies force-new)
2873 "Enter HEADER into the DEPENDENCIES table if it is not already there.
2875 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
2876 if it was already present.
2878 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
2879 will not be entered in the DEPENDENCIES table. Otherwise duplicate
2880 Message-IDs will be renamed be renamed to a unique Message-ID before
2883 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
2884 (let* ((id (mail-header-id header))
2885 (id-dep (and id (intern id dependencies)))
2886 ref ref-dep ref-header)
2887 ;; Enter this `header' in the `dependencies' table.
2891 ;; The first two cases do the normal part: enter a new `header'
2892 ;; in the `dependencies' table.
2893 ((not (boundp id-dep))
2894 (set id-dep (list header)))
2895 ((null (car (symbol-value id-dep)))
2896 (setcar (symbol-value id-dep) header))
2898 ;; From here the `header' was already present in the
2899 ;; `dependencies' table.
2901 ;; Overrides an existing entry;
2902 ;; just set the header part of the entry.
2903 (setcar (symbol-value id-dep) header))
2905 ;; Renames the existing `header' to a unique Message-ID.
2906 ((not gnus-summary-ignore-duplicates)
2907 ;; An article with this Message-ID has already been seen.
2908 ;; We rename the Message-ID.
2909 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
2911 (mail-header-set-id header id))
2913 ;; The last case ignores an existing entry, except it adds any
2914 ;; additional Xrefs (in case the two articles came from different
2916 ;; Also sets `header' to `nil' meaning that the `dependencies'
2917 ;; table was *not* modified.
2919 (mail-header-set-xref
2920 (car (symbol-value id-dep))
2921 (concat (or (mail-header-xref (car (symbol-value id-dep)))
2923 (or (mail-header-xref header) "")))
2927 ;; First check if that we are not creating a References loop.
2928 (setq ref (gnus-parent-id (mail-header-references header)))
2930 (setq ref-dep (intern-soft ref dependencies))
2932 (setq ref-header (car (symbol-value ref-dep))))
2933 (if (string= id ref)
2934 ;; Yuk! This is a reference loop. Make the article be a
2938 (mail-header-set-references (car (symbol-value id-dep)) "none")
2940 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
2941 (setq ref (gnus-parent-id (mail-header-references header)))
2942 (setq ref-dep (intern (or ref "none") dependencies))
2943 (if (boundp ref-dep)
2944 (setcdr (symbol-value ref-dep)
2945 (nconc (cdr (symbol-value ref-dep))
2946 (list (symbol-value id-dep))))
2947 (set ref-dep (list nil (symbol-value id-dep)))))
2950 (defun gnus-build-sparse-threads ()
2951 (let ((headers gnus-newsgroup-headers)
2952 header references generation relations
2953 cthread subject child end pthread relation new-child date)
2954 ;; First we create an alist of generations/relations, where
2955 ;; generations is how much we trust the relation, and the relation
2957 (gnus-message 7 "Making sparse threads...")
2959 (nnheader-set-temp-buffer " *gnus sparse threads*")
2960 (while (setq header (pop headers))
2961 (when (and (setq references (mail-header-references header))
2962 (not (string= references "")))
2964 (setq child (mail-header-id header)
2965 subject (mail-header-subject header)
2966 date (mail-header-date header)
2968 (while (search-backward ">" nil t)
2969 (setq end (1+ (point)))
2970 (if (search-backward "<" nil t)
2971 (push (list (incf generation)
2972 child (setq child new-child)
2975 (push (list (1+ generation) child nil subject) relations)
2977 (kill-buffer (current-buffer)))
2978 ;; Sort over trustworthiness.
2981 (when (gnus-dependencies-add-header
2982 (make-full-mail-header
2983 gnus-reffed-article-number
2984 (nth 3 relation) "" (nth 4 relation)
2986 (or (nth 2 relation) "") 0 0 "")
2987 gnus-newsgroup-dependencies nil)
2988 (push gnus-reffed-article-number gnus-newsgroup-limit)
2989 (push gnus-reffed-article-number gnus-newsgroup-sparse)
2990 (push (cons gnus-reffed-article-number gnus-sparse-mark)
2991 gnus-newsgroup-reads)
2992 (decf gnus-reffed-article-number)))
2993 (sort relations 'car-less-than-car))
2994 (gnus-message 7 "Making sparse threads...done")))
2996 (defun gnus-build-old-threads ()
2997 ;; Look at all the articles that refer back to old articles, and
2998 ;; fetch the headers for the articles that aren't there. This will
2999 ;; build complete threads - if the roots haven't been expired by the
3004 (when (not (car (symbol-value refs)))
3005 (setq heads (cdr (symbol-value refs)))
3007 (if (memq (mail-header-number (caar heads))
3008 gnus-newsgroup-dormant)
3009 (setq heads (cdr heads))
3010 (setq id (symbol-name refs))
3011 (while (and (setq id (gnus-build-get-header id))
3012 (not (car (gnus-id-to-thread id)))))
3013 (setq heads nil)))))
3014 gnus-newsgroup-dependencies)))
3016 ;; The following macros and functions were written by Felix Lee
3017 ;; <flee@cse.psu.edu>.
3019 (defmacro gnus-nov-read-integer ()
3021 (if (= (following-char) ?\t)
3023 (let ((num (ignore-errors (read buffer))))
3024 (if (numberp num) num 0)))
3026 (search-forward "\t" eol 'move))))
3028 (defmacro gnus-nov-skip-field ()
3029 '(search-forward "\t" eol 'move))
3031 (defmacro gnus-nov-field ()
3032 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
3034 ;; This function has to be called with point after the article number
3035 ;; on the beginning of the line.
3036 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3037 (let ((eol (gnus-point-at-eol))
3038 (buffer (current-buffer))
3041 ;; overview: [num subject from date id refs chars lines misc]
3044 (narrow-to-region (point) eol)
3049 (make-full-mail-header
3052 gnus-unstructured-field-decoder (gnus-nov-field)) ; subject
3054 gnus-structured-field-decoder (gnus-nov-field)) ; from
3055 (gnus-nov-field) ; date
3056 (or (gnus-nov-field)
3057 (nnheader-generate-fake-message-id)) ; id
3058 (gnus-nov-field) ; refs
3059 (gnus-nov-read-integer) ; chars
3060 (gnus-nov-read-integer) ; lines
3061 (unless (= (following-char) ?\n)
3062 (gnus-nov-field))))) ; misc
3066 (when gnus-alter-header-function
3067 (funcall gnus-alter-header-function header))
3068 (gnus-dependencies-add-header header dependencies force-new)))
3070 (defun gnus-build-get-header (id)
3071 ;; Look through the buffer of NOV lines and find the header to
3072 ;; ID. Enter this line into the dependencies hash table, and return
3073 ;; the id of the parent article (if any).
3074 (let ((deps gnus-newsgroup-dependencies)
3078 (set-buffer nntp-server-buffer)
3079 (let ((case-fold-search nil))
3080 (goto-char (point-min))
3081 (while (and (not found)
3082 (search-forward id nil t))
3084 (setq found (looking-at
3085 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3086 (regexp-quote id))))
3087 (or found (beginning-of-line 2)))
3091 (setq header (gnus-nov-parse-line
3092 (read (current-buffer)) deps))
3093 (gnus-parent-id (mail-header-references header))))))
3095 (let ((number (mail-header-number header)))
3096 (push number gnus-newsgroup-limit)
3097 (push header gnus-newsgroup-headers)
3098 (if (memq number gnus-newsgroup-unselected)
3100 (push number gnus-newsgroup-unreads)
3101 (setq gnus-newsgroup-unselected
3102 (delq number gnus-newsgroup-unselected)))
3103 (push number gnus-newsgroup-ancient)))))))
3105 (defun gnus-build-all-threads ()
3106 "Read all the headers."
3107 (let ((gnus-summary-ignore-duplicates t)
3108 (dependencies gnus-newsgroup-dependencies)
3109 found header article)
3111 (set-buffer nntp-server-buffer)
3112 (let ((case-fold-search nil))
3113 (goto-char (point-min))
3116 (setq article (read (current-buffer))
3117 header (gnus-nov-parse-line
3118 article dependencies)))
3120 (push header gnus-newsgroup-headers)
3121 (if (memq (setq article (mail-header-number header))
3122 gnus-newsgroup-unselected)
3124 (push article gnus-newsgroup-unreads)
3125 (setq gnus-newsgroup-unselected
3126 (delq article gnus-newsgroup-unselected)))
3127 (push article gnus-newsgroup-ancient))
3128 (forward-line 1)))))))
3130 (defun gnus-summary-update-article-line (article header)
3131 "Update the line for ARTICLE using HEADERS."
3132 (let* ((id (mail-header-id header))
3133 (thread (gnus-id-to-thread id)))
3135 (error "Article in no thread"))
3136 ;; Update the thread.
3137 (setcar thread header)
3138 (gnus-summary-goto-subject article)
3139 (let* ((datal (gnus-data-find-list article))
3141 (length (when (cdr datal)
3142 (- (gnus-data-pos data)
3143 (gnus-data-pos (cadr datal)))))
3144 (buffer-read-only nil)
3145 (level (gnus-summary-thread-level)))
3147 (gnus-summary-insert-line
3148 header level nil (gnus-article-mark article)
3149 (memq article gnus-newsgroup-replied)
3150 (memq article gnus-newsgroup-expirable)
3151 ;; Only insert the Subject string when it's different
3152 ;; from the previous Subject string.
3153 (if (gnus-subject-equal
3155 (mail-header-subject
3158 (gnus-data-find-list
3160 (gnus-data-list t)))))
3161 ;; Error on the side of excessive subjects.
3163 (mail-header-subject header))
3165 (mail-header-subject header))
3166 nil (cdr (assq article gnus-newsgroup-scored))
3167 (memq article gnus-newsgroup-processable))
3169 (gnus-data-update-list
3170 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3172 (defun gnus-summary-update-article (article &optional iheader)
3173 "Update ARTICLE in the summary buffer."
3174 (set-buffer gnus-summary-buffer)
3175 (let* ((header (or iheader (gnus-summary-article-header article)))
3176 (id (mail-header-id header))
3177 (data (gnus-data-find article))
3178 (thread (gnus-id-to-thread id))
3179 (references (mail-header-references header))
3183 (when (and references
3184 (not (equal "" references)))
3187 (buffer-read-only nil)
3189 (number (mail-header-number header))
3192 ;; !!! Should this be in or not?
3194 (setcar thread nil))
3196 (delq thread parent))
3197 (if (gnus-summary-insert-subject id header iheader)
3198 ;; Set the (possibly) new article number in the data structure.
3199 (gnus-data-set-number data (gnus-id-to-article id))
3203 (defun gnus-rebuild-thread (id &optional line)
3204 "Rebuild the thread containing ID.
3205 If LINE, insert the rebuilt thread starting on line LINE."
3206 (let ((buffer-read-only nil)
3207 old-pos current thread data)
3208 (if (not gnus-show-threads)
3209 (setq thread (list (car (gnus-id-to-thread id))))
3210 ;; Get the thread this article is part of.
3211 (setq thread (gnus-remove-thread id)))
3212 (setq old-pos (gnus-point-at-bol))
3213 (setq current (save-excursion
3214 (and (zerop (forward-line -1))
3215 (gnus-summary-article-number))))
3216 ;; If this is a gathered thread, we have to go some re-gathering.
3217 (when (stringp (car thread))
3218 (let ((subject (car thread))
3220 (setq thread (cdr thread))
3222 (unless (memq (setq thr (gnus-id-to-thread
3224 (mail-header-id (caar thread)))))
3227 (setq thread (cdr thread)))
3228 ;; We now have all (unique) roots.
3229 (if (= (length roots) 1)
3230 ;; All the loose roots are now one solid root.
3231 (setq thread (car roots))
3232 (setq thread (cons subject (gnus-sort-threads roots))))))
3234 ;; We then insert this thread into the summary buffer.
3236 (goto-char (point-min))
3237 (forward-line (1- line)))
3238 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3239 (if gnus-show-threads
3240 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3241 (gnus-summary-prepare-unthreaded thread))
3242 (setq data (nreverse gnus-newsgroup-data))
3243 (setq threads gnus-newsgroup-threads))
3244 ;; We splice the new data into the data structure.
3245 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3246 ;;!!! then we want to insert at the beginning of the buffer.
3247 ;;!!! That happens to be true with Gnus now, but that may
3248 ;;!!! change in the future. Perhaps.
3249 (gnus-data-enter-list (if line nil current) data (- (point) old-pos))
3250 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads))
3252 (gnus-data-compute-positions)))))
3254 (defun gnus-number-to-header (number)
3255 "Return the header for article NUMBER."
3256 (let ((headers gnus-newsgroup-headers))
3258 (not (= number (mail-header-number (car headers)))))
3263 (defun gnus-parent-headers (in-headers &optional generation)
3264 "Return the headers of the GENERATIONeth parent of HEADERS."
3266 (setq generation 1))
3268 (headers in-headers)
3271 (not (zerop generation))
3272 (setq references (mail-header-references headers)))
3273 (setq headers (if (and references
3274 (setq parent (gnus-parent-id references)))
3275 (car (gnus-id-to-thread parent))
3278 (and (not (eq headers in-headers))
3281 (defun gnus-id-to-thread (id)
3282 "Return the (sub-)thread where ID appears."
3283 (gnus-gethash id gnus-newsgroup-dependencies))
3285 (defun gnus-id-to-article (id)
3286 "Return the article number of ID."
3287 (let ((thread (gnus-id-to-thread id)))
3290 (mail-header-number (car thread)))))
3292 (defun gnus-id-to-header (id)
3293 "Return the article headers of ID."
3294 (car (gnus-id-to-thread id)))
3296 (defun gnus-article-displayed-root-p (article)
3297 "Say whether ARTICLE is a root(ish) article."
3298 (let ((level (gnus-summary-thread-level article))
3299 (refs (mail-header-references (gnus-summary-article-header article)))
3305 ((null (gnus-parent-id refs)) t)
3307 (null (setq particle (gnus-id-to-article
3308 (gnus-parent-id refs))))
3309 (null (gnus-summary-thread-level particle)))))))
3311 (defun gnus-root-id (id)
3312 "Return the id of the root of the thread where ID appears."
3314 (while (and id (setq prev (car (gnus-id-to-thread id))))
3316 id (gnus-parent-id (mail-header-references prev))))
3319 (defun gnus-articles-in-thread (thread)
3320 "Return the list of articles in THREAD."
3321 (cons (mail-header-number (car thread))
3322 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3324 (defun gnus-remove-thread (id &optional dont-remove)
3325 "Remove the thread that has ID in it."
3326 (let (headers thread last-id)
3327 ;; First go up in this thread until we find the root.
3328 (setq last-id (gnus-root-id id))
3329 (setq headers (list (car (gnus-id-to-thread last-id))
3330 (caadr (gnus-id-to-thread last-id))))
3331 ;; We have now found the real root of this thread. It might have
3332 ;; been gathered into some loose thread, so we have to search
3333 ;; through the threads to find the thread we wanted.
3334 (let ((threads gnus-newsgroup-threads)
3337 (setq sub (car threads))
3338 (if (stringp (car sub))
3339 ;; This is a gathered thread, so we look at the roots
3340 ;; below it to find whether this article is in this
3343 (setq sub (cdr sub))
3345 (when (member (caar sub) headers)
3346 (setq thread (car threads)
3349 (setq sub (cdr sub))))
3350 ;; It's an ordinary thread, so we check it.
3351 (when (eq (car sub) (car headers))
3354 (setq threads (cdr threads)))
3355 ;; If this article is in no thread, then it's a root.
3358 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3359 (setq thread (gnus-id-to-thread last-id)))
3362 thread ; We return this thread.
3364 (if (stringp (car thread))
3366 ;; If we use dummy roots, then we have to remove the
3367 ;; dummy root as well.
3368 (when (eq gnus-summary-make-false-root 'dummy)
3369 ;; We go to the dummy root by going to
3370 ;; the first sub-"thread", and then one line up.
3371 (gnus-summary-goto-article
3372 (mail-header-number (caadr thread)))
3375 (gnus-data-compute-positions))
3376 (setq thread (cdr thread))
3378 (gnus-remove-thread-1 (car thread))
3379 (setq thread (cdr thread))))
3380 (gnus-remove-thread-1 thread))))))))
3382 (defun gnus-remove-thread-1 (thread)
3383 "Remove the thread THREAD recursively."
3384 (let ((number (mail-header-number (pop thread)))
3386 (setq thread (reverse thread))
3388 (gnus-remove-thread-1 (pop thread)))
3389 (when (setq d (gnus-data-find number))
3390 (goto-char (gnus-data-pos d))
3393 (- (gnus-point-at-bol)
3395 (1+ (gnus-point-at-eol))
3396 (gnus-delete-line)))))))
3398 (defun gnus-sort-threads (threads)
3400 (if (not gnus-thread-sort-functions)
3402 (gnus-message 7 "Sorting threads...")
3404 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3405 (gnus-message 7 "Sorting threads...done"))))
3407 (defun gnus-sort-articles (articles)
3409 (when gnus-article-sort-functions
3410 (gnus-message 7 "Sorting articles...")
3412 (setq gnus-newsgroup-headers
3413 (sort articles (gnus-make-sort-function
3414 gnus-article-sort-functions)))
3415 (gnus-message 7 "Sorting articles...done"))))
3417 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3418 (defmacro gnus-thread-header (thread)
3419 ;; Return header of first article in THREAD.
3420 ;; Note that THREAD must never, ever be anything else than a variable -
3421 ;; using some other form will lead to serious barfage.
3422 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3423 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3424 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
3427 (defsubst gnus-article-sort-by-number (h1 h2)
3428 "Sort articles by article number."
3429 (< (mail-header-number h1)
3430 (mail-header-number h2)))
3432 (defun gnus-thread-sort-by-number (h1 h2)
3433 "Sort threads by root article number."
3434 (gnus-article-sort-by-number
3435 (gnus-thread-header h1) (gnus-thread-header h2)))
3437 (defsubst gnus-article-sort-by-lines (h1 h2)
3438 "Sort articles by article Lines header."
3439 (< (mail-header-lines h1)
3440 (mail-header-lines h2)))
3442 (defun gnus-thread-sort-by-lines (h1 h2)
3443 "Sort threads by root article Lines header."
3444 (gnus-article-sort-by-lines
3445 (gnus-thread-header h1) (gnus-thread-header h2)))
3447 (defsubst gnus-article-sort-by-author (h1 h2)
3448 "Sort articles by root author."
3450 (let ((extract (funcall
3451 gnus-extract-address-components
3452 (mail-header-from h1))))
3453 (or (car extract) (cadr extract) ""))
3454 (let ((extract (funcall
3455 gnus-extract-address-components
3456 (mail-header-from h2))))
3457 (or (car extract) (cadr extract) ""))))
3459 (defun gnus-thread-sort-by-author (h1 h2)
3460 "Sort threads by root author."
3461 (gnus-article-sort-by-author
3462 (gnus-thread-header h1) (gnus-thread-header h2)))
3464 (defsubst gnus-article-sort-by-subject (h1 h2)
3465 "Sort articles by root subject."
3467 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3468 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3470 (defun gnus-thread-sort-by-subject (h1 h2)
3471 "Sort threads by root subject."
3472 (gnus-article-sort-by-subject
3473 (gnus-thread-header h1) (gnus-thread-header h2)))
3475 (defsubst gnus-article-sort-by-date (h1 h2)
3476 "Sort articles by root article date."
3478 (gnus-date-get-time (mail-header-date h1))
3479 (gnus-date-get-time (mail-header-date h2))))
3481 (defun gnus-thread-sort-by-date (h1 h2)
3482 "Sort threads by root article date."
3483 (gnus-article-sort-by-date
3484 (gnus-thread-header h1) (gnus-thread-header h2)))
3486 (defsubst gnus-article-sort-by-score (h1 h2)
3487 "Sort articles by root article score.
3488 Unscored articles will be counted as having a score of zero."
3489 (> (or (cdr (assq (mail-header-number h1)
3490 gnus-newsgroup-scored))
3491 gnus-summary-default-score 0)
3492 (or (cdr (assq (mail-header-number h2)
3493 gnus-newsgroup-scored))
3494 gnus-summary-default-score 0)))
3496 (defun gnus-thread-sort-by-score (h1 h2)
3497 "Sort threads by root article score."
3498 (gnus-article-sort-by-score
3499 (gnus-thread-header h1) (gnus-thread-header h2)))
3501 (defun gnus-thread-sort-by-total-score (h1 h2)
3502 "Sort threads by the sum of all scores in the thread.
3503 Unscored articles will be counted as having a score of zero."
3504 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3506 (defun gnus-thread-total-score (thread)
3507 ;; This function find the total score of THREAD.
3508 (cond ((null thread)
3511 (if (stringp (car thread))
3512 (apply gnus-thread-score-function 0
3513 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3514 (gnus-thread-total-score-1 thread)))
3516 (gnus-thread-total-score-1 (list thread)))))
3518 (defun gnus-thread-total-score-1 (root)
3519 ;; This function find the total score of the thread below ROOT.
3520 (setq root (car root))
3521 (apply gnus-thread-score-function
3523 (mapcar 'gnus-thread-total-score
3524 (cdr (gnus-id-to-thread (mail-header-id root))))
3525 (when (> (mail-header-number root) 0)
3526 (list (or (cdr (assq (mail-header-number root)
3527 gnus-newsgroup-scored))
3528 gnus-summary-default-score 0))))
3529 (list gnus-summary-default-score)
3532 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3533 (defvar gnus-tmp-prev-subject nil)
3534 (defvar gnus-tmp-false-parent nil)
3535 (defvar gnus-tmp-root-expunged nil)
3536 (defvar gnus-tmp-dummy-line nil)
3538 (defun gnus-summary-prepare-threads (threads)
3539 "Prepare summary buffer from THREADS and indentation LEVEL.
3540 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3541 or a straight list of headers."
3542 (gnus-message 7 "Generating summary...")
3544 (setq gnus-newsgroup-threads threads)
3547 (let ((gnus-tmp-level 0)
3548 (default-score (or gnus-summary-default-score 0))
3549 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3550 thread number subject stack state gnus-tmp-gathered beg-match
3551 new-roots gnus-tmp-new-adopts thread-end
3552 gnus-tmp-header gnus-tmp-unread
3553 gnus-tmp-replied gnus-tmp-subject-or-nil
3554 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3555 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3556 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3558 (setq gnus-tmp-prev-subject nil)
3560 (if (vectorp (car threads))
3561 ;; If this is a straight (sic) list of headers, then a
3562 ;; threaded summary display isn't required, so we just create
3563 ;; an unthreaded one.
3564 (gnus-summary-prepare-unthreaded threads)
3566 ;; Do the threaded display.
3568 (while (or threads stack gnus-tmp-new-adopts new-roots)
3570 (if (and (= gnus-tmp-level 0)
3573 (not gnus-tmp-false-parent)
3574 (or gnus-tmp-new-adopts new-roots))
3575 (if gnus-tmp-new-adopts
3576 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3577 thread (list (car gnus-tmp-new-adopts))
3578 gnus-tmp-header (caar thread)
3579 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3581 (setq thread (list (car new-roots))
3582 gnus-tmp-header (caar thread)
3583 new-roots (cdr new-roots))))
3586 ;; If there are some threads, we do them before the
3587 ;; threads on the stack.
3588 (setq thread threads
3589 gnus-tmp-header (caar thread))
3590 ;; There were no current threads, so we pop something off
3592 (setq state (car stack)
3593 gnus-tmp-level (car state)
3596 gnus-tmp-header (caar thread))))
3598 (setq gnus-tmp-false-parent nil)
3599 (setq gnus-tmp-root-expunged nil)
3600 (setq thread-end nil)
3602 (if (stringp gnus-tmp-header)
3603 ;; The header is a dummy root.
3605 ((eq gnus-summary-make-false-root 'adopt)
3606 ;; We let the first article adopt the rest.
3607 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3609 (setq gnus-tmp-gathered
3611 (lambda (h) (mail-header-number (car h)))
3614 (setq thread (cons (list (caar thread)
3617 (setq gnus-tmp-level -1
3618 gnus-tmp-false-parent t))
3619 ((eq gnus-summary-make-false-root 'empty)
3620 ;; We print adopted articles with empty subject fields.
3621 (setq gnus-tmp-gathered
3623 (lambda (h) (mail-header-number (car h)))
3626 (setq gnus-tmp-level -1))
3627 ((eq gnus-summary-make-false-root 'dummy)
3628 ;; We remember that we probably want to output a dummy
3630 (setq gnus-tmp-dummy-line gnus-tmp-header)
3631 (setq gnus-tmp-prev-subject gnus-tmp-header))
3633 ;; We do not make a root for the gathered
3634 ;; sub-threads at all.
3635 (setq gnus-tmp-level -1)))
3637 (setq number (mail-header-number gnus-tmp-header)
3638 subject (mail-header-subject gnus-tmp-header))
3641 ;; If the thread has changed subject, we might want to make
3642 ;; this subthread into a root.
3643 ((and (null gnus-thread-ignore-subject)
3644 (not (zerop gnus-tmp-level))
3645 gnus-tmp-prev-subject
3647 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3648 (setq new-roots (nconc new-roots (list (car thread)))
3650 gnus-tmp-header nil))
3651 ;; If the article lies outside the current limit,
3652 ;; then we do not display it.
3653 ((not (memq number gnus-newsgroup-limit))
3654 (setq gnus-tmp-gathered
3656 (lambda (h) (mail-header-number (car h)))
3659 (setq gnus-tmp-new-adopts (if (cdar thread)
3660 (append gnus-tmp-new-adopts
3662 gnus-tmp-new-adopts)
3664 gnus-tmp-header nil)
3665 (when (zerop gnus-tmp-level)
3666 (setq gnus-tmp-root-expunged t)))
3667 ;; Perhaps this article is to be marked as read?
3668 ((and gnus-summary-mark-below
3669 (< (or (cdr (assq number gnus-newsgroup-scored))
3671 gnus-summary-mark-below)
3672 ;; Don't touch sparse articles.
3673 (not (gnus-summary-article-sparse-p number))
3674 (not (gnus-summary-article-ancient-p number)))
3675 (setq gnus-newsgroup-unreads
3676 (delq number gnus-newsgroup-unreads))
3677 (if gnus-newsgroup-auto-expire
3678 (push number gnus-newsgroup-expirable)
3679 (push (cons number gnus-low-score-mark)
3680 gnus-newsgroup-reads))))
3682 (when gnus-tmp-header
3683 ;; We may have an old dummy line to output before this
3685 (when (and gnus-tmp-dummy-line
3688 (mail-header-subject gnus-tmp-header)))
3689 (gnus-summary-insert-dummy-line
3690 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3691 (setq gnus-tmp-dummy-line nil))
3693 ;; Compute the mark.
3694 (setq gnus-tmp-unread (gnus-article-mark number))
3696 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3697 gnus-tmp-header gnus-tmp-level)
3698 gnus-newsgroup-data)
3700 ;; Actually insert the line.
3702 gnus-tmp-subject-or-nil
3704 ((and gnus-thread-ignore-subject
3705 gnus-tmp-prev-subject
3706 (not (inline (gnus-subject-equal
3707 gnus-tmp-prev-subject subject))))
3709 ((zerop gnus-tmp-level)
3710 (if (and (eq gnus-summary-make-false-root 'empty)
3711 (memq number gnus-tmp-gathered)
3712 gnus-tmp-prev-subject
3713 (inline (gnus-subject-equal
3714 gnus-tmp-prev-subject subject)))
3715 gnus-summary-same-subject
3717 (t gnus-summary-same-subject)))
3718 (if (and (eq gnus-summary-make-false-root 'adopt)
3719 (= gnus-tmp-level 1)
3720 (memq number gnus-tmp-gathered))
3721 (setq gnus-tmp-opening-bracket ?\<
3722 gnus-tmp-closing-bracket ?\>)
3723 (setq gnus-tmp-opening-bracket ?\[
3724 gnus-tmp-closing-bracket ?\]))
3726 gnus-tmp-indentation
3727 (aref gnus-thread-indent-array gnus-tmp-level)
3728 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3729 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3730 gnus-summary-default-score 0)
3732 (if (or (null gnus-summary-default-score)
3733 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3734 gnus-summary-zcore-fuzz))
3736 (if (< gnus-tmp-score gnus-summary-default-score)
3737 gnus-score-below-mark gnus-score-over-mark))
3739 (cond ((memq number gnus-newsgroup-processable)
3741 ((memq number gnus-newsgroup-cached)
3743 ((memq number gnus-newsgroup-replied)
3745 ((memq number gnus-newsgroup-saved)
3747 (t gnus-unread-mark))
3748 gnus-tmp-from (mail-header-from gnus-tmp-header)
3751 ((string-match "<[^>]+> *$" gnus-tmp-from)
3752 (setq beg-match (match-beginning 0))
3753 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3754 (substring gnus-tmp-from (1+ (match-beginning 0))
3755 (1- (match-end 0))))
3756 (substring gnus-tmp-from 0 beg-match)))
3757 ((string-match "(.+)" gnus-tmp-from)
3758 (substring gnus-tmp-from
3759 (1+ (match-beginning 0)) (1- (match-end 0))))
3761 (when (string= gnus-tmp-name "")
3762 (setq gnus-tmp-name gnus-tmp-from))
3763 (unless (numberp gnus-tmp-lines)
3764 (setq gnus-tmp-lines 0))
3765 (gnus-put-text-property
3767 (progn (eval gnus-summary-line-format-spec) (point))
3768 'gnus-number number)
3771 (gnus-run-hooks 'gnus-summary-update-hook)
3774 (setq gnus-tmp-prev-subject subject)))
3776 (when (nth 1 thread)
3777 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3778 (incf gnus-tmp-level)
3779 (setq threads (if thread-end nil (cdar thread)))
3781 (setq gnus-tmp-level 0)))))
3782 (gnus-message 7 "Generating summary...done"))
3784 (defun gnus-summary-prepare-unthreaded (headers)
3785 "Generate an unthreaded summary buffer based on HEADERS."
3786 (let (header number mark)
3791 ;; We may have to root out some bad articles...
3792 (when (memq (setq number (mail-header-number
3793 (setq header (pop headers))))
3794 gnus-newsgroup-limit)
3795 ;; Mark article as read when it has a low score.
3796 (when (and gnus-summary-mark-below
3797 (< (or (cdr (assq number gnus-newsgroup-scored))
3798 gnus-summary-default-score 0)
3799 gnus-summary-mark-below)
3800 (not (gnus-summary-article-ancient-p number)))
3801 (setq gnus-newsgroup-unreads
3802 (delq number gnus-newsgroup-unreads))
3803 (if gnus-newsgroup-auto-expire
3804 (push number gnus-newsgroup-expirable)
3805 (push (cons number gnus-low-score-mark)
3806 gnus-newsgroup-reads)))
3808 (setq mark (gnus-article-mark number))
3809 (push (gnus-data-make number mark (1+ (point)) header 0)
3810 gnus-newsgroup-data)
3811 (gnus-summary-insert-line
3813 mark (memq number gnus-newsgroup-replied)
3814 (memq number gnus-newsgroup-expirable)
3815 (mail-header-subject header) nil
3816 (cdr (assq number gnus-newsgroup-scored))
3817 (memq number gnus-newsgroup-processable))))))
3819 (defun gnus-select-newsgroup (group &optional read-all)
3820 "Select newsgroup GROUP.
3821 If READ-ALL is non-nil, all articles in the group are selected."
3822 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3823 ;;!!! Dirty hack; should be removed.
3824 (gnus-summary-ignore-duplicates
3825 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
3827 gnus-summary-ignore-duplicates))
3828 (info (nth 2 entry))
3829 articles fetched-articles cached)
3831 (unless (gnus-check-server
3832 (setq gnus-current-select-method
3833 (gnus-find-method-for-group group)))
3834 (error "Couldn't open server"))
3836 (or (and entry (not (eq (car entry) t))) ; Either it's active...
3837 (gnus-activate-group group) ; Or we can activate it...
3838 (progn ; Or we bug out.
3839 (when (equal major-mode 'gnus-summary-mode)
3840 (kill-buffer (current-buffer)))
3841 (error "Couldn't request group %s: %s"
3842 group (gnus-status-message group))))
3844 (unless (gnus-request-group group t)
3845 (when (equal major-mode 'gnus-summary-mode)
3846 (kill-buffer (current-buffer)))
3847 (error "Couldn't request group %s: %s"
3848 group (gnus-status-message group)))
3850 (setq gnus-newsgroup-name group)
3851 (setq gnus-newsgroup-unselected nil)
3852 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
3854 ;; Adjust and set lists of article marks.
3856 (gnus-adjust-marked-articles info))
3858 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3859 (when (gnus-virtual-group-p group)
3860 (setq cached gnus-newsgroup-cached))
3862 (setq gnus-newsgroup-unreads
3863 (gnus-set-difference
3864 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
3865 gnus-newsgroup-dormant))
3867 (setq gnus-newsgroup-processable nil)
3869 (gnus-update-read-articles group gnus-newsgroup-unreads)
3870 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
3871 (gnus-group-update-group group))
3873 (setq articles (gnus-articles-to-read group read-all))
3877 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
3879 ((eq articles 0) nil)
3881 ;; Init the dependencies hash table.
3882 (setq gnus-newsgroup-dependencies
3883 (gnus-make-hashtable (length articles)))
3884 ;; Retrieve the headers and read them in.
3885 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
3886 (setq gnus-newsgroup-headers
3888 (setq gnus-headers-retrieved-by
3889 (gnus-retrieve-headers
3890 articles gnus-newsgroup-name
3891 ;; We might want to fetch old headers, but
3892 ;; not if there is only 1 article.
3894 (not (eq gnus-fetch-old-headers 'some))
3895 (not (numberp gnus-fetch-old-headers)))
3896 (> (length articles) 1))
3897 gnus-fetch-old-headers))))
3898 (gnus-get-newsgroup-headers-xover
3899 articles nil nil gnus-newsgroup-name t)
3900 (gnus-get-newsgroup-headers)))
3901 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
3903 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3905 (setq gnus-newsgroup-cached cached))
3907 ;; Suppress duplicates?
3908 (when gnus-suppress-duplicates
3909 (gnus-dup-suppress-articles))
3911 ;; Set the initial limit.
3912 (setq gnus-newsgroup-limit (copy-sequence articles))
3913 ;; Remove canceled articles from the list of unread articles.
3914 (setq gnus-newsgroup-unreads
3915 (gnus-set-sorted-intersection
3916 gnus-newsgroup-unreads
3917 (setq fetched-articles
3918 (mapcar (lambda (headers) (mail-header-number headers))
3919 gnus-newsgroup-headers))))
3920 ;; Removed marked articles that do not exist.
3921 (gnus-update-missing-marks
3922 (gnus-sorted-complement fetched-articles articles))
3923 ;; Let the Gnus agent mark articles as read.
3925 (gnus-agent-get-undownloaded-list))
3926 ;; We might want to build some more threads first.
3927 (when (and gnus-fetch-old-headers
3928 (eq gnus-headers-retrieved-by 'nov))
3929 (if (eq gnus-fetch-old-headers 'invisible)
3930 (gnus-build-all-threads)
3931 (gnus-build-old-threads)))
3932 ;; Check whether auto-expire is to be done in this group.
3933 (setq gnus-newsgroup-auto-expire
3934 (gnus-group-auto-expirable-p group))
3935 ;; Set up the article buffer now, if necessary.
3936 (unless gnus-single-article-buffer
3937 (gnus-article-setup-buffer))
3938 ;; First and last article in this newsgroup.
3939 (when gnus-newsgroup-headers
3940 (setq gnus-newsgroup-begin
3941 (mail-header-number (car gnus-newsgroup-headers))
3944 (gnus-last-element gnus-newsgroup-headers))))
3945 ;; GROUP is successfully selected.
3946 (or gnus-newsgroup-headers t)))))
3948 (defun gnus-articles-to-read (group &optional read-all)
3949 ;; Find out what articles the user wants to read.
3951 ;; Select all articles if `read-all' is non-nil, or if there
3952 ;; are no unread articles.
3954 (and (zerop (length gnus-newsgroup-marked))
3955 (zerop (length gnus-newsgroup-unreads)))
3956 (eq (gnus-group-find-parameter group 'display)
3958 (gnus-uncompress-range (gnus-active group))
3959 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
3960 (copy-sequence gnus-newsgroup-unreads))
3962 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
3963 (scored (length scored-list))
3964 (number (length articles))
3965 (marked (+ (length gnus-newsgroup-marked)
3966 (length gnus-newsgroup-dormant)))
3974 ((and (or (<= scored marked) (= scored number))
3975 (numberp gnus-large-newsgroup)
3976 (> number gnus-large-newsgroup))
3980 "How many articles from %s (default %d): "
3981 (gnus-limit-string gnus-newsgroup-name 35)
3983 (if (string-match "^[ \t]*$" input) number input)))
3984 ((and (> scored marked) (< scored number)
3985 (> (- scored number) 20))
3988 (format "%s %s (%d scored, %d total): "
3989 "How many articles from"
3990 group scored number))))
3991 (if (string-match "^[ \t]*$" input)
3995 (setq select (if (stringp select) (string-to-number select) select))
3996 (if (or (null select) (zerop select))
3998 (if (and (not (zerop scored)) (<= (abs select) scored))
4000 (setq articles (sort scored-list '<))
4001 (setq number (length articles)))
4002 (setq articles (copy-sequence articles)))
4004 (when (< (abs select) number)
4006 ;; Select the N oldest articles.
4007 (setcdr (nthcdr (1- (abs select)) articles) nil)
4008 ;; Select the N most recent articles.
4009 (setq articles (nthcdr (- number select) articles))))
4010 (setq gnus-newsgroup-unselected
4011 (gnus-sorted-intersection
4012 gnus-newsgroup-unreads
4013 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4016 (defun gnus-killed-articles (killed articles)
4019 (when (inline (gnus-member-of-range (car articles) killed))
4020 (push (car articles) out))
4021 (setq articles (cdr articles)))
4024 (defun gnus-uncompress-marks (marks)
4025 "Uncompress the mark ranges in MARKS."
4026 (let ((uncompressed '(score bookmark))
4029 (if (memq (caar marks) uncompressed)
4030 (push (car marks) out)
4031 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4032 (setq marks (cdr marks)))
4035 (defun gnus-adjust-marked-articles (info)
4036 "Set all article lists and remove all marks that are no longer legal."
4037 (let* ((marked-lists (gnus-info-marks info))
4038 (active (gnus-active (gnus-info-group info)))
4041 (types gnus-article-mark-lists)
4042 (uncompressed '(score bookmark killed))
4043 marks var articles article mark)
4046 (setq marks (pop marked-lists))
4047 (set (setq var (intern (format "gnus-newsgroup-%s"
4048 (car (rassq (setq mark (car marks))
4050 (if (memq (car marks) uncompressed) (cdr marks)
4051 (gnus-uncompress-range (cdr marks))))
4053 (setq articles (symbol-value var))
4055 ;; All articles have to be subsets of the active articles.
4057 ;; Adjust "simple" lists.
4058 ((memq mark '(tick dormant expire reply save))
4060 (when (or (< (setq article (pop articles)) min) (> article max))
4061 (set var (delq article (symbol-value var))))))
4063 ((memq mark uncompressed)
4064 (when (not (listp (cdr (symbol-value var))))
4065 (set var (list (symbol-value var))))
4066 (when (not (listp (cdr articles)))
4067 (setq articles (list articles)))
4069 (when (or (not (consp (setq article (pop articles))))
4070 (< (car article) min)
4071 (> (car article) max))
4072 (set var (delq article (symbol-value var))))))))))
4074 (defun gnus-update-missing-marks (missing)
4075 "Go through the list of MISSING articles and remove them from the mark lists."
4077 (let ((types gnus-article-mark-lists)
4079 ;; Go through all types.
4081 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4082 (when (symbol-value var)
4083 ;; This list has articles. So we delete all missing articles
4087 (set var (delq (pop m) (symbol-value var)))))))))
4089 (defun gnus-update-marks ()
4090 "Enter the various lists of marked articles into the newsgroup info list."
4091 (let ((types gnus-article-mark-lists)
4092 (info (gnus-get-info gnus-newsgroup-name))
4093 (uncompressed '(score bookmark killed))
4094 type list newmarked symbol)
4096 ;; Add all marks lists that are non-nil to the list of marks lists.
4097 (while (setq type (pop types))
4098 (when (setq list (symbol-value
4100 (intern (format "gnus-newsgroup-%s"
4103 ;; Get rid of the entries of the articles that have the
4105 (when (and (eq (cdr type) 'score)
4109 (prev (cons nil list))
4112 (if (or (not (consp (car arts)))
4113 (= (cdar arts) gnus-summary-default-score))
4114 (setcdr prev (cdr arts))
4116 (setq arts (cdr arts)))
4117 (setq list (cdr all))))
4119 (push (cons (cdr type)
4120 (if (memq (cdr type) uncompressed) list
4121 (gnus-compress-sequence
4122 (set symbol (sort list '<)) t)))
4125 ;; Enter these new marks into the info of the group.
4127 (setcar (nthcdr 3 info) newmarked)
4128 ;; Add the marks lists to the end of the info.
4130 (setcdr (nthcdr 2 info) (list newmarked))))
4132 ;; Cut off the end of the info if there's nothing else there.
4136 (when (nthcdr (decf i) info)
4137 (setcdr (nthcdr i info) nil)))))))
4139 (defun gnus-set-mode-line (where)
4140 "This function sets the mode line of the article or summary buffers.
4141 If WHERE is `summary', the summary mode line format will be used."
4142 ;; Is this mode line one we keep updated?
4143 (when (memq where gnus-updated-mode-lines)
4146 ;; We evaluate this in the summary buffer since these
4147 ;; variables are buffer-local to that buffer.
4148 (set-buffer gnus-summary-buffer)
4149 ;; We bind all these variables that are used in the `eval' form
4151 (let* ((mformat (symbol-value
4153 (format "gnus-%s-mode-line-format-spec" where))))
4154 (gnus-tmp-group-name gnus-newsgroup-name)
4155 (gnus-tmp-article-number (or gnus-current-article 0))
4156 (gnus-tmp-unread gnus-newsgroup-unreads)
4157 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4158 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4159 (gnus-tmp-unread-and-unselected
4160 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4161 (zerop gnus-tmp-unselected))
4163 ((zerop gnus-tmp-unselected)
4164 (format "{%d more}" gnus-tmp-unread-and-unticked))
4165 (t (format "{%d(+%d) more}"
4166 gnus-tmp-unread-and-unticked
4167 gnus-tmp-unselected))))
4169 (if (and gnus-current-headers
4170 (vectorp gnus-current-headers))
4171 (gnus-mode-string-quote
4172 (mail-header-subject gnus-current-headers))
4174 bufname-length max-len
4175 gnus-tmp-header);; passed as argument to any user-format-funcs
4176 (setq mode-string (eval mformat))
4177 (setq bufname-length (if (string-match "%b" mode-string)
4180 (if (eq where 'summary)
4182 (get-buffer gnus-article-buffer))))
4185 (setq max-len (max 4 (if gnus-mode-non-string-length
4187 gnus-mode-non-string-length
4189 (length mode-string))))
4190 ;; We might have to chop a bit of the string off...
4191 (when (> (length mode-string) max-len)
4193 (concat (gnus-truncate-string mode-string (- max-len 3))
4195 ;; Pad the mode string a bit.
4196 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4197 ;; Update the mode line.
4198 (setq mode-line-buffer-identification
4199 (gnus-mode-line-buffer-identification (list mode-string)))
4200 (set-buffer-modified-p t))))
4202 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4203 "Go through the HEADERS list and add all Xrefs to a hash table.
4204 The resulting hash table is returned, or nil if no Xrefs were found."
4205 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4206 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4207 (xref-hashtb (gnus-make-hashtable))
4208 start group entry number xrefs header)
4210 (setq header (pop headers))
4211 (when (and (setq xrefs (mail-header-xref header))
4212 (not (memq (setq number (mail-header-number header))
4215 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4216 (setq start (match-end 0))
4217 (setq group (if prefix
4218 (concat prefix (substring xrefs (match-beginning 1)
4220 (substring xrefs (match-beginning 1) (match-end 1))))
4222 (string-to-int (substring xrefs (match-beginning 2)
4224 (if (setq entry (gnus-gethash group xref-hashtb))
4225 (setcdr entry (cons number (cdr entry)))
4226 (gnus-sethash group (cons number nil) xref-hashtb)))))
4227 (and start xref-hashtb)))
4229 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4230 "Look through all the headers and mark the Xrefs as read."
4231 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4232 name entry info xref-hashtb idlist method nth4)
4234 (set-buffer gnus-group-buffer)
4235 (when (setq xref-hashtb
4236 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4239 (unless (string= from-newsgroup (setq name (symbol-name group)))
4240 (setq idlist (symbol-value group))
4241 ;; Dead groups are not updated.
4243 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4245 (when (stringp (setq nth4 (gnus-info-method info)))
4246 (setq nth4 (gnus-server-to-method nth4))))
4247 ;; Only do the xrefs if the group has the same
4248 ;; select method as the group we have just read.
4249 (or (gnus-methods-equal-p
4250 nth4 (gnus-find-method-for-group from-newsgroup))
4252 (equal nth4 (setq method (gnus-find-method-for-group
4254 (and (equal (car nth4) (car method))
4255 (equal (nth 1 nth4) (nth 1 method))))
4256 gnus-use-cross-reference
4257 (or (not (eq gnus-use-cross-reference t))
4259 ;; Only do cross-references on subscribed
4260 ;; groups, if that is what is wanted.
4261 (<= (gnus-info-level info) gnus-level-subscribed))
4262 (gnus-group-make-articles-read name idlist))))
4265 (defun gnus-compute-read-articles (group articles)
4266 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4267 (info (nth 2 entry))
4268 (active (gnus-active group))
4271 ;; First peel off all illegal article numbers.
4273 (let ((ids articles)
4275 (while (setq id (pop ids))
4276 (when (and first (> id (cdr active)))
4277 ;; We'll end up in this situation in one particular
4278 ;; obscure situation. If you re-scan a group and get
4279 ;; a new article that is cross-posted to a different
4280 ;; group that has not been re-scanned, you might get
4281 ;; crossposted article that has a higher number than
4282 ;; Gnus believes possible. So we re-activate this
4283 ;; group as well. This might mean doing the
4284 ;; crossposting thingy will *increase* the number
4285 ;; of articles in some groups. Tsk, tsk.
4286 (setq active (or (gnus-activate-group group) active)))
4287 (when (or (> id (cdr active))
4288 (< id (car active)))
4289 (setq articles (delq id articles))))))
4290 ;; If the read list is nil, we init it.
4292 (null (gnus-info-read info))
4294 (setq ninfo (cons 1 (1- (car active))))
4295 (setq ninfo (gnus-info-read info)))
4296 ;; Then we add the read articles to the range.
4298 ninfo (setq articles (sort articles '<))))))
4300 (defun gnus-group-make-articles-read (group articles)
4301 "Update the info of GROUP to say that ARTICLES are read."
4303 (entry (gnus-gethash group gnus-newsrc-hashtb))
4304 (info (nth 2 entry))
4305 (active (gnus-active group))
4308 (setq range (gnus-compute-read-articles group articles))
4310 (set-buffer gnus-group-buffer)
4313 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4314 (gnus-info-set-read ',info ',(gnus-info-read info))
4315 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4316 (gnus-group-update-group ,group t))))
4317 ;; Add the read articles to the range.
4318 (gnus-info-set-read info range)
4319 ;; Then we have to re-compute how many unread
4320 ;; articles there are in this group.
4324 (setq num (- (1+ (cdr active)) (car active))))
4325 ((not (listp (cdr range)))
4326 (setq num (- (cdr active) (- (1+ (cdr range))
4330 (if (numberp (car range))
4332 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4333 (setq range (cdr range)))
4334 (setq num (- (cdr active) num))))
4335 ;; Update the number of unread articles.
4337 ;; Update the group buffer.
4338 (gnus-group-update-group group t)))))
4340 (defun gnus-methods-equal-p (m1 m2)
4341 (let ((m1 (or m1 gnus-select-method))
4342 (m2 (or m2 gnus-select-method)))
4344 (and (eq (car m1) (car m2))
4345 (or (not (memq 'address (assoc (symbol-name (car m1))
4346 gnus-valid-select-methods)))
4347 (equal (nth 1 m1) (nth 1 m2)))))))
4349 (defvar gnus-newsgroup-none-id 0)
4351 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4352 (let ((cur nntp-server-buffer)
4355 (save-excursion (set-buffer gnus-summary-buffer)
4356 gnus-newsgroup-dependencies)))
4357 headers id id-dep ref-dep end ref)
4359 (set-buffer nntp-server-buffer)
4360 ;; Translate all TAB characters into SPACE characters.
4361 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4362 (gnus-run-hooks 'gnus-parse-headers-hook)
4363 (let ((case-fold-search t)
4364 in-reply-to header p lines chars)
4365 (goto-char (point-min))
4366 ;; Search to the beginning of the next header. Error messages
4367 ;; do not begin with 2 or 3.
4368 (while (re-search-forward "^[23][0-9]+ " nil t)
4371 ;; This implementation of this function, with nine
4372 ;; search-forwards instead of the one re-search-forward and
4373 ;; a case (which basically was the old function) is actually
4374 ;; about twice as fast, even though it looks messier. You
4375 ;; can't have everything, I guess. Speed and elegance
4376 ;; doesn't always go hand in hand.
4385 (narrow-to-region (point)
4386 (or (and (search-forward "\n.\n" nil t)
4392 (if (search-forward "\nsubject: " nil t)
4394 gnus-unstructured-field-decoder (nnheader-header-value))
4399 (if (search-forward "\nfrom: " nil t)
4401 gnus-structured-field-decoder (nnheader-header-value))
4406 (if (search-forward "\ndate: " nil t)
4407 (nnheader-header-value) ""))
4411 (setq id (if (re-search-forward
4412 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4413 ;; We do it this way to make sure the Message-ID
4414 ;; is (somewhat) syntactically valid.
4415 (buffer-substring (match-beginning 1)
4417 ;; If there was no message-id, we just fake one
4418 ;; to make subsequent routines simpler.
4419 (nnheader-generate-fake-message-id))))
4423 (if (search-forward "\nreferences: " nil t)
4427 (nnheader-header-value)
4432 (search-backward ">" end t)
4435 (search-backward "<" end t)
4437 ;; Get the references from the in-reply-to header if there
4438 ;; were no references and the in-reply-to header looks
4440 (if (and (search-forward "\nin-reply-to: " nil t)
4441 (setq in-reply-to (nnheader-header-value))
4442 (string-match "<[^>]+>" in-reply-to))
4444 (setq ref (substring in-reply-to (match-beginning 0)
4446 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4447 (setq ref2 (substring in-reply-to (match-beginning 0)
4449 (when (> (length ref2) (length ref))
4455 (if (search-forward "\nchars: " nil t)
4456 (if (numberp (setq chars (ignore-errors (read cur))))
4462 (if (search-forward "\nlines: " nil t)
4463 (if (numberp (setq lines (ignore-errors (read cur))))
4469 (and (search-forward "\nxref: " nil t)
4470 (nnheader-header-value)))))
4471 (when (equal id ref)
4474 (when gnus-alter-header-function
4475 (funcall gnus-alter-header-function header)
4476 (setq id (mail-header-id header)
4477 ref (gnus-parent-id (mail-header-references header))))
4480 (gnus-dependencies-add-header
4481 header dependencies force-new))
4482 (push header headers))
4483 (goto-char (point-max))
4485 (nreverse headers)))))
4487 ;; Goes through the xover lines and returns a list of vectors
4488 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4489 force-new dependencies
4490 group also-fetch-heads)
4491 "Parse the news overview data in the server buffer, and return a
4492 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4493 ;; Get the Xref when the users reads the articles since most/some
4494 ;; NNTP servers do not include Xrefs when using XOVER.
4495 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4496 (let ((cur nntp-server-buffer)
4497 (dependencies (or dependencies gnus-newsgroup-dependencies))
4498 number headers header)
4500 (set-buffer nntp-server-buffer)
4501 ;; Allow the user to mangle the headers before parsing them.
4502 (gnus-run-hooks 'gnus-parse-headers-hook)
4503 (goto-char (point-min))
4506 (while (and sequence (not (eobp)))
4507 (setq number (read cur))
4508 (while (and sequence
4509 (< (car sequence) number))
4510 (setq sequence (cdr sequence)))
4512 (eq number (car sequence))
4514 (setq sequence (cdr sequence))
4515 (setq header (inline
4516 (gnus-nov-parse-line
4517 number dependencies force-new))))
4518 (push header headers))
4521 (gnus-error 4 "Strange nov line (%d)"
4522 (count-lines (point-min) (point)))))
4524 ;; A common bug in inn is that if you have posted an article and
4525 ;; then retrieves the active file, it will answer correctly --
4526 ;; the new article is included. However, a NOV entry for the
4527 ;; article may not have been generated yet, so this may fail.
4528 ;; We work around this problem by retrieving the last few
4529 ;; headers using HEAD.
4530 (if (or (not also-fetch-heads)
4532 ;; We (probably) got all the headers.
4534 (let ((gnus-nov-is-evil t))
4537 (when (gnus-retrieve-headers sequence group)
4538 (gnus-get-newsgroup-headers))))))))
4540 (defun gnus-article-get-xrefs ()
4541 "Fill in the Xref value in `gnus-current-headers', if necessary.
4542 This is meant to be called in `gnus-article-internal-prepare-hook'."
4543 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4544 gnus-current-headers)))
4545 (or (not gnus-use-cross-reference)
4547 (and (mail-header-xref headers)
4548 (not (string= (mail-header-xref headers) "")))
4549 (let ((case-fold-search t)
4552 (nnheader-narrow-to-headers)
4553 (goto-char (point-min))
4554 (when (or (and (eq (downcase (following-char)) ?x)
4555 (looking-at "Xref:"))
4556 (search-forward "\nXref:" nil t))
4557 (goto-char (1+ (match-end 0)))
4558 (setq xref (buffer-substring (point)
4559 (progn (end-of-line) (point))))
4560 (mail-header-set-xref headers xref)))))))
4562 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4563 "Find article ID and insert the summary line for that article.
4564 OLD-HEADER can either be a header or a line number to insert
4565 the subject line on."
4566 (let* ((line (and (numberp old-header) old-header))
4567 (old-header (and (vectorp old-header) old-header))
4568 (header (cond ((and old-header use-old-header)
4571 (gnus-number-to-header id))
4572 (gnus-number-to-header id))
4574 (gnus-read-header id))))
4575 (number (and (numberp id) id))
4578 ;; Rebuild the thread that this article is part of and go to the
4579 ;; article we have fetched.
4580 (when (and (not gnus-show-threads)
4583 (setq d (gnus-data-find (mail-header-number old-header))))
4584 (goto-char (gnus-data-pos d))
4587 (- (gnus-point-at-bol)
4589 (1+ (gnus-point-at-eol))
4590 (gnus-delete-line))))))
4592 (mail-header-set-number header (mail-header-number old-header)))
4593 (setq gnus-newsgroup-sparse
4594 (delq (setq number (mail-header-number header))
4595 gnus-newsgroup-sparse))
4596 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4597 (push number gnus-newsgroup-limit)
4598 (gnus-rebuild-thread (mail-header-id header) line)
4599 (gnus-summary-goto-subject number nil t))
4600 (when (and (numberp number)
4602 ;; We have to update the boundaries even if we can't fetch the
4603 ;; article if ID is a number -- so that the next `P' or `N'
4604 ;; command will fetch the previous (or next) article even
4605 ;; if the one we tried to fetch this time has been canceled.
4606 (when (> number gnus-newsgroup-end)
4607 (setq gnus-newsgroup-end number))
4608 (when (< number gnus-newsgroup-begin)
4609 (setq gnus-newsgroup-begin number))
4610 (setq gnus-newsgroup-unselected
4611 (delq number gnus-newsgroup-unselected)))
4612 ;; Report back a success?
4613 (and header (mail-header-number header))))
4615 ;;; Process/prefix in the summary buffer
4617 (defun gnus-summary-work-articles (n)
4618 "Return a list of articles to be worked upon.
4619 The prefix argument, the list of process marked articles, and the
4620 current article will be taken into consideration."
4622 (set-buffer gnus-summary-buffer)
4625 ;; A numerical prefix has been given.
4626 (setq n (prefix-numeric-value n))
4627 (let ((backward (< n 0))
4628 (n (abs (prefix-numeric-value n)))
4633 (push (setq article (gnus-summary-article-number))
4636 (gnus-summary-find-prev nil article)
4637 (gnus-summary-find-next nil article)))
4639 (nreverse articles)))
4640 ((and (gnus-region-active-p) (mark))
4641 (message "region active")
4642 ;; Work on the region between point and mark.
4643 (let ((max (max (point) (mark)))
4646 (goto-char (min (point) (mark)))
4649 (push (setq article (gnus-summary-article-number)) articles)
4650 (gnus-summary-find-next nil article)
4652 (nreverse articles))))
4653 (gnus-newsgroup-processable
4654 ;; There are process-marked articles present.
4655 ;; Save current state.
4656 (gnus-summary-save-process-mark)
4658 (reverse gnus-newsgroup-processable))
4660 ;; Just return the current article.
4661 (list (gnus-summary-article-number))))))
4663 (defun gnus-summary-save-process-mark ()
4664 "Push the current set of process marked articles on the stack."
4666 (push (copy-sequence gnus-newsgroup-processable)
4667 gnus-newsgroup-process-stack))
4669 (defun gnus-summary-kill-process-mark ()
4670 "Push the current set of process marked articles on the stack and unmark."
4672 (gnus-summary-save-process-mark)
4673 (gnus-summary-unmark-all-processable))
4675 (defun gnus-summary-yank-process-mark ()
4676 "Pop the last process mark state off the stack and restore it."
4678 (unless gnus-newsgroup-process-stack
4679 (error "Empty mark stack"))
4680 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4682 (defun gnus-summary-process-mark-set (set)
4683 "Make SET into the current process marked articles."
4684 (gnus-summary-unmark-all-processable)
4686 (gnus-summary-set-process-mark (pop set))))
4688 ;;; Searching and stuff
4690 (defun gnus-summary-search-group (&optional backward use-level)
4691 "Search for next unread newsgroup.
4692 If optional argument BACKWARD is non-nil, search backward instead."
4694 (set-buffer gnus-group-buffer)
4695 (when (gnus-group-search-forward
4696 backward nil (if use-level (gnus-group-group-level) nil))
4697 (gnus-group-group-name))))
4699 (defun gnus-summary-best-group (&optional exclude-group)
4700 "Find the name of the best unread group.
4701 If EXCLUDE-GROUP, do not go to this group."
4703 (set-buffer gnus-group-buffer)
4705 (gnus-group-best-unread-group exclude-group))))
4707 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
4708 (if backward (gnus-summary-find-prev)
4709 (let* ((dummy (gnus-summary-article-intangible-p))
4710 (article (or article (gnus-summary-article-number)))
4711 (arts (gnus-data-find-list article))
4713 (when (and (not dummy)
4714 (or (not gnus-summary-check-current)
4716 (not (gnus-data-unread-p (car arts)))))
4717 (setq arts (cdr arts)))
4722 (when (or (and undownloaded
4723 (eq gnus-undownloaded-mark
4724 (gnus-data-mark (car arts))))
4725 (gnus-data-unread-p (car arts)))
4726 (setq result (car arts)
4728 (setq arts (cdr arts)))
4731 (goto-char (gnus-data-pos result))
4732 (gnus-data-number result)))))
4734 (defun gnus-summary-find-prev (&optional unread article)
4735 (let* ((eobp (eobp))
4736 (article (or article (gnus-summary-article-number)))
4737 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
4739 (when (and (not eobp)
4740 (or (not gnus-summary-check-current)
4742 (not (gnus-data-unread-p (car arts)))))
4743 (setq arts (cdr arts)))
4748 (when (gnus-data-unread-p (car arts))
4749 (setq result (car arts)
4751 (setq arts (cdr arts)))
4754 (goto-char (gnus-data-pos result))
4755 (gnus-data-number result))))
4757 (defun gnus-summary-find-subject (subject &optional unread backward article)
4758 (let* ((simp-subject (gnus-simplify-subject-fully subject))
4759 (article (or article (gnus-summary-article-number)))
4760 (articles (gnus-data-list backward))
4761 (arts (gnus-data-find-list article articles))
4763 (when (or (not gnus-summary-check-current)
4765 (not (gnus-data-unread-p (car arts))))
4766 (setq arts (cdr arts)))
4768 (and (or (not unread)
4769 (gnus-data-unread-p (car arts)))
4770 (vectorp (gnus-data-header (car arts)))
4772 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
4773 (setq result (car arts)
4775 (setq arts (cdr arts)))
4777 (goto-char (gnus-data-pos result))
4778 (gnus-data-number result))))
4780 (defun gnus-summary-search-forward (&optional unread subject backward)
4781 "Search forward for an article.
4782 If UNREAD, look for unread articles. If SUBJECT, look for
4783 articles with that subject. If BACKWARD, search backward instead."
4784 (cond (subject (gnus-summary-find-subject subject unread backward))
4785 (backward (gnus-summary-find-prev unread))
4786 (t (gnus-summary-find-next unread))))
4788 (defun gnus-recenter (&optional n)
4789 "Center point in window and redisplay frame.
4790 Also do horizontal recentering."
4792 (when (and gnus-auto-center-summary
4793 (not (eq gnus-auto-center-summary 'vertical)))
4794 (gnus-horizontal-recenter))
4797 (defun gnus-summary-recenter ()
4798 "Center point in the summary window.
4799 If `gnus-auto-center-summary' is nil, or the article buffer isn't
4800 displayed, no centering will be performed."
4801 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
4802 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
4803 (let* ((top (cond ((< (window-height) 4) 0)
4804 ((< (window-height) 7) 1)
4806 (height (1- (window-height)))
4807 (bottom (save-excursion (goto-char (point-max))
4808 (forward-line (- height))
4810 (window (get-buffer-window (current-buffer))))
4811 ;; The user has to want it.
4812 (when gnus-auto-center-summary
4813 (when (get-buffer-window gnus-article-buffer)
4814 ;; Only do recentering when the article buffer is displayed,
4815 ;; Set the window start to either `bottom', which is the biggest
4816 ;; possible valid number, or the second line from the top,
4817 ;; whichever is the least.
4819 window (min bottom (save-excursion
4820 (forward-line (- top)) (point)))))
4821 ;; Do horizontal recentering while we're at it.
4822 (when (and (get-buffer-window (current-buffer) t)
4823 (not (eq gnus-auto-center-summary 'vertical)))
4824 (let ((selected (selected-window)))
4825 (select-window (get-buffer-window (current-buffer) t))
4826 (gnus-summary-position-point)
4827 (gnus-horizontal-recenter)
4828 (select-window selected))))))
4830 (defun gnus-summary-jump-to-group (newsgroup)
4831 "Move point to NEWSGROUP in group mode buffer."
4832 ;; Keep update point of group mode buffer if visible.
4833 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
4834 (save-window-excursion
4835 ;; Take care of tree window mode.
4836 (when (get-buffer-window gnus-group-buffer)
4837 (pop-to-buffer gnus-group-buffer))
4838 (gnus-group-jump-to-group newsgroup))
4840 ;; Take care of tree window mode.
4841 (if (get-buffer-window gnus-group-buffer)
4842 (pop-to-buffer gnus-group-buffer)
4843 (set-buffer gnus-group-buffer))
4844 (gnus-group-jump-to-group newsgroup))))
4846 ;; This function returns a list of article numbers based on the
4847 ;; difference between the ranges of read articles in this group and
4848 ;; the range of active articles.
4849 (defun gnus-list-of-unread-articles (group)
4850 (let* ((read (gnus-info-read (gnus-get-info group)))
4851 (active (or (gnus-active group) (gnus-activate-group group)))
4854 ;; If none are read, then all are unread.
4856 (setq first (car active))
4857 ;; If the range of read articles is a single range, then the
4858 ;; first unread article is the article after the last read
4859 ;; article. Sounds logical, doesn't it?
4860 (if (not (listp (cdr read)))
4861 (setq first (1+ (cdr read)))
4862 ;; `read' is a list of ranges.
4863 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
4869 (while (< first nlast)
4871 (setq first (1+ first))))
4872 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
4873 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
4874 (setq read (cdr read)))))
4875 ;; And add the last unread articles.
4876 (while (<= first last)
4878 (setq first (1+ first)))
4879 ;; Return the list of unread articles.
4880 (delq 0 (nreverse unread))))
4882 (defun gnus-list-of-read-articles (group)
4883 "Return a list of unread, unticked and non-dormant articles."
4884 (let* ((info (gnus-get-info group))
4885 (marked (gnus-info-marks info))
4886 (active (gnus-active group)))
4888 (gnus-set-difference
4889 (gnus-sorted-complement
4890 (gnus-uncompress-range active)
4891 (gnus-list-of-unread-articles group))
4893 (gnus-uncompress-range (cdr (assq 'dormant marked)))
4894 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
4896 ;; Various summary commands
4898 (defun gnus-summary-select-article-buffer ()
4899 "Reconfigure windows to show article buffer."
4901 (if (not (gnus-buffer-live-p gnus-article-buffer))
4902 (error "There is no article buffer for this summary buffer")
4903 (gnus-configure-windows 'article)
4904 (select-window (get-buffer-window gnus-article-buffer))))
4906 (defun gnus-summary-universal-argument (arg)
4907 "Perform any operation on all articles that are process/prefixed."
4909 (let ((articles (gnus-summary-work-articles arg))
4916 (substitute-command-keys
4917 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
4920 (gnus-error 1 "Undefined key")
4923 (gnus-summary-goto-subject (setq article (pop articles)))
4924 (let (gnus-newsgroup-processable)
4925 (command-execute func))
4926 (gnus-summary-remove-process-mark article)))))
4927 (gnus-summary-position-point))
4929 (defun gnus-summary-toggle-truncation (&optional arg)
4930 "Toggle truncation of summary lines.
4931 With arg, turn line truncation on iff arg is positive."
4933 (setq truncate-lines
4934 (if (null arg) (not truncate-lines)
4935 (> (prefix-numeric-value arg) 0)))
4938 (defun gnus-summary-reselect-current-group (&optional all rescan)
4939 "Exit and then reselect the current newsgroup.
4940 The prefix argument ALL means to select all articles."
4942 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
4943 (error "Ephemeral groups can't be reselected"))
4944 (let ((current-subject (gnus-summary-article-number))
4945 (group gnus-newsgroup-name))
4946 (setq gnus-newsgroup-begin nil)
4948 ;; We have to adjust the point of group mode buffer because
4949 ;; point was moved to the next unread newsgroup by exiting.
4950 (gnus-summary-jump-to-group group)
4953 (gnus-group-get-new-news-this-group 1)))
4954 (gnus-group-read-group all t)
4955 (gnus-summary-goto-subject current-subject nil t)))
4957 (defun gnus-summary-rescan-group (&optional all)
4958 "Exit the newsgroup, ask for new articles, and select the newsgroup."
4960 (gnus-summary-reselect-current-group all t))
4962 (defun gnus-summary-update-info (&optional non-destructive)
4964 (let ((group gnus-newsgroup-name))
4966 (when gnus-newsgroup-kill-headers
4967 (setq gnus-newsgroup-killed
4968 (gnus-compress-sequence
4970 (gnus-set-sorted-intersection
4971 (gnus-uncompress-range gnus-newsgroup-killed)
4972 (setq gnus-newsgroup-unselected
4973 (sort gnus-newsgroup-unselected '<)))
4974 (setq gnus-newsgroup-unreads
4975 (sort gnus-newsgroup-unreads '<)))
4977 (unless (listp (cdr gnus-newsgroup-killed))
4978 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
4979 (let ((headers gnus-newsgroup-headers))
4980 ;; Set the new ranges of read articles.
4982 (set-buffer gnus-group-buffer)
4983 (gnus-undo-force-boundary))
4984 (gnus-update-read-articles
4985 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
4986 ;; Set the current article marks.
4987 (let ((gnus-newsgroup-scored
4988 (if (and (not gnus-save-score)
4989 (not non-destructive))
4991 gnus-newsgroup-scored)))
4993 (gnus-update-marks)))
4994 ;; Do the cross-ref thing.
4995 (when gnus-use-cross-reference
4996 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
4997 ;; Do not switch windows but change the buffer to work.
4998 (set-buffer gnus-group-buffer)
4999 (unless (gnus-ephemeral-group-p group)
5000 (gnus-group-update-group group)))))))
5002 (defun gnus-summary-save-newsrc (&optional force)
5003 "Save the current number of read/marked articles in the dribble buffer.
5004 The dribble buffer will then be saved.
5005 If FORCE (the prefix), also save the .newsrc file(s)."
5007 (gnus-summary-update-info t)
5009 (gnus-save-newsrc-file)
5010 (gnus-dribble-save)))
5012 (defun gnus-summary-exit (&optional temporary)
5013 "Exit reading current newsgroup, and then return to group selection mode.
5014 gnus-exit-group-hook is called with no arguments if that value is non-nil."
5016 (gnus-set-global-variables)
5017 (gnus-kill-save-kill-buffer)
5018 (gnus-async-halt-prefetch)
5019 (let* ((group gnus-newsgroup-name)
5020 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5023 (buf (current-buffer)))
5024 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5025 ;; If we have several article buffers, we kill them at exit.
5026 (unless gnus-single-article-buffer
5027 (gnus-kill-buffer gnus-original-article-buffer)
5028 (setq gnus-article-current nil))
5029 (when gnus-use-cache
5030 (gnus-cache-possibly-remove-articles)
5031 (gnus-cache-save-buffers))
5032 (gnus-async-prefetch-remove-group group)
5033 (when gnus-suppress-duplicates
5034 (gnus-dup-enter-articles))
5035 (when gnus-use-trees
5036 (gnus-tree-close group))
5037 ;; Remove entries for this group.
5038 (nnmail-purge-split-history (gnus-group-real-name group))
5039 ;; Make all changes in this group permanent.
5041 (gnus-run-hooks 'gnus-exit-group-hook)
5042 (gnus-summary-update-info)
5043 ;; Do adaptive scoring, and possibly save score files.
5044 (when gnus-newsgroup-adaptive
5045 (gnus-score-adaptive))
5046 (when gnus-use-scoring
5048 (gnus-close-group group)
5049 ;; Make sure where we were, and go to next newsgroup.
5050 (set-buffer gnus-group-buffer)
5052 (gnus-group-jump-to-group group))
5053 (gnus-run-hooks 'gnus-summary-exit-hook)
5054 (unless (or quit-config
5055 ;; If this group has disappeared from the summary
5056 ;; buffer, don't skip forwards.
5057 (not (string= group (gnus-group-group-name))))
5058 (gnus-group-next-unread-group 1))
5059 (setq group-point (point))
5062 ;; If we have several article buffers, we kill them at exit.
5063 (unless gnus-single-article-buffer
5064 (gnus-kill-buffer gnus-article-buffer)
5065 (gnus-kill-buffer gnus-original-article-buffer)
5066 (setq gnus-article-current nil))
5068 (if (not gnus-kill-summary-on-exit)
5069 (gnus-deaden-summary)
5070 ;; We set all buffer-local variables to nil. It is unclear why
5071 ;; this is needed, but if we don't, buffer-local variables are
5072 ;; not garbage-collected, it seems. This would the lead to en
5073 ;; ever-growing Emacs.
5074 (gnus-summary-clear-local-variables)
5075 (when (get-buffer gnus-article-buffer)
5076 (bury-buffer gnus-article-buffer))
5077 ;; We clear the global counterparts of the buffer-local
5078 ;; variables as well, just to be on the safe side.
5079 (set-buffer gnus-group-buffer)
5080 (gnus-summary-clear-local-variables)
5081 ;; Return to group mode buffer.
5082 (when (eq mode 'gnus-summary-mode)
5083 (gnus-kill-buffer buf)))
5084 (setq gnus-current-select-method gnus-select-method)
5085 (pop-to-buffer gnus-group-buffer)
5086 ;; Clear the current group name.
5087 (if (not quit-config)
5089 (goto-char group-point)
5090 (gnus-configure-windows 'group 'force))
5091 (gnus-handle-ephemeral-exit quit-config))
5093 (setq gnus-newsgroup-name nil)))))
5095 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5096 (defun gnus-summary-exit-no-update (&optional no-questions)
5097 "Quit reading current newsgroup without updating read article info."
5099 (let* ((group gnus-newsgroup-name)
5100 (quit-config (gnus-group-quit-config group)))
5101 (when (or no-questions
5103 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5104 (gnus-async-halt-prefetch)
5105 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5106 ;; If we have several article buffers, we kill them at exit.
5107 (unless gnus-single-article-buffer
5108 (gnus-kill-buffer gnus-article-buffer)
5109 (gnus-kill-buffer gnus-original-article-buffer)
5110 (setq gnus-article-current nil))
5111 (if (not gnus-kill-summary-on-exit)
5112 (gnus-deaden-summary)
5113 (gnus-close-group group)
5114 (gnus-summary-clear-local-variables)
5115 (set-buffer gnus-group-buffer)
5116 (gnus-summary-clear-local-variables)
5117 (when (get-buffer gnus-summary-buffer)
5118 (kill-buffer gnus-summary-buffer)))
5119 (unless gnus-single-article-buffer
5120 (setq gnus-article-current nil))
5121 (when gnus-use-trees
5122 (gnus-tree-close group))
5123 (gnus-async-prefetch-remove-group group)
5124 (when (get-buffer gnus-article-buffer)
5125 (bury-buffer gnus-article-buffer))
5126 ;; Return to the group buffer.
5127 (gnus-configure-windows 'group 'force)
5128 ;; Clear the current group name.
5129 (setq gnus-newsgroup-name nil)
5130 (when (equal (gnus-group-group-name) group)
5131 (gnus-group-next-unread-group 1))
5133 (gnus-handle-ephemeral-exit quit-config)))))
5135 (defun gnus-handle-ephemeral-exit (quit-config)
5136 "Handle movement when leaving an ephemeral group.
5137 The state which existed when entering the ephemeral is reset."
5138 (if (not (buffer-name (car quit-config)))
5139 (gnus-configure-windows 'group 'force)
5140 (set-buffer (car quit-config))
5141 (cond ((eq major-mode 'gnus-summary-mode)
5142 (gnus-set-global-variables))
5143 ((eq major-mode 'gnus-article-mode)
5145 ;; The `gnus-summary-buffer' variable may point
5146 ;; to the old summary buffer when using a single
5148 (unless (gnus-buffer-live-p gnus-summary-buffer)
5149 (set-buffer gnus-group-buffer))
5150 (set-buffer gnus-summary-buffer)
5151 (gnus-set-global-variables))))
5152 (if (or (eq (cdr quit-config) 'article)
5153 (eq (cdr quit-config) 'pick))
5155 ;; The current article may be from the ephemeral group
5156 ;; thus it is best that we reload this article
5157 (gnus-summary-show-article)
5158 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5159 (gnus-configure-windows 'pick 'force)
5160 (gnus-configure-windows (cdr quit-config) 'force)))
5161 (gnus-configure-windows (cdr quit-config) 'force))
5162 (when (eq major-mode 'gnus-summary-mode)
5163 (gnus-summary-next-subject 1 nil t)
5164 (gnus-summary-recenter)
5165 (gnus-summary-position-point))))
5167 (defun gnus-summary-preview-mime-message (arg)
5168 "MIME decode and play this message."
5170 (let ((gnus-break-pages nil))
5171 (gnus-summary-select-article t t)
5173 (pop-to-buffer gnus-original-article-buffer t)
5174 (let (buffer-read-only)
5175 (if (text-property-any (point-min) (point-max) 'invisible t)
5176 (remove-text-properties (point-min) (point-max)
5177 gnus-hidden-properties)
5179 (mime-view-mode nil nil nil gnus-original-article-buffer
5180 gnus-article-buffer)
5183 (defun gnus-summary-scroll-down ()
5184 "Scroll down one line current article."
5186 (gnus-summary-scroll-up -1)
5191 (defvar gnus-dead-summary-mode-map nil)
5193 (unless gnus-dead-summary-mode-map
5194 (setq gnus-dead-summary-mode-map (make-keymap))
5195 (suppress-keymap gnus-dead-summary-mode-map)
5196 (substitute-key-definition
5197 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5198 (let ((keys '("\C-d" "\r" "\177" [delete])))
5200 (define-key gnus-dead-summary-mode-map
5201 (pop keys) 'gnus-summary-wake-up-the-dead))))
5203 (defvar gnus-dead-summary-mode nil
5204 "Minor mode for Gnus summary buffers.")
5206 (defun gnus-dead-summary-mode (&optional arg)
5207 "Minor mode for Gnus summary buffers."
5209 (when (eq major-mode 'gnus-summary-mode)
5210 (make-local-variable 'gnus-dead-summary-mode)
5211 (setq gnus-dead-summary-mode
5212 (if (null arg) (not gnus-dead-summary-mode)
5213 (> (prefix-numeric-value arg) 0)))
5214 (when gnus-dead-summary-mode
5215 (gnus-add-minor-mode
5216 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5218 (defun gnus-deaden-summary ()
5219 "Make the current summary buffer into a dead summary buffer."
5220 ;; Kill any previous dead summary buffer.
5221 (when (and gnus-dead-summary
5222 (buffer-name gnus-dead-summary))
5224 (set-buffer gnus-dead-summary)
5225 (when gnus-dead-summary-mode
5226 (kill-buffer (current-buffer)))))
5227 ;; Make this the current dead summary.
5228 (setq gnus-dead-summary (current-buffer))
5229 (gnus-dead-summary-mode 1)
5230 (let ((name (buffer-name)))
5231 (when (string-match "Summary" name)
5233 (concat (substring name 0 (match-beginning 0)) "Dead "
5234 (substring name (match-beginning 0)))
5237 (defun gnus-kill-or-deaden-summary (buffer)
5238 "Kill or deaden the summary BUFFER."
5240 (when (and (buffer-name buffer)
5241 (not gnus-single-article-buffer))
5244 (gnus-kill-buffer gnus-article-buffer)
5245 (gnus-kill-buffer gnus-original-article-buffer)))
5246 (cond (gnus-kill-summary-on-exit
5247 (when (and gnus-use-trees
5248 (gnus-buffer-exists-p buffer))
5251 (gnus-tree-close gnus-newsgroup-name)))
5252 (gnus-kill-buffer buffer))
5253 ((gnus-buffer-exists-p buffer)
5256 (gnus-deaden-summary))))))
5258 (defun gnus-summary-wake-up-the-dead (&rest args)
5259 "Wake up the dead summary buffer."
5261 (gnus-dead-summary-mode -1)
5262 (let ((name (buffer-name)))
5263 (when (string-match "Dead " name)
5265 (concat (substring name 0 (match-beginning 0))
5266 (substring name (match-end 0)))
5268 (gnus-message 3 "This dead summary is now alive again"))
5270 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5271 (defun gnus-summary-fetch-faq (&optional faq-dir)
5272 "Fetch the FAQ for the current group.
5273 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5277 (when current-prefix-arg
5279 "Faq dir: " (and (listp gnus-group-faq-directory)
5280 (mapcar (lambda (file) (list file))
5281 gnus-group-faq-directory))))))
5282 (let (gnus-faq-buffer)
5283 (when (setq gnus-faq-buffer
5284 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5285 (gnus-configure-windows 'summary-faq))))
5287 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5288 (defun gnus-summary-describe-group (&optional force)
5289 "Describe the current newsgroup."
5291 (gnus-group-describe-group force gnus-newsgroup-name))
5293 (defun gnus-summary-describe-briefly ()
5294 "Describe summary mode commands briefly."
5297 (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")))
5299 ;; Walking around group mode buffer from summary mode.
5301 (defun gnus-summary-next-group (&optional no-article target-group backward)
5302 "Exit current newsgroup and then select next unread newsgroup.
5303 If prefix argument NO-ARTICLE is non-nil, no article is selected
5304 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5305 previous group instead."
5307 ;; Stop pre-fetching.
5308 (gnus-async-halt-prefetch)
5309 (let ((current-group gnus-newsgroup-name)
5310 (current-buffer (current-buffer))
5312 ;; First we semi-exit this group to update Xrefs and all variables.
5313 ;; We can't do a real exit, because the window conf must remain
5314 ;; the same in case the user is prompted for info, and we don't
5315 ;; want the window conf to change before that...
5316 (gnus-summary-exit t)
5317 (while (not entered)
5318 ;; Then we find what group we are supposed to enter.
5319 (set-buffer gnus-group-buffer)
5320 (gnus-group-jump-to-group current-group)
5323 (if (eq gnus-keep-same-level 'best)
5324 (gnus-summary-best-group gnus-newsgroup-name)
5325 (gnus-summary-search-group backward gnus-keep-same-level))))
5326 (if (not target-group)
5327 ;; There are no further groups, so we return to the group
5330 (gnus-message 5 "Returning to the group buffer")
5332 (when (gnus-buffer-live-p current-buffer)
5333 (set-buffer current-buffer)
5334 (gnus-summary-exit))
5335 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5336 ;; We try to enter the target group.
5337 (gnus-group-jump-to-group target-group)
5338 (let ((unreads (gnus-group-group-unread)))
5339 (if (and (or (eq t unreads)
5340 (and unreads (not (zerop unreads))))
5341 (gnus-summary-read-group
5342 target-group nil no-article
5343 (and (buffer-name current-buffer) current-buffer)
5346 (setq current-group target-group
5347 target-group nil)))))))
5349 (defun gnus-summary-prev-group (&optional no-article)
5350 "Exit current newsgroup and then select previous unread newsgroup.
5351 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5353 (gnus-summary-next-group no-article nil t))
5355 ;; Walking around summary lines.
5357 (defun gnus-summary-first-subject (&optional unread undownloaded)
5358 "Go to the first unread subject.
5359 If UNREAD is non-nil, go to the first unread article.
5360 Returns the article selected or nil if there are no unread articles."
5365 ((null gnus-newsgroup-data)
5366 (gnus-message 3 "No articles in the group")
5368 ;; Pick the first article.
5370 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5371 (gnus-data-number (car gnus-newsgroup-data)))
5372 ;; No unread articles.
5373 ((null gnus-newsgroup-unreads)
5374 (gnus-message 3 "No more unread articles")
5376 ;; Find the first unread article.
5378 (let ((data gnus-newsgroup-data))
5380 (and (not (and undownloaded
5381 (eq gnus-undownloaded-mark
5382 (gnus-data-mark (car data)))))
5383 (not (gnus-data-unread-p (car data)))))
5384 (setq data (cdr data)))
5386 (goto-char (gnus-data-pos (car data)))
5387 (gnus-data-number (car data))))))
5388 (gnus-summary-position-point)))
5390 (defun gnus-summary-next-subject (n &optional unread dont-display)
5391 "Go to next N'th summary line.
5392 If N is negative, go to the previous N'th subject line.
5393 If UNREAD is non-nil, only unread articles are selected.
5394 The difference between N and the actual number of steps taken is
5397 (let ((backward (< n 0))
5401 (gnus-summary-find-prev unread)
5402 (gnus-summary-find-next unread)))
5403 (gnus-summary-show-thread)
5406 (gnus-message 7 "No more%s articles"
5407 (if unread " unread" "")))
5408 (unless dont-display
5409 (gnus-summary-recenter)
5410 (gnus-summary-position-point))
5413 (defun gnus-summary-next-unread-subject (n)
5414 "Go to next N'th unread summary line."
5416 (gnus-summary-next-subject n t))
5418 (defun gnus-summary-prev-subject (n &optional unread)
5419 "Go to previous N'th summary line.
5420 If optional argument UNREAD is non-nil, only unread article is selected."
5422 (gnus-summary-next-subject (- n) unread))
5424 (defun gnus-summary-prev-unread-subject (n)
5425 "Go to previous N'th unread summary line."
5427 (gnus-summary-next-subject (- n) t))
5429 (defun gnus-summary-goto-subject (article &optional force silent)
5430 "Go the subject line of ARTICLE.
5431 If FORCE, also allow jumping to articles not currently shown."
5432 (interactive "nArticle number: ")
5434 (data (gnus-data-find article)))
5435 ;; We read in the article if we have to.
5438 (gnus-summary-insert-subject
5440 (if (or (numberp force) (vectorp force)) force)
5442 (setq data (gnus-data-find article)))
5447 (gnus-message 3 "Can't find article %d" article))
5449 (goto-char (gnus-data-pos data))
5452 ;; Walking around summary lines with displaying articles.
5454 (defun gnus-summary-expand-window (&optional arg)
5455 "Make the summary buffer take up the entire Emacs frame.
5456 Given a prefix, will force an `article' buffer configuration."
5459 (gnus-configure-windows 'article 'force)
5460 (gnus-configure-windows 'summary 'force)))
5462 (defun gnus-summary-display-article (article &optional all-header)
5463 "Display ARTICLE in article buffer."
5464 (gnus-set-global-variables)
5468 (if gnus-summary-display-article-function
5469 (funcall gnus-summary-display-article-function article all-header)
5470 (gnus-article-prepare article all-header))
5471 (gnus-run-hooks 'gnus-select-article-hook)
5472 (when (and gnus-current-article
5473 (not (zerop gnus-current-article)))
5474 (gnus-summary-goto-subject gnus-current-article))
5475 (gnus-summary-recenter)
5476 (when (and gnus-use-trees gnus-show-threads)
5477 (gnus-possibly-generate-tree article)
5478 (gnus-highlight-selected-tree article))
5479 ;; Successfully display article.
5480 (gnus-article-set-window-start
5481 (cdr (assq article gnus-newsgroup-bookmarks))))))
5483 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5484 "Select the current article.
5485 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5486 non-nil, the article will be re-fetched even if it already present in
5487 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5489 ;; Make sure we are in the summary buffer to work around bbdb bug.
5490 (unless (eq major-mode 'gnus-summary-mode)
5491 (set-buffer gnus-summary-buffer))
5492 (let ((article (or article (gnus-summary-article-number)))
5493 (all-headers (not (not all-headers))) ;Must be T or NIL.
5494 gnus-summary-display-article-function
5497 (gnus-summary-article-pseudo-p article)
5498 (error "This is a pseudo-article"))
5501 (set-buffer gnus-summary-buffer)
5502 (if (or (and gnus-single-article-buffer
5503 (or (null gnus-current-article)
5504 (null gnus-article-current)
5505 (null (get-buffer gnus-article-buffer))
5506 (not (eq article (cdr gnus-article-current)))
5507 (not (equal (car gnus-article-current)
5508 gnus-newsgroup-name))))
5509 (and (not gnus-single-article-buffer)
5510 (or (null gnus-current-article)
5511 (not (eq gnus-current-article article))))
5513 ;; The requested article is different from the current article.
5515 (gnus-summary-display-article article all-headers)
5517 (when (or all-headers gnus-show-all-headers)
5518 (gnus-article-show-all-headers))
5521 (gnus-article-set-window-start
5522 (cdr (assq article gnus-newsgroup-bookmarks)))))))
5524 (defun gnus-summary-set-current-mark (&optional current-mark)
5525 "Obsolete function."
5528 (defun gnus-summary-next-article (&optional unread subject backward push)
5529 "Select the next article.
5530 If UNREAD, only unread articles are selected.
5531 If SUBJECT, only articles with SUBJECT are selected.
5532 If BACKWARD, the previous article is selected instead of the next."
5535 ;; Is there such an article?
5536 ((and (gnus-summary-search-forward unread subject backward)
5537 (or (gnus-summary-display-article (gnus-summary-article-number))
5538 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5539 (gnus-summary-position-point))
5540 ;; If not, we try the first unread, if that is wanted.
5542 gnus-auto-select-same
5543 (gnus-summary-first-unread-article))
5544 (gnus-summary-position-point)
5545 (gnus-message 6 "Wrapped"))
5546 ;; Try to get next/previous article not displayed in this group.
5547 ((and gnus-auto-extend-newsgroup
5548 (not unread) (not subject))
5549 (gnus-summary-goto-article
5550 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5551 nil (count-lines (point-min) (point))))
5552 ;; Go to next/previous group.
5554 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5555 (gnus-summary-jump-to-group gnus-newsgroup-name))
5556 (let ((cmd last-command-char)
5559 (set-buffer gnus-group-buffer)
5562 (if (eq gnus-keep-same-level 'best)
5563 (gnus-summary-best-group gnus-newsgroup-name)
5564 (gnus-summary-search-group backward gnus-keep-same-level))))
5565 ;; For some reason, the group window gets selected. We change
5567 (select-window (get-buffer-window (current-buffer)))
5568 ;; Select next unread newsgroup automagically.
5570 ((or (not gnus-auto-select-next)
5572 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5573 ((or (eq gnus-auto-select-next 'quietly)
5574 (and (eq gnus-auto-select-next 'slightly-quietly)
5576 (and (eq gnus-auto-select-next 'almost-quietly)
5577 (gnus-summary-last-article-p)))
5579 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5581 (gnus-message 7 "No more%s articles (%s)..."
5582 (if unread " unread" "")
5583 (if group (concat "selecting " group)
5585 (gnus-summary-next-group nil group backward)))
5587 (when (gnus-key-press-event-p last-input-event)
5588 (gnus-summary-walk-group-buffer
5589 gnus-newsgroup-name cmd unread backward point))))))))
5591 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5592 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5593 (?\C-p (gnus-group-prev-unread-group 1))))
5594 (cursor-in-echo-area t)
5595 keve key group ended)
5597 (set-buffer gnus-group-buffer)
5600 (if (eq gnus-keep-same-level 'best)
5601 (gnus-summary-best-group gnus-newsgroup-name)
5602 (gnus-summary-search-group backward gnus-keep-same-level))))
5605 5 "No more%s articles%s" (if unread " unread" "")
5607 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5608 (format " (Type %s for %s [%s])"
5609 (single-key-description cmd) group
5610 (car (gnus-gethash group gnus-newsrc-hashtb)))
5611 (format " (Type %s to exit %s)"
5612 (single-key-description cmd)
5613 gnus-newsgroup-name)))
5614 ;; Confirm auto selection.
5615 (setq key (car (setq keve (gnus-read-event-char))))
5618 ((assq key keystrokes)
5619 (let ((obuf (current-buffer)))
5620 (switch-to-buffer gnus-group-buffer)
5622 (gnus-group-jump-to-group group))
5623 (eval (cadr (assq key keystrokes)))
5624 (setq group (gnus-group-group-name))
5625 (switch-to-buffer obuf))
5629 (gnus-ephemeral-group-p gnus-newsgroup-name))
5631 (gnus-summary-next-group nil group backward)))
5633 (push (cdr keve) unread-command-events))))))
5635 (defun gnus-summary-next-unread-article ()
5636 "Select unread article after current one."
5638 (gnus-summary-next-article
5639 (or (not (eq gnus-summary-goto-unread 'never))
5640 (gnus-summary-last-article-p (gnus-summary-article-number)))
5641 (and gnus-auto-select-same
5642 (gnus-summary-article-subject))))
5644 (defun gnus-summary-prev-article (&optional unread subject)
5645 "Select the article after the current one.
5646 If UNREAD is non-nil, only unread articles are selected."
5648 (gnus-summary-next-article unread subject t))
5650 (defun gnus-summary-prev-unread-article ()
5651 "Select unread article before current one."
5653 (gnus-summary-prev-article
5654 (or (not (eq gnus-summary-goto-unread 'never))
5655 (gnus-summary-first-article-p (gnus-summary-article-number)))
5656 (and gnus-auto-select-same
5657 (gnus-summary-article-subject))))
5659 (defun gnus-summary-next-page (&optional lines circular)
5660 "Show next page of the selected article.
5661 If at the end of the current article, select the next article.
5662 LINES says how many lines should be scrolled up.
5664 If CIRCULAR is non-nil, go to the start of the article instead of
5665 selecting the next article when reaching the end of the current
5668 (setq gnus-summary-buffer (current-buffer))
5669 (gnus-set-global-variables)
5670 (let ((article (gnus-summary-article-number))
5671 (article-window (get-buffer-window gnus-article-buffer t))
5673 ;; If the buffer is empty, we have no article.
5675 (error "No article to select"))
5676 (gnus-configure-windows 'article)
5677 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
5678 (if (and (eq gnus-summary-goto-unread 'never)
5679 (not (gnus-summary-last-article-p article)))
5680 (gnus-summary-next-article)
5681 (gnus-summary-next-unread-article))
5682 (if (or (null gnus-current-article)
5683 (null gnus-article-current)
5684 (/= article (cdr gnus-article-current))
5685 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5686 ;; Selected subject is different from current article's.
5687 (gnus-summary-display-article article)
5688 (when article-window
5689 (gnus-eval-in-buffer-window gnus-article-buffer
5690 (setq endp (gnus-article-next-page lines)))
5693 (gnus-summary-beginning-of-article))
5695 (gnus-message 3 "End of message"))
5697 (if (and (eq gnus-summary-goto-unread 'never)
5698 (not (gnus-summary-last-article-p article)))
5699 (gnus-summary-next-article)
5700 (gnus-summary-next-unread-article))))))))
5701 (gnus-summary-recenter)
5702 (gnus-summary-position-point)))
5704 (defun gnus-summary-prev-page (&optional lines move)
5705 "Show previous page of selected article.
5706 Argument LINES specifies lines to be scrolled down.
5707 If MOVE, move to the previous unread article if point is at
5708 the beginning of the buffer."
5710 (let ((article (gnus-summary-article-number))
5711 (article-window (get-buffer-window gnus-article-buffer t))
5713 (gnus-configure-windows 'article)
5714 (if (or (null gnus-current-article)
5715 (null gnus-article-current)
5716 (/= article (cdr gnus-article-current))
5717 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5718 ;; Selected subject is different from current article's.
5719 (gnus-summary-display-article article)
5720 (gnus-summary-recenter)
5721 (when article-window
5722 (gnus-eval-in-buffer-window gnus-article-buffer
5723 (setq endp (gnus-article-prev-page lines)))
5724 (when (and move endp)
5726 (gnus-message 3 "Beginning of message"))
5728 (if (and (eq gnus-summary-goto-unread 'never)
5729 (not (gnus-summary-first-article-p article)))
5730 (gnus-summary-prev-article)
5731 (gnus-summary-prev-unread-article))))))))
5732 (gnus-summary-position-point))
5734 (defun gnus-summary-prev-page-or-article (&optional lines)
5735 "Show previous page of selected article.
5736 Argument LINES specifies lines to be scrolled down.
5737 If at the beginning of the article, go to the next article."
5739 (gnus-summary-prev-page lines t))
5741 (defun gnus-summary-scroll-up (lines)
5742 "Scroll up (or down) one line current article.
5743 Argument LINES specifies lines to be scrolled up (or down if negative)."
5745 (gnus-configure-windows 'article)
5746 (gnus-summary-show-thread)
5747 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
5748 (gnus-eval-in-buffer-window gnus-article-buffer
5750 (when (gnus-article-next-page lines)
5751 (gnus-message 3 "End of message")))
5753 (gnus-article-prev-page (- lines))))))
5754 (gnus-summary-recenter)
5755 (gnus-summary-position-point))
5757 (defun gnus-summary-next-same-subject ()
5758 "Select next article which has the same subject as current one."
5760 (gnus-summary-next-article nil (gnus-summary-article-subject)))
5762 (defun gnus-summary-prev-same-subject ()
5763 "Select previous article which has the same subject as current one."
5765 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
5767 (defun gnus-summary-next-unread-same-subject ()
5768 "Select next unread article which has the same subject as current one."
5770 (gnus-summary-next-article t (gnus-summary-article-subject)))
5772 (defun gnus-summary-prev-unread-same-subject ()
5773 "Select previous unread article which has the same subject as current one."
5775 (gnus-summary-prev-article t (gnus-summary-article-subject)))
5777 (defun gnus-summary-first-unread-article ()
5778 "Select the first unread article.
5779 Return nil if there are no unread articles."
5782 (when (gnus-summary-first-subject t)
5783 (gnus-summary-show-thread)
5784 (gnus-summary-first-subject t)
5785 (gnus-summary-display-article (gnus-summary-article-number)))
5786 (gnus-summary-position-point)))
5788 (defun gnus-summary-first-article ()
5789 "Select the first article.
5790 Return nil if there are no articles."
5793 (when (gnus-summary-first-subject)
5794 (gnus-summary-show-thread)
5795 (gnus-summary-first-subject)
5796 (gnus-summary-display-article (gnus-summary-article-number)))
5797 (gnus-summary-position-point)))
5799 (defun gnus-summary-best-unread-article ()
5800 "Select the unread article with the highest score."
5802 (let ((best -1000000)
5803 (data gnus-newsgroup-data)
5806 (and (gnus-data-unread-p (car data))
5808 (gnus-summary-article-score (gnus-data-number (car data))))
5811 article (gnus-data-number (car data))))
5812 (setq data (cdr data)))
5815 (gnus-summary-goto-article article)
5816 (error "No unread articles"))
5817 (gnus-summary-position-point))))
5819 (defun gnus-summary-last-subject ()
5820 "Go to the last displayed subject line in the group."
5821 (let ((article (gnus-data-number (car (gnus-data-list t)))))
5823 (gnus-summary-goto-subject article))))
5825 (defun gnus-summary-goto-article (article &optional all-headers force)
5826 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
5827 If ALL-HEADERS is non-nil, no header lines are hidden.
5828 If FORCE, go to the article even if it isn't displayed. If FORCE
5829 is a number, it is the line the article is to be displayed on."
5833 "Article number or Message-ID: "
5834 (mapcar (lambda (number) (list (int-to-string number)))
5835 gnus-newsgroup-limit))
5839 (if (and (stringp article)
5840 (string-match "@" article))
5841 (gnus-summary-refer-article article)
5842 (when (stringp article)
5843 (setq article (string-to-number article)))
5844 (if (gnus-summary-goto-subject article force)
5845 (gnus-summary-display-article article all-headers)
5846 (gnus-message 4 "Couldn't go to article %s" article) nil))
5847 (gnus-summary-position-point)))
5849 (defun gnus-summary-goto-last-article ()
5850 "Go to the previously read article."
5853 (when gnus-last-article
5854 (gnus-summary-goto-article gnus-last-article nil t))
5855 (gnus-summary-position-point)))
5857 (defun gnus-summary-pop-article (number)
5858 "Pop one article off the history and go to the previous.
5859 NUMBER articles will be popped off."
5862 (setq gnus-newsgroup-history
5863 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
5865 (gnus-summary-goto-article (car to) nil t)
5866 (error "Article history empty")))
5867 (gnus-summary-position-point))
5869 ;; Summary commands and functions for limiting the summary buffer.
5871 (defun gnus-summary-limit-to-articles (n)
5872 "Limit the summary buffer to the next N articles.
5873 If not given a prefix, use the process marked articles instead."
5876 (let ((articles (gnus-summary-work-articles n)))
5877 (setq gnus-newsgroup-processable nil)
5878 (gnus-summary-limit articles))
5879 (gnus-summary-position-point)))
5881 (defun gnus-summary-pop-limit (&optional total)
5882 "Restore the previous limit.
5883 If given a prefix, remove all limits."
5886 (setq gnus-newsgroup-limits
5887 (list (mapcar (lambda (h) (mail-header-number h))
5888 gnus-newsgroup-headers))))
5889 (unless gnus-newsgroup-limits
5890 (error "No limit to pop"))
5892 (gnus-summary-limit nil 'pop)
5893 (gnus-summary-position-point)))
5895 (defun gnus-summary-limit-to-subject (subject &optional header)
5896 "Limit the summary buffer to articles that have subjects that match a regexp."
5897 (interactive "sLimit to subject (regexp): ")
5899 (setq header "subject"))
5900 (when (not (equal "" subject))
5902 (let ((articles (gnus-summary-find-matching
5903 (or header "subject") subject 'all)))
5905 (error "Found no matches for \"%s\"" subject))
5906 (gnus-summary-limit articles))
5907 (gnus-summary-position-point))))
5909 (defun gnus-summary-limit-to-author (from)
5910 "Limit the summary buffer to articles that have authors that match a regexp."
5911 (interactive "sLimit to author (regexp): ")
5912 (gnus-summary-limit-to-subject from "from"))
5914 (defun gnus-summary-limit-to-age (age &optional younger-p)
5915 "Limit the summary buffer to articles that are older than (or equal) AGE days.
5916 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
5917 articles that are younger than AGE days."
5918 (interactive "nTime in days: \nP")
5920 (let ((data gnus-newsgroup-data)
5921 (cutoff (nnmail-days-to-time age))
5922 articles d date is-younger)
5923 (while (setq d (pop data))
5924 (when (and (vectorp (gnus-data-header d))
5925 (setq date (mail-header-date (gnus-data-header d))))
5926 (setq is-younger (nnmail-time-less
5927 (nnmail-time-since (nnmail-date-to-time date))
5932 (push (gnus-data-number d) articles))))
5933 (gnus-summary-limit (nreverse articles)))
5934 (gnus-summary-position-point)))
5936 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5938 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5940 (defun gnus-summary-limit-to-unread (&optional all)
5941 "Limit the summary buffer to articles that are not marked as read.
5942 If ALL is non-nil, limit strictly to unread articles."
5945 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
5946 (gnus-summary-limit-to-marks
5947 ;; Concat all the marks that say that an article is read and have
5949 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
5950 gnus-killed-mark gnus-kill-file-mark
5951 gnus-low-score-mark gnus-expirable-mark
5952 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
5953 gnus-duplicate-mark gnus-souped-mark)
5956 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
5957 (make-obsolete 'gnus-summary-delete-marked-with
5958 'gnus-summary-limit-exlude-marks)
5960 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
5961 "Exclude articles that are marked with MARKS (e.g. \"DK\").
5962 If REVERSE, limit the summary buffer to articles that are marked
5963 with MARKS. MARKS can either be a string of marks or a list of marks.
5964 Returns how many articles were removed."
5965 (interactive "sMarks: ")
5966 (gnus-summary-limit-to-marks marks t))
5968 (defun gnus-summary-limit-to-marks (marks &optional reverse)
5969 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
5970 If REVERSE (the prefix), limit the summary buffer to articles that are
5971 not marked with MARKS. MARKS can either be a string of marks or a
5973 Returns how many articles were removed."
5974 (interactive "sMarks: \nP")
5976 (let ((data gnus-newsgroup-data)
5977 (marks (if (listp marks) marks
5978 (append marks nil))) ; Transform to list.
5981 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
5982 (memq (gnus-data-mark (car data)) marks))
5983 (push (gnus-data-number (car data)) articles))
5984 (setq data (cdr data)))
5985 (gnus-summary-limit articles))
5986 (gnus-summary-position-point)))
5988 (defun gnus-summary-limit-to-score (&optional score)
5989 "Limit to articles with score at or above SCORE."
5991 (setq score (if score
5992 (prefix-numeric-value score)
5993 (or gnus-summary-default-score 0)))
5994 (let ((data gnus-newsgroup-data)
5997 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
5999 (push (gnus-data-number (car data)) articles))
6000 (setq data (cdr data)))
6002 (gnus-summary-limit articles)
6003 (gnus-summary-position-point))))
6005 (defun gnus-summary-limit-include-thread (id)
6006 "Display all the hidden articles that in the current thread."
6007 (interactive (list (mail-header-id (gnus-summary-article-header))))
6008 (let ((articles (gnus-articles-in-thread
6009 (gnus-id-to-thread (gnus-root-id id)))))
6011 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6012 (gnus-summary-position-point))))
6014 (defun gnus-summary-limit-include-dormant ()
6015 "Display all the hidden articles that are marked as dormant.
6016 Note that this command only works on a subset of the articles currently
6017 fetched for this group."
6019 (unless gnus-newsgroup-dormant
6020 (error "There are no dormant articles in this group"))
6022 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6023 (gnus-summary-position-point)))
6025 (defun gnus-summary-limit-exclude-dormant ()
6026 "Hide all dormant articles."
6029 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6030 (gnus-summary-position-point)))
6032 (defun gnus-summary-limit-exclude-childless-dormant ()
6033 "Hide all dormant articles that have no children."
6035 (let ((data (gnus-data-list t))
6036 articles d children)
6037 ;; Find all articles that are either not dormant or have
6039 (while (setq d (pop data))
6040 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6042 (gnus-article-children (gnus-data-number d)))
6045 (when (memq (car children) articles)
6050 (push (gnus-data-number d) articles)))
6053 (gnus-summary-limit articles)
6054 (gnus-summary-position-point))))
6056 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6057 "Mark all unread excluded articles as read.
6058 If ALL, mark even excluded ticked and dormants as read."
6060 (let ((articles (gnus-sorted-complement
6062 (mapcar (lambda (h) (mail-header-number h))
6063 gnus-newsgroup-headers)
6065 (sort gnus-newsgroup-limit '<)))
6067 (setq gnus-newsgroup-unreads gnus-newsgroup-limit)
6069 (setq gnus-newsgroup-dormant nil
6070 gnus-newsgroup-marked nil
6071 gnus-newsgroup-reads
6073 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6074 gnus-newsgroup-reads))
6075 (while (setq article (pop articles))
6076 (unless (or (memq article gnus-newsgroup-dormant)
6077 (memq article gnus-newsgroup-marked))
6078 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6080 (defun gnus-summary-limit (articles &optional pop)
6082 ;; We pop the previous limit off the stack and use that.
6083 (setq articles (car gnus-newsgroup-limits)
6084 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6085 ;; We use the new limit, so we push the old limit on the stack.
6086 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6088 (setq gnus-newsgroup-limit articles)
6089 (let ((total (length gnus-newsgroup-data))
6090 (data (gnus-data-find-list (gnus-summary-article-number)))
6091 (gnus-summary-mark-below nil) ; Inhibit this.
6093 ;; This will do all the work of generating the new summary buffer
6094 ;; according to the new limit.
6095 (gnus-summary-prepare)
6096 ;; Hide any threads, possibly.
6097 (and gnus-show-threads
6098 gnus-thread-hide-subtree
6099 (gnus-summary-hide-all-threads))
6100 ;; Try to return to the article you were at, or one in the
6103 ;; We try to find some article after the current one.
6105 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6108 (setq data (cdr data))))
6110 ;; If there is no data, that means that we were after the last
6111 ;; article. The same goes when we can't find any articles
6112 ;; after the current one.
6113 (goto-char (point-max))
6114 (gnus-summary-find-prev))
6115 ;; We return how many articles were removed from the summary
6116 ;; buffer as a result of the new limit.
6117 (- total (length gnus-newsgroup-data))))
6119 (defsubst gnus-invisible-cut-children (threads)
6122 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6127 (defsubst gnus-cut-thread (thread)
6128 "Go forwards in the thread until we find an article that we want to display."
6129 (when (or (eq gnus-fetch-old-headers 'some)
6130 (eq gnus-fetch-old-headers 'invisible)
6131 (eq gnus-build-sparse-threads 'some)
6132 (eq gnus-build-sparse-threads 'more))
6133 ;; Deal with old-fetched headers and sparse threads.
6137 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6138 (gnus-summary-article-ancient-p
6139 (mail-header-number (car thread))))
6140 (if (or (<= (length (cdr thread)) 1)
6141 (eq gnus-fetch-old-headers 'invisible))
6142 (setq gnus-newsgroup-limit
6143 (delq (mail-header-number (car thread))
6144 gnus-newsgroup-limit)
6145 thread (cadr thread))
6146 (when (gnus-invisible-cut-children (cdr thread))
6147 (let ((th (cdr thread)))
6149 (if (memq (mail-header-number (caar th))
6150 gnus-newsgroup-limit)
6151 (setq thread (car th)
6153 (setq th (cdr th))))))))))
6156 (defun gnus-cut-threads (threads)
6157 "Cut off all uninteresting articles from the beginning of threads."
6158 (when (or (eq gnus-fetch-old-headers 'some)
6159 (eq gnus-fetch-old-headers 'invisible)
6160 (eq gnus-build-sparse-threads 'some)
6161 (eq gnus-build-sparse-threads 'more))
6164 (setcar th (gnus-cut-thread (car th)))
6165 (setq th (cdr th)))))
6166 ;; Remove nixed out threads.
6169 (defun gnus-summary-initial-limit (&optional show-if-empty)
6170 "Figure out what the initial limit is supposed to be on group entry.
6171 This entails weeding out unwanted dormants, low-scored articles,
6172 fetch-old-headers verbiage, and so on."
6173 ;; Most groups have nothing to remove.
6174 (if (or gnus-inhibit-limiting
6175 (and (null gnus-newsgroup-dormant)
6176 (not (eq gnus-fetch-old-headers 'some))
6177 (not (eq gnus-fetch-old-headers 'invisible))
6178 (null gnus-summary-expunge-below)
6179 (not (eq gnus-build-sparse-threads 'some))
6180 (not (eq gnus-build-sparse-threads 'more))
6181 (null gnus-thread-expunge-below)
6182 (not gnus-use-nocem)))
6184 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6185 (setq gnus-newsgroup-limit nil)
6188 (unless (car (symbol-value node))
6189 ;; These threads have no parents -- they are roots.
6190 (let ((nodes (cdr (symbol-value node)))
6193 (if (and gnus-thread-expunge-below
6194 (< (gnus-thread-total-score (car nodes))
6195 gnus-thread-expunge-below))
6196 (gnus-expunge-thread (pop nodes))
6197 (setq thread (pop nodes))
6198 (gnus-summary-limit-children thread))))))
6199 gnus-newsgroup-dependencies)
6200 ;; If this limitation resulted in an empty group, we might
6201 ;; pop the previous limit and use it instead.
6202 (when (and (not gnus-newsgroup-limit)
6204 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6205 gnus-newsgroup-limit))
6207 (defun gnus-summary-limit-children (thread)
6208 "Return 1 if this subthread is visible and 0 if it is not."
6209 ;; First we get the number of visible children to this thread. This
6210 ;; is done by recursing down the thread using this function, so this
6211 ;; will really go down to a leaf article first, before slowly
6212 ;; working its way up towards the root.
6216 (apply '+ (mapcar 'gnus-summary-limit-children
6219 (number (mail-header-number (car thread)))
6222 (not (memq number gnus-newsgroup-marked))
6224 ;; If this article is dormant and has absolutely no visible
6225 ;; children, then this article isn't visible.
6226 (and (memq number gnus-newsgroup-dormant)
6228 ;; If this is "fetch-old-headered" and there is no
6229 ;; visible children, then we don't want this article.
6230 (and (eq gnus-fetch-old-headers 'some)
6231 (gnus-summary-article-ancient-p number)
6233 ;; If this is "fetch-old-headered" and `invisible', then
6234 ;; we don't want this article.
6235 (and (eq gnus-fetch-old-headers 'invisible)
6236 (gnus-summary-article-ancient-p number))
6237 ;; If this is a sparsely inserted article with no children,
6238 ;; we don't want it.
6239 (and (eq gnus-build-sparse-threads 'some)
6240 (gnus-summary-article-sparse-p number)
6242 ;; If we use expunging, and this article is really
6243 ;; low-scored, then we don't want this article.
6244 (when (and gnus-summary-expunge-below
6246 (or (cdr (assq number gnus-newsgroup-scored))
6247 gnus-summary-default-score))
6248 gnus-summary-expunge-below))
6249 ;; We increase the expunge-tally here, but that has
6250 ;; nothing to do with the limits, really.
6251 (incf gnus-newsgroup-expunged-tally)
6252 ;; We also mark as read here, if that's wanted.
6253 (when (and gnus-summary-mark-below
6254 (< score gnus-summary-mark-below))
6255 (setq gnus-newsgroup-unreads
6256 (delq number gnus-newsgroup-unreads))
6257 (if gnus-newsgroup-auto-expire
6258 (push number gnus-newsgroup-expirable)
6259 (push (cons number gnus-low-score-mark)
6260 gnus-newsgroup-reads)))
6262 ;; Check NoCeM things.
6263 (if (and gnus-use-nocem
6264 (gnus-nocem-unwanted-article-p
6265 (mail-header-id (car thread))))
6267 (setq gnus-newsgroup-unreads
6268 (delq number gnus-newsgroup-unreads))
6270 ;; Nope, invisible article.
6272 ;; Ok, this article is to be visible, so we add it to the limit
6274 (push number gnus-newsgroup-limit)
6277 (defun gnus-expunge-thread (thread)
6278 "Mark all articles in THREAD as read."
6279 (let* ((number (mail-header-number (car thread))))
6280 (incf gnus-newsgroup-expunged-tally)
6281 ;; We also mark as read here, if that's wanted.
6282 (setq gnus-newsgroup-unreads
6283 (delq number gnus-newsgroup-unreads))
6284 (if gnus-newsgroup-auto-expire
6285 (push number gnus-newsgroup-expirable)
6286 (push (cons number gnus-low-score-mark)
6287 gnus-newsgroup-reads)))
6288 ;; Go recursively through all subthreads.
6289 (mapcar 'gnus-expunge-thread (cdr thread)))
6291 ;; Summary article oriented commands
6293 (defun gnus-summary-refer-parent-article (n)
6294 "Refer parent article N times.
6295 If N is negative, go to ancestor -N instead.
6296 The difference between N and the number of articles fetched is returned."
6300 (when (not (natnump n))
6305 (setq header (gnus-summary-article-header))
6306 (if (and (eq (mail-header-number header)
6307 (cdr gnus-article-current))
6308 (equal gnus-newsgroup-name
6309 (car gnus-article-current)))
6310 ;; If we try to find the parent of the currently
6311 ;; displayed article, then we take a look at the actual
6312 ;; References header, since this is slightly more
6313 ;; reliable than the References field we got from the
6316 (set-buffer gnus-original-article-buffer)
6317 (nnheader-narrow-to-headers)
6318 (unless (setq ref (message-fetch-field "references"))
6319 (setq ref (message-fetch-field "in-reply-to")))
6322 ;; It's not the current article, so we take a bet on
6323 ;; the value we got from the server.
6324 (mail-header-references header)))
6326 (not (equal ref "")))
6327 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6328 (gnus-message 1 "Couldn't find parent"))
6329 (gnus-message 1 "No references in article %d"
6330 (gnus-summary-article-number))
6333 (gnus-summary-position-point)
6336 (defun gnus-summary-refer-references ()
6337 "Fetch all articles mentioned in the References header.
6338 Return the number of articles fetched."
6340 (let ((ref (mail-header-references (gnus-summary-article-header)))
6341 (current (gnus-summary-article-number))
6345 (error "No References in the current article")
6346 ;; For each Message-ID in the References header...
6347 (while (string-match "<[^>]*>" ref)
6349 ;; ... fetch that article.
6350 (gnus-summary-refer-article
6351 (prog1 (match-string 0 ref)
6352 (setq ref (substring ref (match-end 0))))))
6353 (gnus-summary-goto-subject current)
6354 (gnus-summary-position-point)
6357 (defun gnus-summary-refer-thread (&optional limit)
6358 "Fetch all articles in the current thread.
6359 If LIMIT (the numerical prefix), fetch that many old headers instead
6360 of what's specified by the `gnus-refer-thread-limit' variable."
6362 (let ((id (mail-header-id (gnus-summary-article-header)))
6363 (limit (if limit (prefix-numeric-value limit)
6364 gnus-refer-thread-limit))
6366 ;; We want to fetch LIMIT *old* headers, but we also have to
6367 ;; re-fetch all the headers in the current buffer, because many of
6368 ;; them may be undisplayed. So we adjust LIMIT.
6369 (when (numberp limit)
6370 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6371 (unless (eq gnus-fetch-old-headers 'invisible)
6372 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6373 ;; Retrieve the headers and read them in.
6374 (if (eq (gnus-retrieve-headers
6375 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6377 (gnus-build-all-threads)
6378 (error "Can't fetch thread from backends that don't support NOV"))
6379 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6380 (gnus-summary-limit-include-thread id)))
6382 (defun gnus-summary-refer-article (message-id &optional arg)
6383 "Fetch an article specified by MESSAGE-ID.
6384 If ARG (the prefix), fetch the article using `gnus-refer-article-method'
6385 or `gnus-select-method', no matter what backend the article comes from."
6386 (interactive "sMessage-ID: \nP")
6387 (when (and (stringp message-id)
6388 (not (zerop (length message-id))))
6389 ;; Construct the correct Message-ID if necessary.
6390 ;; Suggested by tale@pawl.rpi.edu.
6391 (unless (string-match "^<" message-id)
6392 (setq message-id (concat "<" message-id)))
6393 (unless (string-match ">$" message-id)
6394 (setq message-id (concat message-id ">")))
6395 (let* ((header (gnus-id-to-header message-id))
6397 (gnus-summary-article-sparse-p
6398 (mail-header-number header))
6399 (memq (mail-header-number header)
6400 gnus-newsgroup-limit)))
6403 ;; If the article is present in the buffer we just go to it.
6405 (or (not (gnus-summary-article-sparse-p
6406 (mail-header-number header)))
6409 (gnus-summary-goto-article
6410 (mail-header-number header) nil t)
6412 (gnus-summary-update-article (mail-header-number header)))))
6414 ;; We fetch the article
6415 (let ((gnus-override-method
6416 (cond ((gnus-news-group-p gnus-newsgroup-name)
6417 gnus-refer-article-method)
6419 (or gnus-refer-article-method gnus-select-method))
6422 ;; Start the special refer-article method, if necessary.
6423 (when (and gnus-refer-article-method
6424 (gnus-news-group-p gnus-newsgroup-name))
6425 (gnus-check-server gnus-refer-article-method))
6426 ;; Fetch the header, and display the article.
6427 (if (setq number (gnus-summary-insert-subject message-id))
6428 (gnus-summary-select-article nil nil nil number)
6429 (gnus-message 3 "Couldn't fetch article %s" message-id))))))))
6431 (defun gnus-summary-edit-parameters ()
6432 "Edit the group parameters of the current group."
6434 (gnus-group-edit-group gnus-newsgroup-name 'params))
6436 (defun gnus-summary-enter-digest-group (&optional force)
6437 "Enter an nndoc group based on the current article.
6438 If FORCE, force a digest interpretation. If not, try
6439 to guess what the document format is."
6441 (let ((conf gnus-current-window-configuration))
6443 (gnus-summary-select-article))
6444 (setq gnus-current-window-configuration conf)
6445 (let* ((name (format "%s-%d"
6446 (gnus-group-prefixed-name
6447 gnus-newsgroup-name (list 'nndoc ""))
6449 (set-buffer gnus-summary-buffer)
6450 gnus-current-article)))
6451 (ogroup gnus-newsgroup-name)
6452 (params (append (gnus-info-params (gnus-get-info ogroup))
6453 (list (cons 'to-group ogroup))
6454 (list (cons 'save-article-group ogroup))))
6455 (case-fold-search t)
6456 (buf (current-buffer))
6459 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6460 (insert-buffer-substring gnus-original-article-buffer)
6461 ;; Remove lines that may lead nndoc to misinterpret the
6464 (goto-char (point-min))
6465 (or (search-forward "\n\n" nil t) (point)))
6466 (goto-char (point-min))
6467 (delete-matching-lines "^\\(Path\\):\\|^From ")
6470 (if (gnus-group-read-ephemeral-group
6471 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6473 ,(if force 'digest 'guess))) t)
6474 ;; Make all postings to this group go to the parent group.
6475 (nconc (gnus-info-params (gnus-get-info name))
6477 ;; Couldn't select this doc group.
6478 (switch-to-buffer buf)
6479 (gnus-set-global-variables)
6480 (gnus-configure-windows 'summary)
6481 (gnus-message 3 "Article couldn't be entered?"))
6482 (kill-buffer dig)))))
6484 (defun gnus-summary-read-document (n)
6485 "Open a new group based on the current article(s).
6486 This will allow you to read digests and other similar
6487 documents as newsgroups.
6488 Obeys the standard process/prefix convention."
6490 (let* ((articles (gnus-summary-work-articles n))
6491 (ogroup gnus-newsgroup-name)
6492 (params (append (gnus-info-params (gnus-get-info ogroup))
6493 (list (cons 'to-group ogroup))))
6494 article group egroup groups vgroup)
6495 (while (setq article (pop articles))
6496 (setq group (format "%s-%d" gnus-newsgroup-name article))
6497 (gnus-summary-remove-process-mark article)
6498 (when (gnus-summary-display-article article)
6500 (nnheader-temp-write nil
6501 (insert-buffer-substring gnus-original-article-buffer)
6502 ;; Remove some headers that may lead nndoc to make
6504 (message-narrow-to-head)
6505 (goto-char (point-min))
6506 (delete-matching-lines "^\\(Path\\):\\|^From ")
6509 (gnus-group-read-ephemeral-group
6510 group `(nndoc ,group (nndoc-address ,(current-buffer))
6511 (nndoc-article-type guess))
6514 ;; Make all postings to this group go to the parent group.
6515 (nconc (gnus-info-params (gnus-get-info egroup))
6517 (push egroup groups))
6518 ;; Couldn't select this doc group.
6519 (gnus-error 3 "Article couldn't be entered"))))))
6520 ;; Now we have selected all the documents.
6523 (error "None of the articles could be interpreted as documents"))
6524 ((gnus-group-read-ephemeral-group
6525 (setq vgroup (format
6526 "nnvirtual:%s-%s" gnus-newsgroup-name
6527 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6528 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6530 (cons (current-buffer) 'summary)))
6532 (error "Couldn't select virtual nndoc group")))))
6534 (defun gnus-summary-isearch-article (&optional regexp-p)
6535 "Do incremental search forward on the current article.
6536 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6538 (gnus-summary-select-article)
6539 (gnus-configure-windows 'article)
6540 (gnus-eval-in-buffer-window gnus-article-buffer
6543 (isearch-forward regexp-p))))
6545 (defun gnus-summary-search-article-forward (regexp &optional backward)
6546 "Search for an article containing REGEXP forward.
6547 If BACKWARD, search backward instead."
6550 (format "Search article %s (regexp%s): "
6551 (if current-prefix-arg "backward" "forward")
6552 (if gnus-last-search-regexp
6553 (concat ", default " gnus-last-search-regexp)
6555 current-prefix-arg))
6556 (if (string-equal regexp "")
6557 (setq regexp (or gnus-last-search-regexp ""))
6558 (setq gnus-last-search-regexp regexp))
6559 (if (gnus-summary-search-article regexp backward)
6560 (gnus-summary-show-thread)
6561 (error "Search failed: \"%s\"" regexp)))
6563 (defun gnus-summary-search-article-backward (regexp)
6564 "Search for an article containing REGEXP backward."
6567 (format "Search article backward (regexp%s): "
6568 (if gnus-last-search-regexp
6569 (concat ", default " gnus-last-search-regexp)
6571 (gnus-summary-search-article-forward regexp 'backward))
6573 (defun gnus-summary-search-article (regexp &optional backward)
6574 "Search for an article containing REGEXP.
6575 Optional argument BACKWARD means do search for backward.
6576 `gnus-select-article-hook' is not called during the search."
6577 ;; We have to require this here to make sure that the following
6578 ;; dynamic binding isn't shadowed by autoloading.
6579 (require 'gnus-async)
6580 (let ((gnus-select-article-hook nil) ;Disable hook.
6581 (gnus-article-display-hook nil)
6582 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6583 (gnus-use-article-prefetch nil)
6584 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
6585 (gnus-use-trees nil) ;Inhibit updating tree buffer.
6586 (sum (current-buffer))
6589 (gnus-save-hidden-threads
6590 (gnus-summary-select-article)
6591 (set-buffer gnus-article-buffer)
6595 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
6597 (re-search-backward regexp nil t)
6598 (re-search-forward regexp nil t))
6599 ;; We found the regexp.
6604 (get-buffer-window (current-buffer))
6608 (setq point (point)))
6609 ;; We didn't find it, so we go to the next article.
6612 (while (eq found 'not)
6613 (if (not (if backward (gnus-summary-find-prev)
6614 (gnus-summary-find-next)))
6615 ;; No more articles.
6617 ;; Select the next article and adjust point.
6618 (unless (gnus-summary-article-sparse-p
6619 (gnus-summary-article-number))
6621 (gnus-summary-select-article)
6622 (set-buffer gnus-article-buffer)
6624 (goto-char (if backward (point-max) (point-min))))))))
6625 (gnus-message 7 ""))
6626 ;; Return whether we found the regexp.
6627 (when (eq found 'found)
6629 (gnus-summary-show-thread)
6630 (gnus-summary-goto-subject gnus-current-article)
6631 (gnus-summary-position-point)
6634 (defun gnus-summary-find-matching (header regexp &optional backward unread
6636 "Return a list of all articles that match REGEXP on HEADER.
6637 The search stars on the current article and goes forwards unless
6638 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
6639 If UNREAD is non-nil, only unread articles will
6640 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
6641 in the comparisons."
6642 (let ((data (if (eq backward 'all) gnus-newsgroup-data
6643 (gnus-data-find-list
6644 (gnus-summary-article-number) (gnus-data-list backward))))
6645 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
6646 (case-fold-search (not not-case-fold))
6648 (unless (fboundp (intern (concat "mail-header-" header)))
6649 (error "%s is not a valid header" header))
6652 (and (or (not unread) ; We want all articles...
6653 (gnus-data-unread-p d)) ; Or just unreads.
6654 (vectorp (gnus-data-header d)) ; It's not a pseudo.
6655 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
6656 (push (gnus-data-number d) articles)) ; Success!
6657 (setq data (cdr data)))
6658 (nreverse articles)))
6660 (defun gnus-summary-execute-command (header regexp command &optional backward)
6661 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
6662 If HEADER is an empty string (or nil), the match is done on the entire
6663 article. If BACKWARD (the prefix) is non-nil, search backward instead."
6665 (list (let ((completion-ignore-case t))
6668 (mapcar (lambda (string) (list string))
6669 '("Number" "Subject" "From" "Lines" "Date"
6670 "Message-ID" "Xref" "References" "Body"))
6671 nil 'require-match))
6672 (read-string "Regexp: ")
6673 (read-key-sequence "Command: ")
6674 current-prefix-arg))
6675 (when (equal header "Body")
6677 ;; Hidden thread subtrees must be searched as well.
6678 (gnus-summary-show-all-threads)
6679 ;; We don't want to change current point nor window configuration.
6681 (save-window-excursion
6682 (gnus-message 6 "Executing %s..." (key-description command))
6683 ;; We'd like to execute COMMAND interactively so as to give arguments.
6684 (gnus-execute header regexp
6685 `(call-interactively ',(key-binding command))
6687 (gnus-message 6 "Executing %s...done" (key-description command)))))
6689 (defun gnus-summary-beginning-of-article ()
6690 "Scroll the article back to the beginning."
6692 (gnus-summary-select-article)
6693 (gnus-configure-windows 'article)
6694 (gnus-eval-in-buffer-window gnus-article-buffer
6696 (goto-char (point-min))
6697 (when gnus-page-broken
6698 (gnus-narrow-to-page))))
6700 (defun gnus-summary-end-of-article ()
6701 "Scroll to the end of the article."
6703 (gnus-summary-select-article)
6704 (gnus-configure-windows 'article)
6705 (gnus-eval-in-buffer-window gnus-article-buffer
6707 (goto-char (point-max))
6709 (when gnus-page-broken
6710 (gnus-narrow-to-page))))
6712 (defun gnus-summary-print-article (&optional filename n)
6713 "Generate and print a PostScript image of the N next (mail) articles.
6715 If N is negative, print the N previous articles. If N is nil and articles
6716 have been marked with the process mark, print these instead.
6718 If the optional second argument FILENAME is nil, send the image to the
6719 printer. If FILENAME is a string, save the PostScript image in a file with
6720 that name. If FILENAME is a number, prompt the user for the name of the file
6722 (interactive (list (ps-print-preprint current-prefix-arg)
6723 current-prefix-arg))
6724 (dolist (article (gnus-summary-work-articles n))
6725 (gnus-summary-select-article nil nil 'pseudo article)
6726 (gnus-eval-in-buffer-window gnus-article-buffer
6727 (let ((buffer (generate-new-buffer " *print*")))
6730 (copy-to-buffer buffer (point-min) (point-max))
6732 (gnus-article-delete-invisible-text)
6733 (let ((ps-left-header
6736 (mail-header-subject gnus-current-headers) ")")
6738 (mail-header-from gnus-current-headers) ")")))
6741 "/pagenumberstring load"
6743 (mail-header-date gnus-current-headers) ")"))))
6744 (gnus-run-hooks 'gnus-ps-print-hook)
6746 (ps-print-buffer-with-faces filename))))
6747 (kill-buffer buffer))))))
6749 (defun gnus-summary-show-article (&optional arg)
6750 "Force re-fetching of the current article.
6751 If ARG (the prefix) is non-nil, show the raw article without any
6752 article massaging functions being run."
6755 ;; Select the article the normal way.
6756 (gnus-summary-select-article nil 'force)
6757 ;; Bind the article treatment functions to nil.
6758 (let ((gnus-have-all-headers t)
6759 gnus-article-display-hook
6760 gnus-article-prepare-hook
6764 (gnus-summary-select-article nil 'force)))
6765 (gnus-summary-goto-subject gnus-current-article)
6766 (gnus-summary-position-point))
6768 (defun gnus-summary-verbose-headers (&optional arg)
6769 "Toggle permanent full header display.
6770 If ARG is a positive number, turn header display on.
6771 If ARG is a negative number, turn header display off."
6773 (setq gnus-show-all-headers
6774 (cond ((or (not (numberp arg))
6776 (not gnus-show-all-headers))
6779 (gnus-summary-show-article))
6781 (defun gnus-summary-toggle-header (&optional arg)
6782 "Show the headers if they are hidden, or hide them if they are shown.
6783 If ARG is a positive number, show the entire header.
6784 If ARG is a negative number, hide the unwanted header lines."
6787 (set-buffer gnus-article-buffer)
6788 (let* ((buffer-read-only nil)
6789 (inhibit-point-motion-hooks t)
6790 (hidden (text-property-any
6791 (goto-char (point-min)) (search-forward "\n\n")
6794 (goto-char (point-min))
6795 (when (search-forward "\n\n" nil t)
6796 (delete-region (point-min) (1- (point))))
6797 (goto-char (point-min))
6799 (set-buffer gnus-original-article-buffer)
6800 (goto-char (point-min))
6801 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
6802 (insert-buffer-substring gnus-original-article-buffer 1 e)
6803 (let ((article-inhibit-hiding t))
6804 (gnus-run-hooks 'gnus-article-display-hook))
6805 (when (or (not hidden) (and (numberp arg) (< arg 0)))
6806 (gnus-article-hide-headers)))))
6808 (defun gnus-summary-show-all-headers ()
6809 "Make all header lines visible."
6811 (gnus-article-show-all-headers))
6813 (defun gnus-summary-toggle-mime (&optional arg)
6814 "Toggle MIME processing.
6815 If ARG is a positive number, turn MIME processing on."
6817 (setq gnus-show-mime
6818 (if (null arg) (not gnus-show-mime)
6819 (> (prefix-numeric-value arg) 0)))
6820 (gnus-summary-select-article t 'force))
6822 (defun gnus-summary-caesar-message (&optional arg)
6823 "Caesar rotate the current article by 13.
6824 The numerical prefix specifies how many places to rotate each letter
6827 (gnus-summary-select-article)
6828 (let ((mail-header-separator ""))
6829 (gnus-eval-in-buffer-window gnus-article-buffer
6832 (let ((start (window-start))
6834 (message-caesar-buffer-body arg)
6835 (set-window-start (get-buffer-window (current-buffer)) start))))))
6837 (defun gnus-summary-stop-page-breaking ()
6838 "Stop page breaking in the current article."
6840 (gnus-summary-select-article)
6841 (gnus-eval-in-buffer-window gnus-article-buffer
6843 (when (gnus-visual-p 'page-marker)
6844 (let ((buffer-read-only nil))
6845 (gnus-remove-text-with-property 'gnus-prev)
6846 (gnus-remove-text-with-property 'gnus-next))
6847 (setq gnus-page-broken nil))))
6849 (defun gnus-summary-move-article (&optional n to-newsgroup
6850 select-method action)
6851 "Move the current article to a different newsgroup.
6852 If N is a positive number, move the N next articles.
6853 If N is a negative number, move the N previous articles.
6854 If N is nil and any articles have been marked with the process mark,
6855 move those articles instead.
6856 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6857 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6858 re-spool using this method.
6860 For this function to work, both the current newsgroup and the
6861 newsgroup that you want to move to have to support the `request-move'
6862 and `request-accept' functions."
6865 (setq action 'move))
6866 ;; Disable marking as read.
6867 (let (gnus-mark-article-hook)
6868 (save-window-excursion
6869 (gnus-summary-select-article)))
6870 ;; Check whether the source group supports the required functions.
6871 (cond ((and (eq action 'move)
6872 (not (gnus-check-backend-function
6873 'request-move-article gnus-newsgroup-name)))
6874 (error "The current group does not support article moving"))
6875 ((and (eq action 'crosspost)
6876 (not (gnus-check-backend-function
6877 'request-replace-article gnus-newsgroup-name)))
6878 (error "The current group does not support article editing")))
6879 (let ((articles (gnus-summary-work-articles n))
6880 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
6881 (names '((move "Move" "Moving")
6882 (copy "Copy" "Copying")
6883 (crosspost "Crosspost" "Crossposting")))
6884 (copy-buf (save-excursion
6885 (nnheader-set-temp-buffer " *copy article*")))
6886 art-group to-method new-xref article to-groups)
6887 (unless (assq action names)
6888 (error "Unknown action %s" action))
6889 ;; Read the newsgroup name.
6890 (when (and (not to-newsgroup)
6891 (not select-method))
6893 (gnus-read-move-group-name
6894 (cadr (assq action names))
6895 (symbol-value (intern (format "gnus-current-%s-group" action)))
6897 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
6898 (setq to-method (or select-method
6899 (gnus-group-name-to-method to-newsgroup)))
6900 ;; Check the method we are to move this article to...
6901 (unless (gnus-check-backend-function
6902 'request-accept-article (car to-method))
6903 (error "%s does not support article copying" (car to-method)))
6904 (unless (gnus-check-server to-method)
6905 (error "Can't open server %s" (car to-method)))
6906 (gnus-message 6 "%s to %s: %s..."
6907 (caddr (assq action names))
6908 (or (car select-method) to-newsgroup) articles)
6910 (setq article (pop articles))
6914 ;; Move the article.
6916 ;; Remove this article from future suppression.
6917 (gnus-dup-unsuppress-article article)
6918 (gnus-request-move-article
6919 article ; Article to move
6920 gnus-newsgroup-name ; From newsgroup
6921 (nth 1 (gnus-find-method-for-group
6922 gnus-newsgroup-name)) ; Server
6923 (list 'gnus-request-accept-article
6924 to-newsgroup (list 'quote select-method)
6925 (not articles)) ; Accept form
6926 (not articles))) ; Only save nov last time
6927 ;; Copy the article.
6930 (set-buffer copy-buf)
6931 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
6932 (gnus-request-accept-article
6933 to-newsgroup select-method (not articles)))))
6934 ;; Crosspost the article.
6935 ((eq action 'crosspost)
6936 (let ((xref (message-tokenize-header
6937 (mail-header-xref (gnus-summary-article-header article))
6939 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
6942 (setq xref (list (system-name))))
6945 (mapconcat 'identity
6946 (delete "Xref:" (delete new-xref xref))
6950 (set-buffer copy-buf)
6951 ;; First put the article in the destination group.
6952 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6953 (when (consp (setq art-group
6954 (gnus-request-accept-article
6955 to-newsgroup select-method (not articles))))
6956 (setq new-xref (concat new-xref " " (car art-group)
6957 ":" (cdr art-group)))
6958 ;; Now we have the new Xrefs header, so we insert
6959 ;; it and replace the new article.
6960 (nnheader-replace-header "Xref" new-xref)
6961 (gnus-request-replace-article
6962 (cdr art-group) to-newsgroup (current-buffer))
6966 (gnus-message 1 "Couldn't %s article %s"
6967 (cadr (assq action names)) article))
6968 ((and (eq art-group 'junk)
6970 (gnus-summary-mark-article article gnus-canceled-mark)
6971 (gnus-message 4 "Deleted article %s" article))
6975 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
6977 (gnus-group-prefixed-name
6980 (gnus-find-method-for-group to-newsgroup)))
6981 gnus-newsrc-hashtb)))
6982 (info (nth 2 entry))
6983 (to-group (gnus-info-group info)))
6984 ;; Update the group that has been moved to.
6986 (memq action '(move copy)))
6987 (unless (member to-group to-groups)
6988 (push to-group to-groups))
6990 (unless (memq article gnus-newsgroup-unreads)
6992 info (gnus-add-to-range (gnus-info-read info)
6993 (list (cdr art-group)))))
6995 ;; Copy any marks over to the new group.
6996 (let ((marks gnus-article-mark-lists)
6997 (to-article (cdr art-group)))
6999 ;; See whether the article is to be put in the cache.
7000 (when gnus-use-cache
7001 (gnus-cache-possibly-enter-article
7003 (let ((header (copy-sequence
7004 (gnus-summary-article-header article))))
7005 (mail-header-set-number header to-article)
7007 (memq article gnus-newsgroup-marked)
7008 (memq article gnus-newsgroup-dormant)
7009 (memq article gnus-newsgroup-unreads)))
7011 (when (and (equal to-group gnus-newsgroup-name)
7012 (not (memq article gnus-newsgroup-unreads)))
7013 ;; Mark this article as read in this group.
7014 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7015 (setcdr (gnus-active to-group) to-article)
7016 (setcdr gnus-newsgroup-active to-article))
7019 (when (memq article (symbol-value
7020 (intern (format "gnus-newsgroup-%s"
7022 ;; If the other group is the same as this group,
7023 ;; then we have to add the mark to the list.
7024 (when (equal to-group gnus-newsgroup-name)
7025 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7028 (intern (format "gnus-newsgroup-%s"
7030 ;; Copy the marks to other group.
7031 (gnus-add-marked-articles
7032 to-group (cdar marks) (list to-article) info))
7033 (setq marks (cdr marks)))
7036 (concat "(gnus-group-set-info '"
7037 (gnus-prin1-to-string (gnus-get-info to-group))
7040 ;; Update the Xref header in this article to point to
7041 ;; the new crossposted article we have just created.
7042 (when (eq action 'crosspost)
7044 (set-buffer copy-buf)
7045 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7046 (nnheader-replace-header "Xref" new-xref)
7047 (gnus-request-replace-article
7048 article gnus-newsgroup-name (current-buffer)))))
7050 ;;;!!!Why is this necessary?
7051 (set-buffer gnus-summary-buffer)
7053 (gnus-summary-goto-subject article)
7054 (when (eq action 'move)
7055 (gnus-summary-mark-article article gnus-canceled-mark))))
7056 (gnus-summary-remove-process-mark article))
7057 ;; Re-activate all groups that have been moved to.
7060 (set-buffer gnus-group-buffer)
7061 (when (gnus-group-goto-group (car to-groups) t)
7062 (gnus-group-get-new-news-this-group 1 t))
7065 (gnus-kill-buffer copy-buf)
7066 (gnus-summary-position-point)
7067 (gnus-set-mode-line 'summary)))
7069 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7070 "Move the current article to a different newsgroup.
7071 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7072 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7073 re-spool using this method."
7075 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7077 (defun gnus-summary-crosspost-article (&optional n)
7078 "Crosspost the current article to some other group."
7080 (gnus-summary-move-article n nil nil 'crosspost))
7082 (defcustom gnus-summary-respool-default-method nil
7083 "Default method for respooling an article.
7084 If nil, use to the current newsgroup method."
7085 :type `(choice (gnus-select-method :value (nnml ""))
7087 :group 'gnus-summary-mail)
7089 (defun gnus-summary-respool-article (&optional n method)
7090 "Respool the current article.
7091 The article will be squeezed through the mail spooling process again,
7092 which means that it will be put in some mail newsgroup or other
7093 depending on `nnmail-split-methods'.
7094 If N is a positive number, respool the N next articles.
7095 If N is a negative number, respool the N previous articles.
7096 If N is nil and any articles have been marked with the process mark,
7097 respool those articles instead.
7099 Respooling can be done both from mail groups and \"real\" newsgroups.
7100 In the former case, the articles in question will be moved from the
7101 current group into whatever groups they are destined to. In the
7102 latter case, they will be copied into the relevant groups."
7104 (list current-prefix-arg
7105 (let* ((methods (gnus-methods-using 'respool))
7107 (symbol-name (or gnus-summary-respool-default-method
7108 (car (gnus-find-method-for-group
7109 gnus-newsgroup-name)))))
7111 (gnus-completing-read
7112 methname "What backend do you want to use when respooling?"
7113 methods nil t nil 'gnus-mail-method-history))
7116 ((zerop (length (setq ms (gnus-servers-using-backend
7118 (list (intern method) ""))
7122 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7123 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7126 (error "No method given for respooling"))
7127 (if (assoc (symbol-name
7128 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7129 (gnus-methods-using 'respool))
7130 (gnus-summary-move-article n nil method)
7131 (gnus-summary-copy-article n nil method)))
7133 (defun gnus-summary-import-article (file)
7134 "Import an arbitrary file into a mail newsgroup."
7135 (interactive "fImport file: ")
7136 (let ((group gnus-newsgroup-name)
7137 (now (current-time))
7139 (unless (gnus-check-backend-function 'request-accept-article group)
7140 (error "%s does not support article importing" group))
7141 (or (file-readable-p file)
7142 (not (file-regular-p file))
7143 (error "Can't read %s" file))
7145 (set-buffer (get-buffer-create " *import file*"))
7146 (buffer-disable-undo (current-buffer))
7148 (nnheader-insert-file-contents file)
7149 (goto-char (point-min))
7150 (unless (nnheader-article-p)
7151 ;; This doesn't look like an article, so we fudge some headers.
7152 (setq atts (file-attributes file)
7153 lines (count-lines (point-min) (point-max)))
7154 (insert "From: " (read-string "From: ") "\n"
7155 "Subject: " (read-string "Subject: ") "\n"
7156 "Date: " (timezone-make-date-arpa-standard
7157 (current-time-string (nth 5 atts))
7158 (current-time-zone now)
7159 (current-time-zone now))
7161 "Message-ID: " (message-make-message-id) "\n"
7162 "Lines: " (int-to-string lines) "\n"
7163 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7164 (gnus-request-accept-article group nil t)
7165 (kill-buffer (current-buffer)))))
7167 (defun gnus-summary-article-posted-p ()
7168 "Say whether the current (mail) article is available from `gnus-select-method' as well.
7169 This will be the case if the article has both been mailed and posted."
7171 (let ((id (mail-header-references (gnus-summary-article-header)))
7172 (gnus-override-method
7173 (or gnus-refer-article-method gnus-select-method)))
7174 (if (gnus-request-head id "")
7175 (gnus-message 2 "The current message was found on %s"
7176 gnus-override-method)
7177 (gnus-message 2 "The current message couldn't be found on %s"
7178 gnus-override-method)
7181 (defun gnus-summary-expire-articles (&optional now)
7182 "Expire all articles that are marked as expirable in the current group."
7184 (when (gnus-check-backend-function
7185 'request-expire-articles gnus-newsgroup-name)
7186 ;; This backend supports expiry.
7187 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7188 (expirable (if total
7190 ;; We need to update the info for
7191 ;; this group for `gnus-list-of-read-articles'
7192 ;; to give us the right answer.
7193 (gnus-run-hooks 'gnus-exit-group-hook)
7194 (gnus-summary-update-info)
7195 (gnus-list-of-read-articles gnus-newsgroup-name))
7196 (setq gnus-newsgroup-expirable
7197 (sort gnus-newsgroup-expirable '<))))
7198 (expiry-wait (if now 'immediate
7199 (gnus-group-find-parameter
7200 gnus-newsgroup-name 'expiry-wait)))
7203 ;; There are expirable articles in this group, so we run them
7204 ;; through the expiry process.
7205 (gnus-message 6 "Expiring articles...")
7206 ;; The list of articles that weren't expired is returned.
7209 (let ((nnmail-expiry-wait-function nil)
7210 (nnmail-expiry-wait expiry-wait))
7211 (setq es (gnus-request-expire-articles
7212 expirable gnus-newsgroup-name)))
7213 (setq es (gnus-request-expire-articles
7214 expirable gnus-newsgroup-name))))
7216 (setq gnus-newsgroup-expirable es))
7217 ;; We go through the old list of expirable, and mark all
7218 ;; really expired articles as nonexistent.
7219 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7220 (let ((gnus-use-cache nil))
7222 (unless (memq (car expirable) es)
7223 (when (gnus-data-find (car expirable))
7224 (gnus-summary-mark-article
7225 (car expirable) gnus-canceled-mark)))
7226 (setq expirable (cdr expirable)))))
7227 (gnus-message 6 "Expiring articles...done")))))
7229 (defun gnus-summary-expire-articles-now ()
7230 "Expunge all expirable articles in the current group.
7231 This means that *all* articles that are marked as expirable will be
7232 deleted forever, right now."
7234 (or gnus-expert-user
7236 "Are you really, really, really sure you want to delete all these messages? ")
7238 (gnus-summary-expire-articles t))
7240 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7241 (defun gnus-summary-delete-article (&optional n)
7242 "Delete the N next (mail) articles.
7243 This command actually deletes articles. This is not a marking
7244 command. The article will disappear forever from your life, never to
7246 If N is negative, delete backwards.
7247 If N is nil and articles have been marked with the process mark,
7248 delete these instead."
7250 (unless (gnus-check-backend-function 'request-expire-articles
7251 gnus-newsgroup-name)
7252 (error "The current newsgroup does not support article deletion"))
7253 ;; Compute the list of articles to delete.
7254 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
7256 (if (and gnus-novice-user
7257 (not (gnus-yes-or-no-p
7258 (format "Do you really want to delete %s forever? "
7259 (if (> (length articles) 1)
7260 (format "these %s articles" (length articles))
7263 ;; Delete the articles.
7264 (setq not-deleted (gnus-request-expire-articles
7265 articles gnus-newsgroup-name 'force))
7267 (gnus-summary-remove-process-mark (car articles))
7268 ;; The backend might not have been able to delete the article
7270 (unless (memq (car articles) not-deleted)
7271 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7272 (setq articles (cdr articles)))
7274 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7275 (gnus-summary-position-point)
7276 (gnus-set-mode-line 'summary)
7279 (defun gnus-summary-edit-article (&optional force)
7280 "Edit the current article.
7281 This will have permanent effect only in mail groups.
7282 If FORCE is non-nil, allow editing of articles even in read-only
7286 (set-buffer gnus-summary-buffer)
7287 (gnus-set-global-variables)
7288 (when (and (not force)
7289 (gnus-group-read-only-p))
7290 (error "The current newsgroup does not support article editing"))
7291 ;; Select article if needed.
7292 (unless (eq (gnus-summary-article-number)
7293 gnus-current-article)
7294 (gnus-summary-select-article t))
7295 (gnus-article-date-original)
7296 (gnus-article-edit-article
7297 `(lambda (no-highlight)
7298 (gnus-summary-edit-article-done
7299 ,(or (mail-header-references gnus-current-headers) "")
7300 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))
7302 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7304 (defun gnus-summary-edit-article-done (&optional references read-only buffer
7306 "Make edits to the current article permanent."
7308 ;; Replace the article.
7309 (if (and (not read-only)
7310 (not (gnus-request-replace-article
7311 (cdr gnus-article-current) (car gnus-article-current)
7313 (error "Couldn't replace article")
7314 ;; Update the summary buffer.
7316 (equal (message-tokenize-header references " ")
7317 (message-tokenize-header
7318 (or (message-fetch-field "references") "") " ")))
7319 ;; We only have to update this line.
7322 (message-narrow-to-head)
7323 (let ((head (buffer-string))
7325 (nnheader-temp-write nil
7326 (insert (format "211 %d Article retrieved.\n"
7327 (cdr gnus-article-current)))
7330 (let ((nntp-server-buffer (current-buffer)))
7331 (setq header (car (gnus-get-newsgroup-headers
7333 (set-buffer gnus-summary-buffer)
7334 gnus-newsgroup-dependencies)
7337 (set-buffer gnus-summary-buffer)
7338 (gnus-data-set-header
7339 (gnus-data-find (cdr gnus-article-current))
7341 (gnus-summary-update-article-line
7342 (cdr gnus-article-current) header))))))
7344 (set-buffer (or buffer gnus-summary-buffer))
7345 (gnus-summary-update-article (cdr gnus-article-current)))
7346 ;; Prettify the article buffer again.
7347 (unless no-highlight
7349 (set-buffer gnus-article-buffer)
7350 (gnus-run-hooks 'gnus-article-display-hook)
7351 (set-buffer gnus-original-article-buffer)
7352 (gnus-request-article
7353 (cdr gnus-article-current)
7354 (car gnus-article-current) (current-buffer))))
7355 ;; Prettify the summary buffer line.
7356 (when (gnus-visual-p 'summary-highlight 'highlight)
7357 (gnus-run-hooks 'gnus-visual-mark-article-hook))))
7359 (defun gnus-summary-edit-wash (key)
7360 "Perform editing command KEY in the article buffer."
7364 (message "%s" (concat (this-command-keys) "- "))
7367 (gnus-summary-edit-article)
7368 (execute-kbd-macro (concat (this-command-keys) key))
7369 (gnus-article-edit-done))
7373 (defun gnus-summary-respool-query (&optional silent)
7374 "Query where the respool algorithm would put this article."
7376 (let (gnus-mark-article-hook)
7377 (gnus-summary-select-article)
7379 (set-buffer gnus-original-article-buffer)
7381 (message-narrow-to-head)
7382 (let ((groups (nnmail-article-group 'identity)))
7385 (message "This message would go to %s"
7386 (mapconcat 'car groups ", "))
7387 (message "This message would go to no groups"))
7390 ;; Summary marking commands.
7392 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
7393 "Mark articles which has the same subject as read, and then select the next.
7394 If UNMARK is positive, remove any kind of mark.
7395 If UNMARK is negative, tick articles."
7398 (setq unmark (prefix-numeric-value unmark)))
7400 (gnus-summary-mark-same-subject
7401 (gnus-summary-article-subject) unmark)))
7402 ;; Select next unread article. If auto-select-same mode, should
7403 ;; select the first unread article.
7404 (gnus-summary-next-article t (and gnus-auto-select-same
7405 (gnus-summary-article-subject)))
7406 (gnus-message 7 "%d article%s marked as %s"
7407 count (if (= count 1) " is" "s are")
7408 (if unmark "unread" "read"))))
7410 (defun gnus-summary-kill-same-subject (&optional unmark)
7411 "Mark articles which has the same subject as read.
7412 If UNMARK is positive, remove any kind of mark.
7413 If UNMARK is negative, tick articles."
7416 (setq unmark (prefix-numeric-value unmark)))
7418 (gnus-summary-mark-same-subject
7419 (gnus-summary-article-subject) unmark)))
7420 ;; If marked as read, go to next unread subject.
7422 ;; Go to next unread subject.
7423 (gnus-summary-next-subject 1 t))
7424 (gnus-message 7 "%d articles are marked as %s"
7425 count (if unmark "unread" "read"))))
7427 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7428 "Mark articles with same SUBJECT as read, and return marked number.
7429 If optional argument UNMARK is positive, remove any kinds of marks.
7430 If optional argument UNMARK is negative, mark articles as unread instead."
7434 ((null unmark) ; Mark as read.
7437 (gnus-summary-mark-article-as-read gnus-killed-mark)
7438 (gnus-summary-show-thread) t)
7439 (gnus-summary-find-subject subject))
7440 (setq count (1+ count))))
7441 ((> unmark 0) ; Tick.
7444 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
7445 (gnus-summary-show-thread) t)
7446 (gnus-summary-find-subject subject))
7447 (setq count (1+ count))))
7448 (t ; Mark as unread.
7451 (gnus-summary-mark-article-as-unread gnus-unread-mark)
7452 (gnus-summary-show-thread) t)
7453 (gnus-summary-find-subject subject))
7454 (setq count (1+ count)))))
7455 (gnus-set-mode-line 'summary)
7456 ;; Return the number of marked articles.
7459 (defun gnus-summary-mark-as-processable (n &optional unmark)
7460 "Set the process mark on the next N articles.
7461 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7462 the process mark instead. The difference between N and the actual
7463 number of articles marked is returned."
7465 (let ((backward (< n 0))
7470 (gnus-summary-remove-process-mark
7471 (gnus-summary-article-number))
7472 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7473 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7476 (gnus-message 7 "No more articles"))
7477 (gnus-summary-recenter)
7478 (gnus-summary-position-point)
7481 (defun gnus-summary-unmark-as-processable (n)
7482 "Remove the process mark from the next N articles.
7483 If N is negative, unmark backward instead. The difference between N and
7484 the actual number of articles unmarked is returned."
7486 (gnus-summary-mark-as-processable n t))
7488 (defun gnus-summary-unmark-all-processable ()
7489 "Remove the process mark from all articles."
7492 (while gnus-newsgroup-processable
7493 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7494 (gnus-summary-position-point))
7496 (defun gnus-summary-mark-as-expirable (n)
7497 "Mark N articles forward as expirable.
7498 If N is negative, mark backward instead. The difference between N and
7499 the actual number of articles marked is returned."
7501 (gnus-summary-mark-forward n gnus-expirable-mark))
7503 (defun gnus-summary-mark-article-as-replied (article)
7504 "Mark ARTICLE replied and update the summary line."
7505 (push article gnus-newsgroup-replied)
7506 (let ((buffer-read-only nil))
7507 (when (gnus-summary-goto-subject article)
7508 (gnus-summary-update-secondary-mark article))))
7510 (defun gnus-summary-set-bookmark (article)
7511 "Set a bookmark in current article."
7512 (interactive (list (gnus-summary-article-number)))
7513 (when (or (not (get-buffer gnus-article-buffer))
7514 (not gnus-current-article)
7515 (not gnus-article-current)
7516 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7517 (error "No current article selected"))
7518 ;; Remove old bookmark, if one exists.
7519 (let ((old (assq article gnus-newsgroup-bookmarks)))
7521 (setq gnus-newsgroup-bookmarks
7522 (delq old gnus-newsgroup-bookmarks))))
7523 ;; Set the new bookmark, which is on the form
7524 ;; (article-number . line-number-in-body).
7528 (set-buffer gnus-article-buffer)
7532 (goto-char (point-min))
7533 (search-forward "\n\n" nil t)
7536 gnus-newsgroup-bookmarks)
7537 (gnus-message 6 "A bookmark has been added to the current article."))
7539 (defun gnus-summary-remove-bookmark (article)
7540 "Remove the bookmark from the current article."
7541 (interactive (list (gnus-summary-article-number)))
7542 ;; Remove old bookmark, if one exists.
7543 (let ((old (assq article gnus-newsgroup-bookmarks)))
7546 (setq gnus-newsgroup-bookmarks
7547 (delq old gnus-newsgroup-bookmarks))
7548 (gnus-message 6 "Removed bookmark."))
7549 (gnus-message 6 "No bookmark in current article."))))
7551 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7552 (defun gnus-summary-mark-as-dormant (n)
7553 "Mark N articles forward as dormant.
7554 If N is negative, mark backward instead. The difference between N and
7555 the actual number of articles marked is returned."
7557 (gnus-summary-mark-forward n gnus-dormant-mark))
7559 (defun gnus-summary-set-process-mark (article)
7560 "Set the process mark on ARTICLE and update the summary line."
7561 (setq gnus-newsgroup-processable
7563 (delq article gnus-newsgroup-processable)))
7564 (when (gnus-summary-goto-subject article)
7565 (gnus-summary-show-thread)
7566 (gnus-summary-update-secondary-mark article)))
7568 (defun gnus-summary-remove-process-mark (article)
7569 "Remove the process mark from ARTICLE and update the summary line."
7570 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7571 (when (gnus-summary-goto-subject article)
7572 (gnus-summary-show-thread)
7573 (gnus-summary-update-secondary-mark article)))
7575 (defun gnus-summary-set-saved-mark (article)
7576 "Set the process mark on ARTICLE and update the summary line."
7577 (push article gnus-newsgroup-saved)
7578 (when (gnus-summary-goto-subject article)
7579 (gnus-summary-update-secondary-mark article)))
7581 (defun gnus-summary-mark-forward (n &optional mark no-expire)
7582 "Mark N articles as read forwards.
7583 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
7584 The difference between N and the actual number of articles marked is
7587 (let ((backward (< n 0))
7588 (gnus-summary-goto-unread
7589 (and gnus-summary-goto-unread
7590 (not (eq gnus-summary-goto-unread 'never))
7591 (not (memq mark (list gnus-unread-mark
7592 gnus-ticked-mark gnus-dormant-mark)))))
7594 (mark (or mark gnus-del-mark)))
7596 (gnus-summary-mark-article nil mark no-expire)
7597 (zerop (gnus-summary-next-subject
7599 (and gnus-summary-goto-unread
7600 (not (eq gnus-summary-goto-unread 'never)))
7604 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
7605 (gnus-summary-recenter)
7606 (gnus-summary-position-point)
7607 (gnus-set-mode-line 'summary)
7610 (defun gnus-summary-mark-article-as-read (mark)
7611 "Mark the current article quickly as read with MARK."
7612 (let ((article (gnus-summary-article-number)))
7613 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7614 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7615 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7616 (push (cons article mark) gnus-newsgroup-reads)
7617 ;; Possibly remove from cache, if that is used.
7618 (when gnus-use-cache
7619 (gnus-cache-enter-remove-article article))
7620 ;; Allow the backend to change the mark.
7621 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7622 ;; Check for auto-expiry.
7623 (when (and gnus-newsgroup-auto-expire
7624 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7625 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7626 (= mark gnus-ancient-mark)
7627 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7628 (= mark gnus-duplicate-mark)))
7629 (setq mark gnus-expirable-mark)
7630 (push article gnus-newsgroup-expirable))
7631 ;; Set the mark in the buffer.
7632 (gnus-summary-update-mark mark 'unread)
7635 (defun gnus-summary-mark-article-as-unread (mark)
7636 "Mark the current article quickly as unread with MARK."
7637 (let* ((article (gnus-summary-article-number))
7638 (old-mark (gnus-summary-article-mark article)))
7639 (if (eq mark old-mark)
7643 (gnus-error 1 "Can't mark negative article numbers")
7645 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7646 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7647 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
7648 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
7649 (cond ((= mark gnus-ticked-mark)
7650 (push article gnus-newsgroup-marked))
7651 ((= mark gnus-dormant-mark)
7652 (push article gnus-newsgroup-dormant))
7654 (push article gnus-newsgroup-unreads)))
7655 (gnus-pull article gnus-newsgroup-reads)
7657 ;; See whether the article is to be put in the cache.
7659 (vectorp (gnus-summary-article-header article))
7661 (gnus-cache-possibly-enter-article
7662 gnus-newsgroup-name article
7663 (gnus-summary-article-header article)
7664 (= mark gnus-ticked-mark)
7665 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7668 (gnus-summary-update-mark mark 'unread)
7671 (defun gnus-summary-mark-article (&optional article mark no-expire)
7672 "Mark ARTICLE with MARK. MARK can be any character.
7673 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
7674 `??' (dormant) and `?E' (expirable).
7675 If MARK is nil, then the default character `?D' is used.
7676 If ARTICLE is nil, then the article on the current line will be
7678 ;; The mark might be a string.
7679 (when (stringp mark)
7680 (setq mark (aref mark 0)))
7681 ;; If no mark is given, then we check auto-expiring.
7682 (and (not no-expire)
7683 gnus-newsgroup-auto-expire
7685 (and (gnus-characterp mark)
7686 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7687 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7688 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7689 (= mark gnus-duplicate-mark))))
7690 (setq mark gnus-expirable-mark))
7691 (let* ((mark (or mark gnus-del-mark))
7692 (article (or article (gnus-summary-article-number)))
7693 (old-mark (gnus-summary-article-mark article)))
7694 (if (eq mark old-mark)
7697 (error "No article on current line"))
7698 (if (not (if (or (= mark gnus-unread-mark)
7699 (= mark gnus-ticked-mark)
7700 (= mark gnus-dormant-mark))
7701 (gnus-mark-article-as-unread article mark)
7702 (gnus-mark-article-as-read article mark)))
7704 ;; See whether the article is to be put in the cache.
7706 (not (= mark gnus-canceled-mark))
7707 (vectorp (gnus-summary-article-header article))
7709 (gnus-cache-possibly-enter-article
7710 gnus-newsgroup-name article
7711 (gnus-summary-article-header article)
7712 (= mark gnus-ticked-mark)
7713 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7715 (when (gnus-summary-goto-subject article nil t)
7716 (let ((buffer-read-only nil))
7717 (gnus-summary-show-thread)
7719 (gnus-summary-update-mark mark 'unread)
7722 (defun gnus-summary-update-secondary-mark (article)
7723 "Update the secondary (read, process, cache) mark."
7724 (gnus-summary-update-mark
7725 (cond ((memq article gnus-newsgroup-processable)
7727 ((memq article gnus-newsgroup-cached)
7729 ((memq article gnus-newsgroup-replied)
7731 ((memq article gnus-newsgroup-saved)
7733 (t gnus-unread-mark))
7735 (when (gnus-visual-p 'summary-highlight 'highlight)
7736 (gnus-run-hooks 'gnus-summary-update-hook))
7739 (defun gnus-summary-update-mark (mark type)
7740 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
7741 (buffer-read-only nil))
7742 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
7743 (when (looking-at "\r")
7746 (<= (+ forward (point)) (point-max)))
7747 ;; Go to the right position on the line.
7748 (goto-char (+ forward (point)))
7749 ;; Replace the old mark with the new mark.
7750 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
7751 ;; Optionally update the marks by some user rule.
7752 (when (eq type 'unread)
7754 (gnus-data-find (gnus-summary-article-number)) mark)
7755 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
7757 (defun gnus-mark-article-as-read (article &optional mark)
7758 "Enter ARTICLE in the pertinent lists and remove it from others."
7759 ;; Make the article expirable.
7760 (let ((mark (or mark gnus-del-mark)))
7761 (if (= mark gnus-expirable-mark)
7762 (push article gnus-newsgroup-expirable)
7763 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
7764 ;; Remove from unread and marked lists.
7765 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7766 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7767 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7768 (push (cons article mark) gnus-newsgroup-reads)
7769 ;; Possibly remove from cache, if that is used.
7770 (when gnus-use-cache
7771 (gnus-cache-enter-remove-article article))
7774 (defun gnus-mark-article-as-unread (article &optional mark)
7775 "Enter ARTICLE in the pertinent lists and remove it from others."
7776 (let ((mark (or mark gnus-ticked-mark)))
7779 (gnus-error 1 "Can't mark negative article numbers")
7781 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
7782 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
7783 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
7784 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7786 ;; Unsuppress duplicates?
7787 (when gnus-suppress-duplicates
7788 (gnus-dup-unsuppress-article article))
7790 (cond ((= mark gnus-ticked-mark)
7791 (push article gnus-newsgroup-marked))
7792 ((= mark gnus-dormant-mark)
7793 (push article gnus-newsgroup-dormant))
7795 (push article gnus-newsgroup-unreads)))
7796 (gnus-pull article gnus-newsgroup-reads)
7799 (defalias 'gnus-summary-mark-as-unread-forward
7800 'gnus-summary-tick-article-forward)
7801 (make-obsolete 'gnus-summary-mark-as-unread-forward
7802 'gnus-summary-tick-article-forward)
7803 (defun gnus-summary-tick-article-forward (n)
7804 "Tick N articles forwards.
7805 If N is negative, tick backwards instead.
7806 The difference between N and the number of articles ticked is returned."
7808 (gnus-summary-mark-forward n gnus-ticked-mark))
7810 (defalias 'gnus-summary-mark-as-unread-backward
7811 'gnus-summary-tick-article-backward)
7812 (make-obsolete 'gnus-summary-mark-as-unread-backward
7813 'gnus-summary-tick-article-backward)
7814 (defun gnus-summary-tick-article-backward (n)
7815 "Tick N articles backwards.
7816 The difference between N and the number of articles ticked is returned."
7818 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
7820 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7821 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7822 (defun gnus-summary-tick-article (&optional article clear-mark)
7823 "Mark current article as unread.
7824 Optional 1st argument ARTICLE specifies article number to be marked as unread.
7825 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
7827 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
7830 (defun gnus-summary-mark-as-read-forward (n)
7831 "Mark N articles as read forwards.
7832 If N is negative, mark backwards instead.
7833 The difference between N and the actual number of articles marked is
7836 (gnus-summary-mark-forward n gnus-del-mark t))
7838 (defun gnus-summary-mark-as-read-backward (n)
7839 "Mark the N articles as read backwards.
7840 The difference between N and the actual number of articles marked is
7843 (gnus-summary-mark-forward (- n) gnus-del-mark t))
7845 (defun gnus-summary-mark-as-read (&optional article mark)
7846 "Mark current article as read.
7847 ARTICLE specifies the article to be marked as read.
7848 MARK specifies a string to be inserted at the beginning of the line."
7849 (gnus-summary-mark-article article mark))
7851 (defun gnus-summary-clear-mark-forward (n)
7852 "Clear marks from N articles forward.
7853 If N is negative, clear backward instead.
7854 The difference between N and the number of marks cleared is returned."
7856 (gnus-summary-mark-forward n gnus-unread-mark))
7858 (defun gnus-summary-clear-mark-backward (n)
7859 "Clear marks from N articles backward.
7860 The difference between N and the number of marks cleared is returned."
7862 (gnus-summary-mark-forward (- n) gnus-unread-mark))
7864 (defun gnus-summary-mark-unread-as-read ()
7865 "Intended to be used by `gnus-summary-mark-article-hook'."
7866 (when (memq gnus-current-article gnus-newsgroup-unreads)
7867 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
7869 (defun gnus-summary-mark-read-and-unread-as-read ()
7870 "Intended to be used by `gnus-summary-mark-article-hook'."
7871 (let ((mark (gnus-summary-article-mark)))
7872 (when (or (gnus-unread-mark-p mark)
7873 (gnus-read-mark-p mark))
7874 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
7876 (defun gnus-summary-mark-region-as-read (point mark all)
7877 "Mark all unread articles between point and mark as read.
7878 If given a prefix, mark all articles between point and mark as read,
7879 even ticked and dormant ones."
7880 (interactive "r\nP")
7889 (memq (setq article (gnus-summary-article-number))
7890 gnus-newsgroup-unreads))
7891 (gnus-summary-mark-article article gnus-del-mark))
7893 (gnus-summary-find-next))))))
7895 (defun gnus-summary-mark-below (score mark)
7896 "Mark articles with score less than SCORE with MARK."
7897 (interactive "P\ncMark: ")
7898 (setq score (if score
7899 (prefix-numeric-value score)
7900 (or gnus-summary-default-score 0)))
7902 (set-buffer gnus-summary-buffer)
7903 (goto-char (point-min))
7906 (and (< (gnus-summary-article-score) score)
7907 (gnus-summary-mark-article nil mark))
7908 (gnus-summary-find-next)))))
7910 (defun gnus-summary-kill-below (&optional score)
7911 "Mark articles with score below SCORE as read."
7913 (gnus-summary-mark-below score gnus-killed-mark))
7915 (defun gnus-summary-clear-above (&optional score)
7916 "Clear all marks from articles with score above SCORE."
7918 (gnus-summary-mark-above score gnus-unread-mark))
7920 (defun gnus-summary-tick-above (&optional score)
7921 "Tick all articles with score above SCORE."
7923 (gnus-summary-mark-above score gnus-ticked-mark))
7925 (defun gnus-summary-mark-above (score mark)
7926 "Mark articles with score over SCORE with MARK."
7927 (interactive "P\ncMark: ")
7928 (setq score (if score
7929 (prefix-numeric-value score)
7930 (or gnus-summary-default-score 0)))
7932 (set-buffer gnus-summary-buffer)
7933 (goto-char (point-min))
7935 (when (> (gnus-summary-article-score) score)
7936 (gnus-summary-mark-article nil mark))
7938 (gnus-summary-find-next)))))
7940 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7941 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
7942 (defun gnus-summary-limit-include-expunged (&optional no-error)
7943 "Display all the hidden articles that were expunged for low scores."
7945 (let ((buffer-read-only nil))
7946 (let ((scored gnus-newsgroup-scored)
7949 (unless (gnus-summary-goto-subject (caar scored))
7950 (and (setq h (gnus-summary-article-header (caar scored)))
7951 (< (cdar scored) gnus-summary-expunge-below)
7953 (setq scored (cdr scored)))
7955 (when (not no-error)
7956 (error "No expunged articles hidden"))
7957 (goto-char (point-min))
7958 (gnus-summary-prepare-unthreaded (nreverse headers))
7959 (goto-char (point-min))
7960 (gnus-summary-position-point)
7963 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
7964 "Mark all unread articles in this newsgroup as read.
7965 If prefix argument ALL is non-nil, ticked and dormant articles will
7966 also be marked as read.
7967 If QUIETLY is non-nil, no questions will be asked.
7968 If TO-HERE is non-nil, it should be a point in the buffer. All
7969 articles before this point will be marked as read.
7970 Note that this function will only catch up the unread article
7971 in the current summary buffer limitation.
7972 The number of articles marked as read is returned."
7977 (not gnus-interactive-catchup) ;Without confirmation?
7981 "Mark absolutely all articles as read? "
7982 "Mark all unread articles as read? ")))
7984 (not gnus-newsgroup-adaptive)
7985 (not gnus-newsgroup-auto-expire)
7986 (not gnus-suppress-duplicates)
7987 (or (not gnus-use-cache)
7988 (eq gnus-use-cache 'passive)))
7991 (setq gnus-newsgroup-marked nil
7992 gnus-newsgroup-dormant nil))
7993 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
7994 ;; We actually mark all articles as canceled, which we
7995 ;; have to do when using auto-expiry or adaptive scoring.
7996 (gnus-summary-show-all-threads)
7997 (when (gnus-summary-first-subject (not all) t)
7999 (if to-here (< (point) to-here) t)
8000 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8001 (gnus-summary-find-next (not all) nil nil t))))
8002 (gnus-set-mode-line 'summary))
8004 (gnus-summary-position-point)))
8006 (defun gnus-summary-catchup-to-here (&optional all)
8007 "Mark all unticked articles before the current one as read.
8008 If ALL is non-nil, also mark ticked and dormant articles as read."
8011 (gnus-save-hidden-threads
8012 (let ((beg (point)))
8013 ;; We check that there are unread articles.
8014 (when (or all (gnus-summary-find-prev))
8015 (gnus-summary-catchup all t beg)))))
8016 (gnus-summary-position-point))
8018 (defun gnus-summary-catchup-all (&optional quietly)
8019 "Mark all articles in this newsgroup as read."
8021 (gnus-summary-catchup t quietly))
8023 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8024 "Mark all articles not marked as unread in this newsgroup as read, then exit.
8025 If prefix argument ALL is non-nil, all articles are marked as read."
8027 (when (gnus-summary-catchup all quietly nil 'fast)
8028 ;; Select next newsgroup or exit.
8029 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
8030 (eq gnus-auto-select-next 'quietly))
8031 (gnus-summary-next-group nil)
8032 (gnus-summary-exit))))
8034 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8035 "Mark all articles in this newsgroup as read, and then exit."
8037 (gnus-summary-catchup-and-exit t quietly))
8039 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
8040 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8041 "Mark all articles in this group as read and select the next group.
8042 If given a prefix, mark all articles, unread as well as ticked, as
8046 (gnus-summary-catchup all))
8047 (gnus-summary-next-article t nil nil t))
8049 ;; Thread-based commands.
8051 (defun gnus-summary-articles-in-thread (&optional article)
8052 "Return a list of all articles in the current thread.
8053 If ARTICLE is non-nil, return all articles in the thread that starts
8055 (let* ((article (or article (gnus-summary-article-number)))
8056 (data (gnus-data-find-list article))
8057 (top-level (gnus-data-level (car data)))
8059 (cond ((null gnus-thread-operation-ignore-subject)
8060 (gnus-simplify-subject-re
8061 (mail-header-subject (gnus-data-header (car data)))))
8062 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8063 (gnus-simplify-subject-fuzzy
8064 (mail-header-subject (gnus-data-header (car data)))))
8066 (end-point (save-excursion
8067 (if (gnus-summary-go-to-next-thread)
8068 (point) (point-max))))
8071 (< (gnus-data-pos (car data)) end-point))
8072 (when (or (not top-subject)
8073 (string= top-subject
8074 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8075 (gnus-simplify-subject-fuzzy
8076 (mail-header-subject
8077 (gnus-data-header (car data))))
8078 (gnus-simplify-subject-re
8079 (mail-header-subject
8080 (gnus-data-header (car data)))))))
8081 (push (gnus-data-number (car data)) articles))
8082 (unless (and (setq data (cdr data))
8083 (> (gnus-data-level (car data)) top-level))
8085 ;; Return the list of articles.
8086 (nreverse articles)))
8088 (defun gnus-summary-rethread-current ()
8089 "Rethread the thread the current article is part of."
8091 (let* ((gnus-show-threads t)
8092 (article (gnus-summary-article-number))
8093 (id (mail-header-id (gnus-summary-article-header)))
8094 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8096 (error "No article on the current line"))
8097 (gnus-rebuild-thread id)
8098 (gnus-summary-goto-subject article)))
8100 (defun gnus-summary-reparent-thread ()
8101 "Make the current article child of the marked (or previous) article.
8103 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8104 is non-nil or the Subject: of both articles are the same."
8106 (unless (not (gnus-group-read-only-p))
8107 (error "The current newsgroup does not support article editing"))
8108 (unless (<= (length gnus-newsgroup-processable) 1)
8109 (error "No more than one article may be marked"))
8110 (save-window-excursion
8111 (let ((gnus-article-buffer " *reparent*")
8112 (current-article (gnus-summary-article-number))
8113 ;; First grab the marked article, otherwise one line up.
8114 (parent-article (if (not (null gnus-newsgroup-processable))
8115 (car gnus-newsgroup-processable)
8117 (if (eq (forward-line -1) 0)
8118 (gnus-summary-article-number)
8119 (error "Beginning of summary buffer"))))))
8120 (unless (not (eq current-article parent-article))
8121 (error "An article may not be self-referential"))
8122 (let ((message-id (mail-header-id
8123 (gnus-summary-article-header parent-article))))
8124 (unless (and message-id (not (equal message-id "")))
8125 (error "No message-id in desired parent"))
8126 ;; We don't want the article to be marked as read.
8127 (let (gnus-mark-article-hook)
8128 (gnus-summary-select-article t t nil current-article))
8129 (set-buffer gnus-original-article-buffer)
8130 (let ((buf (format "%s" (buffer-string))))
8131 (nnheader-temp-write nil
8133 (goto-char (point-min))
8134 (if (re-search-forward "^References: " nil t)
8136 (re-search-forward "^[^ \t]" nil t)
8139 (insert " " message-id))
8140 (insert "References: " message-id "\n"))
8141 (unless (gnus-request-replace-article
8142 current-article (car gnus-article-current)
8144 (error "Couldn't replace article"))))
8145 (set-buffer gnus-summary-buffer)
8146 (gnus-summary-unmark-all-processable)
8147 (gnus-summary-update-article current-article)
8148 (gnus-summary-rethread-current)
8149 (gnus-message 3 "Article %d is now the child of article %d"
8150 current-article parent-article)))))
8152 (defun gnus-summary-toggle-threads (&optional arg)
8153 "Toggle showing conversation threads.
8154 If ARG is positive number, turn showing conversation threads on."
8156 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8157 (setq gnus-show-threads
8158 (if (null arg) (not gnus-show-threads)
8159 (> (prefix-numeric-value arg) 0)))
8160 (gnus-summary-prepare)
8161 (gnus-summary-goto-subject current)
8162 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8163 (gnus-summary-position-point)))
8165 (defun gnus-summary-show-all-threads ()
8169 (let ((buffer-read-only nil))
8170 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8171 (gnus-summary-position-point))
8173 (defun gnus-summary-show-thread ()
8174 "Show thread subtrees.
8175 Returns nil if no thread was there to be shown."
8177 (let ((buffer-read-only nil)
8179 ;; first goto end then to beg, to have point at beg after let
8180 (end (progn (end-of-line) (point)))
8181 (beg (progn (beginning-of-line) (point))))
8183 ;; Any hidden lines here?
8184 (search-forward "\r" end t)
8185 (subst-char-in-region beg end ?\^M ?\n t)
8187 (gnus-summary-position-point))))
8189 (defun gnus-summary-hide-all-threads ()
8190 "Hide all thread subtrees."
8193 (goto-char (point-min))
8194 (gnus-summary-hide-thread)
8195 (while (zerop (gnus-summary-next-thread 1 t))
8196 (gnus-summary-hide-thread)))
8197 (gnus-summary-position-point))
8199 (defun gnus-summary-hide-thread ()
8200 "Hide thread subtrees.
8201 Returns nil if no threads were there to be hidden."
8203 (let ((buffer-read-only nil)
8205 (article (gnus-summary-article-number)))
8207 ;; Go forward until either the buffer ends or the subthread
8209 (when (and (not (eobp))
8210 (or (zerop (gnus-summary-next-thread 1 t))
8211 (goto-char (point-max))))
8213 (if (and (> (point) start)
8214 (search-backward "\n" start t))
8216 (subst-char-in-region start (point) ?\n ?\^M)
8217 (gnus-summary-goto-subject article))
8220 ;;(gnus-summary-position-point)
8223 (defun gnus-summary-go-to-next-thread (&optional previous)
8224 "Go to the same level (or less) next thread.
8225 If PREVIOUS is non-nil, go to previous thread instead.
8226 Return the article number moved to, or nil if moving was impossible."
8227 (let ((level (gnus-summary-thread-level))
8228 (way (if previous -1 1))
8231 (while (and (not (eobp))
8232 (< level (gnus-summary-thread-level)))
8240 (gnus-summary-article-number)
8243 (defun gnus-summary-next-thread (n &optional silent)
8244 "Go to the same level next N'th thread.
8245 If N is negative, search backward instead.
8246 Returns the difference between N and the number of skips actually
8249 If SILENT, don't output messages."
8251 (let ((backward (< n 0))
8254 (gnus-summary-go-to-next-thread backward))
8257 (gnus-summary-position-point))
8258 (when (and (not silent) (/= 0 n))
8259 (gnus-message 7 "No more threads"))
8262 (defun gnus-summary-prev-thread (n)
8263 "Go to the same level previous N'th thread.
8264 Returns the difference between N and the number of skips actually
8267 (gnus-summary-next-thread (- n)))
8269 (defun gnus-summary-go-down-thread ()
8270 "Go down one level in the current thread."
8271 (let ((children (gnus-summary-article-children)))
8273 (gnus-summary-goto-subject (car children)))))
8275 (defun gnus-summary-go-up-thread ()
8276 "Go up one level in the current thread."
8277 (let ((parent (gnus-summary-article-parent)))
8279 (gnus-summary-goto-subject parent))))
8281 (defun gnus-summary-down-thread (n)
8282 "Go down thread N steps.
8283 If N is negative, go up instead.
8284 Returns the difference between N and how many steps down that were
8290 (if up (gnus-summary-go-up-thread)
8291 (gnus-summary-go-down-thread)))
8293 (gnus-summary-position-point)
8295 (gnus-message 7 "Can't go further"))
8298 (defun gnus-summary-up-thread (n)
8299 "Go up thread N steps.
8300 If N is negative, go up instead.
8301 Returns the difference between N and how many steps down that were
8304 (gnus-summary-down-thread (- n)))
8306 (defun gnus-summary-top-thread ()
8307 "Go to the top of the thread."
8309 (while (gnus-summary-go-up-thread))
8310 (gnus-summary-article-number))
8312 (defun gnus-summary-kill-thread (&optional unmark)
8313 "Mark articles under current thread as read.
8314 If the prefix argument is positive, remove any kinds of marks.
8315 If the prefix argument is negative, tick articles instead."
8318 (setq unmark (prefix-numeric-value unmark)))
8319 (let ((articles (gnus-summary-articles-in-thread)))
8321 ;; Expand the thread.
8322 (gnus-summary-show-thread)
8323 ;; Mark all the articles.
8325 (gnus-summary-goto-subject (car articles))
8326 (cond ((null unmark)
8327 (gnus-summary-mark-article-as-read gnus-killed-mark))
8329 (gnus-summary-mark-article-as-unread gnus-unread-mark))
8331 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
8332 (setq articles (cdr articles))))
8333 ;; Hide killed subtrees.
8335 gnus-thread-hide-killed
8336 (gnus-summary-hide-thread))
8337 ;; If marked as read, go to next unread subject.
8339 ;; Go to next unread subject.
8340 (gnus-summary-next-subject 1 t)))
8341 (gnus-set-mode-line 'summary))
8343 ;; Summary sorting commands
8345 (defun gnus-summary-sort-by-number (&optional reverse)
8346 "Sort the summary buffer by article number.
8347 Argument REVERSE means reverse order."
8349 (gnus-summary-sort 'number reverse))
8351 (defun gnus-summary-sort-by-author (&optional reverse)
8352 "Sort the summary buffer by author name alphabetically.
8353 If case-fold-search is non-nil, case of letters is ignored.
8354 Argument REVERSE means reverse order."
8356 (gnus-summary-sort 'author reverse))
8358 (defun gnus-summary-sort-by-subject (&optional reverse)
8359 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8360 If case-fold-search is non-nil, case of letters is ignored.
8361 Argument REVERSE means reverse order."
8363 (gnus-summary-sort 'subject reverse))
8365 (defun gnus-summary-sort-by-date (&optional reverse)
8366 "Sort the summary buffer by date.
8367 Argument REVERSE means reverse order."
8369 (gnus-summary-sort 'date reverse))
8371 (defun gnus-summary-sort-by-score (&optional reverse)
8372 "Sort the summary buffer by score.
8373 Argument REVERSE means reverse order."
8375 (gnus-summary-sort 'score reverse))
8377 (defun gnus-summary-sort-by-lines (&optional reverse)
8378 "Sort the summary buffer by article length.
8379 Argument REVERSE means reverse order."
8381 (gnus-summary-sort 'lines reverse))
8383 (defun gnus-summary-sort (predicate reverse)
8384 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
8385 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
8386 (article (intern (format "gnus-article-sort-by-%s" predicate)))
8387 (gnus-thread-sort-functions
8393 (gnus-article-sort-functions
8398 (,article t2 t1)))))
8400 (gnus-summary-prepare-hook nil))
8401 ;; We do the sorting by regenerating the threads.
8402 (gnus-summary-prepare)
8403 ;; Hide subthreads if needed.
8404 (when (and gnus-show-threads gnus-thread-hide-subtree)
8405 (gnus-summary-hide-all-threads))))
8407 ;; Summary saving commands.
8409 (defun gnus-summary-save-article (&optional n not-saved)
8410 "Save the current article using the default saver function.
8411 If N is a positive number, save the N next articles.
8412 If N is a negative number, save the N previous articles.
8413 If N is nil and any articles have been marked with the process mark,
8414 save those articles instead.
8415 The variable `gnus-default-article-saver' specifies the saver function."
8417 (let* ((articles (gnus-summary-work-articles n))
8418 (save-buffer (save-excursion
8419 (nnheader-set-temp-buffer " *Gnus Save*")))
8420 (num (length articles))
8421 header article file)
8423 (setq header (gnus-summary-article-header
8424 (setq article (pop articles))))
8425 (if (not (vectorp header))
8426 ;; This is a pseudo-article.
8427 (if (assq 'name header)
8428 (gnus-copy-file (cdr (assq 'name header)))
8429 (gnus-message 1 "Article %d is unsaveable" article))
8430 ;; This is a real article.
8431 (save-window-excursion
8432 (gnus-summary-select-article t nil nil article))
8434 (set-buffer save-buffer)
8436 (insert-buffer-substring gnus-original-article-buffer))
8437 (setq file (gnus-article-save save-buffer file num))
8438 (gnus-summary-remove-process-mark article)
8440 (gnus-summary-set-saved-mark article))))
8441 (gnus-kill-buffer save-buffer)
8442 (gnus-summary-position-point)
8443 (gnus-set-mode-line 'summary)
8446 (defun gnus-summary-pipe-output (&optional arg)
8447 "Pipe the current article to a subprocess.
8448 If N is a positive number, pipe the N next articles.
8449 If N is a negative number, pipe the N previous articles.
8450 If N is nil and any articles have been marked with the process mark,
8451 pipe those articles instead."
8453 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8454 (gnus-summary-save-article arg t))
8455 (gnus-configure-windows 'pipe))
8457 (defun gnus-summary-save-article-mail (&optional arg)
8458 "Append the current article to an mail file.
8459 If N is a positive number, save the N next articles.
8460 If N is a negative number, save the N previous articles.
8461 If N is nil and any articles have been marked with the process mark,
8462 save those articles instead."
8464 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8465 (gnus-summary-save-article arg)))
8467 (defun gnus-summary-save-article-rmail (&optional arg)
8468 "Append the current article to an rmail file.
8469 If N is a positive number, save the N next articles.
8470 If N is a negative number, save the N previous articles.
8471 If N is nil and any articles have been marked with the process mark,
8472 save those articles instead."
8474 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
8475 (gnus-summary-save-article arg)))
8477 (defun gnus-summary-save-article-file (&optional arg)
8478 "Append the current article to a file.
8479 If N is a positive number, save the N next articles.
8480 If N is a negative number, save the N previous articles.
8481 If N is nil and any articles have been marked with the process mark,
8482 save those articles instead."
8484 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8485 (gnus-summary-save-article arg)))
8487 (defun gnus-summary-write-article-file (&optional arg)
8488 "Write the current article to a file, deleting the previous file.
8489 If N is a positive number, save the N next articles.
8490 If N is a negative number, save the N previous articles.
8491 If N is nil and any articles have been marked with the process mark,
8492 save those articles instead."
8494 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
8495 (gnus-summary-save-article arg)))
8497 (defun gnus-summary-save-article-body-file (&optional arg)
8498 "Append the current article body to a file.
8499 If N is a positive number, save the N next articles.
8500 If N is a negative number, save the N previous articles.
8501 If N is nil and any articles have been marked with the process mark,
8502 save those articles instead."
8504 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
8505 (gnus-summary-save-article arg)))
8507 (defun gnus-summary-pipe-message (program)
8508 "Pipe the current article through PROGRAM."
8509 (interactive "sProgram: ")
8510 (gnus-summary-select-article)
8511 (let ((mail-header-separator "")
8512 (art-buf (get-buffer gnus-article-buffer)))
8513 (gnus-eval-in-buffer-window gnus-article-buffer
8516 (let ((start (window-start))
8518 (message-pipe-buffer-body program)
8519 (set-window-start (get-buffer-window (current-buffer)) start))))))
8521 (defun gnus-get-split-value (methods)
8522 "Return a value based on the split METHODS."
8523 (let (split-name method result match)
8526 (set-buffer gnus-original-article-buffer)
8528 (nnheader-narrow-to-headers)
8530 (goto-char (point-min))
8531 (setq method (pop methods))
8532 (setq match (car method))
8535 ;; Regular expression.
8537 (re-search-forward match nil t)))
8538 ((gnus-functionp match)
8542 (setq result (funcall match gnus-newsgroup-name))))
8547 (setq result (eval match)))))
8548 (setq split-name (append (cdr method) split-name))
8549 (cond ((stringp result)
8550 (push (expand-file-name
8551 result gnus-article-save-directory)
8554 (setq split-name (append result split-name)))))))))
8557 (defun gnus-valid-move-group-p (group)
8562 (car (gnus-find-method-for-group
8563 (symbol-name group))))
8564 gnus-valid-select-methods))))
8566 (defun gnus-read-move-group-name (prompt default articles prefix)
8567 "Read a group name."
8568 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
8569 (minibuffer-confirm-incomplete nil) ; XEmacs
8573 (if (> (length articles) 1)
8574 (format "these %d articles" (length articles))
8579 (gnus-completing-read default prom
8581 'gnus-valid-move-group-p
8583 'gnus-group-history))
8584 ((= 1 (length split-name))
8585 (gnus-completing-read (car split-name) prom
8587 'gnus-valid-move-group-p
8589 'gnus-group-history))
8591 (gnus-completing-read nil prom
8592 (mapcar (lambda (el) (list el))
8593 (nreverse split-name))
8595 'gnus-group-history)))))
8597 (if (or (string= to-newsgroup "")
8598 (string= to-newsgroup prefix))
8599 (setq to-newsgroup default))
8600 (unless to-newsgroup
8601 (error "No group name entered"))
8602 (or (gnus-active to-newsgroup)
8603 (gnus-activate-group to-newsgroup)
8604 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
8606 (or (and (gnus-request-create-group
8607 to-newsgroup (gnus-group-name-to-method to-newsgroup))
8608 (gnus-activate-group to-newsgroup nil nil
8609 (gnus-group-name-to-method
8611 (error "Couldn't create group %s" to-newsgroup)))
8612 (error "No such group: %s" to-newsgroup)))
8615 ;; Summary extract commands
8617 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
8618 (let ((buffer-read-only nil)
8619 (article (gnus-summary-article-number))
8621 (unless (gnus-summary-goto-subject article)
8622 (error "No such article: %d" article))
8623 (gnus-summary-position-point)
8624 ;; If all commands are to be bunched up on one line, we collect
8626 (unless gnus-view-pseudos-separately
8627 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
8630 (setq action (cdr (assq 'action (car ps))))
8631 (setq files (list (cdr (assq 'name (car ps)))))
8632 (while (and ps (cdr ps)
8633 (string= (or action "1")
8634 (or (cdr (assq 'action (cadr ps))) "2")))
8635 (push (cdr (assq 'name (cadr ps))) files)
8636 (setcdr ps (cddr ps)))
8638 (when (not (string-match "%s" action))
8641 (when (assq 'execute (car ps))
8642 (setcdr (assq 'execute (car ps))
8643 (funcall (if (string-match "%s" action)
8650 (gnus-quote-arg-for-sh-or-csh f)))
8652 (setq ps (cdr ps)))))
8653 (if (and gnus-view-pseudos (not not-view))
8655 (when (assq 'execute (car pslist))
8656 (gnus-execute-command (cdr (assq 'execute (car pslist)))
8657 (eq gnus-view-pseudos 'not-confirm)))
8658 (setq pslist (cdr pslist)))
8661 (setq after-article (or (cdr (assq 'article (car pslist)))
8662 (gnus-summary-article-number)))
8663 (gnus-summary-goto-subject after-article)
8666 (insert " " (file-name-nondirectory
8667 (cdr (assq 'name (car pslist))))
8668 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
8670 (forward-line -1) ; back to `b'
8671 (gnus-add-text-properties
8672 b (1- e) (list 'gnus-number gnus-reffed-article-number
8673 gnus-mouse-face-prop gnus-mouse-face))
8675 after-article gnus-reffed-article-number
8676 gnus-unread-mark b (car pslist) 0 (- e b))
8677 (push gnus-reffed-article-number gnus-newsgroup-unreads)
8678 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
8679 (setq pslist (cdr pslist)))))))
8681 (defun gnus-pseudos< (p1 p2)
8682 (let ((c1 (cdr (assq 'action p1)))
8683 (c2 (cdr (assq 'action p2))))
8684 (and c1 c2 (string< c1 c2))))
8686 (defun gnus-request-pseudo-article (props)
8687 (cond ((assq 'execute props)
8688 (gnus-execute-command (cdr (assq 'execute props)))))
8689 (let ((gnus-current-article (gnus-summary-article-number)))
8690 (gnus-run-hooks 'gnus-mark-article-hook)))
8692 (defun gnus-execute-command (command &optional automatic)
8694 (gnus-article-setup-buffer)
8695 (set-buffer gnus-article-buffer)
8696 (setq buffer-read-only nil)
8697 (let ((command (if automatic command
8698 (read-string "Command: " (cons command 0)))))
8700 (insert "$ " command "\n\n")
8701 (if gnus-view-pseudo-asynchronously
8702 (start-process "gnus-execute" (current-buffer) shell-file-name
8703 shell-command-switch command)
8704 (call-process shell-file-name nil t nil
8705 shell-command-switch command)))))
8707 ;; Summary kill commands.
8709 (defun gnus-summary-edit-global-kill (article)
8710 "Edit the \"global\" kill file."
8711 (interactive (list (gnus-summary-article-number)))
8712 (gnus-group-edit-global-kill article))
8714 (defun gnus-summary-edit-local-kill ()
8715 "Edit a local kill file applied to the current newsgroup."
8717 (setq gnus-current-headers (gnus-summary-article-header))
8718 (gnus-group-edit-local-kill
8719 (gnus-summary-article-number) gnus-newsgroup-name))
8723 (defun gnus-read-header (id &optional header)
8724 "Read the headers of article ID and enter them into the Gnus system."
8725 (let ((group gnus-newsgroup-name)
8726 (gnus-override-method
8727 (and (gnus-news-group-p gnus-newsgroup-name)
8728 gnus-refer-article-method))
8730 ;; First we check to see whether the header in question is already
8733 ;; This is a Message-ID.
8734 (setq header (or header (gnus-id-to-header id)))
8735 ;; This is an article number.
8736 (setq header (or header (gnus-summary-article-header id))))
8738 (not (gnus-summary-article-sparse-p (mail-header-number header))))
8739 ;; We have found the header.
8741 ;; If this is a sparse article, we have to nix out its
8742 ;; previous entry in the thread hashtb.
8744 (gnus-summary-article-sparse-p (mail-header-number header)))
8745 (let* ((parent (gnus-parent-id (mail-header-references header)))
8746 (thread (and parent (gnus-id-to-thread parent))))
8748 (delq (assq header thread) thread))))
8749 ;; We have to really fetch the header to this article.
8751 (set-buffer nntp-server-buffer)
8752 (when (setq where (gnus-request-head id group))
8753 (nnheader-fold-continuation-lines)
8754 (goto-char (point-max))
8756 (goto-char (point-min))
8760 ((cdr where) (cdr where))
8761 (header (mail-header-number header))
8762 (t gnus-reffed-article-number))
8764 (insert " Article retrieved.\n"))
8766 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
8767 () ; Malformed head.
8768 (unless (gnus-summary-article-sparse-p (mail-header-number header))
8769 (when (and (stringp id)
8770 (not (string= (gnus-group-real-name group)
8772 ;; If we fetched by Message-ID and the article came
8773 ;; from a different group, we fudge some bogus article
8774 ;; numbers for this article.
8775 (mail-header-set-number header gnus-reffed-article-number))
8777 (set-buffer gnus-summary-buffer)
8778 (decf gnus-reffed-article-number)
8779 (gnus-remove-header (mail-header-number header))
8780 (push header gnus-newsgroup-headers)
8781 (setq gnus-current-headers header)
8782 (push (mail-header-number header) gnus-newsgroup-limit)))
8785 (defun gnus-remove-header (number)
8786 "Remove header NUMBER from `gnus-newsgroup-headers'."
8787 (if (and gnus-newsgroup-headers
8788 (= number (mail-header-number (car gnus-newsgroup-headers))))
8789 (pop gnus-newsgroup-headers)
8790 (let ((headers gnus-newsgroup-headers))
8791 (while (and (cdr headers)
8792 (not (= number (mail-header-number (cadr headers)))))
8795 (setcdr headers (cddr headers))))))
8798 ;;; summary highlights
8801 (defun gnus-highlight-selected-summary ()
8802 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8803 ;; Highlight selected article in summary buffer
8804 (when gnus-summary-selected-face
8806 (let* ((beg (progn (beginning-of-line) (point)))
8807 (end (progn (end-of-line) (point)))
8808 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
8809 (from (if (get-text-property beg gnus-mouse-face-prop)
8811 (or (next-single-property-change
8812 beg gnus-mouse-face-prop nil end)
8817 (or (next-single-property-change
8818 from gnus-mouse-face-prop nil end)
8820 ;; If no mouse-face prop on line we will have to = from = end,
8821 ;; so we highlight the entire line instead.
8822 (when (= (+ to 2) from)
8825 (if gnus-newsgroup-selected-overlay
8826 ;; Move old overlay.
8828 gnus-newsgroup-selected-overlay from to (current-buffer))
8829 ;; Create new overlay.
8831 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
8832 'face gnus-summary-selected-face))))))
8834 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
8835 (defun gnus-summary-highlight-line ()
8836 "Highlight current line according to `gnus-summary-highlight'."
8837 (let* ((list gnus-summary-highlight)
8839 (end (progn (end-of-line) (point)))
8840 ;; now find out where the line starts and leave point there.
8841 (beg (progn (beginning-of-line) (point)))
8842 (article (gnus-summary-article-number))
8843 (score (or (cdr (assq (or article gnus-current-article)
8844 gnus-newsgroup-scored))
8845 gnus-summary-default-score 0))
8846 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
8847 (inhibit-read-only t))
8848 ;; Eval the cars of the lists until we find a match.
8849 (let ((default gnus-summary-default-score))
8851 (not (eval (caar list))))
8852 (setq list (cdr list))))
8853 (let ((face (cdar list)))
8854 (unless (eq face (get-text-property beg 'face))
8855 (gnus-put-text-property
8857 (setq face (if (boundp face) (symbol-value face) face)))
8858 (when gnus-summary-highlight-line-function
8859 (funcall gnus-summary-highlight-line-function article face))))
8862 (defun gnus-update-read-articles (group unread &optional compute)
8863 "Update the list of read articles in GROUP."
8864 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
8865 (entry (gnus-gethash group gnus-newsrc-hashtb))
8866 (info (nth 2 entry))
8868 (unread (sort (copy-sequence unread) '<))
8870 (if (or (not info) (not active))
8871 ;; There is no info on this group if it was, in fact,
8872 ;; killed. Gnus stores no information on killed groups, so
8873 ;; there's nothing to be done.
8874 ;; One could store the information somewhere temporarily,
8875 ;; perhaps... Hmmm...
8877 ;; Remove any negative articles numbers.
8878 (while (and unread (< (car unread) 0))
8879 (setq unread (cdr unread)))
8880 ;; Remove any expired article numbers
8881 (while (and unread (< (car unread) (car active)))
8882 (setq unread (cdr unread)))
8883 ;; Compute the ranges of read articles by looking at the list of
8886 (when (/= (car unread) prev)
8887 (push (if (= prev (1- (car unread))) prev
8888 (cons prev (1- (car unread))))
8890 (setq prev (1+ (car unread)))
8891 (setq unread (cdr unread)))
8892 (when (<= prev (cdr active))
8893 (push (cons prev (cdr active)) read))
8895 (if (> (length read) 1) (nreverse read) read)
8897 (set-buffer gnus-group-buffer)
8900 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
8901 (gnus-info-set-read ',info ',(gnus-info-read info))
8902 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
8903 (gnus-group-update-group ,group t))))
8904 ;; Enter this list into the group info.
8906 info (if (> (length read) 1) (nreverse read) read))
8907 ;; Set the number of unread articles in gnus-newsrc-hashtb.
8908 (gnus-get-unread-articles-in-group info (gnus-active group))
8911 (defun gnus-offer-save-summaries ()
8912 "Offer to save all active summary buffers."
8914 (let ((buflist (buffer-list))
8916 ;; Go through all buffers and find all summaries.
8918 (and (setq bufname (buffer-name (car buflist)))
8919 (string-match "Summary" bufname)
8921 (set-buffer bufname)
8922 ;; We check that this is, indeed, a summary buffer.
8923 (and (eq major-mode 'gnus-summary-mode)
8924 ;; Also make sure this isn't bogus.
8925 gnus-newsgroup-prepared
8926 ;; Also make sure that this isn't a dead summary buffer.
8927 (not gnus-dead-summary-mode)))
8928 (push bufname buffers))
8929 (setq buflist (cdr buflist)))
8930 ;; Go through all these summary buffers and offer to save them.
8933 "Update summary buffer %s? "
8935 (switch-to-buffer buf)
8936 (gnus-summary-exit))
8940 ;;; @ for mime-partial
8943 (defun gnus-request-partial-message ()
8945 (let ((number (gnus-summary-article-number))
8946 (group gnus-newsgroup-name)
8947 (mother gnus-article-buffer))
8948 (set-buffer (get-buffer-create " *Partial Article*"))
8950 (setq mime-preview-buffer mother)
8951 (gnus-request-article-this-buffer number group)
8955 (autoload 'mime-combine-message/partial-pieces-automatically
8957 "Internal method to combine message/partial messages automatically.")
8960 'action '((type . message)(subtype . partial)
8961 (major-mode . gnus-original-article-mode)
8962 (method . mime-combine-message/partial-pieces-automatically)
8963 (summary-buffer-exp . gnus-summary-buffer)
8964 (request-partial-message-method . gnus-request-partial-message)
8975 (run-hooks 'gnus-sum-load-hook)
8977 ;;; gnus-sum.el ends here