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 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
41 (autoload 'gnus-set-summary-default-charset "gnus-i18n" nil t)
43 (defcustom gnus-kill-summary-on-exit t
44 "*If non-nil, kill the summary buffer when you exit from it.
45 If nil, the summary will become a \"*Dead Summary*\" buffer, and
46 it will be killed sometime later."
47 :group 'gnus-summary-exit
50 (defcustom gnus-fetch-old-headers nil
51 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
52 If an unread article in the group refers to an older, already read (or
53 just marked as read) article, the old article will not normally be
54 displayed in the Summary buffer. If this variable is non-nil, Gnus
55 will attempt to grab the headers to the old articles, and thereby
56 build complete threads. If it has the value `some', only enough
57 headers to connect otherwise loose threads will be displayed. This
58 variable can also be a number. In that case, no more than that number
59 of old headers will be fetched. If it has the value `invisible', all
60 old headers will be fetched, but none will be displayed.
62 The server has to support NOV for any of this to work."
64 :type '(choice (const :tag "off" nil)
67 (sexp :menu-tag "other" t)))
69 (defcustom gnus-refer-thread-limit 200
70 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
71 If t, fetch all the available old headers."
74 (sexp :menu-tag "other" t)))
76 (defcustom gnus-summary-make-false-root 'adopt
77 "*nil means that Gnus won't gather loose threads.
78 If the root of a thread has expired or been read in a previous
79 session, the information necessary to build a complete thread has been
80 lost. Instead of having many small sub-threads from this original thread
81 scattered all over the summary buffer, Gnus can gather them.
83 If non-nil, Gnus will try to gather all loose sub-threads from an
84 original thread into one large thread.
86 If this variable is non-nil, it should be one of `none', `adopt',
89 If this variable is `none', Gnus will not make a false root, but just
90 present the sub-threads after another.
91 If this variable is `dummy', Gnus will create a dummy root that will
92 have all the sub-threads as children.
93 If this variable is `adopt', Gnus will make one of the \"children\"
94 the parent and mark all the step-children as such.
95 If this variable is `empty', the \"children\" are printed with empty
96 subject fields. (Or rather, they will be printed with a string
97 given by the `gnus-summary-same-subject' variable.)"
99 :type '(choice (const :tag "off" nil)
105 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
106 "*A regexp to match subjects to be excluded from loose thread gathering.
107 As loose thread gathering is done on subjects only, that means that
108 there can be many false gatherings performed. By rooting out certain
109 common subjects, gathering might become saner."
113 (defcustom gnus-summary-gather-subject-limit nil
114 "*Maximum length of subject comparisons when gathering loose threads.
115 Use nil to compare full subjects. Setting this variable to a low
116 number will help gather threads that have been corrupted by
117 newsreaders chopping off subject lines, but it might also mean that
118 unrelated articles that have subject that happen to begin with the
119 same few characters will be incorrectly gathered.
121 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
124 :type '(choice (const :tag "off" nil)
126 (sexp :menu-tag "on" t)))
128 (defcustom gnus-simplify-subject-functions nil
129 "List of functions taking a string argument that simplify subjects.
130 The functions are applied recursively.
132 Useful functions to put in this list include: `gnus-simplify-subject-re',
133 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
135 :type '(repeat function))
137 (defcustom gnus-simplify-ignored-prefixes nil
138 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
140 :type '(choice (const :tag "off" nil)
143 (defcustom gnus-build-sparse-threads nil
144 "*If non-nil, fill in the gaps in threads.
145 If `some', only fill in the gaps that are needed to tie loose threads
146 together. If `more', fill in all leaf nodes that Gnus can find. If
147 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
149 :type '(choice (const :tag "off" nil)
152 (sexp :menu-tag "all" t)))
154 (defcustom gnus-summary-thread-gathering-function
155 'gnus-gather-threads-by-subject
156 "*Function used for gathering loose threads.
157 There are two pre-defined functions: `gnus-gather-threads-by-subject',
158 which only takes Subjects into consideration; and
159 `gnus-gather-threads-by-references', which compared the References
160 headers of the articles to find matches."
162 :type '(radio (function-item gnus-gather-threads-by-subject)
163 (function-item gnus-gather-threads-by-references)
164 (function :tag "other")))
166 (defcustom gnus-summary-same-subject ""
167 "*String indicating that the current article has the same subject as the previous.
168 This variable will only be used if the value of
169 `gnus-summary-make-false-root' is `empty'."
170 :group 'gnus-summary-format
173 (defcustom gnus-summary-goto-unread t
174 "*If t, marking commands will go to the next unread article.
175 If `never', commands that usually go to the next unread article, will
176 go to the next article, whether it is read or not.
177 If nil, only the marking commands will go to the next (un)read article."
178 :group 'gnus-summary-marks
179 :link '(custom-manual "(gnus)Setting Marks")
180 :type '(choice (const :tag "off" nil)
182 (sexp :menu-tag "on" t)))
184 (defcustom gnus-summary-default-score 0
185 "*Default article score level.
186 All scores generated by the score files will be added to this score.
187 If this variable is nil, scoring will be disabled."
188 :group 'gnus-score-default
189 :type '(choice (const :tag "disable")
192 (defcustom gnus-summary-zcore-fuzz 0
193 "*Fuzziness factor for the zcore in the summary buffer.
194 Articles with scores closer than this to `gnus-summary-default-score'
196 :group 'gnus-summary-format
199 (defcustom gnus-simplify-subject-fuzzy-regexp nil
200 "*Strings to be removed when doing fuzzy matches.
201 This can either be a regular expression or list of regular expressions
202 that will be removed from subject strings if fuzzy subject
203 simplification is selected."
205 :type '(repeat regexp))
207 (defcustom gnus-show-threads t
208 "*If non-nil, display threads in summary mode."
212 (defcustom gnus-thread-hide-subtree nil
213 "*If non-nil, hide all threads initially.
214 If threads are hidden, you have to run the command
215 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
216 to expose hidden threads."
220 (defcustom gnus-thread-hide-killed t
221 "*If non-nil, hide killed threads automatically."
225 (defcustom gnus-thread-ignore-subject nil
226 "*If non-nil, ignore subjects and do all threading based on the Reference header.
227 If nil, which is the default, articles that have different subjects
228 from their parents will start separate threads."
232 (defcustom gnus-thread-operation-ignore-subject t
233 "*If non-nil, subjects will be ignored when doing thread commands.
234 This affects commands like `gnus-summary-kill-thread' and
235 `gnus-summary-lower-thread'.
237 If this variable is nil, articles in the same thread with different
238 subjects will not be included in the operation in question. If this
239 variable is `fuzzy', only articles that have subjects that are fuzzily
240 equal will be included."
242 :type '(choice (const :tag "off" nil)
246 (defcustom gnus-thread-indent-level 4
247 "*Number that says how much each sub-thread should be indented."
251 (defcustom gnus-auto-extend-newsgroup t
252 "*If non-nil, extend newsgroup forward and backward when requested."
253 :group 'gnus-summary-choose
256 (defcustom gnus-auto-select-first t
257 "*If nil, don't select the first unread article when entering a group.
258 If this variable is `best', select the highest-scored unread article
259 in the group. If neither nil nor `best', select the first unread
262 If you want to prevent automatic selection of the first unread article
263 in some newsgroups, set the variable to nil in
264 `gnus-select-group-hook'."
265 :group 'gnus-group-select
266 :type '(choice (const :tag "none" nil)
268 (sexp :menu-tag "first" t)))
270 (defcustom gnus-auto-select-next t
271 "*If non-nil, offer to go to the next group from the end of the previous.
272 If the value is t and the next newsgroup is empty, Gnus will exit
273 summary mode and go back to group mode. If the value is neither nil
274 nor t, Gnus will select the following unread newsgroup. In
275 particular, if the value is the symbol `quietly', the next unread
276 newsgroup will be selected without any confirmation, and if it is
277 `almost-quietly', the next group will be selected without any
278 confirmation if you are located on the last article in the group.
279 Finally, if this variable is `slightly-quietly', the `Z n' command
280 will go to the next group without confirmation."
281 :group 'gnus-summary-maneuvering
282 :type '(choice (const :tag "off" nil)
284 (const almost-quietly)
285 (const slightly-quietly)
286 (sexp :menu-tag "on" t)))
288 (defcustom gnus-auto-select-same nil
289 "*If non-nil, select the next article with the same subject."
290 :group 'gnus-summary-maneuvering
293 (defcustom gnus-summary-check-current nil
294 "*If non-nil, consider the current article when moving.
295 The \"unread\" movement commands will stay on the same line if the
296 current article is unread."
297 :group 'gnus-summary-maneuvering
300 (defcustom gnus-auto-center-summary t
301 "*If non-nil, always center the current summary buffer.
302 In particular, if `vertical' do only vertical recentering. If non-nil
303 and non-`vertical', do both horizontal and vertical recentering."
304 :group 'gnus-summary-maneuvering
305 :type '(choice (const :tag "none" nil)
307 (sexp :menu-tag "both" t)))
309 (defcustom gnus-show-all-headers nil
310 "*If non-nil, don't hide any headers."
311 :group 'gnus-article-hiding
312 :group 'gnus-article-headers
315 (defcustom gnus-summary-ignore-duplicates nil
316 "*If non-nil, ignore articles with identical Message-ID headers."
320 (defcustom gnus-single-article-buffer t
321 "*If non-nil, display all articles in the same buffer.
322 If nil, each group will get its own article buffer."
323 :group 'gnus-article-various
326 (defcustom gnus-break-pages t
327 "*If non-nil, do page breaking on articles.
328 The page delimiter is specified by the `gnus-page-delimiter'
330 :group 'gnus-article-various
333 (defcustom gnus-show-mime t
334 "*If non-nil, do mime processing of articles.
335 The articles will simply be fed to the function given by
336 `gnus-show-mime-method'."
337 :group 'gnus-article-mime
340 (defcustom gnus-move-split-methods nil
341 "*Variable used to suggest where articles are to be moved to.
342 It uses the same syntax as the `gnus-split-methods' variable."
343 :group 'gnus-summary-mail
344 :type '(repeat (choice (list :value (fun) function)
345 (cons :value ("" "") regexp (repeat string))
348 (defcustom gnus-unread-mark ?
349 "*Mark used for unread articles."
350 :group 'gnus-summary-marks
353 (defcustom gnus-ticked-mark ?!
354 "*Mark used for ticked articles."
355 :group 'gnus-summary-marks
358 (defcustom gnus-dormant-mark ??
359 "*Mark used for dormant articles."
360 :group 'gnus-summary-marks
363 (defcustom gnus-del-mark ?r
364 "*Mark used for del'd articles."
365 :group 'gnus-summary-marks
368 (defcustom gnus-read-mark ?R
369 "*Mark used for read articles."
370 :group 'gnus-summary-marks
373 (defcustom gnus-expirable-mark ?E
374 "*Mark used for expirable articles."
375 :group 'gnus-summary-marks
378 (defcustom gnus-killed-mark ?K
379 "*Mark used for killed articles."
380 :group 'gnus-summary-marks
383 (defcustom gnus-souped-mark ?F
384 "*Mark used for killed articles."
385 :group 'gnus-summary-marks
388 (defcustom gnus-kill-file-mark ?X
389 "*Mark used for articles killed by kill files."
390 :group 'gnus-summary-marks
393 (defcustom gnus-low-score-mark ?Y
394 "*Mark used for articles with a low score."
395 :group 'gnus-summary-marks
398 (defcustom gnus-catchup-mark ?C
399 "*Mark used for articles that are caught up."
400 :group 'gnus-summary-marks
403 (defcustom gnus-replied-mark ?A
404 "*Mark used for articles that have been replied to."
405 :group 'gnus-summary-marks
408 (defcustom gnus-cached-mark ?*
409 "*Mark used for articles that are in the cache."
410 :group 'gnus-summary-marks
413 (defcustom gnus-saved-mark ?S
414 "*Mark used for articles that have been saved to."
415 :group 'gnus-summary-marks
418 (defcustom gnus-ancient-mark ?O
419 "*Mark used for ancient articles."
420 :group 'gnus-summary-marks
423 (defcustom gnus-sparse-mark ?Q
424 "*Mark used for sparsely reffed articles."
425 :group 'gnus-summary-marks
428 (defcustom gnus-canceled-mark ?G
429 "*Mark used for canceled articles."
430 :group 'gnus-summary-marks
433 (defcustom gnus-duplicate-mark ?M
434 "*Mark used for duplicate articles."
435 :group 'gnus-summary-marks
438 (defcustom gnus-undownloaded-mark ?@
439 "*Mark used for articles that weren't downloaded."
440 :group 'gnus-summary-marks
443 (defcustom gnus-downloadable-mark ?%
444 "*Mark used for articles that are to be downloaded."
445 :group 'gnus-summary-marks
448 (defcustom gnus-unsendable-mark ?=
449 "*Mark used for articles that won't be sent."
450 :group 'gnus-summary-marks
453 (defcustom gnus-score-over-mark ?+
454 "*Score mark used for articles with high scores."
455 :group 'gnus-summary-marks
458 (defcustom gnus-score-below-mark ?-
459 "*Score mark used for articles with low scores."
460 :group 'gnus-summary-marks
463 (defcustom gnus-empty-thread-mark ?
464 "*There is no thread under the article."
465 :group 'gnus-summary-marks
468 (defcustom gnus-not-empty-thread-mark ?=
469 "*There is a thread under the article."
470 :group 'gnus-summary-marks
473 (defcustom gnus-view-pseudo-asynchronously nil
474 "*If non-nil, Gnus will view pseudo-articles asynchronously."
475 :group 'gnus-extract-view
478 (defcustom gnus-view-pseudos nil
479 "*If `automatic', pseudo-articles will be viewed automatically.
480 If `not-confirm', pseudos will be viewed automatically, and the user
481 will not be asked to confirm the command."
482 :group 'gnus-extract-view
483 :type '(choice (const :tag "off" nil)
485 (const not-confirm)))
487 (defcustom gnus-view-pseudos-separately t
488 "*If non-nil, one pseudo-article will be created for each file to be viewed.
489 If nil, all files that use the same viewing command will be given as a
490 list of parameters to that command."
491 :group 'gnus-extract-view
494 (defcustom gnus-insert-pseudo-articles t
495 "*If non-nil, insert pseudo-articles when decoding articles."
496 :group 'gnus-extract-view
499 (defcustom gnus-summary-dummy-line-format
501 "*The format specification for the dummy roots in the summary buffer.
502 It works along the same lines as a normal formatting string,
503 with some simple extensions.
506 :group 'gnus-threading
509 (defcustom gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
510 "*The format specification for the summary mode line.
511 It works along the same lines as a normal formatting string,
512 with some simple extensions:
515 %p Unprefixed group name
516 %A Current article number
517 %z Current article score
519 %U Number of unread articles in the group
520 %e Number of unselected articles in the group
521 %Z A string with unread/unselected article counts
522 %g Shortish group name
523 %S Subject of the current article
525 %s Current score file name
526 %d Number of dormant articles
527 %r Number of articles that have been marked as read in this session
528 %E Number of articles expunged by the score files"
529 :group 'gnus-summary-format
532 (defcustom gnus-summary-mark-below 0
533 "*Mark all articles with a score below this variable as read.
534 This variable is local to each summary buffer and usually set by the
536 :group 'gnus-score-default
539 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
540 "*List of functions used for sorting articles in the summary buffer.
541 This variable is only used when not using a threaded display."
542 :group 'gnus-summary-sort
543 :type '(repeat (choice (function-item gnus-article-sort-by-number)
544 (function-item gnus-article-sort-by-author)
545 (function-item gnus-article-sort-by-subject)
546 (function-item gnus-article-sort-by-date)
547 (function-item gnus-article-sort-by-score)
548 (function :tag "other"))))
550 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
551 "*List of functions used for sorting threads in the summary buffer.
552 By default, threads are sorted by article number.
554 Each function takes two threads and return non-nil if the first thread
555 should be sorted before the other. If you use more than one function,
556 the primary sort function should be the last. You should probably
557 always include `gnus-thread-sort-by-number' in the list of sorting
558 functions -- preferably first.
560 Ready-made functions include `gnus-thread-sort-by-number',
561 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
562 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
563 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
564 :group 'gnus-summary-sort
565 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
566 (function-item gnus-thread-sort-by-author)
567 (function-item gnus-thread-sort-by-subject)
568 (function-item gnus-thread-sort-by-date)
569 (function-item gnus-thread-sort-by-score)
570 (function-item gnus-thread-sort-by-total-score)
571 (function :tag "other"))))
573 (defcustom gnus-thread-score-function '+
574 "*Function used for calculating the total score of a thread.
576 The function is called with the scores of the article and each
577 subthread and should then return the score of the thread.
579 Some functions you can use are `+', `max', or `min'."
580 :group 'gnus-summary-sort
583 (defcustom gnus-summary-expunge-below nil
584 "All articles that have a score less than this variable will be expunged.
585 This variable is local to the summary buffers."
586 :group 'gnus-score-default
587 :type '(choice (const :tag "off" nil)
590 (defcustom gnus-thread-expunge-below nil
591 "All threads that have a total score less than this variable will be expunged.
592 See `gnus-thread-score-function' for en explanation of what a
595 This variable is local to the summary buffers."
596 :group 'gnus-treading
597 :group 'gnus-score-default
598 :type '(choice (const :tag "off" nil)
601 (defcustom gnus-summary-mode-hook nil
602 "*A hook for Gnus summary mode.
603 This hook is run before any variables are set in the summary buffer."
604 :group 'gnus-summary-various
607 (defcustom gnus-summary-menu-hook nil
608 "*Hook run after the creation of the summary mode menu."
609 :group 'gnus-summary-visual
612 (defcustom gnus-summary-exit-hook nil
613 "*A hook called on exit from the summary buffer.
614 It will be called with point in the group buffer."
615 :group 'gnus-summary-exit
618 (defcustom gnus-summary-prepare-hook nil
619 "*A hook called after the summary buffer has been generated.
620 If you want to modify the summary buffer, you can use this hook."
621 :group 'gnus-summary-various
624 (defcustom gnus-summary-prepared-hook nil
625 "*A hook called as the last thing after the summary buffer has been generated."
626 :group 'gnus-summary-various
629 (defcustom gnus-summary-generate-hook nil
630 "*A hook run just before generating the summary buffer.
631 This hook is commonly used to customize threading variables and the
633 :group 'gnus-summary-various
636 (defcustom gnus-select-group-hook nil
637 "*A hook called when a newsgroup is selected.
639 If you'd like to simplify subjects like the
640 `gnus-summary-next-same-subject' command does, you can use the
643 (setq gnus-select-group-hook
646 (mapcar (lambda (header)
647 (mail-header-set-subject
649 (gnus-simplify-subject
650 (mail-header-subject header) 're-only)))
651 gnus-newsgroup-headers))))"
652 :group 'gnus-group-select
655 (defcustom gnus-select-article-hook nil
656 "*A hook called when an article is selected."
657 :group 'gnus-summary-choose
660 (defcustom gnus-visual-mark-article-hook
661 (list 'gnus-highlight-selected-summary)
662 "*Hook run after selecting an article in the summary buffer.
663 It is meant to be used for highlighting the article in some way. It
664 is not run if `gnus-visual' is nil."
665 :group 'gnus-summary-visual
668 (defcustom gnus-structured-field-decoder
669 #'eword-decode-and-unfold-structured-field
670 "Function to decode non-ASCII characters in structured field for summary."
674 (defcustom gnus-unstructured-field-decoder
677 (eword-decode-unstructured-field-body
678 (std11-unfold-string string) 'must-unfold)
680 "Function to decode non-ASCII characters in unstructured field for summary."
684 (defcustom gnus-parse-headers-hook
685 '(gnus-set-summary-default-charset)
686 "*A hook called before parsing the headers."
690 (defcustom gnus-exit-group-hook nil
691 "*A hook called when exiting (not quitting) summary mode."
695 (defcustom gnus-summary-update-hook
696 (list 'gnus-summary-highlight-line)
697 "*A hook called when a summary line is changed.
698 The hook will not be called if `gnus-visual' is nil.
700 The default function `gnus-summary-highlight-line' will
701 highlight the line according to the `gnus-summary-highlight'
703 :group 'gnus-summary-visual
706 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
707 "*A hook called when an article is selected for the first time.
708 The hook is intended to mark an article as read (or unread)
709 automatically when it is selected."
710 :group 'gnus-summary-choose
713 (defcustom gnus-group-no-more-groups-hook nil
714 "*A hook run when returning to group mode having no more (unread) groups."
715 :group 'gnus-group-select
718 (defcustom gnus-ps-print-hook nil
719 "*A hook run before ps-printing something from Gnus."
723 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
724 "Face used for highlighting the current article in the summary buffer."
725 :group 'gnus-summary-visual
728 (defcustom gnus-summary-highlight
729 '(((= mark gnus-canceled-mark)
730 . gnus-summary-cancelled-face)
731 ((and (> score default)
732 (or (= mark gnus-dormant-mark)
733 (= mark gnus-ticked-mark)))
734 . gnus-summary-high-ticked-face)
735 ((and (< score default)
736 (or (= mark gnus-dormant-mark)
737 (= mark gnus-ticked-mark)))
738 . gnus-summary-low-ticked-face)
739 ((or (= mark gnus-dormant-mark)
740 (= mark gnus-ticked-mark))
741 . gnus-summary-normal-ticked-face)
742 ((and (> score default) (= mark gnus-ancient-mark))
743 . gnus-summary-high-ancient-face)
744 ((and (< score default) (= mark gnus-ancient-mark))
745 . gnus-summary-low-ancient-face)
746 ((= mark gnus-ancient-mark)
747 . gnus-summary-normal-ancient-face)
748 ((and (> score default) (= mark gnus-unread-mark))
749 . gnus-summary-high-unread-face)
750 ((and (< score default) (= mark gnus-unread-mark))
751 . gnus-summary-low-unread-face)
752 ((= mark gnus-unread-mark)
753 . gnus-summary-normal-unread-face)
754 ((and (> score default) (memq mark (list gnus-downloadable-mark
755 gnus-undownloaded-mark)))
756 . gnus-summary-high-unread-face)
757 ((and (< score default) (memq mark (list gnus-downloadable-mark
758 gnus-undownloaded-mark)))
759 . gnus-summary-low-unread-face)
760 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
761 . gnus-summary-normal-unread-face)
763 . gnus-summary-high-read-face)
765 . gnus-summary-low-read-face)
767 . gnus-summary-normal-read-face))
768 "*Controls the highlighting of summary buffer lines.
770 A list of (FORM . FACE) pairs. When deciding how a a particular
771 summary line should be displayed, each form is evaluated. The content
772 of the face field after the first true form is used. You can change
773 how those summary lines are displayed, by editing the face field.
775 You can use the following variables in the FORM field.
777 score: The articles score
778 default: The default article score.
779 below: The score below which articles are automatically marked as read.
780 mark: The articles mark."
781 :group 'gnus-summary-visual
782 :type '(repeat (cons (sexp :tag "Form" nil)
785 (defcustom gnus-alter-header-function nil
786 "Function called to allow alteration of article header structures.
787 The function is called with one parameter, the article header vector,
788 which it may alter in any way.")
790 ;;; Internal variables
792 (defvar gnus-scores-exclude-files nil)
793 (defvar gnus-page-broken nil)
795 (defvar gnus-original-article nil)
796 (defvar gnus-article-internal-prepare-hook nil)
797 (defvar gnus-newsgroup-process-stack nil)
799 (defvar gnus-thread-indent-array nil)
800 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
802 ;; Avoid highlighting in kill files.
803 (defvar gnus-summary-inhibit-highlight nil)
804 (defvar gnus-newsgroup-selected-overlay nil)
805 (defvar gnus-inhibit-limiting nil)
806 (defvar gnus-newsgroup-adaptive-score-file nil)
807 (defvar gnus-current-score-file nil)
808 (defvar gnus-current-move-group nil)
809 (defvar gnus-current-copy-group nil)
810 (defvar gnus-current-crosspost-group nil)
812 (defvar gnus-newsgroup-dependencies nil)
813 (defvar gnus-newsgroup-adaptive nil)
814 (defvar gnus-summary-display-article-function nil)
815 (defvar gnus-summary-highlight-line-function nil
816 "Function called after highlighting a summary line.")
818 (defvar gnus-summary-line-format-alist
819 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
820 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
821 (?s gnus-tmp-subject-or-nil ?s)
822 (?n gnus-tmp-name ?s)
823 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
825 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
827 (?F gnus-tmp-from ?s)
828 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
829 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
830 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
831 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
832 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
833 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
834 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
835 (?L gnus-tmp-lines ?d)
836 (?I gnus-tmp-indentation ?s)
837 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
838 (?R gnus-tmp-replied ?c)
839 (?\[ gnus-tmp-opening-bracket ?c)
840 (?\] gnus-tmp-closing-bracket ?c)
841 (?\> (make-string gnus-tmp-level ? ) ?s)
842 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
843 (?i gnus-tmp-score ?d)
844 (?z gnus-tmp-score-char ?c)
845 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
846 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
847 (?U gnus-tmp-unread ?c)
848 (?t (gnus-summary-number-of-articles-in-thread
849 (and (boundp 'thread) (car thread)) gnus-tmp-level)
851 (?e (gnus-summary-number-of-articles-in-thread
852 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
854 (?u gnus-tmp-user-defined ?s)
855 (?P (gnus-pick-line-number) ?d))
856 "An alist of format specifications that can appear in summary lines,
857 and what variables they correspond with, along with the type of the
858 variable (string, integer, character, etc).")
860 (defvar gnus-summary-dummy-line-format-alist
861 `((?S gnus-tmp-subject ?s)
862 (?N gnus-tmp-number ?d)
863 (?u gnus-tmp-user-defined ?s)))
865 (defvar gnus-summary-mode-line-format-alist
866 `((?G gnus-tmp-group-name ?s)
867 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
868 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
869 (?A gnus-tmp-article-number ?d)
870 (?Z gnus-tmp-unread-and-unselected ?s)
872 (?U gnus-tmp-unread-and-unticked ?d)
873 (?S gnus-tmp-subject ?s)
874 (?e gnus-tmp-unselected ?d)
875 (?u gnus-tmp-user-defined ?s)
876 (?d (length gnus-newsgroup-dormant) ?d)
877 (?t (length gnus-newsgroup-marked) ?d)
878 (?r (length gnus-newsgroup-reads) ?d)
879 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
880 (?E gnus-newsgroup-expunged-tally ?d)
881 (?s (gnus-current-score-file-nondirectory) ?s)))
883 (defvar gnus-last-search-regexp nil
884 "Default regexp for article search command.")
886 (defvar gnus-last-shell-command nil
887 "Default shell command on article.")
889 (defvar gnus-newsgroup-begin nil)
890 (defvar gnus-newsgroup-end nil)
891 (defvar gnus-newsgroup-last-rmail nil)
892 (defvar gnus-newsgroup-last-mail nil)
893 (defvar gnus-newsgroup-last-folder nil)
894 (defvar gnus-newsgroup-last-file nil)
895 (defvar gnus-newsgroup-auto-expire nil)
896 (defvar gnus-newsgroup-active nil)
898 (defvar gnus-newsgroup-data nil)
899 (defvar gnus-newsgroup-data-reverse nil)
900 (defvar gnus-newsgroup-limit nil)
901 (defvar gnus-newsgroup-limits nil)
903 (defvar gnus-newsgroup-unreads nil
904 "List of unread articles in the current newsgroup.")
906 (defvar gnus-newsgroup-unselected nil
907 "List of unselected unread articles in the current newsgroup.")
909 (defvar gnus-newsgroup-reads nil
910 "Alist of read articles and article marks in the current newsgroup.")
912 (defvar gnus-newsgroup-expunged-tally nil)
914 (defvar gnus-newsgroup-marked nil
915 "List of ticked articles in the current newsgroup (a subset of unread art).")
917 (defvar gnus-newsgroup-killed nil
918 "List of ranges of articles that have been through the scoring process.")
920 (defvar gnus-newsgroup-cached nil
921 "List of articles that come from the article cache.")
923 (defvar gnus-newsgroup-saved nil
924 "List of articles that have been saved.")
926 (defvar gnus-newsgroup-kill-headers nil)
928 (defvar gnus-newsgroup-replied nil
929 "List of articles that have been replied to in the current newsgroup.")
931 (defvar gnus-newsgroup-expirable nil
932 "List of articles in the current newsgroup that can be expired.")
934 (defvar gnus-newsgroup-processable nil
935 "List of articles in the current newsgroup that can be processed.")
937 (defvar gnus-newsgroup-downloadable nil
938 "List of articles in the current newsgroup that can be processed.")
940 (defvar gnus-newsgroup-undownloaded nil
941 "List of articles in the current newsgroup that haven't been downloaded..")
943 (defvar gnus-newsgroup-unsendable nil
944 "List of articles in the current newsgroup that won't be sent.")
946 (defvar gnus-newsgroup-bookmarks nil
947 "List of articles in the current newsgroup that have bookmarks.")
949 (defvar gnus-newsgroup-dormant nil
950 "List of dormant articles in the current newsgroup.")
952 (defvar gnus-newsgroup-scored nil
953 "List of scored articles in the current newsgroup.")
955 (defvar gnus-newsgroup-headers nil
956 "List of article headers in the current newsgroup.")
958 (defvar gnus-newsgroup-threads nil)
960 (defvar gnus-newsgroup-prepared nil
961 "Whether the current group has been prepared properly.")
963 (defvar gnus-newsgroup-ancient nil
964 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
966 (defvar gnus-newsgroup-sparse nil)
968 (defvar gnus-current-article nil)
969 (defvar gnus-article-current nil)
970 (defvar gnus-current-headers nil)
971 (defvar gnus-have-all-headers nil)
972 (defvar gnus-last-article nil)
973 (defvar gnus-newsgroup-history nil)
975 (defconst gnus-summary-local-variables
976 '(gnus-newsgroup-name
977 gnus-newsgroup-begin gnus-newsgroup-end
978 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
979 gnus-newsgroup-last-folder gnus-newsgroup-last-file
980 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
981 gnus-newsgroup-unselected gnus-newsgroup-marked
982 gnus-newsgroup-reads gnus-newsgroup-saved
983 gnus-newsgroup-replied gnus-newsgroup-expirable
984 gnus-newsgroup-processable gnus-newsgroup-killed
985 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
986 gnus-newsgroup-unsendable
987 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
988 gnus-newsgroup-headers gnus-newsgroup-threads
989 gnus-newsgroup-prepared gnus-summary-highlight-line-function
990 gnus-current-article gnus-current-headers gnus-have-all-headers
991 gnus-last-article gnus-article-internal-prepare-hook
992 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
993 gnus-newsgroup-scored gnus-newsgroup-kill-headers
994 gnus-thread-expunge-below
995 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
996 (gnus-summary-mark-below . global)
997 gnus-newsgroup-active gnus-scores-exclude-files
998 gnus-newsgroup-history gnus-newsgroup-ancient
999 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1000 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1001 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1002 (gnus-newsgroup-expunged-tally . 0)
1003 gnus-cache-removable-articles gnus-newsgroup-cached
1004 gnus-newsgroup-data gnus-newsgroup-data-reverse
1005 gnus-newsgroup-limit gnus-newsgroup-limits)
1006 "Variables that are buffer-local to the summary buffers.")
1008 ;; Byte-compiler warning.
1009 (defvar gnus-article-mode-map)
1011 ;; Subject simplification.
1013 (defun gnus-simplify-whitespace (str)
1014 "Remove excessive whitespace."
1017 (while (string-match "[ \t][ \t]+" mystr)
1018 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1020 (substring mystr (match-end 0)))))
1022 (when (string-match "^[ \t]+" mystr)
1023 (setq mystr (substring mystr (match-end 0))))
1025 (when (string-match "[ \t]+$" mystr)
1026 (setq mystr (substring mystr 0 (match-beginning 0))))
1029 (defsubst gnus-simplify-subject-re (subject)
1030 "Remove \"Re:\" from subject lines."
1031 (if (string-match "^[Rr][Ee]: *" subject)
1032 (substring subject (match-end 0))
1035 (defun gnus-simplify-subject (subject &optional re-only)
1036 "Remove `Re:' and words in parentheses.
1037 If RE-ONLY is non-nil, strip leading `Re:'s only."
1038 (let ((case-fold-search t)) ;Ignore case.
1039 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1040 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1041 (setq subject (substring subject (match-end 0))))
1042 ;; Remove uninteresting prefixes.
1043 (when (and (not re-only)
1044 gnus-simplify-ignored-prefixes
1045 (string-match gnus-simplify-ignored-prefixes subject))
1046 (setq subject (substring subject (match-end 0))))
1047 ;; Remove words in parentheses from end.
1049 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1050 (setq subject (substring subject 0 (match-beginning 0)))))
1051 ;; Return subject string.
1054 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1056 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1057 (goto-char (point-min))
1058 (while (re-search-forward regexp nil t)
1059 (replace-match (or newtext ""))))
1061 (defun gnus-simplify-buffer-fuzzy ()
1062 "Simplify string in the buffer fuzzily.
1063 The string in the accessible portion of the current buffer is simplified.
1064 It is assumed to be a single-line subject.
1065 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1066 matter is removed. Additional things can be deleted by setting
1067 gnus-simplify-subject-fuzzy-regexp."
1068 (let ((case-fold-search t)
1070 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1072 (while (not (eq modified-tick (buffer-modified-tick)))
1073 (setq modified-tick (buffer-modified-tick))
1075 ((listp gnus-simplify-subject-fuzzy-regexp)
1076 (mapcar 'gnus-simplify-buffer-fuzzy-step
1077 gnus-simplify-subject-fuzzy-regexp))
1078 (gnus-simplify-subject-fuzzy-regexp
1079 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1080 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1081 (gnus-simplify-buffer-fuzzy-step
1082 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1083 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1085 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1086 (gnus-simplify-buffer-fuzzy-step " +" " ")
1087 (gnus-simplify-buffer-fuzzy-step " $")
1088 (gnus-simplify-buffer-fuzzy-step "^ +")))
1090 (defun gnus-simplify-subject-fuzzy (subject)
1091 "Simplify a subject string fuzzily.
1092 See `gnus-simplify-buffer-fuzzy' for details."
1094 (gnus-set-work-buffer)
1095 (let ((case-fold-search t))
1096 ;; Remove uninteresting prefixes.
1097 (when (and gnus-simplify-ignored-prefixes
1098 (string-match gnus-simplify-ignored-prefixes subject))
1099 (setq subject (substring subject (match-end 0))))
1101 (inline (gnus-simplify-buffer-fuzzy))
1104 (defsubst gnus-simplify-subject-fully (subject)
1105 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1107 (gnus-simplify-subject-functions
1108 (gnus-map-function gnus-simplify-subject-functions subject))
1109 ((null gnus-summary-gather-subject-limit)
1110 (gnus-simplify-subject-re subject))
1111 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1112 (gnus-simplify-subject-fuzzy subject))
1113 ((numberp gnus-summary-gather-subject-limit)
1114 (gnus-limit-string (gnus-simplify-subject-re subject)
1115 gnus-summary-gather-subject-limit))
1119 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1120 "Check whether two subjects are equal.
1121 If optional argument simple-first is t, first argument is already
1124 ((null simple-first)
1125 (equal (gnus-simplify-subject-fully s1)
1126 (gnus-simplify-subject-fully s2)))
1129 (gnus-simplify-subject-fully s2)))))
1131 (defun gnus-summary-bubble-group ()
1132 "Increase the score of the current group.
1133 This is a handy function to add to `gnus-summary-exit-hook' to
1134 increase the score of each group you read."
1135 (gnus-group-add-score gnus-newsgroup-name))
1139 ;;; Gnus summary mode
1142 (put 'gnus-summary-mode 'mode-class 'special)
1145 ;; Non-orthogonal keys
1147 (gnus-define-keys gnus-summary-mode-map
1148 " " gnus-summary-next-page
1149 "\177" gnus-summary-prev-page
1150 [delete] gnus-summary-prev-page
1151 [backspace] gnus-summary-prev-page
1152 "\r" gnus-summary-scroll-up
1153 "\e\r" gnus-summary-scroll-down
1154 "n" gnus-summary-next-unread-article
1155 "p" gnus-summary-prev-unread-article
1156 "N" gnus-summary-next-article
1157 "P" gnus-summary-prev-article
1158 "\M-\C-n" gnus-summary-next-same-subject
1159 "\M-\C-p" gnus-summary-prev-same-subject
1160 "\M-n" gnus-summary-next-unread-subject
1161 "\M-p" gnus-summary-prev-unread-subject
1162 "." gnus-summary-first-unread-article
1163 "," gnus-summary-best-unread-article
1164 "\M-s" gnus-summary-search-article-forward
1165 "\M-r" gnus-summary-search-article-backward
1166 "<" gnus-summary-beginning-of-article
1167 ">" gnus-summary-end-of-article
1168 "j" gnus-summary-goto-article
1169 "^" gnus-summary-refer-parent-article
1170 "\M-^" gnus-summary-refer-article
1171 "u" gnus-summary-tick-article-forward
1172 "!" gnus-summary-tick-article-forward
1173 "U" gnus-summary-tick-article-backward
1174 "d" gnus-summary-mark-as-read-forward
1175 "D" gnus-summary-mark-as-read-backward
1176 "E" gnus-summary-mark-as-expirable
1177 "\M-u" gnus-summary-clear-mark-forward
1178 "\M-U" gnus-summary-clear-mark-backward
1179 "k" gnus-summary-kill-same-subject-and-select
1180 "\C-k" gnus-summary-kill-same-subject
1181 "\M-\C-k" gnus-summary-kill-thread
1182 "\M-\C-l" gnus-summary-lower-thread
1183 "e" gnus-summary-edit-article
1184 "#" gnus-summary-mark-as-processable
1185 "\M-#" gnus-summary-unmark-as-processable
1186 "\M-\C-t" gnus-summary-toggle-threads
1187 "\M-\C-s" gnus-summary-show-thread
1188 "\M-\C-h" gnus-summary-hide-thread
1189 "\M-\C-f" gnus-summary-next-thread
1190 "\M-\C-b" gnus-summary-prev-thread
1191 "\M-\C-u" gnus-summary-up-thread
1192 "\M-\C-d" gnus-summary-down-thread
1193 "&" gnus-summary-execute-command
1194 "c" gnus-summary-catchup-and-exit
1195 "\C-w" gnus-summary-mark-region-as-read
1196 "\C-t" gnus-summary-toggle-truncation
1197 "?" gnus-summary-mark-as-dormant
1198 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1199 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1200 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1201 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1202 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1203 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1204 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1205 "=" gnus-summary-expand-window
1206 "\C-x\C-s" gnus-summary-reselect-current-group
1207 "\M-g" gnus-summary-rescan-group
1208 "w" gnus-summary-stop-page-breaking
1209 "\C-c\C-r" gnus-summary-caesar-message
1210 "\M-t" gnus-summary-toggle-mime
1211 "f" gnus-summary-followup
1212 "F" gnus-summary-followup-with-original
1213 "C" gnus-summary-cancel-article
1214 "r" gnus-summary-reply
1215 "R" gnus-summary-reply-with-original
1216 "\C-c\C-f" gnus-summary-mail-forward
1217 "o" gnus-summary-save-article
1218 "\C-o" gnus-summary-save-article-mail
1219 "|" gnus-summary-pipe-output
1220 "\M-k" gnus-summary-edit-local-kill
1221 "\M-K" gnus-summary-edit-global-kill
1223 "\C-c\C-d" gnus-summary-describe-group
1224 "q" gnus-summary-exit
1225 "Q" gnus-summary-exit-no-update
1226 "\C-c\C-i" gnus-info-find-node
1227 gnus-mouse-2 gnus-mouse-pick-article
1228 "m" gnus-summary-mail-other-window
1229 "a" gnus-summary-post-news
1230 "x" gnus-summary-limit-to-unread
1231 "s" gnus-summary-isearch-article
1232 "t" gnus-article-hide-headers
1233 "g" gnus-summary-show-article
1234 "l" gnus-summary-goto-last-article
1235 "v" gnus-summary-preview-mime-message
1236 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1237 "\C-d" gnus-summary-enter-digest-group
1238 "\M-\C-d" gnus-summary-read-document
1239 "\M-\C-e" gnus-summary-edit-parameters
1241 "*" gnus-cache-enter-article
1242 "\M-*" gnus-cache-remove-article
1243 "\M-&" gnus-summary-universal-argument
1244 "\C-l" gnus-recenter
1245 "I" gnus-summary-increase-score
1246 "L" gnus-summary-lower-score
1247 "\M-i" gnus-symbolic-argument
1248 "h" gnus-summary-select-article-buffer
1250 "V" gnus-summary-score-map
1251 "X" gnus-uu-extract-map
1252 "S" gnus-summary-send-map)
1254 ;; Sort of orthogonal keymap
1255 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1256 "t" gnus-summary-tick-article-forward
1257 "!" gnus-summary-tick-article-forward
1258 "d" gnus-summary-mark-as-read-forward
1259 "r" gnus-summary-mark-as-read-forward
1260 "c" gnus-summary-clear-mark-forward
1261 " " gnus-summary-clear-mark-forward
1262 "e" gnus-summary-mark-as-expirable
1263 "x" gnus-summary-mark-as-expirable
1264 "?" gnus-summary-mark-as-dormant
1265 "b" gnus-summary-set-bookmark
1266 "B" gnus-summary-remove-bookmark
1267 "#" gnus-summary-mark-as-processable
1268 "\M-#" gnus-summary-unmark-as-processable
1269 "S" gnus-summary-limit-include-expunged
1270 "C" gnus-summary-catchup
1271 "H" gnus-summary-catchup-to-here
1272 "\C-c" gnus-summary-catchup-all
1273 "k" gnus-summary-kill-same-subject-and-select
1274 "K" gnus-summary-kill-same-subject
1275 "P" gnus-uu-mark-map)
1277 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1278 "c" gnus-summary-clear-above
1279 "u" gnus-summary-tick-above
1280 "m" gnus-summary-mark-above
1281 "k" gnus-summary-kill-below)
1283 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1284 "/" gnus-summary-limit-to-subject
1285 "n" gnus-summary-limit-to-articles
1286 "w" gnus-summary-pop-limit
1287 "s" gnus-summary-limit-to-subject
1288 "a" gnus-summary-limit-to-author
1289 "u" gnus-summary-limit-to-unread
1290 "m" gnus-summary-limit-to-marks
1291 "v" gnus-summary-limit-to-score
1292 "*" gnus-summary-limit-include-cached
1293 "D" gnus-summary-limit-include-dormant
1294 "T" gnus-summary-limit-include-thread
1295 "d" gnus-summary-limit-exclude-dormant
1296 "t" gnus-summary-limit-to-age
1297 "E" gnus-summary-limit-include-expunged
1298 "c" gnus-summary-limit-exclude-childless-dormant
1299 "C" gnus-summary-limit-mark-excluded-as-read)
1301 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1302 "n" gnus-summary-next-unread-article
1303 "p" gnus-summary-prev-unread-article
1304 "N" gnus-summary-next-article
1305 "P" gnus-summary-prev-article
1306 "\C-n" gnus-summary-next-same-subject
1307 "\C-p" gnus-summary-prev-same-subject
1308 "\M-n" gnus-summary-next-unread-subject
1309 "\M-p" gnus-summary-prev-unread-subject
1310 "f" gnus-summary-first-unread-article
1311 "b" gnus-summary-best-unread-article
1312 "j" gnus-summary-goto-article
1313 "g" gnus-summary-goto-subject
1314 "l" gnus-summary-goto-last-article
1315 "o" gnus-summary-pop-article)
1317 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1318 "k" gnus-summary-kill-thread
1319 "l" gnus-summary-lower-thread
1320 "i" gnus-summary-raise-thread
1321 "T" gnus-summary-toggle-threads
1322 "t" gnus-summary-rethread-current
1323 "^" gnus-summary-reparent-thread
1324 "s" gnus-summary-show-thread
1325 "S" gnus-summary-show-all-threads
1326 "h" gnus-summary-hide-thread
1327 "H" gnus-summary-hide-all-threads
1328 "n" gnus-summary-next-thread
1329 "p" gnus-summary-prev-thread
1330 "u" gnus-summary-up-thread
1331 "o" gnus-summary-top-thread
1332 "d" gnus-summary-down-thread
1333 "#" gnus-uu-mark-thread
1334 "\M-#" gnus-uu-unmark-thread)
1336 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1337 "g" gnus-summary-prepare
1338 "c" gnus-summary-insert-cached-articles)
1340 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1341 "c" gnus-summary-catchup-and-exit
1342 "C" gnus-summary-catchup-all-and-exit
1343 "E" gnus-summary-exit-no-update
1344 "Q" gnus-summary-exit
1345 "Z" gnus-summary-exit
1346 "n" gnus-summary-catchup-and-goto-next-group
1347 "R" gnus-summary-reselect-current-group
1348 "G" gnus-summary-rescan-group
1349 "N" gnus-summary-next-group
1350 "s" gnus-summary-save-newsrc
1351 "P" gnus-summary-prev-group)
1353 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1354 " " gnus-summary-next-page
1355 "n" gnus-summary-next-page
1356 "\177" gnus-summary-prev-page
1357 [delete] gnus-summary-prev-page
1358 "p" gnus-summary-prev-page
1359 "\r" gnus-summary-scroll-up
1360 "<" gnus-summary-beginning-of-article
1361 ">" gnus-summary-end-of-article
1362 "b" gnus-summary-beginning-of-article
1363 "e" gnus-summary-end-of-article
1364 "^" gnus-summary-refer-parent-article
1365 "r" gnus-summary-refer-parent-article
1366 "R" gnus-summary-refer-references
1367 "T" gnus-summary-refer-thread
1368 "g" gnus-summary-show-article
1369 "s" gnus-summary-isearch-article
1370 "P" gnus-summary-print-article)
1372 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1373 "b" gnus-article-add-buttons
1374 "B" gnus-article-add-buttons-to-head
1375 "o" gnus-article-treat-overstrike
1376 "e" gnus-article-emphasize
1377 "w" gnus-article-fill-cited-article
1378 "c" gnus-article-remove-cr
1379 "f" gnus-article-display-x-face
1380 "l" gnus-summary-stop-page-breaking
1381 "r" gnus-summary-caesar-message
1382 "t" gnus-article-hide-headers
1383 "v" gnus-summary-verbose-headers
1384 "m" gnus-summary-toggle-mime
1385 "h" gnus-article-treat-html
1386 "d" gnus-article-treat-dumbquotes)
1388 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1389 "a" gnus-article-hide
1390 "h" gnus-article-hide-headers
1391 "b" gnus-article-hide-boring-headers
1392 "s" gnus-article-hide-signature
1393 "c" gnus-article-hide-citation
1394 "p" gnus-article-hide-pgp
1395 "P" gnus-article-hide-pem
1396 "\C-c" gnus-article-hide-citation-maybe)
1398 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1399 "a" gnus-article-highlight
1400 "h" gnus-article-highlight-headers
1401 "c" gnus-article-highlight-citation
1402 "s" gnus-article-highlight-signature)
1404 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1405 "z" gnus-article-date-ut
1406 "u" gnus-article-date-ut
1407 "l" gnus-article-date-local
1408 "e" gnus-article-date-lapsed
1409 "o" gnus-article-date-original
1410 "i" gnus-article-date-iso8601
1411 "s" gnus-article-date-user)
1413 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1414 "t" gnus-article-remove-trailing-blank-lines
1415 "l" gnus-article-strip-leading-blank-lines
1416 "m" gnus-article-strip-multiple-blank-lines
1417 "a" gnus-article-strip-blank-lines
1418 "A" gnus-article-strip-all-blank-lines
1419 "s" gnus-article-strip-leading-space)
1421 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1423 "f" gnus-summary-fetch-faq
1424 "d" gnus-summary-describe-group
1425 "h" gnus-summary-describe-briefly
1426 "i" gnus-info-find-node)
1428 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1429 "e" gnus-summary-expire-articles
1430 "\M-\C-e" gnus-summary-expire-articles-now
1431 "\177" gnus-summary-delete-article
1432 [delete] gnus-summary-delete-article
1433 "m" gnus-summary-move-article
1434 "r" gnus-summary-respool-article
1435 "w" gnus-summary-edit-article
1436 "c" gnus-summary-copy-article
1437 "B" gnus-summary-crosspost-article
1438 "q" gnus-summary-respool-query
1439 "t" gnus-summary-respool-trace
1440 "i" gnus-summary-import-article
1441 "p" gnus-summary-article-posted-p)
1443 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1444 "o" gnus-summary-save-article
1445 "m" gnus-summary-save-article-mail
1446 "F" gnus-summary-write-article-file
1447 "r" gnus-summary-save-article-rmail
1448 "f" gnus-summary-save-article-file
1449 "b" gnus-summary-save-article-body-file
1450 "h" gnus-summary-save-article-folder
1451 "v" gnus-summary-save-article-vm
1452 "p" gnus-summary-pipe-output
1453 "s" gnus-soup-add-article))
1455 (defun gnus-summary-make-menu-bar ()
1456 (gnus-turn-off-edit-menu 'summary)
1458 (unless (boundp 'gnus-summary-misc-menu)
1461 gnus-summary-kill-menu gnus-summary-mode-map ""
1466 ["Enter score..." gnus-summary-score-entry t]
1467 ["Customize" gnus-score-customize t])
1468 (gnus-make-score-map 'increase)
1469 (gnus-make-score-map 'lower)
1471 ["Kill below" gnus-summary-kill-below t]
1472 ["Mark above" gnus-summary-mark-above t]
1473 ["Tick above" gnus-summary-tick-above t]
1474 ["Clear above" gnus-summary-clear-above t])
1475 ["Current score" gnus-summary-current-score t]
1476 ["Set score" gnus-summary-set-score t]
1477 ["Switch current score file..." gnus-score-change-score-file t]
1478 ["Set mark below..." gnus-score-set-mark-below t]
1479 ["Set expunge below..." gnus-score-set-expunge-below t]
1480 ["Edit current score file" gnus-score-edit-current-scores t]
1481 ["Edit score file" gnus-score-edit-file t]
1482 ["Trace score" gnus-score-find-trace t]
1483 ["Find words" gnus-score-find-favourite-words t]
1484 ["Rescore buffer" gnus-summary-rescore t]
1485 ["Increase score..." gnus-summary-increase-score t]
1486 ["Lower score..." gnus-summary-lower-score t]))))
1488 ;; Define both the Article menu in the summary buffer and the equivalent
1489 ;; Commands menu in the article buffer here for consistency.
1492 ["All" gnus-article-hide t]
1493 ["Headers" gnus-article-hide-headers t]
1494 ["Signature" gnus-article-hide-signature t]
1495 ["Citation" gnus-article-hide-citation t]
1496 ["PGP" gnus-article-hide-pgp t]
1497 ["Boring headers" gnus-article-hide-boring-headers t])
1499 ["All" gnus-article-highlight t]
1500 ["Headers" gnus-article-highlight-headers t]
1501 ["Signature" gnus-article-highlight-signature t]
1502 ["Citation" gnus-article-highlight-citation t])
1504 ["Local" gnus-article-date-local t]
1505 ["ISO8601" gnus-article-date-iso8601 t]
1506 ["UT" gnus-article-date-ut t]
1507 ["Original" gnus-article-date-original t]
1508 ["Lapsed" gnus-article-date-lapsed t]
1509 ["User-defined" gnus-article-date-user t])
1512 ["Leading" gnus-article-strip-leading-blank-lines t]
1513 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1514 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1515 ["All of the above" gnus-article-strip-blank-lines t]
1516 ["All" gnus-article-strip-all-blank-lines t]
1517 ["Leading space" gnus-article-strip-leading-space t])
1518 ["Overstrike" gnus-article-treat-overstrike t]
1519 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1520 ["Emphasis" gnus-article-emphasize t]
1521 ["Word wrap" gnus-article-fill-cited-article t]
1522 ["CR" gnus-article-remove-cr t]
1523 ["Show X-Face" gnus-article-display-x-face t]
1524 ["UnHTMLize" gnus-article-treat-html t]
1525 ["Rot 13" gnus-summary-caesar-message t]
1526 ["Unix pipe" gnus-summary-pipe-message t]
1527 ["Add buttons" gnus-article-add-buttons t]
1528 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1529 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1530 ["Toggle MIME" gnus-summary-toggle-mime t]
1531 ["Verbose header" gnus-summary-verbose-headers t]
1532 ["Toggle header" gnus-summary-toggle-header t])
1534 ["Save in default format" gnus-summary-save-article t]
1535 ["Save in file" gnus-summary-save-article-file t]
1536 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1537 ["Save in MH folder" gnus-summary-save-article-folder t]
1538 ["Save in VM folder" gnus-summary-save-article-vm t]
1539 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1540 ["Save body in file" gnus-summary-save-article-body-file t]
1541 ["Pipe through a filter" gnus-summary-pipe-output t]
1542 ["Add to SOUP packet" gnus-soup-add-article t]
1543 ["Print" gnus-summary-print-article t])
1545 ["Respool article..." gnus-summary-respool-article t]
1546 ["Move article..." gnus-summary-move-article
1547 (gnus-check-backend-function
1548 'request-move-article gnus-newsgroup-name)]
1549 ["Copy article..." gnus-summary-copy-article t]
1550 ["Crosspost article..." gnus-summary-crosspost-article
1551 (gnus-check-backend-function
1552 'request-replace-article gnus-newsgroup-name)]
1553 ["Import file..." gnus-summary-import-article t]
1554 ["Check if posted" gnus-summary-article-posted-p t]
1555 ["Edit article" gnus-summary-edit-article
1556 (not (gnus-group-read-only-p))]
1557 ["Delete article" gnus-summary-delete-article
1558 (gnus-check-backend-function
1559 'request-expire-articles gnus-newsgroup-name)]
1560 ["Query respool" gnus-summary-respool-query t]
1561 ["Trace respool" gnus-summary-respool-trace t]
1562 ["Delete expirable articles" gnus-summary-expire-articles-now
1563 (gnus-check-backend-function
1564 'request-expire-articles gnus-newsgroup-name)])
1566 ["Uudecode" gnus-uu-decode-uu t]
1567 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1568 ["Unshar" gnus-uu-decode-unshar t]
1569 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1570 ["Save" gnus-uu-decode-save t]
1571 ["Binhex" gnus-uu-decode-binhex t]
1572 ["Postscript" gnus-uu-decode-postscript t])
1574 ["Enter article" gnus-cache-enter-article t]
1575 ["Remove article" gnus-cache-remove-article t])
1576 ["Select article buffer" gnus-summary-select-article-buffer t]
1577 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1578 ["Isearch article..." gnus-summary-isearch-article t]
1579 ["Beginning of the article" gnus-summary-beginning-of-article t]
1580 ["End of the article" gnus-summary-end-of-article t]
1581 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1582 ["Fetch referenced articles" gnus-summary-refer-references t]
1583 ["Fetch current thread" gnus-summary-refer-thread t]
1584 ["Fetch article with id..." gnus-summary-refer-article t]
1585 ["Redisplay" gnus-summary-show-article t])))
1587 gnus-summary-article-menu gnus-summary-mode-map ""
1588 (cons "Article" innards))
1591 gnus-article-commands-menu gnus-article-mode-map ""
1592 (cons "Commands" innards)))
1595 gnus-summary-thread-menu gnus-summary-mode-map ""
1597 ["Toggle threading" gnus-summary-toggle-threads t]
1598 ["Hide threads" gnus-summary-hide-all-threads t]
1599 ["Show threads" gnus-summary-show-all-threads t]
1600 ["Hide thread" gnus-summary-hide-thread t]
1601 ["Show thread" gnus-summary-show-thread t]
1602 ["Go to next thread" gnus-summary-next-thread t]
1603 ["Go to previous thread" gnus-summary-prev-thread t]
1604 ["Go down thread" gnus-summary-down-thread t]
1605 ["Go up thread" gnus-summary-up-thread t]
1606 ["Top of thread" gnus-summary-top-thread t]
1607 ["Mark thread as read" gnus-summary-kill-thread t]
1608 ["Lower thread score" gnus-summary-lower-thread t]
1609 ["Raise thread score" gnus-summary-raise-thread t]
1610 ["Rethread current" gnus-summary-rethread-current t]
1614 gnus-summary-post-menu gnus-summary-mode-map ""
1616 ["Post an article" gnus-summary-post-news t]
1617 ["Followup" gnus-summary-followup t]
1618 ["Followup and yank" gnus-summary-followup-with-original t]
1619 ["Supersede article" gnus-summary-supersede-article t]
1620 ["Cancel article" gnus-summary-cancel-article t]
1621 ["Reply" gnus-summary-reply t]
1622 ["Reply and yank" gnus-summary-reply-with-original t]
1623 ["Wide reply" gnus-summary-wide-reply t]
1624 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1625 ["Mail forward" gnus-summary-mail-forward t]
1626 ["Post forward" gnus-summary-post-forward t]
1627 ["Digest and mail" gnus-uu-digest-mail-forward t]
1628 ["Digest and post" gnus-uu-digest-post-forward t]
1629 ["Resend message" gnus-summary-resend-message t]
1630 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1631 ["Send a mail" gnus-summary-mail-other-window t]
1632 ["Uuencode and post" gnus-uu-post-news t]
1633 ["Followup via news" gnus-summary-followup-to-mail t]
1634 ["Followup via news and yank"
1635 gnus-summary-followup-to-mail-with-original t]
1637 ;;["Send" gnus-summary-send-draft t]
1638 ;;["Send bounced" gnus-resend-bounced-mail t])
1642 gnus-summary-misc-menu gnus-summary-mode-map ""
1645 ["Mark as read" gnus-summary-mark-as-read-forward t]
1646 ["Mark same subject and select"
1647 gnus-summary-kill-same-subject-and-select t]
1648 ["Mark same subject" gnus-summary-kill-same-subject t]
1649 ["Catchup" gnus-summary-catchup t]
1650 ["Catchup all" gnus-summary-catchup-all t]
1651 ["Catchup to here" gnus-summary-catchup-to-here t]
1652 ["Catchup region" gnus-summary-mark-region-as-read t]
1653 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1655 ["Tick" gnus-summary-tick-article-forward t]
1656 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1657 ["Remove marks" gnus-summary-clear-mark-forward t]
1658 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1659 ["Set bookmark" gnus-summary-set-bookmark t]
1660 ["Remove bookmark" gnus-summary-remove-bookmark t])
1662 ["Marks..." gnus-summary-limit-to-marks t]
1663 ["Subject..." gnus-summary-limit-to-subject t]
1664 ["Author..." gnus-summary-limit-to-author t]
1665 ["Age..." gnus-summary-limit-to-age t]
1666 ["Score" gnus-summary-limit-to-score t]
1667 ["Unread" gnus-summary-limit-to-unread t]
1668 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1669 ["Articles" gnus-summary-limit-to-articles t]
1670 ["Pop limit" gnus-summary-pop-limit t]
1671 ["Show dormant" gnus-summary-limit-include-dormant t]
1672 ["Hide childless dormant"
1673 gnus-summary-limit-exclude-childless-dormant t]
1674 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1675 ["Show expunged" gnus-summary-show-all-expunged t])
1677 ["Set mark" gnus-summary-mark-as-processable t]
1678 ["Remove mark" gnus-summary-unmark-as-processable t]
1679 ["Remove all marks" gnus-summary-unmark-all-processable t]
1680 ["Mark above" gnus-uu-mark-over t]
1681 ["Mark series" gnus-uu-mark-series t]
1682 ["Mark region" gnus-uu-mark-region t]
1683 ["Unmark region" gnus-uu-unmark-region t]
1684 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1685 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1686 ["Mark all" gnus-uu-mark-all t]
1687 ["Mark buffer" gnus-uu-mark-buffer t]
1688 ["Mark sparse" gnus-uu-mark-sparse t]
1689 ["Mark thread" gnus-uu-mark-thread t]
1690 ["Unmark thread" gnus-uu-unmark-thread t]
1691 ("Process Mark Sets"
1692 ["Kill" gnus-summary-kill-process-mark t]
1693 ["Yank" gnus-summary-yank-process-mark
1694 gnus-newsgroup-process-stack]
1695 ["Save" gnus-summary-save-process-mark t]))
1697 ["Page forward" gnus-summary-next-page t]
1698 ["Page backward" gnus-summary-prev-page t]
1699 ["Line forward" gnus-summary-scroll-up t])
1701 ["Next unread article" gnus-summary-next-unread-article t]
1702 ["Previous unread article" gnus-summary-prev-unread-article t]
1703 ["Next article" gnus-summary-next-article t]
1704 ["Previous article" gnus-summary-prev-article t]
1705 ["Next unread subject" gnus-summary-next-unread-subject t]
1706 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1707 ["Next article same subject" gnus-summary-next-same-subject t]
1708 ["Previous article same subject" gnus-summary-prev-same-subject t]
1709 ["First unread article" gnus-summary-first-unread-article t]
1710 ["Best unread article" gnus-summary-best-unread-article t]
1711 ["Go to subject number..." gnus-summary-goto-subject t]
1712 ["Go to article number..." gnus-summary-goto-article t]
1713 ["Go to the last article" gnus-summary-goto-last-article t]
1714 ["Pop article off history" gnus-summary-pop-article t])
1716 ["Sort by number" gnus-summary-sort-by-number t]
1717 ["Sort by author" gnus-summary-sort-by-author t]
1718 ["Sort by subject" gnus-summary-sort-by-subject t]
1719 ["Sort by date" gnus-summary-sort-by-date t]
1720 ["Sort by score" gnus-summary-sort-by-score t]
1721 ["Sort by lines" gnus-summary-sort-by-lines t])
1723 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1724 ["Describe group" gnus-summary-describe-group t]
1725 ["Read manual" gnus-info-find-node t])
1727 ["Pick and read" gnus-pick-mode t]
1728 ["Binary" gnus-binary-mode t])
1730 ["Regenerate" gnus-summary-prepare t]
1731 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1732 ["Toggle threading" gnus-summary-toggle-threads t])
1733 ["Filter articles..." gnus-summary-execute-command t]
1734 ["Run command on subjects..." gnus-summary-universal-argument t]
1735 ["Search articles forward..." gnus-summary-search-article-forward t]
1736 ["Search articles backward..." gnus-summary-search-article-backward t]
1737 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1738 ["Expand window" gnus-summary-expand-window t]
1739 ["Expire expirable articles" gnus-summary-expire-articles
1740 (gnus-check-backend-function
1741 'request-expire-articles gnus-newsgroup-name)]
1742 ["Edit local kill file" gnus-summary-edit-local-kill t]
1743 ["Edit main kill file" gnus-summary-edit-global-kill t]
1744 ["Edit group parameters" gnus-summary-edit-parameters t]
1746 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1747 ["Catchup all and exit" gnus-summary-catchup-and-exit t]
1748 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1749 ["Exit group" gnus-summary-exit t]
1750 ["Exit group without updating" gnus-summary-exit-no-update t]
1751 ["Exit and goto next group" gnus-summary-next-group t]
1752 ["Exit and goto prev group" gnus-summary-prev-group t]
1753 ["Reselect group" gnus-summary-reselect-current-group t]
1754 ["Rescan group" gnus-summary-rescan-group t]
1755 ["Update dribble" gnus-summary-save-newsrc t])))
1757 (gnus-run-hooks 'gnus-summary-menu-hook)))
1759 (defun gnus-score-set-default (var value)
1760 "A version of set that updates the GNU Emacs menu-bar."
1762 ;; It is the message that forces the active status to be updated.
1765 (defun gnus-make-score-map (type)
1766 "Make a summary score map of type TYPE."
1769 (let ((headers '(("author" "from" string)
1770 ("subject" "subject" string)
1771 ("article body" "body" string)
1772 ("article head" "head" string)
1773 ("xref" "xref" string)
1774 ("lines" "lines" number)
1775 ("followups to author" "followup" string)))
1776 (types '((number ("less than" <)
1779 (string ("substring" s)
1783 (perms '(("temporary" (current-time-string))
1791 (if (eq type 'lower)
1796 (setq header (car headers))
1802 (let ((ts (cdr (assoc (nth 2 header) types)))
1818 'gnus-summary-score-entry
1820 (if (or (string= (nth 1 header)
1822 (string= (nth 1 header)
1825 (list 'gnus-summary-header
1827 (list 'quote (nth 1 (car ts)))
1828 (list 'gnus-score-default nil)
1834 (list (nreverse outp))))
1837 (list (nreverse outt))))
1839 (setq headers (cdr headers)))
1840 (list (nreverse outh))))))))
1844 (defun gnus-summary-mode (&optional group)
1845 "Major mode for reading articles.
1847 All normal editing commands are switched off.
1848 \\<gnus-summary-mode-map>
1849 Each line in this buffer represents one article. To read an
1850 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
1851 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
1854 You can also post articles and send mail from this buffer. To
1855 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
1856 of an article, type `\\[gnus-summary-reply]'.
1858 There are approx. one gazillion commands you can execute in this
1859 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
1861 The following commands are available:
1863 \\{gnus-summary-mode-map}"
1865 (when (gnus-visual-p 'summary-menu 'menu)
1866 (gnus-summary-make-menu-bar))
1867 (kill-all-local-variables)
1868 (gnus-summary-make-local-variables)
1869 (gnus-make-thread-indent-array)
1870 (gnus-simplify-mode-line)
1871 (setq major-mode 'gnus-summary-mode)
1872 (setq mode-name "Summary")
1873 (make-local-variable 'minor-mode-alist)
1874 (use-local-map gnus-summary-mode-map)
1875 (buffer-disable-undo (current-buffer))
1876 (setq buffer-read-only t) ;Disable modification
1877 (setq truncate-lines t)
1878 (setq selective-display t)
1879 (setq selective-display-ellipses t) ;Display `...'
1880 (gnus-summary-set-display-table)
1881 (gnus-set-default-directory)
1882 (setq gnus-newsgroup-name group)
1883 (make-local-variable 'gnus-summary-line-format)
1884 (make-local-variable 'gnus-summary-line-format-spec)
1885 (make-local-variable 'gnus-summary-dummy-line-format)
1886 (make-local-variable 'gnus-summary-dummy-line-format-spec)
1887 (make-local-variable 'gnus-summary-mark-positions)
1888 (make-local-hook 'post-command-hook)
1889 (add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
1890 (make-local-hook 'pre-command-hook)
1891 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
1892 (gnus-run-hooks 'gnus-summary-mode-hook)
1893 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
1894 (gnus-update-summary-mark-positions))
1896 (defun gnus-summary-make-local-variables ()
1897 "Make all the local summary buffer variables."
1898 (let ((locals gnus-summary-local-variables)
1900 (while (setq local (pop locals))
1903 (if (eq (cdr local) 'global)
1904 ;; Copy the global value of the variable.
1905 (setq global (symbol-value (car local)))
1906 ;; Use the value from the list.
1907 (setq global (eval (cdr local))))
1908 (make-local-variable (car local))
1909 (set (car local) global))
1910 ;; Simple nil-valued local variable.
1911 (make-local-variable local)
1914 (defun gnus-summary-clear-local-variables ()
1915 (let ((locals gnus-summary-local-variables))
1917 (if (consp (car locals))
1918 (and (vectorp (caar locals))
1919 (set (caar locals) nil))
1920 (and (vectorp (car locals))
1921 (set (car locals) nil)))
1922 (setq locals (cdr locals)))))
1924 ;; Summary data functions.
1926 (defmacro gnus-data-number (data)
1929 (defmacro gnus-data-set-number (data number)
1930 `(setcar ,data ,number))
1932 (defmacro gnus-data-mark (data)
1935 (defmacro gnus-data-set-mark (data mark)
1936 `(setcar (nthcdr 1 ,data) ,mark))
1938 (defmacro gnus-data-pos (data)
1941 (defmacro gnus-data-set-pos (data pos)
1942 `(setcar (nthcdr 2 ,data) ,pos))
1944 (defmacro gnus-data-header (data)
1947 (defmacro gnus-data-set-header (data header)
1948 `(setf (nth 3 ,data) ,header))
1950 (defmacro gnus-data-level (data)
1953 (defmacro gnus-data-unread-p (data)
1954 `(= (nth 1 ,data) gnus-unread-mark))
1956 (defmacro gnus-data-read-p (data)
1957 `(/= (nth 1 ,data) gnus-unread-mark))
1959 (defmacro gnus-data-pseudo-p (data)
1960 `(consp (nth 3 ,data)))
1962 (defmacro gnus-data-find (number)
1963 `(assq ,number gnus-newsgroup-data))
1965 (defmacro gnus-data-find-list (number &optional data)
1966 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
1967 (memq (assq ,number bdata)
1970 (defmacro gnus-data-make (number mark pos header level)
1971 `(list ,number ,mark ,pos ,header ,level))
1973 (defun gnus-data-enter (after-article number mark pos header level offset)
1974 (let ((data (gnus-data-find-list after-article)))
1976 (error "No such article: %d" after-article))
1977 (setcdr data (cons (gnus-data-make number mark pos header level)
1979 (setq gnus-newsgroup-data-reverse nil)
1980 (gnus-data-update-list (cddr data) offset)))
1982 (defun gnus-data-enter-list (after-article list &optional offset)
1984 (let ((data (and after-article (gnus-data-find-list after-article)))
1986 (or data (not after-article) (error "No such article: %d" after-article))
1987 ;; Find the last element in the list to be spliced into the main
1990 (setq list (cdr list)))
1993 (setcdr list gnus-newsgroup-data)
1994 (setq gnus-newsgroup-data ilist)
1996 (gnus-data-update-list (cdr list) offset)))
1997 (setcdr list (cdr data))
2000 (gnus-data-update-list (cdr list) offset)))
2001 (setq gnus-newsgroup-data-reverse nil))))
2003 (defun gnus-data-remove (article &optional offset)
2004 (let ((data gnus-newsgroup-data))
2005 (if (= (gnus-data-number (car data)) article)
2007 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2008 gnus-newsgroup-data-reverse nil)
2010 (gnus-data-update-list gnus-newsgroup-data offset)))
2012 (when (= (gnus-data-number (cadr data)) article)
2013 (setcdr data (cddr data))
2015 (gnus-data-update-list (cdr data) offset))
2017 gnus-newsgroup-data-reverse nil))
2018 (setq data (cdr data))))))
2020 (defmacro gnus-data-list (backward)
2022 (or gnus-newsgroup-data-reverse
2023 (setq gnus-newsgroup-data-reverse
2024 (reverse gnus-newsgroup-data)))
2025 gnus-newsgroup-data))
2027 (defun gnus-data-update-list (data offset)
2028 "Add OFFSET to the POS of all data entries in DATA."
2030 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2031 (setq data (cdr data))))
2033 (defun gnus-data-compute-positions ()
2034 "Compute the positions of all articles."
2035 (let ((data gnus-newsgroup-data)
2038 (when (setq pos (text-property-any
2039 (point-min) (point-max)
2040 'gnus-number (gnus-data-number (car data))))
2041 (gnus-data-set-pos (car data) (+ pos 3)))
2042 (setq data (cdr data)))))
2044 (defun gnus-summary-article-pseudo-p (article)
2045 "Say whether this article is a pseudo article or not."
2046 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2048 (defmacro gnus-summary-article-sparse-p (article)
2049 "Say whether this article is a sparse article or not."
2050 `(memq ,article gnus-newsgroup-sparse))
2052 (defmacro gnus-summary-article-ancient-p (article)
2053 "Say whether this article is a sparse article or not."
2054 `(memq ,article gnus-newsgroup-ancient))
2056 (defun gnus-article-parent-p (number)
2057 "Say whether this article is a parent or not."
2058 (let ((data (gnus-data-find-list number)))
2059 (and (cdr data) ; There has to be an article after...
2060 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2061 (gnus-data-level (nth 1 data))))))
2063 (defun gnus-article-children (number)
2064 "Return a list of all children to NUMBER."
2065 (let* ((data (gnus-data-find-list number))
2066 (level (gnus-data-level (car data)))
2068 (setq data (cdr data))
2070 (= (gnus-data-level (car data)) (1+ level)))
2071 (push (gnus-data-number (car data)) children)
2072 (setq data (cdr data)))
2075 (defmacro gnus-summary-skip-intangible ()
2076 "If the current article is intangible, then jump to a different article."
2077 '(let ((to (get-text-property (point) 'gnus-intangible)))
2078 (and to (gnus-summary-goto-subject to))))
2080 (defmacro gnus-summary-article-intangible-p ()
2081 "Say whether this article is intangible or not."
2082 '(get-text-property (point) 'gnus-intangible))
2084 (defun gnus-article-read-p (article)
2085 "Say whether ARTICLE is read or not."
2086 (not (or (memq article gnus-newsgroup-marked)
2087 (memq article gnus-newsgroup-unreads)
2088 (memq article gnus-newsgroup-unselected)
2089 (memq article gnus-newsgroup-dormant))))
2091 ;; Some summary mode macros.
2093 (defmacro gnus-summary-article-number ()
2094 "The article number of the article on the current line.
2095 If there isn's an article number here, then we return the current
2098 (gnus-summary-skip-intangible)
2099 (or (get-text-property (point) 'gnus-number)
2100 (gnus-summary-last-subject))))
2102 (defmacro gnus-summary-article-header (&optional number)
2103 "Return the header of article NUMBER."
2104 `(gnus-data-header (gnus-data-find
2105 ,(or number '(gnus-summary-article-number)))))
2107 (defmacro gnus-summary-thread-level (&optional number)
2108 "Return the level of thread that starts with article NUMBER."
2109 `(if (and (eq gnus-summary-make-false-root 'dummy)
2110 (get-text-property (point) 'gnus-intangible))
2112 (gnus-data-level (gnus-data-find
2113 ,(or number '(gnus-summary-article-number))))))
2115 (defmacro gnus-summary-article-mark (&optional number)
2116 "Return the mark of article NUMBER."
2117 `(gnus-data-mark (gnus-data-find
2118 ,(or number '(gnus-summary-article-number)))))
2120 (defmacro gnus-summary-article-pos (&optional number)
2121 "Return the position of the line of article NUMBER."
2122 `(gnus-data-pos (gnus-data-find
2123 ,(or number '(gnus-summary-article-number)))))
2125 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2126 (defmacro gnus-summary-article-subject (&optional number)
2127 "Return current subject string or nil if nothing."
2130 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2131 '(gnus-data-header (assq (gnus-summary-article-number)
2132 gnus-newsgroup-data)))))
2135 (mail-header-subject headers))))
2137 (defmacro gnus-summary-article-score (&optional number)
2138 "Return current article score."
2139 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2140 gnus-newsgroup-scored))
2141 gnus-summary-default-score 0))
2143 (defun gnus-summary-article-children (&optional number)
2144 "Return a list of article numbers that are children of article NUMBER."
2145 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2146 (level (gnus-data-level (car data)))
2148 (while (and (setq data (cdr data))
2149 (> (setq l (gnus-data-level (car data))) level))
2150 (and (= (1+ level) l)
2151 (push (gnus-data-number (car data))
2153 (nreverse children)))
2155 (defun gnus-summary-article-parent (&optional number)
2156 "Return the article number of the parent of article NUMBER."
2157 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2158 (gnus-data-list t)))
2159 (level (gnus-data-level (car data))))
2161 () ; This is a root.
2162 ;; We search until we find an article with a level less than
2163 ;; this one. That function has to be the parent.
2164 (while (and (setq data (cdr data))
2165 (not (< (gnus-data-level (car data)) level))))
2166 (and data (gnus-data-number (car data))))))
2168 (defun gnus-unread-mark-p (mark)
2169 "Say whether MARK is the unread mark."
2170 (= mark gnus-unread-mark))
2172 (defun gnus-read-mark-p (mark)
2173 "Say whether MARK is one of the marks that mark as read.
2174 This is all marks except unread, ticked, dormant, and expirable."
2175 (not (or (= mark gnus-unread-mark)
2176 (= mark gnus-ticked-mark)
2177 (= mark gnus-dormant-mark)
2178 (= mark gnus-expirable-mark))))
2180 (defmacro gnus-article-mark (number)
2181 "Return the MARK of article NUMBER.
2182 This macro should only be used when computing the mark the \"first\"
2183 time; i.e., when generating the summary lines. After that,
2184 `gnus-summary-article-mark' should be used to examine the
2187 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2188 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2189 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2190 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2191 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2192 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2193 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2194 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2195 gnus-ancient-mark))))
2197 ;; Saving hidden threads.
2199 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2200 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2202 (defmacro gnus-save-hidden-threads (&rest forms)
2203 "Save hidden threads, eval FORMS, and restore the hidden threads."
2204 (let ((config (make-symbol "config")))
2205 `(let ((,config (gnus-hidden-threads-configuration)))
2209 (gnus-restore-hidden-threads-configuration ,config)))))
2211 (defun gnus-hidden-threads-configuration ()
2212 "Return the current hidden threads configuration."
2215 (goto-char (point-min))
2216 (while (search-forward "\r" nil t)
2217 (push (1- (point)) config))
2220 (defun gnus-restore-hidden-threads-configuration (config)
2221 "Restore hidden threads configuration from CONFIG."
2222 (let (point buffer-read-only)
2223 (while (setq point (pop config))
2224 (when (and (< point (point-max))
2226 (= (following-char) ?\n))
2227 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2229 ;; Various summary mode internalish functions.
2231 (defun gnus-mouse-pick-article (e)
2234 (gnus-summary-next-page nil t))
2236 (defun gnus-summary-set-display-table ()
2237 ;; Change the display table. Odd characters have a tendency to mess
2238 ;; up nicely formatted displays - we make all possible glyphs
2239 ;; display only a single character.
2241 ;; We start from the standard display table, if any.
2242 (let ((table (or (copy-sequence standard-display-table)
2243 (make-display-table)))
2245 ;; Nix out all the control chars...
2246 (while (>= (setq i (1- i)) 0)
2247 (aset table i [??]))
2248 ;; ... but not newline and cr, of course. (cr is necessary for the
2249 ;; selective display).
2250 (aset table ?\n nil)
2251 (aset table ?\r nil)
2252 ;; We keep TAB as well.
2253 (aset table ?\t nil)
2254 ;; We nix out any glyphs over 126 that are not set already.
2256 (while (>= (setq i (1- i)) 127)
2257 ;; Only modify if the entry is nil.
2258 (unless (aref table i)
2259 (aset table i [??]))))
2260 (setq buffer-display-table table)))
2262 (defun gnus-summary-setup-buffer (group)
2263 "Initialize summary buffer."
2264 (let ((buffer (concat "*Summary " group "*")))
2265 (if (get-buffer buffer)
2268 (setq gnus-summary-buffer (current-buffer))
2269 (not gnus-newsgroup-prepared))
2270 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2271 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
2272 (gnus-add-current-to-buffer-list)
2273 (gnus-summary-mode group)
2275 (gnus-carpal-setup-buffer 'summary))
2276 (unless gnus-single-article-buffer
2277 (make-local-variable 'gnus-article-buffer)
2278 (make-local-variable 'gnus-article-current)
2279 (make-local-variable 'gnus-original-article-buffer))
2280 (setq gnus-newsgroup-name group)
2283 (defun gnus-set-global-variables ()
2284 ;; Set the global equivalents of the summary buffer-local variables
2285 ;; to the latest values they had. These reflect the summary buffer
2286 ;; that was in action when the last article was fetched.
2287 (when (eq major-mode 'gnus-summary-mode)
2288 (setq gnus-summary-buffer (current-buffer))
2289 (let ((name gnus-newsgroup-name)
2290 (marked gnus-newsgroup-marked)
2291 (unread gnus-newsgroup-unreads)
2292 (headers gnus-current-headers)
2293 (data gnus-newsgroup-data)
2294 (summary gnus-summary-buffer)
2295 (article-buffer gnus-article-buffer)
2296 (original gnus-original-article-buffer)
2297 (gac gnus-article-current)
2298 (reffed gnus-reffed-article-number)
2299 (score-file gnus-current-score-file))
2301 (set-buffer gnus-group-buffer)
2302 (setq gnus-newsgroup-name name
2303 gnus-newsgroup-marked marked
2304 gnus-newsgroup-unreads unread
2305 gnus-current-headers headers
2306 gnus-newsgroup-data data
2307 gnus-article-current gac
2308 gnus-summary-buffer summary
2309 gnus-article-buffer article-buffer
2310 gnus-original-article-buffer original
2311 gnus-reffed-article-number reffed
2312 gnus-current-score-file score-file)
2313 ;; The article buffer also has local variables.
2314 (when (gnus-buffer-live-p gnus-article-buffer)
2315 (set-buffer gnus-article-buffer)
2316 (setq gnus-summary-buffer summary))))))
2318 (defun gnus-summary-article-unread-p (article)
2319 "Say whether ARTICLE is unread or not."
2320 (memq article gnus-newsgroup-unreads))
2322 (defun gnus-summary-first-article-p (&optional article)
2323 "Return whether ARTICLE is the first article in the buffer."
2324 (if (not (setq article (or article (gnus-summary-article-number))))
2326 (eq article (caar gnus-newsgroup-data))))
2328 (defun gnus-summary-last-article-p (&optional article)
2329 "Return whether ARTICLE is the last article in the buffer."
2330 (if (not (setq article (or article (gnus-summary-article-number))))
2331 t ; All non-existent numbers are the last article. :-)
2332 (not (cdr (gnus-data-find-list article)))))
2334 (defun gnus-make-thread-indent-array ()
2336 (unless (and gnus-thread-indent-array
2337 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2338 (setq gnus-thread-indent-array (make-vector 201 "")
2339 gnus-thread-indent-array-level gnus-thread-indent-level)
2341 (aset gnus-thread-indent-array n
2342 (make-string (* n gnus-thread-indent-level) ? ))
2345 (defun gnus-update-summary-mark-positions ()
2346 "Compute where the summary marks are to go."
2348 (when (gnus-buffer-exists-p gnus-summary-buffer)
2349 (set-buffer gnus-summary-buffer))
2350 (let ((gnus-replied-mark 129)
2351 (gnus-score-below-mark 130)
2352 (gnus-score-over-mark 130)
2353 (gnus-download-mark 131)
2354 (spec gnus-summary-line-format-spec)
2355 thread gnus-visual pos)
2357 (gnus-set-work-buffer)
2358 (let ((gnus-summary-line-format-spec spec)
2359 (gnus-newsgroup-downloadable '((0 . t))))
2360 (gnus-summary-insert-line
2361 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2362 (goto-char (point-min))
2363 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2365 (goto-char (point-min))
2366 (push (cons 'replied (and (search-forward "\201" nil t)
2369 (goto-char (point-min))
2370 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2372 (goto-char (point-min))
2373 (push (cons 'download
2374 (and (search-forward "\203" nil t) (- (point) 2)))
2376 (setq gnus-summary-mark-positions pos))))
2378 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2379 "Insert a dummy root in the summary buffer."
2381 (gnus-add-text-properties
2382 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2383 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2385 (defun gnus-summary-insert-line (gnus-tmp-header
2386 gnus-tmp-level gnus-tmp-current
2387 gnus-tmp-unread gnus-tmp-replied
2388 gnus-tmp-expirable gnus-tmp-subject-or-nil
2389 &optional gnus-tmp-dummy gnus-tmp-score
2391 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2392 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2393 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2394 (gnus-tmp-score-char
2395 (if (or (null gnus-summary-default-score)
2396 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2397 gnus-summary-zcore-fuzz))
2399 (if (< gnus-tmp-score gnus-summary-default-score)
2400 gnus-score-below-mark gnus-score-over-mark)))
2402 (cond (gnus-tmp-process gnus-process-mark)
2403 ((memq gnus-tmp-current gnus-newsgroup-cached)
2405 (gnus-tmp-replied gnus-replied-mark)
2406 ((memq gnus-tmp-current gnus-newsgroup-saved)
2408 (t gnus-unread-mark)))
2409 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2412 ((string-match "<[^>]+> *$" gnus-tmp-from)
2413 (let ((beg (match-beginning 0)))
2414 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2415 (substring gnus-tmp-from (1+ (match-beginning 0))
2416 (1- (match-end 0))))
2417 (substring gnus-tmp-from 0 beg))))
2418 ((string-match "(.+)" gnus-tmp-from)
2419 (substring gnus-tmp-from
2420 (1+ (match-beginning 0)) (1- (match-end 0))))
2422 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2423 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2424 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2425 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2426 (buffer-read-only nil))
2427 (when (string= gnus-tmp-name "")
2428 (setq gnus-tmp-name gnus-tmp-from))
2429 (unless (numberp gnus-tmp-lines)
2430 (setq gnus-tmp-lines 0))
2431 (gnus-put-text-property-excluding-characters-with-faces
2433 (progn (eval gnus-summary-line-format-spec) (point))
2434 'gnus-number gnus-tmp-number)
2435 (when (gnus-visual-p 'summary-highlight 'highlight)
2437 (gnus-run-hooks 'gnus-summary-update-hook)
2440 (defun gnus-summary-update-line (&optional dont-update)
2441 ;; Update summary line after change.
2442 (when (and gnus-summary-default-score
2443 (not gnus-summary-inhibit-highlight))
2444 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2445 (article (gnus-summary-article-number))
2446 (score (gnus-summary-article-score article)))
2448 (if (and gnus-summary-mark-below
2449 (< (gnus-summary-article-score)
2450 gnus-summary-mark-below))
2451 ;; This article has a low score, so we mark it as read.
2452 (when (memq article gnus-newsgroup-unreads)
2453 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2454 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2455 ;; This article was previously marked as read on account
2456 ;; of a low score, but now it has risen, so we mark it as
2458 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2459 (gnus-summary-update-mark
2460 (if (or (null gnus-summary-default-score)
2461 (<= (abs (- score gnus-summary-default-score))
2462 gnus-summary-zcore-fuzz))
2464 (if (< score gnus-summary-default-score)
2465 gnus-score-below-mark gnus-score-over-mark))
2467 ;; Do visual highlighting.
2468 (when (gnus-visual-p 'summary-highlight 'highlight)
2469 (gnus-run-hooks 'gnus-summary-update-hook)))))
2471 (defvar gnus-tmp-new-adopts nil)
2473 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2474 "Return the number of articles in THREAD.
2475 This may be 0 in some cases -- if none of the articles in
2476 the thread are to be displayed."
2478 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2480 ((not (listp thread))
2482 ((and (consp thread) (cdr thread))
2485 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2488 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2491 (when (and level (zerop level) gnus-tmp-new-adopts)
2494 'gnus-summary-number-of-articles-in-thread
2495 gnus-tmp-new-adopts))))
2497 (if (> number 1) gnus-not-empty-thread-mark
2498 gnus-empty-thread-mark)
2501 (defun gnus-summary-set-local-parameters (group)
2502 "Go through the local params of GROUP and set all variable specs in that list."
2503 (let ((params (gnus-group-find-parameter group))
2506 (setq elem (car params)
2507 params (cdr params))
2508 (and (consp elem) ; Has to be a cons.
2509 (consp (cdr elem)) ; The cdr has to be a list.
2510 (symbolp (car elem)) ; Has to be a symbol in there.
2511 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2512 (ignore-errors ; So we set it.
2513 (make-local-variable (car elem))
2514 (set (car elem) (eval (nth 1 elem))))))))
2516 (defun gnus-summary-read-group (group &optional show-all no-article
2517 kill-buffer no-display backward
2519 "Start reading news in newsgroup GROUP.
2520 If SHOW-ALL is non-nil, already read articles are also listed.
2521 If NO-ARTICLE is non-nil, no article is selected initially.
2522 If NO-DISPLAY, don't generate a summary buffer."
2526 (let ((gnus-auto-select-next nil))
2527 (or (gnus-summary-read-group-1
2528 group show-all no-article
2529 kill-buffer no-display)
2532 (eq gnus-auto-select-next 'quietly))
2533 (set-buffer gnus-group-buffer)
2534 ;; The entry function called above goes to the next
2535 ;; group automatically, so we go two groups back
2536 ;; if we are searching for the previous group.
2538 (gnus-group-prev-unread-group 2))
2539 (if (not (equal group (gnus-group-group-name)))
2540 (setq group (gnus-group-group-name))
2544 (defun gnus-summary-read-group-1 (group show-all no-article
2545 kill-buffer no-display
2546 &optional select-articles)
2547 ;; Killed foreign groups can't be entered.
2548 (when (and (not (gnus-group-native-p group))
2549 (not (gnus-gethash group gnus-newsrc-hashtb)))
2550 (error "Dead non-native groups can't be entered"))
2551 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2552 (let* ((new-group (gnus-summary-setup-buffer group))
2553 (quit-config (gnus-group-quit-config group))
2554 (did-select (and new-group (gnus-select-newsgroup
2555 group show-all select-articles))))
2557 ;; This summary buffer exists already, so we just select it.
2559 (gnus-set-global-variables)
2561 (gnus-kill-or-deaden-summary kill-buffer))
2562 (gnus-configure-windows 'summary 'force)
2563 (gnus-set-mode-line 'summary)
2564 (gnus-summary-position-point)
2567 ;; We couldn't select this group.
2569 (when (and (eq major-mode 'gnus-summary-mode)
2570 (not (equal (current-buffer) kill-buffer)))
2571 (kill-buffer (current-buffer))
2572 (if (not quit-config)
2574 ;; Update the info -- marks might need to be removed,
2576 (gnus-summary-update-info)
2577 (set-buffer gnus-group-buffer)
2578 (gnus-group-jump-to-group group)
2579 (gnus-group-next-unread-group 1))
2580 (gnus-handle-ephemeral-exit quit-config)))
2581 (gnus-message 3 "Can't select group")
2583 ;; The user did a `C-g' while prompting for number of articles,
2584 ;; so we exit this group.
2585 ((eq did-select 'quit)
2586 (and (eq major-mode 'gnus-summary-mode)
2587 (not (equal (current-buffer) kill-buffer))
2588 (kill-buffer (current-buffer)))
2590 (gnus-kill-or-deaden-summary kill-buffer))
2591 (if (not quit-config)
2593 (set-buffer gnus-group-buffer)
2594 (gnus-group-jump-to-group group)
2595 (gnus-group-next-unread-group 1)
2596 (gnus-configure-windows 'group 'force))
2597 (gnus-handle-ephemeral-exit quit-config))
2598 ;; Finally signal the quit.
2600 ;; The group was successfully selected.
2602 (gnus-set-global-variables)
2603 ;; Save the active value in effect when the group was entered.
2604 (setq gnus-newsgroup-active
2606 (gnus-active gnus-newsgroup-name)))
2607 ;; You can change the summary buffer in some way with this hook.
2608 (gnus-run-hooks 'gnus-select-group-hook)
2609 ;; Set any local variables in the group parameters.
2610 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2611 (gnus-update-format-specifications
2612 nil 'summary 'summary-mode 'summary-dummy)
2613 ;; Do score processing.
2614 (when gnus-use-scoring
2615 (gnus-possibly-score-headers))
2616 ;; Check whether to fill in the gaps in the threads.
2617 (when gnus-build-sparse-threads
2618 (gnus-build-sparse-threads))
2619 ;; Find the initial limit.
2620 (if gnus-show-threads
2622 (let ((gnus-newsgroup-dormant nil))
2623 (gnus-summary-initial-limit show-all))
2624 (gnus-summary-initial-limit show-all))
2625 (setq gnus-newsgroup-limit
2627 (lambda (header) (mail-header-number header))
2628 gnus-newsgroup-headers)))
2629 ;; Generate the summary buffer.
2631 (gnus-summary-prepare))
2632 (when gnus-use-trees
2633 (gnus-tree-open group)
2634 (setq gnus-summary-highlight-line-function
2635 'gnus-tree-highlight-article))
2636 ;; If the summary buffer is empty, but there are some low-scored
2637 ;; articles or some excluded dormants, we include these in the
2639 (when (and (zerop (buffer-size))
2641 (cond (gnus-newsgroup-dormant
2642 (gnus-summary-limit-include-dormant))
2643 ((and gnus-newsgroup-scored show-all)
2644 (gnus-summary-limit-include-expunged t))))
2645 ;; Function `gnus-apply-kill-file' must be called in this hook.
2646 (gnus-run-hooks 'gnus-apply-kill-hook)
2647 (if (and (zerop (buffer-size))
2650 ;; This newsgroup is empty.
2651 (gnus-summary-catchup-and-exit nil t)
2652 (gnus-message 6 "No unread news")
2654 (gnus-kill-or-deaden-summary kill-buffer))
2655 ;; Return nil from this function.
2657 ;; Hide conversation thread subtrees. We cannot do this in
2658 ;; gnus-summary-prepare-hook since kill processing may not
2659 ;; work with hidden articles.
2660 (and gnus-show-threads
2661 gnus-thread-hide-subtree
2662 (gnus-summary-hide-all-threads))
2664 (gnus-kill-or-deaden-summary kill-buffer))
2665 ;; Show first unread article if requested.
2666 (if (and (not no-article)
2668 gnus-newsgroup-unreads
2669 gnus-auto-select-first)
2670 (unless (if (eq gnus-auto-select-first 'best)
2671 (gnus-summary-best-unread-article)
2672 (gnus-summary-first-unread-article))
2673 (gnus-configure-windows 'summary))
2674 ;; Don't select any articles, just move point to the first
2675 ;; article in the group.
2676 (goto-char (point-min))
2677 (gnus-summary-position-point)
2678 (gnus-configure-windows 'summary 'force)
2679 (gnus-set-mode-line 'summary))
2680 (when (get-buffer-window gnus-group-buffer t)
2681 ;; Gotta use windows, because recenter does weird stuff if
2682 ;; the current buffer ain't the displayed window.
2683 (let ((owin (selected-window)))
2684 (select-window (get-buffer-window gnus-group-buffer t))
2685 (when (gnus-group-goto-group group)
2687 (select-window owin)))
2688 ;; Mark this buffer as "prepared".
2689 (setq gnus-newsgroup-prepared t)
2690 (gnus-run-hooks 'gnus-summary-prepared-hook)
2693 (defun gnus-summary-prepare ()
2694 "Generate the summary buffer."
2696 (let ((buffer-read-only nil))
2698 (setq gnus-newsgroup-data nil
2699 gnus-newsgroup-data-reverse nil)
2700 (gnus-run-hooks 'gnus-summary-generate-hook)
2701 ;; Generate the buffer, either with threads or without.
2702 (when gnus-newsgroup-headers
2703 (gnus-summary-prepare-threads
2704 (if gnus-show-threads
2705 (gnus-sort-gathered-threads
2706 (funcall gnus-summary-thread-gathering-function
2708 (gnus-cut-threads (gnus-make-threads)))))
2709 ;; Unthreaded display.
2710 (gnus-sort-articles gnus-newsgroup-headers))))
2711 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2712 ;; Call hooks for modifying summary buffer.
2713 (goto-char (point-min))
2714 (gnus-run-hooks 'gnus-summary-prepare-hook)))
2716 (defsubst gnus-general-simplify-subject (subject)
2717 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2720 ;; Truncate the subject.
2721 (gnus-simplify-subject-functions
2722 (gnus-map-function gnus-simplify-subject-functions subject))
2723 ((numberp gnus-summary-gather-subject-limit)
2724 (setq subject (gnus-simplify-subject-re subject))
2725 (if (> (length subject) gnus-summary-gather-subject-limit)
2726 (substring subject 0 gnus-summary-gather-subject-limit)
2728 ;; Fuzzily simplify it.
2729 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2730 (gnus-simplify-subject-fuzzy subject))
2731 ;; Just remove the leading "Re:".
2733 (gnus-simplify-subject-re subject))))
2735 (if (and gnus-summary-gather-exclude-subject
2736 (string-match gnus-summary-gather-exclude-subject subject))
2737 nil ; This article shouldn't be gathered
2740 (defun gnus-summary-simplify-subject-query ()
2741 "Query where the respool algorithm would put this article."
2743 (gnus-summary-select-article)
2744 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2746 (defun gnus-gather-threads-by-subject (threads)
2747 "Gather threads by looking at Subject headers."
2748 (if (not gnus-summary-make-false-root)
2750 (let ((hashtb (gnus-make-hashtable 1024))
2753 subject hthread whole-subject)
2755 (setq subject (gnus-general-simplify-subject
2756 (setq whole-subject (mail-header-subject
2759 (if (setq hthread (gnus-gethash subject hashtb))
2761 ;; We enter a dummy root into the thread, if we
2762 ;; haven't done that already.
2763 (unless (stringp (caar hthread))
2764 (setcar hthread (list whole-subject (car hthread))))
2765 ;; We add this new gathered thread to this gathered
2767 (setcdr (car hthread)
2768 (nconc (cdar hthread) (list (car threads))))
2769 ;; Remove it from the list of threads.
2770 (setcdr prev (cdr threads))
2771 (setq threads prev))
2772 ;; Enter this thread into the hash table.
2773 (gnus-sethash subject threads hashtb)))
2775 (setq threads (cdr threads)))
2778 (defun gnus-gather-threads-by-references (threads)
2779 "Gather threads by looking at References headers."
2780 (let ((idhashtb (gnus-make-hashtable 1024))
2781 (thhashtb (gnus-make-hashtable 1024))
2784 ids references id gthread gid entered ref)
2786 (when (setq references (mail-header-references (caar threads)))
2787 (setq id (mail-header-id (caar threads))
2788 ids (gnus-split-references references)
2790 (while (setq ref (pop ids))
2791 (setq ids (delete ref ids))
2792 (if (not (setq gid (gnus-gethash ref idhashtb)))
2794 (gnus-sethash ref id idhashtb)
2795 (gnus-sethash id threads thhashtb))
2796 (setq gthread (gnus-gethash gid thhashtb))
2798 ;; We enter a dummy root into the thread, if we
2799 ;; haven't done that already.
2800 (unless (stringp (caar gthread))
2801 (setcar gthread (list (mail-header-subject (caar gthread))
2803 ;; We add this new gathered thread to this gathered
2805 (setcdr (car gthread)
2806 (nconc (cdar gthread) (list (car threads)))))
2807 ;; Add it into the thread hash table.
2808 (gnus-sethash id gthread thhashtb)
2810 ;; Remove it from the list of threads.
2811 (setcdr prev (cdr threads))
2812 (setq threads prev))))
2814 (setq threads (cdr threads)))
2817 (defun gnus-sort-gathered-threads (threads)
2818 "Sort subtreads inside each gathered thread by article number."
2819 (let ((result threads))
2821 (when (stringp (caar threads))
2822 (setcdr (car threads)
2823 (sort (cdar threads) 'gnus-thread-sort-by-number)))
2824 (setq threads (cdr threads)))
2827 (defun gnus-thread-loop-p (root thread)
2828 "Say whether ROOT is in THREAD."
2829 (let ((stack (list thread))
2832 (while (setq thread (pop stack))
2833 (setq th (cdr thread))
2835 (not (eq (caar th) root)))
2838 ;; We have found a loop.
2840 (setcdr thread (delq (car th) (cdr thread)))
2841 (if (boundp (setq ref-dep (intern "none"
2842 gnus-newsgroup-dependencies)))
2843 (setcdr (symbol-value ref-dep)
2844 (nconc (cdr (symbol-value ref-dep))
2846 (set ref-dep (list nil (car th))))
2849 ;; Push all the subthreads onto the stack.
2850 (push (cdr thread) stack)))
2853 (defun gnus-make-threads ()
2854 "Go through the dependency hashtb and find the roots. Return all threads."
2856 (while (catch 'infloop
2859 ;; Deal with self-referencing References loops.
2860 (when (and (car (symbol-value refs))
2867 (car (symbol-value refs)) thread))
2868 (cdr (symbol-value refs)))))))
2871 (unless (car (symbol-value refs))
2872 ;; These threads do not refer back to any other articles,
2873 ;; so they're roots.
2874 (setq threads (append (cdr (symbol-value refs)) threads))))
2875 gnus-newsgroup-dependencies)))
2878 ;; Build the thread tree.
2879 (defun gnus-dependencies-add-header (header dependencies force-new)
2880 "Enter HEADER into the DEPENDENCIES table if it is not already there.
2882 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
2883 if it was already present.
2885 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
2886 will not be entered in the DEPENDENCIES table. Otherwise duplicate
2887 Message-IDs will be renamed be renamed to a unique Message-ID before
2890 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
2891 (let* ((id (mail-header-id header))
2892 (id-dep (and id (intern id dependencies)))
2893 ref ref-dep ref-header)
2894 ;; Enter this `header' in the `dependencies' table.
2898 ;; The first two cases do the normal part: enter a new `header'
2899 ;; in the `dependencies' table.
2900 ((not (boundp id-dep))
2901 (set id-dep (list header)))
2902 ((null (car (symbol-value id-dep)))
2903 (setcar (symbol-value id-dep) header))
2905 ;; From here the `header' was already present in the
2906 ;; `dependencies' table.
2908 ;; Overrides an existing entry;
2909 ;; just set the header part of the entry.
2910 (setcar (symbol-value id-dep) header))
2912 ;; Renames the existing `header' to a unique Message-ID.
2913 ((not gnus-summary-ignore-duplicates)
2914 ;; An article with this Message-ID has already been seen.
2915 ;; We rename the Message-ID.
2916 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
2918 (mail-header-set-id header id))
2920 ;; The last case ignores an existing entry, except it adds any
2921 ;; additional Xrefs (in case the two articles came from different
2923 ;; Also sets `header' to `nil' meaning that the `dependencies'
2924 ;; table was *not* modified.
2926 (mail-header-set-xref
2927 (car (symbol-value id-dep))
2928 (concat (or (mail-header-xref (car (symbol-value id-dep)))
2930 (or (mail-header-xref header) "")))
2934 ;; First check if that we are not creating a References loop.
2935 (setq ref (gnus-parent-id (mail-header-references header)))
2937 (setq ref-dep (intern-soft ref dependencies))
2939 (setq ref-header (car (symbol-value ref-dep))))
2940 (if (string= id ref)
2941 ;; Yuk! This is a reference loop. Make the article be a
2944 (mail-header-set-references (car (symbol-value id-dep)) "none")
2946 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
2947 (setq ref (gnus-parent-id (mail-header-references header)))
2948 (setq ref-dep (intern (or ref "none") dependencies))
2949 (if (boundp ref-dep)
2950 (setcdr (symbol-value ref-dep)
2951 (nconc (cdr (symbol-value ref-dep))
2952 (list (symbol-value id-dep))))
2953 (set ref-dep (list nil (symbol-value id-dep)))))
2956 (defun gnus-build-sparse-threads ()
2957 (let ((headers gnus-newsgroup-headers)
2958 (gnus-summary-ignore-duplicates t)
2959 header references generation relations
2960 cthread subject child end pthread relation new-child date)
2961 ;; First we create an alist of generations/relations, where
2962 ;; generations is how much we trust the relation, and the relation
2964 (gnus-message 7 "Making sparse threads...")
2966 (nnheader-set-temp-buffer " *gnus sparse threads*")
2967 (while (setq header (pop headers))
2968 (when (and (setq references (mail-header-references header))
2969 (not (string= references "")))
2971 (setq child (mail-header-id header)
2972 subject (mail-header-subject header)
2973 date (mail-header-date header)
2975 (while (search-backward ">" nil t)
2976 (setq end (1+ (point)))
2977 (when (search-backward "<" nil t)
2978 (setq new-child (buffer-substring (point) end))
2979 (push (list (incf generation)
2980 child (setq child new-child)
2984 (push (list (1+ generation) child nil subject) relations))
2986 (kill-buffer (current-buffer)))
2987 ;; Sort over trustworthiness.
2990 (when (gnus-dependencies-add-header
2991 (make-full-mail-header
2992 gnus-reffed-article-number
2993 (nth 3 relation) "" (or (nth 4 relation) "")
2995 (or (nth 2 relation) "") 0 0 "")
2996 gnus-newsgroup-dependencies nil)
2997 (push gnus-reffed-article-number gnus-newsgroup-limit)
2998 (push gnus-reffed-article-number gnus-newsgroup-sparse)
2999 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3000 gnus-newsgroup-reads)
3001 (decf gnus-reffed-article-number)))
3002 (sort relations 'car-less-than-car))
3003 (gnus-message 7 "Making sparse threads...done")))
3005 (defun gnus-build-old-threads ()
3006 ;; Look at all the articles that refer back to old articles, and
3007 ;; fetch the headers for the articles that aren't there. This will
3008 ;; build complete threads - if the roots haven't been expired by the
3013 (when (not (car (symbol-value refs)))
3014 (setq heads (cdr (symbol-value refs)))
3016 (if (memq (mail-header-number (caar heads))
3017 gnus-newsgroup-dormant)
3018 (setq heads (cdr heads))
3019 (setq id (symbol-name refs))
3020 (while (and (setq id (gnus-build-get-header id))
3021 (not (car (gnus-id-to-thread id)))))
3022 (setq heads nil)))))
3023 gnus-newsgroup-dependencies)))
3025 ;; The following macros and functions were written by Felix Lee
3026 ;; <flee@cse.psu.edu>.
3028 (defmacro gnus-nov-read-integer ()
3030 (if (= (following-char) ?\t)
3032 (let ((num (ignore-errors (read buffer))))
3033 (if (numberp num) num 0)))
3035 (search-forward "\t" eol 'move))))
3037 (defmacro gnus-nov-skip-field ()
3038 '(search-forward "\t" eol 'move))
3040 (defmacro gnus-nov-field ()
3041 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
3043 ;; This function has to be called with point after the article number
3044 ;; on the beginning of the line.
3045 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3046 (let ((eol (gnus-point-at-eol))
3047 (buffer (current-buffer))
3048 header rawtext decoded)
3050 ;; overview: [num subject from date id refs chars lines misc]
3053 (narrow-to-region (point) eol)
3058 (make-full-mail-header
3061 (setq rawtext (gnus-nov-field) ; subject
3063 gnus-unstructured-field-decoder rawtext))
3064 (if (string= rawtext decoded)
3066 (put-text-property 0 (length decoded) 'raw-text rawtext decoded)
3069 (setq rawtext (gnus-nov-field) ; from
3071 gnus-structured-field-decoder rawtext))
3072 (if (string= rawtext decoded)
3074 (put-text-property 0 (length decoded) 'raw-text rawtext decoded)
3076 (gnus-nov-field) ; date
3077 (or (gnus-nov-field)
3078 (nnheader-generate-fake-message-id)) ; id
3079 (gnus-nov-field) ; refs
3080 (gnus-nov-read-integer) ; chars
3081 (gnus-nov-read-integer) ; lines
3082 (unless (= (following-char) ?\n)
3083 (gnus-nov-field))))) ; misc
3087 (when gnus-alter-header-function
3088 (funcall gnus-alter-header-function header))
3089 (gnus-dependencies-add-header header dependencies force-new)))
3091 (defun gnus-build-get-header (id)
3092 ;; Look through the buffer of NOV lines and find the header to
3093 ;; ID. Enter this line into the dependencies hash table, and return
3094 ;; the id of the parent article (if any).
3095 (let ((deps gnus-newsgroup-dependencies)
3099 (set-buffer nntp-server-buffer)
3100 (let ((case-fold-search nil))
3101 (goto-char (point-min))
3102 (while (and (not found)
3103 (search-forward id nil t))
3105 (setq found (looking-at
3106 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3107 (regexp-quote id))))
3108 (or found (beginning-of-line 2)))
3112 (setq header (gnus-nov-parse-line
3113 (read (current-buffer)) deps))
3114 (gnus-parent-id (mail-header-references header))))))
3116 (let ((number (mail-header-number header)))
3117 (push number gnus-newsgroup-limit)
3118 (push header gnus-newsgroup-headers)
3119 (if (memq number gnus-newsgroup-unselected)
3121 (push number gnus-newsgroup-unreads)
3122 (setq gnus-newsgroup-unselected
3123 (delq number gnus-newsgroup-unselected)))
3124 (push number gnus-newsgroup-ancient)))))))
3126 (defun gnus-build-all-threads ()
3127 "Read all the headers."
3128 (let ((gnus-summary-ignore-duplicates t)
3129 (dependencies gnus-newsgroup-dependencies)
3130 found header article)
3132 (set-buffer nntp-server-buffer)
3133 (let ((case-fold-search nil))
3134 (goto-char (point-min))
3137 (setq article (read (current-buffer))
3138 header (gnus-nov-parse-line
3139 article dependencies)))
3141 (push header gnus-newsgroup-headers)
3142 (if (memq (setq article (mail-header-number header))
3143 gnus-newsgroup-unselected)
3145 (push article gnus-newsgroup-unreads)
3146 (setq gnus-newsgroup-unselected
3147 (delq article gnus-newsgroup-unselected)))
3148 (push article gnus-newsgroup-ancient))
3149 (forward-line 1)))))))
3151 (defun gnus-summary-update-article-line (article header)
3152 "Update the line for ARTICLE using HEADERS."
3153 (let* ((id (mail-header-id header))
3154 (thread (gnus-id-to-thread id)))
3156 (error "Article in no thread"))
3157 ;; Update the thread.
3158 (setcar thread header)
3159 (gnus-summary-goto-subject article)
3160 (let* ((datal (gnus-data-find-list article))
3162 (length (when (cdr datal)
3163 (- (gnus-data-pos data)
3164 (gnus-data-pos (cadr datal)))))
3165 (buffer-read-only nil)
3166 (level (gnus-summary-thread-level)))
3168 (gnus-summary-insert-line
3169 header level nil (gnus-article-mark article)
3170 (memq article gnus-newsgroup-replied)
3171 (memq article gnus-newsgroup-expirable)
3172 ;; Only insert the Subject string when it's different
3173 ;; from the previous Subject string.
3174 (if (gnus-subject-equal
3176 (mail-header-subject
3179 (gnus-data-find-list
3181 (gnus-data-list t)))))
3182 ;; Error on the side of excessive subjects.
3184 (mail-header-subject header))
3186 (mail-header-subject header))
3187 nil (cdr (assq article gnus-newsgroup-scored))
3188 (memq article gnus-newsgroup-processable))
3190 (gnus-data-update-list
3191 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3193 (defun gnus-summary-update-article (article &optional iheader)
3194 "Update ARTICLE in the summary buffer."
3195 (set-buffer gnus-summary-buffer)
3196 (let* ((header (or iheader (gnus-summary-article-header article)))
3197 (id (mail-header-id header))
3198 (data (gnus-data-find article))
3199 (thread (gnus-id-to-thread id))
3200 (references (mail-header-references header))
3204 (when (and references
3205 (not (equal "" references)))
3208 (buffer-read-only nil)
3210 (number (mail-header-number header))
3213 ;; !!! Should this be in or not?
3215 (setcar thread nil))
3217 (delq thread parent))
3218 (if (gnus-summary-insert-subject id header iheader)
3219 ;; Set the (possibly) new article number in the data structure.
3220 (gnus-data-set-number data (gnus-id-to-article id))
3224 (defun gnus-rebuild-thread (id &optional line)
3225 "Rebuild the thread containing ID.
3226 If LINE, insert the rebuilt thread starting on line LINE."
3227 (let ((buffer-read-only nil)
3228 old-pos current thread data)
3229 (if (not gnus-show-threads)
3230 (setq thread (list (car (gnus-id-to-thread id))))
3231 ;; Get the thread this article is part of.
3232 (setq thread (gnus-remove-thread id)))
3233 (setq old-pos (gnus-point-at-bol))
3234 (setq current (save-excursion
3235 (and (zerop (forward-line -1))
3236 (gnus-summary-article-number))))
3237 ;; If this is a gathered thread, we have to go some re-gathering.
3238 (when (stringp (car thread))
3239 (let ((subject (car thread))
3241 (setq thread (cdr thread))
3243 (unless (memq (setq thr (gnus-id-to-thread
3245 (mail-header-id (caar thread)))))
3248 (setq thread (cdr thread)))
3249 ;; We now have all (unique) roots.
3250 (if (= (length roots) 1)
3251 ;; All the loose roots are now one solid root.
3252 (setq thread (car roots))
3253 (setq thread (cons subject (gnus-sort-threads roots))))))
3255 ;; We then insert this thread into the summary buffer.
3257 (goto-char (point-min))
3258 (forward-line (1- line)))
3259 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3260 (if gnus-show-threads
3261 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3262 (gnus-summary-prepare-unthreaded thread))
3263 (setq data (nreverse gnus-newsgroup-data))
3264 (setq threads gnus-newsgroup-threads))
3265 ;; We splice the new data into the data structure.
3266 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3267 ;;!!! then we want to insert at the beginning of the buffer.
3268 ;;!!! That happens to be true with Gnus now, but that may
3269 ;;!!! change in the future. Perhaps.
3270 (gnus-data-enter-list (if line nil current) data (- (point) old-pos))
3271 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads))
3273 (gnus-data-compute-positions)))))
3275 (defun gnus-number-to-header (number)
3276 "Return the header for article NUMBER."
3277 (let ((headers gnus-newsgroup-headers))
3279 (not (= number (mail-header-number (car headers)))))
3284 (defun gnus-parent-headers (in-headers &optional generation)
3285 "Return the headers of the GENERATIONeth parent of HEADERS."
3287 (setq generation 1))
3289 (headers in-headers)
3292 (not (zerop generation))
3293 (setq references (mail-header-references headers)))
3294 (setq headers (if (and references
3295 (setq parent (gnus-parent-id references)))
3296 (car (gnus-id-to-thread parent))
3299 (and (not (eq headers in-headers))
3302 (defun gnus-id-to-thread (id)
3303 "Return the (sub-)thread where ID appears."
3304 (gnus-gethash id gnus-newsgroup-dependencies))
3306 (defun gnus-id-to-article (id)
3307 "Return the article number of ID."
3308 (let ((thread (gnus-id-to-thread id)))
3311 (mail-header-number (car thread)))))
3313 (defun gnus-id-to-header (id)
3314 "Return the article headers of ID."
3315 (car (gnus-id-to-thread id)))
3317 (defun gnus-article-displayed-root-p (article)
3318 "Say whether ARTICLE is a root(ish) article."
3319 (let ((level (gnus-summary-thread-level article))
3320 (refs (mail-header-references (gnus-summary-article-header article)))
3326 ((null (gnus-parent-id refs)) t)
3328 (null (setq particle (gnus-id-to-article
3329 (gnus-parent-id refs))))
3330 (null (gnus-summary-thread-level particle)))))))
3332 (defun gnus-root-id (id)
3333 "Return the id of the root of the thread where ID appears."
3335 (while (and id (setq prev (car (gnus-id-to-thread id))))
3337 id (gnus-parent-id (mail-header-references prev))))
3340 (defun gnus-articles-in-thread (thread)
3341 "Return the list of articles in THREAD."
3342 (cons (mail-header-number (car thread))
3343 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3345 (defun gnus-remove-thread (id &optional dont-remove)
3346 "Remove the thread that has ID in it."
3347 (let (headers thread last-id)
3348 ;; First go up in this thread until we find the root.
3349 (setq last-id (gnus-root-id id))
3350 (setq headers (list (car (gnus-id-to-thread last-id))
3351 (caadr (gnus-id-to-thread last-id))))
3352 ;; We have now found the real root of this thread. It might have
3353 ;; been gathered into some loose thread, so we have to search
3354 ;; through the threads to find the thread we wanted.
3355 (let ((threads gnus-newsgroup-threads)
3358 (setq sub (car threads))
3359 (if (stringp (car sub))
3360 ;; This is a gathered thread, so we look at the roots
3361 ;; below it to find whether this article is in this
3364 (setq sub (cdr sub))
3366 (when (member (caar sub) headers)
3367 (setq thread (car threads)
3370 (setq sub (cdr sub))))
3371 ;; It's an ordinary thread, so we check it.
3372 (when (eq (car sub) (car headers))
3375 (setq threads (cdr threads)))
3376 ;; If this article is in no thread, then it's a root.
3379 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3380 (setq thread (gnus-id-to-thread last-id)))
3383 thread ; We return this thread.
3385 (if (stringp (car thread))
3387 ;; If we use dummy roots, then we have to remove the
3388 ;; dummy root as well.
3389 (when (eq gnus-summary-make-false-root 'dummy)
3390 ;; We go to the dummy root by going to
3391 ;; the first sub-"thread", and then one line up.
3392 (gnus-summary-goto-article
3393 (mail-header-number (caadr thread)))
3396 (gnus-data-compute-positions))
3397 (setq thread (cdr thread))
3399 (gnus-remove-thread-1 (car thread))
3400 (setq thread (cdr thread))))
3401 (gnus-remove-thread-1 thread))))))))
3403 (defun gnus-remove-thread-1 (thread)
3404 "Remove the thread THREAD recursively."
3405 (let ((number (mail-header-number (pop thread)))
3407 (setq thread (reverse thread))
3409 (gnus-remove-thread-1 (pop thread)))
3410 (when (setq d (gnus-data-find number))
3411 (goto-char (gnus-data-pos d))
3414 (- (gnus-point-at-bol)
3416 (1+ (gnus-point-at-eol))
3417 (gnus-delete-line)))))))
3419 (defun gnus-sort-threads (threads)
3421 (if (not gnus-thread-sort-functions)
3423 (gnus-message 7 "Sorting threads...")
3425 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3426 (gnus-message 7 "Sorting threads...done"))))
3428 (defun gnus-sort-articles (articles)
3430 (when gnus-article-sort-functions
3431 (gnus-message 7 "Sorting articles...")
3433 (setq gnus-newsgroup-headers
3434 (sort articles (gnus-make-sort-function
3435 gnus-article-sort-functions)))
3436 (gnus-message 7 "Sorting articles...done"))))
3438 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3439 (defmacro gnus-thread-header (thread)
3440 ;; Return header of first article in THREAD.
3441 ;; Note that THREAD must never, ever be anything else than a variable -
3442 ;; using some other form will lead to serious barfage.
3443 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3444 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3445 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
3448 (defsubst gnus-article-sort-by-number (h1 h2)
3449 "Sort articles by article number."
3450 (< (mail-header-number h1)
3451 (mail-header-number h2)))
3453 (defun gnus-thread-sort-by-number (h1 h2)
3454 "Sort threads by root article number."
3455 (gnus-article-sort-by-number
3456 (gnus-thread-header h1) (gnus-thread-header h2)))
3458 (defsubst gnus-article-sort-by-lines (h1 h2)
3459 "Sort articles by article Lines header."
3460 (< (mail-header-lines h1)
3461 (mail-header-lines h2)))
3463 (defun gnus-thread-sort-by-lines (h1 h2)
3464 "Sort threads by root article Lines header."
3465 (gnus-article-sort-by-lines
3466 (gnus-thread-header h1) (gnus-thread-header h2)))
3468 (defsubst gnus-article-sort-by-author (h1 h2)
3469 "Sort articles by root author."
3471 (let ((extract (funcall
3472 gnus-extract-address-components
3473 (mail-header-from h1))))
3474 (or (car extract) (cadr extract) ""))
3475 (let ((extract (funcall
3476 gnus-extract-address-components
3477 (mail-header-from h2))))
3478 (or (car extract) (cadr extract) ""))))
3480 (defun gnus-thread-sort-by-author (h1 h2)
3481 "Sort threads by root author."
3482 (gnus-article-sort-by-author
3483 (gnus-thread-header h1) (gnus-thread-header h2)))
3485 (defsubst gnus-article-sort-by-subject (h1 h2)
3486 "Sort articles by root subject."
3488 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3489 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3491 (defun gnus-thread-sort-by-subject (h1 h2)
3492 "Sort threads by root subject."
3493 (gnus-article-sort-by-subject
3494 (gnus-thread-header h1) (gnus-thread-header h2)))
3496 (defsubst gnus-article-sort-by-date (h1 h2)
3497 "Sort articles by root article date."
3499 (gnus-date-get-time (mail-header-date h1))
3500 (gnus-date-get-time (mail-header-date h2))))
3502 (defun gnus-thread-sort-by-date (h1 h2)
3503 "Sort threads by root article date."
3504 (gnus-article-sort-by-date
3505 (gnus-thread-header h1) (gnus-thread-header h2)))
3507 (defsubst gnus-article-sort-by-score (h1 h2)
3508 "Sort articles by root article score.
3509 Unscored articles will be counted as having a score of zero."
3510 (> (or (cdr (assq (mail-header-number h1)
3511 gnus-newsgroup-scored))
3512 gnus-summary-default-score 0)
3513 (or (cdr (assq (mail-header-number h2)
3514 gnus-newsgroup-scored))
3515 gnus-summary-default-score 0)))
3517 (defun gnus-thread-sort-by-score (h1 h2)
3518 "Sort threads by root article score."
3519 (gnus-article-sort-by-score
3520 (gnus-thread-header h1) (gnus-thread-header h2)))
3522 (defun gnus-thread-sort-by-total-score (h1 h2)
3523 "Sort threads by the sum of all scores in the thread.
3524 Unscored articles will be counted as having a score of zero."
3525 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3527 (defun gnus-thread-total-score (thread)
3528 ;; This function find the total score of THREAD.
3529 (cond ((null thread)
3532 (if (stringp (car thread))
3533 (apply gnus-thread-score-function 0
3534 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3535 (gnus-thread-total-score-1 thread)))
3537 (gnus-thread-total-score-1 (list thread)))))
3539 (defun gnus-thread-total-score-1 (root)
3540 ;; This function find the total score of the thread below ROOT.
3541 (setq root (car root))
3542 (apply gnus-thread-score-function
3544 (mapcar 'gnus-thread-total-score
3545 (cdr (gnus-id-to-thread (mail-header-id root))))
3546 (when (> (mail-header-number root) 0)
3547 (list (or (cdr (assq (mail-header-number root)
3548 gnus-newsgroup-scored))
3549 gnus-summary-default-score 0))))
3550 (list gnus-summary-default-score)
3553 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3554 (defvar gnus-tmp-prev-subject nil)
3555 (defvar gnus-tmp-false-parent nil)
3556 (defvar gnus-tmp-root-expunged nil)
3557 (defvar gnus-tmp-dummy-line nil)
3559 (defun gnus-summary-prepare-threads (threads)
3560 "Prepare summary buffer from THREADS and indentation LEVEL.
3561 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3562 or a straight list of headers."
3563 (gnus-message 7 "Generating summary...")
3565 (setq gnus-newsgroup-threads threads)
3568 (let ((gnus-tmp-level 0)
3569 (default-score (or gnus-summary-default-score 0))
3570 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3571 thread number subject stack state gnus-tmp-gathered beg-match
3572 new-roots gnus-tmp-new-adopts thread-end
3573 gnus-tmp-header gnus-tmp-unread
3574 gnus-tmp-replied gnus-tmp-subject-or-nil
3575 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3576 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3577 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3579 (setq gnus-tmp-prev-subject nil)
3581 (if (vectorp (car threads))
3582 ;; If this is a straight (sic) list of headers, then a
3583 ;; threaded summary display isn't required, so we just create
3584 ;; an unthreaded one.
3585 (gnus-summary-prepare-unthreaded threads)
3587 ;; Do the threaded display.
3589 (while (or threads stack gnus-tmp-new-adopts new-roots)
3591 (if (and (= gnus-tmp-level 0)
3594 (not gnus-tmp-false-parent)
3595 (or gnus-tmp-new-adopts new-roots))
3596 (if gnus-tmp-new-adopts
3597 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3598 thread (list (car gnus-tmp-new-adopts))
3599 gnus-tmp-header (caar thread)
3600 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3602 (setq thread (list (car new-roots))
3603 gnus-tmp-header (caar thread)
3604 new-roots (cdr new-roots))))
3607 ;; If there are some threads, we do them before the
3608 ;; threads on the stack.
3609 (setq thread threads
3610 gnus-tmp-header (caar thread))
3611 ;; There were no current threads, so we pop something off
3613 (setq state (car stack)
3614 gnus-tmp-level (car state)
3617 gnus-tmp-header (caar thread))))
3619 (setq gnus-tmp-false-parent nil)
3620 (setq gnus-tmp-root-expunged nil)
3621 (setq thread-end nil)
3623 (if (stringp gnus-tmp-header)
3624 ;; The header is a dummy root.
3626 ((eq gnus-summary-make-false-root 'adopt)
3627 ;; We let the first article adopt the rest.
3628 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3630 (setq gnus-tmp-gathered
3632 (lambda (h) (mail-header-number (car h)))
3635 (setq thread (cons (list (caar thread)
3638 (setq gnus-tmp-level -1
3639 gnus-tmp-false-parent t))
3640 ((eq gnus-summary-make-false-root 'empty)
3641 ;; We print adopted articles with empty subject fields.
3642 (setq gnus-tmp-gathered
3644 (lambda (h) (mail-header-number (car h)))
3647 (setq gnus-tmp-level -1))
3648 ((eq gnus-summary-make-false-root 'dummy)
3649 ;; We remember that we probably want to output a dummy
3651 (setq gnus-tmp-dummy-line gnus-tmp-header)
3652 (setq gnus-tmp-prev-subject gnus-tmp-header))
3654 ;; We do not make a root for the gathered
3655 ;; sub-threads at all.
3656 (setq gnus-tmp-level -1)))
3658 (setq number (mail-header-number gnus-tmp-header)
3659 subject (mail-header-subject gnus-tmp-header))
3662 ;; If the thread has changed subject, we might want to make
3663 ;; this subthread into a root.
3664 ((and (null gnus-thread-ignore-subject)
3665 (not (zerop gnus-tmp-level))
3666 gnus-tmp-prev-subject
3668 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3669 (setq new-roots (nconc new-roots (list (car thread)))
3671 gnus-tmp-header nil))
3672 ;; If the article lies outside the current limit,
3673 ;; then we do not display it.
3674 ((not (memq number gnus-newsgroup-limit))
3675 (setq gnus-tmp-gathered
3677 (lambda (h) (mail-header-number (car h)))
3680 (setq gnus-tmp-new-adopts (if (cdar thread)
3681 (append gnus-tmp-new-adopts
3683 gnus-tmp-new-adopts)
3685 gnus-tmp-header nil)
3686 (when (zerop gnus-tmp-level)
3687 (setq gnus-tmp-root-expunged t)))
3688 ;; Perhaps this article is to be marked as read?
3689 ((and gnus-summary-mark-below
3690 (< (or (cdr (assq number gnus-newsgroup-scored))
3692 gnus-summary-mark-below)
3693 ;; Don't touch sparse articles.
3694 (not (gnus-summary-article-sparse-p number))
3695 (not (gnus-summary-article-ancient-p number)))
3696 (setq gnus-newsgroup-unreads
3697 (delq number gnus-newsgroup-unreads))
3698 (if gnus-newsgroup-auto-expire
3699 (push number gnus-newsgroup-expirable)
3700 (push (cons number gnus-low-score-mark)
3701 gnus-newsgroup-reads))))
3703 (when gnus-tmp-header
3704 ;; We may have an old dummy line to output before this
3706 (when (and gnus-tmp-dummy-line
3709 (mail-header-subject gnus-tmp-header)))
3710 (gnus-summary-insert-dummy-line
3711 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3712 (setq gnus-tmp-dummy-line nil))
3714 ;; Compute the mark.
3715 (setq gnus-tmp-unread (gnus-article-mark number))
3717 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3718 gnus-tmp-header gnus-tmp-level)
3719 gnus-newsgroup-data)
3721 ;; Actually insert the line.
3723 gnus-tmp-subject-or-nil
3725 ((and gnus-thread-ignore-subject
3726 gnus-tmp-prev-subject
3727 (not (inline (gnus-subject-equal
3728 gnus-tmp-prev-subject subject))))
3730 ((zerop gnus-tmp-level)
3731 (if (and (eq gnus-summary-make-false-root 'empty)
3732 (memq number gnus-tmp-gathered)
3733 gnus-tmp-prev-subject
3734 (inline (gnus-subject-equal
3735 gnus-tmp-prev-subject subject)))
3736 gnus-summary-same-subject
3738 (t gnus-summary-same-subject)))
3739 (if (and (eq gnus-summary-make-false-root 'adopt)
3740 (= gnus-tmp-level 1)
3741 (memq number gnus-tmp-gathered))
3742 (setq gnus-tmp-opening-bracket ?\<
3743 gnus-tmp-closing-bracket ?\>)
3744 (setq gnus-tmp-opening-bracket ?\[
3745 gnus-tmp-closing-bracket ?\]))
3747 gnus-tmp-indentation
3748 (aref gnus-thread-indent-array gnus-tmp-level)
3749 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3750 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3751 gnus-summary-default-score 0)
3753 (if (or (null gnus-summary-default-score)
3754 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3755 gnus-summary-zcore-fuzz))
3757 (if (< gnus-tmp-score gnus-summary-default-score)
3758 gnus-score-below-mark gnus-score-over-mark))
3760 (cond ((memq number gnus-newsgroup-processable)
3762 ((memq number gnus-newsgroup-cached)
3764 ((memq number gnus-newsgroup-replied)
3766 ((memq number gnus-newsgroup-saved)
3768 (t gnus-unread-mark))
3769 gnus-tmp-from (mail-header-from gnus-tmp-header)
3772 ((string-match "<[^>]+> *$" gnus-tmp-from)
3773 (setq beg-match (match-beginning 0))
3774 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3775 (substring gnus-tmp-from (1+ (match-beginning 0))
3776 (1- (match-end 0))))
3777 (substring gnus-tmp-from 0 beg-match)))
3778 ((string-match "(.+)" gnus-tmp-from)
3779 (substring gnus-tmp-from
3780 (1+ (match-beginning 0)) (1- (match-end 0))))
3782 (when (string= gnus-tmp-name "")
3783 (setq gnus-tmp-name gnus-tmp-from))
3784 (unless (numberp gnus-tmp-lines)
3785 (setq gnus-tmp-lines 0))
3786 (gnus-put-text-property-excluding-characters-with-faces
3788 (progn (eval gnus-summary-line-format-spec) (point))
3789 'gnus-number number)
3792 (gnus-run-hooks 'gnus-summary-update-hook)
3795 (setq gnus-tmp-prev-subject subject)))
3797 (when (nth 1 thread)
3798 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3799 (incf gnus-tmp-level)
3800 (setq threads (if thread-end nil (cdar thread)))
3802 (setq gnus-tmp-level 0)))))
3803 (gnus-message 7 "Generating summary...done"))
3805 (defun gnus-summary-prepare-unthreaded (headers)
3806 "Generate an unthreaded summary buffer based on HEADERS."
3807 (let (header number mark)
3812 ;; We may have to root out some bad articles...
3813 (when (memq (setq number (mail-header-number
3814 (setq header (pop headers))))
3815 gnus-newsgroup-limit)
3816 ;; Mark article as read when it has a low score.
3817 (when (and gnus-summary-mark-below
3818 (< (or (cdr (assq number gnus-newsgroup-scored))
3819 gnus-summary-default-score 0)
3820 gnus-summary-mark-below)
3821 (not (gnus-summary-article-ancient-p number)))
3822 (setq gnus-newsgroup-unreads
3823 (delq number gnus-newsgroup-unreads))
3824 (if gnus-newsgroup-auto-expire
3825 (push number gnus-newsgroup-expirable)
3826 (push (cons number gnus-low-score-mark)
3827 gnus-newsgroup-reads)))
3829 (setq mark (gnus-article-mark number))
3830 (push (gnus-data-make number mark (1+ (point)) header 0)
3831 gnus-newsgroup-data)
3832 (gnus-summary-insert-line
3834 mark (memq number gnus-newsgroup-replied)
3835 (memq number gnus-newsgroup-expirable)
3836 (mail-header-subject header) nil
3837 (cdr (assq number gnus-newsgroup-scored))
3838 (memq number gnus-newsgroup-processable))))))
3840 (defun gnus-select-newsgroup (group &optional read-all select-articles)
3841 "Select newsgroup GROUP.
3842 If READ-ALL is non-nil, all articles in the group are selected.
3843 If SELECT-ARTICLES, only select those articles from GROUP."
3844 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3845 ;;!!! Dirty hack; should be removed.
3846 (gnus-summary-ignore-duplicates
3847 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
3849 gnus-summary-ignore-duplicates))
3850 (info (nth 2 entry))
3851 articles fetched-articles cached)
3853 (unless (gnus-check-server
3854 (setq gnus-current-select-method
3855 (gnus-find-method-for-group group)))
3856 (error "Couldn't open server"))
3858 (or (and entry (not (eq (car entry) t))) ; Either it's active...
3859 (gnus-activate-group group) ; Or we can activate it...
3860 (progn ; Or we bug out.
3861 (when (equal major-mode 'gnus-summary-mode)
3862 (kill-buffer (current-buffer)))
3863 (error "Couldn't request group %s: %s"
3864 group (gnus-status-message group))))
3866 (unless (gnus-request-group group t)
3867 (when (equal major-mode 'gnus-summary-mode)
3868 (kill-buffer (current-buffer)))
3869 (error "Couldn't request group %s: %s"
3870 group (gnus-status-message group)))
3872 (setq gnus-newsgroup-name group)
3873 (setq gnus-newsgroup-unselected nil)
3874 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
3876 ;; Adjust and set lists of article marks.
3878 (gnus-adjust-marked-articles info))
3880 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3881 (when (gnus-virtual-group-p group)
3882 (setq cached gnus-newsgroup-cached))
3884 (setq gnus-newsgroup-unreads
3885 (gnus-set-difference
3886 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
3887 gnus-newsgroup-dormant))
3889 (setq gnus-newsgroup-processable nil)
3891 (gnus-update-read-articles group gnus-newsgroup-unreads)
3892 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
3893 (gnus-group-update-group group))
3895 (setq articles (or select-articles (gnus-articles-to-read group read-all)))
3899 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
3901 ((eq articles 0) nil)
3903 ;; Init the dependencies hash table.
3904 (setq gnus-newsgroup-dependencies
3905 (gnus-make-hashtable (length articles)))
3906 ;; Retrieve the headers and read them in.
3907 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
3908 (setq gnus-newsgroup-headers
3910 (setq gnus-headers-retrieved-by
3911 (gnus-retrieve-headers
3912 articles gnus-newsgroup-name
3913 ;; We might want to fetch old headers, but
3914 ;; not if there is only 1 article.
3916 (not (eq gnus-fetch-old-headers 'some))
3917 (not (numberp gnus-fetch-old-headers)))
3918 (> (length articles) 1))
3919 gnus-fetch-old-headers))))
3920 (gnus-get-newsgroup-headers-xover
3921 articles nil nil gnus-newsgroup-name t)
3922 (gnus-get-newsgroup-headers)))
3923 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
3925 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3927 (setq gnus-newsgroup-cached cached))
3929 ;; Suppress duplicates?
3930 (when gnus-suppress-duplicates
3931 (gnus-dup-suppress-articles))
3933 ;; Set the initial limit.
3934 (setq gnus-newsgroup-limit (copy-sequence articles))
3935 ;; Remove canceled articles from the list of unread articles.
3936 (setq gnus-newsgroup-unreads
3937 (gnus-set-sorted-intersection
3938 gnus-newsgroup-unreads
3939 (setq fetched-articles
3940 (mapcar (lambda (headers) (mail-header-number headers))
3941 gnus-newsgroup-headers))))
3942 ;; Removed marked articles that do not exist.
3943 (gnus-update-missing-marks
3944 (gnus-sorted-complement fetched-articles articles))
3945 ;; We might want to build some more threads first.
3946 (when (and gnus-fetch-old-headers
3947 (eq gnus-headers-retrieved-by 'nov))
3948 (if (eq gnus-fetch-old-headers 'invisible)
3949 (gnus-build-all-threads)
3950 (gnus-build-old-threads)))
3951 ;; Let the Gnus agent mark articles as read.
3953 (gnus-agent-get-undownloaded-list))
3954 ;; Check whether auto-expire is to be done in this group.
3955 (setq gnus-newsgroup-auto-expire
3956 (gnus-group-auto-expirable-p group))
3957 ;; Set up the article buffer now, if necessary.
3958 (unless gnus-single-article-buffer
3959 (gnus-article-setup-buffer))
3960 ;; First and last article in this newsgroup.
3961 (when gnus-newsgroup-headers
3962 (setq gnus-newsgroup-begin
3963 (mail-header-number (car gnus-newsgroup-headers))
3966 (gnus-last-element gnus-newsgroup-headers))))
3967 ;; GROUP is successfully selected.
3968 (or gnus-newsgroup-headers t)))))
3970 (defun gnus-articles-to-read (group &optional read-all)
3971 ;; Find out what articles the user wants to read.
3973 ;; Select all articles if `read-all' is non-nil, or if there
3974 ;; are no unread articles.
3976 (and (zerop (length gnus-newsgroup-marked))
3977 (zerop (length gnus-newsgroup-unreads)))
3978 (eq (gnus-group-find-parameter group 'display)
3980 (gnus-uncompress-range (gnus-active group))
3981 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
3982 (copy-sequence gnus-newsgroup-unreads))
3984 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
3985 (scored (length scored-list))
3986 (number (length articles))
3987 (marked (+ (length gnus-newsgroup-marked)
3988 (length gnus-newsgroup-dormant)))
3996 ((and (or (<= scored marked) (= scored number))
3997 (numberp gnus-large-newsgroup)
3998 (> number gnus-large-newsgroup))
4002 "How many articles from %s (default %d): "
4003 (gnus-limit-string gnus-newsgroup-name 35)
4005 (if (string-match "^[ \t]*$" input) number input)))
4006 ((and (> scored marked) (< scored number)
4007 (> (- scored number) 20))
4010 (format "%s %s (%d scored, %d total): "
4011 "How many articles from"
4012 group scored number))))
4013 (if (string-match "^[ \t]*$" input)
4017 (setq select (if (stringp select) (string-to-number select) select))
4018 (if (or (null select) (zerop select))
4020 (if (and (not (zerop scored)) (<= (abs select) scored))
4022 (setq articles (sort scored-list '<))
4023 (setq number (length articles)))
4024 (setq articles (copy-sequence articles)))
4026 (when (< (abs select) number)
4028 ;; Select the N oldest articles.
4029 (setcdr (nthcdr (1- (abs select)) articles) nil)
4030 ;; Select the N most recent articles.
4031 (setq articles (nthcdr (- number select) articles))))
4032 (setq gnus-newsgroup-unselected
4033 (gnus-sorted-intersection
4034 gnus-newsgroup-unreads
4035 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4038 (defun gnus-killed-articles (killed articles)
4041 (when (inline (gnus-member-of-range (car articles) killed))
4042 (push (car articles) out))
4043 (setq articles (cdr articles)))
4046 (defun gnus-uncompress-marks (marks)
4047 "Uncompress the mark ranges in MARKS."
4048 (let ((uncompressed '(score bookmark))
4051 (if (memq (caar marks) uncompressed)
4052 (push (car marks) out)
4053 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4054 (setq marks (cdr marks)))
4057 (defun gnus-adjust-marked-articles (info)
4058 "Set all article lists and remove all marks that are no longer legal."
4059 (let* ((marked-lists (gnus-info-marks info))
4060 (active (gnus-active (gnus-info-group info)))
4063 (types gnus-article-mark-lists)
4064 (uncompressed '(score bookmark killed))
4065 marks var articles article mark)
4068 (setq marks (pop marked-lists))
4069 (set (setq var (intern (format "gnus-newsgroup-%s"
4070 (car (rassq (setq mark (car marks))
4072 (if (memq (car marks) uncompressed) (cdr marks)
4073 (gnus-uncompress-range (cdr marks))))
4075 (setq articles (symbol-value var))
4077 ;; All articles have to be subsets of the active articles.
4079 ;; Adjust "simple" lists.
4080 ((memq mark '(tick dormant expire reply save))
4082 (when (or (< (setq article (pop articles)) min) (> article max))
4083 (set var (delq article (symbol-value var))))))
4085 ((memq mark uncompressed)
4086 (when (not (listp (cdr (symbol-value var))))
4087 (set var (list (symbol-value var))))
4088 (when (not (listp (cdr articles)))
4089 (setq articles (list articles)))
4091 (when (or (not (consp (setq article (pop articles))))
4092 (< (car article) min)
4093 (> (car article) max))
4094 (set var (delq article (symbol-value var))))))))))
4096 (defun gnus-update-missing-marks (missing)
4097 "Go through the list of MISSING articles and remove them from the mark lists."
4099 (let ((types gnus-article-mark-lists)
4101 ;; Go through all types.
4103 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4104 (when (symbol-value var)
4105 ;; This list has articles. So we delete all missing articles
4109 (set var (delq (pop m) (symbol-value var)))))))))
4111 (defun gnus-update-marks ()
4112 "Enter the various lists of marked articles into the newsgroup info list."
4113 (let ((types gnus-article-mark-lists)
4114 (info (gnus-get-info gnus-newsgroup-name))
4115 (uncompressed '(score bookmark killed))
4116 type list newmarked symbol)
4118 ;; Add all marks lists that are non-nil to the list of marks lists.
4119 (while (setq type (pop types))
4120 (when (setq list (symbol-value
4122 (intern (format "gnus-newsgroup-%s"
4125 ;; Get rid of the entries of the articles that have the
4127 (when (and (eq (cdr type) 'score)
4131 (prev (cons nil list))
4134 (if (or (not (consp (car arts)))
4135 (= (cdar arts) gnus-summary-default-score))
4136 (setcdr prev (cdr arts))
4138 (setq arts (cdr arts)))
4139 (setq list (cdr all))))
4141 (push (cons (cdr type)
4142 (if (memq (cdr type) uncompressed) list
4143 (gnus-compress-sequence
4144 (set symbol (sort list '<)) t)))
4147 ;; Enter these new marks into the info of the group.
4149 (setcar (nthcdr 3 info) newmarked)
4150 ;; Add the marks lists to the end of the info.
4152 (setcdr (nthcdr 2 info) (list newmarked))))
4154 ;; Cut off the end of the info if there's nothing else there.
4158 (when (nthcdr (decf i) info)
4159 (setcdr (nthcdr i info) nil)))))))
4161 (defun gnus-set-mode-line (where)
4162 "This function sets the mode line of the article or summary buffers.
4163 If WHERE is `summary', the summary mode line format will be used."
4164 ;; Is this mode line one we keep updated?
4165 (when (memq where gnus-updated-mode-lines)
4168 ;; We evaluate this in the summary buffer since these
4169 ;; variables are buffer-local to that buffer.
4170 (set-buffer gnus-summary-buffer)
4171 ;; We bind all these variables that are used in the `eval' form
4173 (let* ((mformat (symbol-value
4175 (format "gnus-%s-mode-line-format-spec" where))))
4176 (gnus-tmp-group-name gnus-newsgroup-name)
4177 (gnus-tmp-article-number (or gnus-current-article 0))
4178 (gnus-tmp-unread gnus-newsgroup-unreads)
4179 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4180 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4181 (gnus-tmp-unread-and-unselected
4182 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4183 (zerop gnus-tmp-unselected))
4185 ((zerop gnus-tmp-unselected)
4186 (format "{%d more}" gnus-tmp-unread-and-unticked))
4187 (t (format "{%d(+%d) more}"
4188 gnus-tmp-unread-and-unticked
4189 gnus-tmp-unselected))))
4191 (if (and gnus-current-headers
4192 (vectorp gnus-current-headers))
4193 (gnus-mode-string-quote
4194 (mail-header-subject gnus-current-headers))
4196 bufname-length max-len
4197 gnus-tmp-header);; passed as argument to any user-format-funcs
4198 (setq mode-string (eval mformat))
4199 (setq bufname-length (if (string-match "%b" mode-string)
4202 (if (eq where 'summary)
4204 (get-buffer gnus-article-buffer))))
4207 (setq max-len (max 4 (if gnus-mode-non-string-length
4209 gnus-mode-non-string-length
4211 (length mode-string))))
4212 ;; We might have to chop a bit of the string off...
4213 (when (> (length mode-string) max-len)
4215 (concat (gnus-truncate-string mode-string (- max-len 3))
4217 ;; Pad the mode string a bit.
4218 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4219 ;; Update the mode line.
4220 (setq mode-line-buffer-identification
4221 (gnus-mode-line-buffer-identification (list mode-string)))
4222 (set-buffer-modified-p t))))
4224 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4225 "Go through the HEADERS list and add all Xrefs to a hash table.
4226 The resulting hash table is returned, or nil if no Xrefs were found."
4227 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4228 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4229 (xref-hashtb (gnus-make-hashtable))
4230 start group entry number xrefs header)
4232 (setq header (pop headers))
4233 (when (and (setq xrefs (mail-header-xref header))
4234 (not (memq (setq number (mail-header-number header))
4237 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4238 (setq start (match-end 0))
4239 (setq group (if prefix
4240 (concat prefix (substring xrefs (match-beginning 1)
4242 (substring xrefs (match-beginning 1) (match-end 1))))
4244 (string-to-int (substring xrefs (match-beginning 2)
4246 (if (setq entry (gnus-gethash group xref-hashtb))
4247 (setcdr entry (cons number (cdr entry)))
4248 (gnus-sethash group (cons number nil) xref-hashtb)))))
4249 (and start xref-hashtb)))
4251 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4252 "Look through all the headers and mark the Xrefs as read."
4253 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4254 name entry info xref-hashtb idlist method nth4)
4256 (set-buffer gnus-group-buffer)
4257 (when (setq xref-hashtb
4258 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4261 (unless (string= from-newsgroup (setq name (symbol-name group)))
4262 (setq idlist (symbol-value group))
4263 ;; Dead groups are not updated.
4265 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4267 (when (stringp (setq nth4 (gnus-info-method info)))
4268 (setq nth4 (gnus-server-to-method nth4))))
4269 ;; Only do the xrefs if the group has the same
4270 ;; select method as the group we have just read.
4271 (or (gnus-methods-equal-p
4272 nth4 (gnus-find-method-for-group from-newsgroup))
4274 (equal nth4 (setq method (gnus-find-method-for-group
4276 (and (equal (car nth4) (car method))
4277 (equal (nth 1 nth4) (nth 1 method))))
4278 gnus-use-cross-reference
4279 (or (not (eq gnus-use-cross-reference t))
4281 ;; Only do cross-references on subscribed
4282 ;; groups, if that is what is wanted.
4283 (<= (gnus-info-level info) gnus-level-subscribed))
4284 (gnus-group-make-articles-read name idlist))))
4287 (defun gnus-compute-read-articles (group articles)
4288 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4289 (info (nth 2 entry))
4290 (active (gnus-active group))
4293 ;; First peel off all illegal article numbers.
4295 (let ((ids articles)
4297 (while (setq id (pop ids))
4298 (when (and first (> id (cdr active)))
4299 ;; We'll end up in this situation in one particular
4300 ;; obscure situation. If you re-scan a group and get
4301 ;; a new article that is cross-posted to a different
4302 ;; group that has not been re-scanned, you might get
4303 ;; crossposted article that has a higher number than
4304 ;; Gnus believes possible. So we re-activate this
4305 ;; group as well. This might mean doing the
4306 ;; crossposting thingy will *increase* the number
4307 ;; of articles in some groups. Tsk, tsk.
4308 (setq active (or (gnus-activate-group group) active)))
4309 (when (or (> id (cdr active))
4310 (< id (car active)))
4311 (setq articles (delq id articles))))))
4312 ;; If the read list is nil, we init it.
4314 (null (gnus-info-read info))
4316 (setq ninfo (cons 1 (1- (car active))))
4317 (setq ninfo (gnus-info-read info)))
4318 ;; Then we add the read articles to the range.
4320 ninfo (setq articles (sort articles '<))))))
4322 (defun gnus-group-make-articles-read (group articles)
4323 "Update the info of GROUP to say that ARTICLES are read."
4325 (entry (gnus-gethash group gnus-newsrc-hashtb))
4326 (info (nth 2 entry))
4327 (active (gnus-active group))
4330 (setq range (gnus-compute-read-articles group articles))
4332 (set-buffer gnus-group-buffer)
4335 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4336 (gnus-info-set-read ',info ',(gnus-info-read info))
4337 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4338 (gnus-group-update-group ,group t))))
4339 ;; Add the read articles to the range.
4340 (gnus-info-set-read info range)
4341 ;; Then we have to re-compute how many unread
4342 ;; articles there are in this group.
4346 (setq num (- (1+ (cdr active)) (car active))))
4347 ((not (listp (cdr range)))
4348 (setq num (- (cdr active) (- (1+ (cdr range))
4352 (if (numberp (car range))
4354 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4355 (setq range (cdr range)))
4356 (setq num (- (cdr active) num))))
4357 ;; Update the number of unread articles.
4359 ;; Update the group buffer.
4360 (gnus-group-update-group group t)))))
4362 (defun gnus-methods-equal-p (m1 m2)
4363 (let ((m1 (or m1 gnus-select-method))
4364 (m2 (or m2 gnus-select-method)))
4366 (and (eq (car m1) (car m2))
4367 (or (not (memq 'address (assoc (symbol-name (car m1))
4368 gnus-valid-select-methods)))
4369 (equal (nth 1 m1) (nth 1 m2)))))))
4371 (defvar gnus-newsgroup-none-id 0)
4373 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4374 (let ((cur nntp-server-buffer)
4377 (save-excursion (set-buffer gnus-summary-buffer)
4378 gnus-newsgroup-dependencies)))
4379 headers id id-dep ref-dep end ref)
4381 (set-buffer nntp-server-buffer)
4382 ;; Translate all TAB characters into SPACE characters.
4383 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4384 (gnus-run-hooks 'gnus-parse-headers-hook)
4385 (let ((case-fold-search t)
4387 in-reply-to header p lines chars)
4388 (goto-char (point-min))
4389 ;; Search to the beginning of the next header. Error messages
4390 ;; do not begin with 2 or 3.
4391 (while (re-search-forward "^[23][0-9]+ " nil t)
4394 ;; This implementation of this function, with nine
4395 ;; search-forwards instead of the one re-search-forward and
4396 ;; a case (which basically was the old function) is actually
4397 ;; about twice as fast, even though it looks messier. You
4398 ;; can't have everything, I guess. Speed and elegance
4399 ;; doesn't always go hand in hand.
4408 (narrow-to-region (point)
4409 (or (and (search-forward "\n.\n" nil t)
4415 (if (search-forward "\nsubject: " nil t)
4417 (setq rawtext (nnheader-header-value)
4419 gnus-unstructured-field-decoder rawtext))
4420 (if (string-equal rawtext decoded)
4422 (put-text-property 0 (length decoded) 'raw-text rawtext decoded)
4428 (if (search-forward "\nfrom: " nil t)
4430 (setq rawtext (nnheader-header-value)
4432 gnus-structured-field-decoder rawtext))
4433 (if (string-equal rawtext decoded)
4435 (put-text-property 0 (length decoded) 'raw-text rawtext decoded)
4441 (if (search-forward "\ndate: " nil t)
4442 (nnheader-header-value) ""))
4446 (setq id (if (re-search-forward
4447 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4448 ;; We do it this way to make sure the Message-ID
4449 ;; is (somewhat) syntactically valid.
4450 (buffer-substring (match-beginning 1)
4452 ;; If there was no message-id, we just fake one
4453 ;; to make subsequent routines simpler.
4454 (nnheader-generate-fake-message-id))))
4458 (if (search-forward "\nreferences: " nil t)
4462 (nnheader-header-value)
4467 (search-backward ">" end t)
4470 (search-backward "<" end t)
4472 ;; Get the references from the in-reply-to header if there
4473 ;; were no references and the in-reply-to header looks
4475 (if (and (search-forward "\nin-reply-to: " nil t)
4476 (setq in-reply-to (nnheader-header-value))
4477 (string-match "<[^>]+>" in-reply-to))
4479 (setq ref (substring in-reply-to (match-beginning 0)
4481 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4482 (setq ref2 (substring in-reply-to (match-beginning 0)
4484 (when (> (length ref2) (length ref))
4490 (if (search-forward "\nchars: " nil t)
4491 (if (numberp (setq chars (ignore-errors (read cur))))
4497 (if (search-forward "\nlines: " nil t)
4498 (if (numberp (setq lines (ignore-errors (read cur))))
4504 (and (search-forward "\nxref: " nil t)
4505 (nnheader-header-value)))))
4506 (when (equal id ref)
4509 (when gnus-alter-header-function
4510 (funcall gnus-alter-header-function header)
4511 (setq id (mail-header-id header)
4512 ref (gnus-parent-id (mail-header-references header))))
4515 (gnus-dependencies-add-header
4516 header dependencies force-new))
4517 (push header headers))
4518 (goto-char (point-max))
4520 (nreverse headers)))))
4522 ;; Goes through the xover lines and returns a list of vectors
4523 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4524 force-new dependencies
4525 group also-fetch-heads)
4526 "Parse the news overview data in the server buffer, and return a
4527 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4528 ;; Get the Xref when the users reads the articles since most/some
4529 ;; NNTP servers do not include Xrefs when using XOVER.
4530 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4531 (let ((cur nntp-server-buffer)
4532 (dependencies (or dependencies gnus-newsgroup-dependencies))
4533 number headers header)
4535 (set-buffer nntp-server-buffer)
4536 ;; Allow the user to mangle the headers before parsing them.
4537 (gnus-run-hooks 'gnus-parse-headers-hook)
4538 (goto-char (point-min))
4541 (while (and sequence (not (eobp)))
4542 (setq number (read cur))
4543 (while (and sequence
4544 (< (car sequence) number))
4545 (setq sequence (cdr sequence)))
4547 (eq number (car sequence))
4549 (setq sequence (cdr sequence))
4550 (setq header (inline
4551 (gnus-nov-parse-line
4552 number dependencies force-new))))
4553 (push header headers))
4556 (gnus-error 4 "Strange nov line (%d)"
4557 (count-lines (point-min) (point)))))
4559 ;; A common bug in inn is that if you have posted an article and
4560 ;; then retrieves the active file, it will answer correctly --
4561 ;; the new article is included. However, a NOV entry for the
4562 ;; article may not have been generated yet, so this may fail.
4563 ;; We work around this problem by retrieving the last few
4564 ;; headers using HEAD.
4565 (if (or (not also-fetch-heads)
4567 ;; We (probably) got all the headers.
4569 (let ((gnus-nov-is-evil t))
4572 (when (gnus-retrieve-headers sequence group)
4573 (gnus-get-newsgroup-headers))))))))
4575 (defun gnus-article-get-xrefs ()
4576 "Fill in the Xref value in `gnus-current-headers', if necessary.
4577 This is meant to be called in `gnus-article-internal-prepare-hook'."
4578 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4579 gnus-current-headers)))
4580 (or (not gnus-use-cross-reference)
4582 (and (mail-header-xref headers)
4583 (not (string= (mail-header-xref headers) "")))
4584 (let ((case-fold-search t)
4587 (nnheader-narrow-to-headers)
4588 (goto-char (point-min))
4589 (when (or (and (eq (downcase (following-char)) ?x)
4590 (looking-at "Xref:"))
4591 (search-forward "\nXref:" nil t))
4592 (goto-char (1+ (match-end 0)))
4593 (setq xref (buffer-substring (point)
4594 (progn (end-of-line) (point))))
4595 (mail-header-set-xref headers xref)))))))
4597 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4598 "Find article ID and insert the summary line for that article.
4599 OLD-HEADER can either be a header or a line number to insert
4600 the subject line on."
4601 (let* ((line (and (numberp old-header) old-header))
4602 (old-header (and (vectorp old-header) old-header))
4603 (header (cond ((and old-header use-old-header)
4606 (gnus-number-to-header id))
4607 (gnus-number-to-header id))
4609 (gnus-read-header id))))
4610 (number (and (numberp id) id))
4613 ;; Rebuild the thread that this article is part of and go to the
4614 ;; article we have fetched.
4615 (when (and (not gnus-show-threads)
4618 (setq d (gnus-data-find (mail-header-number old-header))))
4619 (goto-char (gnus-data-pos d))
4622 (- (gnus-point-at-bol)
4624 (1+ (gnus-point-at-eol))
4625 (gnus-delete-line))))))
4627 (mail-header-set-number header (mail-header-number old-header)))
4628 (setq gnus-newsgroup-sparse
4629 (delq (setq number (mail-header-number header))
4630 gnus-newsgroup-sparse))
4631 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4632 (push number gnus-newsgroup-limit)
4633 (gnus-rebuild-thread (mail-header-id header) line)
4634 (gnus-summary-goto-subject number nil t))
4635 (when (and (numberp number)
4637 ;; We have to update the boundaries even if we can't fetch the
4638 ;; article if ID is a number -- so that the next `P' or `N'
4639 ;; command will fetch the previous (or next) article even
4640 ;; if the one we tried to fetch this time has been canceled.
4641 (when (> number gnus-newsgroup-end)
4642 (setq gnus-newsgroup-end number))
4643 (when (< number gnus-newsgroup-begin)
4644 (setq gnus-newsgroup-begin number))
4645 (setq gnus-newsgroup-unselected
4646 (delq number gnus-newsgroup-unselected)))
4647 ;; Report back a success?
4648 (and header (mail-header-number header))))
4650 ;;; Process/prefix in the summary buffer
4652 (defun gnus-summary-work-articles (n)
4653 "Return a list of articles to be worked upon.
4654 The prefix argument, the list of process marked articles, and the
4655 current article will be taken into consideration."
4657 (set-buffer gnus-summary-buffer)
4660 ;; A numerical prefix has been given.
4661 (setq n (prefix-numeric-value n))
4662 (let ((backward (< n 0))
4663 (n (abs (prefix-numeric-value n)))
4668 (push (setq article (gnus-summary-article-number))
4671 (gnus-summary-find-prev nil article)
4672 (gnus-summary-find-next nil article)))
4674 (nreverse articles)))
4675 ((and (gnus-region-active-p) (mark))
4676 (message "region active")
4677 ;; Work on the region between point and mark.
4678 (let ((max (max (point) (mark)))
4681 (goto-char (min (point) (mark)))
4684 (push (setq article (gnus-summary-article-number)) articles)
4685 (gnus-summary-find-next nil article)
4687 (nreverse articles))))
4688 (gnus-newsgroup-processable
4689 ;; There are process-marked articles present.
4690 ;; Save current state.
4691 (gnus-summary-save-process-mark)
4693 (reverse gnus-newsgroup-processable))
4695 ;; Just return the current article.
4696 (list (gnus-summary-article-number))))))
4698 (defmacro gnus-summary-iterate (arg &rest forms)
4699 "Iterate over the process/prefixed articles and do FORMS.
4700 ARG is the interactive prefix given to the command. FORMS will be
4701 executed with point over the summary line of the articles."
4702 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
4703 `(let ((,articles (gnus-summary-work-articles ,arg)))
4705 (gnus-summary-goto-subject (car ,articles))
4708 (put 'gnus-summary-iterate 'lisp-indent-function 1)
4709 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
4711 (defun gnus-summary-save-process-mark ()
4712 "Push the current set of process marked articles on the stack."
4714 (push (copy-sequence gnus-newsgroup-processable)
4715 gnus-newsgroup-process-stack))
4717 (defun gnus-summary-kill-process-mark ()
4718 "Push the current set of process marked articles on the stack and unmark."
4720 (gnus-summary-save-process-mark)
4721 (gnus-summary-unmark-all-processable))
4723 (defun gnus-summary-yank-process-mark ()
4724 "Pop the last process mark state off the stack and restore it."
4726 (unless gnus-newsgroup-process-stack
4727 (error "Empty mark stack"))
4728 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4730 (defun gnus-summary-process-mark-set (set)
4731 "Make SET into the current process marked articles."
4732 (gnus-summary-unmark-all-processable)
4734 (gnus-summary-set-process-mark (pop set))))
4736 ;;; Searching and stuff
4738 (defun gnus-summary-search-group (&optional backward use-level)
4739 "Search for next unread newsgroup.
4740 If optional argument BACKWARD is non-nil, search backward instead."
4742 (set-buffer gnus-group-buffer)
4743 (when (gnus-group-search-forward
4744 backward nil (if use-level (gnus-group-group-level) nil))
4745 (gnus-group-group-name))))
4747 (defun gnus-summary-best-group (&optional exclude-group)
4748 "Find the name of the best unread group.
4749 If EXCLUDE-GROUP, do not go to this group."
4751 (set-buffer gnus-group-buffer)
4753 (gnus-group-best-unread-group exclude-group))))
4755 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
4756 (if backward (gnus-summary-find-prev)
4757 (let* ((dummy (gnus-summary-article-intangible-p))
4758 (article (or article (gnus-summary-article-number)))
4759 (arts (gnus-data-find-list article))
4761 (when (and (not dummy)
4762 (or (not gnus-summary-check-current)
4764 (not (gnus-data-unread-p (car arts)))))
4765 (setq arts (cdr arts)))
4770 (when (or (and undownloaded
4771 (eq gnus-undownloaded-mark
4772 (gnus-data-mark (car arts))))
4773 (gnus-data-unread-p (car arts)))
4774 (setq result (car arts)
4776 (setq arts (cdr arts)))
4779 (goto-char (gnus-data-pos result))
4780 (gnus-data-number result)))))
4782 (defun gnus-summary-find-prev (&optional unread article)
4783 (let* ((eobp (eobp))
4784 (article (or article (gnus-summary-article-number)))
4785 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
4787 (when (and (not eobp)
4788 (or (not gnus-summary-check-current)
4790 (not (gnus-data-unread-p (car arts)))))
4791 (setq arts (cdr arts)))
4796 (when (gnus-data-unread-p (car arts))
4797 (setq result (car arts)
4799 (setq arts (cdr arts)))
4802 (goto-char (gnus-data-pos result))
4803 (gnus-data-number result))))
4805 (defun gnus-summary-find-subject (subject &optional unread backward article)
4806 (let* ((simp-subject (gnus-simplify-subject-fully subject))
4807 (article (or article (gnus-summary-article-number)))
4808 (articles (gnus-data-list backward))
4809 (arts (gnus-data-find-list article articles))
4811 (when (or (not gnus-summary-check-current)
4813 (not (gnus-data-unread-p (car arts))))
4814 (setq arts (cdr arts)))
4816 (and (or (not unread)
4817 (gnus-data-unread-p (car arts)))
4818 (vectorp (gnus-data-header (car arts)))
4820 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
4821 (setq result (car arts)
4823 (setq arts (cdr arts)))
4825 (goto-char (gnus-data-pos result))
4826 (gnus-data-number result))))
4828 (defun gnus-summary-search-forward (&optional unread subject backward)
4829 "Search forward for an article.
4830 If UNREAD, look for unread articles. If SUBJECT, look for
4831 articles with that subject. If BACKWARD, search backward instead."
4832 (cond (subject (gnus-summary-find-subject subject unread backward))
4833 (backward (gnus-summary-find-prev unread))
4834 (t (gnus-summary-find-next unread))))
4836 (defun gnus-recenter (&optional n)
4837 "Center point in window and redisplay frame.
4838 Also do horizontal recentering."
4840 (when (and gnus-auto-center-summary
4841 (not (eq gnus-auto-center-summary 'vertical)))
4842 (gnus-horizontal-recenter))
4845 (defun gnus-summary-recenter ()
4846 "Center point in the summary window.
4847 If `gnus-auto-center-summary' is nil, or the article buffer isn't
4848 displayed, no centering will be performed."
4849 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
4850 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
4851 (let* ((top (cond ((< (window-height) 4) 0)
4852 ((< (window-height) 7) 1)
4854 (height (1- (window-height)))
4855 (bottom (save-excursion (goto-char (point-max))
4856 (forward-line (- height))
4858 (window (get-buffer-window (current-buffer))))
4859 ;; The user has to want it.
4860 (when gnus-auto-center-summary
4861 (when (get-buffer-window gnus-article-buffer)
4862 ;; Only do recentering when the article buffer is displayed,
4863 ;; Set the window start to either `bottom', which is the biggest
4864 ;; possible valid number, or the second line from the top,
4865 ;; whichever is the least.
4867 window (min bottom (save-excursion
4868 (forward-line (- top)) (point)))))
4869 ;; Do horizontal recentering while we're at it.
4870 (when (and (get-buffer-window (current-buffer) t)
4871 (not (eq gnus-auto-center-summary 'vertical)))
4872 (let ((selected (selected-window)))
4873 (select-window (get-buffer-window (current-buffer) t))
4874 (gnus-summary-position-point)
4875 (gnus-horizontal-recenter)
4876 (select-window selected))))))
4878 (defun gnus-summary-jump-to-group (newsgroup)
4879 "Move point to NEWSGROUP in group mode buffer."
4880 ;; Keep update point of group mode buffer if visible.
4881 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
4882 (save-window-excursion
4883 ;; Take care of tree window mode.
4884 (when (get-buffer-window gnus-group-buffer)
4885 (pop-to-buffer gnus-group-buffer))
4886 (gnus-group-jump-to-group newsgroup))
4888 ;; Take care of tree window mode.
4889 (if (get-buffer-window gnus-group-buffer)
4890 (pop-to-buffer gnus-group-buffer)
4891 (set-buffer gnus-group-buffer))
4892 (gnus-group-jump-to-group newsgroup))))
4894 ;; This function returns a list of article numbers based on the
4895 ;; difference between the ranges of read articles in this group and
4896 ;; the range of active articles.
4897 (defun gnus-list-of-unread-articles (group)
4898 (let* ((read (gnus-info-read (gnus-get-info group)))
4899 (active (or (gnus-active group) (gnus-activate-group group)))
4902 ;; If none are read, then all are unread.
4904 (setq first (car active))
4905 ;; If the range of read articles is a single range, then the
4906 ;; first unread article is the article after the last read
4907 ;; article. Sounds logical, doesn't it?
4908 (if (not (listp (cdr read)))
4909 (setq first (max (car active) (1+ (cdr read))))
4910 ;; `read' is a list of ranges.
4911 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
4914 (setq first (car active)))
4917 (while (< first nlast)
4919 (setq first (1+ first))))
4920 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
4921 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
4922 (setq read (cdr read)))))
4923 ;; And add the last unread articles.
4924 (while (<= first last)
4926 (setq first (1+ first)))
4927 ;; Return the list of unread articles.
4928 (delq 0 (nreverse unread))))
4930 (defun gnus-list-of-read-articles (group)
4931 "Return a list of unread, unticked and non-dormant articles."
4932 (let* ((info (gnus-get-info group))
4933 (marked (gnus-info-marks info))
4934 (active (gnus-active group)))
4936 (gnus-set-difference
4937 (gnus-sorted-complement
4938 (gnus-uncompress-range active)
4939 (gnus-list-of-unread-articles group))
4941 (gnus-uncompress-range (cdr (assq 'dormant marked)))
4942 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
4944 ;; Various summary commands
4946 (defun gnus-summary-select-article-buffer ()
4947 "Reconfigure windows to show article buffer."
4949 (if (not (gnus-buffer-live-p gnus-article-buffer))
4950 (error "There is no article buffer for this summary buffer")
4951 (gnus-configure-windows 'article)
4952 (select-window (get-buffer-window gnus-article-buffer))))
4954 (defun gnus-summary-universal-argument (arg)
4955 "Perform any operation on all articles that are process/prefixed."
4957 (let ((articles (gnus-summary-work-articles arg))
4964 (substitute-command-keys
4965 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
4968 (gnus-error 1 "Undefined key")
4971 (gnus-summary-goto-subject (setq article (pop articles)))
4972 (let (gnus-newsgroup-processable)
4973 (command-execute func))
4974 (gnus-summary-remove-process-mark article)))))
4975 (gnus-summary-position-point))
4977 (defun gnus-summary-toggle-truncation (&optional arg)
4978 "Toggle truncation of summary lines.
4979 With arg, turn line truncation on iff arg is positive."
4981 (setq truncate-lines
4982 (if (null arg) (not truncate-lines)
4983 (> (prefix-numeric-value arg) 0)))
4986 (defun gnus-summary-reselect-current-group (&optional all rescan)
4987 "Exit and then reselect the current newsgroup.
4988 The prefix argument ALL means to select all articles."
4990 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
4991 (error "Ephemeral groups can't be reselected"))
4992 (let ((current-subject (gnus-summary-article-number))
4993 (group gnus-newsgroup-name))
4994 (setq gnus-newsgroup-begin nil)
4996 ;; We have to adjust the point of group mode buffer because
4997 ;; point was moved to the next unread newsgroup by exiting.
4998 (gnus-summary-jump-to-group group)
5001 (gnus-group-get-new-news-this-group 1)))
5002 (gnus-group-read-group all t)
5003 (gnus-summary-goto-subject current-subject nil t)))
5005 (defun gnus-summary-rescan-group (&optional all)
5006 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5008 (gnus-summary-reselect-current-group all t))
5010 (defun gnus-summary-update-info (&optional non-destructive)
5012 (let ((group gnus-newsgroup-name))
5014 (when gnus-newsgroup-kill-headers
5015 (setq gnus-newsgroup-killed
5016 (gnus-compress-sequence
5018 (gnus-set-sorted-intersection
5019 (gnus-uncompress-range gnus-newsgroup-killed)
5020 (setq gnus-newsgroup-unselected
5021 (sort gnus-newsgroup-unselected '<)))
5022 (setq gnus-newsgroup-unreads
5023 (sort gnus-newsgroup-unreads '<)))
5025 (unless (listp (cdr gnus-newsgroup-killed))
5026 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5027 (let ((headers gnus-newsgroup-headers))
5028 ;; Set the new ranges of read articles.
5030 (set-buffer gnus-group-buffer)
5031 (gnus-undo-force-boundary))
5032 (gnus-update-read-articles
5033 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5034 ;; Set the current article marks.
5035 (let ((gnus-newsgroup-scored
5036 (if (and (not gnus-save-score)
5037 (not non-destructive))
5039 gnus-newsgroup-scored)))
5041 (gnus-update-marks)))
5042 ;; Do the cross-ref thing.
5043 (when gnus-use-cross-reference
5044 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5045 ;; Do not switch windows but change the buffer to work.
5046 (set-buffer gnus-group-buffer)
5047 (unless (gnus-ephemeral-group-p group)
5048 (gnus-group-update-group group)))))))
5050 (defun gnus-summary-save-newsrc (&optional force)
5051 "Save the current number of read/marked articles in the dribble buffer.
5052 The dribble buffer will then be saved.
5053 If FORCE (the prefix), also save the .newsrc file(s)."
5055 (gnus-summary-update-info t)
5057 (gnus-save-newsrc-file)
5058 (gnus-dribble-save)))
5060 (defun gnus-summary-exit (&optional temporary)
5061 "Exit reading current newsgroup, and then return to group selection mode.
5062 gnus-exit-group-hook is called with no arguments if that value is non-nil."
5064 (gnus-set-global-variables)
5065 (gnus-kill-save-kill-buffer)
5066 (gnus-async-halt-prefetch)
5067 (let* ((group gnus-newsgroup-name)
5068 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5071 (buf (current-buffer)))
5072 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5073 ;; If we have several article buffers, we kill them at exit.
5074 (unless gnus-single-article-buffer
5075 (gnus-kill-buffer gnus-original-article-buffer)
5076 (setq gnus-article-current nil))
5077 (when gnus-use-cache
5078 (gnus-cache-possibly-remove-articles)
5079 (gnus-cache-save-buffers))
5080 (gnus-async-prefetch-remove-group group)
5081 (when gnus-suppress-duplicates
5082 (gnus-dup-enter-articles))
5083 (when gnus-use-trees
5084 (gnus-tree-close group))
5085 ;; Remove entries for this group.
5086 (nnmail-purge-split-history (gnus-group-real-name group))
5087 ;; Make all changes in this group permanent.
5089 (gnus-run-hooks 'gnus-exit-group-hook)
5090 (gnus-summary-update-info)
5091 ;; Do adaptive scoring, and possibly save score files.
5092 (when gnus-newsgroup-adaptive
5093 (gnus-score-adaptive))
5094 (when gnus-use-scoring
5096 (gnus-close-group group)
5097 ;; Make sure where we were, and go to next newsgroup.
5098 (set-buffer gnus-group-buffer)
5100 (gnus-group-jump-to-group group))
5101 (gnus-run-hooks 'gnus-summary-exit-hook)
5102 (unless (or quit-config
5103 ;; If this group has disappeared from the summary
5104 ;; buffer, don't skip forwards.
5105 (not (string= group (gnus-group-group-name))))
5106 (gnus-group-next-unread-group 1))
5107 (setq group-point (point))
5110 ;; If we have several article buffers, we kill them at exit.
5111 (unless gnus-single-article-buffer
5112 (gnus-kill-buffer gnus-article-buffer)
5113 (gnus-kill-buffer gnus-original-article-buffer)
5114 (setq gnus-article-current nil))
5116 (if (not gnus-kill-summary-on-exit)
5117 (gnus-deaden-summary)
5118 ;; We set all buffer-local variables to nil. It is unclear why
5119 ;; this is needed, but if we don't, buffer-local variables are
5120 ;; not garbage-collected, it seems. This would the lead to en
5121 ;; ever-growing Emacs.
5122 (gnus-summary-clear-local-variables)
5123 (when (get-buffer gnus-article-buffer)
5124 (bury-buffer gnus-article-buffer))
5125 ;; We clear the global counterparts of the buffer-local
5126 ;; variables as well, just to be on the safe side.
5127 (set-buffer gnus-group-buffer)
5128 (gnus-summary-clear-local-variables)
5129 ;; Return to group mode buffer.
5130 (when (eq mode 'gnus-summary-mode)
5131 (gnus-kill-buffer buf)))
5132 (setq gnus-current-select-method gnus-select-method)
5133 (pop-to-buffer gnus-group-buffer)
5134 ;; Clear the current group name.
5135 (if (not quit-config)
5137 (goto-char group-point)
5138 (gnus-configure-windows 'group 'force))
5139 (gnus-handle-ephemeral-exit quit-config))
5141 (setq gnus-newsgroup-name nil)))))
5143 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5144 (defun gnus-summary-exit-no-update (&optional no-questions)
5145 "Quit reading current newsgroup without updating read article info."
5147 (let* ((group gnus-newsgroup-name)
5148 (quit-config (gnus-group-quit-config group)))
5149 (when (or no-questions
5151 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5152 (gnus-async-halt-prefetch)
5153 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5154 ;; If we have several article buffers, we kill them at exit.
5155 (unless gnus-single-article-buffer
5156 (gnus-kill-buffer gnus-article-buffer)
5157 (gnus-kill-buffer gnus-original-article-buffer)
5158 (setq gnus-article-current nil))
5159 (if (not gnus-kill-summary-on-exit)
5160 (gnus-deaden-summary)
5161 (gnus-close-group group)
5162 (gnus-summary-clear-local-variables)
5163 (set-buffer gnus-group-buffer)
5164 (gnus-summary-clear-local-variables)
5165 (when (get-buffer gnus-summary-buffer)
5166 (kill-buffer gnus-summary-buffer)))
5167 (unless gnus-single-article-buffer
5168 (setq gnus-article-current nil))
5169 (when gnus-use-trees
5170 (gnus-tree-close group))
5171 (gnus-async-prefetch-remove-group group)
5172 (when (get-buffer gnus-article-buffer)
5173 (bury-buffer gnus-article-buffer))
5174 ;; Return to the group buffer.
5175 (gnus-configure-windows 'group 'force)
5176 ;; Clear the current group name.
5177 (setq gnus-newsgroup-name nil)
5178 (when (equal (gnus-group-group-name) group)
5179 (gnus-group-next-unread-group 1))
5181 (gnus-handle-ephemeral-exit quit-config)))))
5183 (defun gnus-handle-ephemeral-exit (quit-config)
5184 "Handle movement when leaving an ephemeral group.
5185 The state which existed when entering the ephemeral is reset."
5186 (if (not (buffer-name (car quit-config)))
5187 (gnus-configure-windows 'group 'force)
5188 (set-buffer (car quit-config))
5189 (cond ((eq major-mode 'gnus-summary-mode)
5190 (gnus-set-global-variables))
5191 ((eq major-mode 'gnus-article-mode)
5193 ;; The `gnus-summary-buffer' variable may point
5194 ;; to the old summary buffer when using a single
5196 (unless (gnus-buffer-live-p gnus-summary-buffer)
5197 (set-buffer gnus-group-buffer))
5198 (set-buffer gnus-summary-buffer)
5199 (gnus-set-global-variables))))
5200 (if (or (eq (cdr quit-config) 'article)
5201 (eq (cdr quit-config) 'pick))
5203 ;; The current article may be from the ephemeral group
5204 ;; thus it is best that we reload this article
5205 (gnus-summary-show-article)
5206 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5207 (gnus-configure-windows 'pick 'force)
5208 (gnus-configure-windows (cdr quit-config) 'force)))
5209 (gnus-configure-windows (cdr quit-config) 'force))
5210 (when (eq major-mode 'gnus-summary-mode)
5211 (gnus-summary-next-subject 1 nil t)
5212 (gnus-summary-recenter)
5213 (gnus-summary-position-point))))
5215 (defun gnus-summary-preview-mime-message (arg)
5216 "MIME decode and play this message."
5219 (let ((gnus-break-pages nil)
5221 (gnus-summary-select-article t t)
5223 (select-window (get-buffer-window gnus-article-buffer))
5226 (defun gnus-summary-scroll-down ()
5227 "Scroll down one line current article."
5229 (gnus-summary-scroll-up -1)
5234 (defvar gnus-dead-summary-mode-map nil)
5236 (unless gnus-dead-summary-mode-map
5237 (setq gnus-dead-summary-mode-map (make-keymap))
5238 (suppress-keymap gnus-dead-summary-mode-map)
5239 (substitute-key-definition
5240 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5241 (let ((keys '("\C-d" "\r" "\177" [delete])))
5243 (define-key gnus-dead-summary-mode-map
5244 (pop keys) 'gnus-summary-wake-up-the-dead))))
5246 (defvar gnus-dead-summary-mode nil
5247 "Minor mode for Gnus summary buffers.")
5249 (defun gnus-dead-summary-mode (&optional arg)
5250 "Minor mode for Gnus summary buffers."
5252 (when (eq major-mode 'gnus-summary-mode)
5253 (make-local-variable 'gnus-dead-summary-mode)
5254 (setq gnus-dead-summary-mode
5255 (if (null arg) (not gnus-dead-summary-mode)
5256 (> (prefix-numeric-value arg) 0)))
5257 (when gnus-dead-summary-mode
5258 (gnus-add-minor-mode
5259 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5261 (defun gnus-deaden-summary ()
5262 "Make the current summary buffer into a dead summary buffer."
5263 ;; Kill any previous dead summary buffer.
5264 (when (and gnus-dead-summary
5265 (buffer-name gnus-dead-summary))
5267 (set-buffer gnus-dead-summary)
5268 (when gnus-dead-summary-mode
5269 (kill-buffer (current-buffer)))))
5270 ;; Make this the current dead summary.
5271 (setq gnus-dead-summary (current-buffer))
5272 (gnus-dead-summary-mode 1)
5273 (let ((name (buffer-name)))
5274 (when (string-match "Summary" name)
5276 (concat (substring name 0 (match-beginning 0)) "Dead "
5277 (substring name (match-beginning 0)))
5280 (defun gnus-kill-or-deaden-summary (buffer)
5281 "Kill or deaden the summary BUFFER."
5283 (when (and (buffer-name buffer)
5284 (not gnus-single-article-buffer))
5287 (gnus-kill-buffer gnus-article-buffer)
5288 (gnus-kill-buffer gnus-original-article-buffer)))
5289 (cond (gnus-kill-summary-on-exit
5290 (when (and gnus-use-trees
5291 (gnus-buffer-exists-p buffer))
5294 (gnus-tree-close gnus-newsgroup-name)))
5295 (gnus-kill-buffer buffer))
5296 ((gnus-buffer-exists-p buffer)
5299 (gnus-deaden-summary))))))
5301 (defun gnus-summary-wake-up-the-dead (&rest args)
5302 "Wake up the dead summary buffer."
5304 (gnus-dead-summary-mode -1)
5305 (let ((name (buffer-name)))
5306 (when (string-match "Dead " name)
5308 (concat (substring name 0 (match-beginning 0))
5309 (substring name (match-end 0)))
5311 (gnus-message 3 "This dead summary is now alive again"))
5313 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5314 (defun gnus-summary-fetch-faq (&optional faq-dir)
5315 "Fetch the FAQ for the current group.
5316 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5320 (when current-prefix-arg
5322 "Faq dir: " (and (listp gnus-group-faq-directory)
5323 (mapcar (lambda (file) (list file))
5324 gnus-group-faq-directory))))))
5325 (let (gnus-faq-buffer)
5326 (when (setq gnus-faq-buffer
5327 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5328 (gnus-configure-windows 'summary-faq))))
5330 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5331 (defun gnus-summary-describe-group (&optional force)
5332 "Describe the current newsgroup."
5334 (gnus-group-describe-group force gnus-newsgroup-name))
5336 (defun gnus-summary-describe-briefly ()
5337 "Describe summary mode commands briefly."
5340 (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")))
5342 ;; Walking around group mode buffer from summary mode.
5344 (defun gnus-summary-next-group (&optional no-article target-group backward)
5345 "Exit current newsgroup and then select next unread newsgroup.
5346 If prefix argument NO-ARTICLE is non-nil, no article is selected
5347 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5348 previous group instead."
5350 ;; Stop pre-fetching.
5351 (gnus-async-halt-prefetch)
5352 (let ((current-group gnus-newsgroup-name)
5353 (current-buffer (current-buffer))
5355 ;; First we semi-exit this group to update Xrefs and all variables.
5356 ;; We can't do a real exit, because the window conf must remain
5357 ;; the same in case the user is prompted for info, and we don't
5358 ;; want the window conf to change before that...
5359 (gnus-summary-exit t)
5360 (while (not entered)
5361 ;; Then we find what group we are supposed to enter.
5362 (set-buffer gnus-group-buffer)
5363 (gnus-group-jump-to-group current-group)
5366 (if (eq gnus-keep-same-level 'best)
5367 (gnus-summary-best-group gnus-newsgroup-name)
5368 (gnus-summary-search-group backward gnus-keep-same-level))))
5369 (if (not target-group)
5370 ;; There are no further groups, so we return to the group
5373 (gnus-message 5 "Returning to the group buffer")
5375 (when (gnus-buffer-live-p current-buffer)
5376 (set-buffer current-buffer)
5377 (gnus-summary-exit))
5378 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5379 ;; We try to enter the target group.
5380 (gnus-group-jump-to-group target-group)
5381 (let ((unreads (gnus-group-group-unread)))
5382 (if (and (or (eq t unreads)
5383 (and unreads (not (zerop unreads))))
5384 (gnus-summary-read-group
5385 target-group nil no-article
5386 (and (buffer-name current-buffer) current-buffer)
5389 (setq current-group target-group
5390 target-group nil)))))))
5392 (defun gnus-summary-prev-group (&optional no-article)
5393 "Exit current newsgroup and then select previous unread newsgroup.
5394 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5396 (gnus-summary-next-group no-article nil t))
5398 ;; Walking around summary lines.
5400 (defun gnus-summary-first-subject (&optional unread undownloaded)
5401 "Go to the first unread subject.
5402 If UNREAD is non-nil, go to the first unread article.
5403 Returns the article selected or nil if there are no unread articles."
5408 ((null gnus-newsgroup-data)
5409 (gnus-message 3 "No articles in the group")
5411 ;; Pick the first article.
5413 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5414 (gnus-data-number (car gnus-newsgroup-data)))
5415 ;; No unread articles.
5416 ((null gnus-newsgroup-unreads)
5417 (gnus-message 3 "No more unread articles")
5419 ;; Find the first unread article.
5421 (let ((data gnus-newsgroup-data))
5423 (and (not (and undownloaded
5424 (eq gnus-undownloaded-mark
5425 (gnus-data-mark (car data)))))
5426 (not (gnus-data-unread-p (car data)))))
5427 (setq data (cdr data)))
5429 (goto-char (gnus-data-pos (car data)))
5430 (gnus-data-number (car data))))))
5431 (gnus-summary-position-point)))
5433 (defun gnus-summary-next-subject (n &optional unread dont-display)
5434 "Go to next N'th summary line.
5435 If N is negative, go to the previous N'th subject line.
5436 If UNREAD is non-nil, only unread articles are selected.
5437 The difference between N and the actual number of steps taken is
5440 (let ((backward (< n 0))
5444 (gnus-summary-find-prev unread)
5445 (gnus-summary-find-next unread)))
5446 (gnus-summary-show-thread)
5449 (gnus-message 7 "No more%s articles"
5450 (if unread " unread" "")))
5451 (unless dont-display
5452 (gnus-summary-recenter)
5453 (gnus-summary-position-point))
5456 (defun gnus-summary-next-unread-subject (n)
5457 "Go to next N'th unread summary line."
5459 (gnus-summary-next-subject n t))
5461 (defun gnus-summary-prev-subject (n &optional unread)
5462 "Go to previous N'th summary line.
5463 If optional argument UNREAD is non-nil, only unread article is selected."
5465 (gnus-summary-next-subject (- n) unread))
5467 (defun gnus-summary-prev-unread-subject (n)
5468 "Go to previous N'th unread summary line."
5470 (gnus-summary-next-subject (- n) t))
5472 (defun gnus-summary-goto-subject (article &optional force silent)
5473 "Go the subject line of ARTICLE.
5474 If FORCE, also allow jumping to articles not currently shown."
5475 (interactive "nArticle number: ")
5477 (data (gnus-data-find article)))
5478 ;; We read in the article if we have to.
5481 (gnus-summary-insert-subject
5483 (if (or (numberp force) (vectorp force)) force)
5485 (setq data (gnus-data-find article)))
5490 (gnus-message 3 "Can't find article %d" article))
5492 (goto-char (gnus-data-pos data))
5493 (gnus-summary-position-point)
5496 ;; Walking around summary lines with displaying articles.
5498 (defun gnus-summary-expand-window (&optional arg)
5499 "Make the summary buffer take up the entire Emacs frame.
5500 Given a prefix, will force an `article' buffer configuration."
5503 (gnus-configure-windows 'article 'force)
5504 (gnus-configure-windows 'summary 'force)))
5506 (defun gnus-summary-display-article (article &optional all-header)
5507 "Display ARTICLE in article buffer."
5508 (gnus-set-global-variables)
5512 (if gnus-summary-display-article-function
5513 (funcall gnus-summary-display-article-function article all-header)
5514 (gnus-article-prepare article all-header))
5515 (gnus-run-hooks 'gnus-select-article-hook)
5516 (when (and gnus-current-article
5517 (not (zerop gnus-current-article)))
5518 (gnus-summary-goto-subject gnus-current-article))
5519 (gnus-summary-recenter)
5520 (when (and gnus-use-trees gnus-show-threads)
5521 (gnus-possibly-generate-tree article)
5522 (gnus-highlight-selected-tree article))
5523 ;; Successfully display article.
5524 (gnus-article-set-window-start
5525 (cdr (assq article gnus-newsgroup-bookmarks))))))
5527 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5528 "Select the current article.
5529 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5530 non-nil, the article will be re-fetched even if it already present in
5531 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5533 ;; Make sure we are in the summary buffer to work around bbdb bug.
5534 (unless (eq major-mode 'gnus-summary-mode)
5535 (set-buffer gnus-summary-buffer))
5536 (let ((article (or article (gnus-summary-article-number)))
5537 (all-headers (not (not all-headers))) ;Must be T or NIL.
5538 gnus-summary-display-article-function
5541 (gnus-summary-article-pseudo-p article)
5542 (error "This is a pseudo-article"))
5545 (set-buffer gnus-summary-buffer)
5546 (if (or (and gnus-single-article-buffer
5547 (or (null gnus-current-article)
5548 (null gnus-article-current)
5549 (null (get-buffer gnus-article-buffer))
5550 (not (eq article (cdr gnus-article-current)))
5551 (not (equal (car gnus-article-current)
5552 gnus-newsgroup-name))))
5553 (and (not gnus-single-article-buffer)
5554 (or (null gnus-current-article)
5555 (not (eq gnus-current-article article))))
5557 ;; The requested article is different from the current article.
5559 (gnus-summary-display-article article all-headers)
5561 (when (or all-headers gnus-show-all-headers)
5562 (gnus-article-show-all-headers))
5565 (gnus-article-set-window-start
5566 (cdr (assq article gnus-newsgroup-bookmarks)))))))
5568 (defun gnus-summary-set-current-mark (&optional current-mark)
5569 "Obsolete function."
5572 (defun gnus-summary-next-article (&optional unread subject backward push)
5573 "Select the next article.
5574 If UNREAD, only unread articles are selected.
5575 If SUBJECT, only articles with SUBJECT are selected.
5576 If BACKWARD, the previous article is selected instead of the next."
5579 ;; Is there such an article?
5580 ((and (gnus-summary-search-forward unread subject backward)
5581 (or (gnus-summary-display-article (gnus-summary-article-number))
5582 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5583 (gnus-summary-position-point))
5584 ;; If not, we try the first unread, if that is wanted.
5586 gnus-auto-select-same
5587 (gnus-summary-first-unread-article))
5588 (gnus-summary-position-point)
5589 (gnus-message 6 "Wrapped"))
5590 ;; Try to get next/previous article not displayed in this group.
5591 ((and gnus-auto-extend-newsgroup
5592 (not unread) (not subject))
5593 (gnus-summary-goto-article
5594 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5595 nil (count-lines (point-min) (point))))
5596 ;; Go to next/previous group.
5598 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5599 (gnus-summary-jump-to-group gnus-newsgroup-name))
5600 (let ((cmd last-command-char)
5603 (set-buffer gnus-group-buffer)
5606 (if (eq gnus-keep-same-level 'best)
5607 (gnus-summary-best-group gnus-newsgroup-name)
5608 (gnus-summary-search-group backward gnus-keep-same-level))))
5609 ;; For some reason, the group window gets selected. We change
5611 (select-window (get-buffer-window (current-buffer)))
5612 ;; Select next unread newsgroup automagically.
5614 ((or (not gnus-auto-select-next)
5616 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5617 ((or (eq gnus-auto-select-next 'quietly)
5618 (and (eq gnus-auto-select-next 'slightly-quietly)
5620 (and (eq gnus-auto-select-next 'almost-quietly)
5621 (gnus-summary-last-article-p)))
5623 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5625 (gnus-message 7 "No more%s articles (%s)..."
5626 (if unread " unread" "")
5627 (if group (concat "selecting " group)
5629 (gnus-summary-next-group nil group backward)))
5631 (when (gnus-key-press-event-p last-input-event)
5632 (gnus-summary-walk-group-buffer
5633 gnus-newsgroup-name cmd unread backward point))))))))
5635 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5636 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5637 (?\C-p (gnus-group-prev-unread-group 1))))
5638 (cursor-in-echo-area t)
5639 keve key group ended)
5641 (set-buffer gnus-group-buffer)
5644 (if (eq gnus-keep-same-level 'best)
5645 (gnus-summary-best-group gnus-newsgroup-name)
5646 (gnus-summary-search-group backward gnus-keep-same-level))))
5649 5 "No more%s articles%s" (if unread " unread" "")
5651 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5652 (format " (Type %s for %s [%s])"
5653 (single-key-description cmd) group
5654 (car (gnus-gethash group gnus-newsrc-hashtb)))
5655 (format " (Type %s to exit %s)"
5656 (single-key-description cmd)
5657 gnus-newsgroup-name)))
5658 ;; Confirm auto selection.
5659 (setq key (car (setq keve (gnus-read-event-char))))
5662 ((assq key keystrokes)
5663 (let ((obuf (current-buffer)))
5664 (switch-to-buffer gnus-group-buffer)
5666 (gnus-group-jump-to-group group))
5667 (eval (cadr (assq key keystrokes)))
5668 (setq group (gnus-group-group-name))
5669 (switch-to-buffer obuf))
5673 (gnus-ephemeral-group-p gnus-newsgroup-name))
5675 (gnus-summary-next-group nil group backward)))
5677 (push (cdr keve) unread-command-events))))))
5679 (defun gnus-summary-next-unread-article ()
5680 "Select unread article after current one."
5682 (gnus-summary-next-article
5683 (or (not (eq gnus-summary-goto-unread 'never))
5684 (gnus-summary-last-article-p (gnus-summary-article-number)))
5685 (and gnus-auto-select-same
5686 (gnus-summary-article-subject))))
5688 (defun gnus-summary-prev-article (&optional unread subject)
5689 "Select the article after the current one.
5690 If UNREAD is non-nil, only unread articles are selected."
5692 (gnus-summary-next-article unread subject t))
5694 (defun gnus-summary-prev-unread-article ()
5695 "Select unread article before current one."
5697 (gnus-summary-prev-article
5698 (or (not (eq gnus-summary-goto-unread 'never))
5699 (gnus-summary-first-article-p (gnus-summary-article-number)))
5700 (and gnus-auto-select-same
5701 (gnus-summary-article-subject))))
5703 (defun gnus-summary-next-page (&optional lines circular)
5704 "Show next page of the selected article.
5705 If at the end of the current article, select the next article.
5706 LINES says how many lines should be scrolled up.
5708 If CIRCULAR is non-nil, go to the start of the article instead of
5709 selecting the next article when reaching the end of the current
5712 (setq gnus-summary-buffer (current-buffer))
5713 (gnus-set-global-variables)
5714 (let ((article (gnus-summary-article-number))
5715 (article-window (get-buffer-window gnus-article-buffer t))
5717 ;; If the buffer is empty, we have no article.
5719 (error "No article to select"))
5720 (gnus-configure-windows 'article)
5721 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
5722 (if (and (eq gnus-summary-goto-unread 'never)
5723 (not (gnus-summary-last-article-p article)))
5724 (gnus-summary-next-article)
5725 (gnus-summary-next-unread-article))
5726 (if (or (null gnus-current-article)
5727 (null gnus-article-current)
5728 (/= article (cdr gnus-article-current))
5729 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5730 ;; Selected subject is different from current article's.
5731 (gnus-summary-display-article article)
5732 (when article-window
5733 (gnus-eval-in-buffer-window gnus-article-buffer
5734 (setq endp (gnus-article-next-page lines)))
5737 (gnus-summary-beginning-of-article))
5739 (gnus-message 3 "End of message"))
5741 (if (and (eq gnus-summary-goto-unread 'never)
5742 (not (gnus-summary-last-article-p article)))
5743 (gnus-summary-next-article)
5744 (gnus-summary-next-unread-article))))))))
5745 (gnus-summary-recenter)
5746 (gnus-summary-position-point)))
5748 (defun gnus-summary-prev-page (&optional lines move)
5749 "Show previous page of selected article.
5750 Argument LINES specifies lines to be scrolled down.
5751 If MOVE, move to the previous unread article if point is at
5752 the beginning of the buffer."
5754 (let ((article (gnus-summary-article-number))
5755 (article-window (get-buffer-window gnus-article-buffer t))
5757 (gnus-configure-windows 'article)
5758 (if (or (null gnus-current-article)
5759 (null gnus-article-current)
5760 (/= article (cdr gnus-article-current))
5761 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5762 ;; Selected subject is different from current article's.
5763 (gnus-summary-display-article article)
5764 (gnus-summary-recenter)
5765 (when article-window
5766 (gnus-eval-in-buffer-window gnus-article-buffer
5767 (setq endp (gnus-article-prev-page lines)))
5768 (when (and move endp)
5770 (gnus-message 3 "Beginning of message"))
5772 (if (and (eq gnus-summary-goto-unread 'never)
5773 (not (gnus-summary-first-article-p article)))
5774 (gnus-summary-prev-article)
5775 (gnus-summary-prev-unread-article))))))))
5776 (gnus-summary-position-point))
5778 (defun gnus-summary-prev-page-or-article (&optional lines)
5779 "Show previous page of selected article.
5780 Argument LINES specifies lines to be scrolled down.
5781 If at the beginning of the article, go to the next article."
5783 (gnus-summary-prev-page lines t))
5785 (defun gnus-summary-scroll-up (lines)
5786 "Scroll up (or down) one line current article.
5787 Argument LINES specifies lines to be scrolled up (or down if negative)."
5789 (gnus-configure-windows 'article)
5790 (gnus-summary-show-thread)
5791 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
5792 (gnus-eval-in-buffer-window gnus-article-buffer
5794 (when (gnus-article-next-page lines)
5795 (gnus-message 3 "End of message")))
5797 (gnus-article-prev-page (- lines))))))
5798 (gnus-summary-recenter)
5799 (gnus-summary-position-point))
5801 (defun gnus-summary-next-same-subject ()
5802 "Select next article which has the same subject as current one."
5804 (gnus-summary-next-article nil (gnus-summary-article-subject)))
5806 (defun gnus-summary-prev-same-subject ()
5807 "Select previous article which has the same subject as current one."
5809 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
5811 (defun gnus-summary-next-unread-same-subject ()
5812 "Select next unread article which has the same subject as current one."
5814 (gnus-summary-next-article t (gnus-summary-article-subject)))
5816 (defun gnus-summary-prev-unread-same-subject ()
5817 "Select previous unread article which has the same subject as current one."
5819 (gnus-summary-prev-article t (gnus-summary-article-subject)))
5821 (defun gnus-summary-first-unread-article ()
5822 "Select the first unread article.
5823 Return nil if there are no unread articles."
5826 (when (gnus-summary-first-subject t)
5827 (gnus-summary-show-thread)
5828 (gnus-summary-first-subject t)
5829 (gnus-summary-display-article (gnus-summary-article-number)))
5830 (gnus-summary-position-point)))
5832 (defun gnus-summary-first-article ()
5833 "Select the first article.
5834 Return nil if there are no articles."
5837 (when (gnus-summary-first-subject)
5838 (gnus-summary-show-thread)
5839 (gnus-summary-first-subject)
5840 (gnus-summary-display-article (gnus-summary-article-number)))
5841 (gnus-summary-position-point)))
5843 (defun gnus-summary-best-unread-article ()
5844 "Select the unread article with the highest score."
5846 (let ((best -1000000)
5847 (data gnus-newsgroup-data)
5850 (and (gnus-data-unread-p (car data))
5852 (gnus-summary-article-score (gnus-data-number (car data))))
5855 article (gnus-data-number (car data))))
5856 (setq data (cdr data)))
5859 (gnus-summary-goto-article article)
5860 (error "No unread articles"))
5861 (gnus-summary-position-point))))
5863 (defun gnus-summary-last-subject ()
5864 "Go to the last displayed subject line in the group."
5865 (let ((article (gnus-data-number (car (gnus-data-list t)))))
5867 (gnus-summary-goto-subject article))))
5869 (defun gnus-summary-goto-article (article &optional all-headers force)
5870 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
5871 If ALL-HEADERS is non-nil, no header lines are hidden.
5872 If FORCE, go to the article even if it isn't displayed. If FORCE
5873 is a number, it is the line the article is to be displayed on."
5877 "Article number or Message-ID: "
5878 (mapcar (lambda (number) (list (int-to-string number)))
5879 gnus-newsgroup-limit))
5883 (if (and (stringp article)
5884 (string-match "@" article))
5885 (gnus-summary-refer-article article)
5886 (when (stringp article)
5887 (setq article (string-to-number article)))
5888 (if (gnus-summary-goto-subject article force)
5889 (gnus-summary-display-article article all-headers)
5890 (gnus-message 4 "Couldn't go to article %s" article) nil))
5891 (gnus-summary-position-point)))
5893 (defun gnus-summary-goto-last-article ()
5894 "Go to the previously read article."
5897 (when gnus-last-article
5898 (gnus-summary-goto-article gnus-last-article nil t))
5899 (gnus-summary-position-point)))
5901 (defun gnus-summary-pop-article (number)
5902 "Pop one article off the history and go to the previous.
5903 NUMBER articles will be popped off."
5906 (setq gnus-newsgroup-history
5907 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
5909 (gnus-summary-goto-article (car to) nil t)
5910 (error "Article history empty")))
5911 (gnus-summary-position-point))
5913 ;; Summary commands and functions for limiting the summary buffer.
5915 (defun gnus-summary-limit-to-articles (n)
5916 "Limit the summary buffer to the next N articles.
5917 If not given a prefix, use the process marked articles instead."
5920 (let ((articles (gnus-summary-work-articles n)))
5921 (setq gnus-newsgroup-processable nil)
5922 (gnus-summary-limit articles))
5923 (gnus-summary-position-point)))
5925 (defun gnus-summary-pop-limit (&optional total)
5926 "Restore the previous limit.
5927 If given a prefix, remove all limits."
5930 (setq gnus-newsgroup-limits
5931 (list (mapcar (lambda (h) (mail-header-number h))
5932 gnus-newsgroup-headers))))
5933 (unless gnus-newsgroup-limits
5934 (error "No limit to pop"))
5936 (gnus-summary-limit nil 'pop)
5937 (gnus-summary-position-point)))
5939 (defun gnus-summary-limit-to-subject (subject &optional header)
5940 "Limit the summary buffer to articles that have subjects that match a regexp."
5941 (interactive "sLimit to subject (regexp): ")
5943 (setq header "subject"))
5944 (when (not (equal "" subject))
5946 (let ((articles (gnus-summary-find-matching
5947 (or header "subject") subject 'all)))
5949 (error "Found no matches for \"%s\"" subject))
5950 (gnus-summary-limit articles))
5951 (gnus-summary-position-point))))
5953 (defun gnus-summary-limit-to-author (from)
5954 "Limit the summary buffer to articles that have authors that match a regexp."
5955 (interactive "sLimit to author (regexp): ")
5956 (gnus-summary-limit-to-subject from "from"))
5958 (defun gnus-summary-limit-to-age (age &optional younger-p)
5959 "Limit the summary buffer to articles that are older than (or equal) AGE days.
5960 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
5961 articles that are younger than AGE days."
5962 (interactive "nTime in days: \nP")
5964 (let ((data gnus-newsgroup-data)
5965 (cutoff (nnmail-days-to-time age))
5966 articles d date is-younger)
5967 (while (setq d (pop data))
5968 (when (and (vectorp (gnus-data-header d))
5969 (setq date (mail-header-date (gnus-data-header d))))
5970 (setq is-younger (nnmail-time-less
5971 (nnmail-time-since (nnmail-date-to-time date))
5976 (push (gnus-data-number d) articles))))
5977 (gnus-summary-limit (nreverse articles)))
5978 (gnus-summary-position-point)))
5980 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5982 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5984 (defun gnus-summary-limit-to-unread (&optional all)
5985 "Limit the summary buffer to articles that are not marked as read.
5986 If ALL is non-nil, limit strictly to unread articles."
5989 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
5990 (gnus-summary-limit-to-marks
5991 ;; Concat all the marks that say that an article is read and have
5993 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
5994 gnus-killed-mark gnus-kill-file-mark
5995 gnus-low-score-mark gnus-expirable-mark
5996 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
5997 gnus-duplicate-mark gnus-souped-mark)
6000 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6001 (make-obsolete 'gnus-summary-delete-marked-with
6002 'gnus-summary-limit-exlude-marks)
6004 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6005 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6006 If REVERSE, limit the summary buffer to articles that are marked
6007 with MARKS. MARKS can either be a string of marks or a list of marks.
6008 Returns how many articles were removed."
6009 (interactive "sMarks: ")
6010 (gnus-summary-limit-to-marks marks t))
6012 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6013 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6014 If REVERSE (the prefix), limit the summary buffer to articles that are
6015 not marked with MARKS. MARKS can either be a string of marks or a
6017 Returns how many articles were removed."
6018 (interactive "sMarks: \nP")
6020 (let ((data gnus-newsgroup-data)
6021 (marks (if (listp marks) marks
6022 (append marks nil))) ; Transform to list.
6025 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6026 (memq (gnus-data-mark (car data)) marks))
6027 (push (gnus-data-number (car data)) articles))
6028 (setq data (cdr data)))
6029 (gnus-summary-limit articles))
6030 (gnus-summary-position-point)))
6032 (defun gnus-summary-limit-to-score (&optional score)
6033 "Limit to articles with score at or above SCORE."
6035 (setq score (if score
6036 (prefix-numeric-value score)
6037 (or gnus-summary-default-score 0)))
6038 (let ((data gnus-newsgroup-data)
6041 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6043 (push (gnus-data-number (car data)) articles))
6044 (setq data (cdr data)))
6046 (gnus-summary-limit articles)
6047 (gnus-summary-position-point))))
6049 (defun gnus-summary-limit-include-thread (id)
6050 "Display all the hidden articles that in the current thread."
6051 (interactive (list (mail-header-id (gnus-summary-article-header))))
6052 (let ((articles (gnus-articles-in-thread
6053 (gnus-id-to-thread (gnus-root-id id)))))
6055 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6056 (gnus-summary-position-point))))
6058 (defun gnus-summary-limit-include-dormant ()
6059 "Display all the hidden articles that are marked as dormant.
6060 Note that this command only works on a subset of the articles currently
6061 fetched for this group."
6063 (unless gnus-newsgroup-dormant
6064 (error "There are no dormant articles in this group"))
6066 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6067 (gnus-summary-position-point)))
6069 (defun gnus-summary-limit-exclude-dormant ()
6070 "Hide all dormant articles."
6073 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6074 (gnus-summary-position-point)))
6076 (defun gnus-summary-limit-exclude-childless-dormant ()
6077 "Hide all dormant articles that have no children."
6079 (let ((data (gnus-data-list t))
6080 articles d children)
6081 ;; Find all articles that are either not dormant or have
6083 (while (setq d (pop data))
6084 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6086 (gnus-article-children (gnus-data-number d)))
6089 (when (memq (car children) articles)
6094 (push (gnus-data-number d) articles)))
6097 (gnus-summary-limit articles)
6098 (gnus-summary-position-point))))
6100 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6101 "Mark all unread excluded articles as read.
6102 If ALL, mark even excluded ticked and dormants as read."
6104 (let ((articles (gnus-sorted-complement
6106 (mapcar (lambda (h) (mail-header-number h))
6107 gnus-newsgroup-headers)
6109 (sort gnus-newsgroup-limit '<)))
6111 (setq gnus-newsgroup-unreads
6112 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6114 (setq gnus-newsgroup-dormant nil
6115 gnus-newsgroup-marked nil
6116 gnus-newsgroup-reads
6118 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6119 gnus-newsgroup-reads))
6120 (while (setq article (pop articles))
6121 (unless (or (memq article gnus-newsgroup-dormant)
6122 (memq article gnus-newsgroup-marked))
6123 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6125 (defun gnus-summary-limit (articles &optional pop)
6127 ;; We pop the previous limit off the stack and use that.
6128 (setq articles (car gnus-newsgroup-limits)
6129 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6130 ;; We use the new limit, so we push the old limit on the stack.
6131 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6133 (setq gnus-newsgroup-limit articles)
6134 (let ((total (length gnus-newsgroup-data))
6135 (data (gnus-data-find-list (gnus-summary-article-number)))
6136 (gnus-summary-mark-below nil) ; Inhibit this.
6138 ;; This will do all the work of generating the new summary buffer
6139 ;; according to the new limit.
6140 (gnus-summary-prepare)
6141 ;; Hide any threads, possibly.
6142 (and gnus-show-threads
6143 gnus-thread-hide-subtree
6144 (gnus-summary-hide-all-threads))
6145 ;; Try to return to the article you were at, or one in the
6148 ;; We try to find some article after the current one.
6150 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6153 (setq data (cdr data))))
6155 ;; If there is no data, that means that we were after the last
6156 ;; article. The same goes when we can't find any articles
6157 ;; after the current one.
6158 (goto-char (point-max))
6159 (gnus-summary-find-prev))
6160 ;; We return how many articles were removed from the summary
6161 ;; buffer as a result of the new limit.
6162 (- total (length gnus-newsgroup-data))))
6164 (defsubst gnus-invisible-cut-children (threads)
6167 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6172 (defsubst gnus-cut-thread (thread)
6173 "Go forwards in the thread until we find an article that we want to display."
6174 (when (or (eq gnus-fetch-old-headers 'some)
6175 (eq gnus-fetch-old-headers 'invisible)
6176 (eq gnus-build-sparse-threads 'some)
6177 (eq gnus-build-sparse-threads 'more))
6178 ;; Deal with old-fetched headers and sparse threads.
6182 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6183 (gnus-summary-article-ancient-p
6184 (mail-header-number (car thread))))
6185 (if (or (<= (length (cdr thread)) 1)
6186 (eq gnus-fetch-old-headers 'invisible))
6187 (setq gnus-newsgroup-limit
6188 (delq (mail-header-number (car thread))
6189 gnus-newsgroup-limit)
6190 thread (cadr thread))
6191 (when (gnus-invisible-cut-children (cdr thread))
6192 (let ((th (cdr thread)))
6194 (if (memq (mail-header-number (caar th))
6195 gnus-newsgroup-limit)
6196 (setq thread (car th)
6198 (setq th (cdr th))))))))))
6201 (defun gnus-cut-threads (threads)
6202 "Cut off all uninteresting articles from the beginning of threads."
6203 (when (or (eq gnus-fetch-old-headers 'some)
6204 (eq gnus-fetch-old-headers 'invisible)
6205 (eq gnus-build-sparse-threads 'some)
6206 (eq gnus-build-sparse-threads 'more))
6209 (setcar th (gnus-cut-thread (car th)))
6210 (setq th (cdr th)))))
6211 ;; Remove nixed out threads.
6214 (defun gnus-summary-initial-limit (&optional show-if-empty)
6215 "Figure out what the initial limit is supposed to be on group entry.
6216 This entails weeding out unwanted dormants, low-scored articles,
6217 fetch-old-headers verbiage, and so on."
6218 ;; Most groups have nothing to remove.
6219 (if (or gnus-inhibit-limiting
6220 (and (null gnus-newsgroup-dormant)
6221 (not (eq gnus-fetch-old-headers 'some))
6222 (not (eq gnus-fetch-old-headers 'invisible))
6223 (null gnus-summary-expunge-below)
6224 (not (eq gnus-build-sparse-threads 'some))
6225 (not (eq gnus-build-sparse-threads 'more))
6226 (null gnus-thread-expunge-below)
6227 (not gnus-use-nocem)))
6229 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6230 (setq gnus-newsgroup-limit nil)
6233 (unless (car (symbol-value node))
6234 ;; These threads have no parents -- they are roots.
6235 (let ((nodes (cdr (symbol-value node)))
6238 (if (and gnus-thread-expunge-below
6239 (< (gnus-thread-total-score (car nodes))
6240 gnus-thread-expunge-below))
6241 (gnus-expunge-thread (pop nodes))
6242 (setq thread (pop nodes))
6243 (gnus-summary-limit-children thread))))))
6244 gnus-newsgroup-dependencies)
6245 ;; If this limitation resulted in an empty group, we might
6246 ;; pop the previous limit and use it instead.
6247 (when (and (not gnus-newsgroup-limit)
6249 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6250 gnus-newsgroup-limit))
6252 (defun gnus-summary-limit-children (thread)
6253 "Return 1 if this subthread is visible and 0 if it is not."
6254 ;; First we get the number of visible children to this thread. This
6255 ;; is done by recursing down the thread using this function, so this
6256 ;; will really go down to a leaf article first, before slowly
6257 ;; working its way up towards the root.
6261 (apply '+ (mapcar 'gnus-summary-limit-children
6264 (number (mail-header-number (car thread)))
6267 (not (memq number gnus-newsgroup-marked))
6269 ;; If this article is dormant and has absolutely no visible
6270 ;; children, then this article isn't visible.
6271 (and (memq number gnus-newsgroup-dormant)
6273 ;; If this is "fetch-old-headered" and there is no
6274 ;; visible children, then we don't want this article.
6275 (and (eq gnus-fetch-old-headers 'some)
6276 (gnus-summary-article-ancient-p number)
6278 ;; If this is "fetch-old-headered" and `invisible', then
6279 ;; we don't want this article.
6280 (and (eq gnus-fetch-old-headers 'invisible)
6281 (gnus-summary-article-ancient-p number))
6282 ;; If this is a sparsely inserted article with no children,
6283 ;; we don't want it.
6284 (and (eq gnus-build-sparse-threads 'some)
6285 (gnus-summary-article-sparse-p number)
6287 ;; If we use expunging, and this article is really
6288 ;; low-scored, then we don't want this article.
6289 (when (and gnus-summary-expunge-below
6291 (or (cdr (assq number gnus-newsgroup-scored))
6292 gnus-summary-default-score))
6293 gnus-summary-expunge-below))
6294 ;; We increase the expunge-tally here, but that has
6295 ;; nothing to do with the limits, really.
6296 (incf gnus-newsgroup-expunged-tally)
6297 ;; We also mark as read here, if that's wanted.
6298 (when (and gnus-summary-mark-below
6299 (< score gnus-summary-mark-below))
6300 (setq gnus-newsgroup-unreads
6301 (delq number gnus-newsgroup-unreads))
6302 (if gnus-newsgroup-auto-expire
6303 (push number gnus-newsgroup-expirable)
6304 (push (cons number gnus-low-score-mark)
6305 gnus-newsgroup-reads)))
6307 ;; Check NoCeM things.
6308 (if (and gnus-use-nocem
6309 (gnus-nocem-unwanted-article-p
6310 (mail-header-id (car thread))))
6312 (setq gnus-newsgroup-unreads
6313 (delq number gnus-newsgroup-unreads))
6315 ;; Nope, invisible article.
6317 ;; Ok, this article is to be visible, so we add it to the limit
6319 (push number gnus-newsgroup-limit)
6322 (defun gnus-expunge-thread (thread)
6323 "Mark all articles in THREAD as read."
6324 (let* ((number (mail-header-number (car thread))))
6325 (incf gnus-newsgroup-expunged-tally)
6326 ;; We also mark as read here, if that's wanted.
6327 (setq gnus-newsgroup-unreads
6328 (delq number gnus-newsgroup-unreads))
6329 (if gnus-newsgroup-auto-expire
6330 (push number gnus-newsgroup-expirable)
6331 (push (cons number gnus-low-score-mark)
6332 gnus-newsgroup-reads)))
6333 ;; Go recursively through all subthreads.
6334 (mapcar 'gnus-expunge-thread (cdr thread)))
6336 ;; Summary article oriented commands
6338 (defun gnus-summary-refer-parent-article (n)
6339 "Refer parent article N times.
6340 If N is negative, go to ancestor -N instead.
6341 The difference between N and the number of articles fetched is returned."
6345 (when (not (natnump n))
6350 (setq header (gnus-summary-article-header))
6351 (if (and (eq (mail-header-number header)
6352 (cdr gnus-article-current))
6353 (equal gnus-newsgroup-name
6354 (car gnus-article-current)))
6355 ;; If we try to find the parent of the currently
6356 ;; displayed article, then we take a look at the actual
6357 ;; References header, since this is slightly more
6358 ;; reliable than the References field we got from the
6361 (set-buffer gnus-original-article-buffer)
6362 (nnheader-narrow-to-headers)
6363 (unless (setq ref (message-fetch-field "references"))
6364 (setq ref (message-fetch-field "in-reply-to")))
6367 ;; It's not the current article, so we take a bet on
6368 ;; the value we got from the server.
6369 (mail-header-references header)))
6371 (not (equal ref "")))
6372 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6373 (gnus-message 1 "Couldn't find parent"))
6374 (gnus-message 1 "No references in article %d"
6375 (gnus-summary-article-number))
6378 (gnus-summary-position-point)
6381 (defun gnus-summary-refer-references ()
6382 "Fetch all articles mentioned in the References header.
6383 Return the number of articles fetched."
6385 (let ((ref (mail-header-references (gnus-summary-article-header)))
6386 (current (gnus-summary-article-number))
6390 (error "No References in the current article")
6391 ;; For each Message-ID in the References header...
6392 (while (string-match "<[^>]*>" ref)
6394 ;; ... fetch that article.
6395 (gnus-summary-refer-article
6396 (prog1 (match-string 0 ref)
6397 (setq ref (substring ref (match-end 0))))))
6398 (gnus-summary-goto-subject current)
6399 (gnus-summary-position-point)
6402 (defun gnus-summary-refer-thread (&optional limit)
6403 "Fetch all articles in the current thread.
6404 If LIMIT (the numerical prefix), fetch that many old headers instead
6405 of what's specified by the `gnus-refer-thread-limit' variable."
6407 (let ((id (mail-header-id (gnus-summary-article-header)))
6408 (limit (if limit (prefix-numeric-value limit)
6409 gnus-refer-thread-limit))
6411 ;; We want to fetch LIMIT *old* headers, but we also have to
6412 ;; re-fetch all the headers in the current buffer, because many of
6413 ;; them may be undisplayed. So we adjust LIMIT.
6414 (when (numberp limit)
6415 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6416 (unless (eq gnus-fetch-old-headers 'invisible)
6417 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6418 ;; Retrieve the headers and read them in.
6419 (if (eq (gnus-retrieve-headers
6420 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6422 (gnus-build-all-threads)
6423 (error "Can't fetch thread from backends that don't support NOV"))
6424 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6425 (gnus-summary-limit-include-thread id)))
6427 (defun gnus-summary-refer-article (message-id &optional arg)
6428 "Fetch an article specified by MESSAGE-ID.
6429 If ARG (the prefix), fetch the article using `gnus-refer-article-method'
6430 or `gnus-select-method', no matter what backend the article comes from."
6431 (interactive "sMessage-ID: \nP")
6432 (when (and (stringp message-id)
6433 (not (zerop (length message-id))))
6434 ;; Construct the correct Message-ID if necessary.
6435 ;; Suggested by tale@pawl.rpi.edu.
6436 (unless (string-match "^<" message-id)
6437 (setq message-id (concat "<" message-id)))
6438 (unless (string-match ">$" message-id)
6439 (setq message-id (concat message-id ">")))
6440 (let* ((header (gnus-id-to-header message-id))
6442 (gnus-summary-article-sparse-p
6443 (mail-header-number header))
6444 (memq (mail-header-number header)
6445 gnus-newsgroup-limit)))
6448 ;; If the article is present in the buffer we just go to it.
6450 (or (not (gnus-summary-article-sparse-p
6451 (mail-header-number header)))
6454 (gnus-summary-goto-article
6455 (mail-header-number header) nil t)
6457 (gnus-summary-update-article (mail-header-number header)))))
6459 ;; We fetch the article
6460 (let ((gnus-override-method
6461 (cond ((gnus-news-group-p gnus-newsgroup-name)
6462 gnus-refer-article-method)
6464 (or gnus-refer-article-method gnus-select-method))
6467 ;; Start the special refer-article method, if necessary.
6468 (when (and gnus-refer-article-method
6469 (gnus-news-group-p gnus-newsgroup-name))
6470 (gnus-check-server gnus-refer-article-method))
6471 ;; Fetch the header, and display the article.
6472 (if (setq number (gnus-summary-insert-subject message-id))
6473 (gnus-summary-select-article nil nil nil number)
6474 (gnus-message 3 "Couldn't fetch article %s" message-id))))))))
6476 (defun gnus-summary-edit-parameters ()
6477 "Edit the group parameters of the current group."
6479 (gnus-group-edit-group gnus-newsgroup-name 'params))
6481 (defun gnus-summary-enter-digest-group (&optional force)
6482 "Enter an nndoc group based on the current article.
6483 If FORCE, force a digest interpretation. If not, try
6484 to guess what the document format is."
6486 (let ((conf gnus-current-window-configuration))
6488 (gnus-summary-select-article))
6489 (setq gnus-current-window-configuration conf)
6490 (let* ((name (format "%s-%d"
6491 (gnus-group-prefixed-name
6492 gnus-newsgroup-name (list 'nndoc ""))
6494 (set-buffer gnus-summary-buffer)
6495 gnus-current-article)))
6496 (ogroup gnus-newsgroup-name)
6497 (params (append (gnus-info-params (gnus-get-info ogroup))
6498 (list (cons 'to-group ogroup))
6499 (list (cons 'save-article-group ogroup))))
6500 (case-fold-search t)
6501 (buf (current-buffer))
6504 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6505 (insert-buffer-substring gnus-original-article-buffer)
6506 ;; Remove lines that may lead nndoc to misinterpret the
6509 (goto-char (point-min))
6510 (or (search-forward "\n\n" nil t) (point)))
6511 (goto-char (point-min))
6512 (delete-matching-lines "^\\(Path\\):\\|^From ")
6515 (if (gnus-group-read-ephemeral-group
6516 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6518 ,(if force 'digest 'guess))) t)
6519 ;; Make all postings to this group go to the parent group.
6520 (nconc (gnus-info-params (gnus-get-info name))
6522 ;; Couldn't select this doc group.
6523 (switch-to-buffer buf)
6524 (gnus-set-global-variables)
6525 (gnus-configure-windows 'summary)
6526 (gnus-message 3 "Article couldn't be entered?"))
6527 (kill-buffer dig)))))
6529 (defun gnus-summary-read-document (n)
6530 "Open a new group based on the current article(s).
6531 This will allow you to read digests and other similar
6532 documents as newsgroups.
6533 Obeys the standard process/prefix convention."
6535 (let* ((articles (gnus-summary-work-articles n))
6536 (ogroup gnus-newsgroup-name)
6537 (params (append (gnus-info-params (gnus-get-info ogroup))
6538 (list (cons 'to-group ogroup))))
6539 article group egroup groups vgroup)
6540 (while (setq article (pop articles))
6541 (setq group (format "%s-%d" gnus-newsgroup-name article))
6542 (gnus-summary-remove-process-mark article)
6543 (when (gnus-summary-display-article article)
6545 (nnheader-temp-write nil
6546 (insert-buffer-substring gnus-original-article-buffer)
6547 ;; Remove some headers that may lead nndoc to make
6549 (message-narrow-to-head)
6550 (goto-char (point-min))
6551 (delete-matching-lines "^\\(Path\\):\\|^From ")
6554 (gnus-group-read-ephemeral-group
6555 group `(nndoc ,group (nndoc-address ,(current-buffer))
6556 (nndoc-article-type guess))
6559 ;; Make all postings to this group go to the parent group.
6560 (nconc (gnus-info-params (gnus-get-info egroup))
6562 (push egroup groups))
6563 ;; Couldn't select this doc group.
6564 (gnus-error 3 "Article couldn't be entered"))))))
6565 ;; Now we have selected all the documents.
6568 (error "None of the articles could be interpreted as documents"))
6569 ((gnus-group-read-ephemeral-group
6570 (setq vgroup (format
6571 "nnvirtual:%s-%s" gnus-newsgroup-name
6572 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6573 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6575 (cons (current-buffer) 'summary)))
6577 (error "Couldn't select virtual nndoc group")))))
6579 (defun gnus-summary-isearch-article (&optional regexp-p)
6580 "Do incremental search forward on the current article.
6581 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6583 (gnus-summary-select-article)
6584 (gnus-configure-windows 'article)
6585 (gnus-eval-in-buffer-window gnus-article-buffer
6588 (isearch-forward regexp-p))))
6590 (defun gnus-summary-search-article-forward (regexp &optional backward)
6591 "Search for an article containing REGEXP forward.
6592 If BACKWARD, search backward instead."
6595 (format "Search article %s (regexp%s): "
6596 (if current-prefix-arg "backward" "forward")
6597 (if gnus-last-search-regexp
6598 (concat ", default " gnus-last-search-regexp)
6600 current-prefix-arg))
6601 (if (string-equal regexp "")
6602 (setq regexp (or gnus-last-search-regexp ""))
6603 (setq gnus-last-search-regexp regexp))
6604 (if (gnus-summary-search-article regexp backward)
6605 (gnus-summary-show-thread)
6606 (error "Search failed: \"%s\"" regexp)))
6608 (defun gnus-summary-search-article-backward (regexp)
6609 "Search for an article containing REGEXP backward."
6612 (format "Search article backward (regexp%s): "
6613 (if gnus-last-search-regexp
6614 (concat ", default " gnus-last-search-regexp)
6616 (gnus-summary-search-article-forward regexp 'backward))
6618 (defun gnus-summary-search-article (regexp &optional backward)
6619 "Search for an article containing REGEXP.
6620 Optional argument BACKWARD means do search for backward.
6621 `gnus-select-article-hook' is not called during the search."
6622 ;; We have to require this here to make sure that the following
6623 ;; dynamic binding isn't shadowed by autoloading.
6624 (require 'gnus-async)
6625 (let ((gnus-select-article-hook nil) ;Disable hook.
6626 (gnus-article-display-hook nil)
6627 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6628 (gnus-use-article-prefetch nil)
6629 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
6630 (gnus-use-trees nil) ;Inhibit updating tree buffer.
6631 (sum (current-buffer))
6634 (gnus-save-hidden-threads
6635 (gnus-summary-select-article)
6636 (set-buffer gnus-article-buffer)
6640 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
6642 (re-search-backward regexp nil t)
6643 (re-search-forward regexp nil t))
6644 ;; We found the regexp.
6649 (get-buffer-window (current-buffer))
6653 (setq point (point)))
6654 ;; We didn't find it, so we go to the next article.
6657 (while (eq found 'not)
6658 (if (not (if backward (gnus-summary-find-prev)
6659 (gnus-summary-find-next)))
6660 ;; No more articles.
6662 ;; Select the next article and adjust point.
6663 (unless (gnus-summary-article-sparse-p
6664 (gnus-summary-article-number))
6666 (gnus-summary-select-article)
6667 (set-buffer gnus-article-buffer)
6669 (goto-char (if backward (point-max) (point-min))))))))
6670 (gnus-message 7 ""))
6671 ;; Return whether we found the regexp.
6672 (when (eq found 'found)
6674 (gnus-summary-show-thread)
6675 (gnus-summary-goto-subject gnus-current-article)
6676 (gnus-summary-position-point)
6679 (defun gnus-summary-find-matching (header regexp &optional backward unread
6681 "Return a list of all articles that match REGEXP on HEADER.
6682 The search stars on the current article and goes forwards unless
6683 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
6684 If UNREAD is non-nil, only unread articles will
6685 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
6686 in the comparisons."
6687 (let ((data (if (eq backward 'all) gnus-newsgroup-data
6688 (gnus-data-find-list
6689 (gnus-summary-article-number) (gnus-data-list backward))))
6690 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
6691 (case-fold-search (not not-case-fold))
6693 (unless (fboundp (intern (concat "mail-header-" header)))
6694 (error "%s is not a valid header" header))
6697 (and (or (not unread) ; We want all articles...
6698 (gnus-data-unread-p d)) ; Or just unreads.
6699 (vectorp (gnus-data-header d)) ; It's not a pseudo.
6700 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
6701 (push (gnus-data-number d) articles)) ; Success!
6702 (setq data (cdr data)))
6703 (nreverse articles)))
6705 (defun gnus-summary-execute-command (header regexp command &optional backward)
6706 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
6707 If HEADER is an empty string (or nil), the match is done on the entire
6708 article. If BACKWARD (the prefix) is non-nil, search backward instead."
6710 (list (let ((completion-ignore-case t))
6713 (mapcar (lambda (string) (list string))
6714 '("Number" "Subject" "From" "Lines" "Date"
6715 "Message-ID" "Xref" "References" "Body"))
6716 nil 'require-match))
6717 (read-string "Regexp: ")
6718 (read-key-sequence "Command: ")
6719 current-prefix-arg))
6720 (when (equal header "Body")
6722 ;; Hidden thread subtrees must be searched as well.
6723 (gnus-summary-show-all-threads)
6724 ;; We don't want to change current point nor window configuration.
6726 (save-window-excursion
6727 (gnus-message 6 "Executing %s..." (key-description command))
6728 ;; We'd like to execute COMMAND interactively so as to give arguments.
6729 (gnus-execute header regexp
6730 `(call-interactively ',(key-binding command))
6732 (gnus-message 6 "Executing %s...done" (key-description command)))))
6734 (defun gnus-summary-beginning-of-article ()
6735 "Scroll the article back to the beginning."
6737 (gnus-summary-select-article)
6738 (gnus-configure-windows 'article)
6739 (gnus-eval-in-buffer-window gnus-article-buffer
6741 (goto-char (point-min))
6742 (when gnus-page-broken
6743 (gnus-narrow-to-page))))
6745 (defun gnus-summary-end-of-article ()
6746 "Scroll to the end of the article."
6748 (gnus-summary-select-article)
6749 (gnus-configure-windows 'article)
6750 (gnus-eval-in-buffer-window gnus-article-buffer
6752 (goto-char (point-max))
6754 (when gnus-page-broken
6755 (gnus-narrow-to-page))))
6757 (defun gnus-summary-print-article (&optional filename n)
6758 "Generate and print a PostScript image of the N next (mail) articles.
6760 If N is negative, print the N previous articles. If N is nil and articles
6761 have been marked with the process mark, print these instead.
6763 If the optional second argument FILENAME is nil, send the image to the
6764 printer. If FILENAME is a string, save the PostScript image in a file with
6765 that name. If FILENAME is a number, prompt the user for the name of the file
6767 (interactive (list (ps-print-preprint current-prefix-arg)
6768 current-prefix-arg))
6769 (dolist (article (gnus-summary-work-articles n))
6770 (gnus-summary-select-article nil nil 'pseudo article)
6771 (gnus-eval-in-buffer-window gnus-article-buffer
6772 (let ((buffer (generate-new-buffer " *print*")))
6775 (copy-to-buffer buffer (point-min) (point-max))
6777 (gnus-article-delete-invisible-text)
6778 (let ((ps-left-header
6781 (mail-header-subject gnus-current-headers) ")")
6783 (mail-header-from gnus-current-headers) ")")))
6786 "/pagenumberstring load"
6788 (mail-header-date gnus-current-headers) ")"))))
6789 (gnus-run-hooks 'gnus-ps-print-hook)
6791 (ps-print-buffer-with-faces filename))))
6792 (kill-buffer buffer))))))
6794 (defun gnus-summary-show-article (&optional arg)
6795 "Force re-fetching of the current article.
6796 If ARG (the prefix) is non-nil, show the raw article without any
6797 article massaging functions being run."
6800 ;; Select the article the normal way.
6801 (gnus-summary-select-article nil 'force)
6802 ;; Bind the article treatment functions to nil.
6803 (let ((gnus-have-all-headers t)
6804 gnus-article-display-hook
6805 gnus-article-prepare-hook
6809 (gnus-summary-select-article nil 'force)))
6810 (gnus-summary-goto-subject gnus-current-article)
6811 (gnus-summary-position-point))
6813 (defun gnus-summary-verbose-headers (&optional arg)
6814 "Toggle permanent full header display.
6815 If ARG is a positive number, turn header display on.
6816 If ARG is a negative number, turn header display off."
6818 (setq gnus-show-all-headers
6819 (cond ((or (not (numberp arg))
6821 (not gnus-show-all-headers))
6824 (gnus-summary-show-article))
6826 (defun gnus-summary-toggle-header (&optional arg)
6827 "Show the headers if they are hidden, or hide them if they are shown.
6828 If ARG is a positive number, show the entire header.
6829 If ARG is a negative number, hide the unwanted header lines."
6832 (set-buffer gnus-article-buffer)
6833 (let* ((buffer-read-only nil)
6834 (inhibit-point-motion-hooks t)
6835 (hidden (text-property-any
6836 (goto-char (point-min)) (search-forward "\n\n")
6839 (goto-char (point-min))
6840 (when (search-forward "\n\n" nil t)
6841 (delete-region (point-min) (1- (point))))
6842 (goto-char (point-min))
6844 (set-buffer gnus-original-article-buffer)
6845 (goto-char (point-min))
6846 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
6847 (insert-buffer-substring gnus-original-article-buffer 1 e)
6848 (let ((article-inhibit-hiding t))
6849 (gnus-run-hooks 'gnus-article-display-hook))
6850 (when (or (not hidden) (and (numberp arg) (< arg 0)))
6851 (gnus-article-hide-headers)))))
6853 (defun gnus-summary-show-all-headers ()
6854 "Make all header lines visible."
6856 (gnus-article-show-all-headers))
6858 (defun gnus-summary-toggle-mime (&optional arg)
6859 "Toggle MIME processing.
6860 If ARG is a positive number, turn MIME processing on."
6862 (setq gnus-show-mime
6863 (if (null arg) (not gnus-show-mime)
6864 (> (prefix-numeric-value arg) 0)))
6865 (gnus-summary-select-article t 'force))
6867 (defun gnus-summary-caesar-message (&optional arg)
6868 "Caesar rotate the current article by 13.
6869 The numerical prefix specifies how many places to rotate each letter
6872 (gnus-summary-select-article)
6873 (let ((mail-header-separator ""))
6874 (gnus-eval-in-buffer-window gnus-article-buffer
6877 (let ((start (window-start))
6879 (message-caesar-buffer-body arg)
6880 (set-window-start (get-buffer-window (current-buffer)) start))))))
6882 (defun gnus-summary-stop-page-breaking ()
6883 "Stop page breaking in the current article."
6885 (gnus-summary-select-article)
6886 (gnus-eval-in-buffer-window gnus-article-buffer
6888 (when (gnus-visual-p 'page-marker)
6889 (let ((buffer-read-only nil))
6890 (gnus-remove-text-with-property 'gnus-prev)
6891 (gnus-remove-text-with-property 'gnus-next))
6892 (setq gnus-page-broken nil))))
6894 (defun gnus-summary-move-article (&optional n to-newsgroup
6895 select-method action)
6896 "Move the current article to a different newsgroup.
6897 If N is a positive number, move the N next articles.
6898 If N is a negative number, move the N previous articles.
6899 If N is nil and any articles have been marked with the process mark,
6900 move those articles instead.
6901 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6902 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6903 re-spool using this method.
6905 For this function to work, both the current newsgroup and the
6906 newsgroup that you want to move to have to support the `request-move'
6907 and `request-accept' functions."
6910 (setq action 'move))
6911 ;; Disable marking as read.
6912 (let (gnus-mark-article-hook)
6913 (save-window-excursion
6914 (gnus-summary-select-article)))
6915 ;; Check whether the source group supports the required functions.
6916 (cond ((and (eq action 'move)
6917 (not (gnus-check-backend-function
6918 'request-move-article gnus-newsgroup-name)))
6919 (error "The current group does not support article moving"))
6920 ((and (eq action 'crosspost)
6921 (not (gnus-check-backend-function
6922 'request-replace-article gnus-newsgroup-name)))
6923 (error "The current group does not support article editing")))
6924 (let ((articles (gnus-summary-work-articles n))
6925 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
6926 (names '((move "Move" "Moving")
6927 (copy "Copy" "Copying")
6928 (crosspost "Crosspost" "Crossposting")))
6929 (copy-buf (save-excursion
6930 (nnheader-set-temp-buffer " *copy article*")))
6931 art-group to-method new-xref article to-groups)
6932 (unless (assq action names)
6933 (error "Unknown action %s" action))
6934 ;; Read the newsgroup name.
6935 (when (and (not to-newsgroup)
6936 (not select-method))
6938 (gnus-read-move-group-name
6939 (cadr (assq action names))
6940 (symbol-value (intern (format "gnus-current-%s-group" action)))
6942 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
6943 (setq to-method (or select-method
6944 (gnus-group-name-to-method to-newsgroup)))
6945 ;; Check the method we are to move this article to...
6946 (unless (gnus-check-backend-function
6947 'request-accept-article (car to-method))
6948 (error "%s does not support article copying" (car to-method)))
6949 (unless (gnus-check-server to-method)
6950 (error "Can't open server %s" (car to-method)))
6951 (gnus-message 6 "%s to %s: %s..."
6952 (caddr (assq action names))
6953 (or (car select-method) to-newsgroup) articles)
6955 (setq article (pop articles))
6959 ;; Move the article.
6961 ;; Remove this article from future suppression.
6962 (gnus-dup-unsuppress-article article)
6963 (gnus-request-move-article
6964 article ; Article to move
6965 gnus-newsgroup-name ; From newsgroup
6966 (nth 1 (gnus-find-method-for-group
6967 gnus-newsgroup-name)) ; Server
6968 (list 'gnus-request-accept-article
6969 to-newsgroup (list 'quote select-method)
6970 (not articles)) ; Accept form
6971 (not articles))) ; Only save nov last time
6972 ;; Copy the article.
6975 (set-buffer copy-buf)
6976 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
6977 (gnus-request-accept-article
6978 to-newsgroup select-method (not articles)))))
6979 ;; Crosspost the article.
6980 ((eq action 'crosspost)
6981 (let ((xref (message-tokenize-header
6982 (mail-header-xref (gnus-summary-article-header article))
6984 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
6987 (setq xref (list (system-name))))
6990 (mapconcat 'identity
6991 (delete "Xref:" (delete new-xref xref))
6995 (set-buffer copy-buf)
6996 ;; First put the article in the destination group.
6997 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6998 (when (consp (setq art-group
6999 (gnus-request-accept-article
7000 to-newsgroup select-method (not articles))))
7001 (setq new-xref (concat new-xref " " (car art-group)
7002 ":" (cdr art-group)))
7003 ;; Now we have the new Xrefs header, so we insert
7004 ;; it and replace the new article.
7005 (nnheader-replace-header "Xref" new-xref)
7006 (gnus-request-replace-article
7007 (cdr art-group) to-newsgroup (current-buffer))
7011 (gnus-message 1 "Couldn't %s article %s"
7012 (cadr (assq action names)) article))
7013 ((and (eq art-group 'junk)
7015 (gnus-summary-mark-article article gnus-canceled-mark)
7016 (gnus-message 4 "Deleted article %s" article))
7020 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
7022 (gnus-group-prefixed-name
7025 (gnus-find-method-for-group to-newsgroup)))
7026 gnus-newsrc-hashtb)))
7027 (info (nth 2 entry))
7028 (to-group (gnus-info-group info)))
7029 ;; Update the group that has been moved to.
7031 (memq action '(move copy)))
7032 (unless (member to-group to-groups)
7033 (push to-group to-groups))
7035 (unless (memq article gnus-newsgroup-unreads)
7037 info (gnus-add-to-range (gnus-info-read info)
7038 (list (cdr art-group)))))
7040 ;; Copy any marks over to the new group.
7041 (let ((marks gnus-article-mark-lists)
7042 (to-article (cdr art-group)))
7044 ;; See whether the article is to be put in the cache.
7045 (when gnus-use-cache
7046 (gnus-cache-possibly-enter-article
7048 (let ((header (copy-sequence
7049 (gnus-summary-article-header article))))
7050 (mail-header-set-number header to-article)
7052 (memq article gnus-newsgroup-marked)
7053 (memq article gnus-newsgroup-dormant)
7054 (memq article gnus-newsgroup-unreads)))
7056 (when (and (equal to-group gnus-newsgroup-name)
7057 (not (memq article gnus-newsgroup-unreads)))
7058 ;; Mark this article as read in this group.
7059 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7060 (setcdr (gnus-active to-group) to-article)
7061 (setcdr gnus-newsgroup-active to-article))
7064 (when (memq article (symbol-value
7065 (intern (format "gnus-newsgroup-%s"
7067 ;; If the other group is the same as this group,
7068 ;; then we have to add the mark to the list.
7069 (when (equal to-group gnus-newsgroup-name)
7070 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7073 (intern (format "gnus-newsgroup-%s"
7075 ;; Copy the marks to other group.
7076 (gnus-add-marked-articles
7077 to-group (cdar marks) (list to-article) info))
7078 (setq marks (cdr marks)))
7081 (concat "(gnus-group-set-info '"
7082 (gnus-prin1-to-string (gnus-get-info to-group))
7085 ;; Update the Xref header in this article to point to
7086 ;; the new crossposted article we have just created.
7087 (when (eq action 'crosspost)
7089 (set-buffer copy-buf)
7090 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7091 (nnheader-replace-header "Xref" new-xref)
7092 (gnus-request-replace-article
7093 article gnus-newsgroup-name (current-buffer)))))
7095 ;;;!!!Why is this necessary?
7096 (set-buffer gnus-summary-buffer)
7098 (gnus-summary-goto-subject article)
7099 (when (eq action 'move)
7100 (gnus-summary-mark-article article gnus-canceled-mark))))
7101 (gnus-summary-remove-process-mark article))
7102 ;; Re-activate all groups that have been moved to.
7105 (set-buffer gnus-group-buffer)
7106 (when (gnus-group-goto-group (car to-groups) t)
7107 (gnus-group-get-new-news-this-group 1 t))
7110 (gnus-kill-buffer copy-buf)
7111 (gnus-summary-position-point)
7112 (gnus-set-mode-line 'summary)))
7114 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7115 "Move the current article to a different newsgroup.
7116 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7117 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7118 re-spool using this method."
7120 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7122 (defun gnus-summary-crosspost-article (&optional n)
7123 "Crosspost the current article to some other group."
7125 (gnus-summary-move-article n nil nil 'crosspost))
7127 (defcustom gnus-summary-respool-default-method nil
7128 "Default method for respooling an article.
7129 If nil, use to the current newsgroup method."
7130 :type `(choice (gnus-select-method :value (nnml ""))
7132 :group 'gnus-summary-mail)
7134 (defun gnus-summary-respool-article (&optional n method)
7135 "Respool the current article.
7136 The article will be squeezed through the mail spooling process again,
7137 which means that it will be put in some mail newsgroup or other
7138 depending on `nnmail-split-methods'.
7139 If N is a positive number, respool the N next articles.
7140 If N is a negative number, respool the N previous articles.
7141 If N is nil and any articles have been marked with the process mark,
7142 respool those articles instead.
7144 Respooling can be done both from mail groups and \"real\" newsgroups.
7145 In the former case, the articles in question will be moved from the
7146 current group into whatever groups they are destined to. In the
7147 latter case, they will be copied into the relevant groups."
7149 (list current-prefix-arg
7150 (let* ((methods (gnus-methods-using 'respool))
7152 (symbol-name (or gnus-summary-respool-default-method
7153 (car (gnus-find-method-for-group
7154 gnus-newsgroup-name)))))
7156 (gnus-completing-read
7157 methname "What backend do you want to use when respooling?"
7158 methods nil t nil 'gnus-mail-method-history))
7161 ((zerop (length (setq ms (gnus-servers-using-backend
7163 (list (intern method) ""))
7167 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7168 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7171 (error "No method given for respooling"))
7172 (if (assoc (symbol-name
7173 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7174 (gnus-methods-using 'respool))
7175 (gnus-summary-move-article n nil method)
7176 (gnus-summary-copy-article n nil method)))
7178 (defun gnus-summary-import-article (file)
7179 "Import an arbitrary file into a mail newsgroup."
7180 (interactive "fImport file: ")
7181 (let ((group gnus-newsgroup-name)
7182 (now (current-time))
7184 (unless (gnus-check-backend-function 'request-accept-article group)
7185 (error "%s does not support article importing" group))
7186 (or (file-readable-p file)
7187 (not (file-regular-p file))
7188 (error "Can't read %s" file))
7190 (set-buffer (get-buffer-create " *import file*"))
7191 (buffer-disable-undo (current-buffer))
7193 (nnheader-insert-file-contents file)
7194 (goto-char (point-min))
7195 (unless (nnheader-article-p)
7196 ;; This doesn't look like an article, so we fudge some headers.
7197 (setq atts (file-attributes file)
7198 lines (count-lines (point-min) (point-max)))
7199 (insert "From: " (read-string "From: ") "\n"
7200 "Subject: " (read-string "Subject: ") "\n"
7201 "Date: " (timezone-make-date-arpa-standard
7202 (current-time-string (nth 5 atts))
7203 (current-time-zone now)
7204 (current-time-zone now))
7206 "Message-ID: " (message-make-message-id) "\n"
7207 "Lines: " (int-to-string lines) "\n"
7208 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7209 (gnus-request-accept-article group nil t)
7210 (kill-buffer (current-buffer)))))
7212 (defun gnus-summary-article-posted-p ()
7213 "Say whether the current (mail) article is available from `gnus-select-method' as well.
7214 This will be the case if the article has both been mailed and posted."
7216 (let ((id (mail-header-references (gnus-summary-article-header)))
7217 (gnus-override-method
7218 (or gnus-refer-article-method gnus-select-method)))
7219 (if (gnus-request-head id "")
7220 (gnus-message 2 "The current message was found on %s"
7221 gnus-override-method)
7222 (gnus-message 2 "The current message couldn't be found on %s"
7223 gnus-override-method)
7226 (defun gnus-summary-expire-articles (&optional now)
7227 "Expire all articles that are marked as expirable in the current group."
7229 (when (gnus-check-backend-function
7230 'request-expire-articles gnus-newsgroup-name)
7231 ;; This backend supports expiry.
7232 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7233 (expirable (if total
7235 ;; We need to update the info for
7236 ;; this group for `gnus-list-of-read-articles'
7237 ;; to give us the right answer.
7238 (gnus-run-hooks 'gnus-exit-group-hook)
7239 (gnus-summary-update-info)
7240 (gnus-list-of-read-articles gnus-newsgroup-name))
7241 (setq gnus-newsgroup-expirable
7242 (sort gnus-newsgroup-expirable '<))))
7243 (expiry-wait (if now 'immediate
7244 (gnus-group-find-parameter
7245 gnus-newsgroup-name 'expiry-wait)))
7248 ;; There are expirable articles in this group, so we run them
7249 ;; through the expiry process.
7250 (gnus-message 6 "Expiring articles...")
7251 ;; The list of articles that weren't expired is returned.
7254 (let ((nnmail-expiry-wait-function nil)
7255 (nnmail-expiry-wait expiry-wait))
7256 (setq es (gnus-request-expire-articles
7257 expirable gnus-newsgroup-name)))
7258 (setq es (gnus-request-expire-articles
7259 expirable gnus-newsgroup-name))))
7261 (setq gnus-newsgroup-expirable es))
7262 ;; We go through the old list of expirable, and mark all
7263 ;; really expired articles as nonexistent.
7264 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7265 (let ((gnus-use-cache nil))
7267 (unless (memq (car expirable) es)
7268 (when (gnus-data-find (car expirable))
7269 (gnus-summary-mark-article
7270 (car expirable) gnus-canceled-mark)))
7271 (setq expirable (cdr expirable)))))
7272 (gnus-message 6 "Expiring articles...done")))))
7274 (defun gnus-summary-expire-articles-now ()
7275 "Expunge all expirable articles in the current group.
7276 This means that *all* articles that are marked as expirable will be
7277 deleted forever, right now."
7279 (or gnus-expert-user
7281 "Are you really, really, really sure you want to delete all these messages? ")
7283 (gnus-summary-expire-articles t))
7285 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7286 (defun gnus-summary-delete-article (&optional n)
7287 "Delete the N next (mail) articles.
7288 This command actually deletes articles. This is not a marking
7289 command. The article will disappear forever from your life, never to
7291 If N is negative, delete backwards.
7292 If N is nil and articles have been marked with the process mark,
7293 delete these instead."
7295 (unless (gnus-check-backend-function 'request-expire-articles
7296 gnus-newsgroup-name)
7297 (error "The current newsgroup does not support article deletion"))
7298 ;; Compute the list of articles to delete.
7299 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
7301 (if (and gnus-novice-user
7302 (not (gnus-yes-or-no-p
7303 (format "Do you really want to delete %s forever? "
7304 (if (> (length articles) 1)
7305 (format "these %s articles" (length articles))
7308 ;; Delete the articles.
7309 (setq not-deleted (gnus-request-expire-articles
7310 articles gnus-newsgroup-name 'force))
7312 (gnus-summary-remove-process-mark (car articles))
7313 ;; The backend might not have been able to delete the article
7315 (unless (memq (car articles) not-deleted)
7316 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7317 (setq articles (cdr articles)))
7319 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7320 (gnus-summary-position-point)
7321 (gnus-set-mode-line 'summary)
7324 (defun gnus-summary-edit-article (&optional force)
7325 "Edit the current article.
7326 This will have permanent effect only in mail groups.
7327 If FORCE is non-nil, allow editing of articles even in read-only
7331 (set-buffer gnus-summary-buffer)
7332 (gnus-set-global-variables)
7333 (when (and (not force)
7334 (gnus-group-read-only-p))
7335 (error "The current newsgroup does not support article editing"))
7336 ;; Select article if needed.
7337 (unless (eq (gnus-summary-article-number)
7338 gnus-current-article)
7339 (gnus-summary-select-article t))
7340 (gnus-article-date-original)
7341 (gnus-article-edit-article
7342 `(lambda (no-highlight)
7343 (gnus-summary-edit-article-done
7344 ,(or (mail-header-references gnus-current-headers) "")
7345 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))
7347 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7349 (defun gnus-summary-edit-article-done (&optional references read-only buffer
7351 "Make edits to the current article permanent."
7353 ;; Replace the article.
7354 (let ((buf (current-buffer)))
7355 (nnheader-temp-write nil
7357 (if (and (not read-only)
7358 (not (gnus-request-replace-article
7359 (cdr gnus-article-current) (car gnus-article-current)
7361 (error "Couldn't replace article")
7362 ;; Update the summary buffer.
7364 (equal (message-tokenize-header references " ")
7365 (message-tokenize-header
7366 (or (message-fetch-field "references") "") " ")))
7367 ;; We only have to update this line.
7370 (message-narrow-to-head)
7371 (let ((head (buffer-string))
7373 (nnheader-temp-write nil
7374 (insert (format "211 %d Article retrieved.\n"
7375 (cdr gnus-article-current)))
7378 (let ((nntp-server-buffer (current-buffer)))
7379 (setq header (car (gnus-get-newsgroup-headers
7381 (set-buffer gnus-summary-buffer)
7382 gnus-newsgroup-dependencies)
7385 (set-buffer gnus-summary-buffer)
7386 (gnus-data-set-header
7387 (gnus-data-find (cdr gnus-article-current))
7389 (gnus-summary-update-article-line
7390 (cdr gnus-article-current) header))))))
7392 (set-buffer (or buffer gnus-summary-buffer))
7393 (gnus-summary-update-article (cdr gnus-article-current)))
7394 ;; Prettify the article buffer again.
7395 (unless no-highlight
7397 (set-buffer gnus-article-buffer)
7398 (gnus-run-hooks 'gnus-article-display-hook)
7399 (set-buffer gnus-original-article-buffer)
7400 (gnus-request-article
7401 (cdr gnus-article-current)
7402 (car gnus-article-current) (current-buffer))))
7403 ;; Prettify the summary buffer line.
7404 (when (gnus-visual-p 'summary-highlight 'highlight)
7405 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
7407 (defun gnus-summary-edit-wash (key)
7408 "Perform editing command KEY in the article buffer."
7412 (message "%s" (concat (this-command-keys) "- "))
7415 (gnus-summary-edit-article)
7416 (execute-kbd-macro (concat (this-command-keys) key))
7417 (gnus-article-edit-done))
7421 (defun gnus-summary-respool-query (&optional silent trace)
7422 "Query where the respool algorithm would put this article."
7424 (let (gnus-mark-article-hook)
7425 (gnus-summary-select-article)
7427 (set-buffer gnus-original-article-buffer)
7429 (message-narrow-to-head)
7430 (let ((groups (nnmail-article-group 'identity trace)))
7433 (message "This message would go to %s"
7434 (mapconcat 'car groups ", "))
7435 (message "This message would go to no groups"))
7438 (defun gnus-summary-respool-trace ()
7439 "Trace where the respool algorithm would put this article.
7440 Display a buffer showing all fancy splitting patterns which matched."
7442 (gnus-summary-respool-query nil t))
7444 ;; Summary marking commands.
7446 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
7447 "Mark articles which has the same subject as read, and then select the next.
7448 If UNMARK is positive, remove any kind of mark.
7449 If UNMARK is negative, tick articles."
7452 (setq unmark (prefix-numeric-value unmark)))
7454 (gnus-summary-mark-same-subject
7455 (gnus-summary-article-subject) unmark)))
7456 ;; Select next unread article. If auto-select-same mode, should
7457 ;; select the first unread article.
7458 (gnus-summary-next-article t (and gnus-auto-select-same
7459 (gnus-summary-article-subject)))
7460 (gnus-message 7 "%d article%s marked as %s"
7461 count (if (= count 1) " is" "s are")
7462 (if unmark "unread" "read"))))
7464 (defun gnus-summary-kill-same-subject (&optional unmark)
7465 "Mark articles which has the same subject as read.
7466 If UNMARK is positive, remove any kind of mark.
7467 If UNMARK is negative, tick articles."
7470 (setq unmark (prefix-numeric-value unmark)))
7472 (gnus-summary-mark-same-subject
7473 (gnus-summary-article-subject) unmark)))
7474 ;; If marked as read, go to next unread subject.
7476 ;; Go to next unread subject.
7477 (gnus-summary-next-subject 1 t))
7478 (gnus-message 7 "%d articles are marked as %s"
7479 count (if unmark "unread" "read"))))
7481 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7482 "Mark articles with same SUBJECT as read, and return marked number.
7483 If optional argument UNMARK is positive, remove any kinds of marks.
7484 If optional argument UNMARK is negative, mark articles as unread instead."
7488 ((null unmark) ; Mark as read.
7491 (gnus-summary-mark-article-as-read gnus-killed-mark)
7492 (gnus-summary-show-thread) t)
7493 (gnus-summary-find-subject subject))
7494 (setq count (1+ count))))
7495 ((> unmark 0) ; Tick.
7498 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
7499 (gnus-summary-show-thread) t)
7500 (gnus-summary-find-subject subject))
7501 (setq count (1+ count))))
7502 (t ; Mark as unread.
7505 (gnus-summary-mark-article-as-unread gnus-unread-mark)
7506 (gnus-summary-show-thread) t)
7507 (gnus-summary-find-subject subject))
7508 (setq count (1+ count)))))
7509 (gnus-set-mode-line 'summary)
7510 ;; Return the number of marked articles.
7513 (defun gnus-summary-mark-as-processable (n &optional unmark)
7514 "Set the process mark on the next N articles.
7515 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7516 the process mark instead. The difference between N and the actual
7517 number of articles marked is returned."
7519 (let ((backward (< n 0))
7524 (gnus-summary-remove-process-mark
7525 (gnus-summary-article-number))
7526 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7527 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7530 (gnus-message 7 "No more articles"))
7531 (gnus-summary-recenter)
7532 (gnus-summary-position-point)
7535 (defun gnus-summary-unmark-as-processable (n)
7536 "Remove the process mark from the next N articles.
7537 If N is negative, unmark backward instead. The difference between N and
7538 the actual number of articles unmarked is returned."
7540 (gnus-summary-mark-as-processable n t))
7542 (defun gnus-summary-unmark-all-processable ()
7543 "Remove the process mark from all articles."
7546 (while gnus-newsgroup-processable
7547 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7548 (gnus-summary-position-point))
7550 (defun gnus-summary-mark-as-expirable (n)
7551 "Mark N articles forward as expirable.
7552 If N is negative, mark backward instead. The difference between N and
7553 the actual number of articles marked is returned."
7555 (gnus-summary-mark-forward n gnus-expirable-mark))
7557 (defun gnus-summary-mark-article-as-replied (article)
7558 "Mark ARTICLE replied and update the summary line."
7559 (push article gnus-newsgroup-replied)
7560 (let ((buffer-read-only nil))
7561 (when (gnus-summary-goto-subject article)
7562 (gnus-summary-update-secondary-mark article))))
7564 (defun gnus-summary-set-bookmark (article)
7565 "Set a bookmark in current article."
7566 (interactive (list (gnus-summary-article-number)))
7567 (when (or (not (get-buffer gnus-article-buffer))
7568 (not gnus-current-article)
7569 (not gnus-article-current)
7570 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7571 (error "No current article selected"))
7572 ;; Remove old bookmark, if one exists.
7573 (let ((old (assq article gnus-newsgroup-bookmarks)))
7575 (setq gnus-newsgroup-bookmarks
7576 (delq old gnus-newsgroup-bookmarks))))
7577 ;; Set the new bookmark, which is on the form
7578 ;; (article-number . line-number-in-body).
7582 (set-buffer gnus-article-buffer)
7586 (goto-char (point-min))
7587 (search-forward "\n\n" nil t)
7590 gnus-newsgroup-bookmarks)
7591 (gnus-message 6 "A bookmark has been added to the current article."))
7593 (defun gnus-summary-remove-bookmark (article)
7594 "Remove the bookmark from the current article."
7595 (interactive (list (gnus-summary-article-number)))
7596 ;; Remove old bookmark, if one exists.
7597 (let ((old (assq article gnus-newsgroup-bookmarks)))
7600 (setq gnus-newsgroup-bookmarks
7601 (delq old gnus-newsgroup-bookmarks))
7602 (gnus-message 6 "Removed bookmark."))
7603 (gnus-message 6 "No bookmark in current article."))))
7605 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7606 (defun gnus-summary-mark-as-dormant (n)
7607 "Mark N articles forward as dormant.
7608 If N is negative, mark backward instead. The difference between N and
7609 the actual number of articles marked is returned."
7611 (gnus-summary-mark-forward n gnus-dormant-mark))
7613 (defun gnus-summary-set-process-mark (article)
7614 "Set the process mark on ARTICLE and update the summary line."
7615 (setq gnus-newsgroup-processable
7617 (delq article gnus-newsgroup-processable)))
7618 (when (gnus-summary-goto-subject article)
7619 (gnus-summary-show-thread)
7620 (gnus-summary-update-secondary-mark article)))
7622 (defun gnus-summary-remove-process-mark (article)
7623 "Remove the process mark from ARTICLE and update the summary line."
7624 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7625 (when (gnus-summary-goto-subject article)
7626 (gnus-summary-show-thread)
7627 (gnus-summary-update-secondary-mark article)))
7629 (defun gnus-summary-set-saved-mark (article)
7630 "Set the process mark on ARTICLE and update the summary line."
7631 (push article gnus-newsgroup-saved)
7632 (when (gnus-summary-goto-subject article)
7633 (gnus-summary-update-secondary-mark article)))
7635 (defun gnus-summary-mark-forward (n &optional mark no-expire)
7636 "Mark N articles as read forwards.
7637 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
7638 The difference between N and the actual number of articles marked is
7641 (let ((backward (< n 0))
7642 (gnus-summary-goto-unread
7643 (and gnus-summary-goto-unread
7644 (not (eq gnus-summary-goto-unread 'never))
7645 (not (memq mark (list gnus-unread-mark
7646 gnus-ticked-mark gnus-dormant-mark)))))
7648 (mark (or mark gnus-del-mark)))
7650 (gnus-summary-mark-article nil mark no-expire)
7651 (zerop (gnus-summary-next-subject
7653 (and gnus-summary-goto-unread
7654 (not (eq gnus-summary-goto-unread 'never)))
7658 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
7659 (gnus-summary-recenter)
7660 (gnus-summary-position-point)
7661 (gnus-set-mode-line 'summary)
7664 (defun gnus-summary-mark-article-as-read (mark)
7665 "Mark the current article quickly as read with MARK."
7666 (let ((article (gnus-summary-article-number)))
7667 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7668 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7669 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7670 (push (cons article mark) gnus-newsgroup-reads)
7671 ;; Possibly remove from cache, if that is used.
7672 (when gnus-use-cache
7673 (gnus-cache-enter-remove-article article))
7674 ;; Allow the backend to change the mark.
7675 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7676 ;; Check for auto-expiry.
7677 (when (and gnus-newsgroup-auto-expire
7678 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7679 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7680 (= mark gnus-ancient-mark)
7681 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7682 (= mark gnus-duplicate-mark)))
7683 (setq mark gnus-expirable-mark)
7684 (push article gnus-newsgroup-expirable))
7685 ;; Set the mark in the buffer.
7686 (gnus-summary-update-mark mark 'unread)
7689 (defun gnus-summary-mark-article-as-unread (mark)
7690 "Mark the current article quickly as unread with MARK."
7691 (let* ((article (gnus-summary-article-number))
7692 (old-mark (gnus-summary-article-mark article)))
7693 (if (eq mark old-mark)
7697 (gnus-error 1 "Can't mark negative article numbers")
7699 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7700 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7701 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
7702 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
7703 (cond ((= mark gnus-ticked-mark)
7704 (push article gnus-newsgroup-marked))
7705 ((= mark gnus-dormant-mark)
7706 (push article gnus-newsgroup-dormant))
7708 (push article gnus-newsgroup-unreads)))
7709 (gnus-pull article gnus-newsgroup-reads)
7711 ;; See whether the article is to be put in the cache.
7713 (vectorp (gnus-summary-article-header article))
7715 (gnus-cache-possibly-enter-article
7716 gnus-newsgroup-name article
7717 (gnus-summary-article-header article)
7718 (= mark gnus-ticked-mark)
7719 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7722 (gnus-summary-update-mark mark 'unread)
7725 (defun gnus-summary-mark-article (&optional article mark no-expire)
7726 "Mark ARTICLE with MARK. MARK can be any character.
7727 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
7728 `??' (dormant) and `?E' (expirable).
7729 If MARK is nil, then the default character `?D' is used.
7730 If ARTICLE is nil, then the article on the current line will be
7732 ;; The mark might be a string.
7733 (when (stringp mark)
7734 (setq mark (aref mark 0)))
7735 ;; If no mark is given, then we check auto-expiring.
7736 (and (not no-expire)
7737 gnus-newsgroup-auto-expire
7739 (and (gnus-characterp mark)
7740 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7741 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7742 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7743 (= mark gnus-duplicate-mark))))
7744 (setq mark gnus-expirable-mark))
7745 (let* ((mark (or mark gnus-del-mark))
7746 (article (or article (gnus-summary-article-number)))
7747 (old-mark (gnus-summary-article-mark article)))
7748 (if (eq mark old-mark)
7751 (error "No article on current line"))
7752 (if (not (if (or (= mark gnus-unread-mark)
7753 (= mark gnus-ticked-mark)
7754 (= mark gnus-dormant-mark))
7755 (gnus-mark-article-as-unread article mark)
7756 (gnus-mark-article-as-read article mark)))
7758 ;; See whether the article is to be put in the cache.
7760 (not (= mark gnus-canceled-mark))
7761 (vectorp (gnus-summary-article-header article))
7763 (gnus-cache-possibly-enter-article
7764 gnus-newsgroup-name article
7765 (gnus-summary-article-header article)
7766 (= mark gnus-ticked-mark)
7767 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7769 (when (gnus-summary-goto-subject article nil t)
7770 (let ((buffer-read-only nil))
7771 (gnus-summary-show-thread)
7773 (gnus-summary-update-mark mark 'unread)
7776 (defun gnus-summary-update-secondary-mark (article)
7777 "Update the secondary (read, process, cache) mark."
7778 (gnus-summary-update-mark
7779 (cond ((memq article gnus-newsgroup-processable)
7781 ((memq article gnus-newsgroup-cached)
7783 ((memq article gnus-newsgroup-replied)
7785 ((memq article gnus-newsgroup-saved)
7787 (t gnus-unread-mark))
7789 (when (gnus-visual-p 'summary-highlight 'highlight)
7790 (gnus-run-hooks 'gnus-summary-update-hook))
7793 (defun gnus-summary-update-mark (mark type)
7794 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
7795 (buffer-read-only nil))
7796 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
7797 (when (looking-at "\r")
7800 (<= (+ forward (point)) (point-max)))
7801 ;; Go to the right position on the line.
7802 (goto-char (+ forward (point)))
7803 ;; Replace the old mark with the new mark.
7804 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
7805 ;; Optionally update the marks by some user rule.
7806 (when (eq type 'unread)
7808 (gnus-data-find (gnus-summary-article-number)) mark)
7809 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
7811 (defun gnus-mark-article-as-read (article &optional mark)
7812 "Enter ARTICLE in the pertinent lists and remove it from others."
7813 ;; Make the article expirable.
7814 (let ((mark (or mark gnus-del-mark)))
7815 (if (= mark gnus-expirable-mark)
7816 (push article gnus-newsgroup-expirable)
7817 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
7818 ;; Remove from unread and marked lists.
7819 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7820 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7821 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7822 (push (cons article mark) gnus-newsgroup-reads)
7823 ;; Possibly remove from cache, if that is used.
7824 (when gnus-use-cache
7825 (gnus-cache-enter-remove-article article))
7828 (defun gnus-mark-article-as-unread (article &optional mark)
7829 "Enter ARTICLE in the pertinent lists and remove it from others."
7830 (let ((mark (or mark gnus-ticked-mark)))
7833 (gnus-error 1 "Can't mark negative article numbers")
7835 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
7836 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
7837 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
7838 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7840 ;; Unsuppress duplicates?
7841 (when gnus-suppress-duplicates
7842 (gnus-dup-unsuppress-article article))
7844 (cond ((= mark gnus-ticked-mark)
7845 (push article gnus-newsgroup-marked))
7846 ((= mark gnus-dormant-mark)
7847 (push article gnus-newsgroup-dormant))
7849 (push article gnus-newsgroup-unreads)))
7850 (gnus-pull article gnus-newsgroup-reads)
7853 (defalias 'gnus-summary-mark-as-unread-forward
7854 'gnus-summary-tick-article-forward)
7855 (make-obsolete 'gnus-summary-mark-as-unread-forward
7856 'gnus-summary-tick-article-forward)
7857 (defun gnus-summary-tick-article-forward (n)
7858 "Tick N articles forwards.
7859 If N is negative, tick backwards instead.
7860 The difference between N and the number of articles ticked is returned."
7862 (gnus-summary-mark-forward n gnus-ticked-mark))
7864 (defalias 'gnus-summary-mark-as-unread-backward
7865 'gnus-summary-tick-article-backward)
7866 (make-obsolete 'gnus-summary-mark-as-unread-backward
7867 'gnus-summary-tick-article-backward)
7868 (defun gnus-summary-tick-article-backward (n)
7869 "Tick N articles backwards.
7870 The difference between N and the number of articles ticked is returned."
7872 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
7874 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7875 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7876 (defun gnus-summary-tick-article (&optional article clear-mark)
7877 "Mark current article as unread.
7878 Optional 1st argument ARTICLE specifies article number to be marked as unread.
7879 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
7881 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
7884 (defun gnus-summary-mark-as-read-forward (n)
7885 "Mark N articles as read forwards.
7886 If N is negative, mark backwards instead.
7887 The difference between N and the actual number of articles marked is
7890 (gnus-summary-mark-forward n gnus-del-mark t))
7892 (defun gnus-summary-mark-as-read-backward (n)
7893 "Mark the N articles as read backwards.
7894 The difference between N and the actual number of articles marked is
7897 (gnus-summary-mark-forward (- n) gnus-del-mark t))
7899 (defun gnus-summary-mark-as-read (&optional article mark)
7900 "Mark current article as read.
7901 ARTICLE specifies the article to be marked as read.
7902 MARK specifies a string to be inserted at the beginning of the line."
7903 (gnus-summary-mark-article article mark))
7905 (defun gnus-summary-clear-mark-forward (n)
7906 "Clear marks from N articles forward.
7907 If N is negative, clear backward instead.
7908 The difference between N and the number of marks cleared is returned."
7910 (gnus-summary-mark-forward n gnus-unread-mark))
7912 (defun gnus-summary-clear-mark-backward (n)
7913 "Clear marks from N articles backward.
7914 The difference between N and the number of marks cleared is returned."
7916 (gnus-summary-mark-forward (- n) gnus-unread-mark))
7918 (defun gnus-summary-mark-unread-as-read ()
7919 "Intended to be used by `gnus-summary-mark-article-hook'."
7920 (when (memq gnus-current-article gnus-newsgroup-unreads)
7921 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
7923 (defun gnus-summary-mark-read-and-unread-as-read ()
7924 "Intended to be used by `gnus-summary-mark-article-hook'."
7925 (let ((mark (gnus-summary-article-mark)))
7926 (when (or (gnus-unread-mark-p mark)
7927 (gnus-read-mark-p mark))
7928 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
7930 (defun gnus-summary-mark-region-as-read (point mark all)
7931 "Mark all unread articles between point and mark as read.
7932 If given a prefix, mark all articles between point and mark as read,
7933 even ticked and dormant ones."
7934 (interactive "r\nP")
7943 (memq (setq article (gnus-summary-article-number))
7944 gnus-newsgroup-unreads))
7945 (gnus-summary-mark-article article gnus-del-mark))
7947 (gnus-summary-find-next))))))
7949 (defun gnus-summary-mark-below (score mark)
7950 "Mark articles with score less than SCORE with MARK."
7951 (interactive "P\ncMark: ")
7952 (setq score (if score
7953 (prefix-numeric-value score)
7954 (or gnus-summary-default-score 0)))
7956 (set-buffer gnus-summary-buffer)
7957 (goto-char (point-min))
7960 (and (< (gnus-summary-article-score) score)
7961 (gnus-summary-mark-article nil mark))
7962 (gnus-summary-find-next)))))
7964 (defun gnus-summary-kill-below (&optional score)
7965 "Mark articles with score below SCORE as read."
7967 (gnus-summary-mark-below score gnus-killed-mark))
7969 (defun gnus-summary-clear-above (&optional score)
7970 "Clear all marks from articles with score above SCORE."
7972 (gnus-summary-mark-above score gnus-unread-mark))
7974 (defun gnus-summary-tick-above (&optional score)
7975 "Tick all articles with score above SCORE."
7977 (gnus-summary-mark-above score gnus-ticked-mark))
7979 (defun gnus-summary-mark-above (score mark)
7980 "Mark articles with score over SCORE with MARK."
7981 (interactive "P\ncMark: ")
7982 (setq score (if score
7983 (prefix-numeric-value score)
7984 (or gnus-summary-default-score 0)))
7986 (set-buffer gnus-summary-buffer)
7987 (goto-char (point-min))
7989 (when (> (gnus-summary-article-score) score)
7990 (gnus-summary-mark-article nil mark))
7992 (gnus-summary-find-next)))))
7994 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7995 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
7996 (defun gnus-summary-limit-include-expunged (&optional no-error)
7997 "Display all the hidden articles that were expunged for low scores."
7999 (let ((buffer-read-only nil))
8000 (let ((scored gnus-newsgroup-scored)
8003 (unless (gnus-summary-goto-subject (caar scored))
8004 (and (setq h (gnus-summary-article-header (caar scored)))
8005 (< (cdar scored) gnus-summary-expunge-below)
8007 (setq scored (cdr scored)))
8009 (when (not no-error)
8010 (error "No expunged articles hidden"))
8011 (goto-char (point-min))
8012 (gnus-summary-prepare-unthreaded (nreverse headers))
8013 (goto-char (point-min))
8014 (gnus-summary-position-point)
8017 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
8018 "Mark all unread articles in this newsgroup as read.
8019 If prefix argument ALL is non-nil, ticked and dormant articles will
8020 also be marked as read.
8021 If QUIETLY is non-nil, no questions will be asked.
8022 If TO-HERE is non-nil, it should be a point in the buffer. All
8023 articles before this point will be marked as read.
8024 Note that this function will only catch up the unread article
8025 in the current summary buffer limitation.
8026 The number of articles marked as read is returned."
8031 (not gnus-interactive-catchup) ;Without confirmation?
8035 "Mark absolutely all articles as read? "
8036 "Mark all unread articles as read? ")))
8038 (not gnus-newsgroup-adaptive)
8039 (not gnus-newsgroup-auto-expire)
8040 (not gnus-suppress-duplicates)
8041 (or (not gnus-use-cache)
8042 (eq gnus-use-cache 'passive)))
8045 (setq gnus-newsgroup-marked nil
8046 gnus-newsgroup-dormant nil))
8047 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8048 ;; We actually mark all articles as canceled, which we
8049 ;; have to do when using auto-expiry or adaptive scoring.
8050 (gnus-summary-show-all-threads)
8051 (when (gnus-summary-first-subject (not all) t)
8053 (if to-here (< (point) to-here) t)
8054 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8055 (gnus-summary-find-next (not all) nil nil t))))
8056 (gnus-set-mode-line 'summary))
8058 (gnus-summary-position-point)))
8060 (defun gnus-summary-catchup-to-here (&optional all)
8061 "Mark all unticked articles before the current one as read.
8062 If ALL is non-nil, also mark ticked and dormant articles as read."
8065 (gnus-save-hidden-threads
8066 (let ((beg (point)))
8067 ;; We check that there are unread articles.
8068 (when (or all (gnus-summary-find-prev))
8069 (gnus-summary-catchup all t beg)))))
8070 (gnus-summary-position-point))
8072 (defun gnus-summary-catchup-all (&optional quietly)
8073 "Mark all articles in this newsgroup as read."
8075 (gnus-summary-catchup t quietly))
8077 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8078 "Mark all articles not marked as unread in this newsgroup as read, then exit.
8079 If prefix argument ALL is non-nil, all articles are marked as read."
8081 (when (gnus-summary-catchup all quietly nil 'fast)
8082 ;; Select next newsgroup or exit.
8083 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
8084 (eq gnus-auto-select-next 'quietly))
8085 (gnus-summary-next-group nil)
8086 (gnus-summary-exit))))
8088 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8089 "Mark all articles in this newsgroup as read, and then exit."
8091 (gnus-summary-catchup-and-exit t quietly))
8093 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
8094 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8095 "Mark all articles in this group as read and select the next group.
8096 If given a prefix, mark all articles, unread as well as ticked, as
8100 (gnus-summary-catchup all))
8101 (gnus-summary-next-article t nil nil t))
8103 ;; Thread-based commands.
8105 (defun gnus-summary-articles-in-thread (&optional article)
8106 "Return a list of all articles in the current thread.
8107 If ARTICLE is non-nil, return all articles in the thread that starts
8109 (let* ((article (or article (gnus-summary-article-number)))
8110 (data (gnus-data-find-list article))
8111 (top-level (gnus-data-level (car data)))
8113 (cond ((null gnus-thread-operation-ignore-subject)
8114 (gnus-simplify-subject-re
8115 (mail-header-subject (gnus-data-header (car data)))))
8116 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8117 (gnus-simplify-subject-fuzzy
8118 (mail-header-subject (gnus-data-header (car data)))))
8120 (end-point (save-excursion
8121 (if (gnus-summary-go-to-next-thread)
8122 (point) (point-max))))
8125 (< (gnus-data-pos (car data)) end-point))
8126 (when (or (not top-subject)
8127 (string= top-subject
8128 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8129 (gnus-simplify-subject-fuzzy
8130 (mail-header-subject
8131 (gnus-data-header (car data))))
8132 (gnus-simplify-subject-re
8133 (mail-header-subject
8134 (gnus-data-header (car data)))))))
8135 (push (gnus-data-number (car data)) articles))
8136 (unless (and (setq data (cdr data))
8137 (> (gnus-data-level (car data)) top-level))
8139 ;; Return the list of articles.
8140 (nreverse articles)))
8142 (defun gnus-summary-rethread-current ()
8143 "Rethread the thread the current article is part of."
8145 (let* ((gnus-show-threads t)
8146 (article (gnus-summary-article-number))
8147 (id (mail-header-id (gnus-summary-article-header)))
8148 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8150 (error "No article on the current line"))
8151 (gnus-rebuild-thread id)
8152 (gnus-summary-goto-subject article)))
8154 (defun gnus-summary-reparent-thread ()
8155 "Make the current article child of the marked (or previous) article.
8157 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8158 is non-nil or the Subject: of both articles are the same."
8160 (unless (not (gnus-group-read-only-p))
8161 (error "The current newsgroup does not support article editing"))
8162 (unless (<= (length gnus-newsgroup-processable) 1)
8163 (error "No more than one article may be marked"))
8164 (save-window-excursion
8165 (let ((gnus-article-buffer " *reparent*")
8166 (current-article (gnus-summary-article-number))
8167 ;; First grab the marked article, otherwise one line up.
8168 (parent-article (if (not (null gnus-newsgroup-processable))
8169 (car gnus-newsgroup-processable)
8171 (if (eq (forward-line -1) 0)
8172 (gnus-summary-article-number)
8173 (error "Beginning of summary buffer"))))))
8174 (unless (not (eq current-article parent-article))
8175 (error "An article may not be self-referential"))
8176 (let ((message-id (mail-header-id
8177 (gnus-summary-article-header parent-article))))
8178 (unless (and message-id (not (equal message-id "")))
8179 (error "No message-id in desired parent"))
8180 ;; We don't want the article to be marked as read.
8181 (let (gnus-mark-article-hook)
8182 (gnus-summary-select-article t t nil current-article))
8183 (set-buffer gnus-original-article-buffer)
8184 (let ((buf (format "%s" (buffer-string))))
8185 (nnheader-temp-write nil
8187 (goto-char (point-min))
8188 (if (re-search-forward "^References: " nil t)
8190 (re-search-forward "^[^ \t]" nil t)
8193 (insert " " message-id))
8194 (insert "References: " message-id "\n"))
8195 (unless (gnus-request-replace-article
8196 current-article (car gnus-article-current)
8198 (error "Couldn't replace article"))))
8199 (set-buffer gnus-summary-buffer)
8200 (gnus-summary-unmark-all-processable)
8201 (gnus-summary-update-article current-article)
8202 (gnus-summary-rethread-current)
8203 (gnus-message 3 "Article %d is now the child of article %d"
8204 current-article parent-article)))))
8206 (defun gnus-summary-toggle-threads (&optional arg)
8207 "Toggle showing conversation threads.
8208 If ARG is positive number, turn showing conversation threads on."
8210 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8211 (setq gnus-show-threads
8212 (if (null arg) (not gnus-show-threads)
8213 (> (prefix-numeric-value arg) 0)))
8214 (gnus-summary-prepare)
8215 (gnus-summary-goto-subject current)
8216 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8217 (gnus-summary-position-point)))
8219 (defun gnus-summary-show-all-threads ()
8223 (let ((buffer-read-only nil))
8224 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8225 (gnus-summary-position-point))
8227 (defun gnus-summary-show-thread ()
8228 "Show thread subtrees.
8229 Returns nil if no thread was there to be shown."
8231 (let ((buffer-read-only nil)
8233 ;; first goto end then to beg, to have point at beg after let
8234 (end (progn (end-of-line) (point)))
8235 (beg (progn (beginning-of-line) (point))))
8237 ;; Any hidden lines here?
8238 (search-forward "\r" end t)
8239 (subst-char-in-region beg end ?\^M ?\n t)
8241 (gnus-summary-position-point))))
8243 (defun gnus-summary-hide-all-threads ()
8244 "Hide all thread subtrees."
8247 (goto-char (point-min))
8248 (gnus-summary-hide-thread)
8249 (while (zerop (gnus-summary-next-thread 1 t))
8250 (gnus-summary-hide-thread)))
8251 (gnus-summary-position-point))
8253 (defun gnus-summary-hide-thread ()
8254 "Hide thread subtrees.
8255 Returns nil if no threads were there to be hidden."
8257 (let ((buffer-read-only nil)
8259 (article (gnus-summary-article-number)))
8261 ;; Go forward until either the buffer ends or the subthread
8263 (when (and (not (eobp))
8264 (or (zerop (gnus-summary-next-thread 1 t))
8265 (goto-char (point-max))))
8267 (if (and (> (point) start)
8268 (search-backward "\n" start t))
8270 (subst-char-in-region start (point) ?\n ?\^M)
8271 (gnus-summary-goto-subject article))
8274 ;;(gnus-summary-position-point)
8277 (defun gnus-summary-go-to-next-thread (&optional previous)
8278 "Go to the same level (or less) next thread.
8279 If PREVIOUS is non-nil, go to previous thread instead.
8280 Return the article number moved to, or nil if moving was impossible."
8281 (let ((level (gnus-summary-thread-level))
8282 (way (if previous -1 1))
8285 (while (and (not (eobp))
8286 (< level (gnus-summary-thread-level)))
8294 (gnus-summary-article-number)
8297 (defun gnus-summary-next-thread (n &optional silent)
8298 "Go to the same level next N'th thread.
8299 If N is negative, search backward instead.
8300 Returns the difference between N and the number of skips actually
8303 If SILENT, don't output messages."
8305 (let ((backward (< n 0))
8308 (gnus-summary-go-to-next-thread backward))
8311 (gnus-summary-position-point))
8312 (when (and (not silent) (/= 0 n))
8313 (gnus-message 7 "No more threads"))
8316 (defun gnus-summary-prev-thread (n)
8317 "Go to the same level previous N'th thread.
8318 Returns the difference between N and the number of skips actually
8321 (gnus-summary-next-thread (- n)))
8323 (defun gnus-summary-go-down-thread ()
8324 "Go down one level in the current thread."
8325 (let ((children (gnus-summary-article-children)))
8327 (gnus-summary-goto-subject (car children)))))
8329 (defun gnus-summary-go-up-thread ()
8330 "Go up one level in the current thread."
8331 (let ((parent (gnus-summary-article-parent)))
8333 (gnus-summary-goto-subject parent))))
8335 (defun gnus-summary-down-thread (n)
8336 "Go down thread N steps.
8337 If N is negative, go up instead.
8338 Returns the difference between N and how many steps down that were
8344 (if up (gnus-summary-go-up-thread)
8345 (gnus-summary-go-down-thread)))
8347 (gnus-summary-position-point)
8349 (gnus-message 7 "Can't go further"))
8352 (defun gnus-summary-up-thread (n)
8353 "Go up thread N steps.
8354 If N is negative, go up instead.
8355 Returns the difference between N and how many steps down that were
8358 (gnus-summary-down-thread (- n)))
8360 (defun gnus-summary-top-thread ()
8361 "Go to the top of the thread."
8363 (while (gnus-summary-go-up-thread))
8364 (gnus-summary-article-number))
8366 (defun gnus-summary-kill-thread (&optional unmark)
8367 "Mark articles under current thread as read.
8368 If the prefix argument is positive, remove any kinds of marks.
8369 If the prefix argument is negative, tick articles instead."
8372 (setq unmark (prefix-numeric-value unmark)))
8373 (let ((articles (gnus-summary-articles-in-thread)))
8375 ;; Expand the thread.
8376 (gnus-summary-show-thread)
8377 ;; Mark all the articles.
8379 (gnus-summary-goto-subject (car articles))
8380 (cond ((null unmark)
8381 (gnus-summary-mark-article-as-read gnus-killed-mark))
8383 (gnus-summary-mark-article-as-unread gnus-unread-mark))
8385 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
8386 (setq articles (cdr articles))))
8387 ;; Hide killed subtrees.
8389 gnus-thread-hide-killed
8390 (gnus-summary-hide-thread))
8391 ;; If marked as read, go to next unread subject.
8393 ;; Go to next unread subject.
8394 (gnus-summary-next-subject 1 t)))
8395 (gnus-set-mode-line 'summary))
8397 ;; Summary sorting commands
8399 (defun gnus-summary-sort-by-number (&optional reverse)
8400 "Sort the summary buffer by article number.
8401 Argument REVERSE means reverse order."
8403 (gnus-summary-sort 'number reverse))
8405 (defun gnus-summary-sort-by-author (&optional reverse)
8406 "Sort the summary buffer by author name alphabetically.
8407 If case-fold-search is non-nil, case of letters is ignored.
8408 Argument REVERSE means reverse order."
8410 (gnus-summary-sort 'author reverse))
8412 (defun gnus-summary-sort-by-subject (&optional reverse)
8413 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8414 If case-fold-search is non-nil, case of letters is ignored.
8415 Argument REVERSE means reverse order."
8417 (gnus-summary-sort 'subject reverse))
8419 (defun gnus-summary-sort-by-date (&optional reverse)
8420 "Sort the summary buffer by date.
8421 Argument REVERSE means reverse order."
8423 (gnus-summary-sort 'date reverse))
8425 (defun gnus-summary-sort-by-score (&optional reverse)
8426 "Sort the summary buffer by score.
8427 Argument REVERSE means reverse order."
8429 (gnus-summary-sort 'score reverse))
8431 (defun gnus-summary-sort-by-lines (&optional reverse)
8432 "Sort the summary buffer by article length.
8433 Argument REVERSE means reverse order."
8435 (gnus-summary-sort 'lines reverse))
8437 (defun gnus-summary-sort (predicate reverse)
8438 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
8439 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
8440 (article (intern (format "gnus-article-sort-by-%s" predicate)))
8441 (gnus-thread-sort-functions
8447 (gnus-article-sort-functions
8452 (,article t2 t1)))))
8454 (gnus-summary-prepare-hook nil))
8455 ;; We do the sorting by regenerating the threads.
8456 (gnus-summary-prepare)
8457 ;; Hide subthreads if needed.
8458 (when (and gnus-show-threads gnus-thread-hide-subtree)
8459 (gnus-summary-hide-all-threads))))
8461 ;; Summary saving commands.
8463 (defun gnus-summary-save-article (&optional n not-saved)
8464 "Save the current article using the default saver function.
8465 If N is a positive number, save the N next articles.
8466 If N is a negative number, save the N previous articles.
8467 If N is nil and any articles have been marked with the process mark,
8468 save those articles instead.
8469 The variable `gnus-default-article-saver' specifies the saver function."
8471 (let* ((articles (gnus-summary-work-articles n))
8472 (save-buffer (save-excursion
8473 (nnheader-set-temp-buffer " *Gnus Save*")))
8474 (num (length articles))
8475 header article file)
8477 (setq header (gnus-summary-article-header
8478 (setq article (pop articles))))
8479 (if (not (vectorp header))
8480 ;; This is a pseudo-article.
8481 (if (assq 'name header)
8482 (gnus-copy-file (cdr (assq 'name header)))
8483 (gnus-message 1 "Article %d is unsaveable" article))
8484 ;; This is a real article.
8485 (save-window-excursion
8486 (gnus-summary-select-article t nil nil article))
8488 (set-buffer save-buffer)
8490 (insert-buffer-substring gnus-original-article-buffer))
8491 (setq file (gnus-article-save save-buffer file num))
8492 (gnus-summary-remove-process-mark article)
8494 (gnus-summary-set-saved-mark article))))
8495 (gnus-kill-buffer save-buffer)
8496 (gnus-summary-position-point)
8497 (gnus-set-mode-line 'summary)
8500 (defun gnus-summary-pipe-output (&optional arg)
8501 "Pipe the current article to a subprocess.
8502 If N is a positive number, pipe the N next articles.
8503 If N is a negative number, pipe the N previous articles.
8504 If N is nil and any articles have been marked with the process mark,
8505 pipe those articles instead."
8507 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8508 (gnus-summary-save-article arg t))
8509 (gnus-configure-windows 'pipe))
8511 (defun gnus-summary-save-article-mail (&optional arg)
8512 "Append the current article to an mail file.
8513 If N is a positive number, save the N next articles.
8514 If N is a negative number, save the N previous articles.
8515 If N is nil and any articles have been marked with the process mark,
8516 save those articles instead."
8518 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8519 (gnus-summary-save-article arg)))
8521 (defun gnus-summary-save-article-rmail (&optional arg)
8522 "Append the current article to an rmail file.
8523 If N is a positive number, save the N next articles.
8524 If N is a negative number, save the N previous articles.
8525 If N is nil and any articles have been marked with the process mark,
8526 save those articles instead."
8528 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
8529 (gnus-summary-save-article arg)))
8531 (defun gnus-summary-save-article-file (&optional arg)
8532 "Append the current article to a file.
8533 If N is a positive number, save the N next articles.
8534 If N is a negative number, save the N previous articles.
8535 If N is nil and any articles have been marked with the process mark,
8536 save those articles instead."
8538 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8539 (gnus-summary-save-article arg)))
8541 (defun gnus-summary-write-article-file (&optional arg)
8542 "Write the current article to a file, deleting the previous file.
8543 If N is a positive number, save the N next articles.
8544 If N is a negative number, save the N previous articles.
8545 If N is nil and any articles have been marked with the process mark,
8546 save those articles instead."
8548 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
8549 (gnus-summary-save-article arg)))
8551 (defun gnus-summary-save-article-body-file (&optional arg)
8552 "Append the current article body to a file.
8553 If N is a positive number, save the N next articles.
8554 If N is a negative number, save the N previous articles.
8555 If N is nil and any articles have been marked with the process mark,
8556 save those articles instead."
8558 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
8559 (gnus-summary-save-article arg)))
8561 (defun gnus-summary-pipe-message (program)
8562 "Pipe the current article through PROGRAM."
8563 (interactive "sProgram: ")
8564 (gnus-summary-select-article)
8565 (let ((mail-header-separator "")
8566 (art-buf (get-buffer gnus-article-buffer)))
8567 (gnus-eval-in-buffer-window gnus-article-buffer
8570 (let ((start (window-start))
8572 (message-pipe-buffer-body program)
8573 (set-window-start (get-buffer-window (current-buffer)) start))))))
8575 (defun gnus-get-split-value (methods)
8576 "Return a value based on the split METHODS."
8577 (let (split-name method result match)
8580 (set-buffer gnus-original-article-buffer)
8582 (nnheader-narrow-to-headers)
8584 (goto-char (point-min))
8585 (setq method (pop methods))
8586 (setq match (car method))
8589 ;; Regular expression.
8591 (re-search-forward match nil t)))
8592 ((gnus-functionp match)
8596 (setq result (funcall match gnus-newsgroup-name))))
8601 (setq result (eval match)))))
8602 (setq split-name (append (cdr method) split-name))
8603 (cond ((stringp result)
8604 (push (expand-file-name
8605 result gnus-article-save-directory)
8608 (setq split-name (append result split-name)))))))))
8611 (defun gnus-valid-move-group-p (group)
8616 (car (gnus-find-method-for-group
8617 (symbol-name group))))
8618 gnus-valid-select-methods))))
8620 (defun gnus-read-move-group-name (prompt default articles prefix)
8621 "Read a group name."
8622 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
8623 (minibuffer-confirm-incomplete nil) ; XEmacs
8627 (if (> (length articles) 1)
8628 (format "these %d articles" (length articles))
8633 (gnus-completing-read default prom
8635 'gnus-valid-move-group-p
8637 'gnus-group-history))
8638 ((= 1 (length split-name))
8639 (gnus-completing-read (car split-name) prom
8641 'gnus-valid-move-group-p
8643 'gnus-group-history))
8645 (gnus-completing-read nil prom
8646 (mapcar (lambda (el) (list el))
8647 (nreverse split-name))
8649 'gnus-group-history)))))
8651 (if (or (string= to-newsgroup "")
8652 (string= to-newsgroup prefix))
8653 (setq to-newsgroup default))
8654 (unless to-newsgroup
8655 (error "No group name entered"))
8656 (or (gnus-active to-newsgroup)
8657 (gnus-activate-group to-newsgroup)
8658 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
8660 (or (and (gnus-request-create-group
8661 to-newsgroup (gnus-group-name-to-method to-newsgroup))
8662 (gnus-activate-group to-newsgroup nil nil
8663 (gnus-group-name-to-method
8665 (error "Couldn't create group %s" to-newsgroup)))
8666 (error "No such group: %s" to-newsgroup)))
8669 ;; Summary extract commands
8671 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
8672 (let ((buffer-read-only nil)
8673 (article (gnus-summary-article-number))
8675 (unless (gnus-summary-goto-subject article)
8676 (error "No such article: %d" article))
8677 (gnus-summary-position-point)
8678 ;; If all commands are to be bunched up on one line, we collect
8680 (unless gnus-view-pseudos-separately
8681 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
8684 (setq action (cdr (assq 'action (car ps))))
8685 (setq files (list (cdr (assq 'name (car ps)))))
8686 (while (and ps (cdr ps)
8687 (string= (or action "1")
8688 (or (cdr (assq 'action (cadr ps))) "2")))
8689 (push (cdr (assq 'name (cadr ps))) files)
8690 (setcdr ps (cddr ps)))
8692 (when (not (string-match "%s" action))
8695 (when (assq 'execute (car ps))
8696 (setcdr (assq 'execute (car ps))
8697 (funcall (if (string-match "%s" action)
8704 (gnus-quote-arg-for-sh-or-csh f)))
8706 (setq ps (cdr ps)))))
8707 (if (and gnus-view-pseudos (not not-view))
8709 (when (assq 'execute (car pslist))
8710 (gnus-execute-command (cdr (assq 'execute (car pslist)))
8711 (eq gnus-view-pseudos 'not-confirm)))
8712 (setq pslist (cdr pslist)))
8715 (setq after-article (or (cdr (assq 'article (car pslist)))
8716 (gnus-summary-article-number)))
8717 (gnus-summary-goto-subject after-article)
8720 (insert " " (file-name-nondirectory
8721 (cdr (assq 'name (car pslist))))
8722 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
8724 (forward-line -1) ; back to `b'
8725 (gnus-add-text-properties
8726 b (1- e) (list 'gnus-number gnus-reffed-article-number
8727 gnus-mouse-face-prop gnus-mouse-face))
8729 after-article gnus-reffed-article-number
8730 gnus-unread-mark b (car pslist) 0 (- e b))
8731 (push gnus-reffed-article-number gnus-newsgroup-unreads)
8732 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
8733 (setq pslist (cdr pslist)))))))
8735 (defun gnus-pseudos< (p1 p2)
8736 (let ((c1 (cdr (assq 'action p1)))
8737 (c2 (cdr (assq 'action p2))))
8738 (and c1 c2 (string< c1 c2))))
8740 (defun gnus-request-pseudo-article (props)
8741 (cond ((assq 'execute props)
8742 (gnus-execute-command (cdr (assq 'execute props)))))
8743 (let ((gnus-current-article (gnus-summary-article-number)))
8744 (gnus-run-hooks 'gnus-mark-article-hook)))
8746 (defun gnus-execute-command (command &optional automatic)
8748 (gnus-article-setup-buffer)
8749 (set-buffer gnus-article-buffer)
8750 (setq buffer-read-only nil)
8751 (let ((command (if automatic command
8752 (read-string "Command: " (cons command 0)))))
8754 (insert "$ " command "\n\n")
8755 (if gnus-view-pseudo-asynchronously
8756 (start-process "gnus-execute" (current-buffer) shell-file-name
8757 shell-command-switch command)
8758 (call-process shell-file-name nil t nil
8759 shell-command-switch command)))))
8761 ;; Summary kill commands.
8763 (defun gnus-summary-edit-global-kill (article)
8764 "Edit the \"global\" kill file."
8765 (interactive (list (gnus-summary-article-number)))
8766 (gnus-group-edit-global-kill article))
8768 (defun gnus-summary-edit-local-kill ()
8769 "Edit a local kill file applied to the current newsgroup."
8771 (setq gnus-current-headers (gnus-summary-article-header))
8772 (gnus-group-edit-local-kill
8773 (gnus-summary-article-number) gnus-newsgroup-name))
8777 (defun gnus-read-header (id &optional header)
8778 "Read the headers of article ID and enter them into the Gnus system."
8779 (let ((group gnus-newsgroup-name)
8780 (gnus-override-method
8781 (and (gnus-news-group-p gnus-newsgroup-name)
8782 gnus-refer-article-method))
8784 ;; First we check to see whether the header in question is already
8787 ;; This is a Message-ID.
8788 (setq header (or header (gnus-id-to-header id)))
8789 ;; This is an article number.
8790 (setq header (or header (gnus-summary-article-header id))))
8792 (not (gnus-summary-article-sparse-p (mail-header-number header))))
8793 ;; We have found the header.
8795 ;; If this is a sparse article, we have to nix out its
8796 ;; previous entry in the thread hashtb.
8798 (gnus-summary-article-sparse-p (mail-header-number header)))
8799 (let* ((parent (gnus-parent-id (mail-header-references header)))
8800 (thread (and parent (gnus-id-to-thread parent))))
8802 (delq (assq header thread) thread))))
8803 ;; We have to really fetch the header to this article.
8805 (set-buffer nntp-server-buffer)
8806 (when (setq where (gnus-request-head id group))
8807 (nnheader-fold-continuation-lines)
8808 (goto-char (point-max))
8810 (goto-char (point-min))
8814 ((cdr where) (cdr where))
8815 (header (mail-header-number header))
8816 (t gnus-reffed-article-number))
8818 (insert " Article retrieved.\n"))
8820 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
8821 () ; Malformed head.
8822 (unless (gnus-summary-article-sparse-p (mail-header-number header))
8823 (when (and (stringp id)
8824 (not (string= (gnus-group-real-name group)
8826 ;; If we fetched by Message-ID and the article came
8827 ;; from a different group, we fudge some bogus article
8828 ;; numbers for this article.
8829 (mail-header-set-number header gnus-reffed-article-number))
8831 (set-buffer gnus-summary-buffer)
8832 (decf gnus-reffed-article-number)
8833 (gnus-remove-header (mail-header-number header))
8834 (push header gnus-newsgroup-headers)
8835 (setq gnus-current-headers header)
8836 (push (mail-header-number header) gnus-newsgroup-limit)))
8839 (defun gnus-remove-header (number)
8840 "Remove header NUMBER from `gnus-newsgroup-headers'."
8841 (if (and gnus-newsgroup-headers
8842 (= number (mail-header-number (car gnus-newsgroup-headers))))
8843 (pop gnus-newsgroup-headers)
8844 (let ((headers gnus-newsgroup-headers))
8845 (while (and (cdr headers)
8846 (not (= number (mail-header-number (cadr headers)))))
8849 (setcdr headers (cddr headers))))))
8852 ;;; summary highlights
8855 (defun gnus-highlight-selected-summary ()
8856 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8857 ;; Highlight selected article in summary buffer
8858 (when gnus-summary-selected-face
8860 (let* ((beg (progn (beginning-of-line) (point)))
8861 (end (progn (end-of-line) (point)))
8862 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
8863 (from (if (get-text-property beg gnus-mouse-face-prop)
8865 (or (next-single-property-change
8866 beg gnus-mouse-face-prop nil end)
8871 (or (next-single-property-change
8872 from gnus-mouse-face-prop nil end)
8874 ;; If no mouse-face prop on line we will have to = from = end,
8875 ;; so we highlight the entire line instead.
8876 (when (= (+ to 2) from)
8879 (if gnus-newsgroup-selected-overlay
8880 ;; Move old overlay.
8882 gnus-newsgroup-selected-overlay from to (current-buffer))
8883 ;; Create new overlay.
8885 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
8886 'face gnus-summary-selected-face))))))
8888 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
8889 (defun gnus-summary-highlight-line ()
8890 "Highlight current line according to `gnus-summary-highlight'."
8891 (let* ((list gnus-summary-highlight)
8893 (end (progn (end-of-line) (point)))
8894 ;; now find out where the line starts and leave point there.
8895 (beg (progn (beginning-of-line) (point)))
8896 (article (gnus-summary-article-number))
8897 (score (or (cdr (assq (or article gnus-current-article)
8898 gnus-newsgroup-scored))
8899 gnus-summary-default-score 0))
8900 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
8901 (inhibit-read-only t))
8902 ;; Eval the cars of the lists until we find a match.
8903 (let ((default gnus-summary-default-score))
8905 (not (eval (caar list))))
8906 (setq list (cdr list))))
8907 (let ((face (cdar list)))
8908 (unless (eq face (get-text-property beg 'face))
8909 (gnus-put-text-property-excluding-characters-with-faces
8911 (setq face (if (boundp face) (symbol-value face) face)))
8912 (when gnus-summary-highlight-line-function
8913 (funcall gnus-summary-highlight-line-function article face))))
8916 (defun gnus-update-read-articles (group unread &optional compute)
8917 "Update the list of read articles in GROUP."
8918 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
8919 (entry (gnus-gethash group gnus-newsrc-hashtb))
8920 (info (nth 2 entry))
8922 (unread (sort (copy-sequence unread) '<))
8924 (if (or (not info) (not active))
8925 ;; There is no info on this group if it was, in fact,
8926 ;; killed. Gnus stores no information on killed groups, so
8927 ;; there's nothing to be done.
8928 ;; One could store the information somewhere temporarily,
8929 ;; perhaps... Hmmm...
8931 ;; Remove any negative articles numbers.
8932 (while (and unread (< (car unread) 0))
8933 (setq unread (cdr unread)))
8934 ;; Remove any expired article numbers
8935 (while (and unread (< (car unread) (car active)))
8936 (setq unread (cdr unread)))
8937 ;; Compute the ranges of read articles by looking at the list of
8940 (when (/= (car unread) prev)
8941 (push (if (= prev (1- (car unread))) prev
8942 (cons prev (1- (car unread))))
8944 (setq prev (1+ (car unread)))
8945 (setq unread (cdr unread)))
8946 (when (<= prev (cdr active))
8947 (push (cons prev (cdr active)) read))
8949 (if (> (length read) 1) (nreverse read) read)
8951 (set-buffer gnus-group-buffer)
8954 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
8955 (gnus-info-set-read ',info ',(gnus-info-read info))
8956 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
8957 (gnus-group-update-group ,group t))))
8958 ;; Enter this list into the group info.
8960 info (if (> (length read) 1) (nreverse read) read))
8961 ;; Set the number of unread articles in gnus-newsrc-hashtb.
8962 (gnus-get-unread-articles-in-group info (gnus-active group))
8965 (defun gnus-offer-save-summaries ()
8966 "Offer to save all active summary buffers."
8968 (let ((buflist (buffer-list))
8970 ;; Go through all buffers and find all summaries.
8972 (and (setq bufname (buffer-name (car buflist)))
8973 (string-match "Summary" bufname)
8975 (set-buffer bufname)
8976 ;; We check that this is, indeed, a summary buffer.
8977 (and (eq major-mode 'gnus-summary-mode)
8978 ;; Also make sure this isn't bogus.
8979 gnus-newsgroup-prepared
8980 ;; Also make sure that this isn't a dead summary buffer.
8981 (not gnus-dead-summary-mode)))
8982 (push bufname buffers))
8983 (setq buflist (cdr buflist)))
8984 ;; Go through all these summary buffers and offer to save them.
8987 "Update summary buffer %s? "
8989 (switch-to-buffer buf)
8990 (gnus-summary-exit))
8994 ;;; @ for mime-partial
8997 (defun gnus-request-partial-message ()
8999 (let ((number (gnus-summary-article-number))
9000 (group gnus-newsgroup-name)
9001 (mother gnus-article-buffer))
9002 (set-buffer (get-buffer-create " *Partial Article*"))
9004 (setq mime-preview-buffer mother)
9005 (gnus-request-article-this-buffer number group)
9009 (autoload 'mime-combine-message/partial-pieces-automatically
9011 "Internal method to combine message/partial messages automatically.")
9014 'action '((type . message)(subtype . partial)
9015 (major-mode . gnus-original-article-mode)
9016 (method . mime-combine-message/partial-pieces-automatically)
9017 (summary-buffer-exp . gnus-summary-buffer)
9018 (request-partial-message-method . gnus-request-partial-message)
9029 (run-hooks 'gnus-sum-load-hook)
9031 ;;; gnus-sum.el ends here