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))
40 ;; Avoid byte-compile warnings.
42 (defvar gnus-article-decoded-p)
43 (defvar gnus-decode-encoded-word-function)
46 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
47 (autoload 'gnus-set-summary-default-charset "gnus-i18n" nil t)
49 (defcustom gnus-kill-summary-on-exit t
50 "*If non-nil, kill the summary buffer when you exit from it.
51 If nil, the summary will become a \"*Dead Summary*\" buffer, and
52 it will be killed sometime later."
53 :group 'gnus-summary-exit
56 (defcustom gnus-fetch-old-headers nil
57 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
58 If an unread article in the group refers to an older, already read (or
59 just marked as read) article, the old article will not normally be
60 displayed in the Summary buffer. If this variable is non-nil, Gnus
61 will attempt to grab the headers to the old articles, and thereby
62 build complete threads. If it has the value `some', only enough
63 headers to connect otherwise loose threads will be displayed. This
64 variable can also be a number. In that case, no more than that number
65 of old headers will be fetched. If it has the value `invisible', all
66 old headers will be fetched, but none will be displayed.
68 The server has to support NOV for any of this to work."
70 :type '(choice (const :tag "off" nil)
73 (sexp :menu-tag "other" t)))
75 (defcustom gnus-refer-thread-limit 200
76 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
77 If t, fetch all the available old headers."
80 (sexp :menu-tag "other" t)))
82 (defcustom gnus-summary-make-false-root 'adopt
83 "*nil means that Gnus won't gather loose threads.
84 If the root of a thread has expired or been read in a previous
85 session, the information necessary to build a complete thread has been
86 lost. Instead of having many small sub-threads from this original thread
87 scattered all over the summary buffer, Gnus can gather them.
89 If non-nil, Gnus will try to gather all loose sub-threads from an
90 original thread into one large thread.
92 If this variable is non-nil, it should be one of `none', `adopt',
95 If this variable is `none', Gnus will not make a false root, but just
96 present the sub-threads after another.
97 If this variable is `dummy', Gnus will create a dummy root that will
98 have all the sub-threads as children.
99 If this variable is `adopt', Gnus will make one of the \"children\"
100 the parent and mark all the step-children as such.
101 If this variable is `empty', the \"children\" are printed with empty
102 subject fields. (Or rather, they will be printed with a string
103 given by the `gnus-summary-same-subject' variable.)"
105 :type '(choice (const :tag "off" nil)
111 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
112 "*A regexp to match subjects to be excluded from loose thread gathering.
113 As loose thread gathering is done on subjects only, that means that
114 there can be many false gatherings performed. By rooting out certain
115 common subjects, gathering might become saner."
119 (defcustom gnus-summary-gather-subject-limit nil
120 "*Maximum length of subject comparisons when gathering loose threads.
121 Use nil to compare full subjects. Setting this variable to a low
122 number will help gather threads that have been corrupted by
123 newsreaders chopping off subject lines, but it might also mean that
124 unrelated articles that have subject that happen to begin with the
125 same few characters will be incorrectly gathered.
127 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
130 :type '(choice (const :tag "off" nil)
132 (sexp :menu-tag "on" t)))
134 (defcustom gnus-simplify-subject-functions nil
135 "List of functions taking a string argument that simplify subjects.
136 The functions are applied recursively.
138 Useful functions to put in this list include: `gnus-simplify-subject-re',
139 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
141 :type '(repeat function))
143 (defcustom gnus-simplify-ignored-prefixes nil
144 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
146 :type '(choice (const :tag "off" nil)
149 (defcustom gnus-build-sparse-threads nil
150 "*If non-nil, fill in the gaps in threads.
151 If `some', only fill in the gaps that are needed to tie loose threads
152 together. If `more', fill in all leaf nodes that Gnus can find. If
153 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
155 :type '(choice (const :tag "off" nil)
158 (sexp :menu-tag "all" t)))
160 (defcustom gnus-summary-thread-gathering-function
161 'gnus-gather-threads-by-subject
162 "*Function used for gathering loose threads.
163 There are two pre-defined functions: `gnus-gather-threads-by-subject',
164 which only takes Subjects into consideration; and
165 `gnus-gather-threads-by-references', which compared the References
166 headers of the articles to find matches."
168 :type '(radio (function-item gnus-gather-threads-by-subject)
169 (function-item gnus-gather-threads-by-references)
170 (function :tag "other")))
172 (defcustom gnus-summary-same-subject ""
173 "*String indicating that the current article has the same subject as the previous.
174 This variable will only be used if the value of
175 `gnus-summary-make-false-root' is `empty'."
176 :group 'gnus-summary-format
179 (defcustom gnus-summary-goto-unread t
180 "*If t, marking commands will go to the next unread article.
181 If `never', commands that usually go to the next unread article, will
182 go to the next article, whether it is read or not.
183 If nil, only the marking commands will go to the next (un)read article."
184 :group 'gnus-summary-marks
185 :link '(custom-manual "(gnus)Setting Marks")
186 :type '(choice (const :tag "off" nil)
188 (sexp :menu-tag "on" t)))
190 (defcustom gnus-summary-default-score 0
191 "*Default article score level.
192 All scores generated by the score files will be added to this score.
193 If this variable is nil, scoring will be disabled."
194 :group 'gnus-score-default
195 :type '(choice (const :tag "disable")
198 (defcustom gnus-summary-zcore-fuzz 0
199 "*Fuzziness factor for the zcore in the summary buffer.
200 Articles with scores closer than this to `gnus-summary-default-score'
202 :group 'gnus-summary-format
205 (defcustom gnus-simplify-subject-fuzzy-regexp nil
206 "*Strings to be removed when doing fuzzy matches.
207 This can either be a regular expression or list of regular expressions
208 that will be removed from subject strings if fuzzy subject
209 simplification is selected."
211 :type '(repeat regexp))
213 (defcustom gnus-show-threads t
214 "*If non-nil, display threads in summary mode."
218 (defcustom gnus-thread-hide-subtree nil
219 "*If non-nil, hide all threads initially.
220 If threads are hidden, you have to run the command
221 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
222 to expose hidden threads."
226 (defcustom gnus-thread-hide-killed t
227 "*If non-nil, hide killed threads automatically."
231 (defcustom gnus-thread-ignore-subject t
232 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
233 If nil, articles that have different subjects from their parents will
234 start separate threads."
238 (defcustom gnus-thread-operation-ignore-subject t
239 "*If non-nil, subjects will be ignored when doing thread commands.
240 This affects commands like `gnus-summary-kill-thread' and
241 `gnus-summary-lower-thread'.
243 If this variable is nil, articles in the same thread with different
244 subjects will not be included in the operation in question. If this
245 variable is `fuzzy', only articles that have subjects that are fuzzily
246 equal will be included."
248 :type '(choice (const :tag "off" nil)
252 (defcustom gnus-thread-indent-level 4
253 "*Number that says how much each sub-thread should be indented."
257 (defcustom gnus-auto-extend-newsgroup t
258 "*If non-nil, extend newsgroup forward and backward when requested."
259 :group 'gnus-summary-choose
262 (defcustom gnus-auto-select-first t
263 "*If nil, don't select the first unread article when entering a group.
264 If this variable is `best', select the highest-scored unread article
265 in the group. If t, select the first unread article.
267 This variable can also be a function to place point on a likely
268 subject line. Useful values include `gnus-summary-first-unread-subject',
269 `gnus-summary-first-unread-article' and
270 `gnus-summary-best-unread-article'.
272 If you want to prevent automatic selection of the first unread article
273 in some newsgroups, set the variable to nil in
274 `gnus-select-group-hook'."
275 :group 'gnus-group-select
276 :type '(choice (const :tag "none" nil)
278 (sexp :menu-tag "first" t)
279 (function-item gnus-summary-first-unread-subject)
280 (function-item gnus-summary-first-unread-article)
281 (function-item gnus-summary-best-unread-article)))
283 (defcustom gnus-auto-select-next t
284 "*If non-nil, offer to go to the next group from the end of the previous.
285 If the value is t and the next newsgroup is empty, Gnus will exit
286 summary mode and go back to group mode. If the value is neither nil
287 nor t, Gnus will select the following unread newsgroup. In
288 particular, if the value is the symbol `quietly', the next unread
289 newsgroup will be selected without any confirmation, and if it is
290 `almost-quietly', the next group will be selected without any
291 confirmation if you are located on the last article in the group.
292 Finally, if this variable is `slightly-quietly', the `Z n' command
293 will go to the next group without confirmation."
294 :group 'gnus-summary-maneuvering
295 :type '(choice (const :tag "off" nil)
297 (const almost-quietly)
298 (const slightly-quietly)
299 (sexp :menu-tag "on" t)))
301 (defcustom gnus-auto-select-same nil
302 "*If non-nil, select the next article with the same subject.
303 If there are no more articles with the same subject, go to
304 the first unread article."
305 :group 'gnus-summary-maneuvering
308 (defcustom gnus-summary-check-current nil
309 "*If non-nil, consider the current article when moving.
310 The \"unread\" movement commands will stay on the same line if the
311 current article is unread."
312 :group 'gnus-summary-maneuvering
315 (defcustom gnus-auto-center-summary t
316 "*If non-nil, always center the current summary buffer.
317 In particular, if `vertical' do only vertical recentering. If non-nil
318 and non-`vertical', do both horizontal and vertical recentering."
319 :group 'gnus-summary-maneuvering
320 :type '(choice (const :tag "none" nil)
322 (integer :tag "height")
323 (sexp :menu-tag "both" t)))
325 (defcustom gnus-show-all-headers nil
326 "*If non-nil, don't hide any headers."
327 :group 'gnus-article-hiding
328 :group 'gnus-article-headers
331 (defcustom gnus-summary-ignore-duplicates nil
332 "*If non-nil, ignore articles with identical Message-ID headers."
336 (defcustom gnus-single-article-buffer t
337 "*If non-nil, display all articles in the same buffer.
338 If nil, each group will get its own article buffer."
339 :group 'gnus-article-various
342 (defcustom gnus-break-pages t
343 "*If non-nil, do page breaking on articles.
344 The page delimiter is specified by the `gnus-page-delimiter'
346 :group 'gnus-article-various
349 (defcustom gnus-show-mime t
350 "*If non-nil, do mime processing of articles.
351 The articles will simply be fed to the function given by
352 `gnus-article-display-method-for-mime'."
353 :group 'gnus-article-mime
356 (defcustom gnus-move-split-methods nil
357 "*Variable used to suggest where articles are to be moved to.
358 It uses the same syntax as the `gnus-split-methods' variable."
359 :group 'gnus-summary-mail
360 :type '(repeat (choice (list :value (fun) function)
361 (cons :value ("" "") regexp (repeat string))
364 (defcustom gnus-unread-mark ?
365 "*Mark used for unread articles."
366 :group 'gnus-summary-marks
369 (defcustom gnus-ticked-mark ?!
370 "*Mark used for ticked articles."
371 :group 'gnus-summary-marks
374 (defcustom gnus-dormant-mark ??
375 "*Mark used for dormant articles."
376 :group 'gnus-summary-marks
379 (defcustom gnus-del-mark ?r
380 "*Mark used for del'd articles."
381 :group 'gnus-summary-marks
384 (defcustom gnus-read-mark ?R
385 "*Mark used for read articles."
386 :group 'gnus-summary-marks
389 (defcustom gnus-expirable-mark ?E
390 "*Mark used for expirable articles."
391 :group 'gnus-summary-marks
394 (defcustom gnus-killed-mark ?K
395 "*Mark used for killed articles."
396 :group 'gnus-summary-marks
399 (defcustom gnus-souped-mark ?F
400 "*Mark used for killed articles."
401 :group 'gnus-summary-marks
404 (defcustom gnus-kill-file-mark ?X
405 "*Mark used for articles killed by kill files."
406 :group 'gnus-summary-marks
409 (defcustom gnus-low-score-mark ?Y
410 "*Mark used for articles with a low score."
411 :group 'gnus-summary-marks
414 (defcustom gnus-catchup-mark ?C
415 "*Mark used for articles that are caught up."
416 :group 'gnus-summary-marks
419 (defcustom gnus-replied-mark ?A
420 "*Mark used for articles that have been replied to."
421 :group 'gnus-summary-marks
424 (defcustom gnus-cached-mark ?*
425 "*Mark used for articles that are in the cache."
426 :group 'gnus-summary-marks
429 (defcustom gnus-saved-mark ?S
430 "*Mark used for articles that have been saved to."
431 :group 'gnus-summary-marks
434 (defcustom gnus-ancient-mark ?O
435 "*Mark used for ancient articles."
436 :group 'gnus-summary-marks
439 (defcustom gnus-sparse-mark ?Q
440 "*Mark used for sparsely reffed articles."
441 :group 'gnus-summary-marks
444 (defcustom gnus-canceled-mark ?G
445 "*Mark used for canceled articles."
446 :group 'gnus-summary-marks
449 (defcustom gnus-duplicate-mark ?M
450 "*Mark used for duplicate articles."
451 :group 'gnus-summary-marks
454 (defcustom gnus-undownloaded-mark ?@
455 "*Mark used for articles that weren't downloaded."
456 :group 'gnus-summary-marks
459 (defcustom gnus-downloadable-mark ?%
460 "*Mark used for articles that are to be downloaded."
461 :group 'gnus-summary-marks
464 (defcustom gnus-unsendable-mark ?=
465 "*Mark used for articles that won't be sent."
466 :group 'gnus-summary-marks
469 (defcustom gnus-score-over-mark ?+
470 "*Score mark used for articles with high scores."
471 :group 'gnus-summary-marks
474 (defcustom gnus-score-below-mark ?-
475 "*Score mark used for articles with low scores."
476 :group 'gnus-summary-marks
479 (defcustom gnus-empty-thread-mark ?
480 "*There is no thread under the article."
481 :group 'gnus-summary-marks
484 (defcustom gnus-not-empty-thread-mark ?=
485 "*There is a thread under the article."
486 :group 'gnus-summary-marks
489 (defcustom gnus-view-pseudo-asynchronously nil
490 "*If non-nil, Gnus will view pseudo-articles asynchronously."
491 :group 'gnus-extract-view
494 (defcustom gnus-view-pseudos nil
495 "*If `automatic', pseudo-articles will be viewed automatically.
496 If `not-confirm', pseudos will be viewed automatically, and the user
497 will not be asked to confirm the command."
498 :group 'gnus-extract-view
499 :type '(choice (const :tag "off" nil)
501 (const not-confirm)))
503 (defcustom gnus-view-pseudos-separately t
504 "*If non-nil, one pseudo-article will be created for each file to be viewed.
505 If nil, all files that use the same viewing command will be given as a
506 list of parameters to that command."
507 :group 'gnus-extract-view
510 (defcustom gnus-insert-pseudo-articles t
511 "*If non-nil, insert pseudo-articles when decoding articles."
512 :group 'gnus-extract-view
515 (defcustom gnus-summary-dummy-line-format
517 "*The format specification for the dummy roots in the summary buffer.
518 It works along the same lines as a normal formatting string,
519 with some simple extensions.
522 :group 'gnus-threading
525 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
526 "*The format specification for the summary mode line.
527 It works along the same lines as a normal formatting string,
528 with some simple extensions:
531 %p Unprefixed group name
532 %A Current article number
533 %z Current article score
535 %U Number of unread articles in the group
536 %e Number of unselected articles in the group
537 %Z A string with unread/unselected article counts
538 %g Shortish group name
539 %S Subject of the current article
541 %s Current score file name
542 %d Number of dormant articles
543 %r Number of articles that have been marked as read in this session
544 %E Number of articles expunged by the score files"
545 :group 'gnus-summary-format
548 (defcustom gnus-summary-mark-below 0
549 "*Mark all articles with a score below this variable as read.
550 This variable is local to each summary buffer and usually set by the
552 :group 'gnus-score-default
555 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
556 "*List of functions used for sorting articles in the summary buffer.
557 This variable is only used when not using a threaded display."
558 :group 'gnus-summary-sort
559 :type '(repeat (choice (function-item gnus-article-sort-by-number)
560 (function-item gnus-article-sort-by-author)
561 (function-item gnus-article-sort-by-subject)
562 (function-item gnus-article-sort-by-date)
563 (function-item gnus-article-sort-by-score)
564 (function :tag "other"))))
566 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
567 "*List of functions used for sorting threads in the summary buffer.
568 By default, threads are sorted by article number.
570 Each function takes two threads and return non-nil if the first thread
571 should be sorted before the other. If you use more than one function,
572 the primary sort function should be the last. You should probably
573 always include `gnus-thread-sort-by-number' in the list of sorting
574 functions -- preferably first.
576 Ready-made functions include `gnus-thread-sort-by-number',
577 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
578 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
579 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
580 :group 'gnus-summary-sort
581 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
582 (function-item gnus-thread-sort-by-author)
583 (function-item gnus-thread-sort-by-subject)
584 (function-item gnus-thread-sort-by-date)
585 (function-item gnus-thread-sort-by-score)
586 (function-item gnus-thread-sort-by-total-score)
587 (function :tag "other"))))
589 (defcustom gnus-thread-score-function '+
590 "*Function used for calculating the total score of a thread.
592 The function is called with the scores of the article and each
593 subthread and should then return the score of the thread.
595 Some functions you can use are `+', `max', or `min'."
596 :group 'gnus-summary-sort
599 (defcustom gnus-summary-expunge-below nil
600 "All articles that have a score less than this variable will be expunged.
601 This variable is local to the summary buffers."
602 :group 'gnus-score-default
603 :type '(choice (const :tag "off" nil)
606 (defcustom gnus-thread-expunge-below nil
607 "All threads that have a total score less than this variable will be expunged.
608 See `gnus-thread-score-function' for en explanation of what a
611 This variable is local to the summary buffers."
612 :group 'gnus-treading
613 :group 'gnus-score-default
614 :type '(choice (const :tag "off" nil)
617 (defcustom gnus-summary-mode-hook nil
618 "*A hook for Gnus summary mode.
619 This hook is run before any variables are set in the summary buffer."
620 :group 'gnus-summary-various
623 (defcustom gnus-summary-menu-hook nil
624 "*Hook run after the creation of the summary mode menu."
625 :group 'gnus-summary-visual
628 (defcustom gnus-summary-exit-hook nil
629 "*A hook called on exit from the summary buffer.
630 It will be called with point in the group buffer."
631 :group 'gnus-summary-exit
634 (defcustom gnus-summary-prepare-hook nil
635 "*A hook called after the summary buffer has been generated.
636 If you want to modify the summary buffer, you can use this hook."
637 :group 'gnus-summary-various
640 (defcustom gnus-summary-prepared-hook nil
641 "*A hook called as the last thing after the summary buffer has been generated."
642 :group 'gnus-summary-various
645 (defcustom gnus-summary-generate-hook nil
646 "*A hook run just before generating the summary buffer.
647 This hook is commonly used to customize threading variables and the
649 :group 'gnus-summary-various
652 (defcustom gnus-select-group-hook nil
653 "*A hook called when a newsgroup is selected.
655 If you'd like to simplify subjects like the
656 `gnus-summary-next-same-subject' command does, you can use the
659 (setq gnus-select-group-hook
662 (mapcar (lambda (header)
663 (mail-header-set-subject
665 (gnus-simplify-subject
666 (mail-header-subject header) 're-only)))
667 gnus-newsgroup-headers))))"
668 :group 'gnus-group-select
671 (defcustom gnus-select-article-hook nil
672 "*A hook called when an article is selected."
673 :group 'gnus-summary-choose
676 (defcustom gnus-visual-mark-article-hook
677 (list 'gnus-highlight-selected-summary)
678 "*Hook run after selecting an article in the summary buffer.
679 It is meant to be used for highlighting the article in some way. It
680 is not run if `gnus-visual' is nil."
681 :group 'gnus-summary-visual
684 (defcustom gnus-parse-headers-hook '(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 (defcustom gnus-extra-headers nil
790 "*Extra headers to parse."
792 :type '(repeat symbol))
794 (defcustom gnus-ignored-from-addresses (regexp-quote user-mail-address)
795 "*Regexp of From headers that may be suppressed in favor of To headers."
799 ;;; Internal variables
801 (defvar gnus-scores-exclude-files nil)
802 (defvar gnus-page-broken nil)
804 (defvar gnus-original-article nil)
805 (defvar gnus-article-internal-prepare-hook nil)
806 (defvar gnus-newsgroup-process-stack nil)
808 (defvar gnus-thread-indent-array nil)
809 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
811 ;; Avoid highlighting in kill files.
812 (defvar gnus-summary-inhibit-highlight nil)
813 (defvar gnus-newsgroup-selected-overlay nil)
814 (defvar gnus-inhibit-limiting nil)
815 (defvar gnus-newsgroup-adaptive-score-file nil)
816 (defvar gnus-current-score-file nil)
817 (defvar gnus-current-move-group nil)
818 (defvar gnus-current-copy-group nil)
819 (defvar gnus-current-crosspost-group nil)
821 (defvar gnus-newsgroup-dependencies nil)
822 (defvar gnus-newsgroup-adaptive nil)
823 (defvar gnus-summary-display-article-function nil)
824 (defvar gnus-summary-highlight-line-function nil
825 "Function called after highlighting a summary line.")
827 (defvar gnus-summary-line-format-alist
828 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
829 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
830 (?s gnus-tmp-subject-or-nil ?s)
831 (?n gnus-tmp-name ?s)
832 (?A (std11-address-string
833 (car (mime-read-field 'From gnus-tmp-header))) ?s)
834 (?a (or (std11-full-name-string
835 (car (mime-read-field 'From gnus-tmp-header)))
837 (?F gnus-tmp-from ?s)
838 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
839 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
840 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
841 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
842 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
843 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
844 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
845 (?L gnus-tmp-lines ?d)
846 (?I gnus-tmp-indentation ?s)
847 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
848 (?R gnus-tmp-replied ?c)
849 (?\[ gnus-tmp-opening-bracket ?c)
850 (?\] gnus-tmp-closing-bracket ?c)
851 (?\> (make-string gnus-tmp-level ? ) ?s)
852 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
853 (?i gnus-tmp-score ?d)
854 (?z gnus-tmp-score-char ?c)
855 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
856 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
857 (?U gnus-tmp-unread ?c)
858 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header) ?s)
859 (?t (gnus-summary-number-of-articles-in-thread
860 (and (boundp 'thread) (car thread)) gnus-tmp-level)
862 (?e (gnus-summary-number-of-articles-in-thread
863 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
865 (?u gnus-tmp-user-defined ?s)
866 (?P (gnus-pick-line-number) ?d))
867 "An alist of format specifications that can appear in summary lines,
868 and what variables they correspond with, along with the type of the
869 variable (string, integer, character, etc).")
871 (defvar gnus-summary-dummy-line-format-alist
872 `((?S gnus-tmp-subject ?s)
873 (?N gnus-tmp-number ?d)
874 (?u gnus-tmp-user-defined ?s)))
876 (defvar gnus-summary-mode-line-format-alist
877 `((?G gnus-tmp-group-name ?s)
878 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
879 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
880 (?A gnus-tmp-article-number ?d)
881 (?Z gnus-tmp-unread-and-unselected ?s)
883 (?U gnus-tmp-unread-and-unticked ?d)
884 (?S gnus-tmp-subject ?s)
885 (?e gnus-tmp-unselected ?d)
886 (?u gnus-tmp-user-defined ?s)
887 (?d (length gnus-newsgroup-dormant) ?d)
888 (?t (length gnus-newsgroup-marked) ?d)
889 (?r (length gnus-newsgroup-reads) ?d)
890 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
891 (?E gnus-newsgroup-expunged-tally ?d)
892 (?s (gnus-current-score-file-nondirectory) ?s)))
894 (defvar gnus-last-search-regexp nil
895 "Default regexp for article search command.")
897 (defvar gnus-last-shell-command nil
898 "Default shell command on article.")
900 (defvar gnus-newsgroup-begin nil)
901 (defvar gnus-newsgroup-end nil)
902 (defvar gnus-newsgroup-last-rmail nil)
903 (defvar gnus-newsgroup-last-mail nil)
904 (defvar gnus-newsgroup-last-folder nil)
905 (defvar gnus-newsgroup-last-file nil)
906 (defvar gnus-newsgroup-auto-expire nil)
907 (defvar gnus-newsgroup-active nil)
909 (defvar gnus-newsgroup-data nil)
910 (defvar gnus-newsgroup-data-reverse nil)
911 (defvar gnus-newsgroup-limit nil)
912 (defvar gnus-newsgroup-limits nil)
914 (defvar gnus-newsgroup-unreads nil
915 "List of unread articles in the current newsgroup.")
917 (defvar gnus-newsgroup-unselected nil
918 "List of unselected unread articles in the current newsgroup.")
920 (defvar gnus-newsgroup-reads nil
921 "Alist of read articles and article marks in the current newsgroup.")
923 (defvar gnus-newsgroup-expunged-tally nil)
925 (defvar gnus-newsgroup-marked nil
926 "List of ticked articles in the current newsgroup (a subset of unread art).")
928 (defvar gnus-newsgroup-killed nil
929 "List of ranges of articles that have been through the scoring process.")
931 (defvar gnus-newsgroup-cached nil
932 "List of articles that come from the article cache.")
934 (defvar gnus-newsgroup-saved nil
935 "List of articles that have been saved.")
937 (defvar gnus-newsgroup-kill-headers nil)
939 (defvar gnus-newsgroup-replied nil
940 "List of articles that have been replied to in the current newsgroup.")
942 (defvar gnus-newsgroup-expirable nil
943 "List of articles in the current newsgroup that can be expired.")
945 (defvar gnus-newsgroup-processable nil
946 "List of articles in the current newsgroup that can be processed.")
948 (defvar gnus-newsgroup-downloadable nil
949 "List of articles in the current newsgroup that can be processed.")
951 (defvar gnus-newsgroup-undownloaded nil
952 "List of articles in the current newsgroup that haven't been downloaded..")
954 (defvar gnus-newsgroup-unsendable nil
955 "List of articles in the current newsgroup that won't be sent.")
957 (defvar gnus-newsgroup-bookmarks nil
958 "List of articles in the current newsgroup that have bookmarks.")
960 (defvar gnus-newsgroup-dormant nil
961 "List of dormant articles in the current newsgroup.")
963 (defvar gnus-newsgroup-scored nil
964 "List of scored articles in the current newsgroup.")
966 (defvar gnus-newsgroup-headers nil
967 "List of article headers in the current newsgroup.")
969 (defvar gnus-newsgroup-threads nil)
971 (defvar gnus-newsgroup-prepared nil
972 "Whether the current group has been prepared properly.")
974 (defvar gnus-newsgroup-ancient nil
975 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
977 (defvar gnus-newsgroup-sparse nil)
979 (defvar gnus-current-article nil)
980 (defvar gnus-article-current nil)
981 (defvar gnus-current-headers nil)
982 (defvar gnus-have-all-headers nil)
983 (defvar gnus-last-article nil)
984 (defvar gnus-newsgroup-history nil)
986 (defconst gnus-summary-local-variables
987 '(gnus-newsgroup-name
988 gnus-newsgroup-begin gnus-newsgroup-end
989 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
990 gnus-newsgroup-last-folder gnus-newsgroup-last-file
991 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
992 gnus-newsgroup-unselected gnus-newsgroup-marked
993 gnus-newsgroup-reads gnus-newsgroup-saved
994 gnus-newsgroup-replied gnus-newsgroup-expirable
995 gnus-newsgroup-processable gnus-newsgroup-killed
996 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
997 gnus-newsgroup-unsendable
998 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
999 gnus-newsgroup-headers gnus-newsgroup-threads
1000 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1001 gnus-current-article gnus-current-headers gnus-have-all-headers
1002 gnus-last-article gnus-article-internal-prepare-hook
1003 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1004 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1005 gnus-thread-expunge-below
1006 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1007 (gnus-summary-mark-below . global)
1008 gnus-newsgroup-active gnus-scores-exclude-files
1009 gnus-newsgroup-history gnus-newsgroup-ancient
1010 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1011 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1012 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1013 (gnus-newsgroup-expunged-tally . 0)
1014 gnus-cache-removable-articles gnus-newsgroup-cached
1015 gnus-newsgroup-data gnus-newsgroup-data-reverse
1016 gnus-newsgroup-limit gnus-newsgroup-limits)
1017 "Variables that are buffer-local to the summary buffers.")
1019 ;; Byte-compiler warning.
1020 (defvar gnus-article-mode-map)
1022 ;; Subject simplification.
1024 (defun gnus-simplify-whitespace (str)
1025 "Remove excessive whitespace."
1028 (while (string-match "[ \t][ \t]+" mystr)
1029 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1031 (substring mystr (match-end 0)))))
1033 (when (string-match "^[ \t]+" mystr)
1034 (setq mystr (substring mystr (match-end 0))))
1036 (when (string-match "[ \t]+$" mystr)
1037 (setq mystr (substring mystr 0 (match-beginning 0))))
1040 (defsubst gnus-simplify-subject-re (subject)
1041 "Remove \"Re:\" from subject lines."
1042 (if (string-match "^[Rr][Ee]: *" subject)
1043 (substring subject (match-end 0))
1046 (defun gnus-simplify-subject (subject &optional re-only)
1047 "Remove `Re:' and words in parentheses.
1048 If RE-ONLY is non-nil, strip leading `Re:'s only."
1049 (let ((case-fold-search t)) ;Ignore case.
1050 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1051 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1052 (setq subject (substring subject (match-end 0))))
1053 ;; Remove uninteresting prefixes.
1054 (when (and (not re-only)
1055 gnus-simplify-ignored-prefixes
1056 (string-match gnus-simplify-ignored-prefixes subject))
1057 (setq subject (substring subject (match-end 0))))
1058 ;; Remove words in parentheses from end.
1060 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1061 (setq subject (substring subject 0 (match-beginning 0)))))
1062 ;; Return subject string.
1065 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1067 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1068 (goto-char (point-min))
1069 (while (re-search-forward regexp nil t)
1070 (replace-match (or newtext ""))))
1072 (defun gnus-simplify-buffer-fuzzy ()
1073 "Simplify string in the buffer fuzzily.
1074 The string in the accessible portion of the current buffer is simplified.
1075 It is assumed to be a single-line subject.
1076 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1077 matter is removed. Additional things can be deleted by setting
1078 gnus-simplify-subject-fuzzy-regexp."
1079 (let ((case-fold-search t)
1081 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1083 (while (not (eq modified-tick (buffer-modified-tick)))
1084 (setq modified-tick (buffer-modified-tick))
1086 ((listp gnus-simplify-subject-fuzzy-regexp)
1087 (mapcar 'gnus-simplify-buffer-fuzzy-step
1088 gnus-simplify-subject-fuzzy-regexp))
1089 (gnus-simplify-subject-fuzzy-regexp
1090 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1091 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1092 (gnus-simplify-buffer-fuzzy-step
1093 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1094 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1096 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1097 (gnus-simplify-buffer-fuzzy-step " +" " ")
1098 (gnus-simplify-buffer-fuzzy-step " $")
1099 (gnus-simplify-buffer-fuzzy-step "^ +")))
1101 (defun gnus-simplify-subject-fuzzy (subject)
1102 "Simplify a subject string fuzzily.
1103 See `gnus-simplify-buffer-fuzzy' for details."
1105 (gnus-set-work-buffer)
1106 (let ((case-fold-search t))
1107 ;; Remove uninteresting prefixes.
1108 (when (and gnus-simplify-ignored-prefixes
1109 (string-match gnus-simplify-ignored-prefixes subject))
1110 (setq subject (substring subject (match-end 0))))
1112 (inline (gnus-simplify-buffer-fuzzy))
1115 (defsubst gnus-simplify-subject-fully (subject)
1116 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1118 (gnus-simplify-subject-functions
1119 (gnus-map-function gnus-simplify-subject-functions subject))
1120 ((null gnus-summary-gather-subject-limit)
1121 (gnus-simplify-subject-re subject))
1122 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1123 (gnus-simplify-subject-fuzzy subject))
1124 ((numberp gnus-summary-gather-subject-limit)
1125 (gnus-limit-string (gnus-simplify-subject-re subject)
1126 gnus-summary-gather-subject-limit))
1130 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1131 "Check whether two subjects are equal.
1132 If optional argument simple-first is t, first argument is already
1135 ((null simple-first)
1136 (equal (gnus-simplify-subject-fully s1)
1137 (gnus-simplify-subject-fully s2)))
1140 (gnus-simplify-subject-fully s2)))))
1142 (defun gnus-summary-bubble-group ()
1143 "Increase the score of the current group.
1144 This is a handy function to add to `gnus-summary-exit-hook' to
1145 increase the score of each group you read."
1146 (gnus-group-add-score gnus-newsgroup-name))
1150 ;;; Gnus summary mode
1153 (put 'gnus-summary-mode 'mode-class 'special)
1156 ;; Non-orthogonal keys
1158 (gnus-define-keys gnus-summary-mode-map
1159 " " gnus-summary-next-page
1160 "\177" gnus-summary-prev-page
1161 [delete] gnus-summary-prev-page
1162 [backspace] gnus-summary-prev-page
1163 "\r" gnus-summary-scroll-up
1164 "\M-\r" gnus-summary-scroll-down
1165 "n" gnus-summary-next-unread-article
1166 "p" gnus-summary-prev-unread-article
1167 "N" gnus-summary-next-article
1168 "P" gnus-summary-prev-article
1169 "\M-\C-n" gnus-summary-next-same-subject
1170 "\M-\C-p" gnus-summary-prev-same-subject
1171 "\M-n" gnus-summary-next-unread-subject
1172 "\M-p" gnus-summary-prev-unread-subject
1173 "." gnus-summary-first-unread-article
1174 "," gnus-summary-best-unread-article
1175 "\M-s" gnus-summary-search-article-forward
1176 "\M-r" gnus-summary-search-article-backward
1177 "<" gnus-summary-beginning-of-article
1178 ">" gnus-summary-end-of-article
1179 "j" gnus-summary-goto-article
1180 "^" gnus-summary-refer-parent-article
1181 "\M-^" gnus-summary-refer-article
1182 "u" gnus-summary-tick-article-forward
1183 "!" gnus-summary-tick-article-forward
1184 "U" gnus-summary-tick-article-backward
1185 "d" gnus-summary-mark-as-read-forward
1186 "D" gnus-summary-mark-as-read-backward
1187 "E" gnus-summary-mark-as-expirable
1188 "\M-u" gnus-summary-clear-mark-forward
1189 "\M-U" gnus-summary-clear-mark-backward
1190 "k" gnus-summary-kill-same-subject-and-select
1191 "\C-k" gnus-summary-kill-same-subject
1192 "\M-\C-k" gnus-summary-kill-thread
1193 "\M-\C-l" gnus-summary-lower-thread
1194 "e" gnus-summary-edit-article
1195 "#" gnus-summary-mark-as-processable
1196 "\M-#" gnus-summary-unmark-as-processable
1197 "\M-\C-t" gnus-summary-toggle-threads
1198 "\M-\C-s" gnus-summary-show-thread
1199 "\M-\C-h" gnus-summary-hide-thread
1200 "\M-\C-f" gnus-summary-next-thread
1201 "\M-\C-b" gnus-summary-prev-thread
1202 "\M-\C-u" gnus-summary-up-thread
1203 "\M-\C-d" gnus-summary-down-thread
1204 "&" gnus-summary-execute-command
1205 "c" gnus-summary-catchup-and-exit
1206 "\C-w" gnus-summary-mark-region-as-read
1207 "\C-t" gnus-summary-toggle-truncation
1208 "?" gnus-summary-mark-as-dormant
1209 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1210 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1211 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1212 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1213 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1214 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1215 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1216 "=" gnus-summary-expand-window
1217 "\C-x\C-s" gnus-summary-reselect-current-group
1218 "\M-g" gnus-summary-rescan-group
1219 "w" gnus-summary-stop-page-breaking
1220 "\C-c\C-r" gnus-summary-caesar-message
1221 "\M-t" gnus-summary-toggle-mime
1222 "f" gnus-summary-followup
1223 "F" gnus-summary-followup-with-original
1224 "C" gnus-summary-cancel-article
1225 "r" gnus-summary-reply
1226 "R" gnus-summary-reply-with-original
1227 "\C-c\C-f" gnus-summary-mail-forward
1228 "o" gnus-summary-save-article
1229 "\C-o" gnus-summary-save-article-mail
1230 "|" gnus-summary-pipe-output
1231 "\M-k" gnus-summary-edit-local-kill
1232 "\M-K" gnus-summary-edit-global-kill
1234 "\C-c\C-d" gnus-summary-describe-group
1235 "q" gnus-summary-exit
1236 "Q" gnus-summary-exit-no-update
1237 "\C-c\C-i" gnus-info-find-node
1238 gnus-mouse-2 gnus-mouse-pick-article
1239 "m" gnus-summary-mail-other-window
1240 "a" gnus-summary-post-news
1241 "x" gnus-summary-limit-to-unread
1242 "s" gnus-summary-isearch-article
1243 "t" gnus-article-hide-headers
1244 "g" gnus-summary-show-article
1245 "l" gnus-summary-goto-last-article
1246 "v" gnus-summary-preview-mime-message
1247 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1248 "\C-d" gnus-summary-enter-digest-group
1249 "\M-\C-d" gnus-summary-read-document
1250 "\M-\C-e" gnus-summary-edit-parameters
1252 "*" gnus-cache-enter-article
1253 "\M-*" gnus-cache-remove-article
1254 "\M-&" gnus-summary-universal-argument
1255 "\C-l" gnus-recenter
1256 "I" gnus-summary-increase-score
1257 "L" gnus-summary-lower-score
1258 "\M-i" gnus-symbolic-argument
1259 "h" gnus-summary-select-article-buffer
1261 "V" gnus-summary-score-map
1262 "X" gnus-uu-extract-map
1263 "S" gnus-summary-send-map)
1265 ;; Sort of orthogonal keymap
1266 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1267 "t" gnus-summary-tick-article-forward
1268 "!" gnus-summary-tick-article-forward
1269 "d" gnus-summary-mark-as-read-forward
1270 "r" gnus-summary-mark-as-read-forward
1271 "c" gnus-summary-clear-mark-forward
1272 " " gnus-summary-clear-mark-forward
1273 "e" gnus-summary-mark-as-expirable
1274 "x" gnus-summary-mark-as-expirable
1275 "?" gnus-summary-mark-as-dormant
1276 "b" gnus-summary-set-bookmark
1277 "B" gnus-summary-remove-bookmark
1278 "#" gnus-summary-mark-as-processable
1279 "\M-#" gnus-summary-unmark-as-processable
1280 "S" gnus-summary-limit-include-expunged
1281 "C" gnus-summary-catchup
1282 "H" gnus-summary-catchup-to-here
1283 "\C-c" gnus-summary-catchup-all
1284 "k" gnus-summary-kill-same-subject-and-select
1285 "K" gnus-summary-kill-same-subject
1286 "P" gnus-uu-mark-map)
1288 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1289 "c" gnus-summary-clear-above
1290 "u" gnus-summary-tick-above
1291 "m" gnus-summary-mark-above
1292 "k" gnus-summary-kill-below)
1294 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1295 "/" gnus-summary-limit-to-subject
1296 "n" gnus-summary-limit-to-articles
1297 "w" gnus-summary-pop-limit
1298 "s" gnus-summary-limit-to-subject
1299 "a" gnus-summary-limit-to-author
1300 "u" gnus-summary-limit-to-unread
1301 "m" gnus-summary-limit-to-marks
1302 "v" gnus-summary-limit-to-score
1303 "*" gnus-summary-limit-include-cached
1304 "D" gnus-summary-limit-include-dormant
1305 "T" gnus-summary-limit-include-thread
1306 "d" gnus-summary-limit-exclude-dormant
1307 "t" gnus-summary-limit-to-age
1308 "E" gnus-summary-limit-include-expunged
1309 "c" gnus-summary-limit-exclude-childless-dormant
1310 "C" gnus-summary-limit-mark-excluded-as-read)
1312 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1313 "n" gnus-summary-next-unread-article
1314 "p" gnus-summary-prev-unread-article
1315 "N" gnus-summary-next-article
1316 "P" gnus-summary-prev-article
1317 "\C-n" gnus-summary-next-same-subject
1318 "\C-p" gnus-summary-prev-same-subject
1319 "\M-n" gnus-summary-next-unread-subject
1320 "\M-p" gnus-summary-prev-unread-subject
1321 "f" gnus-summary-first-unread-article
1322 "b" gnus-summary-best-unread-article
1323 "j" gnus-summary-goto-article
1324 "g" gnus-summary-goto-subject
1325 "l" gnus-summary-goto-last-article
1326 "o" gnus-summary-pop-article)
1328 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1329 "k" gnus-summary-kill-thread
1330 "l" gnus-summary-lower-thread
1331 "i" gnus-summary-raise-thread
1332 "T" gnus-summary-toggle-threads
1333 "t" gnus-summary-rethread-current
1334 "^" gnus-summary-reparent-thread
1335 "s" gnus-summary-show-thread
1336 "S" gnus-summary-show-all-threads
1337 "h" gnus-summary-hide-thread
1338 "H" gnus-summary-hide-all-threads
1339 "n" gnus-summary-next-thread
1340 "p" gnus-summary-prev-thread
1341 "u" gnus-summary-up-thread
1342 "o" gnus-summary-top-thread
1343 "d" gnus-summary-down-thread
1344 "#" gnus-uu-mark-thread
1345 "\M-#" gnus-uu-unmark-thread)
1347 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1348 "g" gnus-summary-prepare
1349 "c" gnus-summary-insert-cached-articles)
1351 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1352 "c" gnus-summary-catchup-and-exit
1353 "C" gnus-summary-catchup-all-and-exit
1354 "E" gnus-summary-exit-no-update
1355 "Q" gnus-summary-exit
1356 "Z" gnus-summary-exit
1357 "n" gnus-summary-catchup-and-goto-next-group
1358 "R" gnus-summary-reselect-current-group
1359 "G" gnus-summary-rescan-group
1360 "N" gnus-summary-next-group
1361 "s" gnus-summary-save-newsrc
1362 "P" gnus-summary-prev-group)
1364 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1365 " " gnus-summary-next-page
1366 "n" gnus-summary-next-page
1367 "\177" gnus-summary-prev-page
1368 [delete] gnus-summary-prev-page
1369 "p" gnus-summary-prev-page
1370 "\r" gnus-summary-scroll-up
1371 "\M-\r" gnus-summary-scroll-down
1372 "<" gnus-summary-beginning-of-article
1373 ">" gnus-summary-end-of-article
1374 "b" gnus-summary-beginning-of-article
1375 "e" gnus-summary-end-of-article
1376 "^" gnus-summary-refer-parent-article
1377 "r" gnus-summary-refer-parent-article
1378 "R" gnus-summary-refer-references
1379 "T" gnus-summary-refer-thread
1380 "g" gnus-summary-show-article
1381 "s" gnus-summary-isearch-article
1382 "P" gnus-summary-print-article)
1384 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1385 "b" gnus-article-add-buttons
1386 "B" gnus-article-add-buttons-to-head
1387 "o" gnus-article-treat-overstrike
1388 "e" gnus-article-emphasize
1389 "w" gnus-article-fill-cited-article
1390 "c" gnus-article-remove-cr
1391 "f" gnus-article-display-x-face
1392 "l" gnus-summary-stop-page-breaking
1393 "r" gnus-summary-caesar-message
1394 "t" gnus-article-hide-headers
1395 "v" gnus-summary-verbose-headers
1396 "m" gnus-summary-toggle-mime
1397 "h" gnus-article-treat-html
1398 "d" gnus-article-treat-dumbquotes)
1400 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1401 "a" gnus-article-hide
1402 "h" gnus-article-hide-headers
1403 "b" gnus-article-hide-boring-headers
1404 "s" gnus-article-hide-signature
1405 "c" gnus-article-hide-citation
1406 "C" gnus-article-hide-citation-in-followups
1407 "p" gnus-article-hide-pgp
1408 "P" gnus-article-hide-pem
1409 "\C-c" gnus-article-hide-citation-maybe)
1411 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1412 "a" gnus-article-highlight
1413 "h" gnus-article-highlight-headers
1414 "c" gnus-article-highlight-citation
1415 "s" gnus-article-highlight-signature)
1417 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1418 "z" gnus-article-date-ut
1419 "u" gnus-article-date-ut
1420 "l" gnus-article-date-local
1421 "e" gnus-article-date-lapsed
1422 "o" gnus-article-date-original
1423 "i" gnus-article-date-iso8601
1424 "s" gnus-article-date-user)
1426 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1427 "t" gnus-article-remove-trailing-blank-lines
1428 "l" gnus-article-strip-leading-blank-lines
1429 "m" gnus-article-strip-multiple-blank-lines
1430 "a" gnus-article-strip-blank-lines
1431 "A" gnus-article-strip-all-blank-lines
1432 "s" gnus-article-strip-leading-space)
1434 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1436 "f" gnus-summary-fetch-faq
1437 "d" gnus-summary-describe-group
1438 "h" gnus-summary-describe-briefly
1439 "i" gnus-info-find-node)
1441 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1442 "e" gnus-summary-expire-articles
1443 "\M-\C-e" gnus-summary-expire-articles-now
1444 "\177" gnus-summary-delete-article
1445 [delete] gnus-summary-delete-article
1446 "m" gnus-summary-move-article
1447 "r" gnus-summary-respool-article
1448 "w" gnus-summary-edit-article
1449 "c" gnus-summary-copy-article
1450 "B" gnus-summary-crosspost-article
1451 "q" gnus-summary-respool-query
1452 "t" gnus-summary-respool-trace
1453 "i" gnus-summary-import-article
1454 "p" gnus-summary-article-posted-p)
1456 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1457 "o" gnus-summary-save-article
1458 "m" gnus-summary-save-article-mail
1459 "F" gnus-summary-write-article-file
1460 "r" gnus-summary-save-article-rmail
1461 "f" gnus-summary-save-article-file
1462 "b" gnus-summary-save-article-body-file
1463 "h" gnus-summary-save-article-folder
1464 "v" gnus-summary-save-article-vm
1465 "p" gnus-summary-pipe-output
1466 "s" gnus-soup-add-article))
1468 (defun gnus-summary-make-menu-bar ()
1469 (gnus-turn-off-edit-menu 'summary)
1471 (unless (boundp 'gnus-summary-misc-menu)
1474 gnus-summary-kill-menu gnus-summary-mode-map ""
1479 ["Enter score..." gnus-summary-score-entry t]
1480 ["Customize" gnus-score-customize t])
1481 (gnus-make-score-map 'increase)
1482 (gnus-make-score-map 'lower)
1484 ["Kill below" gnus-summary-kill-below t]
1485 ["Mark above" gnus-summary-mark-above t]
1486 ["Tick above" gnus-summary-tick-above t]
1487 ["Clear above" gnus-summary-clear-above t])
1488 ["Current score" gnus-summary-current-score t]
1489 ["Set score" gnus-summary-set-score t]
1490 ["Switch current score file..." gnus-score-change-score-file t]
1491 ["Set mark below..." gnus-score-set-mark-below t]
1492 ["Set expunge below..." gnus-score-set-expunge-below t]
1493 ["Edit current score file" gnus-score-edit-current-scores t]
1494 ["Edit score file" gnus-score-edit-file t]
1495 ["Trace score" gnus-score-find-trace t]
1496 ["Find words" gnus-score-find-favourite-words t]
1497 ["Rescore buffer" gnus-summary-rescore t]
1498 ["Increase score..." gnus-summary-increase-score t]
1499 ["Lower score..." gnus-summary-lower-score t]))))
1501 ;; Define both the Article menu in the summary buffer and the equivalent
1502 ;; Commands menu in the article buffer here for consistency.
1505 ["All" gnus-article-hide t]
1506 ["Headers" gnus-article-hide-headers t]
1507 ["Signature" gnus-article-hide-signature t]
1508 ["Citation" gnus-article-hide-citation t]
1509 ["PGP" gnus-article-hide-pgp t]
1510 ["Boring headers" gnus-article-hide-boring-headers t])
1512 ["All" gnus-article-highlight t]
1513 ["Headers" gnus-article-highlight-headers t]
1514 ["Signature" gnus-article-highlight-signature t]
1515 ["Citation" gnus-article-highlight-citation t])
1517 ["Local" gnus-article-date-local t]
1518 ["ISO8601" gnus-article-date-iso8601 t]
1519 ["UT" gnus-article-date-ut t]
1520 ["Original" gnus-article-date-original t]
1521 ["Lapsed" gnus-article-date-lapsed t]
1522 ["User-defined" gnus-article-date-user t])
1525 ["Leading" gnus-article-strip-leading-blank-lines t]
1526 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1527 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1528 ["All of the above" gnus-article-strip-blank-lines t]
1529 ["All" gnus-article-strip-all-blank-lines t]
1530 ["Leading space" gnus-article-strip-leading-space t])
1531 ["Overstrike" gnus-article-treat-overstrike t]
1532 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1533 ["Emphasis" gnus-article-emphasize t]
1534 ["Word wrap" gnus-article-fill-cited-article t]
1535 ["CR" gnus-article-remove-cr t]
1536 ["Show X-Face" gnus-article-display-x-face t]
1537 ["UnHTMLize" gnus-article-treat-html t]
1538 ["Rot 13" gnus-summary-caesar-message t]
1539 ["Unix pipe" gnus-summary-pipe-message t]
1540 ["Add buttons" gnus-article-add-buttons t]
1541 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1542 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1543 ["Toggle MIME" gnus-summary-toggle-mime t]
1544 ["Verbose header" gnus-summary-verbose-headers t]
1545 ["Toggle header" gnus-summary-toggle-header t])
1547 ["Save in default format" gnus-summary-save-article t]
1548 ["Save in file" gnus-summary-save-article-file t]
1549 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1550 ["Save in MH folder" gnus-summary-save-article-folder t]
1551 ["Save in VM folder" gnus-summary-save-article-vm t]
1552 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1553 ["Save body in file" gnus-summary-save-article-body-file t]
1554 ["Pipe through a filter" gnus-summary-pipe-output t]
1555 ["Add to SOUP packet" gnus-soup-add-article t]
1556 ["Print" gnus-summary-print-article t])
1558 ["Respool article..." gnus-summary-respool-article t]
1559 ["Move article..." gnus-summary-move-article
1560 (gnus-check-backend-function
1561 'request-move-article gnus-newsgroup-name)]
1562 ["Copy article..." gnus-summary-copy-article t]
1563 ["Crosspost article..." gnus-summary-crosspost-article
1564 (gnus-check-backend-function
1565 'request-replace-article gnus-newsgroup-name)]
1566 ["Import file..." gnus-summary-import-article t]
1567 ["Check if posted" gnus-summary-article-posted-p t]
1568 ["Edit article" gnus-summary-edit-article
1569 (not (gnus-group-read-only-p))]
1570 ["Delete article" gnus-summary-delete-article
1571 (gnus-check-backend-function
1572 'request-expire-articles gnus-newsgroup-name)]
1573 ["Query respool" gnus-summary-respool-query t]
1574 ["Trace respool" gnus-summary-respool-trace t]
1575 ["Delete expirable articles" gnus-summary-expire-articles-now
1576 (gnus-check-backend-function
1577 'request-expire-articles gnus-newsgroup-name)])
1579 ["Uudecode" gnus-uu-decode-uu t]
1580 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1581 ["Unshar" gnus-uu-decode-unshar t]
1582 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1583 ["Save" gnus-uu-decode-save t]
1584 ["Binhex" gnus-uu-decode-binhex t]
1585 ["Postscript" gnus-uu-decode-postscript t])
1587 ["Enter article" gnus-cache-enter-article t]
1588 ["Remove article" gnus-cache-remove-article t])
1589 ["Select article buffer" gnus-summary-select-article-buffer t]
1590 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1591 ["Isearch article..." gnus-summary-isearch-article t]
1592 ["Beginning of the article" gnus-summary-beginning-of-article t]
1593 ["End of the article" gnus-summary-end-of-article t]
1594 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1595 ["Fetch referenced articles" gnus-summary-refer-references t]
1596 ["Fetch current thread" gnus-summary-refer-thread t]
1597 ["Fetch article with id..." gnus-summary-refer-article t]
1598 ["Redisplay" gnus-summary-show-article t])))
1600 gnus-summary-article-menu gnus-summary-mode-map ""
1601 (cons "Article" innards))
1604 gnus-article-commands-menu gnus-article-mode-map ""
1605 (cons "Commands" innards)))
1608 gnus-summary-thread-menu gnus-summary-mode-map ""
1610 ["Toggle threading" gnus-summary-toggle-threads t]
1611 ["Hide threads" gnus-summary-hide-all-threads t]
1612 ["Show threads" gnus-summary-show-all-threads t]
1613 ["Hide thread" gnus-summary-hide-thread t]
1614 ["Show thread" gnus-summary-show-thread t]
1615 ["Go to next thread" gnus-summary-next-thread t]
1616 ["Go to previous thread" gnus-summary-prev-thread t]
1617 ["Go down thread" gnus-summary-down-thread t]
1618 ["Go up thread" gnus-summary-up-thread t]
1619 ["Top of thread" gnus-summary-top-thread t]
1620 ["Mark thread as read" gnus-summary-kill-thread t]
1621 ["Lower thread score" gnus-summary-lower-thread t]
1622 ["Raise thread score" gnus-summary-raise-thread t]
1623 ["Rethread current" gnus-summary-rethread-current t]
1627 gnus-summary-post-menu gnus-summary-mode-map ""
1629 ["Post an article" gnus-summary-post-news t]
1630 ["Followup" gnus-summary-followup t]
1631 ["Followup and yank" gnus-summary-followup-with-original t]
1632 ["Supersede article" gnus-summary-supersede-article t]
1633 ["Cancel article" gnus-summary-cancel-article t]
1634 ["Reply" gnus-summary-reply t]
1635 ["Reply and yank" gnus-summary-reply-with-original t]
1636 ["Wide reply" gnus-summary-wide-reply t]
1637 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1638 ["Mail forward" gnus-summary-mail-forward t]
1639 ["Post forward" gnus-summary-post-forward t]
1640 ["Digest and mail" gnus-summary-mail-digest t]
1641 ["Digest and post" gnus-summary-post-digest t]
1642 ["Resend message" gnus-summary-resend-message t]
1643 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1644 ["Send a mail" gnus-summary-mail-other-window t]
1645 ["Uuencode and post" gnus-uu-post-news t]
1646 ["Followup via news" gnus-summary-followup-to-mail t]
1647 ["Followup via news and yank"
1648 gnus-summary-followup-to-mail-with-original t]
1650 ;;["Send" gnus-summary-send-draft t]
1651 ;;["Send bounced" gnus-resend-bounced-mail t])
1655 gnus-summary-misc-menu gnus-summary-mode-map ""
1658 ["Mark as read" gnus-summary-mark-as-read-forward t]
1659 ["Mark same subject and select"
1660 gnus-summary-kill-same-subject-and-select t]
1661 ["Mark same subject" gnus-summary-kill-same-subject t]
1662 ["Catchup" gnus-summary-catchup t]
1663 ["Catchup all" gnus-summary-catchup-all t]
1664 ["Catchup to here" gnus-summary-catchup-to-here t]
1665 ["Catchup region" gnus-summary-mark-region-as-read t]
1666 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1668 ["Tick" gnus-summary-tick-article-forward t]
1669 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1670 ["Remove marks" gnus-summary-clear-mark-forward t]
1671 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1672 ["Set bookmark" gnus-summary-set-bookmark t]
1673 ["Remove bookmark" gnus-summary-remove-bookmark t])
1675 ["Marks..." gnus-summary-limit-to-marks t]
1676 ["Subject..." gnus-summary-limit-to-subject t]
1677 ["Author..." gnus-summary-limit-to-author t]
1678 ["Age..." gnus-summary-limit-to-age t]
1679 ["Score" gnus-summary-limit-to-score t]
1680 ["Unread" gnus-summary-limit-to-unread t]
1681 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1682 ["Articles" gnus-summary-limit-to-articles t]
1683 ["Pop limit" gnus-summary-pop-limit t]
1684 ["Show dormant" gnus-summary-limit-include-dormant t]
1685 ["Hide childless dormant"
1686 gnus-summary-limit-exclude-childless-dormant t]
1687 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1688 ["Show expunged" gnus-summary-show-all-expunged t])
1690 ["Set mark" gnus-summary-mark-as-processable t]
1691 ["Remove mark" gnus-summary-unmark-as-processable t]
1692 ["Remove all marks" gnus-summary-unmark-all-processable t]
1693 ["Mark above" gnus-uu-mark-over t]
1694 ["Mark series" gnus-uu-mark-series t]
1695 ["Mark region" gnus-uu-mark-region t]
1696 ["Unmark region" gnus-uu-unmark-region t]
1697 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1698 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1699 ["Mark all" gnus-uu-mark-all t]
1700 ["Mark buffer" gnus-uu-mark-buffer t]
1701 ["Mark sparse" gnus-uu-mark-sparse t]
1702 ["Mark thread" gnus-uu-mark-thread t]
1703 ["Unmark thread" gnus-uu-unmark-thread t]
1704 ("Process Mark Sets"
1705 ["Kill" gnus-summary-kill-process-mark t]
1706 ["Yank" gnus-summary-yank-process-mark
1707 gnus-newsgroup-process-stack]
1708 ["Save" gnus-summary-save-process-mark t]))
1710 ["Page forward" gnus-summary-next-page t]
1711 ["Page backward" gnus-summary-prev-page t]
1712 ["Line forward" gnus-summary-scroll-up t])
1714 ["Next unread article" gnus-summary-next-unread-article t]
1715 ["Previous unread article" gnus-summary-prev-unread-article t]
1716 ["Next article" gnus-summary-next-article t]
1717 ["Previous article" gnus-summary-prev-article t]
1718 ["Next unread subject" gnus-summary-next-unread-subject t]
1719 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1720 ["Next article same subject" gnus-summary-next-same-subject t]
1721 ["Previous article same subject" gnus-summary-prev-same-subject t]
1722 ["First unread article" gnus-summary-first-unread-article t]
1723 ["Best unread article" gnus-summary-best-unread-article t]
1724 ["Go to subject number..." gnus-summary-goto-subject t]
1725 ["Go to article number..." gnus-summary-goto-article t]
1726 ["Go to the last article" gnus-summary-goto-last-article t]
1727 ["Pop article off history" gnus-summary-pop-article t])
1729 ["Sort by number" gnus-summary-sort-by-number t]
1730 ["Sort by author" gnus-summary-sort-by-author t]
1731 ["Sort by subject" gnus-summary-sort-by-subject t]
1732 ["Sort by date" gnus-summary-sort-by-date t]
1733 ["Sort by score" gnus-summary-sort-by-score t]
1734 ["Sort by lines" gnus-summary-sort-by-lines t])
1736 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1737 ["Describe group" gnus-summary-describe-group t]
1738 ["Read manual" gnus-info-find-node t])
1740 ["Pick and read" gnus-pick-mode t]
1741 ["Binary" gnus-binary-mode t])
1743 ["Regenerate" gnus-summary-prepare t]
1744 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1745 ["Toggle threading" gnus-summary-toggle-threads t])
1746 ["Filter articles..." gnus-summary-execute-command t]
1747 ["Run command on subjects..." gnus-summary-universal-argument t]
1748 ["Search articles forward..." gnus-summary-search-article-forward t]
1749 ["Search articles backward..." gnus-summary-search-article-backward t]
1750 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1751 ["Expand window" gnus-summary-expand-window t]
1752 ["Expire expirable articles" gnus-summary-expire-articles
1753 (gnus-check-backend-function
1754 'request-expire-articles gnus-newsgroup-name)]
1755 ["Edit local kill file" gnus-summary-edit-local-kill t]
1756 ["Edit main kill file" gnus-summary-edit-global-kill t]
1757 ["Edit group parameters" gnus-summary-edit-parameters t]
1758 ["Send a bug report" gnus-bug t]
1760 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1761 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
1762 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1763 ["Exit group" gnus-summary-exit t]
1764 ["Exit group without updating" gnus-summary-exit-no-update t]
1765 ["Exit and goto next group" gnus-summary-next-group t]
1766 ["Exit and goto prev group" gnus-summary-prev-group t]
1767 ["Reselect group" gnus-summary-reselect-current-group t]
1768 ["Rescan group" gnus-summary-rescan-group t]
1769 ["Update dribble" gnus-summary-save-newsrc t])))
1771 (gnus-run-hooks 'gnus-summary-menu-hook)))
1773 (defun gnus-score-set-default (var value)
1774 "A version of set that updates the GNU Emacs menu-bar."
1776 ;; It is the message that forces the active status to be updated.
1779 (defun gnus-make-score-map (type)
1780 "Make a summary score map of type TYPE."
1783 (let ((headers '(("author" "from" string)
1784 ("subject" "subject" string)
1785 ("article body" "body" string)
1786 ("article head" "head" string)
1787 ("xref" "xref" string)
1788 ("lines" "lines" number)
1789 ("followups to author" "followup" string)))
1790 (types '((number ("less than" <)
1793 (string ("substring" s)
1797 (perms '(("temporary" (current-time-string))
1805 (if (eq type 'lower)
1810 (setq header (car headers))
1816 (let ((ts (cdr (assoc (nth 2 header) types)))
1832 'gnus-summary-score-entry
1834 (if (or (string= (nth 1 header)
1836 (string= (nth 1 header)
1839 (list 'gnus-summary-header
1841 (list 'quote (nth 1 (car ts)))
1842 (list 'gnus-score-default nil)
1848 (list (nreverse outp))))
1851 (list (nreverse outt))))
1853 (setq headers (cdr headers)))
1854 (list (nreverse outh))))))))
1858 (defun gnus-summary-mode (&optional group)
1859 "Major mode for reading articles.
1861 All normal editing commands are switched off.
1862 \\<gnus-summary-mode-map>
1863 Each line in this buffer represents one article. To read an
1864 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
1865 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
1868 You can also post articles and send mail from this buffer. To
1869 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
1870 of an article, type `\\[gnus-summary-reply]'.
1872 There are approx. one gazillion commands you can execute in this
1873 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
1875 The following commands are available:
1877 \\{gnus-summary-mode-map}"
1879 (when (gnus-visual-p 'summary-menu 'menu)
1880 (gnus-summary-make-menu-bar))
1881 (kill-all-local-variables)
1882 (gnus-summary-make-local-variables)
1883 (gnus-make-thread-indent-array)
1884 (gnus-simplify-mode-line)
1885 (setq major-mode 'gnus-summary-mode)
1886 (setq mode-name "Summary")
1887 (make-local-variable 'minor-mode-alist)
1888 (use-local-map gnus-summary-mode-map)
1889 (buffer-disable-undo)
1890 (setq buffer-read-only t) ;Disable modification
1891 (setq truncate-lines t)
1892 (setq selective-display t)
1893 (setq selective-display-ellipses t) ;Display `...'
1894 (gnus-summary-set-display-table)
1895 (gnus-set-default-directory)
1896 (setq gnus-newsgroup-name group)
1897 (make-local-variable 'gnus-summary-line-format)
1898 (make-local-variable 'gnus-summary-line-format-spec)
1899 (make-local-variable 'gnus-summary-dummy-line-format)
1900 (make-local-variable 'gnus-summary-dummy-line-format-spec)
1901 (make-local-variable 'gnus-summary-mark-positions)
1902 (make-local-hook 'post-command-hook)
1903 (add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
1904 (make-local-hook 'pre-command-hook)
1905 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
1906 (gnus-run-hooks 'gnus-summary-mode-hook)
1907 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
1908 (gnus-update-summary-mark-positions))
1910 (defun gnus-summary-make-local-variables ()
1911 "Make all the local summary buffer variables."
1912 (let ((locals gnus-summary-local-variables)
1914 (while (setq local (pop locals))
1917 (if (eq (cdr local) 'global)
1918 ;; Copy the global value of the variable.
1919 (setq global (symbol-value (car local)))
1920 ;; Use the value from the list.
1921 (setq global (eval (cdr local))))
1922 (make-local-variable (car local))
1923 (set (car local) global))
1924 ;; Simple nil-valued local variable.
1925 (make-local-variable local)
1928 (defun gnus-summary-clear-local-variables ()
1929 (let ((locals gnus-summary-local-variables))
1931 (if (consp (car locals))
1932 (and (vectorp (caar locals))
1933 (set (caar locals) nil))
1934 (and (vectorp (car locals))
1935 (set (car locals) nil)))
1936 (setq locals (cdr locals)))))
1938 ;; Summary data functions.
1940 (defmacro gnus-data-number (data)
1943 (defmacro gnus-data-set-number (data number)
1944 `(setcar ,data ,number))
1946 (defmacro gnus-data-mark (data)
1949 (defmacro gnus-data-set-mark (data mark)
1950 `(setcar (nthcdr 1 ,data) ,mark))
1952 (defmacro gnus-data-pos (data)
1955 (defmacro gnus-data-set-pos (data pos)
1956 `(setcar (nthcdr 2 ,data) ,pos))
1958 (defmacro gnus-data-header (data)
1961 (defmacro gnus-data-set-header (data header)
1962 `(setf (nth 3 ,data) ,header))
1964 (defmacro gnus-data-level (data)
1967 (defmacro gnus-data-unread-p (data)
1968 `(= (nth 1 ,data) gnus-unread-mark))
1970 (defmacro gnus-data-read-p (data)
1971 `(/= (nth 1 ,data) gnus-unread-mark))
1973 (defmacro gnus-data-pseudo-p (data)
1974 `(consp (nth 3 ,data)))
1976 (defmacro gnus-data-find (number)
1977 `(assq ,number gnus-newsgroup-data))
1979 (defmacro gnus-data-find-list (number &optional data)
1980 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
1981 (memq (assq ,number bdata)
1984 (defmacro gnus-data-make (number mark pos header level)
1985 `(list ,number ,mark ,pos ,header ,level))
1987 (defun gnus-data-enter (after-article number mark pos header level offset)
1988 (let ((data (gnus-data-find-list after-article)))
1990 (error "No such article: %d" after-article))
1991 (setcdr data (cons (gnus-data-make number mark pos header level)
1993 (setq gnus-newsgroup-data-reverse nil)
1994 (gnus-data-update-list (cddr data) offset)))
1996 (defun gnus-data-enter-list (after-article list &optional offset)
1998 (let ((data (and after-article (gnus-data-find-list after-article)))
2002 (let ((odata gnus-newsgroup-data))
2003 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2005 (gnus-data-update-list odata offset)))
2006 ;; Find the last element in the list to be spliced into the main
2009 (setq list (cdr list)))
2012 (setcdr list gnus-newsgroup-data)
2013 (setq gnus-newsgroup-data ilist)
2015 (gnus-data-update-list (cdr list) offset)))
2016 (setcdr list (cdr data))
2019 (gnus-data-update-list (cdr list) offset))))
2020 (setq gnus-newsgroup-data-reverse nil))))
2022 (defun gnus-data-remove (article &optional offset)
2023 (let ((data gnus-newsgroup-data))
2024 (if (= (gnus-data-number (car data)) article)
2026 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2027 gnus-newsgroup-data-reverse nil)
2029 (gnus-data-update-list gnus-newsgroup-data offset)))
2031 (when (= (gnus-data-number (cadr data)) article)
2032 (setcdr data (cddr data))
2034 (gnus-data-update-list (cdr data) offset))
2036 gnus-newsgroup-data-reverse nil))
2037 (setq data (cdr data))))))
2039 (defmacro gnus-data-list (backward)
2041 (or gnus-newsgroup-data-reverse
2042 (setq gnus-newsgroup-data-reverse
2043 (reverse gnus-newsgroup-data)))
2044 gnus-newsgroup-data))
2046 (defun gnus-data-update-list (data offset)
2047 "Add OFFSET to the POS of all data entries in DATA."
2048 (setq gnus-newsgroup-data-reverse nil)
2050 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2051 (setq data (cdr data))))
2053 (defun gnus-summary-article-pseudo-p (article)
2054 "Say whether this article is a pseudo article or not."
2055 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2057 (defmacro gnus-summary-article-sparse-p (article)
2058 "Say whether this article is a sparse article or not."
2059 `(memq ,article gnus-newsgroup-sparse))
2061 (defmacro gnus-summary-article-ancient-p (article)
2062 "Say whether this article is a sparse article or not."
2063 `(memq ,article gnus-newsgroup-ancient))
2065 (defun gnus-article-parent-p (number)
2066 "Say whether this article is a parent or not."
2067 (let ((data (gnus-data-find-list number)))
2068 (and (cdr data) ; There has to be an article after...
2069 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2070 (gnus-data-level (nth 1 data))))))
2072 (defun gnus-article-children (number)
2073 "Return a list of all children to NUMBER."
2074 (let* ((data (gnus-data-find-list number))
2075 (level (gnus-data-level (car data)))
2077 (setq data (cdr data))
2079 (= (gnus-data-level (car data)) (1+ level)))
2080 (push (gnus-data-number (car data)) children)
2081 (setq data (cdr data)))
2084 (defmacro gnus-summary-skip-intangible ()
2085 "If the current article is intangible, then jump to a different article."
2086 '(let ((to (get-text-property (point) 'gnus-intangible)))
2087 (and to (gnus-summary-goto-subject to))))
2089 (defmacro gnus-summary-article-intangible-p ()
2090 "Say whether this article is intangible or not."
2091 '(get-text-property (point) 'gnus-intangible))
2093 (defun gnus-article-read-p (article)
2094 "Say whether ARTICLE is read or not."
2095 (not (or (memq article gnus-newsgroup-marked)
2096 (memq article gnus-newsgroup-unreads)
2097 (memq article gnus-newsgroup-unselected)
2098 (memq article gnus-newsgroup-dormant))))
2100 ;; Some summary mode macros.
2102 (defmacro gnus-summary-article-number ()
2103 "The article number of the article on the current line.
2104 If there isn's an article number here, then we return the current
2107 (gnus-summary-skip-intangible)
2108 (or (get-text-property (point) 'gnus-number)
2109 (gnus-summary-last-subject))))
2111 (defmacro gnus-summary-article-header (&optional number)
2112 "Return the header of article NUMBER."
2113 `(gnus-data-header (gnus-data-find
2114 ,(or number '(gnus-summary-article-number)))))
2116 (defmacro gnus-summary-thread-level (&optional number)
2117 "Return the level of thread that starts with article NUMBER."
2118 `(if (and (eq gnus-summary-make-false-root 'dummy)
2119 (get-text-property (point) 'gnus-intangible))
2121 (gnus-data-level (gnus-data-find
2122 ,(or number '(gnus-summary-article-number))))))
2124 (defmacro gnus-summary-article-mark (&optional number)
2125 "Return the mark of article NUMBER."
2126 `(gnus-data-mark (gnus-data-find
2127 ,(or number '(gnus-summary-article-number)))))
2129 (defmacro gnus-summary-article-pos (&optional number)
2130 "Return the position of the line of article NUMBER."
2131 `(gnus-data-pos (gnus-data-find
2132 ,(or number '(gnus-summary-article-number)))))
2134 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2135 (defmacro gnus-summary-article-subject (&optional number)
2136 "Return current subject string or nil if nothing."
2139 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2140 '(gnus-data-header (assq (gnus-summary-article-number)
2141 gnus-newsgroup-data)))))
2144 (mail-header-subject headers))))
2146 (defmacro gnus-summary-article-score (&optional number)
2147 "Return current article score."
2148 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2149 gnus-newsgroup-scored))
2150 gnus-summary-default-score 0))
2152 (defun gnus-summary-article-children (&optional number)
2153 "Return a list of article numbers that are children of article NUMBER."
2154 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2155 (level (gnus-data-level (car data)))
2157 (while (and (setq data (cdr data))
2158 (> (setq l (gnus-data-level (car data))) level))
2159 (and (= (1+ level) l)
2160 (push (gnus-data-number (car data))
2162 (nreverse children)))
2164 (defun gnus-summary-article-parent (&optional number)
2165 "Return the article number of the parent of article NUMBER."
2166 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2167 (gnus-data-list t)))
2168 (level (gnus-data-level (car data))))
2170 () ; This is a root.
2171 ;; We search until we find an article with a level less than
2172 ;; this one. That function has to be the parent.
2173 (while (and (setq data (cdr data))
2174 (not (< (gnus-data-level (car data)) level))))
2175 (and data (gnus-data-number (car data))))))
2177 (defun gnus-unread-mark-p (mark)
2178 "Say whether MARK is the unread mark."
2179 (= mark gnus-unread-mark))
2181 (defun gnus-read-mark-p (mark)
2182 "Say whether MARK is one of the marks that mark as read.
2183 This is all marks except unread, ticked, dormant, and expirable."
2184 (not (or (= mark gnus-unread-mark)
2185 (= mark gnus-ticked-mark)
2186 (= mark gnus-dormant-mark)
2187 (= mark gnus-expirable-mark))))
2189 (defmacro gnus-article-mark (number)
2190 "Return the MARK of article NUMBER.
2191 This macro should only be used when computing the mark the \"first\"
2192 time; i.e., when generating the summary lines. After that,
2193 `gnus-summary-article-mark' should be used to examine the
2196 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2197 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2198 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2199 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2200 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2201 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2202 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2203 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2204 gnus-ancient-mark))))
2206 ;; Saving hidden threads.
2208 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2209 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2211 (defmacro gnus-save-hidden-threads (&rest forms)
2212 "Save hidden threads, eval FORMS, and restore the hidden threads."
2213 (let ((config (make-symbol "config")))
2214 `(let ((,config (gnus-hidden-threads-configuration)))
2218 (gnus-restore-hidden-threads-configuration ,config)))))
2220 (defun gnus-data-compute-positions ()
2221 "Compute the positions of all articles."
2222 (setq gnus-newsgroup-data-reverse nil)
2223 (let ((data gnus-newsgroup-data))
2225 (gnus-save-hidden-threads
2226 (gnus-summary-show-all-threads)
2227 (goto-char (point-min))
2229 (while (get-text-property (point) 'gnus-intangible)
2231 (gnus-data-set-pos (car data) (+ (point) 3))
2232 (setq data (cdr data))
2233 (forward-line 1))))))
2235 (defun gnus-hidden-threads-configuration ()
2236 "Return the current hidden threads configuration."
2239 (goto-char (point-min))
2240 (while (search-forward "\r" nil t)
2241 (push (1- (point)) config))
2244 (defun gnus-restore-hidden-threads-configuration (config)
2245 "Restore hidden threads configuration from CONFIG."
2246 (let (point buffer-read-only)
2247 (while (setq point (pop config))
2248 (when (and (< point (point-max))
2250 (eq (char-after) ?\n))
2251 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2253 ;; Various summary mode internalish functions.
2255 (defun gnus-mouse-pick-article (e)
2258 (gnus-summary-next-page nil t))
2260 (defun gnus-summary-set-display-table ()
2261 ;; Change the display table. Odd characters have a tendency to mess
2262 ;; up nicely formatted displays - we make all possible glyphs
2263 ;; display only a single character.
2265 ;; We start from the standard display table, if any.
2266 (let ((table (or (copy-sequence standard-display-table)
2267 (make-display-table)))
2269 ;; Nix out all the control chars...
2270 (while (>= (setq i (1- i)) 0)
2271 (aset table i [??]))
2272 ;; ... but not newline and cr, of course. (cr is necessary for the
2273 ;; selective display).
2274 (aset table ?\n nil)
2275 (aset table ?\r nil)
2276 ;; We keep TAB as well.
2277 (aset table ?\t nil)
2278 ;; We nix out any glyphs over 126 that are not set already.
2280 (while (>= (setq i (1- i)) 127)
2281 ;; Only modify if the entry is nil.
2282 (unless (aref table i)
2283 (aset table i [??]))))
2284 (setq buffer-display-table table)))
2286 (defun gnus-summary-setup-buffer (group)
2287 "Initialize summary buffer."
2288 (let ((buffer (concat "*Summary " group "*")))
2289 (if (get-buffer buffer)
2292 (setq gnus-summary-buffer (current-buffer))
2293 (not gnus-newsgroup-prepared))
2294 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2295 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2296 (gnus-summary-mode group)
2298 (gnus-carpal-setup-buffer 'summary))
2299 (unless gnus-single-article-buffer
2300 (make-local-variable 'gnus-article-buffer)
2301 (make-local-variable 'gnus-article-current)
2302 (make-local-variable 'gnus-original-article-buffer))
2303 (setq gnus-newsgroup-name group)
2306 (defun gnus-set-global-variables ()
2307 ;; Set the global equivalents of the summary buffer-local variables
2308 ;; to the latest values they had. These reflect the summary buffer
2309 ;; that was in action when the last article was fetched.
2310 (when (eq major-mode 'gnus-summary-mode)
2311 (setq gnus-summary-buffer (current-buffer))
2312 (let ((name gnus-newsgroup-name)
2313 (marked gnus-newsgroup-marked)
2314 (unread gnus-newsgroup-unreads)
2315 (headers gnus-current-headers)
2316 (data gnus-newsgroup-data)
2317 (summary gnus-summary-buffer)
2318 (article-buffer gnus-article-buffer)
2319 (original gnus-original-article-buffer)
2320 (gac gnus-article-current)
2321 (reffed gnus-reffed-article-number)
2322 (score-file gnus-current-score-file))
2324 (set-buffer gnus-group-buffer)
2325 (setq gnus-newsgroup-name name
2326 gnus-newsgroup-marked marked
2327 gnus-newsgroup-unreads unread
2328 gnus-current-headers headers
2329 gnus-newsgroup-data data
2330 gnus-article-current gac
2331 gnus-summary-buffer summary
2332 gnus-article-buffer article-buffer
2333 gnus-original-article-buffer original
2334 gnus-reffed-article-number reffed
2335 gnus-current-score-file score-file)
2336 ;; The article buffer also has local variables.
2337 (when (gnus-buffer-live-p gnus-article-buffer)
2338 (set-buffer gnus-article-buffer)
2339 (setq gnus-summary-buffer summary))))))
2341 (defun gnus-summary-article-unread-p (article)
2342 "Say whether ARTICLE is unread or not."
2343 (memq article gnus-newsgroup-unreads))
2345 (defun gnus-summary-first-article-p (&optional article)
2346 "Return whether ARTICLE is the first article in the buffer."
2347 (if (not (setq article (or article (gnus-summary-article-number))))
2349 (eq article (caar gnus-newsgroup-data))))
2351 (defun gnus-summary-last-article-p (&optional article)
2352 "Return whether ARTICLE is the last article in the buffer."
2353 (if (not (setq article (or article (gnus-summary-article-number))))
2354 t ; All non-existent numbers are the last article. :-)
2355 (not (cdr (gnus-data-find-list article)))))
2357 (defun gnus-make-thread-indent-array ()
2359 (unless (and gnus-thread-indent-array
2360 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2361 (setq gnus-thread-indent-array (make-vector 201 "")
2362 gnus-thread-indent-array-level gnus-thread-indent-level)
2364 (aset gnus-thread-indent-array n
2365 (make-string (* n gnus-thread-indent-level) ? ))
2368 (defun gnus-update-summary-mark-positions ()
2369 "Compute where the summary marks are to go."
2371 (when (gnus-buffer-exists-p gnus-summary-buffer)
2372 (set-buffer gnus-summary-buffer))
2373 (let ((gnus-replied-mark 129)
2374 (gnus-score-below-mark 130)
2375 (gnus-score-over-mark 130)
2376 (gnus-download-mark 131)
2377 (spec gnus-summary-line-format-spec)
2380 (gnus-set-work-buffer)
2381 (let ((gnus-summary-line-format-spec spec)
2382 (gnus-newsgroup-downloadable '((0 . t))))
2383 (gnus-summary-insert-line
2384 (make-full-mail-header 0 "" "" "" "" "" 0 0 "" nil)
2385 0 nil 128 t nil "" nil 1)
2386 (goto-char (point-min))
2387 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2389 (goto-char (point-min))
2390 (push (cons 'replied (and (search-forward "\201" nil t)
2393 (goto-char (point-min))
2394 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2396 (goto-char (point-min))
2397 (push (cons 'download
2398 (and (search-forward "\203" nil t) (- (point) 2)))
2400 (setq gnus-summary-mark-positions pos))))
2402 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2403 "Insert a dummy root in the summary buffer."
2405 (gnus-add-text-properties
2406 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2407 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2409 (defun gnus-summary-from-or-to-or-newsgroups (header)
2410 (let ((to (cdr (assq 'To (mail-header-extra header))))
2411 (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header)))))
2414 gnus-ignored-from-addresses
2415 (string-match gnus-ignored-from-addresses
2416 (mail-header-from header)))
2418 (or (car (funcall gnus-extract-address-components
2420 gnus-decode-encoded-word-function to)))
2421 (funcall gnus-decode-encoded-word-function to))))
2423 gnus-ignored-from-addresses
2424 (string-match gnus-ignored-from-addresses
2425 (mail-header-from header)))
2426 (concat "=> " newsgroups))
2428 (or (car (funcall gnus-extract-address-components
2429 (mail-header-from header)))
2430 (mail-header-from header))))))
2432 (defun gnus-summary-insert-line (gnus-tmp-header
2433 gnus-tmp-level gnus-tmp-current
2434 gnus-tmp-unread gnus-tmp-replied
2435 gnus-tmp-expirable gnus-tmp-subject-or-nil
2436 &optional gnus-tmp-dummy gnus-tmp-score
2438 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2439 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2440 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2441 (gnus-tmp-score-char
2442 (if (or (null gnus-summary-default-score)
2443 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2444 gnus-summary-zcore-fuzz))
2446 (if (< gnus-tmp-score gnus-summary-default-score)
2447 gnus-score-below-mark gnus-score-over-mark)))
2449 (cond (gnus-tmp-process gnus-process-mark)
2450 ((memq gnus-tmp-current gnus-newsgroup-cached)
2452 (gnus-tmp-replied gnus-replied-mark)
2453 ((memq gnus-tmp-current gnus-newsgroup-saved)
2455 (t gnus-unread-mark)))
2456 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2459 ((string-match "<[^>]+> *$" gnus-tmp-from)
2460 (let ((beg (match-beginning 0)))
2461 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2462 (substring gnus-tmp-from (1+ (match-beginning 0))
2463 (1- (match-end 0))))
2464 (substring gnus-tmp-from 0 beg))))
2465 ((string-match "(.+)" gnus-tmp-from)
2466 (substring gnus-tmp-from
2467 (1+ (match-beginning 0)) (1- (match-end 0))))
2469 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2470 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2471 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2472 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2473 (buffer-read-only nil))
2474 (when (string= gnus-tmp-name "")
2475 (setq gnus-tmp-name gnus-tmp-from))
2476 (unless (numberp gnus-tmp-lines)
2477 (setq gnus-tmp-lines 0))
2478 (gnus-put-text-property-excluding-characters-with-faces
2480 (progn (eval gnus-summary-line-format-spec) (point))
2481 'gnus-number gnus-tmp-number)
2482 (when (gnus-visual-p 'summary-highlight 'highlight)
2484 (gnus-run-hooks 'gnus-summary-update-hook)
2487 (defun gnus-summary-update-line (&optional dont-update)
2488 ;; Update summary line after change.
2489 (when (and gnus-summary-default-score
2490 (not gnus-summary-inhibit-highlight))
2491 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2492 (article (gnus-summary-article-number))
2493 (score (gnus-summary-article-score article)))
2495 (if (and gnus-summary-mark-below
2496 (< (gnus-summary-article-score)
2497 gnus-summary-mark-below))
2498 ;; This article has a low score, so we mark it as read.
2499 (when (memq article gnus-newsgroup-unreads)
2500 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2501 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2502 ;; This article was previously marked as read on account
2503 ;; of a low score, but now it has risen, so we mark it as
2505 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2506 (gnus-summary-update-mark
2507 (if (or (null gnus-summary-default-score)
2508 (<= (abs (- score gnus-summary-default-score))
2509 gnus-summary-zcore-fuzz))
2511 (if (< score gnus-summary-default-score)
2512 gnus-score-below-mark gnus-score-over-mark))
2514 ;; Do visual highlighting.
2515 (when (gnus-visual-p 'summary-highlight 'highlight)
2516 (gnus-run-hooks 'gnus-summary-update-hook)))))
2518 (defvar gnus-tmp-new-adopts nil)
2520 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2521 "Return the number of articles in THREAD.
2522 This may be 0 in some cases -- if none of the articles in
2523 the thread are to be displayed."
2525 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2527 ((not (listp thread))
2529 ((and (consp thread) (cdr thread))
2532 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2535 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2538 (when (and level (zerop level) gnus-tmp-new-adopts)
2541 'gnus-summary-number-of-articles-in-thread
2542 gnus-tmp-new-adopts))))
2544 (if (> number 1) gnus-not-empty-thread-mark
2545 gnus-empty-thread-mark)
2548 (defun gnus-summary-set-local-parameters (group)
2549 "Go through the local params of GROUP and set all variable specs in that list."
2550 (let ((params (gnus-group-find-parameter group))
2553 (setq elem (car params)
2554 params (cdr params))
2555 (and (consp elem) ; Has to be a cons.
2556 (consp (cdr elem)) ; The cdr has to be a list.
2557 (symbolp (car elem)) ; Has to be a symbol in there.
2558 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2559 (ignore-errors ; So we set it.
2560 (make-local-variable (car elem))
2561 (set (car elem) (eval (nth 1 elem))))))))
2563 (defun gnus-summary-read-group (group &optional show-all no-article
2564 kill-buffer no-display backward
2566 "Start reading news in newsgroup GROUP.
2567 If SHOW-ALL is non-nil, already read articles are also listed.
2568 If NO-ARTICLE is non-nil, no article is selected initially.
2569 If NO-DISPLAY, don't generate a summary buffer."
2573 (let ((gnus-auto-select-next nil))
2574 (or (gnus-summary-read-group-1
2575 group show-all no-article
2576 kill-buffer no-display
2579 select-articles nil)))))
2580 (eq gnus-auto-select-next 'quietly))
2581 (set-buffer gnus-group-buffer)
2582 ;; The entry function called above goes to the next
2583 ;; group automatically, so we go two groups back
2584 ;; if we are searching for the previous group.
2586 (gnus-group-prev-unread-group 2))
2587 (if (not (equal group (gnus-group-group-name)))
2588 (setq group (gnus-group-group-name))
2592 (defun gnus-summary-read-group-1 (group show-all no-article
2593 kill-buffer no-display
2594 &optional select-articles)
2595 ;; Killed foreign groups can't be entered.
2596 (when (and (not (gnus-group-native-p group))
2597 (not (gnus-gethash group gnus-newsrc-hashtb)))
2598 (error "Dead non-native groups can't be entered"))
2599 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2600 (let* ((new-group (gnus-summary-setup-buffer group))
2601 (quit-config (gnus-group-quit-config group))
2602 (did-select (and new-group (gnus-select-newsgroup
2603 group show-all select-articles))))
2605 ;; This summary buffer exists already, so we just select it.
2607 (gnus-set-global-variables)
2609 (gnus-kill-or-deaden-summary kill-buffer))
2610 (gnus-configure-windows 'summary 'force)
2611 (gnus-set-mode-line 'summary)
2612 (gnus-summary-position-point)
2615 ;; We couldn't select this group.
2617 (when (and (eq major-mode 'gnus-summary-mode)
2618 (not (equal (current-buffer) kill-buffer)))
2619 (kill-buffer (current-buffer))
2620 (if (not quit-config)
2622 ;; Update the info -- marks might need to be removed,
2624 (gnus-summary-update-info)
2625 (set-buffer gnus-group-buffer)
2626 (gnus-group-jump-to-group group)
2627 (gnus-group-next-unread-group 1))
2628 (gnus-handle-ephemeral-exit quit-config)))
2629 (gnus-message 3 "Can't select group")
2631 ;; The user did a `C-g' while prompting for number of articles,
2632 ;; so we exit this group.
2633 ((eq did-select 'quit)
2634 (and (eq major-mode 'gnus-summary-mode)
2635 (not (equal (current-buffer) kill-buffer))
2636 (kill-buffer (current-buffer)))
2638 (gnus-kill-or-deaden-summary kill-buffer))
2639 (if (not quit-config)
2641 (set-buffer gnus-group-buffer)
2642 (gnus-group-jump-to-group group)
2643 (gnus-group-next-unread-group 1)
2644 (gnus-configure-windows 'group 'force))
2645 (gnus-handle-ephemeral-exit quit-config))
2646 ;; Finally signal the quit.
2648 ;; The group was successfully selected.
2650 (gnus-set-global-variables)
2651 ;; Save the active value in effect when the group was entered.
2652 (setq gnus-newsgroup-active
2654 (gnus-active gnus-newsgroup-name)))
2655 ;; You can change the summary buffer in some way with this hook.
2656 (gnus-run-hooks 'gnus-select-group-hook)
2657 ;; Set any local variables in the group parameters.
2658 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2659 (gnus-update-format-specifications
2660 nil 'summary 'summary-mode 'summary-dummy)
2661 ;; Do score processing.
2662 (when gnus-use-scoring
2663 (gnus-possibly-score-headers))
2664 ;; Check whether to fill in the gaps in the threads.
2665 (when gnus-build-sparse-threads
2666 (gnus-build-sparse-threads))
2667 ;; Find the initial limit.
2668 (if gnus-show-threads
2670 (let ((gnus-newsgroup-dormant nil))
2671 (gnus-summary-initial-limit show-all))
2672 (gnus-summary-initial-limit show-all))
2673 (setq gnus-newsgroup-limit
2675 (lambda (header) (mail-header-number header))
2676 gnus-newsgroup-headers)))
2677 ;; Generate the summary buffer.
2679 (gnus-summary-prepare))
2680 (when gnus-use-trees
2681 (gnus-tree-open group)
2682 (setq gnus-summary-highlight-line-function
2683 'gnus-tree-highlight-article))
2684 ;; If the summary buffer is empty, but there are some low-scored
2685 ;; articles or some excluded dormants, we include these in the
2687 (when (and (zerop (buffer-size))
2689 (cond (gnus-newsgroup-dormant
2690 (gnus-summary-limit-include-dormant))
2691 ((and gnus-newsgroup-scored show-all)
2692 (gnus-summary-limit-include-expunged t))))
2693 ;; Function `gnus-apply-kill-file' must be called in this hook.
2694 (gnus-run-hooks 'gnus-apply-kill-hook)
2695 (if (and (zerop (buffer-size))
2698 ;; This newsgroup is empty.
2699 (gnus-summary-catchup-and-exit nil t)
2700 (gnus-message 6 "No unread news")
2702 (gnus-kill-or-deaden-summary kill-buffer))
2703 ;; Return nil from this function.
2705 ;; Hide conversation thread subtrees. We cannot do this in
2706 ;; gnus-summary-prepare-hook since kill processing may not
2707 ;; work with hidden articles.
2708 (and gnus-show-threads
2709 gnus-thread-hide-subtree
2710 (gnus-summary-hide-all-threads))
2712 (gnus-kill-or-deaden-summary kill-buffer))
2713 ;; Show first unread article if requested.
2714 (if (and (not no-article)
2716 gnus-newsgroup-unreads
2717 gnus-auto-select-first)
2719 (gnus-configure-windows 'summary)
2721 ((eq gnus-auto-select-first 'best)
2722 (gnus-summary-best-unread-article))
2723 ((eq gnus-auto-select-first t)
2724 (gnus-summary-first-unread-article))
2725 ((gnus-functionp gnus-auto-select-first)
2726 (funcall gnus-auto-select-first))))
2727 ;; Don't select any articles, just move point to the first
2728 ;; article in the group.
2729 (goto-char (point-min))
2730 (gnus-summary-position-point)
2731 (gnus-configure-windows 'summary 'force)
2732 (gnus-set-mode-line 'summary))
2733 (when (get-buffer-window gnus-group-buffer t)
2734 ;; Gotta use windows, because recenter does weird stuff if
2735 ;; the current buffer ain't the displayed window.
2736 (let ((owin (selected-window)))
2737 (select-window (get-buffer-window gnus-group-buffer t))
2738 (when (gnus-group-goto-group group)
2740 (select-window owin)))
2741 ;; Mark this buffer as "prepared".
2742 (setq gnus-newsgroup-prepared t)
2743 (gnus-run-hooks 'gnus-summary-prepared-hook)
2746 (defun gnus-summary-prepare ()
2747 "Generate the summary buffer."
2749 (let ((buffer-read-only nil))
2751 (setq gnus-newsgroup-data nil
2752 gnus-newsgroup-data-reverse nil)
2753 (gnus-run-hooks 'gnus-summary-generate-hook)
2754 ;; Generate the buffer, either with threads or without.
2755 (when gnus-newsgroup-headers
2756 (gnus-summary-prepare-threads
2757 (if gnus-show-threads
2758 (gnus-sort-gathered-threads
2759 (funcall gnus-summary-thread-gathering-function
2761 (gnus-cut-threads (gnus-make-threads)))))
2762 ;; Unthreaded display.
2763 (gnus-sort-articles gnus-newsgroup-headers))))
2764 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2765 ;; Call hooks for modifying summary buffer.
2766 (goto-char (point-min))
2767 (gnus-run-hooks 'gnus-summary-prepare-hook)))
2769 (defsubst gnus-general-simplify-subject (subject)
2770 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2773 ;; Truncate the subject.
2774 (gnus-simplify-subject-functions
2775 (gnus-map-function gnus-simplify-subject-functions subject))
2776 ((numberp gnus-summary-gather-subject-limit)
2777 (setq subject (gnus-simplify-subject-re subject))
2778 (if (> (length subject) gnus-summary-gather-subject-limit)
2779 (substring subject 0 gnus-summary-gather-subject-limit)
2781 ;; Fuzzily simplify it.
2782 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2783 (gnus-simplify-subject-fuzzy subject))
2784 ;; Just remove the leading "Re:".
2786 (gnus-simplify-subject-re subject))))
2788 (if (and gnus-summary-gather-exclude-subject
2789 (string-match gnus-summary-gather-exclude-subject subject))
2790 nil ; This article shouldn't be gathered
2793 (defun gnus-summary-simplify-subject-query ()
2794 "Query where the respool algorithm would put this article."
2796 (gnus-summary-select-article)
2797 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2799 (defun gnus-gather-threads-by-subject (threads)
2800 "Gather threads by looking at Subject headers."
2801 (if (not gnus-summary-make-false-root)
2803 (let ((hashtb (gnus-make-hashtable 1024))
2806 subject hthread whole-subject)
2808 (setq subject (gnus-general-simplify-subject
2809 (setq whole-subject (mail-header-subject
2812 (if (setq hthread (gnus-gethash subject hashtb))
2814 ;; We enter a dummy root into the thread, if we
2815 ;; haven't done that already.
2816 (unless (stringp (caar hthread))
2817 (setcar hthread (list whole-subject (car hthread))))
2818 ;; We add this new gathered thread to this gathered
2820 (setcdr (car hthread)
2821 (nconc (cdar hthread) (list (car threads))))
2822 ;; Remove it from the list of threads.
2823 (setcdr prev (cdr threads))
2824 (setq threads prev))
2825 ;; Enter this thread into the hash table.
2826 (gnus-sethash subject threads hashtb)))
2828 (setq threads (cdr threads)))
2831 (defun gnus-gather-threads-by-references (threads)
2832 "Gather threads by looking at References headers."
2833 (let ((idhashtb (gnus-make-hashtable 1024))
2834 (thhashtb (gnus-make-hashtable 1024))
2837 ids references id gthread gid entered ref)
2839 (when (setq references (mail-header-references (caar threads)))
2840 (setq id (mail-header-id (caar threads))
2841 ids (gnus-split-references references)
2843 (while (setq ref (pop ids))
2844 (setq ids (delete ref ids))
2845 (if (not (setq gid (gnus-gethash ref idhashtb)))
2847 (gnus-sethash ref id idhashtb)
2848 (gnus-sethash id threads thhashtb))
2849 (setq gthread (gnus-gethash gid thhashtb))
2851 ;; We enter a dummy root into the thread, if we
2852 ;; haven't done that already.
2853 (unless (stringp (caar gthread))
2854 (setcar gthread (list (mail-header-subject (caar gthread))
2856 ;; We add this new gathered thread to this gathered
2858 (setcdr (car gthread)
2859 (nconc (cdar gthread) (list (car threads)))))
2860 ;; Add it into the thread hash table.
2861 (gnus-sethash id gthread thhashtb)
2863 ;; Remove it from the list of threads.
2864 (setcdr prev (cdr threads))
2865 (setq threads prev))))
2867 (setq threads (cdr threads)))
2870 (defun gnus-sort-gathered-threads (threads)
2871 "Sort subtreads inside each gathered thread by article number."
2872 (let ((result threads))
2874 (when (stringp (caar threads))
2875 (setcdr (car threads)
2876 (sort (cdar threads) 'gnus-thread-sort-by-number)))
2877 (setq threads (cdr threads)))
2880 (defun gnus-thread-loop-p (root thread)
2881 "Say whether ROOT is in THREAD."
2882 (let ((stack (list thread))
2885 (while (setq thread (pop stack))
2886 (setq th (cdr thread))
2888 (not (eq (caar th) root)))
2891 ;; We have found a loop.
2893 (setcdr thread (delq (car th) (cdr thread)))
2894 (if (boundp (setq ref-dep (intern "none"
2895 gnus-newsgroup-dependencies)))
2896 (setcdr (symbol-value ref-dep)
2897 (nconc (cdr (symbol-value ref-dep))
2899 (set ref-dep (list nil (car th))))
2902 ;; Push all the subthreads onto the stack.
2903 (push (cdr thread) stack)))
2906 (defun gnus-make-threads ()
2907 "Go through the dependency hashtb and find the roots. Return all threads."
2909 (while (catch 'infloop
2912 ;; Deal with self-referencing References loops.
2913 (when (and (car (symbol-value refs))
2920 (car (symbol-value refs)) thread))
2921 (cdr (symbol-value refs)))))))
2924 (unless (car (symbol-value refs))
2925 ;; These threads do not refer back to any other articles,
2926 ;; so they're roots.
2927 (setq threads (append (cdr (symbol-value refs)) threads))))
2928 gnus-newsgroup-dependencies)))
2931 ;; Build the thread tree.
2932 (defsubst gnus-dependencies-add-header (header dependencies force-new)
2933 "Enter HEADER into the DEPENDENCIES table if it is not already there.
2935 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
2936 if it was already present.
2938 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
2939 will not be entered in the DEPENDENCIES table. Otherwise duplicate
2940 Message-IDs will be renamed be renamed to a unique Message-ID before
2943 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
2944 (let* ((id (mail-header-id header))
2945 (id-dep (and id (intern id dependencies)))
2946 ref ref-dep ref-header)
2947 ;; Enter this `header' in the `dependencies' table.
2951 ;; The first two cases do the normal part: enter a new `header'
2952 ;; in the `dependencies' table.
2953 ((not (boundp id-dep))
2954 (set id-dep (list header)))
2955 ((null (car (symbol-value id-dep)))
2956 (setcar (symbol-value id-dep) header))
2958 ;; From here the `header' was already present in the
2959 ;; `dependencies' table.
2961 ;; Overrides an existing entry;
2962 ;; just set the header part of the entry.
2963 (setcar (symbol-value id-dep) header))
2965 ;; Renames the existing `header' to a unique Message-ID.
2966 ((not gnus-summary-ignore-duplicates)
2967 ;; An article with this Message-ID has already been seen.
2968 ;; We rename the Message-ID.
2969 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
2971 (mail-header-set-id header id))
2973 ;; The last case ignores an existing entry, except it adds any
2974 ;; additional Xrefs (in case the two articles came from different
2976 ;; Also sets `header' to `nil' meaning that the `dependencies'
2977 ;; table was *not* modified.
2979 (mail-header-set-xref
2980 (car (symbol-value id-dep))
2981 (concat (or (mail-header-xref (car (symbol-value id-dep)))
2983 (or (mail-header-xref header) "")))
2987 ;; First check if that we are not creating a References loop.
2988 (setq ref (gnus-parent-id (mail-header-references header)))
2990 (setq ref-dep (intern-soft ref dependencies))
2992 (setq ref-header (car (symbol-value ref-dep))))
2993 (if (string= id ref)
2994 ;; Yuk! This is a reference loop. Make the article be a
2997 (mail-header-set-references (car (symbol-value id-dep)) "none")
2999 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3000 (setq ref (gnus-parent-id (mail-header-references header)))
3001 (setq ref-dep (intern (or ref "none") dependencies))
3002 (if (boundp ref-dep)
3003 (setcdr (symbol-value ref-dep)
3004 (nconc (cdr (symbol-value ref-dep))
3005 (list (symbol-value id-dep))))
3006 (set ref-dep (list nil (symbol-value id-dep)))))
3009 (defun gnus-build-sparse-threads ()
3010 (let ((headers gnus-newsgroup-headers)
3011 (gnus-summary-ignore-duplicates t)
3012 header references generation relations
3013 subject child end new-child date)
3014 ;; First we create an alist of generations/relations, where
3015 ;; generations is how much we trust the relation, and the relation
3017 (gnus-message 7 "Making sparse threads...")
3019 (nnheader-set-temp-buffer " *gnus sparse threads*")
3020 (while (setq header (pop headers))
3021 (when (and (setq references (mail-header-references header))
3022 (not (string= references "")))
3024 (setq child (mail-header-id header)
3025 subject (mail-header-subject header)
3026 date (mail-header-date header)
3028 (while (search-backward ">" nil t)
3029 (setq end (1+ (point)))
3030 (when (search-backward "<" nil t)
3031 (setq new-child (buffer-substring (point) end))
3032 (push (list (incf generation)
3033 child (setq child new-child)
3037 (push (list (1+ generation) child nil subject) relations))
3039 (kill-buffer (current-buffer)))
3040 ;; Sort over trustworthiness.
3043 (when (gnus-dependencies-add-header
3044 (make-full-mail-header
3045 gnus-reffed-article-number
3046 (nth 3 relation) "" (or (nth 4 relation) "")
3048 (or (nth 2 relation) "") 0 0 "")
3049 gnus-newsgroup-dependencies nil)
3050 (push gnus-reffed-article-number gnus-newsgroup-limit)
3051 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3052 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3053 gnus-newsgroup-reads)
3054 (decf gnus-reffed-article-number)))
3055 (sort relations 'car-less-than-car))
3056 (gnus-message 7 "Making sparse threads...done")))
3058 (defun gnus-build-old-threads ()
3059 ;; Look at all the articles that refer back to old articles, and
3060 ;; fetch the headers for the articles that aren't there. This will
3061 ;; build complete threads - if the roots haven't been expired by the
3066 (when (not (car (symbol-value refs)))
3067 (setq heads (cdr (symbol-value refs)))
3069 (if (memq (mail-header-number (caar heads))
3070 gnus-newsgroup-dormant)
3071 (setq heads (cdr heads))
3072 (setq id (symbol-name refs))
3073 (while (and (setq id (gnus-build-get-header id))
3074 (not (car (gnus-id-to-thread id)))))
3075 (setq heads nil)))))
3076 gnus-newsgroup-dependencies)))
3078 (defmacro gnus-nov-read-integer ()
3080 (if (eq (char-after) ?\t)
3082 (let ((num (ignore-errors (read buffer))))
3083 (if (numberp num) num 0)))
3085 (search-forward "\t" eol 'move))))
3087 (defmacro gnus-nov-skip-field ()
3088 '(search-forward "\t" eol 'move))
3090 (defmacro gnus-nov-field ()
3091 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
3093 (defmacro gnus-nov-parse-extra ()
3095 (while (not (memq (char-after) '(?\n nil)))
3096 (setq string (gnus-nov-field))
3097 (when (string-match "^\\([^ :]+\\): " string)
3098 (push (cons (intern (match-string 1 string))
3099 (substring string (match-end 0)))
3103 ;; This function has to be called with point after the article number
3104 ;; on the beginning of the line.
3105 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3106 (let ((eol (gnus-point-at-eol))
3107 (buffer (current-buffer))
3110 ;; overview: [num subject from date id refs chars lines misc]
3113 (narrow-to-region (point) eol)
3118 (make-full-mail-header
3120 (gnus-nov-field) ; subject
3121 (gnus-nov-field) ; from
3122 (gnus-nov-field) ; date
3123 (or (gnus-nov-field)
3124 (nnheader-generate-fake-message-id)) ; id
3125 (gnus-nov-field) ; refs
3126 (gnus-nov-read-integer) ; chars
3127 (gnus-nov-read-integer) ; lines
3128 (unless (eq (char-after) ?\n)
3129 (gnus-nov-field)) ; misc
3130 (gnus-nov-parse-extra)))) ; extra
3134 (when gnus-alter-header-function
3135 (funcall gnus-alter-header-function header))
3136 (gnus-dependencies-add-header header dependencies force-new)))
3138 (defun gnus-build-get-header (id)
3139 ;; Look through the buffer of NOV lines and find the header to
3140 ;; ID. Enter this line into the dependencies hash table, and return
3141 ;; the id of the parent article (if any).
3142 (let ((deps gnus-newsgroup-dependencies)
3146 (set-buffer nntp-server-buffer)
3147 (let ((case-fold-search nil))
3148 (goto-char (point-min))
3149 (while (and (not found)
3150 (search-forward id nil t))
3152 (setq found (looking-at
3153 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3154 (regexp-quote id))))
3155 (or found (beginning-of-line 2)))
3159 (setq header (gnus-nov-parse-line
3160 (read (current-buffer)) deps))
3161 (gnus-parent-id (mail-header-references header))))))
3163 (let ((number (mail-header-number header)))
3164 (push number gnus-newsgroup-limit)
3165 (push header gnus-newsgroup-headers)
3166 (if (memq number gnus-newsgroup-unselected)
3168 (push number gnus-newsgroup-unreads)
3169 (setq gnus-newsgroup-unselected
3170 (delq number gnus-newsgroup-unselected)))
3171 (push number gnus-newsgroup-ancient)))))))
3173 (defun gnus-build-all-threads ()
3174 "Read all the headers."
3175 (let ((gnus-summary-ignore-duplicates t)
3176 (dependencies gnus-newsgroup-dependencies)
3179 (set-buffer nntp-server-buffer)
3180 (let ((case-fold-search nil))
3181 (goto-char (point-min))
3184 (setq article (read (current-buffer))
3185 header (gnus-nov-parse-line
3186 article dependencies)))
3189 (set-buffer gnus-summary-buffer)
3190 (push header gnus-newsgroup-headers)
3191 (if (memq (setq article (mail-header-number header))
3192 gnus-newsgroup-unselected)
3194 (push article gnus-newsgroup-unreads)
3195 (setq gnus-newsgroup-unselected
3196 (delq article gnus-newsgroup-unselected)))
3197 (push article gnus-newsgroup-ancient)))
3198 (forward-line 1)))))))
3200 (defun gnus-summary-update-article-line (article header)
3201 "Update the line for ARTICLE using HEADERS."
3202 (let* ((id (mail-header-id header))
3203 (thread (gnus-id-to-thread id)))
3205 (error "Article in no thread"))
3206 ;; Update the thread.
3207 (setcar thread header)
3208 (gnus-summary-goto-subject article)
3209 (let* ((datal (gnus-data-find-list article))
3211 (length (when (cdr datal)
3212 (- (gnus-data-pos data)
3213 (gnus-data-pos (cadr datal)))))
3214 (buffer-read-only nil)
3215 (level (gnus-summary-thread-level)))
3217 (gnus-summary-insert-line
3218 header level nil (gnus-article-mark article)
3219 (memq article gnus-newsgroup-replied)
3220 (memq article gnus-newsgroup-expirable)
3221 ;; Only insert the Subject string when it's different
3222 ;; from the previous Subject string.
3223 (if (gnus-subject-equal
3225 (mail-header-subject
3228 (gnus-data-find-list
3230 (gnus-data-list t)))))
3231 ;; Error on the side of excessive subjects.
3233 (mail-header-subject header))
3235 (mail-header-subject header))
3236 nil (cdr (assq article gnus-newsgroup-scored))
3237 (memq article gnus-newsgroup-processable))
3239 (gnus-data-update-list
3240 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3242 (defun gnus-summary-update-article (article &optional iheader)
3243 "Update ARTICLE in the summary buffer."
3244 (set-buffer gnus-summary-buffer)
3245 (let* ((header (gnus-summary-article-header article))
3246 (id (mail-header-id header))
3247 (data (gnus-data-find article))
3248 (thread (gnus-id-to-thread id))
3249 (references (mail-header-references header))
3253 (when (and references
3254 (not (equal "" references)))
3257 (buffer-read-only nil)
3263 (delq thread parent)))
3264 (if (gnus-summary-insert-subject id header)
3265 ;; Set the (possibly) new article number in the data structure.
3266 (gnus-data-set-number data (gnus-id-to-article id))
3270 (defun gnus-rebuild-thread (id &optional line)
3271 "Rebuild the thread containing ID.
3272 If LINE, insert the rebuilt thread starting on line LINE."
3273 (let ((buffer-read-only nil)
3274 old-pos current thread data)
3275 (if (not gnus-show-threads)
3276 (setq thread (list (car (gnus-id-to-thread id))))
3277 ;; Get the thread this article is part of.
3278 (setq thread (gnus-remove-thread id)))
3279 (setq old-pos (gnus-point-at-bol))
3280 (setq current (save-excursion
3281 (and (zerop (forward-line -1))
3282 (gnus-summary-article-number))))
3283 ;; If this is a gathered thread, we have to go some re-gathering.
3284 (when (stringp (car thread))
3285 (let ((subject (car thread))
3287 (setq thread (cdr thread))
3289 (unless (memq (setq thr (gnus-id-to-thread
3291 (mail-header-id (caar thread)))))
3294 (setq thread (cdr thread)))
3295 ;; We now have all (unique) roots.
3296 (if (= (length roots) 1)
3297 ;; All the loose roots are now one solid root.
3298 (setq thread (car roots))
3299 (setq thread (cons subject (gnus-sort-threads roots))))))
3301 ;; We then insert this thread into the summary buffer.
3303 (goto-char (point-min))
3304 (forward-line (1- line)))
3305 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3306 (if gnus-show-threads
3307 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3308 (gnus-summary-prepare-unthreaded thread))
3309 (setq data (nreverse gnus-newsgroup-data))
3310 (setq threads gnus-newsgroup-threads))
3311 ;; We splice the new data into the data structure.
3312 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3313 ;;!!! then we want to insert at the beginning of the buffer.
3314 ;;!!! That happens to be true with Gnus now, but that may
3315 ;;!!! change in the future. Perhaps.
3316 (gnus-data-enter-list
3317 (if line nil current) data (- (point) old-pos))
3318 (setq gnus-newsgroup-threads
3319 (nconc threads gnus-newsgroup-threads))
3320 (gnus-data-compute-positions))))
3322 (defun gnus-number-to-header (number)
3323 "Return the header for article NUMBER."
3324 (let ((headers gnus-newsgroup-headers))
3326 (not (= number (mail-header-number (car headers)))))
3331 (defun gnus-parent-headers (in-headers &optional generation)
3332 "Return the headers of the GENERATIONeth parent of HEADERS."
3334 (setq generation 1))
3336 (headers in-headers)
3339 (not (zerop generation))
3340 (setq references (mail-header-references headers)))
3341 (setq headers (if (and references
3342 (setq parent (gnus-parent-id references)))
3343 (car (gnus-id-to-thread parent))
3346 (and (not (eq headers in-headers))
3349 (defun gnus-id-to-thread (id)
3350 "Return the (sub-)thread where ID appears."
3351 (gnus-gethash id gnus-newsgroup-dependencies))
3353 (defun gnus-id-to-article (id)
3354 "Return the article number of ID."
3355 (let ((thread (gnus-id-to-thread id)))
3358 (mail-header-number (car thread)))))
3360 (defun gnus-id-to-header (id)
3361 "Return the article headers of ID."
3362 (car (gnus-id-to-thread id)))
3364 (defun gnus-article-displayed-root-p (article)
3365 "Say whether ARTICLE is a root(ish) article."
3366 (let ((level (gnus-summary-thread-level article))
3367 (refs (mail-header-references (gnus-summary-article-header article)))
3373 ((null (gnus-parent-id refs)) t)
3375 (null (setq particle (gnus-id-to-article
3376 (gnus-parent-id refs))))
3377 (null (gnus-summary-thread-level particle)))))))
3379 (defun gnus-root-id (id)
3380 "Return the id of the root of the thread where ID appears."
3382 (while (and id (setq prev (car (gnus-id-to-thread id))))
3384 id (gnus-parent-id (mail-header-references prev))))
3387 (defun gnus-articles-in-thread (thread)
3388 "Return the list of articles in THREAD."
3389 (cons (mail-header-number (car thread))
3390 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3392 (defun gnus-remove-thread (id &optional dont-remove)
3393 "Remove the thread that has ID in it."
3394 (let (headers thread last-id)
3395 ;; First go up in this thread until we find the root.
3396 (setq last-id (gnus-root-id id)
3397 headers (message-flatten-list (gnus-id-to-thread last-id)))
3398 ;; We have now found the real root of this thread. It might have
3399 ;; been gathered into some loose thread, so we have to search
3400 ;; through the threads to find the thread we wanted.
3401 (let ((threads gnus-newsgroup-threads)
3404 (setq sub (car threads))
3405 (if (stringp (car sub))
3406 ;; This is a gathered thread, so we look at the roots
3407 ;; below it to find whether this article is in this
3410 (setq sub (cdr sub))
3412 (when (member (caar sub) headers)
3413 (setq thread (car threads)
3416 (setq sub (cdr sub))))
3417 ;; It's an ordinary thread, so we check it.
3418 (when (eq (car sub) (car headers))
3421 (setq threads (cdr threads)))
3422 ;; If this article is in no thread, then it's a root.
3425 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3426 (setq thread (gnus-id-to-thread last-id)))
3429 thread ; We return this thread.
3431 (if (stringp (car thread))
3433 ;; If we use dummy roots, then we have to remove the
3434 ;; dummy root as well.
3435 (when (eq gnus-summary-make-false-root 'dummy)
3436 ;; We go to the dummy root by going to
3437 ;; the first sub-"thread", and then one line up.
3438 (gnus-summary-goto-article
3439 (mail-header-number (caadr thread)))
3442 (gnus-data-compute-positions))
3443 (setq thread (cdr thread))
3445 (gnus-remove-thread-1 (car thread))
3446 (setq thread (cdr thread))))
3447 (gnus-summary-show-all-threads)
3448 (gnus-remove-thread-1 thread))))))))
3450 (defun gnus-remove-thread-1 (thread)
3451 "Remove the thread THREAD recursively."
3452 (let ((number (mail-header-number (pop thread)))
3454 (setq thread (reverse thread))
3456 (gnus-remove-thread-1 (pop thread)))
3457 (when (setq d (gnus-data-find number))
3458 (goto-char (gnus-data-pos d))
3461 (- (gnus-point-at-bol)
3463 (1+ (gnus-point-at-eol))
3464 (gnus-delete-line)))))))
3466 (defun gnus-sort-threads (threads)
3468 (if (not gnus-thread-sort-functions)
3470 (gnus-message 8 "Sorting threads...")
3472 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3473 (gnus-message 8 "Sorting threads...done"))))
3475 (defun gnus-sort-articles (articles)
3477 (when gnus-article-sort-functions
3478 (gnus-message 7 "Sorting articles...")
3480 (setq gnus-newsgroup-headers
3481 (sort articles (gnus-make-sort-function
3482 gnus-article-sort-functions)))
3483 (gnus-message 7 "Sorting articles...done"))))
3485 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3486 (defmacro gnus-thread-header (thread)
3487 ;; Return header of first article in THREAD.
3488 ;; Note that THREAD must never, ever be anything else than a variable -
3489 ;; using some other form will lead to serious barfage.
3490 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3491 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3492 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
3495 (defsubst gnus-article-sort-by-number (h1 h2)
3496 "Sort articles by article number."
3497 (< (mail-header-number h1)
3498 (mail-header-number h2)))
3500 (defun gnus-thread-sort-by-number (h1 h2)
3501 "Sort threads by root article number."
3502 (gnus-article-sort-by-number
3503 (gnus-thread-header h1) (gnus-thread-header h2)))
3505 (defsubst gnus-article-sort-by-lines (h1 h2)
3506 "Sort articles by article Lines header."
3507 (< (mail-header-lines h1)
3508 (mail-header-lines h2)))
3510 (defun gnus-thread-sort-by-lines (h1 h2)
3511 "Sort threads by root article Lines header."
3512 (gnus-article-sort-by-lines
3513 (gnus-thread-header h1) (gnus-thread-header h2)))
3515 (defsubst gnus-article-sort-by-author (h1 h2)
3516 "Sort articles by root author."
3518 (let ((addr (mime-read-field 'From h1)))
3519 (or (std11-full-name-string addr)
3520 (std11-address-string addr)
3522 (let ((addr (mime-read-field 'From h2)))
3523 (or (std11-full-name-string addr)
3524 (std11-address-string addr)
3528 (defun gnus-thread-sort-by-author (h1 h2)
3529 "Sort threads by root author."
3530 (gnus-article-sort-by-author
3531 (gnus-thread-header h1) (gnus-thread-header h2)))
3533 (defsubst gnus-article-sort-by-subject (h1 h2)
3534 "Sort articles by root subject."
3536 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3537 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3539 (defun gnus-thread-sort-by-subject (h1 h2)
3540 "Sort threads by root subject."
3541 (gnus-article-sort-by-subject
3542 (gnus-thread-header h1) (gnus-thread-header h2)))
3544 (defsubst gnus-article-sort-by-date (h1 h2)
3545 "Sort articles by root article date."
3547 (gnus-date-get-time (mail-header-date h1))
3548 (gnus-date-get-time (mail-header-date h2))))
3550 (defun gnus-thread-sort-by-date (h1 h2)
3551 "Sort threads by root article date."
3552 (gnus-article-sort-by-date
3553 (gnus-thread-header h1) (gnus-thread-header h2)))
3555 (defsubst gnus-article-sort-by-score (h1 h2)
3556 "Sort articles by root article score.
3557 Unscored articles will be counted as having a score of zero."
3558 (> (or (cdr (assq (mail-header-number h1)
3559 gnus-newsgroup-scored))
3560 gnus-summary-default-score 0)
3561 (or (cdr (assq (mail-header-number h2)
3562 gnus-newsgroup-scored))
3563 gnus-summary-default-score 0)))
3565 (defun gnus-thread-sort-by-score (h1 h2)
3566 "Sort threads by root article score."
3567 (gnus-article-sort-by-score
3568 (gnus-thread-header h1) (gnus-thread-header h2)))
3570 (defun gnus-thread-sort-by-total-score (h1 h2)
3571 "Sort threads by the sum of all scores in the thread.
3572 Unscored articles will be counted as having a score of zero."
3573 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3575 (defun gnus-thread-total-score (thread)
3576 ;; This function find the total score of THREAD.
3577 (cond ((null thread)
3580 (if (stringp (car thread))
3581 (apply gnus-thread-score-function 0
3582 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3583 (gnus-thread-total-score-1 thread)))
3585 (gnus-thread-total-score-1 (list thread)))))
3587 (defun gnus-thread-total-score-1 (root)
3588 ;; This function find the total score of the thread below ROOT.
3589 (setq root (car root))
3590 (apply gnus-thread-score-function
3592 (mapcar 'gnus-thread-total-score
3593 (cdr (gnus-id-to-thread (mail-header-id root))))
3594 (when (> (mail-header-number root) 0)
3595 (list (or (cdr (assq (mail-header-number root)
3596 gnus-newsgroup-scored))
3597 gnus-summary-default-score 0))))
3598 (list gnus-summary-default-score)
3601 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3602 (defvar gnus-tmp-prev-subject nil)
3603 (defvar gnus-tmp-false-parent nil)
3604 (defvar gnus-tmp-root-expunged nil)
3605 (defvar gnus-tmp-dummy-line nil)
3607 (defvar gnus-tmp-header)
3608 (defun gnus-extra-header (type &optional header)
3609 "Return the extra header of TYPE."
3610 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
3613 (defun gnus-summary-prepare-threads (threads)
3614 "Prepare summary buffer from THREADS and indentation LEVEL.
3615 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3616 or a straight list of headers."
3617 (gnus-message 7 "Generating summary...")
3619 (setq gnus-newsgroup-threads threads)
3622 (let ((gnus-tmp-level 0)
3623 (default-score (or gnus-summary-default-score 0))
3624 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3625 thread number subject stack state gnus-tmp-gathered beg-match
3626 new-roots gnus-tmp-new-adopts thread-end
3627 gnus-tmp-header gnus-tmp-unread
3628 gnus-tmp-replied gnus-tmp-subject-or-nil
3629 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3630 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3631 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3633 (setq gnus-tmp-prev-subject nil)
3635 (if (vectorp (car threads))
3636 ;; If this is a straight (sic) list of headers, then a
3637 ;; threaded summary display isn't required, so we just create
3638 ;; an unthreaded one.
3639 (gnus-summary-prepare-unthreaded threads)
3641 ;; Do the threaded display.
3643 (while (or threads stack gnus-tmp-new-adopts new-roots)
3645 (if (and (= gnus-tmp-level 0)
3648 (not gnus-tmp-false-parent)
3649 (or gnus-tmp-new-adopts new-roots))
3650 (if gnus-tmp-new-adopts
3651 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3652 thread (list (car gnus-tmp-new-adopts))
3653 gnus-tmp-header (caar thread)
3654 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3656 (setq thread (list (car new-roots))
3657 gnus-tmp-header (caar thread)
3658 new-roots (cdr new-roots))))
3661 ;; If there are some threads, we do them before the
3662 ;; threads on the stack.
3663 (setq thread threads
3664 gnus-tmp-header (caar thread))
3665 ;; There were no current threads, so we pop something off
3667 (setq state (car stack)
3668 gnus-tmp-level (car state)
3671 gnus-tmp-header (caar thread))))
3673 (setq gnus-tmp-false-parent nil)
3674 (setq gnus-tmp-root-expunged nil)
3675 (setq thread-end nil)
3677 (if (stringp gnus-tmp-header)
3678 ;; The header is a dummy root.
3680 ((eq gnus-summary-make-false-root 'adopt)
3681 ;; We let the first article adopt the rest.
3682 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3684 (setq gnus-tmp-gathered
3686 (lambda (h) (mail-header-number (car h)))
3689 (setq thread (cons (list (caar thread)
3692 (setq gnus-tmp-level -1
3693 gnus-tmp-false-parent t))
3694 ((eq gnus-summary-make-false-root 'empty)
3695 ;; We print adopted articles with empty subject fields.
3696 (setq gnus-tmp-gathered
3698 (lambda (h) (mail-header-number (car h)))
3701 (setq gnus-tmp-level -1))
3702 ((eq gnus-summary-make-false-root 'dummy)
3703 ;; We remember that we probably want to output a dummy
3705 (setq gnus-tmp-dummy-line gnus-tmp-header)
3706 (setq gnus-tmp-prev-subject gnus-tmp-header))
3708 ;; We do not make a root for the gathered
3709 ;; sub-threads at all.
3710 (setq gnus-tmp-level -1)))
3712 (setq number (mail-header-number gnus-tmp-header)
3713 subject (mail-header-subject gnus-tmp-header))
3716 ;; If the thread has changed subject, we might want to make
3717 ;; this subthread into a root.
3718 ((and (null gnus-thread-ignore-subject)
3719 (not (zerop gnus-tmp-level))
3720 gnus-tmp-prev-subject
3722 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3723 (setq new-roots (nconc new-roots (list (car thread)))
3725 gnus-tmp-header nil))
3726 ;; If the article lies outside the current limit,
3727 ;; then we do not display it.
3728 ((not (memq number gnus-newsgroup-limit))
3729 (setq gnus-tmp-gathered
3731 (lambda (h) (mail-header-number (car h)))
3734 (setq gnus-tmp-new-adopts (if (cdar thread)
3735 (append gnus-tmp-new-adopts
3737 gnus-tmp-new-adopts)
3739 gnus-tmp-header nil)
3740 (when (zerop gnus-tmp-level)
3741 (setq gnus-tmp-root-expunged t)))
3742 ;; Perhaps this article is to be marked as read?
3743 ((and gnus-summary-mark-below
3744 (< (or (cdr (assq number gnus-newsgroup-scored))
3746 gnus-summary-mark-below)
3747 ;; Don't touch sparse articles.
3748 (not (gnus-summary-article-sparse-p number))
3749 (not (gnus-summary-article-ancient-p number)))
3750 (setq gnus-newsgroup-unreads
3751 (delq number gnus-newsgroup-unreads))
3752 (if gnus-newsgroup-auto-expire
3753 (push number gnus-newsgroup-expirable)
3754 (push (cons number gnus-low-score-mark)
3755 gnus-newsgroup-reads))))
3757 (when gnus-tmp-header
3758 ;; We may have an old dummy line to output before this
3760 (when (and gnus-tmp-dummy-line
3763 (mail-header-subject gnus-tmp-header)))
3764 (gnus-summary-insert-dummy-line
3765 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3766 (setq gnus-tmp-dummy-line nil))
3768 ;; Compute the mark.
3769 (setq gnus-tmp-unread (gnus-article-mark number))
3771 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3772 gnus-tmp-header gnus-tmp-level)
3773 gnus-newsgroup-data)
3775 ;; Actually insert the line.
3777 gnus-tmp-subject-or-nil
3779 ((and gnus-thread-ignore-subject
3780 gnus-tmp-prev-subject
3781 (not (inline (gnus-subject-equal
3782 gnus-tmp-prev-subject subject))))
3784 ((zerop gnus-tmp-level)
3785 (if (and (eq gnus-summary-make-false-root 'empty)
3786 (memq number gnus-tmp-gathered)
3787 gnus-tmp-prev-subject
3788 (inline (gnus-subject-equal
3789 gnus-tmp-prev-subject subject)))
3790 gnus-summary-same-subject
3792 (t gnus-summary-same-subject)))
3793 (if (and (eq gnus-summary-make-false-root 'adopt)
3794 (= gnus-tmp-level 1)
3795 (memq number gnus-tmp-gathered))
3796 (setq gnus-tmp-opening-bracket ?\<
3797 gnus-tmp-closing-bracket ?\>)
3798 (setq gnus-tmp-opening-bracket ?\[
3799 gnus-tmp-closing-bracket ?\]))
3801 gnus-tmp-indentation
3802 (aref gnus-thread-indent-array gnus-tmp-level)
3803 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3804 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3805 gnus-summary-default-score 0)
3807 (if (or (null gnus-summary-default-score)
3808 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3809 gnus-summary-zcore-fuzz))
3811 (if (< gnus-tmp-score gnus-summary-default-score)
3812 gnus-score-below-mark gnus-score-over-mark))
3814 (cond ((memq number gnus-newsgroup-processable)
3816 ((memq number gnus-newsgroup-cached)
3818 ((memq number gnus-newsgroup-replied)
3820 ((memq number gnus-newsgroup-saved)
3822 (t gnus-unread-mark))
3823 gnus-tmp-from (mail-header-from gnus-tmp-header)
3826 ((string-match "<[^>]+> *$" gnus-tmp-from)
3827 (setq beg-match (match-beginning 0))
3828 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3829 (substring gnus-tmp-from (1+ (match-beginning 0))
3830 (1- (match-end 0))))
3831 (substring gnus-tmp-from 0 beg-match)))
3832 ((string-match "(.+)" gnus-tmp-from)
3833 (substring gnus-tmp-from
3834 (1+ (match-beginning 0)) (1- (match-end 0))))
3836 (when (string= gnus-tmp-name "")
3837 (setq gnus-tmp-name gnus-tmp-from))
3838 (unless (numberp gnus-tmp-lines)
3839 (setq gnus-tmp-lines 0))
3840 (gnus-put-text-property
3842 (progn (eval gnus-summary-line-format-spec) (point))
3843 'gnus-number number)
3846 (gnus-run-hooks 'gnus-summary-update-hook)
3849 (setq gnus-tmp-prev-subject subject)))
3851 (when (nth 1 thread)
3852 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3853 (incf gnus-tmp-level)
3854 (setq threads (if thread-end nil (cdar thread)))
3856 (setq gnus-tmp-level 0)))))
3857 (gnus-message 7 "Generating summary...done"))
3859 (defun gnus-summary-prepare-unthreaded (headers)
3860 "Generate an unthreaded summary buffer based on HEADERS."
3861 (let (header number mark)
3866 ;; We may have to root out some bad articles...
3867 (when (memq (setq number (mail-header-number
3868 (setq header (pop headers))))
3869 gnus-newsgroup-limit)
3870 ;; Mark article as read when it has a low score.
3871 (when (and gnus-summary-mark-below
3872 (< (or (cdr (assq number gnus-newsgroup-scored))
3873 gnus-summary-default-score 0)
3874 gnus-summary-mark-below)
3875 (not (gnus-summary-article-ancient-p number)))
3876 (setq gnus-newsgroup-unreads
3877 (delq number gnus-newsgroup-unreads))
3878 (if gnus-newsgroup-auto-expire
3879 (push number gnus-newsgroup-expirable)
3880 (push (cons number gnus-low-score-mark)
3881 gnus-newsgroup-reads)))
3883 (setq mark (gnus-article-mark number))
3884 (push (gnus-data-make number mark (1+ (point)) header 0)
3885 gnus-newsgroup-data)
3886 (gnus-summary-insert-line
3888 mark (memq number gnus-newsgroup-replied)
3889 (memq number gnus-newsgroup-expirable)
3890 (mail-header-subject header) nil
3891 (cdr (assq number gnus-newsgroup-scored))
3892 (memq number gnus-newsgroup-processable))))))
3894 (defun gnus-select-newsgroup (group &optional read-all select-articles)
3895 "Select newsgroup GROUP.
3896 If READ-ALL is non-nil, all articles in the group are selected.
3897 If SELECT-ARTICLES, only select those articles from GROUP."
3898 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3899 ;;!!! Dirty hack; should be removed.
3900 (gnus-summary-ignore-duplicates
3901 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
3903 gnus-summary-ignore-duplicates))
3904 (info (nth 2 entry))
3905 articles fetched-articles cached)
3907 (unless (gnus-check-server
3908 (setq gnus-current-select-method
3909 (gnus-find-method-for-group group)))
3910 (error "Couldn't open server"))
3912 (or (and entry (not (eq (car entry) t))) ; Either it's active...
3913 (gnus-activate-group group) ; Or we can activate it...
3914 (progn ; Or we bug out.
3915 (when (equal major-mode 'gnus-summary-mode)
3916 (kill-buffer (current-buffer)))
3917 (error "Couldn't request group %s: %s"
3918 group (gnus-status-message group))))
3920 (unless (gnus-request-group group t)
3921 (when (equal major-mode 'gnus-summary-mode)
3922 (kill-buffer (current-buffer)))
3923 (error "Couldn't request group %s: %s"
3924 group (gnus-status-message group)))
3926 (setq gnus-newsgroup-name group)
3927 (setq gnus-newsgroup-unselected nil)
3928 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
3930 ;; Adjust and set lists of article marks.
3932 (gnus-adjust-marked-articles info))
3934 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3935 (when (gnus-virtual-group-p group)
3936 (setq cached gnus-newsgroup-cached))
3938 (setq gnus-newsgroup-unreads
3939 (gnus-set-difference
3940 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
3941 gnus-newsgroup-dormant))
3943 (setq gnus-newsgroup-processable nil)
3945 (gnus-update-read-articles group gnus-newsgroup-unreads)
3947 (if (setq articles select-articles)
3948 (setq gnus-newsgroup-unselected
3949 (gnus-sorted-intersection
3950 gnus-newsgroup-unreads
3951 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
3952 (setq articles (gnus-articles-to-read group read-all)))
3956 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
3958 ((eq articles 0) nil)
3960 ;; Init the dependencies hash table.
3961 (setq gnus-newsgroup-dependencies
3962 (gnus-make-hashtable (length articles)))
3963 (gnus-set-global-variables)
3964 ;; Retrieve the headers and read them in.
3965 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
3966 (setq gnus-newsgroup-headers
3968 (setq gnus-headers-retrieved-by
3969 (gnus-retrieve-headers
3970 articles gnus-newsgroup-name
3971 ;; We might want to fetch old headers, but
3972 ;; not if there is only 1 article.
3974 (not (eq gnus-fetch-old-headers 'some))
3975 (not (numberp gnus-fetch-old-headers)))
3976 (> (length articles) 1))
3977 gnus-fetch-old-headers))))
3978 (gnus-get-newsgroup-headers-xover
3979 articles nil nil gnus-newsgroup-name t)
3980 (gnus-get-newsgroup-headers)))
3981 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
3983 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3985 (setq gnus-newsgroup-cached cached))
3987 ;; Suppress duplicates?
3988 (when gnus-suppress-duplicates
3989 (gnus-dup-suppress-articles))
3991 ;; Set the initial limit.
3992 (setq gnus-newsgroup-limit (copy-sequence articles))
3993 ;; Remove canceled articles from the list of unread articles.
3994 (setq gnus-newsgroup-unreads
3995 (gnus-set-sorted-intersection
3996 gnus-newsgroup-unreads
3997 (setq fetched-articles
3998 (mapcar (lambda (headers) (mail-header-number headers))
3999 gnus-newsgroup-headers))))
4000 ;; Removed marked articles that do not exist.
4001 (gnus-update-missing-marks
4002 (gnus-sorted-complement fetched-articles articles))
4003 ;; We might want to build some more threads first.
4004 (when (and gnus-fetch-old-headers
4005 (eq gnus-headers-retrieved-by 'nov))
4006 (if (eq gnus-fetch-old-headers 'invisible)
4007 (gnus-build-all-threads)
4008 (gnus-build-old-threads)))
4009 ;; Let the Gnus agent mark articles as read.
4011 (gnus-agent-get-undownloaded-list))
4012 ;; Check whether auto-expire is to be done in this group.
4013 (setq gnus-newsgroup-auto-expire
4014 (gnus-group-auto-expirable-p group))
4015 ;; Set up the article buffer now, if necessary.
4016 (unless gnus-single-article-buffer
4017 (gnus-article-setup-buffer))
4018 ;; First and last article in this newsgroup.
4019 (when gnus-newsgroup-headers
4020 (setq gnus-newsgroup-begin
4021 (mail-header-number (car gnus-newsgroup-headers))
4024 (gnus-last-element gnus-newsgroup-headers))))
4025 ;; GROUP is successfully selected.
4026 (or gnus-newsgroup-headers t)))))
4028 (defun gnus-articles-to-read (group &optional read-all)
4029 ;; Find out what articles the user wants to read.
4031 ;; Select all articles if `read-all' is non-nil, or if there
4032 ;; are no unread articles.
4034 (and (zerop (length gnus-newsgroup-marked))
4035 (zerop (length gnus-newsgroup-unreads)))
4036 (eq (gnus-group-find-parameter group 'display)
4038 (gnus-uncompress-range (gnus-active group))
4039 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4040 (copy-sequence gnus-newsgroup-unreads))
4042 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4043 (scored (length scored-list))
4044 (number (length articles))
4045 (marked (+ (length gnus-newsgroup-marked)
4046 (length gnus-newsgroup-dormant)))
4054 ((and (or (<= scored marked) (= scored number))
4055 (numberp gnus-large-newsgroup)
4056 (> number gnus-large-newsgroup))
4060 "How many articles from %s (default %d): "
4061 (gnus-limit-string gnus-newsgroup-name 35)
4063 (if (string-match "^[ \t]*$" input) number input)))
4064 ((and (> scored marked) (< scored number)
4065 (> (- scored number) 20))
4068 (format "%s %s (%d scored, %d total): "
4069 "How many articles from"
4070 group scored number))))
4071 (if (string-match "^[ \t]*$" input)
4075 (setq select (if (stringp select) (string-to-number select) select))
4076 (if (or (null select) (zerop select))
4078 (if (and (not (zerop scored)) (<= (abs select) scored))
4080 (setq articles (sort scored-list '<))
4081 (setq number (length articles)))
4082 (setq articles (copy-sequence articles)))
4084 (when (< (abs select) number)
4086 ;; Select the N oldest articles.
4087 (setcdr (nthcdr (1- (abs select)) articles) nil)
4088 ;; Select the N most recent articles.
4089 (setq articles (nthcdr (- number select) articles))))
4090 (setq gnus-newsgroup-unselected
4091 (gnus-sorted-intersection
4092 gnus-newsgroup-unreads
4093 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4096 (defun gnus-killed-articles (killed articles)
4099 (when (inline (gnus-member-of-range (car articles) killed))
4100 (push (car articles) out))
4101 (setq articles (cdr articles)))
4104 (defun gnus-uncompress-marks (marks)
4105 "Uncompress the mark ranges in MARKS."
4106 (let ((uncompressed '(score bookmark))
4109 (if (memq (caar marks) uncompressed)
4110 (push (car marks) out)
4111 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4112 (setq marks (cdr marks)))
4115 (defun gnus-adjust-marked-articles (info)
4116 "Set all article lists and remove all marks that are no longer legal."
4117 (let* ((marked-lists (gnus-info-marks info))
4118 (active (gnus-active (gnus-info-group info)))
4121 (types gnus-article-mark-lists)
4122 (uncompressed '(score bookmark killed))
4123 marks var articles article mark)
4126 (setq marks (pop marked-lists))
4127 (set (setq var (intern (format "gnus-newsgroup-%s"
4128 (car (rassq (setq mark (car marks))
4130 (if (memq (car marks) uncompressed) (cdr marks)
4131 (gnus-uncompress-range (cdr marks))))
4133 (setq articles (symbol-value var))
4135 ;; All articles have to be subsets of the active articles.
4137 ;; Adjust "simple" lists.
4138 ((memq mark '(tick dormant expire reply save))
4140 (when (or (< (setq article (pop articles)) min) (> article max))
4141 (set var (delq article (symbol-value var))))))
4143 ((memq mark uncompressed)
4144 (when (not (listp (cdr (symbol-value var))))
4145 (set var (list (symbol-value var))))
4146 (when (not (listp (cdr articles)))
4147 (setq articles (list articles)))
4149 (when (or (not (consp (setq article (pop articles))))
4150 (< (car article) min)
4151 (> (car article) max))
4152 (set var (delq article (symbol-value var))))))))))
4154 (defun gnus-update-missing-marks (missing)
4155 "Go through the list of MISSING articles and remove them from the mark lists."
4157 (let ((types gnus-article-mark-lists)
4159 ;; Go through all types.
4161 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4162 (when (symbol-value var)
4163 ;; This list has articles. So we delete all missing articles
4167 (set var (delq (pop m) (symbol-value var)))))))))
4169 (defun gnus-update-marks ()
4170 "Enter the various lists of marked articles into the newsgroup info list."
4171 (let ((types gnus-article-mark-lists)
4172 (info (gnus-get-info gnus-newsgroup-name))
4173 (uncompressed '(score bookmark killed))
4174 type list newmarked symbol delta-marks)
4176 ;; Add all marks lists that are non-nil to the list of marks lists.
4177 (while (setq type (pop types))
4178 (when (setq list (symbol-value
4180 (intern (format "gnus-newsgroup-%s"
4183 ;; Get rid of the entries of the articles that have the
4185 (when (and (eq (cdr type) 'score)
4189 (prev (cons nil list))
4192 (if (or (not (consp (car arts)))
4193 (= (cdar arts) gnus-summary-default-score))
4194 (setcdr prev (cdr arts))
4196 (setq arts (cdr arts)))
4197 (setq list (cdr all))))
4199 (push (cons (cdr type)
4200 (if (memq (cdr type) uncompressed) list
4201 (gnus-compress-sequence
4202 (set symbol (sort list '<)) t)))
4205 ;; Enter these new marks into the info of the group.
4207 (setcar (nthcdr 3 info) newmarked)
4208 ;; Add the marks lists to the end of the info.
4210 (setcdr (nthcdr 2 info) (list newmarked))))
4212 ;; Cut off the end of the info if there's nothing else there.
4216 (when (nthcdr (decf i) info)
4217 (setcdr (nthcdr i info) nil)))))))
4219 (defun gnus-set-mode-line (where)
4220 "This function sets the mode line of the article or summary buffers.
4221 If WHERE is `summary', the summary mode line format will be used."
4222 ;; Is this mode line one we keep updated?
4223 (when (and (memq where gnus-updated-mode-lines)
4225 (intern (format "gnus-%s-mode-line-format-spec" where))))
4228 ;; We evaluate this in the summary buffer since these
4229 ;; variables are buffer-local to that buffer.
4230 (set-buffer gnus-summary-buffer)
4231 ;; We bind all these variables that are used in the `eval' form
4233 (let* ((mformat (symbol-value
4235 (format "gnus-%s-mode-line-format-spec" where))))
4236 (gnus-tmp-group-name gnus-newsgroup-name)
4237 (gnus-tmp-article-number (or gnus-current-article 0))
4238 (gnus-tmp-unread gnus-newsgroup-unreads)
4239 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4240 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4241 (gnus-tmp-unread-and-unselected
4242 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4243 (zerop gnus-tmp-unselected))
4245 ((zerop gnus-tmp-unselected)
4246 (format "{%d more}" gnus-tmp-unread-and-unticked))
4247 (t (format "{%d(+%d) more}"
4248 gnus-tmp-unread-and-unticked
4249 gnus-tmp-unselected))))
4251 (if (and gnus-current-headers
4252 (vectorp gnus-current-headers))
4253 (gnus-mode-string-quote
4254 (mail-header-subject gnus-current-headers))
4256 bufname-length max-len
4257 gnus-tmp-header);; passed as argument to any user-format-funcs
4258 (setq mode-string (eval mformat))
4259 (setq bufname-length (if (string-match "%b" mode-string)
4262 (if (eq where 'summary)
4264 (get-buffer gnus-article-buffer))))
4267 (setq max-len (max 4 (if gnus-mode-non-string-length
4269 gnus-mode-non-string-length
4271 (length mode-string))))
4272 ;; We might have to chop a bit of the string off...
4273 (when (> (length mode-string) max-len)
4275 (concat (gnus-truncate-string mode-string (- max-len 3))
4277 ;; Pad the mode string a bit.
4278 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4279 ;; Update the mode line.
4280 (setq mode-line-buffer-identification
4281 (gnus-mode-line-buffer-identification (list mode-string)))
4282 (set-buffer-modified-p t))))
4284 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4285 "Go through the HEADERS list and add all Xrefs to a hash table.
4286 The resulting hash table is returned, or nil if no Xrefs were found."
4287 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4288 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4289 (xref-hashtb (gnus-make-hashtable))
4290 start group entry number xrefs header)
4292 (setq header (pop headers))
4293 (when (and (setq xrefs (mail-header-xref header))
4294 (not (memq (setq number (mail-header-number header))
4297 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4298 (setq start (match-end 0))
4299 (setq group (if prefix
4300 (concat prefix (substring xrefs (match-beginning 1)
4302 (substring xrefs (match-beginning 1) (match-end 1))))
4304 (string-to-int (substring xrefs (match-beginning 2)
4306 (if (setq entry (gnus-gethash group xref-hashtb))
4307 (setcdr entry (cons number (cdr entry)))
4308 (gnus-sethash group (cons number nil) xref-hashtb)))))
4309 (and start xref-hashtb)))
4311 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4312 "Look through all the headers and mark the Xrefs as read."
4313 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4314 name entry info xref-hashtb idlist method nth4)
4316 (set-buffer gnus-group-buffer)
4317 (when (setq xref-hashtb
4318 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4321 (unless (string= from-newsgroup (setq name (symbol-name group)))
4322 (setq idlist (symbol-value group))
4323 ;; Dead groups are not updated.
4325 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4327 (when (stringp (setq nth4 (gnus-info-method info)))
4328 (setq nth4 (gnus-server-to-method nth4))))
4329 ;; Only do the xrefs if the group has the same
4330 ;; select method as the group we have just read.
4331 (or (gnus-methods-equal-p
4332 nth4 (gnus-find-method-for-group from-newsgroup))
4334 (equal nth4 (setq method (gnus-find-method-for-group
4336 (and (equal (car nth4) (car method))
4337 (equal (nth 1 nth4) (nth 1 method))))
4338 gnus-use-cross-reference
4339 (or (not (eq gnus-use-cross-reference t))
4341 ;; Only do cross-references on subscribed
4342 ;; groups, if that is what is wanted.
4343 (<= (gnus-info-level info) gnus-level-subscribed))
4344 (gnus-group-make-articles-read name idlist))))
4347 (defun gnus-compute-read-articles (group articles)
4348 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4349 (info (nth 2 entry))
4350 (active (gnus-active group))
4353 ;; First peel off all illegal article numbers.
4355 (let ((ids articles)
4357 (while (setq id (pop ids))
4358 (when (and first (> id (cdr active)))
4359 ;; We'll end up in this situation in one particular
4360 ;; obscure situation. If you re-scan a group and get
4361 ;; a new article that is cross-posted to a different
4362 ;; group that has not been re-scanned, you might get
4363 ;; crossposted article that has a higher number than
4364 ;; Gnus believes possible. So we re-activate this
4365 ;; group as well. This might mean doing the
4366 ;; crossposting thingy will *increase* the number
4367 ;; of articles in some groups. Tsk, tsk.
4368 (setq active (or (gnus-activate-group group) active)))
4369 (when (or (> id (cdr active))
4370 (< id (car active)))
4371 (setq articles (delq id articles))))))
4372 ;; If the read list is nil, we init it.
4374 (null (gnus-info-read info))
4376 (setq ninfo (cons 1 (1- (car active))))
4377 (setq ninfo (gnus-info-read info)))
4378 ;; Then we add the read articles to the range.
4380 ninfo (setq articles (sort articles '<))))))
4382 (defun gnus-group-make-articles-read (group articles)
4383 "Update the info of GROUP to say that ARTICLES are read."
4385 (entry (gnus-gethash group gnus-newsrc-hashtb))
4386 (info (nth 2 entry))
4387 (active (gnus-active group))
4390 (setq range (gnus-compute-read-articles group articles))
4392 (set-buffer gnus-group-buffer)
4395 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4396 (gnus-info-set-read ',info ',(gnus-info-read info))
4397 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4398 (gnus-group-update-group ,group t))))
4399 ;; Add the read articles to the range.
4400 (gnus-info-set-read info range)
4401 ;; Then we have to re-compute how many unread
4402 ;; articles there are in this group.
4406 (setq num (- (1+ (cdr active)) (car active))))
4407 ((not (listp (cdr range)))
4408 (setq num (- (cdr active) (- (1+ (cdr range))
4412 (if (numberp (car range))
4414 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4415 (setq range (cdr range)))
4416 (setq num (- (cdr active) num))))
4417 ;; Update the number of unread articles.
4419 ;; Update the group buffer.
4420 (gnus-group-update-group group t)))))
4422 (defun gnus-methods-equal-p (m1 m2)
4423 (let ((m1 (or m1 gnus-select-method))
4424 (m2 (or m2 gnus-select-method)))
4426 (and (eq (car m1) (car m2))
4427 (or (not (memq 'address (assoc (symbol-name (car m1))
4428 gnus-valid-select-methods)))
4429 (equal (nth 1 m1) (nth 1 m2)))))))
4431 (defvar gnus-newsgroup-none-id 0)
4433 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4434 (let ((cur nntp-server-buffer)
4437 (save-excursion (set-buffer gnus-summary-buffer)
4438 gnus-newsgroup-dependencies)))
4441 (set-buffer nntp-server-buffer)
4442 ;; Translate all TAB characters into SPACE characters.
4443 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4444 (gnus-run-hooks 'gnus-parse-headers-hook)
4445 (let ((case-fold-search t)
4446 in-reply-to header p lines chars ctype)
4447 (goto-char (point-min))
4448 ;; Search to the beginning of the next header. Error messages
4449 ;; do not begin with 2 or 3.
4450 (while (re-search-forward "^[23][0-9]+ " nil t)
4453 ;; This implementation of this function, with nine
4454 ;; search-forwards instead of the one re-search-forward and
4455 ;; a case (which basically was the old function) is actually
4456 ;; about twice as fast, even though it looks messier. You
4457 ;; can't have everything, I guess. Speed and elegance
4458 ;; doesn't always go hand in hand.
4461 (make-full-mail-header
4467 (narrow-to-region (point)
4468 (or (and (search-forward "\n.\n" nil t)
4474 (if (search-forward "\nsubject: " nil t)
4475 (buffer-substring (match-end 0) (std11-field-end))
4480 (if (search-forward "\nfrom: " nil t)
4481 (buffer-substring (match-end 0) (std11-field-end))
4486 (if (search-forward "\ndate: " nil t)
4487 (buffer-substring (match-end 0) (std11-field-end))
4492 (setq id (if (re-search-forward
4493 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4494 ;; We do it this way to make sure the Message-ID
4495 ;; is (somewhat) syntactically valid.
4496 (buffer-substring (match-beginning 1)
4498 ;; If there was no message-id, we just fake one
4499 ;; to make subsequent routines simpler.
4500 (nnheader-generate-fake-message-id))))
4504 (if (search-forward "\nreferences: " nil t)
4508 (buffer-substring (match-end 0) (std11-field-end))
4513 (search-backward ">" end t)
4516 (search-backward "<" end t)
4518 ;; Get the references from the in-reply-to header if there
4519 ;; were no references and the in-reply-to header looks
4521 (if (and (search-forward "\nin-reply-to: " nil t)
4523 (buffer-substring (match-end 0)
4525 (string-match "<[^>]+>" in-reply-to))
4527 (setq ref (substring in-reply-to (match-beginning 0)
4529 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4530 (setq ref2 (substring in-reply-to (match-beginning 0)
4532 (when (> (length ref2) (length ref))
4539 (if (search-forward "\nchars: " nil t)
4540 (if (numberp (setq chars (ignore-errors (read cur))))
4546 (if (search-forward "\nlines: " nil t)
4547 (if (numberp (setq lines (ignore-errors (read cur))))
4553 (and (search-forward "\nxref: " nil t)
4554 (buffer-substring (match-end 0) (std11-field-end))))
4556 (when gnus-extra-headers
4557 (let ((extra gnus-extra-headers)
4561 (when (search-forward
4562 (concat "\n" (symbol-name (car extra)) ": ") nil t)
4563 (push (cons (car extra)
4564 (buffer-substring (match-end 0)
4570 (if (and (search-forward "\ncontent-type: " nil t)
4572 (buffer-substring (match-end 0) (std11-field-end))))
4573 (mime-entity-set-content-type-internal
4574 header (mime-parse-Content-Type ctype)))
4575 (when (equal id ref)
4578 (when gnus-alter-header-function
4579 (funcall gnus-alter-header-function header)
4580 (setq id (mail-header-id header)
4581 ref (gnus-parent-id (mail-header-references header))))
4584 (gnus-dependencies-add-header
4585 header dependencies force-new))
4586 (push header headers))
4587 (goto-char (point-max))
4589 (nreverse headers)))))
4591 ;; Goes through the xover lines and returns a list of vectors
4592 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4593 force-new dependencies
4594 group also-fetch-heads)
4595 "Parse the news overview data in the server buffer, and return a
4596 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4597 ;; Get the Xref when the users reads the articles since most/some
4598 ;; NNTP servers do not include Xrefs when using XOVER.
4599 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4600 (let ((cur nntp-server-buffer)
4601 (dependencies (or dependencies gnus-newsgroup-dependencies))
4602 number headers header)
4604 (set-buffer nntp-server-buffer)
4605 ;; Allow the user to mangle the headers before parsing them.
4606 (gnus-run-hooks 'gnus-parse-headers-hook)
4607 (goto-char (point-min))
4610 (while (and sequence (not (eobp)))
4611 (setq number (read cur))
4612 (while (and sequence
4613 (< (car sequence) number))
4614 (setq sequence (cdr sequence)))
4616 (eq number (car sequence))
4618 (setq sequence (cdr sequence))
4619 (setq header (inline
4620 (gnus-nov-parse-line
4621 number dependencies force-new))))
4622 (push header headers))
4625 (gnus-error 4 "Strange nov line (%d)"
4626 (count-lines (point-min) (point)))))
4628 ;; A common bug in inn is that if you have posted an article and
4629 ;; then retrieves the active file, it will answer correctly --
4630 ;; the new article is included. However, a NOV entry for the
4631 ;; article may not have been generated yet, so this may fail.
4632 ;; We work around this problem by retrieving the last few
4633 ;; headers using HEAD.
4634 (if (or (not also-fetch-heads)
4636 ;; We (probably) got all the headers.
4638 (let ((gnus-nov-is-evil t))
4641 (when (gnus-retrieve-headers sequence group)
4642 (gnus-get-newsgroup-headers))))))))
4644 (defun gnus-article-get-xrefs ()
4645 "Fill in the Xref value in `gnus-current-headers', if necessary.
4646 This is meant to be called in `gnus-article-internal-prepare-hook'."
4647 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4648 gnus-current-headers)))
4649 (or (not gnus-use-cross-reference)
4651 (and (mail-header-xref headers)
4652 (not (string= (mail-header-xref headers) "")))
4653 (let ((case-fold-search t)
4656 (nnheader-narrow-to-headers)
4657 (goto-char (point-min))
4658 (when (or (and (eq (downcase (char-after)) ?x)
4659 (looking-at "Xref:"))
4660 (search-forward "\nXref:" nil t))
4661 (goto-char (1+ (match-end 0)))
4662 (setq xref (buffer-substring (point)
4663 (progn (end-of-line) (point))))
4664 (mail-header-set-xref headers xref)))))))
4666 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4667 "Find article ID and insert the summary line for that article.
4668 OLD-HEADER can either be a header or a line number to insert
4669 the subject line on."
4670 (let* ((line (and (numberp old-header) old-header))
4671 (old-header (and (vectorp old-header) old-header))
4672 (header (cond ((and old-header use-old-header)
4675 (gnus-number-to-header id))
4676 (gnus-number-to-header id))
4678 (gnus-read-header id))))
4679 (number (and (numberp id) id))
4682 ;; Rebuild the thread that this article is part of and go to the
4683 ;; article we have fetched.
4684 (when (and (not gnus-show-threads)
4687 (setq d (gnus-data-find (mail-header-number old-header))))
4688 (goto-char (gnus-data-pos d))
4691 (- (gnus-point-at-bol)
4693 (1+ (gnus-point-at-eol))
4694 (gnus-delete-line))))))
4696 (mail-header-set-number header (mail-header-number old-header)))
4697 (setq gnus-newsgroup-sparse
4698 (delq (setq number (mail-header-number header))
4699 gnus-newsgroup-sparse))
4700 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4701 (push number gnus-newsgroup-limit)
4702 (gnus-rebuild-thread (mail-header-id header) line)
4703 (gnus-summary-goto-subject number nil t))
4704 (when (and (numberp number)
4706 ;; We have to update the boundaries even if we can't fetch the
4707 ;; article if ID is a number -- so that the next `P' or `N'
4708 ;; command will fetch the previous (or next) article even
4709 ;; if the one we tried to fetch this time has been canceled.
4710 (when (> number gnus-newsgroup-end)
4711 (setq gnus-newsgroup-end number))
4712 (when (< number gnus-newsgroup-begin)
4713 (setq gnus-newsgroup-begin number))
4714 (setq gnus-newsgroup-unselected
4715 (delq number gnus-newsgroup-unselected)))
4716 ;; Report back a success?
4717 (and header (mail-header-number header))))
4719 ;;; Process/prefix in the summary buffer
4721 (defun gnus-summary-work-articles (n)
4722 "Return a list of articles to be worked upon.
4723 The prefix argument, the list of process marked articles, and the
4724 current article will be taken into consideration."
4726 (set-buffer gnus-summary-buffer)
4729 ;; A numerical prefix has been given.
4730 (setq n (prefix-numeric-value n))
4731 (let ((backward (< n 0))
4732 (n (abs (prefix-numeric-value n)))
4737 (push (setq article (gnus-summary-article-number))
4740 (gnus-summary-find-prev nil article)
4741 (gnus-summary-find-next nil article)))
4743 (nreverse articles)))
4744 ((and (gnus-region-active-p) (mark))
4745 (message "region active")
4746 ;; Work on the region between point and mark.
4747 (let ((max (max (point) (mark)))
4750 (goto-char (min (point) (mark)))
4753 (push (setq article (gnus-summary-article-number)) articles)
4754 (gnus-summary-find-next nil article)
4756 (nreverse articles))))
4757 (gnus-newsgroup-processable
4758 ;; There are process-marked articles present.
4759 ;; Save current state.
4760 (gnus-summary-save-process-mark)
4762 (reverse gnus-newsgroup-processable))
4764 ;; Just return the current article.
4765 (list (gnus-summary-article-number))))))
4767 (defmacro gnus-summary-iterate (arg &rest forms)
4768 "Iterate over the process/prefixed articles and do FORMS.
4769 ARG is the interactive prefix given to the command. FORMS will be
4770 executed with point over the summary line of the articles."
4771 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
4772 `(let ((,articles (gnus-summary-work-articles ,arg)))
4774 (gnus-summary-goto-subject (car ,articles))
4777 (put 'gnus-summary-iterate 'lisp-indent-function 1)
4778 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
4780 (defun gnus-summary-save-process-mark ()
4781 "Push the current set of process marked articles on the stack."
4783 (push (copy-sequence gnus-newsgroup-processable)
4784 gnus-newsgroup-process-stack))
4786 (defun gnus-summary-kill-process-mark ()
4787 "Push the current set of process marked articles on the stack and unmark."
4789 (gnus-summary-save-process-mark)
4790 (gnus-summary-unmark-all-processable))
4792 (defun gnus-summary-yank-process-mark ()
4793 "Pop the last process mark state off the stack and restore it."
4795 (unless gnus-newsgroup-process-stack
4796 (error "Empty mark stack"))
4797 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4799 (defun gnus-summary-process-mark-set (set)
4800 "Make SET into the current process marked articles."
4801 (gnus-summary-unmark-all-processable)
4803 (gnus-summary-set-process-mark (pop set))))
4805 ;;; Searching and stuff
4807 (defun gnus-summary-search-group (&optional backward use-level)
4808 "Search for next unread newsgroup.
4809 If optional argument BACKWARD is non-nil, search backward instead."
4811 (set-buffer gnus-group-buffer)
4812 (when (gnus-group-search-forward
4813 backward nil (if use-level (gnus-group-group-level) nil))
4814 (gnus-group-group-name))))
4816 (defun gnus-summary-best-group (&optional exclude-group)
4817 "Find the name of the best unread group.
4818 If EXCLUDE-GROUP, do not go to this group."
4820 (set-buffer gnus-group-buffer)
4822 (gnus-group-best-unread-group exclude-group))))
4824 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
4825 (if backward (gnus-summary-find-prev)
4826 (let* ((dummy (gnus-summary-article-intangible-p))
4827 (article (or article (gnus-summary-article-number)))
4828 (arts (gnus-data-find-list article))
4830 (when (and (not dummy)
4831 (or (not gnus-summary-check-current)
4833 (not (gnus-data-unread-p (car arts)))))
4834 (setq arts (cdr arts)))
4839 (when (or (and undownloaded
4840 (eq gnus-undownloaded-mark
4841 (gnus-data-mark (car arts))))
4842 (gnus-data-unread-p (car arts)))
4843 (setq result (car arts)
4845 (setq arts (cdr arts)))
4848 (goto-char (gnus-data-pos result))
4849 (gnus-data-number result)))))
4851 (defun gnus-summary-find-prev (&optional unread article)
4852 (let* ((eobp (eobp))
4853 (article (or article (gnus-summary-article-number)))
4854 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
4856 (when (and (not eobp)
4857 (or (not gnus-summary-check-current)
4859 (not (gnus-data-unread-p (car arts)))))
4860 (setq arts (cdr arts)))
4865 (when (gnus-data-unread-p (car arts))
4866 (setq result (car arts)
4868 (setq arts (cdr arts)))
4871 (goto-char (gnus-data-pos result))
4872 (gnus-data-number result))))
4874 (defun gnus-summary-find-subject (subject &optional unread backward article)
4875 (let* ((simp-subject (gnus-simplify-subject-fully subject))
4876 (article (or article (gnus-summary-article-number)))
4877 (articles (gnus-data-list backward))
4878 (arts (gnus-data-find-list article articles))
4880 (when (or (not gnus-summary-check-current)
4882 (not (gnus-data-unread-p (car arts))))
4883 (setq arts (cdr arts)))
4885 (and (or (not unread)
4886 (gnus-data-unread-p (car arts)))
4887 (vectorp (gnus-data-header (car arts)))
4889 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
4890 (setq result (car arts)
4892 (setq arts (cdr arts)))
4894 (goto-char (gnus-data-pos result))
4895 (gnus-data-number result))))
4897 (defun gnus-summary-search-forward (&optional unread subject backward)
4898 "Search forward for an article.
4899 If UNREAD, look for unread articles. If SUBJECT, look for
4900 articles with that subject. If BACKWARD, search backward instead."
4901 (cond (subject (gnus-summary-find-subject subject unread backward))
4902 (backward (gnus-summary-find-prev unread))
4903 (t (gnus-summary-find-next unread))))
4905 (defun gnus-recenter (&optional n)
4906 "Center point in window and redisplay frame.
4907 Also do horizontal recentering."
4909 (when (and gnus-auto-center-summary
4910 (not (eq gnus-auto-center-summary 'vertical)))
4911 (gnus-horizontal-recenter))
4914 (defun gnus-summary-recenter ()
4915 "Center point in the summary window.
4916 If `gnus-auto-center-summary' is nil, or the article buffer isn't
4917 displayed, no centering will be performed."
4918 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
4919 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
4920 (let* ((top (cond ((< (window-height) 4) 0)
4921 ((< (window-height) 7) 1)
4922 (t (if (numberp gnus-auto-center-summary)
4923 gnus-auto-center-summary
4925 (height (1- (window-height)))
4926 (bottom (save-excursion (goto-char (point-max))
4927 (forward-line (- height))
4929 (window (get-buffer-window (current-buffer))))
4930 ;; The user has to want it.
4931 (when gnus-auto-center-summary
4932 (when (get-buffer-window gnus-article-buffer)
4933 ;; Only do recentering when the article buffer is displayed,
4934 ;; Set the window start to either `bottom', which is the biggest
4935 ;; possible valid number, or the second line from the top,
4936 ;; whichever is the least.
4938 window (min bottom (save-excursion
4939 (forward-line (- top)) (point)))))
4940 ;; Do horizontal recentering while we're at it.
4941 (when (and (get-buffer-window (current-buffer) t)
4942 (not (eq gnus-auto-center-summary 'vertical)))
4943 (let ((selected (selected-window)))
4944 (select-window (get-buffer-window (current-buffer) t))
4945 (gnus-summary-position-point)
4946 (gnus-horizontal-recenter)
4947 (select-window selected))))))
4949 (defun gnus-summary-jump-to-group (newsgroup)
4950 "Move point to NEWSGROUP in group mode buffer."
4951 ;; Keep update point of group mode buffer if visible.
4952 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
4953 (save-window-excursion
4954 ;; Take care of tree window mode.
4955 (when (get-buffer-window gnus-group-buffer)
4956 (pop-to-buffer gnus-group-buffer))
4957 (gnus-group-jump-to-group newsgroup))
4959 ;; Take care of tree window mode.
4960 (if (get-buffer-window gnus-group-buffer)
4961 (pop-to-buffer gnus-group-buffer)
4962 (set-buffer gnus-group-buffer))
4963 (gnus-group-jump-to-group newsgroup))))
4965 ;; This function returns a list of article numbers based on the
4966 ;; difference between the ranges of read articles in this group and
4967 ;; the range of active articles.
4968 (defun gnus-list-of-unread-articles (group)
4969 (let* ((read (gnus-info-read (gnus-get-info group)))
4970 (active (or (gnus-active group) (gnus-activate-group group)))
4973 ;; If none are read, then all are unread.
4975 (setq first (car active))
4976 ;; If the range of read articles is a single range, then the
4977 ;; first unread article is the article after the last read
4978 ;; article. Sounds logical, doesn't it?
4979 (if (not (listp (cdr read)))
4980 (setq first (max (car active) (1+ (cdr read))))
4981 ;; `read' is a list of ranges.
4982 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
4985 (setq first (car active)))
4988 (while (< first nlast)
4990 (setq first (1+ first))))
4991 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
4992 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
4993 (setq read (cdr read)))))
4994 ;; And add the last unread articles.
4995 (while (<= first last)
4997 (setq first (1+ first)))
4998 ;; Return the list of unread articles.
4999 (delq 0 (nreverse unread))))
5001 (defun gnus-list-of-read-articles (group)
5002 "Return a list of unread, unticked and non-dormant articles."
5003 (let* ((info (gnus-get-info group))
5004 (marked (gnus-info-marks info))
5005 (active (gnus-active group)))
5007 (gnus-set-difference
5008 (gnus-sorted-complement
5009 (gnus-uncompress-range active)
5010 (gnus-list-of-unread-articles group))
5012 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5013 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5015 ;; Various summary commands
5017 (defun gnus-summary-select-article-buffer ()
5018 "Reconfigure windows to show article buffer."
5020 (if (not (gnus-buffer-live-p gnus-article-buffer))
5021 (error "There is no article buffer for this summary buffer")
5022 (gnus-configure-windows 'article)
5023 (select-window (get-buffer-window gnus-article-buffer))))
5025 (defun gnus-summary-universal-argument (arg)
5026 "Perform any operation on all articles that are process/prefixed."
5028 (let ((articles (gnus-summary-work-articles arg))
5035 (substitute-command-keys
5036 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
5039 (gnus-error 1 "Undefined key")
5042 (gnus-summary-goto-subject (setq article (pop articles)))
5043 (let (gnus-newsgroup-processable)
5044 (command-execute func))
5045 (gnus-summary-remove-process-mark article)))))
5046 (gnus-summary-position-point))
5048 (defun gnus-summary-toggle-truncation (&optional arg)
5049 "Toggle truncation of summary lines.
5050 With arg, turn line truncation on iff arg is positive."
5052 (setq truncate-lines
5053 (if (null arg) (not truncate-lines)
5054 (> (prefix-numeric-value arg) 0)))
5057 (defun gnus-summary-reselect-current-group (&optional all rescan)
5058 "Exit and then reselect the current newsgroup.
5059 The prefix argument ALL means to select all articles."
5061 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5062 (error "Ephemeral groups can't be reselected"))
5063 (let ((current-subject (gnus-summary-article-number))
5064 (group gnus-newsgroup-name))
5065 (setq gnus-newsgroup-begin nil)
5067 ;; We have to adjust the point of group mode buffer because
5068 ;; point was moved to the next unread newsgroup by exiting.
5069 (gnus-summary-jump-to-group group)
5072 (gnus-group-get-new-news-this-group 1)))
5073 (gnus-group-read-group all t)
5074 (gnus-summary-goto-subject current-subject nil t)))
5076 (defun gnus-summary-rescan-group (&optional all)
5077 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5079 (gnus-summary-reselect-current-group all t))
5081 (defun gnus-summary-update-info (&optional non-destructive)
5083 (let ((group gnus-newsgroup-name))
5085 (when gnus-newsgroup-kill-headers
5086 (setq gnus-newsgroup-killed
5087 (gnus-compress-sequence
5089 (gnus-set-sorted-intersection
5090 (gnus-uncompress-range gnus-newsgroup-killed)
5091 (setq gnus-newsgroup-unselected
5092 (sort gnus-newsgroup-unselected '<)))
5093 (setq gnus-newsgroup-unreads
5094 (sort gnus-newsgroup-unreads '<)))
5096 (unless (listp (cdr gnus-newsgroup-killed))
5097 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5098 (let ((headers gnus-newsgroup-headers))
5099 ;; Set the new ranges of read articles.
5101 (set-buffer gnus-group-buffer)
5102 (gnus-undo-force-boundary))
5103 (gnus-update-read-articles
5104 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5105 ;; Set the current article marks.
5106 (let ((gnus-newsgroup-scored
5107 (if (and (not gnus-save-score)
5108 (not non-destructive))
5110 gnus-newsgroup-scored)))
5112 (gnus-update-marks)))
5113 ;; Do the cross-ref thing.
5114 (when gnus-use-cross-reference
5115 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5116 ;; Do not switch windows but change the buffer to work.
5117 (set-buffer gnus-group-buffer)
5118 (unless (gnus-ephemeral-group-p group)
5119 (gnus-group-update-group group)))))))
5121 (defun gnus-summary-save-newsrc (&optional force)
5122 "Save the current number of read/marked articles in the dribble buffer.
5123 The dribble buffer will then be saved.
5124 If FORCE (the prefix), also save the .newsrc file(s)."
5126 (gnus-summary-update-info t)
5128 (gnus-save-newsrc-file)
5129 (gnus-dribble-save)))
5131 (defun gnus-summary-exit (&optional temporary)
5132 "Exit reading current newsgroup, and then return to group selection mode.
5133 gnus-exit-group-hook is called with no arguments if that value is non-nil."
5135 (gnus-set-global-variables)
5136 (gnus-kill-save-kill-buffer)
5137 (gnus-async-halt-prefetch)
5138 (let* ((group gnus-newsgroup-name)
5139 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5142 (buf (current-buffer)))
5143 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5144 ;; If we have several article buffers, we kill them at exit.
5145 (unless gnus-single-article-buffer
5146 (gnus-kill-buffer gnus-original-article-buffer)
5147 (setq gnus-article-current nil))
5148 (when gnus-use-cache
5149 (gnus-cache-possibly-remove-articles)
5150 (gnus-cache-save-buffers))
5151 (gnus-async-prefetch-remove-group group)
5152 (when gnus-suppress-duplicates
5153 (gnus-dup-enter-articles))
5154 (when gnus-use-trees
5155 (gnus-tree-close group))
5156 ;; Remove entries for this group.
5157 (nnmail-purge-split-history (gnus-group-real-name group))
5158 ;; Make all changes in this group permanent.
5160 (gnus-run-hooks 'gnus-exit-group-hook)
5161 (gnus-summary-update-info)
5162 ;; Do adaptive scoring, and possibly save score files.
5163 (when gnus-newsgroup-adaptive
5164 (gnus-score-adaptive))
5165 (when gnus-use-scoring
5167 (gnus-close-group group)
5168 ;; Make sure where we were, and go to next newsgroup.
5169 (set-buffer gnus-group-buffer)
5171 (gnus-group-jump-to-group group))
5172 (gnus-run-hooks 'gnus-summary-exit-hook)
5173 (unless (or quit-config
5174 ;; If this group has disappeared from the summary
5175 ;; buffer, don't skip forwards.
5176 (not (string= group (gnus-group-group-name))))
5177 (gnus-group-next-unread-group 1))
5178 (setq group-point (point))
5181 ;; If we have several article buffers, we kill them at exit.
5182 (unless gnus-single-article-buffer
5183 (gnus-kill-buffer gnus-article-buffer)
5184 (gnus-kill-buffer gnus-original-article-buffer)
5185 (setq gnus-article-current nil))
5187 (if (not gnus-kill-summary-on-exit)
5188 (gnus-deaden-summary)
5189 ;; We set all buffer-local variables to nil. It is unclear why
5190 ;; this is needed, but if we don't, buffer-local variables are
5191 ;; not garbage-collected, it seems. This would the lead to en
5192 ;; ever-growing Emacs.
5193 (gnus-summary-clear-local-variables)
5194 (when (get-buffer gnus-article-buffer)
5195 (bury-buffer gnus-article-buffer))
5196 ;; We clear the global counterparts of the buffer-local
5197 ;; variables as well, just to be on the safe side.
5198 (set-buffer gnus-group-buffer)
5199 (gnus-summary-clear-local-variables)
5200 ;; Return to group mode buffer.
5201 (when (eq mode 'gnus-summary-mode)
5202 (gnus-kill-buffer buf)))
5203 (setq gnus-current-select-method gnus-select-method)
5204 (pop-to-buffer gnus-group-buffer)
5205 (if (not quit-config)
5207 (goto-char group-point)
5208 (gnus-configure-windows 'group 'force))
5209 (gnus-handle-ephemeral-exit quit-config))
5210 ;; Clear the current group name.
5212 (setq gnus-newsgroup-name nil)))))
5214 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5215 (defun gnus-summary-exit-no-update (&optional no-questions)
5216 "Quit reading current newsgroup without updating read article info."
5218 (let* ((group gnus-newsgroup-name)
5219 (quit-config (gnus-group-quit-config group)))
5220 (when (or no-questions
5222 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5223 (gnus-async-halt-prefetch)
5224 (gnus-run-hooks (delq 'gnus-summary-expire-articles
5225 (copy-list gnus-summary-prepare-exit-hook)))
5226 ;; If we have several article buffers, we kill them at exit.
5227 (unless gnus-single-article-buffer
5228 (gnus-kill-buffer gnus-article-buffer)
5229 (gnus-kill-buffer gnus-original-article-buffer)
5230 (setq gnus-article-current nil))
5231 (if (not gnus-kill-summary-on-exit)
5232 (gnus-deaden-summary)
5233 (gnus-close-group group)
5234 (gnus-summary-clear-local-variables)
5235 (set-buffer gnus-group-buffer)
5236 (gnus-summary-clear-local-variables)
5237 (when (get-buffer gnus-summary-buffer)
5238 (kill-buffer gnus-summary-buffer)))
5239 (unless gnus-single-article-buffer
5240 (setq gnus-article-current nil))
5241 (when gnus-use-trees
5242 (gnus-tree-close group))
5243 (gnus-async-prefetch-remove-group group)
5244 (when (get-buffer gnus-article-buffer)
5245 (bury-buffer gnus-article-buffer))
5246 ;; Return to the group buffer.
5247 (gnus-configure-windows 'group 'force)
5248 ;; Clear the current group name.
5249 (setq gnus-newsgroup-name nil)
5250 (when (equal (gnus-group-group-name) group)
5251 (gnus-group-next-unread-group 1))
5253 (gnus-handle-ephemeral-exit quit-config)))))
5255 (defun gnus-handle-ephemeral-exit (quit-config)
5256 "Handle movement when leaving an ephemeral group.
5257 The state which existed when entering the ephemeral is reset."
5258 (if (not (buffer-name (car quit-config)))
5259 (gnus-configure-windows 'group 'force)
5260 (set-buffer (car quit-config))
5261 (cond ((eq major-mode 'gnus-summary-mode)
5262 (gnus-set-global-variables))
5263 ((eq major-mode 'gnus-article-mode)
5265 ;; The `gnus-summary-buffer' variable may point
5266 ;; to the old summary buffer when using a single
5268 (unless (gnus-buffer-live-p gnus-summary-buffer)
5269 (set-buffer gnus-group-buffer))
5270 (set-buffer gnus-summary-buffer)
5271 (gnus-set-global-variables))))
5272 (if (or (eq (cdr quit-config) 'article)
5273 (eq (cdr quit-config) 'pick))
5275 ;; The current article may be from the ephemeral group
5276 ;; thus it is best that we reload this article
5277 (gnus-summary-show-article)
5278 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5279 (gnus-configure-windows 'pick 'force)
5280 (gnus-configure-windows (cdr quit-config) 'force)))
5281 (gnus-configure-windows (cdr quit-config) 'force))
5282 (when (eq major-mode 'gnus-summary-mode)
5283 (gnus-summary-next-subject 1 nil t)
5284 (gnus-summary-recenter)
5285 (gnus-summary-position-point))))
5287 (defun gnus-summary-preview-mime-message (arg)
5288 "MIME decode and play this message."
5291 (let ((gnus-break-pages nil)
5293 (gnus-summary-select-article t t)
5295 (select-window (get-buffer-window gnus-article-buffer))
5300 (defvar gnus-dead-summary-mode-map nil)
5302 (unless gnus-dead-summary-mode-map
5303 (setq gnus-dead-summary-mode-map (make-keymap))
5304 (suppress-keymap gnus-dead-summary-mode-map)
5305 (substitute-key-definition
5306 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5307 (let ((keys '("\C-d" "\r" "\177" [delete])))
5309 (define-key gnus-dead-summary-mode-map
5310 (pop keys) 'gnus-summary-wake-up-the-dead))))
5312 (defvar gnus-dead-summary-mode nil
5313 "Minor mode for Gnus summary buffers.")
5315 (defun gnus-dead-summary-mode (&optional arg)
5316 "Minor mode for Gnus summary buffers."
5318 (when (eq major-mode 'gnus-summary-mode)
5319 (make-local-variable 'gnus-dead-summary-mode)
5320 (setq gnus-dead-summary-mode
5321 (if (null arg) (not gnus-dead-summary-mode)
5322 (> (prefix-numeric-value arg) 0)))
5323 (when gnus-dead-summary-mode
5324 (gnus-add-minor-mode
5325 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5327 (defun gnus-deaden-summary ()
5328 "Make the current summary buffer into a dead summary buffer."
5329 ;; Kill any previous dead summary buffer.
5330 (when (and gnus-dead-summary
5331 (buffer-name gnus-dead-summary))
5333 (set-buffer gnus-dead-summary)
5334 (when gnus-dead-summary-mode
5335 (kill-buffer (current-buffer)))))
5336 ;; Make this the current dead summary.
5337 (setq gnus-dead-summary (current-buffer))
5338 (gnus-dead-summary-mode 1)
5339 (let ((name (buffer-name)))
5340 (when (string-match "Summary" name)
5342 (concat (substring name 0 (match-beginning 0)) "Dead "
5343 (substring name (match-beginning 0)))
5346 (defun gnus-kill-or-deaden-summary (buffer)
5347 "Kill or deaden the summary BUFFER."
5349 (when (and (buffer-name buffer)
5350 (not gnus-single-article-buffer))
5353 (gnus-kill-buffer gnus-article-buffer)
5354 (gnus-kill-buffer gnus-original-article-buffer)))
5355 (cond (gnus-kill-summary-on-exit
5356 (when (and gnus-use-trees
5357 (gnus-buffer-exists-p buffer))
5360 (gnus-tree-close gnus-newsgroup-name)))
5361 (gnus-kill-buffer buffer))
5362 ((gnus-buffer-exists-p buffer)
5365 (gnus-deaden-summary))))))
5367 (defun gnus-summary-wake-up-the-dead (&rest args)
5368 "Wake up the dead summary buffer."
5370 (gnus-dead-summary-mode -1)
5371 (let ((name (buffer-name)))
5372 (when (string-match "Dead " name)
5374 (concat (substring name 0 (match-beginning 0))
5375 (substring name (match-end 0)))
5377 (gnus-message 3 "This dead summary is now alive again"))
5379 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5380 (defun gnus-summary-fetch-faq (&optional faq-dir)
5381 "Fetch the FAQ for the current group.
5382 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5386 (when current-prefix-arg
5388 "Faq dir: " (and (listp gnus-group-faq-directory)
5389 (mapcar (lambda (file) (list file))
5390 gnus-group-faq-directory))))))
5391 (let (gnus-faq-buffer)
5392 (when (setq gnus-faq-buffer
5393 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5394 (gnus-configure-windows 'summary-faq))))
5396 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5397 (defun gnus-summary-describe-group (&optional force)
5398 "Describe the current newsgroup."
5400 (gnus-group-describe-group force gnus-newsgroup-name))
5402 (defun gnus-summary-describe-briefly ()
5403 "Describe summary mode commands briefly."
5406 (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")))
5408 ;; Walking around group mode buffer from summary mode.
5410 (defun gnus-summary-next-group (&optional no-article target-group backward)
5411 "Exit current newsgroup and then select next unread newsgroup.
5412 If prefix argument NO-ARTICLE is non-nil, no article is selected
5413 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5414 previous group instead."
5416 ;; Stop pre-fetching.
5417 (gnus-async-halt-prefetch)
5418 (let ((current-group gnus-newsgroup-name)
5419 (current-buffer (current-buffer))
5421 ;; First we semi-exit this group to update Xrefs and all variables.
5422 ;; We can't do a real exit, because the window conf must remain
5423 ;; the same in case the user is prompted for info, and we don't
5424 ;; want the window conf to change before that...
5425 (gnus-summary-exit t)
5426 (while (not entered)
5427 ;; Then we find what group we are supposed to enter.
5428 (set-buffer gnus-group-buffer)
5429 (gnus-group-jump-to-group current-group)
5432 (if (eq gnus-keep-same-level 'best)
5433 (gnus-summary-best-group gnus-newsgroup-name)
5434 (gnus-summary-search-group backward gnus-keep-same-level))))
5435 (if (not target-group)
5436 ;; There are no further groups, so we return to the group
5439 (gnus-message 5 "Returning to the group buffer")
5441 (when (gnus-buffer-live-p current-buffer)
5442 (set-buffer current-buffer)
5443 (gnus-summary-exit))
5444 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5445 ;; We try to enter the target group.
5446 (gnus-group-jump-to-group target-group)
5447 (let ((unreads (gnus-group-group-unread)))
5448 (if (and (or (eq t unreads)
5449 (and unreads (not (zerop unreads))))
5450 (gnus-summary-read-group
5451 target-group nil no-article
5452 (and (buffer-name current-buffer) current-buffer)
5455 (setq current-group target-group
5456 target-group nil)))))))
5458 (defun gnus-summary-prev-group (&optional no-article)
5459 "Exit current newsgroup and then select previous unread newsgroup.
5460 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5462 (gnus-summary-next-group no-article nil t))
5464 ;; Walking around summary lines.
5466 (defun gnus-summary-first-subject (&optional unread undownloaded)
5467 "Go to the first unread subject.
5468 If UNREAD is non-nil, go to the first unread article.
5469 Returns the article selected or nil if there are no unread articles."
5474 ((null gnus-newsgroup-data)
5475 (gnus-message 3 "No articles in the group")
5477 ;; Pick the first article.
5479 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5480 (gnus-data-number (car gnus-newsgroup-data)))
5481 ;; No unread articles.
5482 ((null gnus-newsgroup-unreads)
5483 (gnus-message 3 "No more unread articles")
5485 ;; Find the first unread article.
5487 (let ((data gnus-newsgroup-data))
5489 (and (not (and undownloaded
5490 (eq gnus-undownloaded-mark
5491 (gnus-data-mark (car data)))))
5492 (not (gnus-data-unread-p (car data)))))
5493 (setq data (cdr data)))
5495 (goto-char (gnus-data-pos (car data)))
5496 (gnus-data-number (car data))))))
5497 (gnus-summary-position-point)))
5499 (defun gnus-summary-next-subject (n &optional unread dont-display)
5500 "Go to next N'th summary line.
5501 If N is negative, go to the previous N'th subject line.
5502 If UNREAD is non-nil, only unread articles are selected.
5503 The difference between N and the actual number of steps taken is
5506 (let ((backward (< n 0))
5510 (gnus-summary-find-prev unread)
5511 (gnus-summary-find-next unread)))
5512 (gnus-summary-show-thread)
5515 (gnus-message 7 "No more%s articles"
5516 (if unread " unread" "")))
5517 (unless dont-display
5518 (gnus-summary-recenter)
5519 (gnus-summary-position-point))
5522 (defun gnus-summary-next-unread-subject (n)
5523 "Go to next N'th unread summary line."
5525 (gnus-summary-next-subject n t))
5527 (defun gnus-summary-prev-subject (n &optional unread)
5528 "Go to previous N'th summary line.
5529 If optional argument UNREAD is non-nil, only unread article is selected."
5531 (gnus-summary-next-subject (- n) unread))
5533 (defun gnus-summary-prev-unread-subject (n)
5534 "Go to previous N'th unread summary line."
5536 (gnus-summary-next-subject (- n) t))
5538 (defun gnus-summary-goto-subject (article &optional force silent)
5539 "Go the subject line of ARTICLE.
5540 If FORCE, also allow jumping to articles not currently shown."
5541 (interactive "nArticle number: ")
5543 (data (gnus-data-find article)))
5544 ;; We read in the article if we have to.
5547 (gnus-summary-insert-subject
5549 (if (or (numberp force) (vectorp force)) force)
5551 (setq data (gnus-data-find article)))
5556 (gnus-message 3 "Can't find article %d" article))
5558 (goto-char (gnus-data-pos data))
5559 (gnus-summary-position-point)
5562 ;; Walking around summary lines with displaying articles.
5564 (defun gnus-summary-expand-window (&optional arg)
5565 "Make the summary buffer take up the entire Emacs frame.
5566 Given a prefix, will force an `article' buffer configuration."
5569 (gnus-configure-windows 'article 'force)
5570 (gnus-configure-windows 'summary 'force)))
5572 (defun gnus-summary-display-article (article &optional all-header)
5573 "Display ARTICLE in article buffer."
5574 (gnus-set-global-variables)
5578 (if gnus-summary-display-article-function
5579 (funcall gnus-summary-display-article-function article all-header)
5580 (gnus-article-prepare article all-header))
5581 (gnus-run-hooks 'gnus-select-article-hook)
5582 (when (and gnus-current-article
5583 (not (zerop gnus-current-article)))
5584 (gnus-summary-goto-subject gnus-current-article))
5585 (gnus-summary-recenter)
5586 (when (and gnus-use-trees gnus-show-threads)
5587 (gnus-possibly-generate-tree article)
5588 (gnus-highlight-selected-tree article))
5589 ;; Successfully display article.
5590 (gnus-article-set-window-start
5591 (cdr (assq article gnus-newsgroup-bookmarks))))))
5593 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5594 "Select the current article.
5595 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5596 non-nil, the article will be re-fetched even if it already present in
5597 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5599 ;; Make sure we are in the summary buffer to work around bbdb bug.
5600 (unless (eq major-mode 'gnus-summary-mode)
5601 (set-buffer gnus-summary-buffer))
5602 (let ((article (or article (gnus-summary-article-number)))
5603 (all-headers (not (not all-headers))) ;Must be T or NIL.
5604 gnus-summary-display-article-function
5607 (gnus-summary-article-pseudo-p article)
5608 (error "This is a pseudo-article"))
5611 (set-buffer gnus-summary-buffer)
5612 (if (or (and gnus-single-article-buffer
5613 (or (null gnus-current-article)
5614 (null gnus-article-current)
5615 (null (get-buffer gnus-article-buffer))
5616 (not (eq article (cdr gnus-article-current)))
5617 (not (equal (car gnus-article-current)
5618 gnus-newsgroup-name))))
5619 (and (not gnus-single-article-buffer)
5620 (or (null gnus-current-article)
5621 (not (eq gnus-current-article article))))
5623 ;; The requested article is different from the current article.
5625 (gnus-summary-display-article article all-headers)
5627 (when (or all-headers gnus-show-all-headers)
5628 (gnus-article-show-all-headers))
5631 (gnus-article-set-window-start
5632 (cdr (assq article gnus-newsgroup-bookmarks)))))))
5634 (defun gnus-summary-set-current-mark (&optional current-mark)
5635 "Obsolete function."
5638 (defun gnus-summary-next-article (&optional unread subject backward push)
5639 "Select the next article.
5640 If UNREAD, only unread articles are selected.
5641 If SUBJECT, only articles with SUBJECT are selected.
5642 If BACKWARD, the previous article is selected instead of the next."
5645 ;; Is there such an article?
5646 ((and (gnus-summary-search-forward unread subject backward)
5647 (or (gnus-summary-display-article (gnus-summary-article-number))
5648 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5649 (gnus-summary-position-point))
5650 ;; If not, we try the first unread, if that is wanted.
5652 gnus-auto-select-same
5653 (gnus-summary-first-unread-article))
5654 (gnus-summary-position-point)
5655 (gnus-message 6 "Wrapped"))
5656 ;; Try to get next/previous article not displayed in this group.
5657 ((and gnus-auto-extend-newsgroup
5658 (not unread) (not subject))
5659 (gnus-summary-goto-article
5660 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5661 nil (count-lines (point-min) (point))))
5662 ;; Go to next/previous group.
5664 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5665 (gnus-summary-jump-to-group gnus-newsgroup-name))
5666 (let ((cmd last-command-char)
5669 (set-buffer gnus-group-buffer)
5672 (if (eq gnus-keep-same-level 'best)
5673 (gnus-summary-best-group gnus-newsgroup-name)
5674 (gnus-summary-search-group backward gnus-keep-same-level))))
5675 ;; For some reason, the group window gets selected. We change
5677 (select-window (get-buffer-window (current-buffer)))
5678 ;; Select next unread newsgroup automagically.
5680 ((or (not gnus-auto-select-next)
5682 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5683 ((or (eq gnus-auto-select-next 'quietly)
5684 (and (eq gnus-auto-select-next 'slightly-quietly)
5686 (and (eq gnus-auto-select-next 'almost-quietly)
5687 (gnus-summary-last-article-p)))
5689 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5691 (gnus-message 7 "No more%s articles (%s)..."
5692 (if unread " unread" "")
5693 (if group (concat "selecting " group)
5695 (gnus-summary-next-group nil group backward)))
5697 (when (gnus-key-press-event-p last-input-event)
5698 (gnus-summary-walk-group-buffer
5699 gnus-newsgroup-name cmd unread backward point))))))))
5701 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5702 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5703 (?\C-p (gnus-group-prev-unread-group 1))))
5704 (cursor-in-echo-area t)
5705 keve key group ended)
5707 (set-buffer gnus-group-buffer)
5710 (if (eq gnus-keep-same-level 'best)
5711 (gnus-summary-best-group gnus-newsgroup-name)
5712 (gnus-summary-search-group backward gnus-keep-same-level))))
5715 5 "No more%s articles%s" (if unread " unread" "")
5717 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5718 (format " (Type %s for %s [%s])"
5719 (single-key-description cmd) group
5720 (car (gnus-gethash group gnus-newsrc-hashtb)))
5721 (format " (Type %s to exit %s)"
5722 (single-key-description cmd)
5723 gnus-newsgroup-name)))
5724 ;; Confirm auto selection.
5725 (setq key (car (setq keve (gnus-read-event-char))))
5728 ((assq key keystrokes)
5729 (let ((obuf (current-buffer)))
5730 (switch-to-buffer gnus-group-buffer)
5732 (gnus-group-jump-to-group group))
5733 (eval (cadr (assq key keystrokes)))
5734 (setq group (gnus-group-group-name))
5735 (switch-to-buffer obuf))
5739 (gnus-ephemeral-group-p gnus-newsgroup-name))
5741 (gnus-summary-next-group nil group backward)))
5743 (push (cdr keve) unread-command-events))))))
5745 (defun gnus-summary-next-unread-article ()
5746 "Select unread article after current one."
5748 (gnus-summary-next-article
5749 (or (not (eq gnus-summary-goto-unread 'never))
5750 (gnus-summary-last-article-p (gnus-summary-article-number)))
5751 (and gnus-auto-select-same
5752 (gnus-summary-article-subject))))
5754 (defun gnus-summary-prev-article (&optional unread subject)
5755 "Select the article after the current one.
5756 If UNREAD is non-nil, only unread articles are selected."
5758 (gnus-summary-next-article unread subject t))
5760 (defun gnus-summary-prev-unread-article ()
5761 "Select unread article before current one."
5763 (gnus-summary-prev-article
5764 (or (not (eq gnus-summary-goto-unread 'never))
5765 (gnus-summary-first-article-p (gnus-summary-article-number)))
5766 (and gnus-auto-select-same
5767 (gnus-summary-article-subject))))
5769 (defun gnus-summary-next-page (&optional lines circular)
5770 "Show next page of the selected article.
5771 If at the end of the current article, select the next article.
5772 LINES says how many lines should be scrolled up.
5774 If CIRCULAR is non-nil, go to the start of the article instead of
5775 selecting the next article when reaching the end of the current
5778 (setq gnus-summary-buffer (current-buffer))
5779 (gnus-set-global-variables)
5780 (let ((article (gnus-summary-article-number))
5781 (article-window (get-buffer-window gnus-article-buffer t))
5783 ;; If the buffer is empty, we have no article.
5785 (error "No article to select"))
5786 (gnus-configure-windows 'article)
5787 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
5788 (if (and (eq gnus-summary-goto-unread 'never)
5789 (not (gnus-summary-last-article-p article)))
5790 (gnus-summary-next-article)
5791 (gnus-summary-next-unread-article))
5792 (if (or (null gnus-current-article)
5793 (null gnus-article-current)
5794 (/= article (cdr gnus-article-current))
5795 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5796 ;; Selected subject is different from current article's.
5797 (gnus-summary-display-article article)
5798 (when article-window
5799 (gnus-eval-in-buffer-window gnus-article-buffer
5800 (setq endp (gnus-article-next-page lines)))
5803 (gnus-summary-beginning-of-article))
5805 (gnus-message 3 "End of message"))
5807 (if (and (eq gnus-summary-goto-unread 'never)
5808 (not (gnus-summary-last-article-p article)))
5809 (gnus-summary-next-article)
5810 (gnus-summary-next-unread-article))))))))
5811 (gnus-summary-recenter)
5812 (gnus-summary-position-point)))
5814 (defun gnus-summary-prev-page (&optional lines move)
5815 "Show previous page of selected article.
5816 Argument LINES specifies lines to be scrolled down.
5817 If MOVE, move to the previous unread article if point is at
5818 the beginning of the buffer."
5820 (let ((article (gnus-summary-article-number))
5821 (article-window (get-buffer-window gnus-article-buffer t))
5823 (gnus-configure-windows 'article)
5824 (if (or (null gnus-current-article)
5825 (null gnus-article-current)
5826 (/= article (cdr gnus-article-current))
5827 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5828 ;; Selected subject is different from current article's.
5829 (gnus-summary-display-article article)
5830 (gnus-summary-recenter)
5831 (when article-window
5832 (gnus-eval-in-buffer-window gnus-article-buffer
5833 (setq endp (gnus-article-prev-page lines)))
5834 (when (and move endp)
5836 (gnus-message 3 "Beginning of message"))
5838 (if (and (eq gnus-summary-goto-unread 'never)
5839 (not (gnus-summary-first-article-p article)))
5840 (gnus-summary-prev-article)
5841 (gnus-summary-prev-unread-article))))))))
5842 (gnus-summary-position-point))
5844 (defun gnus-summary-prev-page-or-article (&optional lines)
5845 "Show previous page of selected article.
5846 Argument LINES specifies lines to be scrolled down.
5847 If at the beginning of the article, go to the next article."
5849 (gnus-summary-prev-page lines t))
5851 (defun gnus-summary-scroll-up (lines)
5852 "Scroll up (or down) one line current article.
5853 Argument LINES specifies lines to be scrolled up (or down if negative)."
5855 (gnus-configure-windows 'article)
5856 (gnus-summary-show-thread)
5857 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
5858 (gnus-eval-in-buffer-window gnus-article-buffer
5860 (when (gnus-article-next-page lines)
5861 (gnus-message 3 "End of message")))
5863 (gnus-article-prev-page (- lines))))))
5864 (gnus-summary-recenter)
5865 (gnus-summary-position-point))
5867 (defun gnus-summary-scroll-down (lines)
5868 "Scroll down (or up) one line current article.
5869 Argument LINES specifies lines to be scrolled down (or up if negative)."
5871 (gnus-summary-scroll-up (- lines)))
5873 (defun gnus-summary-next-same-subject ()
5874 "Select next article which has the same subject as current one."
5876 (gnus-summary-next-article nil (gnus-summary-article-subject)))
5878 (defun gnus-summary-prev-same-subject ()
5879 "Select previous article which has the same subject as current one."
5881 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
5883 (defun gnus-summary-next-unread-same-subject ()
5884 "Select next unread article which has the same subject as current one."
5886 (gnus-summary-next-article t (gnus-summary-article-subject)))
5888 (defun gnus-summary-prev-unread-same-subject ()
5889 "Select previous unread article which has the same subject as current one."
5891 (gnus-summary-prev-article t (gnus-summary-article-subject)))
5893 (defun gnus-summary-first-unread-article ()
5894 "Select the first unread article.
5895 Return nil if there are no unread articles."
5898 (when (gnus-summary-first-subject t)
5899 (gnus-summary-show-thread)
5900 (gnus-summary-first-subject t)
5901 (gnus-summary-display-article (gnus-summary-article-number)))
5902 (gnus-summary-position-point)))
5904 (defun gnus-summary-first-unread-subject ()
5905 "Place the point on the subject line of the first unread article.
5906 Return nil if there are no unread articles."
5909 (when (gnus-summary-first-subject t)
5910 (gnus-summary-show-thread)
5911 (gnus-summary-first-subject t))
5912 (gnus-summary-position-point)))
5914 (defun gnus-summary-first-article ()
5915 "Select the first article.
5916 Return nil if there are no articles."
5919 (when (gnus-summary-first-subject)
5920 (gnus-summary-show-thread)
5921 (gnus-summary-first-subject)
5922 (gnus-summary-display-article (gnus-summary-article-number)))
5923 (gnus-summary-position-point)))
5925 (defun gnus-summary-best-unread-article ()
5926 "Select the unread article with the highest score."
5928 (let ((best -1000000)
5929 (data gnus-newsgroup-data)
5932 (and (gnus-data-unread-p (car data))
5934 (gnus-summary-article-score (gnus-data-number (car data))))
5937 article (gnus-data-number (car data))))
5938 (setq data (cdr data)))
5941 (gnus-summary-goto-article article)
5942 (error "No unread articles"))
5943 (gnus-summary-position-point))))
5945 (defun gnus-summary-last-subject ()
5946 "Go to the last displayed subject line in the group."
5947 (let ((article (gnus-data-number (car (gnus-data-list t)))))
5949 (gnus-summary-goto-subject article))))
5951 (defun gnus-summary-goto-article (article &optional all-headers force)
5952 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
5953 If ALL-HEADERS is non-nil, no header lines are hidden.
5954 If FORCE, go to the article even if it isn't displayed. If FORCE
5955 is a number, it is the line the article is to be displayed on."
5959 "Article number or Message-ID: "
5960 (mapcar (lambda (number) (list (int-to-string number)))
5961 gnus-newsgroup-limit))
5965 (if (and (stringp article)
5966 (string-match "@" article))
5967 (gnus-summary-refer-article article)
5968 (when (stringp article)
5969 (setq article (string-to-number article)))
5970 (if (gnus-summary-goto-subject article force)
5971 (gnus-summary-display-article article all-headers)
5972 (gnus-message 4 "Couldn't go to article %s" article) nil))
5973 (gnus-summary-position-point)))
5975 (defun gnus-summary-goto-last-article ()
5976 "Go to the previously read article."
5979 (when gnus-last-article
5980 (gnus-summary-goto-article gnus-last-article nil t))
5981 (gnus-summary-position-point)))
5983 (defun gnus-summary-pop-article (number)
5984 "Pop one article off the history and go to the previous.
5985 NUMBER articles will be popped off."
5988 (setq gnus-newsgroup-history
5989 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
5991 (gnus-summary-goto-article (car to) nil t)
5992 (error "Article history empty")))
5993 (gnus-summary-position-point))
5995 ;; Summary commands and functions for limiting the summary buffer.
5997 (defun gnus-summary-limit-to-articles (n)
5998 "Limit the summary buffer to the next N articles.
5999 If not given a prefix, use the process marked articles instead."
6002 (let ((articles (gnus-summary-work-articles n)))
6003 (setq gnus-newsgroup-processable nil)
6004 (gnus-summary-limit articles))
6005 (gnus-summary-position-point)))
6007 (defun gnus-summary-pop-limit (&optional total)
6008 "Restore the previous limit.
6009 If given a prefix, remove all limits."
6012 (setq gnus-newsgroup-limits
6013 (list (mapcar (lambda (h) (mail-header-number h))
6014 gnus-newsgroup-headers))))
6015 (unless gnus-newsgroup-limits
6016 (error "No limit to pop"))
6018 (gnus-summary-limit nil 'pop)
6019 (gnus-summary-position-point)))
6021 (defun gnus-summary-limit-to-subject (subject &optional header)
6022 "Limit the summary buffer to articles that have subjects that match a regexp."
6023 (interactive "sLimit to subject (regexp): ")
6025 (setq header "subject"))
6026 (when (not (equal "" subject))
6028 (let ((articles (gnus-summary-find-matching
6029 (or header "subject") subject 'all)))
6031 (error "Found no matches for \"%s\"" subject))
6032 (gnus-summary-limit articles))
6033 (gnus-summary-position-point))))
6035 (defun gnus-summary-limit-to-author (from)
6036 "Limit the summary buffer to articles that have authors that match a regexp."
6037 (interactive "sLimit to author (regexp): ")
6038 (gnus-summary-limit-to-subject from "from"))
6040 (defun gnus-summary-limit-to-age (age &optional younger-p)
6041 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6042 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6043 articles that are younger than AGE days."
6044 (interactive "nTime in days: \nP")
6046 (let ((data gnus-newsgroup-data)
6047 (cutoff (days-to-time age))
6048 articles d date is-younger)
6049 (while (setq d (pop data))
6050 (when (and (vectorp (gnus-data-header d))
6051 (setq date (mail-header-date (gnus-data-header d))))
6052 (setq is-younger (time-less-p
6053 (time-since (date-to-time date))
6058 (push (gnus-data-number d) articles))))
6059 (gnus-summary-limit (nreverse articles)))
6060 (gnus-summary-position-point)))
6062 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6064 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6066 (defun gnus-summary-limit-to-unread (&optional all)
6067 "Limit the summary buffer to articles that are not marked as read.
6068 If ALL is non-nil, limit strictly to unread articles."
6071 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6072 (gnus-summary-limit-to-marks
6073 ;; Concat all the marks that say that an article is read and have
6075 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6076 gnus-killed-mark gnus-kill-file-mark
6077 gnus-low-score-mark gnus-expirable-mark
6078 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6079 gnus-duplicate-mark gnus-souped-mark)
6082 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6083 (make-obsolete 'gnus-summary-delete-marked-with
6084 'gnus-summary-limit-exlude-marks)
6086 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6087 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6088 If REVERSE, limit the summary buffer to articles that are marked
6089 with MARKS. MARKS can either be a string of marks or a list of marks.
6090 Returns how many articles were removed."
6091 (interactive "sMarks: ")
6092 (gnus-summary-limit-to-marks marks t))
6094 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6095 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6096 If REVERSE (the prefix), limit the summary buffer to articles that are
6097 not marked with MARKS. MARKS can either be a string of marks or a
6099 Returns how many articles were removed."
6100 (interactive "sMarks: \nP")
6102 (let ((data gnus-newsgroup-data)
6103 (marks (if (listp marks) marks
6104 (append marks nil))) ; Transform to list.
6107 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6108 (memq (gnus-data-mark (car data)) marks))
6109 (push (gnus-data-number (car data)) articles))
6110 (setq data (cdr data)))
6111 (gnus-summary-limit articles))
6112 (gnus-summary-position-point)))
6114 (defun gnus-summary-limit-to-score (&optional score)
6115 "Limit to articles with score at or above SCORE."
6117 (setq score (if score
6118 (prefix-numeric-value score)
6119 (or gnus-summary-default-score 0)))
6120 (let ((data gnus-newsgroup-data)
6123 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6125 (push (gnus-data-number (car data)) articles))
6126 (setq data (cdr data)))
6128 (gnus-summary-limit articles)
6129 (gnus-summary-position-point))))
6131 (defun gnus-summary-limit-include-thread (id)
6132 "Display all the hidden articles that in the current thread."
6133 (interactive (list (mail-header-id (gnus-summary-article-header))))
6134 (let ((articles (gnus-articles-in-thread
6135 (gnus-id-to-thread (gnus-root-id id)))))
6137 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6138 (gnus-summary-position-point))))
6140 (defun gnus-summary-limit-include-dormant ()
6141 "Display all the hidden articles that are marked as dormant.
6142 Note that this command only works on a subset of the articles currently
6143 fetched for this group."
6145 (unless gnus-newsgroup-dormant
6146 (error "There are no dormant articles in this group"))
6148 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6149 (gnus-summary-position-point)))
6151 (defun gnus-summary-limit-exclude-dormant ()
6152 "Hide all dormant articles."
6155 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6156 (gnus-summary-position-point)))
6158 (defun gnus-summary-limit-exclude-childless-dormant ()
6159 "Hide all dormant articles that have no children."
6161 (let ((data (gnus-data-list t))
6162 articles d children)
6163 ;; Find all articles that are either not dormant or have
6165 (while (setq d (pop data))
6166 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6168 (gnus-article-children (gnus-data-number d)))
6171 (when (memq (car children) articles)
6176 (push (gnus-data-number d) articles)))
6179 (gnus-summary-limit articles)
6180 (gnus-summary-position-point))))
6182 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6183 "Mark all unread excluded articles as read.
6184 If ALL, mark even excluded ticked and dormants as read."
6186 (let ((articles (gnus-sorted-complement
6188 (mapcar (lambda (h) (mail-header-number h))
6189 gnus-newsgroup-headers)
6191 (sort gnus-newsgroup-limit '<)))
6193 (setq gnus-newsgroup-unreads
6194 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6196 (setq gnus-newsgroup-dormant nil
6197 gnus-newsgroup-marked nil
6198 gnus-newsgroup-reads
6200 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6201 gnus-newsgroup-reads))
6202 (while (setq article (pop articles))
6203 (unless (or (memq article gnus-newsgroup-dormant)
6204 (memq article gnus-newsgroup-marked))
6205 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6207 (defun gnus-summary-limit (articles &optional pop)
6209 ;; We pop the previous limit off the stack and use that.
6210 (setq articles (car gnus-newsgroup-limits)
6211 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6212 ;; We use the new limit, so we push the old limit on the stack.
6213 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6215 (setq gnus-newsgroup-limit articles)
6216 (let ((total (length gnus-newsgroup-data))
6217 (data (gnus-data-find-list (gnus-summary-article-number)))
6218 (gnus-summary-mark-below nil) ; Inhibit this.
6220 ;; This will do all the work of generating the new summary buffer
6221 ;; according to the new limit.
6222 (gnus-summary-prepare)
6223 ;; Hide any threads, possibly.
6224 (and gnus-show-threads
6225 gnus-thread-hide-subtree
6226 (gnus-summary-hide-all-threads))
6227 ;; Try to return to the article you were at, or one in the
6230 ;; We try to find some article after the current one.
6232 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6235 (setq data (cdr data))))
6237 ;; If there is no data, that means that we were after the last
6238 ;; article. The same goes when we can't find any articles
6239 ;; after the current one.
6240 (goto-char (point-max))
6241 (gnus-summary-find-prev))
6242 (gnus-set-mode-line 'summary)
6243 ;; We return how many articles were removed from the summary
6244 ;; buffer as a result of the new limit.
6245 (- total (length gnus-newsgroup-data))))
6247 (defsubst gnus-invisible-cut-children (threads)
6250 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6255 (defsubst gnus-cut-thread (thread)
6256 "Go forwards in the thread until we find an article that we want to display."
6257 (when (or (eq gnus-fetch-old-headers 'some)
6258 (eq gnus-fetch-old-headers 'invisible)
6259 (eq gnus-build-sparse-threads 'some)
6260 (eq gnus-build-sparse-threads 'more))
6261 ;; Deal with old-fetched headers and sparse threads.
6265 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6266 (gnus-summary-article-ancient-p
6267 (mail-header-number (car thread))))
6268 (if (or (<= (length (cdr thread)) 1)
6269 (eq gnus-fetch-old-headers 'invisible))
6270 (setq gnus-newsgroup-limit
6271 (delq (mail-header-number (car thread))
6272 gnus-newsgroup-limit)
6273 thread (cadr thread))
6274 (when (gnus-invisible-cut-children (cdr thread))
6275 (let ((th (cdr thread)))
6277 (if (memq (mail-header-number (caar th))
6278 gnus-newsgroup-limit)
6279 (setq thread (car th)
6281 (setq th (cdr th))))))))))
6284 (defun gnus-cut-threads (threads)
6285 "Cut off all uninteresting articles from the beginning of threads."
6286 (when (or (eq gnus-fetch-old-headers 'some)
6287 (eq gnus-fetch-old-headers 'invisible)
6288 (eq gnus-build-sparse-threads 'some)
6289 (eq gnus-build-sparse-threads 'more))
6292 (setcar th (gnus-cut-thread (car th)))
6293 (setq th (cdr th)))))
6294 ;; Remove nixed out threads.
6297 (defun gnus-summary-initial-limit (&optional show-if-empty)
6298 "Figure out what the initial limit is supposed to be on group entry.
6299 This entails weeding out unwanted dormants, low-scored articles,
6300 fetch-old-headers verbiage, and so on."
6301 ;; Most groups have nothing to remove.
6302 (if (or gnus-inhibit-limiting
6303 (and (null gnus-newsgroup-dormant)
6304 (not (eq gnus-fetch-old-headers 'some))
6305 (not (eq gnus-fetch-old-headers 'invisible))
6306 (null gnus-summary-expunge-below)
6307 (not (eq gnus-build-sparse-threads 'some))
6308 (not (eq gnus-build-sparse-threads 'more))
6309 (null gnus-thread-expunge-below)
6310 (not gnus-use-nocem)))
6312 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6313 (setq gnus-newsgroup-limit nil)
6316 (unless (car (symbol-value node))
6317 ;; These threads have no parents -- they are roots.
6318 (let ((nodes (cdr (symbol-value node)))
6321 (if (and gnus-thread-expunge-below
6322 (< (gnus-thread-total-score (car nodes))
6323 gnus-thread-expunge-below))
6324 (gnus-expunge-thread (pop nodes))
6325 (setq thread (pop nodes))
6326 (gnus-summary-limit-children thread))))))
6327 gnus-newsgroup-dependencies)
6328 ;; If this limitation resulted in an empty group, we might
6329 ;; pop the previous limit and use it instead.
6330 (when (and (not gnus-newsgroup-limit)
6332 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6333 gnus-newsgroup-limit))
6335 (defun gnus-summary-limit-children (thread)
6336 "Return 1 if this subthread is visible and 0 if it is not."
6337 ;; First we get the number of visible children to this thread. This
6338 ;; is done by recursing down the thread using this function, so this
6339 ;; will really go down to a leaf article first, before slowly
6340 ;; working its way up towards the root.
6344 (apply '+ (mapcar 'gnus-summary-limit-children
6347 (number (mail-header-number (car thread)))
6350 (not (memq number gnus-newsgroup-marked))
6352 ;; If this article is dormant and has absolutely no visible
6353 ;; children, then this article isn't visible.
6354 (and (memq number gnus-newsgroup-dormant)
6356 ;; If this is "fetch-old-headered" and there is no
6357 ;; visible children, then we don't want this article.
6358 (and (eq gnus-fetch-old-headers 'some)
6359 (gnus-summary-article-ancient-p number)
6361 ;; If this is "fetch-old-headered" and `invisible', then
6362 ;; we don't want this article.
6363 (and (eq gnus-fetch-old-headers 'invisible)
6364 (gnus-summary-article-ancient-p number))
6365 ;; If this is a sparsely inserted article with no children,
6366 ;; we don't want it.
6367 (and (eq gnus-build-sparse-threads 'some)
6368 (gnus-summary-article-sparse-p number)
6370 ;; If we use expunging, and this article is really
6371 ;; low-scored, then we don't want this article.
6372 (when (and gnus-summary-expunge-below
6374 (or (cdr (assq number gnus-newsgroup-scored))
6375 gnus-summary-default-score))
6376 gnus-summary-expunge-below))
6377 ;; We increase the expunge-tally here, but that has
6378 ;; nothing to do with the limits, really.
6379 (incf gnus-newsgroup-expunged-tally)
6380 ;; We also mark as read here, if that's wanted.
6381 (when (and gnus-summary-mark-below
6382 (< score gnus-summary-mark-below))
6383 (setq gnus-newsgroup-unreads
6384 (delq number gnus-newsgroup-unreads))
6385 (if gnus-newsgroup-auto-expire
6386 (push number gnus-newsgroup-expirable)
6387 (push (cons number gnus-low-score-mark)
6388 gnus-newsgroup-reads)))
6390 ;; Check NoCeM things.
6391 (if (and gnus-use-nocem
6392 (gnus-nocem-unwanted-article-p
6393 (mail-header-id (car thread))))
6395 (setq gnus-newsgroup-unreads
6396 (delq number gnus-newsgroup-unreads))
6398 ;; Nope, invisible article.
6400 ;; Ok, this article is to be visible, so we add it to the limit
6402 (push number gnus-newsgroup-limit)
6405 (defun gnus-expunge-thread (thread)
6406 "Mark all articles in THREAD as read."
6407 (let* ((number (mail-header-number (car thread))))
6408 (incf gnus-newsgroup-expunged-tally)
6409 ;; We also mark as read here, if that's wanted.
6410 (setq gnus-newsgroup-unreads
6411 (delq number gnus-newsgroup-unreads))
6412 (if gnus-newsgroup-auto-expire
6413 (push number gnus-newsgroup-expirable)
6414 (push (cons number gnus-low-score-mark)
6415 gnus-newsgroup-reads)))
6416 ;; Go recursively through all subthreads.
6417 (mapcar 'gnus-expunge-thread (cdr thread)))
6419 ;; Summary article oriented commands
6421 (defun gnus-summary-refer-parent-article (n)
6422 "Refer parent article N times.
6423 If N is negative, go to ancestor -N instead.
6424 The difference between N and the number of articles fetched is returned."
6428 (when (not (natnump n))
6433 (setq header (gnus-summary-article-header))
6434 (if (and (eq (mail-header-number header)
6435 (cdr gnus-article-current))
6436 (equal gnus-newsgroup-name
6437 (car gnus-article-current)))
6438 ;; If we try to find the parent of the currently
6439 ;; displayed article, then we take a look at the actual
6440 ;; References header, since this is slightly more
6441 ;; reliable than the References field we got from the
6444 (set-buffer gnus-original-article-buffer)
6445 (nnheader-narrow-to-headers)
6446 (unless (setq ref (message-fetch-field "references"))
6447 (setq ref (message-fetch-field "in-reply-to")))
6450 ;; It's not the current article, so we take a bet on
6451 ;; the value we got from the server.
6452 (mail-header-references header)))
6454 (not (equal ref "")))
6455 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6456 (gnus-message 1 "Couldn't find parent"))
6457 (gnus-message 1 "No references in article %d"
6458 (gnus-summary-article-number))
6461 (gnus-summary-position-point)
6464 (defun gnus-summary-refer-references ()
6465 "Fetch all articles mentioned in the References header.
6466 Return the number of articles fetched."
6468 (let ((ref (mail-header-references (gnus-summary-article-header)))
6469 (current (gnus-summary-article-number))
6473 (error "No References in the current article")
6474 ;; For each Message-ID in the References header...
6475 (while (string-match "<[^>]*>" ref)
6477 ;; ... fetch that article.
6478 (gnus-summary-refer-article
6479 (prog1 (match-string 0 ref)
6480 (setq ref (substring ref (match-end 0))))))
6481 (gnus-summary-goto-subject current)
6482 (gnus-summary-position-point)
6485 (defun gnus-summary-refer-thread (&optional limit)
6486 "Fetch all articles in the current thread.
6487 If LIMIT (the numerical prefix), fetch that many old headers instead
6488 of what's specified by the `gnus-refer-thread-limit' variable."
6490 (let ((id (mail-header-id (gnus-summary-article-header)))
6491 (limit (if limit (prefix-numeric-value limit)
6492 gnus-refer-thread-limit)))
6493 ;; We want to fetch LIMIT *old* headers, but we also have to
6494 ;; re-fetch all the headers in the current buffer, because many of
6495 ;; them may be undisplayed. So we adjust LIMIT.
6496 (when (numberp limit)
6497 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6498 (unless (eq gnus-fetch-old-headers 'invisible)
6499 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6500 ;; Retrieve the headers and read them in.
6501 (if (eq (gnus-retrieve-headers
6502 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6504 (gnus-build-all-threads)
6505 (error "Can't fetch thread from backends that don't support NOV"))
6506 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6507 (gnus-summary-limit-include-thread id)))
6509 (defun gnus-summary-refer-article (message-id &optional arg)
6510 "Fetch an article specified by MESSAGE-ID.
6511 If ARG (the prefix), fetch the article using `gnus-refer-article-method'
6512 or `gnus-select-method', no matter what backend the article comes from."
6513 (interactive "sMessage-ID: \nP")
6514 (when (and (stringp message-id)
6515 (not (zerop (length message-id))))
6516 ;; Construct the correct Message-ID if necessary.
6517 ;; Suggested by tale@pawl.rpi.edu.
6518 (unless (string-match "^<" message-id)
6519 (setq message-id (concat "<" message-id)))
6520 (unless (string-match ">$" message-id)
6521 (setq message-id (concat message-id ">")))
6522 (let* ((header (gnus-id-to-header message-id))
6524 (gnus-summary-article-sparse-p
6525 (mail-header-number header))
6526 (memq (mail-header-number header)
6527 gnus-newsgroup-limit))))
6529 ;; If the article is present in the buffer we just go to it.
6531 (or (not (gnus-summary-article-sparse-p
6532 (mail-header-number header)))
6535 (gnus-summary-goto-article
6536 (mail-header-number header) nil t)
6538 (gnus-summary-update-article (mail-header-number header)))))
6540 ;; We fetch the article
6541 (let ((gnus-override-method
6542 (cond ((gnus-news-group-p gnus-newsgroup-name)
6543 gnus-refer-article-method)
6545 (or gnus-refer-article-method gnus-select-method))
6548 ;; Start the special refer-article method, if necessary.
6549 (when (and gnus-refer-article-method
6550 (gnus-news-group-p gnus-newsgroup-name))
6551 (gnus-check-server gnus-refer-article-method))
6552 ;; Fetch the header, and display the article.
6553 (if (setq number (gnus-summary-insert-subject message-id))
6554 (gnus-summary-select-article nil nil nil number)
6555 (gnus-message 3 "Couldn't fetch article %s" message-id))))))))
6557 (defun gnus-summary-edit-parameters ()
6558 "Edit the group parameters of the current group."
6560 (gnus-group-edit-group gnus-newsgroup-name 'params))
6562 (defun gnus-summary-enter-digest-group (&optional force)
6563 "Enter an nndoc group based on the current article.
6564 If FORCE, force a digest interpretation. If not, try
6565 to guess what the document format is."
6567 (let ((conf gnus-current-window-configuration))
6569 (gnus-summary-select-article))
6570 (setq gnus-current-window-configuration conf)
6571 (let* ((name (format "%s-%d"
6572 (gnus-group-prefixed-name
6573 gnus-newsgroup-name (list 'nndoc ""))
6575 (set-buffer gnus-summary-buffer)
6576 gnus-current-article)))
6577 (ogroup gnus-newsgroup-name)
6578 (params (append (gnus-info-params (gnus-get-info ogroup))
6579 (list (cons 'to-group ogroup))
6580 (list (cons 'save-article-group ogroup))))
6581 (case-fold-search t)
6582 (buf (current-buffer))
6585 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6586 (insert-buffer-substring gnus-original-article-buffer)
6587 ;; Remove lines that may lead nndoc to misinterpret the
6590 (goto-char (point-min))
6591 (or (search-forward "\n\n" nil t) (point)))
6592 (goto-char (point-min))
6593 (delete-matching-lines "^\\(Path\\):\\|^From ")
6596 (if (gnus-group-read-ephemeral-group
6597 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6599 ,(if force 'digest 'guess))) t)
6600 ;; Make all postings to this group go to the parent group.
6601 (nconc (gnus-info-params (gnus-get-info name))
6603 ;; Couldn't select this doc group.
6604 (switch-to-buffer buf)
6605 (gnus-set-global-variables)
6606 (gnus-configure-windows 'summary)
6607 (gnus-message 3 "Article couldn't be entered?"))
6608 (kill-buffer dig)))))
6610 (defun gnus-summary-read-document (n)
6611 "Open a new group based on the current article(s).
6612 This will allow you to read digests and other similar
6613 documents as newsgroups.
6614 Obeys the standard process/prefix convention."
6616 (let* ((articles (gnus-summary-work-articles n))
6617 (ogroup gnus-newsgroup-name)
6618 (params (append (gnus-info-params (gnus-get-info ogroup))
6619 (list (cons 'to-group ogroup))))
6620 article group egroup groups vgroup)
6621 (while (setq article (pop articles))
6622 (setq group (format "%s-%d" gnus-newsgroup-name article))
6623 (gnus-summary-remove-process-mark article)
6624 (when (gnus-summary-display-article article)
6627 (insert-buffer-substring gnus-original-article-buffer)
6628 ;; Remove some headers that may lead nndoc to make
6630 (message-narrow-to-head)
6631 (goto-char (point-min))
6632 (delete-matching-lines "^\\(Path\\):\\|^From ")
6635 (gnus-group-read-ephemeral-group
6636 group `(nndoc ,group (nndoc-address ,(current-buffer))
6637 (nndoc-article-type guess))
6640 ;; Make all postings to this group go to the parent group.
6641 (nconc (gnus-info-params (gnus-get-info egroup))
6643 (push egroup groups))
6644 ;; Couldn't select this doc group.
6645 (gnus-error 3 "Article couldn't be entered"))))))
6646 ;; Now we have selected all the documents.
6649 (error "None of the articles could be interpreted as documents"))
6650 ((gnus-group-read-ephemeral-group
6651 (setq vgroup (format
6652 "nnvirtual:%s-%s" gnus-newsgroup-name
6653 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6654 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6656 (cons (current-buffer) 'summary)))
6658 (error "Couldn't select virtual nndoc group")))))
6660 (defun gnus-summary-isearch-article (&optional regexp-p)
6661 "Do incremental search forward on the current article.
6662 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6664 (gnus-summary-select-article)
6665 (gnus-configure-windows 'article)
6666 (gnus-eval-in-buffer-window gnus-article-buffer
6669 (isearch-forward regexp-p))))
6671 (defun gnus-summary-search-article-forward (regexp &optional backward)
6672 "Search for an article containing REGEXP forward.
6673 If BACKWARD, search backward instead."
6676 (format "Search article %s (regexp%s): "
6677 (if current-prefix-arg "backward" "forward")
6678 (if gnus-last-search-regexp
6679 (concat ", default " gnus-last-search-regexp)
6681 current-prefix-arg))
6682 (if (string-equal regexp "")
6683 (setq regexp (or gnus-last-search-regexp ""))
6684 (setq gnus-last-search-regexp regexp))
6685 (if (gnus-summary-search-article regexp backward)
6686 (gnus-summary-show-thread)
6687 (error "Search failed: \"%s\"" regexp)))
6689 (defun gnus-summary-search-article-backward (regexp)
6690 "Search for an article containing REGEXP backward."
6693 (format "Search article backward (regexp%s): "
6694 (if gnus-last-search-regexp
6695 (concat ", default " gnus-last-search-regexp)
6697 (gnus-summary-search-article-forward regexp 'backward))
6699 (defun gnus-summary-search-article (regexp &optional backward)
6700 "Search for an article containing REGEXP.
6701 Optional argument BACKWARD means do search for backward.
6702 `gnus-select-article-hook' is not called during the search."
6703 ;; We have to require this here to make sure that the following
6704 ;; dynamic binding isn't shadowed by autoloading.
6705 (require 'gnus-async)
6706 (let ((gnus-select-article-hook nil) ;Disable hook.
6707 (gnus-article-display-hook nil)
6708 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6709 (gnus-use-article-prefetch nil)
6710 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
6711 (gnus-use-trees nil) ;Inhibit updating tree buffer.
6712 (sum (current-buffer))
6715 (gnus-save-hidden-threads
6716 (gnus-summary-select-article)
6717 (set-buffer gnus-article-buffer)
6721 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
6723 (re-search-backward regexp nil t)
6724 (re-search-forward regexp nil t))
6725 ;; We found the regexp.
6730 (get-buffer-window (current-buffer))
6734 (setq point (point)))
6735 ;; We didn't find it, so we go to the next article.
6738 (while (eq found 'not)
6739 (if (not (if backward (gnus-summary-find-prev)
6740 (gnus-summary-find-next)))
6741 ;; No more articles.
6743 ;; Select the next article and adjust point.
6744 (unless (gnus-summary-article-sparse-p
6745 (gnus-summary-article-number))
6747 (gnus-summary-select-article)
6748 (set-buffer gnus-article-buffer)
6750 (goto-char (if backward (point-max) (point-min))))))))
6751 (gnus-message 7 ""))
6752 ;; Return whether we found the regexp.
6753 (when (eq found 'found)
6755 (gnus-summary-show-thread)
6756 (gnus-summary-goto-subject gnus-current-article)
6757 (gnus-summary-position-point)
6760 (defun gnus-summary-find-matching (header regexp &optional backward unread
6762 "Return a list of all articles that match REGEXP on HEADER.
6763 The search stars on the current article and goes forwards unless
6764 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
6765 If UNREAD is non-nil, only unread articles will
6766 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
6767 in the comparisons."
6768 (let ((data (if (eq backward 'all) gnus-newsgroup-data
6769 (gnus-data-find-list
6770 (gnus-summary-article-number) (gnus-data-list backward))))
6771 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
6772 (case-fold-search (not not-case-fold))
6774 (unless (fboundp (intern (concat "mail-header-" header)))
6775 (error "%s is not a valid header" header))
6778 (and (or (not unread) ; We want all articles...
6779 (gnus-data-unread-p d)) ; Or just unreads.
6780 (vectorp (gnus-data-header d)) ; It's not a pseudo.
6781 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
6782 (push (gnus-data-number d) articles)) ; Success!
6783 (setq data (cdr data)))
6784 (nreverse articles)))
6786 (defun gnus-summary-execute-command (header regexp command &optional backward)
6787 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
6788 If HEADER is an empty string (or nil), the match is done on the entire
6789 article. If BACKWARD (the prefix) is non-nil, search backward instead."
6791 (list (let ((completion-ignore-case t))
6794 (mapcar (lambda (string) (list string))
6795 '("Number" "Subject" "From" "Lines" "Date"
6796 "Message-ID" "Xref" "References" "Body"))
6797 nil 'require-match))
6798 (read-string "Regexp: ")
6799 (read-key-sequence "Command: ")
6800 current-prefix-arg))
6801 (when (equal header "Body")
6803 ;; Hidden thread subtrees must be searched as well.
6804 (gnus-summary-show-all-threads)
6805 ;; We don't want to change current point nor window configuration.
6807 (save-window-excursion
6808 (gnus-message 6 "Executing %s..." (key-description command))
6809 ;; We'd like to execute COMMAND interactively so as to give arguments.
6810 (gnus-execute header regexp
6811 `(call-interactively ',(key-binding command))
6813 (gnus-message 6 "Executing %s...done" (key-description command)))))
6815 (defun gnus-summary-beginning-of-article ()
6816 "Scroll the article back to the beginning."
6818 (gnus-summary-select-article)
6819 (gnus-configure-windows 'article)
6820 (gnus-eval-in-buffer-window gnus-article-buffer
6822 (goto-char (point-min))
6823 (when gnus-page-broken
6824 (gnus-narrow-to-page))))
6826 (defun gnus-summary-end-of-article ()
6827 "Scroll to the end of the article."
6829 (gnus-summary-select-article)
6830 (gnus-configure-windows 'article)
6831 (gnus-eval-in-buffer-window gnus-article-buffer
6833 (goto-char (point-max))
6835 (when gnus-page-broken
6836 (gnus-narrow-to-page))))
6838 (defun gnus-summary-print-article (&optional filename n)
6839 "Generate and print a PostScript image of the N next (mail) articles.
6841 If N is negative, print the N previous articles. If N is nil and articles
6842 have been marked with the process mark, print these instead.
6844 If the optional second argument FILENAME is nil, send the image to the
6845 printer. If FILENAME is a string, save the PostScript image in a file with
6846 that name. If FILENAME is a number, prompt the user for the name of the file
6848 (interactive (list (ps-print-preprint current-prefix-arg)
6849 current-prefix-arg))
6850 (dolist (article (gnus-summary-work-articles n))
6851 (gnus-summary-select-article nil nil 'pseudo article)
6852 (gnus-eval-in-buffer-window gnus-article-buffer
6853 (let ((buffer (generate-new-buffer " *print*")))
6856 (copy-to-buffer buffer (point-min) (point-max))
6858 (gnus-article-delete-invisible-text)
6859 (let ((ps-left-header
6862 (mail-header-subject gnus-current-headers) ")")
6864 (mail-header-from gnus-current-headers) ")")))
6867 "/pagenumberstring load"
6869 (mail-header-date gnus-current-headers) ")"))))
6870 (gnus-run-hooks 'gnus-ps-print-hook)
6872 (ps-print-buffer-with-faces filename))))
6873 (kill-buffer buffer))))))
6875 (defun gnus-summary-show-article (&optional arg)
6876 "Force re-fetching of the current article.
6877 If ARG (the prefix) is non-nil, show the raw article without any
6878 article massaging functions being run."
6881 ;; Select the article the normal way.
6882 (gnus-summary-select-article nil 'force)
6883 ;; Bind the article treatment functions to nil.
6884 (let ((gnus-have-all-headers t)
6885 gnus-article-display-hook
6886 gnus-article-prepare-hook
6887 gnus-article-decode-hook
6891 (gnus-summary-select-article nil 'force)))
6892 (gnus-summary-goto-subject gnus-current-article)
6893 (gnus-summary-position-point))
6895 (defun gnus-summary-verbose-headers (&optional arg)
6896 "Toggle permanent full header display.
6897 If ARG is a positive number, turn header display on.
6898 If ARG is a negative number, turn header display off."
6900 (setq gnus-show-all-headers
6901 (cond ((or (not (numberp arg))
6903 (not gnus-show-all-headers))
6906 (gnus-summary-show-article))
6908 (defun gnus-summary-toggle-header (&optional arg)
6909 "Show the headers if they are hidden, or hide them if they are shown.
6910 If ARG is a positive number, show the entire header.
6911 If ARG is a negative number, hide the unwanted header lines."
6914 (set-buffer gnus-article-buffer)
6915 (let* ((buffer-read-only nil)
6916 (inhibit-point-motion-hooks t)
6917 (hidden (text-property-any
6918 (goto-char (point-min)) (search-forward "\n\n")
6921 (goto-char (point-min))
6922 (when (search-forward "\n\n" nil t)
6923 (delete-region (point-min) (1- (point))))
6924 (goto-char (point-min))
6926 (set-buffer gnus-original-article-buffer)
6927 (goto-char (point-min))
6928 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
6929 (insert-buffer-substring gnus-original-article-buffer 1 e)
6930 (let ((article-inhibit-hiding t))
6931 (gnus-run-hooks 'gnus-article-display-hook))
6932 (when (or (not hidden) (and (numberp arg) (< arg 0)))
6933 (gnus-article-hide-headers)))))
6935 (defun gnus-summary-show-all-headers ()
6936 "Make all header lines visible."
6938 (gnus-article-show-all-headers))
6940 (defun gnus-summary-toggle-mime (&optional arg)
6941 "Toggle MIME processing.
6942 If ARG is a positive number, turn MIME processing on."
6944 (setq gnus-show-mime
6945 (if (null arg) (not gnus-show-mime)
6946 (> (prefix-numeric-value arg) 0)))
6947 (gnus-summary-select-article t 'force))
6949 (defun gnus-summary-caesar-message (&optional arg)
6950 "Caesar rotate the current article by 13.
6951 The numerical prefix specifies how many places to rotate each letter
6954 (gnus-summary-select-article)
6955 (let ((mail-header-separator ""))
6956 (gnus-eval-in-buffer-window gnus-article-buffer
6959 (let ((start (window-start))
6961 (message-caesar-buffer-body arg)
6962 (set-window-start (get-buffer-window (current-buffer)) start))))))
6964 (defun gnus-summary-stop-page-breaking ()
6965 "Stop page breaking in the current article."
6967 (gnus-summary-select-article)
6968 (gnus-eval-in-buffer-window gnus-article-buffer
6970 (when (gnus-visual-p 'page-marker)
6971 (let ((buffer-read-only nil))
6972 (gnus-remove-text-with-property 'gnus-prev)
6973 (gnus-remove-text-with-property 'gnus-next))
6974 (setq gnus-page-broken nil))))
6976 (defun gnus-summary-move-article (&optional n to-newsgroup
6977 select-method action)
6978 "Move the current article to a different newsgroup.
6979 If N is a positive number, move the N next articles.
6980 If N is a negative number, move the N previous articles.
6981 If N is nil and any articles have been marked with the process mark,
6982 move those articles instead.
6983 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6984 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6985 re-spool using this method.
6987 For this function to work, both the current newsgroup and the
6988 newsgroup that you want to move to have to support the `request-move'
6989 and `request-accept' functions."
6992 (setq action 'move))
6993 ;; Disable marking as read.
6994 (let (gnus-mark-article-hook)
6995 (save-window-excursion
6996 (gnus-summary-select-article)))
6997 ;; Check whether the source group supports the required functions.
6998 (cond ((and (eq action 'move)
6999 (not (gnus-check-backend-function
7000 'request-move-article gnus-newsgroup-name)))
7001 (error "The current group does not support article moving"))
7002 ((and (eq action 'crosspost)
7003 (not (gnus-check-backend-function
7004 'request-replace-article gnus-newsgroup-name)))
7005 (error "The current group does not support article editing")))
7006 (let ((articles (gnus-summary-work-articles n))
7007 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
7008 (names '((move "Move" "Moving")
7009 (copy "Copy" "Copying")
7010 (crosspost "Crosspost" "Crossposting")))
7011 (copy-buf (save-excursion
7012 (nnheader-set-temp-buffer " *copy article*")))
7013 art-group to-method new-xref article to-groups)
7014 (unless (assq action names)
7015 (error "Unknown action %s" action))
7016 ;; Read the newsgroup name.
7017 (when (and (not to-newsgroup)
7018 (not select-method))
7020 (gnus-read-move-group-name
7021 (cadr (assq action names))
7022 (symbol-value (intern (format "gnus-current-%s-group" action)))
7024 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
7025 (setq to-method (or select-method
7026 (gnus-group-name-to-method to-newsgroup)))
7027 ;; Check the method we are to move this article to...
7028 (unless (gnus-check-backend-function
7029 'request-accept-article (car to-method))
7030 (error "%s does not support article copying" (car to-method)))
7031 (unless (gnus-check-server to-method)
7032 (error "Can't open server %s" (car to-method)))
7033 (gnus-message 6 "%s to %s: %s..."
7034 (caddr (assq action names))
7035 (or (car select-method) to-newsgroup) articles)
7037 (setq article (pop articles))
7041 ;; Move the article.
7043 ;; Remove this article from future suppression.
7044 (gnus-dup-unsuppress-article article)
7045 (gnus-request-move-article
7046 article ; Article to move
7047 gnus-newsgroup-name ; From newsgroup
7048 (nth 1 (gnus-find-method-for-group
7049 gnus-newsgroup-name)) ; Server
7050 (list 'gnus-request-accept-article
7051 to-newsgroup (list 'quote select-method)
7052 (not articles)) ; Accept form
7053 (not articles))) ; Only save nov last time
7054 ;; Copy the article.
7057 (set-buffer copy-buf)
7058 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
7059 (gnus-request-accept-article
7060 to-newsgroup select-method (not articles) t))))
7061 ;; Crosspost the article.
7062 ((eq action 'crosspost)
7063 (let ((xref (message-tokenize-header
7064 (mail-header-xref (gnus-summary-article-header article))
7066 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
7069 (setq xref (list (system-name))))
7072 (mapconcat 'identity
7073 (delete "Xref:" (delete new-xref xref))
7077 (set-buffer copy-buf)
7078 ;; First put the article in the destination group.
7079 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7080 (when (consp (setq art-group
7081 (gnus-request-accept-article
7082 to-newsgroup select-method (not articles))))
7083 (setq new-xref (concat new-xref " " (car art-group)
7084 ":" (cdr art-group)))
7085 ;; Now we have the new Xrefs header, so we insert
7086 ;; it and replace the new article.
7087 (nnheader-replace-header "Xref" new-xref)
7088 (gnus-request-replace-article
7089 (cdr art-group) to-newsgroup (current-buffer))
7093 (gnus-message 1 "Couldn't %s article %s"
7094 (cadr (assq action names)) article))
7095 ((and (eq art-group 'junk)
7097 (gnus-summary-mark-article article gnus-canceled-mark)
7098 (gnus-message 4 "Deleted article %s" article))
7100 (let* ((pto-group (gnus-group-prefixed-name
7101 (car art-group) to-method))
7103 (gnus-gethash pto-group gnus-newsrc-hashtb))
7104 (info (nth 2 entry))
7105 (to-group (gnus-info-group info)))
7106 ;; Update the group that has been moved to.
7108 (memq action '(move copy)))
7109 (unless (member to-group to-groups)
7110 (push to-group to-groups))
7112 (unless (memq article gnus-newsgroup-unreads)
7114 info (gnus-add-to-range (gnus-info-read info)
7115 (list (cdr art-group)))))
7117 ;; Copy any marks over to the new group.
7118 (let ((marks gnus-article-mark-lists)
7119 (to-article (cdr art-group)))
7121 ;; See whether the article is to be put in the cache.
7122 (when gnus-use-cache
7123 (gnus-cache-possibly-enter-article
7125 (let ((header (copy-sequence
7126 (gnus-summary-article-header article))))
7127 (mail-header-set-number header to-article)
7129 (memq article gnus-newsgroup-marked)
7130 (memq article gnus-newsgroup-dormant)
7131 (memq article gnus-newsgroup-unreads)))
7133 (when (and (equal to-group gnus-newsgroup-name)
7134 (not (memq article gnus-newsgroup-unreads)))
7135 ;; Mark this article as read in this group.
7136 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7137 (setcdr (gnus-active to-group) to-article)
7138 (setcdr gnus-newsgroup-active to-article))
7141 (when (memq article (symbol-value
7142 (intern (format "gnus-newsgroup-%s"
7144 ;; If the other group is the same as this group,
7145 ;; then we have to add the mark to the list.
7146 (when (equal to-group gnus-newsgroup-name)
7147 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7150 (intern (format "gnus-newsgroup-%s"
7152 ;; Copy the marks to other group.
7153 (gnus-add-marked-articles
7154 to-group (cdar marks) (list to-article) info))
7155 (setq marks (cdr marks)))
7158 (concat "(gnus-group-set-info '"
7159 (gnus-prin1-to-string (gnus-get-info to-group))
7162 ;; Update the Xref header in this article to point to
7163 ;; the new crossposted article we have just created.
7164 (when (eq action 'crosspost)
7166 (set-buffer copy-buf)
7167 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7168 (nnheader-replace-header "Xref" new-xref)
7169 (gnus-request-replace-article
7170 article gnus-newsgroup-name (current-buffer)))))
7172 ;;;!!!Why is this necessary?
7173 (set-buffer gnus-summary-buffer)
7175 (gnus-summary-goto-subject article)
7176 (when (eq action 'move)
7177 (gnus-summary-mark-article article gnus-canceled-mark))))
7178 (gnus-summary-remove-process-mark article))
7179 ;; Re-activate all groups that have been moved to.
7182 (set-buffer gnus-group-buffer)
7183 (when (gnus-group-goto-group (car to-groups) t)
7184 (gnus-group-get-new-news-this-group 1 t))
7187 (gnus-kill-buffer copy-buf)
7188 (gnus-summary-position-point)
7189 (gnus-set-mode-line 'summary)))
7191 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7192 "Move the current article to a different newsgroup.
7193 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7194 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7195 re-spool using this method."
7197 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7199 (defun gnus-summary-crosspost-article (&optional n)
7200 "Crosspost the current article to some other group."
7202 (gnus-summary-move-article n nil nil 'crosspost))
7204 (defcustom gnus-summary-respool-default-method nil
7205 "Default method for respooling an article.
7206 If nil, use to the current newsgroup method."
7207 :type '(choice (gnus-select-method :value (nnml ""))
7209 :group 'gnus-summary-mail)
7211 (defun gnus-summary-respool-article (&optional n method)
7212 "Respool the current article.
7213 The article will be squeezed through the mail spooling process again,
7214 which means that it will be put in some mail newsgroup or other
7215 depending on `nnmail-split-methods'.
7216 If N is a positive number, respool the N next articles.
7217 If N is a negative number, respool the N previous articles.
7218 If N is nil and any articles have been marked with the process mark,
7219 respool those articles instead.
7221 Respooling can be done both from mail groups and \"real\" newsgroups.
7222 In the former case, the articles in question will be moved from the
7223 current group into whatever groups they are destined to. In the
7224 latter case, they will be copied into the relevant groups."
7226 (list current-prefix-arg
7227 (let* ((methods (gnus-methods-using 'respool))
7229 (symbol-name (or gnus-summary-respool-default-method
7230 (car (gnus-find-method-for-group
7231 gnus-newsgroup-name)))))
7233 (gnus-completing-read
7234 methname "What backend do you want to use when respooling?"
7235 methods nil t nil 'gnus-mail-method-history))
7238 ((zerop (length (setq ms (gnus-servers-using-backend
7240 (list (intern method) ""))
7244 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7245 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7248 (error "No method given for respooling"))
7249 (if (assoc (symbol-name
7250 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7251 (gnus-methods-using 'respool))
7252 (gnus-summary-move-article n nil method)
7253 (gnus-summary-copy-article n nil method)))
7255 (defun gnus-summary-import-article (file)
7256 "Import an arbitrary file into a mail newsgroup."
7257 (interactive "fImport file: ")
7258 (let ((group gnus-newsgroup-name)
7259 (now (current-time))
7261 (unless (gnus-check-backend-function 'request-accept-article group)
7262 (error "%s does not support article importing" group))
7263 (or (file-readable-p file)
7264 (not (file-regular-p file))
7265 (error "Can't read %s" file))
7267 (set-buffer (gnus-get-buffer-create " *import file*"))
7269 (nnheader-insert-file-contents file)
7270 (goto-char (point-min))
7271 (unless (nnheader-article-p)
7272 ;; This doesn't look like an article, so we fudge some headers.
7273 (setq atts (file-attributes file)
7274 lines (count-lines (point-min) (point-max)))
7275 (insert "From: " (read-string "From: ") "\n"
7276 "Subject: " (read-string "Subject: ") "\n"
7277 "Date: " (message-make-date (nth 5 atts))
7279 "Message-ID: " (message-make-message-id) "\n"
7280 "Lines: " (int-to-string lines) "\n"
7281 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7282 (gnus-request-accept-article group nil t)
7283 (kill-buffer (current-buffer)))))
7285 (defun gnus-summary-article-posted-p ()
7286 "Say whether the current (mail) article is available from `gnus-select-method' as well.
7287 This will be the case if the article has both been mailed and posted."
7289 (let ((id (mail-header-references (gnus-summary-article-header)))
7290 (gnus-override-method
7291 (or gnus-refer-article-method gnus-select-method)))
7292 (if (gnus-request-head id "")
7293 (gnus-message 2 "The current message was found on %s"
7294 gnus-override-method)
7295 (gnus-message 2 "The current message couldn't be found on %s"
7296 gnus-override-method)
7299 (defun gnus-summary-expire-articles (&optional now)
7300 "Expire all articles that are marked as expirable in the current group."
7302 (when (gnus-check-backend-function
7303 'request-expire-articles gnus-newsgroup-name)
7304 ;; This backend supports expiry.
7305 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7306 (expirable (if total
7308 ;; We need to update the info for
7309 ;; this group for `gnus-list-of-read-articles'
7310 ;; to give us the right answer.
7311 (gnus-run-hooks 'gnus-exit-group-hook)
7312 (gnus-summary-update-info)
7313 (gnus-list-of-read-articles gnus-newsgroup-name))
7314 (setq gnus-newsgroup-expirable
7315 (sort gnus-newsgroup-expirable '<))))
7316 (expiry-wait (if now 'immediate
7317 (gnus-group-find-parameter
7318 gnus-newsgroup-name 'expiry-wait)))
7321 ;; There are expirable articles in this group, so we run them
7322 ;; through the expiry process.
7323 (gnus-message 6 "Expiring articles...")
7324 ;; The list of articles that weren't expired is returned.
7327 (let ((nnmail-expiry-wait-function nil)
7328 (nnmail-expiry-wait expiry-wait))
7329 (setq es (gnus-request-expire-articles
7330 expirable gnus-newsgroup-name)))
7331 (setq es (gnus-request-expire-articles
7332 expirable gnus-newsgroup-name))))
7334 (setq gnus-newsgroup-expirable es))
7335 ;; We go through the old list of expirable, and mark all
7336 ;; really expired articles as nonexistent.
7337 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7338 (let ((gnus-use-cache nil))
7340 (unless (memq (car expirable) es)
7341 (when (gnus-data-find (car expirable))
7342 (gnus-summary-mark-article
7343 (car expirable) gnus-canceled-mark)))
7344 (setq expirable (cdr expirable)))))
7345 (gnus-message 6 "Expiring articles...done")))))
7347 (defun gnus-summary-expire-articles-now ()
7348 "Expunge all expirable articles in the current group.
7349 This means that *all* articles that are marked as expirable will be
7350 deleted forever, right now."
7352 (or gnus-expert-user
7354 "Are you really, really, really sure you want to delete all these messages? ")
7356 (gnus-summary-expire-articles t))
7358 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7359 (defun gnus-summary-delete-article (&optional n)
7360 "Delete the N next (mail) articles.
7361 This command actually deletes articles. This is not a marking
7362 command. The article will disappear forever from your life, never to
7364 If N is negative, delete backwards.
7365 If N is nil and articles have been marked with the process mark,
7366 delete these instead."
7368 (unless (gnus-check-backend-function 'request-expire-articles
7369 gnus-newsgroup-name)
7370 (error "The current newsgroup does not support article deletion"))
7371 ;; Compute the list of articles to delete.
7372 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
7374 (if (and gnus-novice-user
7375 (not (gnus-yes-or-no-p
7376 (format "Do you really want to delete %s forever? "
7377 (if (> (length articles) 1)
7378 (format "these %s articles" (length articles))
7381 ;; Delete the articles.
7382 (setq not-deleted (gnus-request-expire-articles
7383 articles gnus-newsgroup-name 'force))
7385 (gnus-summary-remove-process-mark (car articles))
7386 ;; The backend might not have been able to delete the article
7388 (unless (memq (car articles) not-deleted)
7389 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7390 (setq articles (cdr articles)))
7392 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7393 (gnus-summary-position-point)
7394 (gnus-set-mode-line 'summary)
7397 (defun gnus-summary-edit-article (&optional force)
7398 "Edit the current article.
7399 This will have permanent effect only in mail groups.
7400 If FORCE is non-nil, allow editing of articles even in read-only
7404 (set-buffer gnus-summary-buffer)
7405 (gnus-set-global-variables)
7406 (when (and (not force)
7407 (gnus-group-read-only-p))
7408 (error "The current newsgroup does not support article editing"))
7409 ;; Select article if needed.
7410 (unless (eq (gnus-summary-article-number)
7411 gnus-current-article)
7412 (gnus-summary-select-article t))
7413 (gnus-article-date-original)
7414 (gnus-article-edit-article
7415 `(lambda (no-highlight)
7416 (gnus-summary-edit-article-done
7417 ,(or (mail-header-references gnus-current-headers) "")
7418 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))
7420 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7422 (defun gnus-summary-edit-article-done (&optional references read-only buffer
7424 "Make edits to the current article permanent."
7426 ;; Replace the article.
7427 (let ((buf (current-buffer)))
7430 (if (and (not read-only)
7431 (not (gnus-request-replace-article
7432 (cdr gnus-article-current) (car gnus-article-current)
7434 (error "Couldn't replace article")
7435 ;; Update the summary buffer.
7437 (equal (message-tokenize-header references " ")
7438 (message-tokenize-header
7439 (or (message-fetch-field "references") "") " ")))
7440 ;; We only have to update this line.
7443 (message-narrow-to-head)
7444 (let ((head (buffer-string))
7447 (insert (format "211 %d Article retrieved.\n"
7448 (cdr gnus-article-current)))
7451 (let ((nntp-server-buffer (current-buffer)))
7452 (setq header (car (gnus-get-newsgroup-headers
7454 (set-buffer gnus-summary-buffer)
7455 gnus-newsgroup-dependencies)
7458 (set-buffer gnus-summary-buffer)
7459 (gnus-data-set-header
7460 (gnus-data-find (cdr gnus-article-current))
7462 (gnus-summary-update-article-line
7463 (cdr gnus-article-current) header))))))
7465 (set-buffer (or buffer gnus-summary-buffer))
7466 (gnus-summary-update-article (cdr gnus-article-current)))
7467 ;; Prettify the article buffer again.
7468 (unless no-highlight
7470 (set-buffer gnus-article-buffer)
7471 (gnus-run-hooks 'gnus-article-display-hook)
7472 (set-buffer gnus-original-article-buffer)
7473 (gnus-request-article
7474 (cdr gnus-article-current)
7475 (car gnus-article-current) (current-buffer))))
7476 ;; Prettify the summary buffer line.
7477 (when (gnus-visual-p 'summary-highlight 'highlight)
7478 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
7480 (defun gnus-summary-edit-wash (key)
7481 "Perform editing command KEY in the article buffer."
7485 (message "%s" (concat (this-command-keys) "- "))
7488 (gnus-summary-edit-article)
7489 (execute-kbd-macro (concat (this-command-keys) key))
7490 (gnus-article-edit-done))
7494 (defun gnus-summary-respool-query (&optional silent trace)
7495 "Query where the respool algorithm would put this article."
7497 (let (gnus-mark-article-hook)
7498 (gnus-summary-select-article)
7500 (set-buffer gnus-original-article-buffer)
7502 (message-narrow-to-head)
7503 (let ((groups (nnmail-article-group 'identity trace)))
7506 (message "This message would go to %s"
7507 (mapconcat 'car groups ", "))
7508 (message "This message would go to no groups"))
7511 (defun gnus-summary-respool-trace ()
7512 "Trace where the respool algorithm would put this article.
7513 Display a buffer showing all fancy splitting patterns which matched."
7515 (gnus-summary-respool-query nil t))
7517 ;; Summary marking commands.
7519 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
7520 "Mark articles which has the same subject as read, and then select the next.
7521 If UNMARK is positive, remove any kind of mark.
7522 If UNMARK is negative, tick articles."
7525 (setq unmark (prefix-numeric-value unmark)))
7527 (gnus-summary-mark-same-subject
7528 (gnus-summary-article-subject) unmark)))
7529 ;; Select next unread article. If auto-select-same mode, should
7530 ;; select the first unread article.
7531 (gnus-summary-next-article t (and gnus-auto-select-same
7532 (gnus-summary-article-subject)))
7533 (gnus-message 7 "%d article%s marked as %s"
7534 count (if (= count 1) " is" "s are")
7535 (if unmark "unread" "read"))))
7537 (defun gnus-summary-kill-same-subject (&optional unmark)
7538 "Mark articles which has the same subject as read.
7539 If UNMARK is positive, remove any kind of mark.
7540 If UNMARK is negative, tick articles."
7543 (setq unmark (prefix-numeric-value unmark)))
7545 (gnus-summary-mark-same-subject
7546 (gnus-summary-article-subject) unmark)))
7547 ;; If marked as read, go to next unread subject.
7549 ;; Go to next unread subject.
7550 (gnus-summary-next-subject 1 t))
7551 (gnus-message 7 "%d articles are marked as %s"
7552 count (if unmark "unread" "read"))))
7554 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7555 "Mark articles with same SUBJECT as read, and return marked number.
7556 If optional argument UNMARK is positive, remove any kinds of marks.
7557 If optional argument UNMARK is negative, mark articles as unread instead."
7561 ((null unmark) ; Mark as read.
7564 (gnus-summary-mark-article-as-read gnus-killed-mark)
7565 (gnus-summary-show-thread) t)
7566 (gnus-summary-find-subject subject))
7567 (setq count (1+ count))))
7568 ((> unmark 0) ; Tick.
7571 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
7572 (gnus-summary-show-thread) t)
7573 (gnus-summary-find-subject subject))
7574 (setq count (1+ count))))
7575 (t ; Mark as unread.
7578 (gnus-summary-mark-article-as-unread gnus-unread-mark)
7579 (gnus-summary-show-thread) t)
7580 (gnus-summary-find-subject subject))
7581 (setq count (1+ count)))))
7582 (gnus-set-mode-line 'summary)
7583 ;; Return the number of marked articles.
7586 (defun gnus-summary-mark-as-processable (n &optional unmark)
7587 "Set the process mark on the next N articles.
7588 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7589 the process mark instead. The difference between N and the actual
7590 number of articles marked is returned."
7592 (let ((backward (< n 0))
7597 (gnus-summary-remove-process-mark
7598 (gnus-summary-article-number))
7599 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7600 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7603 (gnus-message 7 "No more articles"))
7604 (gnus-summary-recenter)
7605 (gnus-summary-position-point)
7608 (defun gnus-summary-unmark-as-processable (n)
7609 "Remove the process mark from the next N articles.
7610 If N is negative, unmark backward instead. The difference between N and
7611 the actual number of articles unmarked is returned."
7613 (gnus-summary-mark-as-processable n t))
7615 (defun gnus-summary-unmark-all-processable ()
7616 "Remove the process mark from all articles."
7619 (while gnus-newsgroup-processable
7620 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7621 (gnus-summary-position-point))
7623 (defun gnus-summary-mark-as-expirable (n)
7624 "Mark N articles forward as expirable.
7625 If N is negative, mark backward instead. The difference between N and
7626 the actual number of articles marked is returned."
7628 (gnus-summary-mark-forward n gnus-expirable-mark))
7630 (defun gnus-summary-mark-article-as-replied (article)
7631 "Mark ARTICLE replied and update the summary line."
7632 (push article gnus-newsgroup-replied)
7633 (let ((buffer-read-only nil))
7634 (when (gnus-summary-goto-subject article nil t)
7635 (gnus-summary-update-secondary-mark article))))
7637 (defun gnus-summary-set-bookmark (article)
7638 "Set a bookmark in current article."
7639 (interactive (list (gnus-summary-article-number)))
7640 (when (or (not (get-buffer gnus-article-buffer))
7641 (not gnus-current-article)
7642 (not gnus-article-current)
7643 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7644 (error "No current article selected"))
7645 ;; Remove old bookmark, if one exists.
7646 (let ((old (assq article gnus-newsgroup-bookmarks)))
7648 (setq gnus-newsgroup-bookmarks
7649 (delq old gnus-newsgroup-bookmarks))))
7650 ;; Set the new bookmark, which is on the form
7651 ;; (article-number . line-number-in-body).
7655 (set-buffer gnus-article-buffer)
7659 (goto-char (point-min))
7660 (search-forward "\n\n" nil t)
7663 gnus-newsgroup-bookmarks)
7664 (gnus-message 6 "A bookmark has been added to the current article."))
7666 (defun gnus-summary-remove-bookmark (article)
7667 "Remove the bookmark from the current article."
7668 (interactive (list (gnus-summary-article-number)))
7669 ;; Remove old bookmark, if one exists.
7670 (let ((old (assq article gnus-newsgroup-bookmarks)))
7673 (setq gnus-newsgroup-bookmarks
7674 (delq old gnus-newsgroup-bookmarks))
7675 (gnus-message 6 "Removed bookmark."))
7676 (gnus-message 6 "No bookmark in current article."))))
7678 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7679 (defun gnus-summary-mark-as-dormant (n)
7680 "Mark N articles forward as dormant.
7681 If N is negative, mark backward instead. The difference between N and
7682 the actual number of articles marked is returned."
7684 (gnus-summary-mark-forward n gnus-dormant-mark))
7686 (defun gnus-summary-set-process-mark (article)
7687 "Set the process mark on ARTICLE and update the summary line."
7688 (setq gnus-newsgroup-processable
7690 (delq article gnus-newsgroup-processable)))
7691 (when (gnus-summary-goto-subject article)
7692 (gnus-summary-show-thread)
7693 (gnus-summary-goto-subject article)
7694 (gnus-summary-update-secondary-mark article)))
7696 (defun gnus-summary-remove-process-mark (article)
7697 "Remove the process mark from ARTICLE and update the summary line."
7698 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7699 (when (gnus-summary-goto-subject article)
7700 (gnus-summary-show-thread)
7701 (gnus-summary-goto-subject article)
7702 (gnus-summary-update-secondary-mark article)))
7704 (defun gnus-summary-set-saved-mark (article)
7705 "Set the process mark on ARTICLE and update the summary line."
7706 (push article gnus-newsgroup-saved)
7707 (when (gnus-summary-goto-subject article)
7708 (gnus-summary-update-secondary-mark article)))
7710 (defun gnus-summary-mark-forward (n &optional mark no-expire)
7711 "Mark N articles as read forwards.
7712 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
7713 The difference between N and the actual number of articles marked is
7716 (gnus-summary-show-thread)
7717 (let ((backward (< n 0))
7718 (gnus-summary-goto-unread
7719 (and gnus-summary-goto-unread
7720 (not (eq gnus-summary-goto-unread 'never))
7721 (not (memq mark (list gnus-unread-mark
7722 gnus-ticked-mark gnus-dormant-mark)))))
7724 (mark (or mark gnus-del-mark)))
7726 (gnus-summary-mark-article nil mark no-expire)
7727 (zerop (gnus-summary-next-subject
7729 (and gnus-summary-goto-unread
7730 (not (eq gnus-summary-goto-unread 'never)))
7734 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
7735 (gnus-summary-recenter)
7736 (gnus-summary-position-point)
7737 (gnus-set-mode-line 'summary)
7740 (defun gnus-summary-mark-article-as-read (mark)
7741 "Mark the current article quickly as read with MARK."
7742 (let ((article (gnus-summary-article-number)))
7743 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7744 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7745 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7746 (push (cons article mark) gnus-newsgroup-reads)
7747 ;; Possibly remove from cache, if that is used.
7748 (when gnus-use-cache
7749 (gnus-cache-enter-remove-article article))
7750 ;; Allow the backend to change the mark.
7751 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7752 ;; Check for auto-expiry.
7753 (when (and gnus-newsgroup-auto-expire
7754 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7755 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7756 (= mark gnus-ancient-mark)
7757 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7758 (= mark gnus-duplicate-mark)))
7759 (setq mark gnus-expirable-mark)
7760 ;; Let the backend know about the mark change.
7761 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7762 (push article gnus-newsgroup-expirable))
7763 ;; Set the mark in the buffer.
7764 (gnus-summary-update-mark mark 'unread)
7767 (defun gnus-summary-mark-article-as-unread (mark)
7768 "Mark the current article quickly as unread with MARK."
7769 (let* ((article (gnus-summary-article-number))
7770 (old-mark (gnus-summary-article-mark article)))
7771 ;; Allow the backend to change the mark.
7772 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7773 (if (eq mark old-mark)
7777 (gnus-error 1 "Can't mark negative article numbers")
7779 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7780 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7781 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
7782 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
7783 (cond ((= mark gnus-ticked-mark)
7784 (push article gnus-newsgroup-marked))
7785 ((= mark gnus-dormant-mark)
7786 (push article gnus-newsgroup-dormant))
7788 (push article gnus-newsgroup-unreads)))
7789 (gnus-pull article gnus-newsgroup-reads)
7791 ;; See whether the article is to be put in the cache.
7793 (vectorp (gnus-summary-article-header article))
7795 (gnus-cache-possibly-enter-article
7796 gnus-newsgroup-name article
7797 (gnus-summary-article-header article)
7798 (= mark gnus-ticked-mark)
7799 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7802 (gnus-summary-update-mark mark 'unread)
7805 (defun gnus-summary-mark-article (&optional article mark no-expire)
7806 "Mark ARTICLE with MARK. MARK can be any character.
7807 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
7808 `??' (dormant) and `?E' (expirable).
7809 If MARK is nil, then the default character `?D' is used.
7810 If ARTICLE is nil, then the article on the current line will be
7812 ;; The mark might be a string.
7813 (when (stringp mark)
7814 (setq mark (aref mark 0)))
7815 ;; If no mark is given, then we check auto-expiring.
7816 (and (not no-expire)
7817 gnus-newsgroup-auto-expire
7819 (and (gnus-characterp mark)
7820 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7821 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7822 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7823 (= mark gnus-duplicate-mark))))
7824 (setq mark gnus-expirable-mark))
7825 (let* ((mark (or mark gnus-del-mark))
7826 (article (or article (gnus-summary-article-number)))
7827 (old-mark (gnus-summary-article-mark article)))
7828 ;; Allow the backend to change the mark.
7829 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7830 (if (eq mark old-mark)
7833 (error "No article on current line"))
7834 (if (not (if (or (= mark gnus-unread-mark)
7835 (= mark gnus-ticked-mark)
7836 (= mark gnus-dormant-mark))
7837 (gnus-mark-article-as-unread article mark)
7838 (gnus-mark-article-as-read article mark)))
7840 ;; See whether the article is to be put in the cache.
7842 (not (= mark gnus-canceled-mark))
7843 (vectorp (gnus-summary-article-header article))
7845 (gnus-cache-possibly-enter-article
7846 gnus-newsgroup-name article
7847 (gnus-summary-article-header article)
7848 (= mark gnus-ticked-mark)
7849 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7851 (when (gnus-summary-goto-subject article nil t)
7852 (let ((buffer-read-only nil))
7853 (gnus-summary-show-thread)
7855 (gnus-summary-update-mark mark 'unread)
7858 (defun gnus-summary-update-secondary-mark (article)
7859 "Update the secondary (read, process, cache) mark."
7860 (gnus-summary-update-mark
7861 (cond ((memq article gnus-newsgroup-processable)
7863 ((memq article gnus-newsgroup-cached)
7865 ((memq article gnus-newsgroup-replied)
7867 ((memq article gnus-newsgroup-saved)
7869 (t gnus-unread-mark))
7871 (when (gnus-visual-p 'summary-highlight 'highlight)
7872 (gnus-run-hooks 'gnus-summary-update-hook))
7875 (defun gnus-summary-update-mark (mark type)
7876 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
7877 (buffer-read-only nil))
7878 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
7880 (when (looking-at "\r")
7882 (when (<= (+ forward (point)) (point-max))
7883 ;; Go to the right position on the line.
7884 (goto-char (+ forward (point)))
7885 ;; Replace the old mark with the new mark.
7886 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
7887 ;; Optionally update the marks by some user rule.
7888 (when (eq type 'unread)
7890 (gnus-data-find (gnus-summary-article-number)) mark)
7891 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
7893 (defun gnus-mark-article-as-read (article &optional mark)
7894 "Enter ARTICLE in the pertinent lists and remove it from others."
7895 ;; Make the article expirable.
7896 (let ((mark (or mark gnus-del-mark)))
7897 (if (= mark gnus-expirable-mark)
7898 (push article gnus-newsgroup-expirable)
7899 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
7900 ;; Remove from unread and marked lists.
7901 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7902 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7903 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7904 (push (cons article mark) gnus-newsgroup-reads)
7905 ;; Possibly remove from cache, if that is used.
7906 (when gnus-use-cache
7907 (gnus-cache-enter-remove-article article))
7910 (defun gnus-mark-article-as-unread (article &optional mark)
7911 "Enter ARTICLE in the pertinent lists and remove it from others."
7912 (let ((mark (or mark gnus-ticked-mark)))
7915 (gnus-error 1 "Can't mark negative article numbers")
7917 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
7918 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
7919 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
7920 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7922 ;; Unsuppress duplicates?
7923 (when gnus-suppress-duplicates
7924 (gnus-dup-unsuppress-article article))
7926 (cond ((= mark gnus-ticked-mark)
7927 (push article gnus-newsgroup-marked))
7928 ((= mark gnus-dormant-mark)
7929 (push article gnus-newsgroup-dormant))
7931 (push article gnus-newsgroup-unreads)))
7932 (gnus-pull article gnus-newsgroup-reads)
7935 (defalias 'gnus-summary-mark-as-unread-forward
7936 'gnus-summary-tick-article-forward)
7937 (make-obsolete 'gnus-summary-mark-as-unread-forward
7938 'gnus-summary-tick-article-forward)
7939 (defun gnus-summary-tick-article-forward (n)
7940 "Tick N articles forwards.
7941 If N is negative, tick backwards instead.
7942 The difference between N and the number of articles ticked is returned."
7944 (gnus-summary-mark-forward n gnus-ticked-mark))
7946 (defalias 'gnus-summary-mark-as-unread-backward
7947 'gnus-summary-tick-article-backward)
7948 (make-obsolete 'gnus-summary-mark-as-unread-backward
7949 'gnus-summary-tick-article-backward)
7950 (defun gnus-summary-tick-article-backward (n)
7951 "Tick N articles backwards.
7952 The difference between N and the number of articles ticked is returned."
7954 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
7956 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7957 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7958 (defun gnus-summary-tick-article (&optional article clear-mark)
7959 "Mark current article as unread.
7960 Optional 1st argument ARTICLE specifies article number to be marked as unread.
7961 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
7963 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
7966 (defun gnus-summary-mark-as-read-forward (n)
7967 "Mark N articles as read forwards.
7968 If N is negative, mark backwards instead.
7969 The difference between N and the actual number of articles marked is
7972 (gnus-summary-mark-forward n gnus-del-mark t))
7974 (defun gnus-summary-mark-as-read-backward (n)
7975 "Mark the N articles as read backwards.
7976 The difference between N and the actual number of articles marked is
7979 (gnus-summary-mark-forward (- n) gnus-del-mark t))
7981 (defun gnus-summary-mark-as-read (&optional article mark)
7982 "Mark current article as read.
7983 ARTICLE specifies the article to be marked as read.
7984 MARK specifies a string to be inserted at the beginning of the line."
7985 (gnus-summary-mark-article article mark))
7987 (defun gnus-summary-clear-mark-forward (n)
7988 "Clear marks from N articles forward.
7989 If N is negative, clear backward instead.
7990 The difference between N and the number of marks cleared is returned."
7992 (gnus-summary-mark-forward n gnus-unread-mark))
7994 (defun gnus-summary-clear-mark-backward (n)
7995 "Clear marks from N articles backward.
7996 The difference between N and the number of marks cleared is returned."
7998 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8000 (defun gnus-summary-mark-unread-as-read ()
8001 "Intended to be used by `gnus-summary-mark-article-hook'."
8002 (when (memq gnus-current-article gnus-newsgroup-unreads)
8003 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
8005 (defun gnus-summary-mark-read-and-unread-as-read ()
8006 "Intended to be used by `gnus-summary-mark-article-hook'."
8007 (let ((mark (gnus-summary-article-mark)))
8008 (when (or (gnus-unread-mark-p mark)
8009 (gnus-read-mark-p mark))
8010 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
8012 (defun gnus-summary-mark-region-as-read (point mark all)
8013 "Mark all unread articles between point and mark as read.
8014 If given a prefix, mark all articles between point and mark as read,
8015 even ticked and dormant ones."
8016 (interactive "r\nP")
8025 (memq (setq article (gnus-summary-article-number))
8026 gnus-newsgroup-unreads))
8027 (gnus-summary-mark-article article gnus-del-mark))
8029 (gnus-summary-find-next))))))
8031 (defun gnus-summary-mark-below (score mark)
8032 "Mark articles with score less than SCORE with MARK."
8033 (interactive "P\ncMark: ")
8034 (setq score (if score
8035 (prefix-numeric-value score)
8036 (or gnus-summary-default-score 0)))
8038 (set-buffer gnus-summary-buffer)
8039 (goto-char (point-min))
8042 (and (< (gnus-summary-article-score) score)
8043 (gnus-summary-mark-article nil mark))
8044 (gnus-summary-find-next)))))
8046 (defun gnus-summary-kill-below (&optional score)
8047 "Mark articles with score below SCORE as read."
8049 (gnus-summary-mark-below score gnus-killed-mark))
8051 (defun gnus-summary-clear-above (&optional score)
8052 "Clear all marks from articles with score above SCORE."
8054 (gnus-summary-mark-above score gnus-unread-mark))
8056 (defun gnus-summary-tick-above (&optional score)
8057 "Tick all articles with score above SCORE."
8059 (gnus-summary-mark-above score gnus-ticked-mark))
8061 (defun gnus-summary-mark-above (score mark)
8062 "Mark articles with score over SCORE with MARK."
8063 (interactive "P\ncMark: ")
8064 (setq score (if score
8065 (prefix-numeric-value score)
8066 (or gnus-summary-default-score 0)))
8068 (set-buffer gnus-summary-buffer)
8069 (goto-char (point-min))
8071 (when (> (gnus-summary-article-score) score)
8072 (gnus-summary-mark-article nil mark))
8074 (gnus-summary-find-next)))))
8076 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8077 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
8078 (defun gnus-summary-limit-include-expunged (&optional no-error)
8079 "Display all the hidden articles that were expunged for low scores."
8081 (let ((buffer-read-only nil))
8082 (let ((scored gnus-newsgroup-scored)
8085 (unless (gnus-summary-goto-subject (caar scored))
8086 (and (setq h (gnus-summary-article-header (caar scored)))
8087 (< (cdar scored) gnus-summary-expunge-below)
8089 (setq scored (cdr scored)))
8091 (when (not no-error)
8092 (error "No expunged articles hidden"))
8093 (goto-char (point-min))
8094 (gnus-summary-prepare-unthreaded (nreverse headers))
8095 (goto-char (point-min))
8096 (gnus-summary-position-point)
8099 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
8100 "Mark all unread articles in this newsgroup as read.
8101 If prefix argument ALL is non-nil, ticked and dormant articles will
8102 also be marked as read.
8103 If QUIETLY is non-nil, no questions will be asked.
8104 If TO-HERE is non-nil, it should be a point in the buffer. All
8105 articles before this point will be marked as read.
8106 Note that this function will only catch up the unread article
8107 in the current summary buffer limitation.
8108 The number of articles marked as read is returned."
8113 (not gnus-interactive-catchup) ;Without confirmation?
8117 "Mark absolutely all articles as read? "
8118 "Mark all unread articles as read? ")))
8120 (not gnus-newsgroup-adaptive)
8121 (not gnus-newsgroup-auto-expire)
8122 (not gnus-suppress-duplicates)
8123 (or (not gnus-use-cache)
8124 (eq gnus-use-cache 'passive)))
8127 (setq gnus-newsgroup-marked nil
8128 gnus-newsgroup-dormant nil))
8129 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8130 ;; We actually mark all articles as canceled, which we
8131 ;; have to do when using auto-expiry or adaptive scoring.
8132 (gnus-summary-show-all-threads)
8133 (when (gnus-summary-first-subject (not all) t)
8135 (if to-here (< (point) to-here) t)
8136 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8137 (gnus-summary-find-next (not all) nil nil t))))
8138 (gnus-set-mode-line 'summary))
8140 (gnus-summary-position-point)))
8142 (defun gnus-summary-catchup-to-here (&optional all)
8143 "Mark all unticked articles before the current one as read.
8144 If ALL is non-nil, also mark ticked and dormant articles as read."
8147 (gnus-save-hidden-threads
8148 (let ((beg (point)))
8149 ;; We check that there are unread articles.
8150 (when (or all (gnus-summary-find-prev))
8151 (gnus-summary-catchup all t beg)))))
8152 (gnus-summary-position-point))
8154 (defun gnus-summary-catchup-all (&optional quietly)
8155 "Mark all articles in this newsgroup as read."
8157 (gnus-summary-catchup t quietly))
8159 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8160 "Mark all articles not marked as unread in this newsgroup as read, then exit.
8161 If prefix argument ALL is non-nil, all articles are marked as read."
8163 (when (gnus-summary-catchup all quietly nil 'fast)
8164 ;; Select next newsgroup or exit.
8165 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
8166 (eq gnus-auto-select-next 'quietly))
8167 (gnus-summary-next-group nil)
8168 (gnus-summary-exit))))
8170 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8171 "Mark all articles in this newsgroup as read, and then exit."
8173 (gnus-summary-catchup-and-exit t quietly))
8175 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
8176 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8177 "Mark all articles in this group as read and select the next group.
8178 If given a prefix, mark all articles, unread as well as ticked, as
8182 (gnus-summary-catchup all))
8183 (gnus-summary-next-article t nil nil t))
8185 ;; Thread-based commands.
8187 (defun gnus-summary-articles-in-thread (&optional article)
8188 "Return a list of all articles in the current thread.
8189 If ARTICLE is non-nil, return all articles in the thread that starts
8191 (let* ((article (or article (gnus-summary-article-number)))
8192 (data (gnus-data-find-list article))
8193 (top-level (gnus-data-level (car data)))
8195 (cond ((null gnus-thread-operation-ignore-subject)
8196 (gnus-simplify-subject-re
8197 (mail-header-subject (gnus-data-header (car data)))))
8198 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8199 (gnus-simplify-subject-fuzzy
8200 (mail-header-subject (gnus-data-header (car data)))))
8202 (end-point (save-excursion
8203 (if (gnus-summary-go-to-next-thread)
8204 (point) (point-max))))
8207 (< (gnus-data-pos (car data)) end-point))
8208 (when (or (not top-subject)
8209 (string= top-subject
8210 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8211 (gnus-simplify-subject-fuzzy
8212 (mail-header-subject
8213 (gnus-data-header (car data))))
8214 (gnus-simplify-subject-re
8215 (mail-header-subject
8216 (gnus-data-header (car data)))))))
8217 (push (gnus-data-number (car data)) articles))
8218 (unless (and (setq data (cdr data))
8219 (> (gnus-data-level (car data)) top-level))
8221 ;; Return the list of articles.
8222 (nreverse articles)))
8224 (defun gnus-summary-rethread-current ()
8225 "Rethread the thread the current article is part of."
8227 (let* ((gnus-show-threads t)
8228 (article (gnus-summary-article-number))
8229 (id (mail-header-id (gnus-summary-article-header)))
8230 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8232 (error "No article on the current line"))
8233 (gnus-rebuild-thread id)
8234 (gnus-summary-goto-subject article)))
8236 (defun gnus-summary-reparent-thread ()
8237 "Make the current article child of the marked (or previous) article.
8239 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8240 is non-nil or the Subject: of both articles are the same."
8242 (unless (not (gnus-group-read-only-p))
8243 (error "The current newsgroup does not support article editing"))
8244 (unless (<= (length gnus-newsgroup-processable) 1)
8245 (error "No more than one article may be marked"))
8246 (save-window-excursion
8247 (let ((gnus-article-buffer " *reparent*")
8248 (current-article (gnus-summary-article-number))
8249 ;; First grab the marked article, otherwise one line up.
8250 (parent-article (if (not (null gnus-newsgroup-processable))
8251 (car gnus-newsgroup-processable)
8253 (if (eq (forward-line -1) 0)
8254 (gnus-summary-article-number)
8255 (error "Beginning of summary buffer"))))))
8256 (unless (not (eq current-article parent-article))
8257 (error "An article may not be self-referential"))
8258 (let ((message-id (mail-header-id
8259 (gnus-summary-article-header parent-article))))
8260 (unless (and message-id (not (equal message-id "")))
8261 (error "No message-id in desired parent"))
8262 ;; We don't want the article to be marked as read.
8263 (let (gnus-mark-article-hook)
8264 (gnus-summary-select-article t t nil current-article))
8265 (set-buffer gnus-original-article-buffer)
8266 (let ((buf (format "%s" (buffer-string))))
8269 (goto-char (point-min))
8270 (if (re-search-forward "^References: " nil t)
8272 (re-search-forward "^[^ \t]" nil t)
8275 (insert " " message-id))
8276 (insert "References: " message-id "\n"))
8277 (unless (gnus-request-replace-article
8278 current-article (car gnus-article-current)
8280 (error "Couldn't replace article"))))
8281 (set-buffer gnus-summary-buffer)
8282 (gnus-summary-unmark-all-processable)
8283 (gnus-summary-update-article current-article)
8284 (gnus-summary-rethread-current)
8285 (gnus-message 3 "Article %d is now the child of article %d"
8286 current-article parent-article)))))
8288 (defun gnus-summary-toggle-threads (&optional arg)
8289 "Toggle showing conversation threads.
8290 If ARG is positive number, turn showing conversation threads on."
8292 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8293 (setq gnus-show-threads
8294 (if (null arg) (not gnus-show-threads)
8295 (> (prefix-numeric-value arg) 0)))
8296 (gnus-summary-prepare)
8297 (gnus-summary-goto-subject current)
8298 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8299 (gnus-summary-position-point)))
8301 (defun gnus-summary-show-all-threads ()
8305 (let ((buffer-read-only nil))
8306 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8307 (gnus-summary-position-point))
8309 (defun gnus-summary-show-thread ()
8310 "Show thread subtrees.
8311 Returns nil if no thread was there to be shown."
8313 (let ((buffer-read-only nil)
8315 ;; first goto end then to beg, to have point at beg after let
8316 (end (progn (end-of-line) (point)))
8317 (beg (progn (beginning-of-line) (point))))
8319 ;; Any hidden lines here?
8320 (search-forward "\r" end t)
8321 (subst-char-in-region beg end ?\^M ?\n t)
8323 (gnus-summary-position-point))))
8325 (defun gnus-summary-hide-all-threads ()
8326 "Hide all thread subtrees."
8329 (goto-char (point-min))
8330 (gnus-summary-hide-thread)
8331 (while (zerop (gnus-summary-next-thread 1 t))
8332 (gnus-summary-hide-thread)))
8333 (gnus-summary-position-point))
8335 (defun gnus-summary-hide-thread ()
8336 "Hide thread subtrees.
8337 Returns nil if no threads were there to be hidden."
8339 (let ((buffer-read-only nil)
8341 (article (gnus-summary-article-number)))
8343 ;; Go forward until either the buffer ends or the subthread
8345 (when (and (not (eobp))
8346 (or (zerop (gnus-summary-next-thread 1 t))
8347 (goto-char (point-max))))
8349 (if (and (> (point) start)
8350 (search-backward "\n" start t))
8352 (subst-char-in-region start (point) ?\n ?\^M)
8353 (gnus-summary-goto-subject article))
8356 ;;(gnus-summary-position-point)
8359 (defun gnus-summary-go-to-next-thread (&optional previous)
8360 "Go to the same level (or less) next thread.
8361 If PREVIOUS is non-nil, go to previous thread instead.
8362 Return the article number moved to, or nil if moving was impossible."
8363 (let ((level (gnus-summary-thread-level))
8364 (way (if previous -1 1))
8367 (while (and (not (eobp))
8368 (< level (gnus-summary-thread-level)))
8376 (gnus-summary-article-number)
8379 (defun gnus-summary-next-thread (n &optional silent)
8380 "Go to the same level next N'th thread.
8381 If N is negative, search backward instead.
8382 Returns the difference between N and the number of skips actually
8385 If SILENT, don't output messages."
8387 (let ((backward (< n 0))
8390 (gnus-summary-go-to-next-thread backward))
8393 (gnus-summary-position-point))
8394 (when (and (not silent) (/= 0 n))
8395 (gnus-message 7 "No more threads"))
8398 (defun gnus-summary-prev-thread (n)
8399 "Go to the same level previous N'th thread.
8400 Returns the difference between N and the number of skips actually
8403 (gnus-summary-next-thread (- n)))
8405 (defun gnus-summary-go-down-thread ()
8406 "Go down one level in the current thread."
8407 (let ((children (gnus-summary-article-children)))
8409 (gnus-summary-goto-subject (car children)))))
8411 (defun gnus-summary-go-up-thread ()
8412 "Go up one level in the current thread."
8413 (let ((parent (gnus-summary-article-parent)))
8415 (gnus-summary-goto-subject parent))))
8417 (defun gnus-summary-down-thread (n)
8418 "Go down thread N steps.
8419 If N is negative, go up instead.
8420 Returns the difference between N and how many steps down that were
8426 (if up (gnus-summary-go-up-thread)
8427 (gnus-summary-go-down-thread)))
8429 (gnus-summary-position-point)
8431 (gnus-message 7 "Can't go further"))
8434 (defun gnus-summary-up-thread (n)
8435 "Go up thread N steps.
8436 If N is negative, go up instead.
8437 Returns the difference between N and how many steps down that were
8440 (gnus-summary-down-thread (- n)))
8442 (defun gnus-summary-top-thread ()
8443 "Go to the top of the thread."
8445 (while (gnus-summary-go-up-thread))
8446 (gnus-summary-article-number))
8448 (defun gnus-summary-kill-thread (&optional unmark)
8449 "Mark articles under current thread as read.
8450 If the prefix argument is positive, remove any kinds of marks.
8451 If the prefix argument is negative, tick articles instead."
8454 (setq unmark (prefix-numeric-value unmark)))
8455 (let ((articles (gnus-summary-articles-in-thread)))
8457 ;; Expand the thread.
8458 (gnus-summary-show-thread)
8459 ;; Mark all the articles.
8461 (gnus-summary-goto-subject (car articles))
8462 (cond ((null unmark)
8463 (gnus-summary-mark-article-as-read gnus-killed-mark))
8465 (gnus-summary-mark-article-as-unread gnus-unread-mark))
8467 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
8468 (setq articles (cdr articles))))
8469 ;; Hide killed subtrees.
8471 gnus-thread-hide-killed
8472 (gnus-summary-hide-thread))
8473 ;; If marked as read, go to next unread subject.
8475 ;; Go to next unread subject.
8476 (gnus-summary-next-subject 1 t)))
8477 (gnus-set-mode-line 'summary))
8479 ;; Summary sorting commands
8481 (defun gnus-summary-sort-by-number (&optional reverse)
8482 "Sort the summary buffer by article number.
8483 Argument REVERSE means reverse order."
8485 (gnus-summary-sort 'number reverse))
8487 (defun gnus-summary-sort-by-author (&optional reverse)
8488 "Sort the summary buffer by author name alphabetically.
8489 If case-fold-search is non-nil, case of letters is ignored.
8490 Argument REVERSE means reverse order."
8492 (gnus-summary-sort 'author reverse))
8494 (defun gnus-summary-sort-by-subject (&optional reverse)
8495 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8496 If case-fold-search is non-nil, case of letters is ignored.
8497 Argument REVERSE means reverse order."
8499 (gnus-summary-sort 'subject reverse))
8501 (defun gnus-summary-sort-by-date (&optional reverse)
8502 "Sort the summary buffer by date.
8503 Argument REVERSE means reverse order."
8505 (gnus-summary-sort 'date reverse))
8507 (defun gnus-summary-sort-by-score (&optional reverse)
8508 "Sort the summary buffer by score.
8509 Argument REVERSE means reverse order."
8511 (gnus-summary-sort 'score reverse))
8513 (defun gnus-summary-sort-by-lines (&optional reverse)
8514 "Sort the summary buffer by article length.
8515 Argument REVERSE means reverse order."
8517 (gnus-summary-sort 'lines reverse))
8519 (defun gnus-summary-sort (predicate reverse)
8520 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
8521 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
8522 (article (intern (format "gnus-article-sort-by-%s" predicate)))
8523 (gnus-thread-sort-functions
8529 (gnus-article-sort-functions
8534 (,article t2 t1)))))
8536 (gnus-summary-prepare-hook nil))
8537 ;; We do the sorting by regenerating the threads.
8538 (gnus-summary-prepare)
8539 ;; Hide subthreads if needed.
8540 (when (and gnus-show-threads gnus-thread-hide-subtree)
8541 (gnus-summary-hide-all-threads))))
8543 ;; Summary saving commands.
8545 (defun gnus-summary-save-article (&optional n not-saved)
8546 "Save the current article using the default saver function.
8547 If N is a positive number, save the N next articles.
8548 If N is a negative number, save the N previous articles.
8549 If N is nil and any articles have been marked with the process mark,
8550 save those articles instead.
8551 The variable `gnus-default-article-saver' specifies the saver function."
8553 (let* ((articles (gnus-summary-work-articles n))
8554 (save-buffer (save-excursion
8555 (nnheader-set-temp-buffer " *Gnus Save*")))
8556 (num (length articles))
8557 header article file)
8559 (setq header (gnus-summary-article-header
8560 (setq article (pop articles))))
8561 (if (not (vectorp header))
8562 ;; This is a pseudo-article.
8563 (if (assq 'name header)
8564 (gnus-copy-file (cdr (assq 'name header)))
8565 (gnus-message 1 "Article %d is unsaveable" article))
8566 ;; This is a real article.
8567 (save-window-excursion
8568 (gnus-summary-select-article t nil nil article))
8570 (set-buffer save-buffer)
8572 (insert-buffer-substring gnus-original-article-buffer))
8573 (setq file (gnus-article-save save-buffer file num))
8574 (gnus-summary-remove-process-mark article)
8576 (gnus-summary-set-saved-mark article))))
8577 (gnus-kill-buffer save-buffer)
8578 (gnus-summary-position-point)
8579 (gnus-set-mode-line 'summary)
8582 (defun gnus-summary-pipe-output (&optional arg)
8583 "Pipe the current article to a subprocess.
8584 If N is a positive number, pipe the N next articles.
8585 If N is a negative number, pipe the N previous articles.
8586 If N is nil and any articles have been marked with the process mark,
8587 pipe those articles instead."
8589 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8590 (gnus-summary-save-article arg t))
8591 (gnus-configure-windows 'pipe))
8593 (defun gnus-summary-save-article-mail (&optional arg)
8594 "Append the current article to an mail file.
8595 If N is a positive number, save the N next articles.
8596 If N is a negative number, save the N previous articles.
8597 If N is nil and any articles have been marked with the process mark,
8598 save those articles instead."
8600 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8601 (gnus-summary-save-article arg)))
8603 (defun gnus-summary-save-article-rmail (&optional arg)
8604 "Append the current article to an rmail file.
8605 If N is a positive number, save the N next articles.
8606 If N is a negative number, save the N previous articles.
8607 If N is nil and any articles have been marked with the process mark,
8608 save those articles instead."
8610 (let ((gnus-default-article-saver 'rmail-output-to-rmail-file))
8611 (gnus-summary-save-article arg)))
8613 (defun gnus-summary-save-article-file (&optional arg)
8614 "Append the current article to a file.
8615 If N is a positive number, save the N next articles.
8616 If N is a negative number, save the N previous articles.
8617 If N is nil and any articles have been marked with the process mark,
8618 save those articles instead."
8620 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8621 (gnus-summary-save-article arg)))
8623 (defun gnus-summary-write-article-file (&optional arg)
8624 "Write the current article to a file, deleting the previous file.
8625 If N is a positive number, save the N next articles.
8626 If N is a negative number, save the N previous articles.
8627 If N is nil and any articles have been marked with the process mark,
8628 save those articles instead."
8630 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
8631 (gnus-summary-save-article arg)))
8633 (defun gnus-summary-save-article-body-file (&optional arg)
8634 "Append the current article body to a file.
8635 If N is a positive number, save the N next articles.
8636 If N is a negative number, save the N previous articles.
8637 If N is nil and any articles have been marked with the process mark,
8638 save those articles instead."
8640 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
8641 (gnus-summary-save-article arg)))
8643 (defun gnus-summary-pipe-message (program)
8644 "Pipe the current article through PROGRAM."
8645 (interactive "sProgram: ")
8646 (gnus-summary-select-article)
8647 (let ((mail-header-separator ""))
8648 (gnus-eval-in-buffer-window gnus-article-buffer
8651 (let ((start (window-start))
8653 (message-pipe-buffer-body program)
8654 (set-window-start (get-buffer-window (current-buffer)) start))))))
8656 (defun gnus-get-split-value (methods)
8657 "Return a value based on the split METHODS."
8658 (let (split-name method result match)
8661 (set-buffer gnus-original-article-buffer)
8663 (nnheader-narrow-to-headers)
8665 (goto-char (point-min))
8666 (setq method (pop methods))
8667 (setq match (car method))
8670 ;; Regular expression.
8672 (re-search-forward match nil t)))
8673 ((gnus-functionp match)
8677 (setq result (funcall match gnus-newsgroup-name))))
8682 (setq result (eval match)))))
8683 (setq split-name (append (cdr method) split-name))
8684 (cond ((stringp result)
8685 (push (expand-file-name
8686 result gnus-article-save-directory)
8689 (setq split-name (append result split-name)))))))))
8692 (defun gnus-valid-move-group-p (group)
8695 (symbol-value group)
8698 (car (gnus-find-method-for-group
8699 (symbol-name group))))
8700 gnus-valid-select-methods))))
8702 (defun gnus-read-move-group-name (prompt default articles prefix)
8703 "Read a group name."
8704 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
8705 (minibuffer-confirm-incomplete nil) ; XEmacs
8709 (if (> (length articles) 1)
8710 (format "these %d articles" (length articles))
8715 (gnus-completing-read default prom
8717 'gnus-valid-move-group-p
8719 'gnus-group-history))
8720 ((= 1 (length split-name))
8721 (gnus-completing-read (car split-name) prom
8723 'gnus-valid-move-group-p
8725 'gnus-group-history))
8727 (gnus-completing-read nil prom
8728 (mapcar (lambda (el) (list el))
8729 (nreverse split-name))
8731 'gnus-group-history)))))
8733 (if (or (string= to-newsgroup "")
8734 (string= to-newsgroup prefix))
8735 (setq to-newsgroup default))
8736 (unless to-newsgroup
8737 (error "No group name entered"))
8738 (or (gnus-active to-newsgroup)
8739 (gnus-activate-group to-newsgroup)
8740 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
8742 (or (and (gnus-request-create-group
8743 to-newsgroup (gnus-group-name-to-method to-newsgroup))
8744 (gnus-activate-group to-newsgroup nil nil
8745 (gnus-group-name-to-method
8747 (error "Couldn't create group %s" to-newsgroup)))
8748 (error "No such group: %s" to-newsgroup)))
8751 ;; Summary extract commands
8753 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
8754 (let ((buffer-read-only nil)
8755 (article (gnus-summary-article-number))
8757 (unless (gnus-summary-goto-subject article)
8758 (error "No such article: %d" article))
8759 (gnus-summary-position-point)
8760 ;; If all commands are to be bunched up on one line, we collect
8762 (unless gnus-view-pseudos-separately
8763 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
8766 (setq action (cdr (assq 'action (car ps))))
8767 (setq files (list (cdr (assq 'name (car ps)))))
8768 (while (and ps (cdr ps)
8769 (string= (or action "1")
8770 (or (cdr (assq 'action (cadr ps))) "2")))
8771 (push (cdr (assq 'name (cadr ps))) files)
8772 (setcdr ps (cddr ps)))
8774 (when (not (string-match "%s" action))
8777 (when (assq 'execute (car ps))
8778 (setcdr (assq 'execute (car ps))
8779 (funcall (if (string-match "%s" action)
8786 (gnus-quote-arg-for-sh-or-csh f)))
8788 (setq ps (cdr ps)))))
8789 (if (and gnus-view-pseudos (not not-view))
8791 (when (assq 'execute (car pslist))
8792 (gnus-execute-command (cdr (assq 'execute (car pslist)))
8793 (eq gnus-view-pseudos 'not-confirm)))
8794 (setq pslist (cdr pslist)))
8797 (setq after-article (or (cdr (assq 'article (car pslist)))
8798 (gnus-summary-article-number)))
8799 (gnus-summary-goto-subject after-article)
8802 (insert " " (file-name-nondirectory
8803 (cdr (assq 'name (car pslist))))
8804 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
8806 (forward-line -1) ; back to `b'
8807 (gnus-add-text-properties
8808 b (1- e) (list 'gnus-number gnus-reffed-article-number
8809 gnus-mouse-face-prop gnus-mouse-face))
8811 after-article gnus-reffed-article-number
8812 gnus-unread-mark b (car pslist) 0 (- e b))
8813 (push gnus-reffed-article-number gnus-newsgroup-unreads)
8814 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
8815 (setq pslist (cdr pslist)))))))
8817 (defun gnus-pseudos< (p1 p2)
8818 (let ((c1 (cdr (assq 'action p1)))
8819 (c2 (cdr (assq 'action p2))))
8820 (and c1 c2 (string< c1 c2))))
8822 (defun gnus-request-pseudo-article (props)
8823 (cond ((assq 'execute props)
8824 (gnus-execute-command (cdr (assq 'execute props)))))
8825 (let ((gnus-current-article (gnus-summary-article-number)))
8826 (gnus-run-hooks 'gnus-mark-article-hook)))
8828 (defun gnus-execute-command (command &optional automatic)
8830 (gnus-article-setup-buffer)
8831 (set-buffer gnus-article-buffer)
8832 (setq buffer-read-only nil)
8833 (let ((command (if automatic command
8834 (read-string "Command: " (cons command 0)))))
8836 (insert "$ " command "\n\n")
8837 (if gnus-view-pseudo-asynchronously
8838 (start-process "gnus-execute" (current-buffer) shell-file-name
8839 shell-command-switch command)
8840 (call-process shell-file-name nil t nil
8841 shell-command-switch command)))))
8843 ;; Summary kill commands.
8845 (defun gnus-summary-edit-global-kill (article)
8846 "Edit the \"global\" kill file."
8847 (interactive (list (gnus-summary-article-number)))
8848 (gnus-group-edit-global-kill article))
8850 (defun gnus-summary-edit-local-kill ()
8851 "Edit a local kill file applied to the current newsgroup."
8853 (setq gnus-current-headers (gnus-summary-article-header))
8854 (gnus-group-edit-local-kill
8855 (gnus-summary-article-number) gnus-newsgroup-name))
8859 (defun gnus-read-header (id &optional header)
8860 "Read the headers of article ID and enter them into the Gnus system."
8861 (let ((group gnus-newsgroup-name)
8862 (gnus-override-method
8863 (and (gnus-news-group-p gnus-newsgroup-name)
8864 gnus-refer-article-method))
8866 ;; First we check to see whether the header in question is already
8869 ;; This is a Message-ID.
8870 (setq header (or header (gnus-id-to-header id)))
8871 ;; This is an article number.
8872 (setq header (or header (gnus-summary-article-header id))))
8874 (not (gnus-summary-article-sparse-p (mail-header-number header))))
8875 ;; We have found the header.
8877 ;; If this is a sparse article, we have to nix out its
8878 ;; previous entry in the thread hashtb.
8880 (gnus-summary-article-sparse-p (mail-header-number header)))
8881 (let* ((parent (gnus-parent-id (mail-header-references header)))
8882 (thread (and parent (gnus-id-to-thread parent))))
8884 (delq (assq header thread) thread))))
8885 ;; We have to really fetch the header to this article.
8887 (set-buffer nntp-server-buffer)
8888 (when (setq where (gnus-request-head id group))
8889 (nnheader-fold-continuation-lines)
8890 (goto-char (point-max))
8892 (goto-char (point-min))
8896 ((cdr where) (cdr where))
8897 (header (mail-header-number header))
8898 (t gnus-reffed-article-number))
8900 (insert " Article retrieved.\n"))
8902 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
8903 () ; Malformed head.
8904 (unless (gnus-summary-article-sparse-p (mail-header-number header))
8905 (when (and (stringp id)
8906 (not (string= (gnus-group-real-name group)
8908 ;; If we fetched by Message-ID and the article came
8909 ;; from a different group, we fudge some bogus article
8910 ;; numbers for this article.
8911 (mail-header-set-number header gnus-reffed-article-number))
8913 (set-buffer gnus-summary-buffer)
8914 (decf gnus-reffed-article-number)
8915 (gnus-remove-header (mail-header-number header))
8916 (push header gnus-newsgroup-headers)
8917 (setq gnus-current-headers header)
8918 (push (mail-header-number header) gnus-newsgroup-limit)))
8921 (defun gnus-remove-header (number)
8922 "Remove header NUMBER from `gnus-newsgroup-headers'."
8923 (if (and gnus-newsgroup-headers
8924 (= number (mail-header-number (car gnus-newsgroup-headers))))
8925 (pop gnus-newsgroup-headers)
8926 (let ((headers gnus-newsgroup-headers))
8927 (while (and (cdr headers)
8928 (not (= number (mail-header-number (cadr headers)))))
8931 (setcdr headers (cddr headers))))))
8934 ;;; summary highlights
8937 (defun gnus-highlight-selected-summary ()
8938 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8939 ;; Highlight selected article in summary buffer
8940 (when gnus-summary-selected-face
8942 (let* ((beg (progn (beginning-of-line) (point)))
8943 (end (progn (end-of-line) (point)))
8944 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
8945 (from (if (get-text-property beg gnus-mouse-face-prop)
8947 (or (next-single-property-change
8948 beg gnus-mouse-face-prop nil end)
8953 (or (next-single-property-change
8954 from gnus-mouse-face-prop nil end)
8956 ;; If no mouse-face prop on line we will have to = from = end,
8957 ;; so we highlight the entire line instead.
8958 (when (= (+ to 2) from)
8961 (if gnus-newsgroup-selected-overlay
8962 ;; Move old overlay.
8964 gnus-newsgroup-selected-overlay from to (current-buffer))
8965 ;; Create new overlay.
8967 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
8968 'face gnus-summary-selected-face))))))
8970 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
8971 (defun gnus-summary-highlight-line ()
8972 "Highlight current line according to `gnus-summary-highlight'."
8973 (let* ((list gnus-summary-highlight)
8975 (end (progn (end-of-line) (point)))
8976 ;; now find out where the line starts and leave point there.
8977 (beg (progn (beginning-of-line) (point)))
8978 (article (gnus-summary-article-number))
8979 (score (or (cdr (assq (or article gnus-current-article)
8980 gnus-newsgroup-scored))
8981 gnus-summary-default-score 0))
8982 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
8983 (inhibit-read-only t))
8984 ;; Eval the cars of the lists until we find a match.
8985 (let ((default gnus-summary-default-score))
8987 (not (eval (caar list))))
8988 (setq list (cdr list))))
8989 (let ((face (cdar list)))
8990 (unless (eq face (get-text-property beg 'face))
8991 (gnus-put-text-property-excluding-characters-with-faces
8993 (setq face (if (boundp face) (symbol-value face) face)))
8994 (when gnus-summary-highlight-line-function
8995 (funcall gnus-summary-highlight-line-function article face))))
8998 (defun gnus-update-read-articles (group unread &optional compute)
8999 "Update the list of read articles in GROUP."
9000 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
9001 (entry (gnus-gethash group gnus-newsrc-hashtb))
9002 (info (nth 2 entry))
9004 (unread (sort (copy-sequence unread) '<))
9006 (if (or (not info) (not active))
9007 ;; There is no info on this group if it was, in fact,
9008 ;; killed. Gnus stores no information on killed groups, so
9009 ;; there's nothing to be done.
9010 ;; One could store the information somewhere temporarily,
9011 ;; perhaps... Hmmm...
9013 ;; Remove any negative articles numbers.
9014 (while (and unread (< (car unread) 0))
9015 (setq unread (cdr unread)))
9016 ;; Remove any expired article numbers
9017 (while (and unread (< (car unread) (car active)))
9018 (setq unread (cdr unread)))
9019 ;; Compute the ranges of read articles by looking at the list of
9022 (when (/= (car unread) prev)
9023 (push (if (= prev (1- (car unread))) prev
9024 (cons prev (1- (car unread))))
9026 (setq prev (1+ (car unread)))
9027 (setq unread (cdr unread)))
9028 (when (<= prev (cdr active))
9029 (push (cons prev (cdr active)) read))
9030 (setq read (if (> (length read) 1) (nreverse read) read))
9034 (set-buffer gnus-group-buffer)
9037 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
9038 (gnus-info-set-read ',info ',(gnus-info-read info))
9039 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
9040 (gnus-group-update-group ,group t))))
9041 ;; Enter this list into the group info.
9042 (gnus-info-set-read info read)
9043 ;; Set the number of unread articles in gnus-newsrc-hashtb.
9044 (gnus-get-unread-articles-in-group info (gnus-active group))
9047 (defun gnus-offer-save-summaries ()
9048 "Offer to save all active summary buffers."
9050 (let ((buflist (buffer-list))
9052 ;; Go through all buffers and find all summaries.
9054 (and (setq bufname (buffer-name (car buflist)))
9055 (string-match "Summary" bufname)
9057 (set-buffer bufname)
9058 ;; We check that this is, indeed, a summary buffer.
9059 (and (eq major-mode 'gnus-summary-mode)
9060 ;; Also make sure this isn't bogus.
9061 gnus-newsgroup-prepared
9062 ;; Also make sure that this isn't a dead summary buffer.
9063 (not gnus-dead-summary-mode)))
9064 (push bufname buffers))
9065 (setq buflist (cdr buflist)))
9066 ;; Go through all these summary buffers and offer to save them.
9069 "Update summary buffer %s? "
9071 (switch-to-buffer buf)
9072 (gnus-summary-exit))
9076 ;;; @ for mime-partial
9079 (defun gnus-request-partial-message ()
9081 (let ((number (gnus-summary-article-number))
9082 (group gnus-newsgroup-name)
9083 (mother gnus-article-buffer))
9084 (set-buffer (get-buffer-create " *Partial Article*"))
9086 (setq mime-preview-buffer mother)
9087 (gnus-request-article-this-buffer number group)
9091 (autoload 'mime-combine-message/partial-pieces-automatically
9093 "Internal method to combine message/partial messages automatically.")
9096 'action '((type . message)(subtype . partial)
9097 (major-mode . gnus-original-article-mode)
9098 (method . mime-combine-message/partial-pieces-automatically)
9099 (summary-buffer-exp . gnus-summary-buffer)
9100 (request-partial-message-method . gnus-request-partial-message)
9111 (run-hooks 'gnus-sum-load-hook)
9113 ;;; gnus-sum.el ends here