1 ;;; gnus-sum.el --- summary mode commands for Gnus
2 ;; Copyright (C) 1996,97,98 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
28 (eval-when-compile (require 'cl))
37 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
39 (defcustom gnus-kill-summary-on-exit t
40 "*If non-nil, kill the summary buffer when you exit from it.
41 If nil, the summary will become a \"*Dead Summary*\" buffer, and
42 it will be killed sometime later."
43 :group 'gnus-summary-exit
46 (defcustom gnus-fetch-old-headers nil
47 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
48 If an unread article in the group refers to an older, already read (or
49 just marked as read) article, the old article will not normally be
50 displayed in the Summary buffer. If this variable is non-nil, Gnus
51 will attempt to grab the headers to the old articles, and thereby
52 build complete threads. If it has the value `some', only enough
53 headers to connect otherwise loose threads will be displayed. This
54 variable can also be a number. In that case, no more than that number
55 of old headers will be fetched. If it has the value `invisible', all
56 old headers will be fetched, but none will be displayed.
58 The server has to support NOV for any of this to work."
60 :type '(choice (const :tag "off" nil)
63 (sexp :menu-tag "other" t)))
65 (defcustom gnus-refer-thread-limit 200
66 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
67 If t, fetch all the available old headers."
70 (sexp :menu-tag "other" t)))
72 (defcustom gnus-summary-make-false-root 'adopt
73 "*nil means that Gnus won't gather loose threads.
74 If the root of a thread has expired or been read in a previous
75 session, the information necessary to build a complete thread has been
76 lost. Instead of having many small sub-threads from this original thread
77 scattered all over the summary buffer, Gnus can gather them.
79 If non-nil, Gnus will try to gather all loose sub-threads from an
80 original thread into one large thread.
82 If this variable is non-nil, it should be one of `none', `adopt',
85 If this variable is `none', Gnus will not make a false root, but just
86 present the sub-threads after another.
87 If this variable is `dummy', Gnus will create a dummy root that will
88 have all the sub-threads as children.
89 If this variable is `adopt', Gnus will make one of the \"children\"
90 the parent and mark all the step-children as such.
91 If this variable is `empty', the \"children\" are printed with empty
92 subject fields. (Or rather, they will be printed with a string
93 given by the `gnus-summary-same-subject' variable.)"
95 :type '(choice (const :tag "off" nil)
101 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
102 "*A regexp to match subjects to be excluded from loose thread gathering.
103 As loose thread gathering is done on subjects only, that means that
104 there can be many false gatherings performed. By rooting out certain
105 common subjects, gathering might become saner."
109 (defcustom gnus-summary-gather-subject-limit nil
110 "*Maximum length of subject comparisons when gathering loose threads.
111 Use nil to compare full subjects. Setting this variable to a low
112 number will help gather threads that have been corrupted by
113 newsreaders chopping off subject lines, but it might also mean that
114 unrelated articles that have subject that happen to begin with the
115 same few characters will be incorrectly gathered.
117 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
120 :type '(choice (const :tag "off" nil)
122 (sexp :menu-tag "on" t)))
124 (defcustom gnus-simplify-subject-functions nil
125 "List of functions taking a string argument that simplify subjects.
126 The functions are applied recursively.
128 Useful functions to put in this list include: `gnus-simplify-subject-re',
129 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
131 :type '(repeat function))
133 (defcustom gnus-simplify-ignored-prefixes nil
134 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
136 :type '(choice (const :tag "off" nil)
139 (defcustom gnus-build-sparse-threads nil
140 "*If non-nil, fill in the gaps in threads.
141 If `some', only fill in the gaps that are needed to tie loose threads
142 together. If `more', fill in all leaf nodes that Gnus can find. If
143 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
145 :type '(choice (const :tag "off" nil)
148 (sexp :menu-tag "all" t)))
150 (defcustom gnus-summary-thread-gathering-function
151 'gnus-gather-threads-by-subject
152 "*Function used for gathering loose threads.
153 There are two pre-defined functions: `gnus-gather-threads-by-subject',
154 which only takes Subjects into consideration; and
155 `gnus-gather-threads-by-references', which compared the References
156 headers of the articles to find matches."
158 :type '(radio (function-item gnus-gather-threads-by-subject)
159 (function-item gnus-gather-threads-by-references)
160 (function :tag "other")))
162 (defcustom gnus-summary-same-subject ""
163 "*String indicating that the current article has the same subject as the previous.
164 This variable will only be used if the value of
165 `gnus-summary-make-false-root' is `empty'."
166 :group 'gnus-summary-format
169 (defcustom gnus-summary-goto-unread t
170 "*If t, marking commands will go to the next unread article.
171 If `never', commands that usually go to the next unread article, will
172 go to the next article, whether it is read or not.
173 If nil, only the marking commands will go to the next (un)read article."
174 :group 'gnus-summary-marks
175 :link '(custom-manual "(gnus)Setting Marks")
176 :type '(choice (const :tag "off" nil)
178 (sexp :menu-tag "on" t)))
180 (defcustom gnus-summary-default-score 0
181 "*Default article score level.
182 All scores generated by the score files will be added to this score.
183 If this variable is nil, scoring will be disabled."
184 :group 'gnus-score-default
185 :type '(choice (const :tag "disable")
188 (defcustom gnus-summary-zcore-fuzz 0
189 "*Fuzziness factor for the zcore in the summary buffer.
190 Articles with scores closer than this to `gnus-summary-default-score'
192 :group 'gnus-summary-format
195 (defcustom gnus-simplify-subject-fuzzy-regexp nil
196 "*Strings to be removed when doing fuzzy matches.
197 This can either be a regular expression or list of regular expressions
198 that will be removed from subject strings if fuzzy subject
199 simplification is selected."
201 :type '(repeat regexp))
203 (defcustom gnus-show-threads t
204 "*If non-nil, display threads in summary mode."
208 (defcustom gnus-thread-hide-subtree nil
209 "*If non-nil, hide all threads initially.
210 If threads are hidden, you have to run the command
211 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
212 to expose hidden threads."
216 (defcustom gnus-thread-hide-killed t
217 "*If non-nil, hide killed threads automatically."
221 (defcustom gnus-thread-ignore-subject t
222 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
223 If nil, articles that have different subjects from their parents will
224 start separate threads."
228 (defcustom gnus-thread-operation-ignore-subject t
229 "*If non-nil, subjects will be ignored when doing thread commands.
230 This affects commands like `gnus-summary-kill-thread' and
231 `gnus-summary-lower-thread'.
233 If this variable is nil, articles in the same thread with different
234 subjects will not be included in the operation in question. If this
235 variable is `fuzzy', only articles that have subjects that are fuzzily
236 equal will be included."
238 :type '(choice (const :tag "off" nil)
242 (defcustom gnus-thread-indent-level 4
243 "*Number that says how much each sub-thread should be indented."
247 (defcustom gnus-auto-extend-newsgroup t
248 "*If non-nil, extend newsgroup forward and backward when requested."
249 :group 'gnus-summary-choose
252 (defcustom gnus-auto-select-first t
253 "*If nil, don't select the first unread article when entering a group.
254 If this variable is `best', select the highest-scored unread article
255 in the group. If neither nil nor `best', select the first unread
258 If you want to prevent automatic selection of the first unread article
259 in some newsgroups, set the variable to nil in
260 `gnus-select-group-hook'."
261 :group 'gnus-group-select
262 :type '(choice (const :tag "none" nil)
264 (sexp :menu-tag "first" t)))
266 (defcustom gnus-auto-select-next t
267 "*If non-nil, offer to go to the next group from the end of the previous.
268 If the value is t and the next newsgroup is empty, Gnus will exit
269 summary mode and go back to group mode. If the value is neither nil
270 nor t, Gnus will select the following unread newsgroup. In
271 particular, if the value is the symbol `quietly', the next unread
272 newsgroup will be selected without any confirmation, and if it is
273 `almost-quietly', the next group will be selected without any
274 confirmation if you are located on the last article in the group.
275 Finally, if this variable is `slightly-quietly', the `Z n' command
276 will go to the next group without confirmation."
277 :group 'gnus-summary-maneuvering
278 :type '(choice (const :tag "off" nil)
280 (const almost-quietly)
281 (const slightly-quietly)
282 (sexp :menu-tag "on" t)))
284 (defcustom gnus-auto-select-same nil
285 "*If non-nil, select the next article with the same subject.
286 If there are no more articles with the same subject, go to
287 the first unread article."
288 :group 'gnus-summary-maneuvering
291 (defcustom gnus-summary-check-current nil
292 "*If non-nil, consider the current article when moving.
293 The \"unread\" movement commands will stay on the same line if the
294 current article is unread."
295 :group 'gnus-summary-maneuvering
298 (defcustom gnus-auto-center-summary t
299 "*If non-nil, always center the current summary buffer.
300 In particular, if `vertical' do only vertical recentering. If non-nil
301 and non-`vertical', do both horizontal and vertical recentering."
302 :group 'gnus-summary-maneuvering
303 :type '(choice (const :tag "none" nil)
305 (sexp :menu-tag "both" t)))
307 (defcustom gnus-show-all-headers nil
308 "*If non-nil, don't hide any headers."
309 :group 'gnus-article-hiding
310 :group 'gnus-article-headers
313 (defcustom gnus-summary-ignore-duplicates nil
314 "*If non-nil, ignore articles with identical Message-ID headers."
318 (defcustom gnus-single-article-buffer t
319 "*If non-nil, display all articles in the same buffer.
320 If nil, each group will get its own article buffer."
321 :group 'gnus-article-various
324 (defcustom gnus-break-pages t
325 "*If non-nil, do page breaking on articles.
326 The page delimiter is specified by the `gnus-page-delimiter'
328 :group 'gnus-article-various
331 (defcustom gnus-show-mime nil
332 "*If non-nil, do mime processing of articles.
333 The articles will simply be fed to the function given by
334 `gnus-show-mime-method'."
335 :group 'gnus-article-mime
338 (defcustom gnus-move-split-methods nil
339 "*Variable used to suggest where articles are to be moved to.
340 It uses the same syntax as the `gnus-split-methods' variable."
341 :group 'gnus-summary-mail
342 :type '(repeat (choice (list :value (fun) function)
343 (cons :value ("" "") regexp (repeat string))
346 (defcustom gnus-unread-mark ?
347 "*Mark used for unread articles."
348 :group 'gnus-summary-marks
351 (defcustom gnus-ticked-mark ?!
352 "*Mark used for ticked articles."
353 :group 'gnus-summary-marks
356 (defcustom gnus-dormant-mark ??
357 "*Mark used for dormant articles."
358 :group 'gnus-summary-marks
361 (defcustom gnus-del-mark ?r
362 "*Mark used for del'd articles."
363 :group 'gnus-summary-marks
366 (defcustom gnus-read-mark ?R
367 "*Mark used for read articles."
368 :group 'gnus-summary-marks
371 (defcustom gnus-expirable-mark ?E
372 "*Mark used for expirable articles."
373 :group 'gnus-summary-marks
376 (defcustom gnus-killed-mark ?K
377 "*Mark used for killed articles."
378 :group 'gnus-summary-marks
381 (defcustom gnus-souped-mark ?F
382 "*Mark used for killed articles."
383 :group 'gnus-summary-marks
386 (defcustom gnus-kill-file-mark ?X
387 "*Mark used for articles killed by kill files."
388 :group 'gnus-summary-marks
391 (defcustom gnus-low-score-mark ?Y
392 "*Mark used for articles with a low score."
393 :group 'gnus-summary-marks
396 (defcustom gnus-catchup-mark ?C
397 "*Mark used for articles that are caught up."
398 :group 'gnus-summary-marks
401 (defcustom gnus-replied-mark ?A
402 "*Mark used for articles that have been replied to."
403 :group 'gnus-summary-marks
406 (defcustom gnus-cached-mark ?*
407 "*Mark used for articles that are in the cache."
408 :group 'gnus-summary-marks
411 (defcustom gnus-saved-mark ?S
412 "*Mark used for articles that have been saved to."
413 :group 'gnus-summary-marks
416 (defcustom gnus-ancient-mark ?O
417 "*Mark used for ancient articles."
418 :group 'gnus-summary-marks
421 (defcustom gnus-sparse-mark ?Q
422 "*Mark used for sparsely reffed articles."
423 :group 'gnus-summary-marks
426 (defcustom gnus-canceled-mark ?G
427 "*Mark used for canceled articles."
428 :group 'gnus-summary-marks
431 (defcustom gnus-duplicate-mark ?M
432 "*Mark used for duplicate articles."
433 :group 'gnus-summary-marks
436 (defcustom gnus-undownloaded-mark ?@
437 "*Mark used for articles that weren't downloaded."
438 :group 'gnus-summary-marks
441 (defcustom gnus-downloadable-mark ?%
442 "*Mark used for articles that are to be downloaded."
443 :group 'gnus-summary-marks
446 (defcustom gnus-unsendable-mark ?=
447 "*Mark used for articles that won't be sent."
448 :group 'gnus-summary-marks
451 (defcustom gnus-score-over-mark ?+
452 "*Score mark used for articles with high scores."
453 :group 'gnus-summary-marks
456 (defcustom gnus-score-below-mark ?-
457 "*Score mark used for articles with low scores."
458 :group 'gnus-summary-marks
461 (defcustom gnus-empty-thread-mark ?
462 "*There is no thread under the article."
463 :group 'gnus-summary-marks
466 (defcustom gnus-not-empty-thread-mark ?=
467 "*There is a thread under the article."
468 :group 'gnus-summary-marks
471 (defcustom gnus-view-pseudo-asynchronously nil
472 "*If non-nil, Gnus will view pseudo-articles asynchronously."
473 :group 'gnus-extract-view
476 (defcustom gnus-view-pseudos nil
477 "*If `automatic', pseudo-articles will be viewed automatically.
478 If `not-confirm', pseudos will be viewed automatically, and the user
479 will not be asked to confirm the command."
480 :group 'gnus-extract-view
481 :type '(choice (const :tag "off" nil)
483 (const not-confirm)))
485 (defcustom gnus-view-pseudos-separately t
486 "*If non-nil, one pseudo-article will be created for each file to be viewed.
487 If nil, all files that use the same viewing command will be given as a
488 list of parameters to that command."
489 :group 'gnus-extract-view
492 (defcustom gnus-insert-pseudo-articles t
493 "*If non-nil, insert pseudo-articles when decoding articles."
494 :group 'gnus-extract-view
497 (defcustom gnus-summary-dummy-line-format
499 "*The format specification for the dummy roots in the summary buffer.
500 It works along the same lines as a normal formatting string,
501 with some simple extensions.
504 :group 'gnus-threading
507 (defcustom gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
508 "*The format specification for the summary mode line.
509 It works along the same lines as a normal formatting string,
510 with some simple extensions:
513 %p Unprefixed group name
514 %A Current article number
515 %z Current article score
517 %U Number of unread articles in the group
518 %e Number of unselected articles in the group
519 %Z A string with unread/unselected article counts
520 %g Shortish group name
521 %S Subject of the current article
523 %s Current score file name
524 %d Number of dormant articles
525 %r Number of articles that have been marked as read in this session
526 %E Number of articles expunged by the score files"
527 :group 'gnus-summary-format
530 (defcustom gnus-summary-mark-below 0
531 "*Mark all articles with a score below this variable as read.
532 This variable is local to each summary buffer and usually set by the
534 :group 'gnus-score-default
537 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
538 "*List of functions used for sorting articles in the summary buffer.
539 This variable is only used when not using a threaded display."
540 :group 'gnus-summary-sort
541 :type '(repeat (choice (function-item gnus-article-sort-by-number)
542 (function-item gnus-article-sort-by-author)
543 (function-item gnus-article-sort-by-subject)
544 (function-item gnus-article-sort-by-date)
545 (function-item gnus-article-sort-by-score)
546 (function :tag "other"))))
548 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
549 "*List of functions used for sorting threads in the summary buffer.
550 By default, threads are sorted by article number.
552 Each function takes two threads and return non-nil if the first thread
553 should be sorted before the other. If you use more than one function,
554 the primary sort function should be the last. You should probably
555 always include `gnus-thread-sort-by-number' in the list of sorting
556 functions -- preferably first.
558 Ready-made functions include `gnus-thread-sort-by-number',
559 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
560 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
561 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
562 :group 'gnus-summary-sort
563 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
564 (function-item gnus-thread-sort-by-author)
565 (function-item gnus-thread-sort-by-subject)
566 (function-item gnus-thread-sort-by-date)
567 (function-item gnus-thread-sort-by-score)
568 (function-item gnus-thread-sort-by-total-score)
569 (function :tag "other"))))
571 (defcustom gnus-thread-score-function '+
572 "*Function used for calculating the total score of a thread.
574 The function is called with the scores of the article and each
575 subthread and should then return the score of the thread.
577 Some functions you can use are `+', `max', or `min'."
578 :group 'gnus-summary-sort
581 (defcustom gnus-summary-expunge-below nil
582 "All articles that have a score less than this variable will be expunged.
583 This variable is local to the summary buffers."
584 :group 'gnus-score-default
585 :type '(choice (const :tag "off" nil)
588 (defcustom gnus-thread-expunge-below nil
589 "All threads that have a total score less than this variable will be expunged.
590 See `gnus-thread-score-function' for en explanation of what a
593 This variable is local to the summary buffers."
594 :group 'gnus-treading
595 :group 'gnus-score-default
596 :type '(choice (const :tag "off" nil)
599 (defcustom gnus-summary-mode-hook nil
600 "*A hook for Gnus summary mode.
601 This hook is run before any variables are set in the summary buffer."
602 :group 'gnus-summary-various
605 (defcustom gnus-summary-menu-hook nil
606 "*Hook run after the creation of the summary mode menu."
607 :group 'gnus-summary-visual
610 (defcustom gnus-summary-exit-hook nil
611 "*A hook called on exit from the summary buffer.
612 It will be called with point in the group buffer."
613 :group 'gnus-summary-exit
616 (defcustom gnus-summary-prepare-hook nil
617 "*A hook called after the summary buffer has been generated.
618 If you want to modify the summary buffer, you can use this hook."
619 :group 'gnus-summary-various
622 (defcustom gnus-summary-prepared-hook nil
623 "*A hook called as the last thing after the summary buffer has been generated."
624 :group 'gnus-summary-various
627 (defcustom gnus-summary-generate-hook nil
628 "*A hook run just before generating the summary buffer.
629 This hook is commonly used to customize threading variables and the
631 :group 'gnus-summary-various
634 (defcustom gnus-select-group-hook nil
635 "*A hook called when a newsgroup is selected.
637 If you'd like to simplify subjects like the
638 `gnus-summary-next-same-subject' command does, you can use the
641 (setq gnus-select-group-hook
644 (mapcar (lambda (header)
645 (mail-header-set-subject
647 (gnus-simplify-subject
648 (mail-header-subject header) 're-only)))
649 gnus-newsgroup-headers))))"
650 :group 'gnus-group-select
653 (defcustom gnus-select-article-hook nil
654 "*A hook called when an article is selected."
655 :group 'gnus-summary-choose
658 (defcustom gnus-visual-mark-article-hook
659 (list 'gnus-highlight-selected-summary)
660 "*Hook run after selecting an article in the summary buffer.
661 It is meant to be used for highlighting the article in some way. It
662 is not run if `gnus-visual' is nil."
663 :group 'gnus-summary-visual
666 (defcustom gnus-structured-field-decoder 'identity
667 "Function to decode non-ASCII characters in structured field for summary."
671 (defcustom gnus-unstructured-field-decoder 'identity
672 "Function to decode non-ASCII characters in unstructured field for summary."
676 (defcustom gnus-parse-headers-hook
677 (list 'gnus-hack-decode-rfc1522 'gnus-decode-rfc1522)
678 "*A hook called before parsing the headers."
682 (defcustom gnus-exit-group-hook nil
683 "*A hook called when exiting (not quitting) summary mode."
687 (defcustom gnus-summary-update-hook
688 (list 'gnus-summary-highlight-line)
689 "*A hook called when a summary line is changed.
690 The hook will not be called if `gnus-visual' is nil.
692 The default function `gnus-summary-highlight-line' will
693 highlight the line according to the `gnus-summary-highlight'
695 :group 'gnus-summary-visual
698 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
699 "*A hook called when an article is selected for the first time.
700 The hook is intended to mark an article as read (or unread)
701 automatically when it is selected."
702 :group 'gnus-summary-choose
705 (defcustom gnus-group-no-more-groups-hook nil
706 "*A hook run when returning to group mode having no more (unread) groups."
707 :group 'gnus-group-select
710 (defcustom gnus-ps-print-hook nil
711 "*A hook run before ps-printing something from Gnus."
715 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
716 "Face used for highlighting the current article in the summary buffer."
717 :group 'gnus-summary-visual
720 (defcustom gnus-summary-highlight
721 '(((= mark gnus-canceled-mark)
722 . gnus-summary-cancelled-face)
723 ((and (> score default)
724 (or (= mark gnus-dormant-mark)
725 (= mark gnus-ticked-mark)))
726 . gnus-summary-high-ticked-face)
727 ((and (< score default)
728 (or (= mark gnus-dormant-mark)
729 (= mark gnus-ticked-mark)))
730 . gnus-summary-low-ticked-face)
731 ((or (= mark gnus-dormant-mark)
732 (= mark gnus-ticked-mark))
733 . gnus-summary-normal-ticked-face)
734 ((and (> score default) (= mark gnus-ancient-mark))
735 . gnus-summary-high-ancient-face)
736 ((and (< score default) (= mark gnus-ancient-mark))
737 . gnus-summary-low-ancient-face)
738 ((= mark gnus-ancient-mark)
739 . gnus-summary-normal-ancient-face)
740 ((and (> score default) (= mark gnus-unread-mark))
741 . gnus-summary-high-unread-face)
742 ((and (< score default) (= mark gnus-unread-mark))
743 . gnus-summary-low-unread-face)
744 ((= mark gnus-unread-mark)
745 . gnus-summary-normal-unread-face)
746 ((and (> score default) (memq mark (list gnus-downloadable-mark
747 gnus-undownloaded-mark)))
748 . gnus-summary-high-unread-face)
749 ((and (< score default) (memq mark (list gnus-downloadable-mark
750 gnus-undownloaded-mark)))
751 . gnus-summary-low-unread-face)
752 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
753 . gnus-summary-normal-unread-face)
755 . gnus-summary-high-read-face)
757 . gnus-summary-low-read-face)
759 . gnus-summary-normal-read-face))
760 "*Controls the highlighting of summary buffer lines.
762 A list of (FORM . FACE) pairs. When deciding how a a particular
763 summary line should be displayed, each form is evaluated. The content
764 of the face field after the first true form is used. You can change
765 how those summary lines are displayed, by editing the face field.
767 You can use the following variables in the FORM field.
769 score: The articles score
770 default: The default article score.
771 below: The score below which articles are automatically marked as read.
772 mark: The articles mark."
773 :group 'gnus-summary-visual
774 :type '(repeat (cons (sexp :tag "Form" nil)
777 (defcustom gnus-alter-header-function nil
778 "Function called to allow alteration of article header structures.
779 The function is called with one parameter, the article header vector,
780 which it may alter in any way.")
782 ;;; Internal variables
784 (defvar gnus-scores-exclude-files nil)
785 (defvar gnus-page-broken nil)
787 (defvar gnus-original-article nil)
788 (defvar gnus-article-internal-prepare-hook nil)
789 (defvar gnus-newsgroup-process-stack nil)
791 (defvar gnus-thread-indent-array nil)
792 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
794 ;; Avoid highlighting in kill files.
795 (defvar gnus-summary-inhibit-highlight nil)
796 (defvar gnus-newsgroup-selected-overlay nil)
797 (defvar gnus-inhibit-limiting nil)
798 (defvar gnus-newsgroup-adaptive-score-file nil)
799 (defvar gnus-current-score-file nil)
800 (defvar gnus-current-move-group nil)
801 (defvar gnus-current-copy-group nil)
802 (defvar gnus-current-crosspost-group nil)
804 (defvar gnus-newsgroup-dependencies nil)
805 (defvar gnus-newsgroup-adaptive nil)
806 (defvar gnus-summary-display-article-function nil)
807 (defvar gnus-summary-highlight-line-function nil
808 "Function called after highlighting a summary line.")
810 (defvar gnus-summary-line-format-alist
811 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
812 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
813 (?s gnus-tmp-subject-or-nil ?s)
814 (?n gnus-tmp-name ?s)
815 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
817 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
819 (?F gnus-tmp-from ?s)
820 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
821 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
822 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
823 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
824 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
825 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
826 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
827 (?L gnus-tmp-lines ?d)
828 (?I gnus-tmp-indentation ?s)
829 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
830 (?R gnus-tmp-replied ?c)
831 (?\[ gnus-tmp-opening-bracket ?c)
832 (?\] gnus-tmp-closing-bracket ?c)
833 (?\> (make-string gnus-tmp-level ? ) ?s)
834 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
835 (?i gnus-tmp-score ?d)
836 (?z gnus-tmp-score-char ?c)
837 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
838 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
839 (?U gnus-tmp-unread ?c)
840 (?t (gnus-summary-number-of-articles-in-thread
841 (and (boundp 'thread) (car thread)) gnus-tmp-level)
843 (?e (gnus-summary-number-of-articles-in-thread
844 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
846 (?u gnus-tmp-user-defined ?s)
847 (?P (gnus-pick-line-number) ?d))
848 "An alist of format specifications that can appear in summary lines,
849 and what variables they correspond with, along with the type of the
850 variable (string, integer, character, etc).")
852 (defvar gnus-summary-dummy-line-format-alist
853 `((?S gnus-tmp-subject ?s)
854 (?N gnus-tmp-number ?d)
855 (?u gnus-tmp-user-defined ?s)))
857 (defvar gnus-summary-mode-line-format-alist
858 `((?G gnus-tmp-group-name ?s)
859 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
860 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
861 (?A gnus-tmp-article-number ?d)
862 (?Z gnus-tmp-unread-and-unselected ?s)
864 (?U gnus-tmp-unread-and-unticked ?d)
865 (?S gnus-tmp-subject ?s)
866 (?e gnus-tmp-unselected ?d)
867 (?u gnus-tmp-user-defined ?s)
868 (?d (length gnus-newsgroup-dormant) ?d)
869 (?t (length gnus-newsgroup-marked) ?d)
870 (?r (length gnus-newsgroup-reads) ?d)
871 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
872 (?E gnus-newsgroup-expunged-tally ?d)
873 (?s (gnus-current-score-file-nondirectory) ?s)))
875 (defvar gnus-last-search-regexp nil
876 "Default regexp for article search command.")
878 (defvar gnus-last-shell-command nil
879 "Default shell command on article.")
881 (defvar gnus-newsgroup-begin nil)
882 (defvar gnus-newsgroup-end nil)
883 (defvar gnus-newsgroup-last-rmail nil)
884 (defvar gnus-newsgroup-last-mail nil)
885 (defvar gnus-newsgroup-last-folder nil)
886 (defvar gnus-newsgroup-last-file nil)
887 (defvar gnus-newsgroup-auto-expire nil)
888 (defvar gnus-newsgroup-active nil)
890 (defvar gnus-newsgroup-data nil)
891 (defvar gnus-newsgroup-data-reverse nil)
892 (defvar gnus-newsgroup-limit nil)
893 (defvar gnus-newsgroup-limits nil)
895 (defvar gnus-newsgroup-unreads nil
896 "List of unread articles in the current newsgroup.")
898 (defvar gnus-newsgroup-unselected nil
899 "List of unselected unread articles in the current newsgroup.")
901 (defvar gnus-newsgroup-reads nil
902 "Alist of read articles and article marks in the current newsgroup.")
904 (defvar gnus-newsgroup-expunged-tally nil)
906 (defvar gnus-newsgroup-marked nil
907 "List of ticked articles in the current newsgroup (a subset of unread art).")
909 (defvar gnus-newsgroup-killed nil
910 "List of ranges of articles that have been through the scoring process.")
912 (defvar gnus-newsgroup-cached nil
913 "List of articles that come from the article cache.")
915 (defvar gnus-newsgroup-saved nil
916 "List of articles that have been saved.")
918 (defvar gnus-newsgroup-kill-headers nil)
920 (defvar gnus-newsgroup-replied nil
921 "List of articles that have been replied to in the current newsgroup.")
923 (defvar gnus-newsgroup-expirable nil
924 "List of articles in the current newsgroup that can be expired.")
926 (defvar gnus-newsgroup-processable nil
927 "List of articles in the current newsgroup that can be processed.")
929 (defvar gnus-newsgroup-downloadable nil
930 "List of articles in the current newsgroup that can be processed.")
932 (defvar gnus-newsgroup-undownloaded nil
933 "List of articles in the current newsgroup that haven't been downloaded..")
935 (defvar gnus-newsgroup-unsendable nil
936 "List of articles in the current newsgroup that won't be sent.")
938 (defvar gnus-newsgroup-bookmarks nil
939 "List of articles in the current newsgroup that have bookmarks.")
941 (defvar gnus-newsgroup-dormant nil
942 "List of dormant articles in the current newsgroup.")
944 (defvar gnus-newsgroup-scored nil
945 "List of scored articles in the current newsgroup.")
947 (defvar gnus-newsgroup-headers nil
948 "List of article headers in the current newsgroup.")
950 (defvar gnus-newsgroup-threads nil)
952 (defvar gnus-newsgroup-prepared nil
953 "Whether the current group has been prepared properly.")
955 (defvar gnus-newsgroup-ancient nil
956 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
958 (defvar gnus-newsgroup-sparse nil)
960 (defvar gnus-current-article nil)
961 (defvar gnus-article-current nil)
962 (defvar gnus-current-headers nil)
963 (defvar gnus-have-all-headers nil)
964 (defvar gnus-last-article nil)
965 (defvar gnus-newsgroup-history nil)
967 (defconst gnus-summary-local-variables
968 '(gnus-newsgroup-name
969 gnus-newsgroup-begin gnus-newsgroup-end
970 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
971 gnus-newsgroup-last-folder gnus-newsgroup-last-file
972 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
973 gnus-newsgroup-unselected gnus-newsgroup-marked
974 gnus-newsgroup-reads gnus-newsgroup-saved
975 gnus-newsgroup-replied gnus-newsgroup-expirable
976 gnus-newsgroup-processable gnus-newsgroup-killed
977 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
978 gnus-newsgroup-unsendable
979 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
980 gnus-newsgroup-headers gnus-newsgroup-threads
981 gnus-newsgroup-prepared gnus-summary-highlight-line-function
982 gnus-current-article gnus-current-headers gnus-have-all-headers
983 gnus-last-article gnus-article-internal-prepare-hook
984 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
985 gnus-newsgroup-scored gnus-newsgroup-kill-headers
986 gnus-thread-expunge-below
987 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
988 (gnus-summary-mark-below . global)
989 gnus-newsgroup-active gnus-scores-exclude-files
990 gnus-newsgroup-history gnus-newsgroup-ancient
991 gnus-newsgroup-sparse gnus-newsgroup-process-stack
992 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
993 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
994 (gnus-newsgroup-expunged-tally . 0)
995 gnus-cache-removable-articles gnus-newsgroup-cached
996 gnus-newsgroup-data gnus-newsgroup-data-reverse
997 gnus-newsgroup-limit gnus-newsgroup-limits)
998 "Variables that are buffer-local to the summary buffers.")
1000 ;; Byte-compiler warning.
1001 (defvar gnus-article-mode-map)
1003 ;; Subject simplification.
1005 (defun gnus-simplify-whitespace (str)
1006 "Remove excessive whitespace."
1009 (while (string-match "[ \t][ \t]+" mystr)
1010 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1012 (substring mystr (match-end 0)))))
1014 (when (string-match "^[ \t]+" mystr)
1015 (setq mystr (substring mystr (match-end 0))))
1017 (when (string-match "[ \t]+$" mystr)
1018 (setq mystr (substring mystr 0 (match-beginning 0))))
1021 (defsubst gnus-simplify-subject-re (subject)
1022 "Remove \"Re:\" from subject lines."
1023 (if (string-match "^[Rr][Ee]: *" subject)
1024 (substring subject (match-end 0))
1027 (defun gnus-simplify-subject (subject &optional re-only)
1028 "Remove `Re:' and words in parentheses.
1029 If RE-ONLY is non-nil, strip leading `Re:'s only."
1030 (let ((case-fold-search t)) ;Ignore case.
1031 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1032 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1033 (setq subject (substring subject (match-end 0))))
1034 ;; Remove uninteresting prefixes.
1035 (when (and (not re-only)
1036 gnus-simplify-ignored-prefixes
1037 (string-match gnus-simplify-ignored-prefixes subject))
1038 (setq subject (substring subject (match-end 0))))
1039 ;; Remove words in parentheses from end.
1041 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1042 (setq subject (substring subject 0 (match-beginning 0)))))
1043 ;; Return subject string.
1046 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1048 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1049 (goto-char (point-min))
1050 (while (re-search-forward regexp nil t)
1051 (replace-match (or newtext ""))))
1053 (defun gnus-simplify-buffer-fuzzy ()
1054 "Simplify string in the buffer fuzzily.
1055 The string in the accessible portion of the current buffer is simplified.
1056 It is assumed to be a single-line subject.
1057 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1058 matter is removed. Additional things can be deleted by setting
1059 gnus-simplify-subject-fuzzy-regexp."
1060 (let ((case-fold-search t)
1062 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1064 (while (not (eq modified-tick (buffer-modified-tick)))
1065 (setq modified-tick (buffer-modified-tick))
1067 ((listp gnus-simplify-subject-fuzzy-regexp)
1068 (mapcar 'gnus-simplify-buffer-fuzzy-step
1069 gnus-simplify-subject-fuzzy-regexp))
1070 (gnus-simplify-subject-fuzzy-regexp
1071 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1072 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1073 (gnus-simplify-buffer-fuzzy-step
1074 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1075 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1077 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1078 (gnus-simplify-buffer-fuzzy-step " +" " ")
1079 (gnus-simplify-buffer-fuzzy-step " $")
1080 (gnus-simplify-buffer-fuzzy-step "^ +")))
1082 (defun gnus-simplify-subject-fuzzy (subject)
1083 "Simplify a subject string fuzzily.
1084 See `gnus-simplify-buffer-fuzzy' for details."
1086 (gnus-set-work-buffer)
1087 (let ((case-fold-search t))
1088 ;; Remove uninteresting prefixes.
1089 (when (and gnus-simplify-ignored-prefixes
1090 (string-match gnus-simplify-ignored-prefixes subject))
1091 (setq subject (substring subject (match-end 0))))
1093 (inline (gnus-simplify-buffer-fuzzy))
1096 (defsubst gnus-simplify-subject-fully (subject)
1097 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1099 (gnus-simplify-subject-functions
1100 (gnus-map-function gnus-simplify-subject-functions subject))
1101 ((null gnus-summary-gather-subject-limit)
1102 (gnus-simplify-subject-re subject))
1103 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1104 (gnus-simplify-subject-fuzzy subject))
1105 ((numberp gnus-summary-gather-subject-limit)
1106 (gnus-limit-string (gnus-simplify-subject-re subject)
1107 gnus-summary-gather-subject-limit))
1111 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1112 "Check whether two subjects are equal.
1113 If optional argument simple-first is t, first argument is already
1116 ((null simple-first)
1117 (equal (gnus-simplify-subject-fully s1)
1118 (gnus-simplify-subject-fully s2)))
1121 (gnus-simplify-subject-fully s2)))))
1123 (defun gnus-summary-bubble-group ()
1124 "Increase the score of the current group.
1125 This is a handy function to add to `gnus-summary-exit-hook' to
1126 increase the score of each group you read."
1127 (gnus-group-add-score gnus-newsgroup-name))
1131 ;;; Gnus summary mode
1134 (put 'gnus-summary-mode 'mode-class 'special)
1137 ;; Non-orthogonal keys
1139 (gnus-define-keys gnus-summary-mode-map
1140 " " gnus-summary-next-page
1141 "\177" gnus-summary-prev-page
1142 [delete] gnus-summary-prev-page
1143 [backspace] gnus-summary-prev-page
1144 "\r" gnus-summary-scroll-up
1145 "n" gnus-summary-next-unread-article
1146 "p" gnus-summary-prev-unread-article
1147 "N" gnus-summary-next-article
1148 "P" gnus-summary-prev-article
1149 "\M-\C-n" gnus-summary-next-same-subject
1150 "\M-\C-p" gnus-summary-prev-same-subject
1151 "\M-n" gnus-summary-next-unread-subject
1152 "\M-p" gnus-summary-prev-unread-subject
1153 "." gnus-summary-first-unread-article
1154 "," gnus-summary-best-unread-article
1155 "\M-s" gnus-summary-search-article-forward
1156 "\M-r" gnus-summary-search-article-backward
1157 "<" gnus-summary-beginning-of-article
1158 ">" gnus-summary-end-of-article
1159 "j" gnus-summary-goto-article
1160 "^" gnus-summary-refer-parent-article
1161 "\M-^" gnus-summary-refer-article
1162 "u" gnus-summary-tick-article-forward
1163 "!" gnus-summary-tick-article-forward
1164 "U" gnus-summary-tick-article-backward
1165 "d" gnus-summary-mark-as-read-forward
1166 "D" gnus-summary-mark-as-read-backward
1167 "E" gnus-summary-mark-as-expirable
1168 "\M-u" gnus-summary-clear-mark-forward
1169 "\M-U" gnus-summary-clear-mark-backward
1170 "k" gnus-summary-kill-same-subject-and-select
1171 "\C-k" gnus-summary-kill-same-subject
1172 "\M-\C-k" gnus-summary-kill-thread
1173 "\M-\C-l" gnus-summary-lower-thread
1174 "e" gnus-summary-edit-article
1175 "#" gnus-summary-mark-as-processable
1176 "\M-#" gnus-summary-unmark-as-processable
1177 "\M-\C-t" gnus-summary-toggle-threads
1178 "\M-\C-s" gnus-summary-show-thread
1179 "\M-\C-h" gnus-summary-hide-thread
1180 "\M-\C-f" gnus-summary-next-thread
1181 "\M-\C-b" gnus-summary-prev-thread
1182 "\M-\C-u" gnus-summary-up-thread
1183 "\M-\C-d" gnus-summary-down-thread
1184 "&" gnus-summary-execute-command
1185 "c" gnus-summary-catchup-and-exit
1186 "\C-w" gnus-summary-mark-region-as-read
1187 "\C-t" gnus-summary-toggle-truncation
1188 "?" gnus-summary-mark-as-dormant
1189 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1190 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1191 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1192 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1193 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1194 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1195 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1196 "=" gnus-summary-expand-window
1197 "\C-x\C-s" gnus-summary-reselect-current-group
1198 "\M-g" gnus-summary-rescan-group
1199 "w" gnus-summary-stop-page-breaking
1200 "\C-c\C-r" gnus-summary-caesar-message
1201 "\M-t" gnus-summary-toggle-mime
1202 "f" gnus-summary-followup
1203 "F" gnus-summary-followup-with-original
1204 "C" gnus-summary-cancel-article
1205 "r" gnus-summary-reply
1206 "R" gnus-summary-reply-with-original
1207 "\C-c\C-f" gnus-summary-mail-forward
1208 "o" gnus-summary-save-article
1209 "\C-o" gnus-summary-save-article-mail
1210 "|" gnus-summary-pipe-output
1211 "\M-k" gnus-summary-edit-local-kill
1212 "\M-K" gnus-summary-edit-global-kill
1214 "\C-c\C-d" gnus-summary-describe-group
1215 "q" gnus-summary-exit
1216 "Q" gnus-summary-exit-no-update
1217 "\C-c\C-i" gnus-info-find-node
1218 gnus-mouse-2 gnus-mouse-pick-article
1219 "m" gnus-summary-mail-other-window
1220 "a" gnus-summary-post-news
1221 "x" gnus-summary-limit-to-unread
1222 "s" gnus-summary-isearch-article
1223 "t" gnus-article-hide-headers
1224 "g" gnus-summary-show-article
1225 "l" gnus-summary-goto-last-article
1226 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1227 "\C-d" gnus-summary-enter-digest-group
1228 "\M-\C-d" gnus-summary-read-document
1229 "\M-\C-e" gnus-summary-edit-parameters
1231 "*" gnus-cache-enter-article
1232 "\M-*" gnus-cache-remove-article
1233 "\M-&" gnus-summary-universal-argument
1234 "\C-l" gnus-recenter
1235 "I" gnus-summary-increase-score
1236 "L" gnus-summary-lower-score
1237 "\M-i" gnus-symbolic-argument
1238 "h" gnus-summary-select-article-buffer
1240 "V" gnus-summary-score-map
1241 "X" gnus-uu-extract-map
1242 "S" gnus-summary-send-map)
1244 ;; Sort of orthogonal keymap
1245 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1246 "t" gnus-summary-tick-article-forward
1247 "!" gnus-summary-tick-article-forward
1248 "d" gnus-summary-mark-as-read-forward
1249 "r" gnus-summary-mark-as-read-forward
1250 "c" gnus-summary-clear-mark-forward
1251 " " gnus-summary-clear-mark-forward
1252 "e" gnus-summary-mark-as-expirable
1253 "x" gnus-summary-mark-as-expirable
1254 "?" gnus-summary-mark-as-dormant
1255 "b" gnus-summary-set-bookmark
1256 "B" gnus-summary-remove-bookmark
1257 "#" gnus-summary-mark-as-processable
1258 "\M-#" gnus-summary-unmark-as-processable
1259 "S" gnus-summary-limit-include-expunged
1260 "C" gnus-summary-catchup
1261 "H" gnus-summary-catchup-to-here
1262 "\C-c" gnus-summary-catchup-all
1263 "k" gnus-summary-kill-same-subject-and-select
1264 "K" gnus-summary-kill-same-subject
1265 "P" gnus-uu-mark-map)
1267 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1268 "c" gnus-summary-clear-above
1269 "u" gnus-summary-tick-above
1270 "m" gnus-summary-mark-above
1271 "k" gnus-summary-kill-below)
1273 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1274 "/" gnus-summary-limit-to-subject
1275 "n" gnus-summary-limit-to-articles
1276 "w" gnus-summary-pop-limit
1277 "s" gnus-summary-limit-to-subject
1278 "a" gnus-summary-limit-to-author
1279 "u" gnus-summary-limit-to-unread
1280 "m" gnus-summary-limit-to-marks
1281 "v" gnus-summary-limit-to-score
1282 "*" gnus-summary-limit-include-cached
1283 "D" gnus-summary-limit-include-dormant
1284 "T" gnus-summary-limit-include-thread
1285 "d" gnus-summary-limit-exclude-dormant
1286 "t" gnus-summary-limit-to-age
1287 "E" gnus-summary-limit-include-expunged
1288 "c" gnus-summary-limit-exclude-childless-dormant
1289 "C" gnus-summary-limit-mark-excluded-as-read)
1291 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1292 "n" gnus-summary-next-unread-article
1293 "p" gnus-summary-prev-unread-article
1294 "N" gnus-summary-next-article
1295 "P" gnus-summary-prev-article
1296 "\C-n" gnus-summary-next-same-subject
1297 "\C-p" gnus-summary-prev-same-subject
1298 "\M-n" gnus-summary-next-unread-subject
1299 "\M-p" gnus-summary-prev-unread-subject
1300 "f" gnus-summary-first-unread-article
1301 "b" gnus-summary-best-unread-article
1302 "j" gnus-summary-goto-article
1303 "g" gnus-summary-goto-subject
1304 "l" gnus-summary-goto-last-article
1305 "o" gnus-summary-pop-article)
1307 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1308 "k" gnus-summary-kill-thread
1309 "l" gnus-summary-lower-thread
1310 "i" gnus-summary-raise-thread
1311 "T" gnus-summary-toggle-threads
1312 "t" gnus-summary-rethread-current
1313 "^" gnus-summary-reparent-thread
1314 "s" gnus-summary-show-thread
1315 "S" gnus-summary-show-all-threads
1316 "h" gnus-summary-hide-thread
1317 "H" gnus-summary-hide-all-threads
1318 "n" gnus-summary-next-thread
1319 "p" gnus-summary-prev-thread
1320 "u" gnus-summary-up-thread
1321 "o" gnus-summary-top-thread
1322 "d" gnus-summary-down-thread
1323 "#" gnus-uu-mark-thread
1324 "\M-#" gnus-uu-unmark-thread)
1326 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1327 "g" gnus-summary-prepare
1328 "c" gnus-summary-insert-cached-articles)
1330 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1331 "c" gnus-summary-catchup-and-exit
1332 "C" gnus-summary-catchup-all-and-exit
1333 "E" gnus-summary-exit-no-update
1334 "Q" gnus-summary-exit
1335 "Z" gnus-summary-exit
1336 "n" gnus-summary-catchup-and-goto-next-group
1337 "R" gnus-summary-reselect-current-group
1338 "G" gnus-summary-rescan-group
1339 "N" gnus-summary-next-group
1340 "s" gnus-summary-save-newsrc
1341 "P" gnus-summary-prev-group)
1343 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1344 " " gnus-summary-next-page
1345 "n" gnus-summary-next-page
1346 "\177" gnus-summary-prev-page
1347 [delete] gnus-summary-prev-page
1348 "p" gnus-summary-prev-page
1349 "\r" gnus-summary-scroll-up
1350 "<" gnus-summary-beginning-of-article
1351 ">" gnus-summary-end-of-article
1352 "b" gnus-summary-beginning-of-article
1353 "e" gnus-summary-end-of-article
1354 "^" gnus-summary-refer-parent-article
1355 "r" gnus-summary-refer-parent-article
1356 "R" gnus-summary-refer-references
1357 "T" gnus-summary-refer-thread
1358 "g" gnus-summary-show-article
1359 "s" gnus-summary-isearch-article
1360 "P" gnus-summary-print-article)
1362 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1363 "b" gnus-article-add-buttons
1364 "B" gnus-article-add-buttons-to-head
1365 "o" gnus-article-treat-overstrike
1366 "e" gnus-article-emphasize
1367 "w" gnus-article-fill-cited-article
1368 "c" gnus-article-remove-cr
1369 "q" gnus-article-de-quoted-unreadable
1370 "f" gnus-article-display-x-face
1371 "l" gnus-summary-stop-page-breaking
1372 "r" gnus-summary-caesar-message
1373 "t" gnus-article-hide-headers
1374 "v" gnus-summary-verbose-headers
1375 "m" gnus-summary-toggle-mime
1376 "h" gnus-article-treat-html
1377 "d" gnus-article-treat-dumbquotes)
1379 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1380 "a" gnus-article-hide
1381 "h" gnus-article-hide-headers
1382 "b" gnus-article-hide-boring-headers
1383 "s" gnus-article-hide-signature
1384 "c" gnus-article-hide-citation
1385 "C" gnus-article-hide-citation-in-followups
1386 "p" gnus-article-hide-pgp
1387 "P" gnus-article-hide-pem
1388 "\C-c" gnus-article-hide-citation-maybe)
1390 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1391 "a" gnus-article-highlight
1392 "h" gnus-article-highlight-headers
1393 "c" gnus-article-highlight-citation
1394 "s" gnus-article-highlight-signature)
1396 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1397 "z" gnus-article-date-ut
1398 "u" gnus-article-date-ut
1399 "l" gnus-article-date-local
1400 "e" gnus-article-date-lapsed
1401 "o" gnus-article-date-original
1402 "i" gnus-article-date-iso8601
1403 "s" gnus-article-date-user)
1405 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1406 "t" gnus-article-remove-trailing-blank-lines
1407 "l" gnus-article-strip-leading-blank-lines
1408 "m" gnus-article-strip-multiple-blank-lines
1409 "a" gnus-article-strip-blank-lines
1410 "A" gnus-article-strip-all-blank-lines
1411 "s" gnus-article-strip-leading-space)
1413 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1415 "f" gnus-summary-fetch-faq
1416 "d" gnus-summary-describe-group
1417 "h" gnus-summary-describe-briefly
1418 "i" gnus-info-find-node)
1420 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1421 "e" gnus-summary-expire-articles
1422 "\M-\C-e" gnus-summary-expire-articles-now
1423 "\177" gnus-summary-delete-article
1424 [delete] gnus-summary-delete-article
1425 "m" gnus-summary-move-article
1426 "r" gnus-summary-respool-article
1427 "w" gnus-summary-edit-article
1428 "c" gnus-summary-copy-article
1429 "B" gnus-summary-crosspost-article
1430 "q" gnus-summary-respool-query
1431 "t" gnus-summary-respool-trace
1432 "i" gnus-summary-import-article
1433 "p" gnus-summary-article-posted-p)
1435 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1436 "o" gnus-summary-save-article
1437 "m" gnus-summary-save-article-mail
1438 "F" gnus-summary-write-article-file
1439 "r" gnus-summary-save-article-rmail
1440 "f" gnus-summary-save-article-file
1441 "b" gnus-summary-save-article-body-file
1442 "h" gnus-summary-save-article-folder
1443 "v" gnus-summary-save-article-vm
1444 "p" gnus-summary-pipe-output
1445 "s" gnus-soup-add-article))
1447 (defun gnus-summary-make-menu-bar ()
1448 (gnus-turn-off-edit-menu 'summary)
1450 (unless (boundp 'gnus-summary-misc-menu)
1453 gnus-summary-kill-menu gnus-summary-mode-map ""
1458 ["Enter score..." gnus-summary-score-entry t]
1459 ["Customize" gnus-score-customize t])
1460 (gnus-make-score-map 'increase)
1461 (gnus-make-score-map 'lower)
1463 ["Kill below" gnus-summary-kill-below t]
1464 ["Mark above" gnus-summary-mark-above t]
1465 ["Tick above" gnus-summary-tick-above t]
1466 ["Clear above" gnus-summary-clear-above t])
1467 ["Current score" gnus-summary-current-score t]
1468 ["Set score" gnus-summary-set-score t]
1469 ["Switch current score file..." gnus-score-change-score-file t]
1470 ["Set mark below..." gnus-score-set-mark-below t]
1471 ["Set expunge below..." gnus-score-set-expunge-below t]
1472 ["Edit current score file" gnus-score-edit-current-scores t]
1473 ["Edit score file" gnus-score-edit-file t]
1474 ["Trace score" gnus-score-find-trace t]
1475 ["Find words" gnus-score-find-favourite-words t]
1476 ["Rescore buffer" gnus-summary-rescore t]
1477 ["Increase score..." gnus-summary-increase-score t]
1478 ["Lower score..." gnus-summary-lower-score t]))))
1480 ;; Define both the Article menu in the summary buffer and the equivalent
1481 ;; Commands menu in the article buffer here for consistency.
1484 ["All" gnus-article-hide t]
1485 ["Headers" gnus-article-hide-headers t]
1486 ["Signature" gnus-article-hide-signature t]
1487 ["Citation" gnus-article-hide-citation t]
1488 ["PGP" gnus-article-hide-pgp t]
1489 ["Boring headers" gnus-article-hide-boring-headers t])
1491 ["All" gnus-article-highlight t]
1492 ["Headers" gnus-article-highlight-headers t]
1493 ["Signature" gnus-article-highlight-signature t]
1494 ["Citation" gnus-article-highlight-citation t])
1496 ["Local" gnus-article-date-local t]
1497 ["ISO8601" gnus-article-date-iso8601 t]
1498 ["UT" gnus-article-date-ut t]
1499 ["Original" gnus-article-date-original t]
1500 ["Lapsed" gnus-article-date-lapsed t]
1501 ["User-defined" gnus-article-date-user t])
1504 ["Leading" gnus-article-strip-leading-blank-lines t]
1505 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1506 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1507 ["All of the above" gnus-article-strip-blank-lines t]
1508 ["All" gnus-article-strip-all-blank-lines t]
1509 ["Leading space" gnus-article-strip-leading-space t])
1510 ["Overstrike" gnus-article-treat-overstrike t]
1511 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1512 ["Emphasis" gnus-article-emphasize t]
1513 ["Word wrap" gnus-article-fill-cited-article t]
1514 ["CR" gnus-article-remove-cr t]
1515 ["Show X-Face" gnus-article-display-x-face t]
1516 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1517 ["UnHTMLize" gnus-article-treat-html t]
1518 ["Rot 13" gnus-summary-caesar-message t]
1519 ["Unix pipe" gnus-summary-pipe-message t]
1520 ["Add buttons" gnus-article-add-buttons t]
1521 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1522 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1523 ["Toggle MIME" gnus-summary-toggle-mime t]
1524 ["Verbose header" gnus-summary-verbose-headers t]
1525 ["Toggle header" gnus-summary-toggle-header t])
1527 ["Save in default format" gnus-summary-save-article t]
1528 ["Save in file" gnus-summary-save-article-file t]
1529 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1530 ["Save in MH folder" gnus-summary-save-article-folder t]
1531 ["Save in VM folder" gnus-summary-save-article-vm t]
1532 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1533 ["Save body in file" gnus-summary-save-article-body-file t]
1534 ["Pipe through a filter" gnus-summary-pipe-output t]
1535 ["Add to SOUP packet" gnus-soup-add-article t]
1536 ["Print" gnus-summary-print-article t])
1538 ["Respool article..." gnus-summary-respool-article t]
1539 ["Move article..." gnus-summary-move-article
1540 (gnus-check-backend-function
1541 'request-move-article gnus-newsgroup-name)]
1542 ["Copy article..." gnus-summary-copy-article t]
1543 ["Crosspost article..." gnus-summary-crosspost-article
1544 (gnus-check-backend-function
1545 'request-replace-article gnus-newsgroup-name)]
1546 ["Import file..." gnus-summary-import-article t]
1547 ["Check if posted" gnus-summary-article-posted-p t]
1548 ["Edit article" gnus-summary-edit-article
1549 (not (gnus-group-read-only-p))]
1550 ["Delete article" gnus-summary-delete-article
1551 (gnus-check-backend-function
1552 'request-expire-articles gnus-newsgroup-name)]
1553 ["Query respool" gnus-summary-respool-query t]
1554 ["Trace respool" gnus-summary-respool-trace t]
1555 ["Delete expirable articles" gnus-summary-expire-articles-now
1556 (gnus-check-backend-function
1557 'request-expire-articles gnus-newsgroup-name)])
1559 ["Uudecode" gnus-uu-decode-uu t]
1560 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1561 ["Unshar" gnus-uu-decode-unshar t]
1562 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1563 ["Save" gnus-uu-decode-save t]
1564 ["Binhex" gnus-uu-decode-binhex t]
1565 ["Postscript" gnus-uu-decode-postscript t])
1567 ["Enter article" gnus-cache-enter-article t]
1568 ["Remove article" gnus-cache-remove-article t])
1569 ["Select article buffer" gnus-summary-select-article-buffer t]
1570 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1571 ["Isearch article..." gnus-summary-isearch-article t]
1572 ["Beginning of the article" gnus-summary-beginning-of-article t]
1573 ["End of the article" gnus-summary-end-of-article t]
1574 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1575 ["Fetch referenced articles" gnus-summary-refer-references t]
1576 ["Fetch current thread" gnus-summary-refer-thread t]
1577 ["Fetch article with id..." gnus-summary-refer-article t]
1578 ["Redisplay" gnus-summary-show-article t])))
1580 gnus-summary-article-menu gnus-summary-mode-map ""
1581 (cons "Article" innards))
1584 gnus-article-commands-menu gnus-article-mode-map ""
1585 (cons "Commands" innards)))
1588 gnus-summary-thread-menu gnus-summary-mode-map ""
1590 ["Toggle threading" gnus-summary-toggle-threads t]
1591 ["Hide threads" gnus-summary-hide-all-threads t]
1592 ["Show threads" gnus-summary-show-all-threads t]
1593 ["Hide thread" gnus-summary-hide-thread t]
1594 ["Show thread" gnus-summary-show-thread t]
1595 ["Go to next thread" gnus-summary-next-thread t]
1596 ["Go to previous thread" gnus-summary-prev-thread t]
1597 ["Go down thread" gnus-summary-down-thread t]
1598 ["Go up thread" gnus-summary-up-thread t]
1599 ["Top of thread" gnus-summary-top-thread t]
1600 ["Mark thread as read" gnus-summary-kill-thread t]
1601 ["Lower thread score" gnus-summary-lower-thread t]
1602 ["Raise thread score" gnus-summary-raise-thread t]
1603 ["Rethread current" gnus-summary-rethread-current t]
1607 gnus-summary-post-menu gnus-summary-mode-map ""
1609 ["Post an article" gnus-summary-post-news t]
1610 ["Followup" gnus-summary-followup t]
1611 ["Followup and yank" gnus-summary-followup-with-original t]
1612 ["Supersede article" gnus-summary-supersede-article t]
1613 ["Cancel article" gnus-summary-cancel-article t]
1614 ["Reply" gnus-summary-reply t]
1615 ["Reply and yank" gnus-summary-reply-with-original t]
1616 ["Wide reply" gnus-summary-wide-reply t]
1617 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1618 ["Mail forward" gnus-summary-mail-forward t]
1619 ["Post forward" gnus-summary-post-forward t]
1620 ["Digest and mail" gnus-uu-digest-mail-forward t]
1621 ["Digest and post" gnus-uu-digest-post-forward t]
1622 ["Resend message" gnus-summary-resend-message t]
1623 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1624 ["Send a mail" gnus-summary-mail-other-window t]
1625 ["Uuencode and post" gnus-uu-post-news t]
1626 ["Followup via news" gnus-summary-followup-to-mail t]
1627 ["Followup via news and yank"
1628 gnus-summary-followup-to-mail-with-original t]
1630 ;;["Send" gnus-summary-send-draft t]
1631 ;;["Send bounced" gnus-resend-bounced-mail t])
1635 gnus-summary-misc-menu gnus-summary-mode-map ""
1638 ["Mark as read" gnus-summary-mark-as-read-forward t]
1639 ["Mark same subject and select"
1640 gnus-summary-kill-same-subject-and-select t]
1641 ["Mark same subject" gnus-summary-kill-same-subject t]
1642 ["Catchup" gnus-summary-catchup t]
1643 ["Catchup all" gnus-summary-catchup-all t]
1644 ["Catchup to here" gnus-summary-catchup-to-here t]
1645 ["Catchup region" gnus-summary-mark-region-as-read t]
1646 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1648 ["Tick" gnus-summary-tick-article-forward t]
1649 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1650 ["Remove marks" gnus-summary-clear-mark-forward t]
1651 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1652 ["Set bookmark" gnus-summary-set-bookmark t]
1653 ["Remove bookmark" gnus-summary-remove-bookmark t])
1655 ["Marks..." gnus-summary-limit-to-marks t]
1656 ["Subject..." gnus-summary-limit-to-subject t]
1657 ["Author..." gnus-summary-limit-to-author t]
1658 ["Age..." gnus-summary-limit-to-age t]
1659 ["Score" gnus-summary-limit-to-score t]
1660 ["Unread" gnus-summary-limit-to-unread t]
1661 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1662 ["Articles" gnus-summary-limit-to-articles t]
1663 ["Pop limit" gnus-summary-pop-limit t]
1664 ["Show dormant" gnus-summary-limit-include-dormant t]
1665 ["Hide childless dormant"
1666 gnus-summary-limit-exclude-childless-dormant t]
1667 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1668 ["Show expunged" gnus-summary-show-all-expunged t])
1670 ["Set mark" gnus-summary-mark-as-processable t]
1671 ["Remove mark" gnus-summary-unmark-as-processable t]
1672 ["Remove all marks" gnus-summary-unmark-all-processable t]
1673 ["Mark above" gnus-uu-mark-over t]
1674 ["Mark series" gnus-uu-mark-series t]
1675 ["Mark region" gnus-uu-mark-region t]
1676 ["Unmark region" gnus-uu-unmark-region t]
1677 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1678 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1679 ["Mark all" gnus-uu-mark-all t]
1680 ["Mark buffer" gnus-uu-mark-buffer t]
1681 ["Mark sparse" gnus-uu-mark-sparse t]
1682 ["Mark thread" gnus-uu-mark-thread t]
1683 ["Unmark thread" gnus-uu-unmark-thread t]
1684 ("Process Mark Sets"
1685 ["Kill" gnus-summary-kill-process-mark t]
1686 ["Yank" gnus-summary-yank-process-mark
1687 gnus-newsgroup-process-stack]
1688 ["Save" gnus-summary-save-process-mark t]))
1690 ["Page forward" gnus-summary-next-page t]
1691 ["Page backward" gnus-summary-prev-page t]
1692 ["Line forward" gnus-summary-scroll-up t])
1694 ["Next unread article" gnus-summary-next-unread-article t]
1695 ["Previous unread article" gnus-summary-prev-unread-article t]
1696 ["Next article" gnus-summary-next-article t]
1697 ["Previous article" gnus-summary-prev-article t]
1698 ["Next unread subject" gnus-summary-next-unread-subject t]
1699 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1700 ["Next article same subject" gnus-summary-next-same-subject t]
1701 ["Previous article same subject" gnus-summary-prev-same-subject t]
1702 ["First unread article" gnus-summary-first-unread-article t]
1703 ["Best unread article" gnus-summary-best-unread-article t]
1704 ["Go to subject number..." gnus-summary-goto-subject t]
1705 ["Go to article number..." gnus-summary-goto-article t]
1706 ["Go to the last article" gnus-summary-goto-last-article t]
1707 ["Pop article off history" gnus-summary-pop-article t])
1709 ["Sort by number" gnus-summary-sort-by-number t]
1710 ["Sort by author" gnus-summary-sort-by-author t]
1711 ["Sort by subject" gnus-summary-sort-by-subject t]
1712 ["Sort by date" gnus-summary-sort-by-date t]
1713 ["Sort by score" gnus-summary-sort-by-score t]
1714 ["Sort by lines" gnus-summary-sort-by-lines t])
1716 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1717 ["Describe group" gnus-summary-describe-group t]
1718 ["Read manual" gnus-info-find-node t])
1720 ["Pick and read" gnus-pick-mode t]
1721 ["Binary" gnus-binary-mode t])
1723 ["Regenerate" gnus-summary-prepare t]
1724 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1725 ["Toggle threading" gnus-summary-toggle-threads t])
1726 ["Filter articles..." gnus-summary-execute-command t]
1727 ["Run command on subjects..." gnus-summary-universal-argument t]
1728 ["Search articles forward..." gnus-summary-search-article-forward t]
1729 ["Search articles backward..." gnus-summary-search-article-backward t]
1730 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1731 ["Expand window" gnus-summary-expand-window t]
1732 ["Expire expirable articles" gnus-summary-expire-articles
1733 (gnus-check-backend-function
1734 'request-expire-articles gnus-newsgroup-name)]
1735 ["Edit local kill file" gnus-summary-edit-local-kill t]
1736 ["Edit main kill file" gnus-summary-edit-global-kill t]
1737 ["Edit group parameters" gnus-summary-edit-parameters t]
1738 ["Send a bug report" gnus-bug t]
1740 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1741 ["Catchup all and exit" gnus-summary-catchup-and-exit t]
1742 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1743 ["Exit group" gnus-summary-exit t]
1744 ["Exit group without updating" gnus-summary-exit-no-update t]
1745 ["Exit and goto next group" gnus-summary-next-group t]
1746 ["Exit and goto prev group" gnus-summary-prev-group t]
1747 ["Reselect group" gnus-summary-reselect-current-group t]
1748 ["Rescan group" gnus-summary-rescan-group t]
1749 ["Update dribble" gnus-summary-save-newsrc t])))
1751 (gnus-run-hooks 'gnus-summary-menu-hook)))
1753 (defun gnus-score-set-default (var value)
1754 "A version of set that updates the GNU Emacs menu-bar."
1756 ;; It is the message that forces the active status to be updated.
1759 (defun gnus-make-score-map (type)
1760 "Make a summary score map of type TYPE."
1763 (let ((headers '(("author" "from" string)
1764 ("subject" "subject" string)
1765 ("article body" "body" string)
1766 ("article head" "head" string)
1767 ("xref" "xref" string)
1768 ("lines" "lines" number)
1769 ("followups to author" "followup" string)))
1770 (types '((number ("less than" <)
1773 (string ("substring" s)
1777 (perms '(("temporary" (current-time-string))
1785 (if (eq type 'lower)
1790 (setq header (car headers))
1796 (let ((ts (cdr (assoc (nth 2 header) types)))
1812 'gnus-summary-score-entry
1814 (if (or (string= (nth 1 header)
1816 (string= (nth 1 header)
1819 (list 'gnus-summary-header
1821 (list 'quote (nth 1 (car ts)))
1822 (list 'gnus-score-default nil)
1828 (list (nreverse outp))))
1831 (list (nreverse outt))))
1833 (setq headers (cdr headers)))
1834 (list (nreverse outh))))))))
1838 (defun gnus-summary-mode (&optional group)
1839 "Major mode for reading articles.
1841 All normal editing commands are switched off.
1842 \\<gnus-summary-mode-map>
1843 Each line in this buffer represents one article. To read an
1844 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
1845 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
1848 You can also post articles and send mail from this buffer. To
1849 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
1850 of an article, type `\\[gnus-summary-reply]'.
1852 There are approx. one gazillion commands you can execute in this
1853 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
1855 The following commands are available:
1857 \\{gnus-summary-mode-map}"
1859 (when (gnus-visual-p 'summary-menu 'menu)
1860 (gnus-summary-make-menu-bar))
1861 (kill-all-local-variables)
1862 (gnus-summary-make-local-variables)
1863 (gnus-make-thread-indent-array)
1864 (gnus-simplify-mode-line)
1865 (setq major-mode 'gnus-summary-mode)
1866 (setq mode-name "Summary")
1867 (make-local-variable 'minor-mode-alist)
1868 (use-local-map gnus-summary-mode-map)
1869 (buffer-disable-undo (current-buffer))
1870 (setq buffer-read-only t) ;Disable modification
1871 (setq truncate-lines t)
1872 (setq selective-display t)
1873 (setq selective-display-ellipses t) ;Display `...'
1874 (gnus-summary-set-display-table)
1875 (gnus-set-default-directory)
1876 (setq gnus-newsgroup-name group)
1877 (make-local-variable 'gnus-summary-line-format)
1878 (make-local-variable 'gnus-summary-line-format-spec)
1879 (make-local-variable 'gnus-summary-dummy-line-format)
1880 (make-local-variable 'gnus-summary-dummy-line-format-spec)
1881 (make-local-variable 'gnus-summary-mark-positions)
1882 (make-local-hook 'post-command-hook)
1883 (add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
1884 (make-local-hook 'pre-command-hook)
1885 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
1886 (gnus-run-hooks 'gnus-summary-mode-hook)
1887 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
1888 (gnus-update-summary-mark-positions))
1890 (defun gnus-summary-make-local-variables ()
1891 "Make all the local summary buffer variables."
1892 (let ((locals gnus-summary-local-variables)
1894 (while (setq local (pop locals))
1897 (if (eq (cdr local) 'global)
1898 ;; Copy the global value of the variable.
1899 (setq global (symbol-value (car local)))
1900 ;; Use the value from the list.
1901 (setq global (eval (cdr local))))
1902 (make-local-variable (car local))
1903 (set (car local) global))
1904 ;; Simple nil-valued local variable.
1905 (make-local-variable local)
1908 (defun gnus-summary-clear-local-variables ()
1909 (let ((locals gnus-summary-local-variables))
1911 (if (consp (car locals))
1912 (and (vectorp (caar locals))
1913 (set (caar locals) nil))
1914 (and (vectorp (car locals))
1915 (set (car locals) nil)))
1916 (setq locals (cdr locals)))))
1918 ;; Summary data functions.
1920 (defmacro gnus-data-number (data)
1923 (defmacro gnus-data-set-number (data number)
1924 `(setcar ,data ,number))
1926 (defmacro gnus-data-mark (data)
1929 (defmacro gnus-data-set-mark (data mark)
1930 `(setcar (nthcdr 1 ,data) ,mark))
1932 (defmacro gnus-data-pos (data)
1935 (defmacro gnus-data-set-pos (data pos)
1936 `(setcar (nthcdr 2 ,data) ,pos))
1938 (defmacro gnus-data-header (data)
1941 (defmacro gnus-data-set-header (data header)
1942 `(setf (nth 3 ,data) ,header))
1944 (defmacro gnus-data-level (data)
1947 (defmacro gnus-data-unread-p (data)
1948 `(= (nth 1 ,data) gnus-unread-mark))
1950 (defmacro gnus-data-read-p (data)
1951 `(/= (nth 1 ,data) gnus-unread-mark))
1953 (defmacro gnus-data-pseudo-p (data)
1954 `(consp (nth 3 ,data)))
1956 (defmacro gnus-data-find (number)
1957 `(assq ,number gnus-newsgroup-data))
1959 (defmacro gnus-data-find-list (number &optional data)
1960 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
1961 (memq (assq ,number bdata)
1964 (defmacro gnus-data-make (number mark pos header level)
1965 `(list ,number ,mark ,pos ,header ,level))
1967 (defun gnus-data-enter (after-article number mark pos header level offset)
1968 (let ((data (gnus-data-find-list after-article)))
1970 (error "No such article: %d" after-article))
1971 (setcdr data (cons (gnus-data-make number mark pos header level)
1973 (setq gnus-newsgroup-data-reverse nil)
1974 (gnus-data-update-list (cddr data) offset)))
1976 (defun gnus-data-enter-list (after-article list &optional offset)
1978 (let ((data (and after-article (gnus-data-find-list after-article)))
1982 (let ((odata gnus-newsgroup-data))
1983 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
1985 (gnus-data-update-list odata offset)))
1986 ;; Find the last element in the list to be spliced into the main
1989 (setq list (cdr list)))
1992 (setcdr list gnus-newsgroup-data)
1993 (setq gnus-newsgroup-data ilist)
1995 (gnus-data-update-list (cdr list) offset)))
1996 (setcdr list (cdr data))
1999 (gnus-data-update-list (cdr list) offset))))
2000 (setq gnus-newsgroup-data-reverse nil))))
2002 (defun gnus-data-remove (article &optional offset)
2003 (let ((data gnus-newsgroup-data))
2004 (if (= (gnus-data-number (car data)) article)
2006 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2007 gnus-newsgroup-data-reverse nil)
2009 (gnus-data-update-list gnus-newsgroup-data offset)))
2011 (when (= (gnus-data-number (cadr data)) article)
2012 (setcdr data (cddr data))
2014 (gnus-data-update-list (cdr data) offset))
2016 gnus-newsgroup-data-reverse nil))
2017 (setq data (cdr data))))))
2019 (defmacro gnus-data-list (backward)
2021 (or gnus-newsgroup-data-reverse
2022 (setq gnus-newsgroup-data-reverse
2023 (reverse gnus-newsgroup-data)))
2024 gnus-newsgroup-data))
2026 (defun gnus-data-update-list (data offset)
2027 "Add OFFSET to the POS of all data entries in DATA."
2028 (setq gnus-newsgroup-data-reverse nil)
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 (setq gnus-newsgroup-data-reverse nil)
2036 (let ((data gnus-newsgroup-data)
2039 (when (setq pos (text-property-any
2040 (point-min) (point-max)
2041 'gnus-number (gnus-data-number (car data))))
2042 (gnus-data-set-pos (car data) (+ pos 3)))
2043 (setq data (cdr data)))))
2045 (defun gnus-summary-article-pseudo-p (article)
2046 "Say whether this article is a pseudo article or not."
2047 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2049 (defmacro gnus-summary-article-sparse-p (article)
2050 "Say whether this article is a sparse article or not."
2051 `(memq ,article gnus-newsgroup-sparse))
2053 (defmacro gnus-summary-article-ancient-p (article)
2054 "Say whether this article is a sparse article or not."
2055 `(memq ,article gnus-newsgroup-ancient))
2057 (defun gnus-article-parent-p (number)
2058 "Say whether this article is a parent or not."
2059 (let ((data (gnus-data-find-list number)))
2060 (and (cdr data) ; There has to be an article after...
2061 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2062 (gnus-data-level (nth 1 data))))))
2064 (defun gnus-article-children (number)
2065 "Return a list of all children to NUMBER."
2066 (let* ((data (gnus-data-find-list number))
2067 (level (gnus-data-level (car data)))
2069 (setq data (cdr data))
2071 (= (gnus-data-level (car data)) (1+ level)))
2072 (push (gnus-data-number (car data)) children)
2073 (setq data (cdr data)))
2076 (defmacro gnus-summary-skip-intangible ()
2077 "If the current article is intangible, then jump to a different article."
2078 '(let ((to (get-text-property (point) 'gnus-intangible)))
2079 (and to (gnus-summary-goto-subject to))))
2081 (defmacro gnus-summary-article-intangible-p ()
2082 "Say whether this article is intangible or not."
2083 '(get-text-property (point) 'gnus-intangible))
2085 (defun gnus-article-read-p (article)
2086 "Say whether ARTICLE is read or not."
2087 (not (or (memq article gnus-newsgroup-marked)
2088 (memq article gnus-newsgroup-unreads)
2089 (memq article gnus-newsgroup-unselected)
2090 (memq article gnus-newsgroup-dormant))))
2092 ;; Some summary mode macros.
2094 (defmacro gnus-summary-article-number ()
2095 "The article number of the article on the current line.
2096 If there isn's an article number here, then we return the current
2099 (gnus-summary-skip-intangible)
2100 (or (get-text-property (point) 'gnus-number)
2101 (gnus-summary-last-subject))))
2103 (defmacro gnus-summary-article-header (&optional number)
2104 "Return the header of article NUMBER."
2105 `(gnus-data-header (gnus-data-find
2106 ,(or number '(gnus-summary-article-number)))))
2108 (defmacro gnus-summary-thread-level (&optional number)
2109 "Return the level of thread that starts with article NUMBER."
2110 `(if (and (eq gnus-summary-make-false-root 'dummy)
2111 (get-text-property (point) 'gnus-intangible))
2113 (gnus-data-level (gnus-data-find
2114 ,(or number '(gnus-summary-article-number))))))
2116 (defmacro gnus-summary-article-mark (&optional number)
2117 "Return the mark of article NUMBER."
2118 `(gnus-data-mark (gnus-data-find
2119 ,(or number '(gnus-summary-article-number)))))
2121 (defmacro gnus-summary-article-pos (&optional number)
2122 "Return the position of the line of article NUMBER."
2123 `(gnus-data-pos (gnus-data-find
2124 ,(or number '(gnus-summary-article-number)))))
2126 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2127 (defmacro gnus-summary-article-subject (&optional number)
2128 "Return current subject string or nil if nothing."
2131 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2132 '(gnus-data-header (assq (gnus-summary-article-number)
2133 gnus-newsgroup-data)))))
2136 (mail-header-subject headers))))
2138 (defmacro gnus-summary-article-score (&optional number)
2139 "Return current article score."
2140 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2141 gnus-newsgroup-scored))
2142 gnus-summary-default-score 0))
2144 (defun gnus-summary-article-children (&optional number)
2145 "Return a list of article numbers that are children of article NUMBER."
2146 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2147 (level (gnus-data-level (car data)))
2149 (while (and (setq data (cdr data))
2150 (> (setq l (gnus-data-level (car data))) level))
2151 (and (= (1+ level) l)
2152 (push (gnus-data-number (car data))
2154 (nreverse children)))
2156 (defun gnus-summary-article-parent (&optional number)
2157 "Return the article number of the parent of article NUMBER."
2158 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2159 (gnus-data-list t)))
2160 (level (gnus-data-level (car data))))
2162 () ; This is a root.
2163 ;; We search until we find an article with a level less than
2164 ;; this one. That function has to be the parent.
2165 (while (and (setq data (cdr data))
2166 (not (< (gnus-data-level (car data)) level))))
2167 (and data (gnus-data-number (car data))))))
2169 (defun gnus-unread-mark-p (mark)
2170 "Say whether MARK is the unread mark."
2171 (= mark gnus-unread-mark))
2173 (defun gnus-read-mark-p (mark)
2174 "Say whether MARK is one of the marks that mark as read.
2175 This is all marks except unread, ticked, dormant, and expirable."
2176 (not (or (= mark gnus-unread-mark)
2177 (= mark gnus-ticked-mark)
2178 (= mark gnus-dormant-mark)
2179 (= mark gnus-expirable-mark))))
2181 (defmacro gnus-article-mark (number)
2182 "Return the MARK of article NUMBER.
2183 This macro should only be used when computing the mark the \"first\"
2184 time; i.e., when generating the summary lines. After that,
2185 `gnus-summary-article-mark' should be used to examine the
2188 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2189 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2190 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2191 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2192 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2193 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2194 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2195 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2196 gnus-ancient-mark))))
2198 ;; Saving hidden threads.
2200 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2201 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2203 (defmacro gnus-save-hidden-threads (&rest forms)
2204 "Save hidden threads, eval FORMS, and restore the hidden threads."
2205 (let ((config (make-symbol "config")))
2206 `(let ((,config (gnus-hidden-threads-configuration)))
2210 (gnus-restore-hidden-threads-configuration ,config)))))
2212 (defun gnus-hidden-threads-configuration ()
2213 "Return the current hidden threads configuration."
2216 (goto-char (point-min))
2217 (while (search-forward "\r" nil t)
2218 (push (1- (point)) config))
2221 (defun gnus-restore-hidden-threads-configuration (config)
2222 "Restore hidden threads configuration from CONFIG."
2223 (let (point buffer-read-only)
2224 (while (setq point (pop config))
2225 (when (and (< point (point-max))
2227 (= (following-char) ?\n))
2228 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2230 ;; Various summary mode internalish functions.
2232 (defun gnus-mouse-pick-article (e)
2235 (gnus-summary-next-page nil t))
2237 (defun gnus-summary-set-display-table ()
2238 ;; Change the display table. Odd characters have a tendency to mess
2239 ;; up nicely formatted displays - we make all possible glyphs
2240 ;; display only a single character.
2242 ;; We start from the standard display table, if any.
2243 (let ((table (or (copy-sequence standard-display-table)
2244 (make-display-table)))
2246 ;; Nix out all the control chars...
2247 (while (>= (setq i (1- i)) 0)
2248 (aset table i [??]))
2249 ;; ... but not newline and cr, of course. (cr is necessary for the
2250 ;; selective display).
2251 (aset table ?\n nil)
2252 (aset table ?\r nil)
2253 ;; We keep TAB as well.
2254 (aset table ?\t nil)
2255 ;; We nix out any glyphs over 126 that are not set already.
2257 (while (>= (setq i (1- i)) 127)
2258 ;; Only modify if the entry is nil.
2259 (unless (aref table i)
2260 (aset table i [??]))))
2261 (setq buffer-display-table table)))
2263 (defun gnus-summary-setup-buffer (group)
2264 "Initialize summary buffer."
2265 (let ((buffer (concat "*Summary " group "*")))
2266 (if (get-buffer buffer)
2269 (setq gnus-summary-buffer (current-buffer))
2270 (not gnus-newsgroup-prepared))
2271 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2272 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
2273 (gnus-add-current-to-buffer-list)
2274 (gnus-summary-mode group)
2276 (gnus-carpal-setup-buffer 'summary))
2277 (unless gnus-single-article-buffer
2278 (make-local-variable 'gnus-article-buffer)
2279 (make-local-variable 'gnus-article-current)
2280 (make-local-variable 'gnus-original-article-buffer))
2281 (setq gnus-newsgroup-name group)
2284 (defun gnus-set-global-variables ()
2285 ;; Set the global equivalents of the summary buffer-local variables
2286 ;; to the latest values they had. These reflect the summary buffer
2287 ;; that was in action when the last article was fetched.
2288 (when (eq major-mode 'gnus-summary-mode)
2289 (setq gnus-summary-buffer (current-buffer))
2290 (let ((name gnus-newsgroup-name)
2291 (marked gnus-newsgroup-marked)
2292 (unread gnus-newsgroup-unreads)
2293 (headers gnus-current-headers)
2294 (data gnus-newsgroup-data)
2295 (summary gnus-summary-buffer)
2296 (article-buffer gnus-article-buffer)
2297 (original gnus-original-article-buffer)
2298 (gac gnus-article-current)
2299 (reffed gnus-reffed-article-number)
2300 (score-file gnus-current-score-file))
2302 (set-buffer gnus-group-buffer)
2303 (setq gnus-newsgroup-name name
2304 gnus-newsgroup-marked marked
2305 gnus-newsgroup-unreads unread
2306 gnus-current-headers headers
2307 gnus-newsgroup-data data
2308 gnus-article-current gac
2309 gnus-summary-buffer summary
2310 gnus-article-buffer article-buffer
2311 gnus-original-article-buffer original
2312 gnus-reffed-article-number reffed
2313 gnus-current-score-file score-file)
2314 ;; The article buffer also has local variables.
2315 (when (gnus-buffer-live-p gnus-article-buffer)
2316 (set-buffer gnus-article-buffer)
2317 (setq gnus-summary-buffer summary))))))
2319 (defun gnus-summary-article-unread-p (article)
2320 "Say whether ARTICLE is unread or not."
2321 (memq article gnus-newsgroup-unreads))
2323 (defun gnus-summary-first-article-p (&optional article)
2324 "Return whether ARTICLE is the first article in the buffer."
2325 (if (not (setq article (or article (gnus-summary-article-number))))
2327 (eq article (caar gnus-newsgroup-data))))
2329 (defun gnus-summary-last-article-p (&optional article)
2330 "Return whether ARTICLE is the last article in the buffer."
2331 (if (not (setq article (or article (gnus-summary-article-number))))
2332 t ; All non-existent numbers are the last article. :-)
2333 (not (cdr (gnus-data-find-list article)))))
2335 (defun gnus-make-thread-indent-array ()
2337 (unless (and gnus-thread-indent-array
2338 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2339 (setq gnus-thread-indent-array (make-vector 201 "")
2340 gnus-thread-indent-array-level gnus-thread-indent-level)
2342 (aset gnus-thread-indent-array n
2343 (make-string (* n gnus-thread-indent-level) ? ))
2346 (defun gnus-update-summary-mark-positions ()
2347 "Compute where the summary marks are to go."
2349 (when (gnus-buffer-exists-p gnus-summary-buffer)
2350 (set-buffer gnus-summary-buffer))
2351 (let ((gnus-replied-mark 129)
2352 (gnus-score-below-mark 130)
2353 (gnus-score-over-mark 130)
2354 (gnus-download-mark 131)
2355 (spec gnus-summary-line-format-spec)
2356 thread gnus-visual pos)
2358 (gnus-set-work-buffer)
2359 (let ((gnus-summary-line-format-spec spec)
2360 (gnus-newsgroup-downloadable '((0 . t))))
2361 (gnus-summary-insert-line
2362 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2363 (goto-char (point-min))
2364 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2366 (goto-char (point-min))
2367 (push (cons 'replied (and (search-forward "\201" nil t)
2370 (goto-char (point-min))
2371 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2373 (goto-char (point-min))
2374 (push (cons 'download
2375 (and (search-forward "\203" nil t) (- (point) 2)))
2377 (setq gnus-summary-mark-positions pos))))
2379 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2380 "Insert a dummy root in the summary buffer."
2382 (gnus-add-text-properties
2383 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2384 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2386 (defun gnus-summary-insert-line (gnus-tmp-header
2387 gnus-tmp-level gnus-tmp-current
2388 gnus-tmp-unread gnus-tmp-replied
2389 gnus-tmp-expirable gnus-tmp-subject-or-nil
2390 &optional gnus-tmp-dummy gnus-tmp-score
2392 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2393 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2394 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2395 (gnus-tmp-score-char
2396 (if (or (null gnus-summary-default-score)
2397 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2398 gnus-summary-zcore-fuzz))
2400 (if (< gnus-tmp-score gnus-summary-default-score)
2401 gnus-score-below-mark gnus-score-over-mark)))
2403 (cond (gnus-tmp-process gnus-process-mark)
2404 ((memq gnus-tmp-current gnus-newsgroup-cached)
2406 (gnus-tmp-replied gnus-replied-mark)
2407 ((memq gnus-tmp-current gnus-newsgroup-saved)
2409 (t gnus-unread-mark)))
2410 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2413 ((string-match "<[^>]+> *$" gnus-tmp-from)
2414 (let ((beg (match-beginning 0)))
2415 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2416 (substring gnus-tmp-from (1+ (match-beginning 0))
2417 (1- (match-end 0))))
2418 (substring gnus-tmp-from 0 beg))))
2419 ((string-match "(.+)" gnus-tmp-from)
2420 (substring gnus-tmp-from
2421 (1+ (match-beginning 0)) (1- (match-end 0))))
2423 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2424 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2425 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2426 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2427 (buffer-read-only nil))
2428 (when (string= gnus-tmp-name "")
2429 (setq gnus-tmp-name gnus-tmp-from))
2430 (unless (numberp gnus-tmp-lines)
2431 (setq gnus-tmp-lines 0))
2432 (gnus-put-text-property-excluding-characters-with-faces
2434 (progn (eval gnus-summary-line-format-spec) (point))
2435 'gnus-number gnus-tmp-number)
2436 (when (gnus-visual-p 'summary-highlight 'highlight)
2438 (gnus-run-hooks 'gnus-summary-update-hook)
2441 (defun gnus-summary-update-line (&optional dont-update)
2442 ;; Update summary line after change.
2443 (when (and gnus-summary-default-score
2444 (not gnus-summary-inhibit-highlight))
2445 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2446 (article (gnus-summary-article-number))
2447 (score (gnus-summary-article-score article)))
2449 (if (and gnus-summary-mark-below
2450 (< (gnus-summary-article-score)
2451 gnus-summary-mark-below))
2452 ;; This article has a low score, so we mark it as read.
2453 (when (memq article gnus-newsgroup-unreads)
2454 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2455 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2456 ;; This article was previously marked as read on account
2457 ;; of a low score, but now it has risen, so we mark it as
2459 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2460 (gnus-summary-update-mark
2461 (if (or (null gnus-summary-default-score)
2462 (<= (abs (- score gnus-summary-default-score))
2463 gnus-summary-zcore-fuzz))
2465 (if (< score gnus-summary-default-score)
2466 gnus-score-below-mark gnus-score-over-mark))
2468 ;; Do visual highlighting.
2469 (when (gnus-visual-p 'summary-highlight 'highlight)
2470 (gnus-run-hooks 'gnus-summary-update-hook)))))
2472 (defvar gnus-tmp-new-adopts nil)
2474 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2475 "Return the number of articles in THREAD.
2476 This may be 0 in some cases -- if none of the articles in
2477 the thread are to be displayed."
2479 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2481 ((not (listp thread))
2483 ((and (consp thread) (cdr thread))
2486 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2489 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2492 (when (and level (zerop level) gnus-tmp-new-adopts)
2495 'gnus-summary-number-of-articles-in-thread
2496 gnus-tmp-new-adopts))))
2498 (if (> number 1) gnus-not-empty-thread-mark
2499 gnus-empty-thread-mark)
2502 (defun gnus-summary-set-local-parameters (group)
2503 "Go through the local params of GROUP and set all variable specs in that list."
2504 (let ((params (gnus-group-find-parameter group))
2507 (setq elem (car params)
2508 params (cdr params))
2509 (and (consp elem) ; Has to be a cons.
2510 (consp (cdr elem)) ; The cdr has to be a list.
2511 (symbolp (car elem)) ; Has to be a symbol in there.
2512 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2513 (ignore-errors ; So we set it.
2514 (make-local-variable (car elem))
2515 (set (car elem) (eval (nth 1 elem))))))))
2517 (defun gnus-summary-read-group (group &optional show-all no-article
2518 kill-buffer no-display backward
2520 "Start reading news in newsgroup GROUP.
2521 If SHOW-ALL is non-nil, already read articles are also listed.
2522 If NO-ARTICLE is non-nil, no article is selected initially.
2523 If NO-DISPLAY, don't generate a summary buffer."
2527 (let ((gnus-auto-select-next nil))
2528 (or (gnus-summary-read-group-1
2529 group show-all no-article
2530 kill-buffer no-display
2533 select-articles nil)))))
2534 (eq gnus-auto-select-next 'quietly))
2535 (set-buffer gnus-group-buffer)
2536 ;; The entry function called above goes to the next
2537 ;; group automatically, so we go two groups back
2538 ;; if we are searching for the previous group.
2540 (gnus-group-prev-unread-group 2))
2541 (if (not (equal group (gnus-group-group-name)))
2542 (setq group (gnus-group-group-name))
2546 (defun gnus-summary-read-group-1 (group show-all no-article
2547 kill-buffer no-display
2548 &optional select-articles)
2549 ;; Killed foreign groups can't be entered.
2550 (when (and (not (gnus-group-native-p group))
2551 (not (gnus-gethash group gnus-newsrc-hashtb)))
2552 (error "Dead non-native groups can't be entered"))
2553 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2554 (let* ((new-group (gnus-summary-setup-buffer group))
2555 (quit-config (gnus-group-quit-config group))
2556 (did-select (and new-group (gnus-select-newsgroup
2557 group show-all select-articles))))
2559 ;; This summary buffer exists already, so we just select it.
2561 (gnus-set-global-variables)
2563 (gnus-kill-or-deaden-summary kill-buffer))
2564 (gnus-configure-windows 'summary 'force)
2565 (gnus-set-mode-line 'summary)
2566 (gnus-summary-position-point)
2569 ;; We couldn't select this group.
2571 (when (and (eq major-mode 'gnus-summary-mode)
2572 (not (equal (current-buffer) kill-buffer)))
2573 (kill-buffer (current-buffer))
2574 (if (not quit-config)
2576 ;; Update the info -- marks might need to be removed,
2578 (gnus-summary-update-info)
2579 (set-buffer gnus-group-buffer)
2580 (gnus-group-jump-to-group group)
2581 (gnus-group-next-unread-group 1))
2582 (gnus-handle-ephemeral-exit quit-config)))
2583 (gnus-message 3 "Can't select group")
2585 ;; The user did a `C-g' while prompting for number of articles,
2586 ;; so we exit this group.
2587 ((eq did-select 'quit)
2588 (and (eq major-mode 'gnus-summary-mode)
2589 (not (equal (current-buffer) kill-buffer))
2590 (kill-buffer (current-buffer)))
2592 (gnus-kill-or-deaden-summary kill-buffer))
2593 (if (not quit-config)
2595 (set-buffer gnus-group-buffer)
2596 (gnus-group-jump-to-group group)
2597 (gnus-group-next-unread-group 1)
2598 (gnus-configure-windows 'group 'force))
2599 (gnus-handle-ephemeral-exit quit-config))
2600 ;; Finally signal the quit.
2602 ;; The group was successfully selected.
2604 (gnus-set-global-variables)
2605 ;; Save the active value in effect when the group was entered.
2606 (setq gnus-newsgroup-active
2608 (gnus-active gnus-newsgroup-name)))
2609 ;; You can change the summary buffer in some way with this hook.
2610 (gnus-run-hooks 'gnus-select-group-hook)
2611 ;; Set any local variables in the group parameters.
2612 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2613 (gnus-update-format-specifications
2614 nil 'summary 'summary-mode 'summary-dummy)
2615 ;; Do score processing.
2616 (when gnus-use-scoring
2617 (gnus-possibly-score-headers))
2618 ;; Check whether to fill in the gaps in the threads.
2619 (when gnus-build-sparse-threads
2620 (gnus-build-sparse-threads))
2621 ;; Find the initial limit.
2622 (if gnus-show-threads
2624 (let ((gnus-newsgroup-dormant nil))
2625 (gnus-summary-initial-limit show-all))
2626 (gnus-summary-initial-limit show-all))
2627 (setq gnus-newsgroup-limit
2629 (lambda (header) (mail-header-number header))
2630 gnus-newsgroup-headers)))
2631 ;; Generate the summary buffer.
2633 (gnus-summary-prepare))
2634 (when gnus-use-trees
2635 (gnus-tree-open group)
2636 (setq gnus-summary-highlight-line-function
2637 'gnus-tree-highlight-article))
2638 ;; If the summary buffer is empty, but there are some low-scored
2639 ;; articles or some excluded dormants, we include these in the
2641 (when (and (zerop (buffer-size))
2643 (cond (gnus-newsgroup-dormant
2644 (gnus-summary-limit-include-dormant))
2645 ((and gnus-newsgroup-scored show-all)
2646 (gnus-summary-limit-include-expunged t))))
2647 ;; Function `gnus-apply-kill-file' must be called in this hook.
2648 (gnus-run-hooks 'gnus-apply-kill-hook)
2649 (if (and (zerop (buffer-size))
2652 ;; This newsgroup is empty.
2653 (gnus-summary-catchup-and-exit nil t)
2654 (gnus-message 6 "No unread news")
2656 (gnus-kill-or-deaden-summary kill-buffer))
2657 ;; Return nil from this function.
2659 ;; Hide conversation thread subtrees. We cannot do this in
2660 ;; gnus-summary-prepare-hook since kill processing may not
2661 ;; work with hidden articles.
2662 (and gnus-show-threads
2663 gnus-thread-hide-subtree
2664 (gnus-summary-hide-all-threads))
2666 (gnus-kill-or-deaden-summary kill-buffer))
2667 ;; Show first unread article if requested.
2668 (if (and (not no-article)
2670 gnus-newsgroup-unreads
2671 gnus-auto-select-first)
2672 (unless (if (eq gnus-auto-select-first 'best)
2673 (gnus-summary-best-unread-article)
2674 (gnus-summary-first-unread-article))
2675 (gnus-configure-windows 'summary))
2676 ;; Don't select any articles, just move point to the first
2677 ;; article in the group.
2678 (goto-char (point-min))
2679 (gnus-summary-position-point)
2680 (gnus-configure-windows 'summary 'force)
2681 (gnus-set-mode-line 'summary))
2682 (when (get-buffer-window gnus-group-buffer t)
2683 ;; Gotta use windows, because recenter does weird stuff if
2684 ;; the current buffer ain't the displayed window.
2685 (let ((owin (selected-window)))
2686 (select-window (get-buffer-window gnus-group-buffer t))
2687 (when (gnus-group-goto-group group)
2689 (select-window owin)))
2690 ;; Mark this buffer as "prepared".
2691 (setq gnus-newsgroup-prepared t)
2692 (gnus-run-hooks 'gnus-summary-prepared-hook)
2695 (defun gnus-summary-prepare ()
2696 "Generate the summary buffer."
2698 (let ((buffer-read-only nil))
2700 (setq gnus-newsgroup-data nil
2701 gnus-newsgroup-data-reverse nil)
2702 (gnus-run-hooks 'gnus-summary-generate-hook)
2703 ;; Generate the buffer, either with threads or without.
2704 (when gnus-newsgroup-headers
2705 (gnus-summary-prepare-threads
2706 (if gnus-show-threads
2707 (gnus-sort-gathered-threads
2708 (funcall gnus-summary-thread-gathering-function
2710 (gnus-cut-threads (gnus-make-threads)))))
2711 ;; Unthreaded display.
2712 (gnus-sort-articles gnus-newsgroup-headers))))
2713 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2714 ;; Call hooks for modifying summary buffer.
2715 (goto-char (point-min))
2716 (gnus-run-hooks 'gnus-summary-prepare-hook)))
2718 (defsubst gnus-general-simplify-subject (subject)
2719 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2722 ;; Truncate the subject.
2723 (gnus-simplify-subject-functions
2724 (gnus-map-function gnus-simplify-subject-functions subject))
2725 ((numberp gnus-summary-gather-subject-limit)
2726 (setq subject (gnus-simplify-subject-re subject))
2727 (if (> (length subject) gnus-summary-gather-subject-limit)
2728 (substring subject 0 gnus-summary-gather-subject-limit)
2730 ;; Fuzzily simplify it.
2731 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2732 (gnus-simplify-subject-fuzzy subject))
2733 ;; Just remove the leading "Re:".
2735 (gnus-simplify-subject-re subject))))
2737 (if (and gnus-summary-gather-exclude-subject
2738 (string-match gnus-summary-gather-exclude-subject subject))
2739 nil ; This article shouldn't be gathered
2742 (defun gnus-summary-simplify-subject-query ()
2743 "Query where the respool algorithm would put this article."
2745 (gnus-summary-select-article)
2746 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2748 (defun gnus-gather-threads-by-subject (threads)
2749 "Gather threads by looking at Subject headers."
2750 (if (not gnus-summary-make-false-root)
2752 (let ((hashtb (gnus-make-hashtable 1024))
2755 subject hthread whole-subject)
2757 (setq subject (gnus-general-simplify-subject
2758 (setq whole-subject (mail-header-subject
2761 (if (setq hthread (gnus-gethash subject hashtb))
2763 ;; We enter a dummy root into the thread, if we
2764 ;; haven't done that already.
2765 (unless (stringp (caar hthread))
2766 (setcar hthread (list whole-subject (car hthread))))
2767 ;; We add this new gathered thread to this gathered
2769 (setcdr (car hthread)
2770 (nconc (cdar hthread) (list (car threads))))
2771 ;; Remove it from the list of threads.
2772 (setcdr prev (cdr threads))
2773 (setq threads prev))
2774 ;; Enter this thread into the hash table.
2775 (gnus-sethash subject threads hashtb)))
2777 (setq threads (cdr threads)))
2780 (defun gnus-gather-threads-by-references (threads)
2781 "Gather threads by looking at References headers."
2782 (let ((idhashtb (gnus-make-hashtable 1024))
2783 (thhashtb (gnus-make-hashtable 1024))
2786 ids references id gthread gid entered ref)
2788 (when (setq references (mail-header-references (caar threads)))
2789 (setq id (mail-header-id (caar threads))
2790 ids (gnus-split-references references)
2792 (while (setq ref (pop ids))
2793 (setq ids (delete ref ids))
2794 (if (not (setq gid (gnus-gethash ref idhashtb)))
2796 (gnus-sethash ref id idhashtb)
2797 (gnus-sethash id threads thhashtb))
2798 (setq gthread (gnus-gethash gid thhashtb))
2800 ;; We enter a dummy root into the thread, if we
2801 ;; haven't done that already.
2802 (unless (stringp (caar gthread))
2803 (setcar gthread (list (mail-header-subject (caar gthread))
2805 ;; We add this new gathered thread to this gathered
2807 (setcdr (car gthread)
2808 (nconc (cdar gthread) (list (car threads)))))
2809 ;; Add it into the thread hash table.
2810 (gnus-sethash id gthread thhashtb)
2812 ;; Remove it from the list of threads.
2813 (setcdr prev (cdr threads))
2814 (setq threads prev))))
2816 (setq threads (cdr threads)))
2819 (defun gnus-sort-gathered-threads (threads)
2820 "Sort subtreads inside each gathered thread by article number."
2821 (let ((result threads))
2823 (when (stringp (caar threads))
2824 (setcdr (car threads)
2825 (sort (cdar threads) 'gnus-thread-sort-by-number)))
2826 (setq threads (cdr threads)))
2829 (defun gnus-thread-loop-p (root thread)
2830 "Say whether ROOT is in THREAD."
2831 (let ((stack (list thread))
2834 (while (setq thread (pop stack))
2835 (setq th (cdr thread))
2837 (not (eq (caar th) root)))
2840 ;; We have found a loop.
2842 (setcdr thread (delq (car th) (cdr thread)))
2843 (if (boundp (setq ref-dep (intern "none"
2844 gnus-newsgroup-dependencies)))
2845 (setcdr (symbol-value ref-dep)
2846 (nconc (cdr (symbol-value ref-dep))
2848 (set ref-dep (list nil (car th))))
2851 ;; Push all the subthreads onto the stack.
2852 (push (cdr thread) stack)))
2855 (defun gnus-make-threads ()
2856 "Go through the dependency hashtb and find the roots. Return all threads."
2858 (while (catch 'infloop
2861 ;; Deal with self-referencing References loops.
2862 (when (and (car (symbol-value refs))
2869 (car (symbol-value refs)) thread))
2870 (cdr (symbol-value refs)))))))
2873 (unless (car (symbol-value refs))
2874 ;; These threads do not refer back to any other articles,
2875 ;; so they're roots.
2876 (setq threads (append (cdr (symbol-value refs)) threads))))
2877 gnus-newsgroup-dependencies)))
2880 ;; Build the thread tree.
2881 (defun gnus-dependencies-add-header (header dependencies force-new)
2882 "Enter HEADER into the DEPENDENCIES table if it is not already there.
2884 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
2885 if it was already present.
2887 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
2888 will not be entered in the DEPENDENCIES table. Otherwise duplicate
2889 Message-IDs will be renamed be renamed to a unique Message-ID before
2892 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
2893 (let* ((id (mail-header-id header))
2894 (id-dep (and id (intern id dependencies)))
2895 ref ref-dep ref-header)
2896 ;; Enter this `header' in the `dependencies' table.
2900 ;; The first two cases do the normal part: enter a new `header'
2901 ;; in the `dependencies' table.
2902 ((not (boundp id-dep))
2903 (set id-dep (list header)))
2904 ((null (car (symbol-value id-dep)))
2905 (setcar (symbol-value id-dep) header))
2907 ;; From here the `header' was already present in the
2908 ;; `dependencies' table.
2910 ;; Overrides an existing entry;
2911 ;; just set the header part of the entry.
2912 (setcar (symbol-value id-dep) header))
2914 ;; Renames the existing `header' to a unique Message-ID.
2915 ((not gnus-summary-ignore-duplicates)
2916 ;; An article with this Message-ID has already been seen.
2917 ;; We rename the Message-ID.
2918 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
2920 (mail-header-set-id header id))
2922 ;; The last case ignores an existing entry, except it adds any
2923 ;; additional Xrefs (in case the two articles came from different
2925 ;; Also sets `header' to `nil' meaning that the `dependencies'
2926 ;; table was *not* modified.
2928 (mail-header-set-xref
2929 (car (symbol-value id-dep))
2930 (concat (or (mail-header-xref (car (symbol-value id-dep)))
2932 (or (mail-header-xref header) "")))
2936 ;; First check if that we are not creating a References loop.
2937 (setq ref (gnus-parent-id (mail-header-references header)))
2939 (setq ref-dep (intern-soft ref dependencies))
2941 (setq ref-header (car (symbol-value ref-dep))))
2942 (if (string= id ref)
2943 ;; Yuk! This is a reference loop. Make the article be a
2946 (mail-header-set-references (car (symbol-value id-dep)) "none")
2948 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
2949 (setq ref (gnus-parent-id (mail-header-references header)))
2950 (setq ref-dep (intern (or ref "none") dependencies))
2951 (if (boundp ref-dep)
2952 (setcdr (symbol-value ref-dep)
2953 (nconc (cdr (symbol-value ref-dep))
2954 (list (symbol-value id-dep))))
2955 (set ref-dep (list nil (symbol-value id-dep)))))
2958 (defun gnus-build-sparse-threads ()
2959 (let ((headers gnus-newsgroup-headers)
2960 (gnus-summary-ignore-duplicates t)
2961 header references generation relations
2962 cthread subject child end pthread relation new-child date)
2963 ;; First we create an alist of generations/relations, where
2964 ;; generations is how much we trust the relation, and the relation
2966 (gnus-message 7 "Making sparse threads...")
2968 (nnheader-set-temp-buffer " *gnus sparse threads*")
2969 (while (setq header (pop headers))
2970 (when (and (setq references (mail-header-references header))
2971 (not (string= references "")))
2973 (setq child (mail-header-id header)
2974 subject (mail-header-subject header)
2975 date (mail-header-date header)
2977 (while (search-backward ">" nil t)
2978 (setq end (1+ (point)))
2979 (when (search-backward "<" nil t)
2980 (setq new-child (buffer-substring (point) end))
2981 (push (list (incf generation)
2982 child (setq child new-child)
2986 (push (list (1+ generation) child nil subject) relations))
2988 (kill-buffer (current-buffer)))
2989 ;; Sort over trustworthiness.
2992 (when (gnus-dependencies-add-header
2993 (make-full-mail-header
2994 gnus-reffed-article-number
2995 (nth 3 relation) "" (or (nth 4 relation) "")
2997 (or (nth 2 relation) "") 0 0 "")
2998 gnus-newsgroup-dependencies nil)
2999 (push gnus-reffed-article-number gnus-newsgroup-limit)
3000 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3001 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3002 gnus-newsgroup-reads)
3003 (decf gnus-reffed-article-number)))
3004 (sort relations 'car-less-than-car))
3005 (gnus-message 7 "Making sparse threads...done")))
3007 (defun gnus-build-old-threads ()
3008 ;; Look at all the articles that refer back to old articles, and
3009 ;; fetch the headers for the articles that aren't there. This will
3010 ;; build complete threads - if the roots haven't been expired by the
3015 (when (not (car (symbol-value refs)))
3016 (setq heads (cdr (symbol-value refs)))
3018 (if (memq (mail-header-number (caar heads))
3019 gnus-newsgroup-dormant)
3020 (setq heads (cdr heads))
3021 (setq id (symbol-name refs))
3022 (while (and (setq id (gnus-build-get-header id))
3023 (not (car (gnus-id-to-thread id)))))
3024 (setq heads nil)))))
3025 gnus-newsgroup-dependencies)))
3027 ;; The following macros and functions were written by Felix Lee
3028 ;; <flee@cse.psu.edu>.
3030 (defmacro gnus-nov-read-integer ()
3032 (if (= (following-char) ?\t)
3034 (let ((num (ignore-errors (read buffer))))
3035 (if (numberp num) num 0)))
3037 (search-forward "\t" eol 'move))))
3039 (defmacro gnus-nov-skip-field ()
3040 '(search-forward "\t" eol 'move))
3042 (defmacro gnus-nov-field ()
3043 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
3045 ;; This function has to be called with point after the article number
3046 ;; on the beginning of the line.
3047 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3048 (let ((eol (gnus-point-at-eol))
3049 (buffer (current-buffer))
3052 ;; overview: [num subject from date id refs chars lines misc]
3055 (narrow-to-region (point) eol)
3060 (make-full-mail-header
3063 gnus-unstructured-field-decoder (gnus-nov-field)) ; subject
3065 gnus-structured-field-decoder (gnus-nov-field)) ; from
3066 (gnus-nov-field) ; date
3067 (or (gnus-nov-field)
3068 (nnheader-generate-fake-message-id)) ; id
3069 (gnus-nov-field) ; refs
3070 (gnus-nov-read-integer) ; chars
3071 (gnus-nov-read-integer) ; lines
3072 (unless (= (following-char) ?\n)
3073 (gnus-nov-field))))) ; misc
3077 (when gnus-alter-header-function
3078 (funcall gnus-alter-header-function header))
3079 (gnus-dependencies-add-header header dependencies force-new)))
3081 (defun gnus-build-get-header (id)
3082 ;; Look through the buffer of NOV lines and find the header to
3083 ;; ID. Enter this line into the dependencies hash table, and return
3084 ;; the id of the parent article (if any).
3085 (let ((deps gnus-newsgroup-dependencies)
3089 (set-buffer nntp-server-buffer)
3090 (let ((case-fold-search nil))
3091 (goto-char (point-min))
3092 (while (and (not found)
3093 (search-forward id nil t))
3095 (setq found (looking-at
3096 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3097 (regexp-quote id))))
3098 (or found (beginning-of-line 2)))
3102 (setq header (gnus-nov-parse-line
3103 (read (current-buffer)) deps))
3104 (gnus-parent-id (mail-header-references header))))))
3106 (let ((number (mail-header-number header)))
3107 (push number gnus-newsgroup-limit)
3108 (push header gnus-newsgroup-headers)
3109 (if (memq number gnus-newsgroup-unselected)
3111 (push number gnus-newsgroup-unreads)
3112 (setq gnus-newsgroup-unselected
3113 (delq number gnus-newsgroup-unselected)))
3114 (push number gnus-newsgroup-ancient)))))))
3116 (defun gnus-build-all-threads ()
3117 "Read all the headers."
3118 (let ((gnus-summary-ignore-duplicates t)
3119 (dependencies gnus-newsgroup-dependencies)
3120 found header article)
3122 (set-buffer nntp-server-buffer)
3123 (let ((case-fold-search nil))
3124 (goto-char (point-min))
3127 (setq article (read (current-buffer))
3128 header (gnus-nov-parse-line
3129 article dependencies)))
3131 (push header gnus-newsgroup-headers)
3132 (if (memq (setq article (mail-header-number header))
3133 gnus-newsgroup-unselected)
3135 (push article gnus-newsgroup-unreads)
3136 (setq gnus-newsgroup-unselected
3137 (delq article gnus-newsgroup-unselected)))
3138 (push article gnus-newsgroup-ancient))
3139 (forward-line 1)))))))
3141 (defun gnus-summary-update-article-line (article header)
3142 "Update the line for ARTICLE using HEADERS."
3143 (let* ((id (mail-header-id header))
3144 (thread (gnus-id-to-thread id)))
3146 (error "Article in no thread"))
3147 ;; Update the thread.
3148 (setcar thread header)
3149 (gnus-summary-goto-subject article)
3150 (let* ((datal (gnus-data-find-list article))
3152 (length (when (cdr datal)
3153 (- (gnus-data-pos data)
3154 (gnus-data-pos (cadr datal)))))
3155 (buffer-read-only nil)
3156 (level (gnus-summary-thread-level)))
3158 (gnus-summary-insert-line
3159 header level nil (gnus-article-mark article)
3160 (memq article gnus-newsgroup-replied)
3161 (memq article gnus-newsgroup-expirable)
3162 ;; Only insert the Subject string when it's different
3163 ;; from the previous Subject string.
3164 (if (gnus-subject-equal
3166 (mail-header-subject
3169 (gnus-data-find-list
3171 (gnus-data-list t)))))
3172 ;; Error on the side of excessive subjects.
3174 (mail-header-subject header))
3176 (mail-header-subject header))
3177 nil (cdr (assq article gnus-newsgroup-scored))
3178 (memq article gnus-newsgroup-processable))
3180 (gnus-data-update-list
3181 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3183 (defun gnus-summary-update-article (article &optional iheader)
3184 "Update ARTICLE in the summary buffer."
3185 (set-buffer gnus-summary-buffer)
3186 (let* ((header (gnus-summary-article-header article))
3187 (id (mail-header-id header))
3188 (data (gnus-data-find article))
3189 (thread (gnus-id-to-thread id))
3190 (references (mail-header-references header))
3194 (when (and references
3195 (not (equal "" references)))
3198 (buffer-read-only nil)
3200 (number (mail-header-number header))
3206 (delq thread parent)))
3207 (if (gnus-summary-insert-subject id header)
3208 ;; Set the (possibly) new article number in the data structure.
3209 (gnus-data-set-number data (gnus-id-to-article id))
3213 (defun gnus-rebuild-thread (id &optional line)
3214 "Rebuild the thread containing ID.
3215 If LINE, insert the rebuilt thread starting on line LINE."
3216 (let ((buffer-read-only nil)
3217 old-pos current thread data)
3218 (if (not gnus-show-threads)
3219 (setq thread (list (car (gnus-id-to-thread id))))
3220 ;; Get the thread this article is part of.
3221 (setq thread (gnus-remove-thread id)))
3222 (setq old-pos (gnus-point-at-bol))
3223 (setq current (save-excursion
3224 (and (zerop (forward-line -1))
3225 (gnus-summary-article-number))))
3226 ;; If this is a gathered thread, we have to go some re-gathering.
3227 (when (stringp (car thread))
3228 (let ((subject (car thread))
3230 (setq thread (cdr thread))
3232 (unless (memq (setq thr (gnus-id-to-thread
3234 (mail-header-id (caar thread)))))
3237 (setq thread (cdr thread)))
3238 ;; We now have all (unique) roots.
3239 (if (= (length roots) 1)
3240 ;; All the loose roots are now one solid root.
3241 (setq thread (car roots))
3242 (setq thread (cons subject (gnus-sort-threads roots))))))
3244 ;; We then insert this thread into the summary buffer.
3246 (goto-char (point-min))
3247 (forward-line (1- line)))
3248 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3249 (if gnus-show-threads
3250 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3251 (gnus-summary-prepare-unthreaded thread))
3252 (setq data (nreverse gnus-newsgroup-data))
3253 (setq threads gnus-newsgroup-threads))
3254 ;; We splice the new data into the data structure.
3255 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3256 ;;!!! then we want to insert at the beginning of the buffer.
3257 ;;!!! That happens to be true with Gnus now, but that may
3258 ;;!!! change in the future. Perhaps.
3259 (gnus-data-enter-list
3260 (if line nil current) data (- (point) old-pos))
3261 (setq gnus-newsgroup-threads
3262 (nconc threads gnus-newsgroup-threads))
3263 (gnus-data-compute-positions))))
3265 (defun gnus-number-to-header (number)
3266 "Return the header for article NUMBER."
3267 (let ((headers gnus-newsgroup-headers))
3269 (not (= number (mail-header-number (car headers)))))
3274 (defun gnus-parent-headers (in-headers &optional generation)
3275 "Return the headers of the GENERATIONeth parent of HEADERS."
3277 (setq generation 1))
3279 (headers in-headers)
3282 (not (zerop generation))
3283 (setq references (mail-header-references headers)))
3284 (setq headers (if (and references
3285 (setq parent (gnus-parent-id references)))
3286 (car (gnus-id-to-thread parent))
3289 (and (not (eq headers in-headers))
3292 (defun gnus-id-to-thread (id)
3293 "Return the (sub-)thread where ID appears."
3294 (gnus-gethash id gnus-newsgroup-dependencies))
3296 (defun gnus-id-to-article (id)
3297 "Return the article number of ID."
3298 (let ((thread (gnus-id-to-thread id)))
3301 (mail-header-number (car thread)))))
3303 (defun gnus-id-to-header (id)
3304 "Return the article headers of ID."
3305 (car (gnus-id-to-thread id)))
3307 (defun gnus-article-displayed-root-p (article)
3308 "Say whether ARTICLE is a root(ish) article."
3309 (let ((level (gnus-summary-thread-level article))
3310 (refs (mail-header-references (gnus-summary-article-header article)))
3316 ((null (gnus-parent-id refs)) t)
3318 (null (setq particle (gnus-id-to-article
3319 (gnus-parent-id refs))))
3320 (null (gnus-summary-thread-level particle)))))))
3322 (defun gnus-root-id (id)
3323 "Return the id of the root of the thread where ID appears."
3325 (while (and id (setq prev (car (gnus-id-to-thread id))))
3327 id (gnus-parent-id (mail-header-references prev))))
3330 (defun gnus-articles-in-thread (thread)
3331 "Return the list of articles in THREAD."
3332 (cons (mail-header-number (car thread))
3333 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3335 (defun gnus-remove-thread (id &optional dont-remove)
3336 "Remove the thread that has ID in it."
3337 (let (headers thread last-id)
3338 ;; First go up in this thread until we find the root.
3339 (setq last-id (gnus-root-id id))
3340 (setq headers (list (car (gnus-id-to-thread last-id))
3341 (caadr (gnus-id-to-thread last-id))))
3342 ;; We have now found the real root of this thread. It might have
3343 ;; been gathered into some loose thread, so we have to search
3344 ;; through the threads to find the thread we wanted.
3345 (let ((threads gnus-newsgroup-threads)
3348 (setq sub (car threads))
3349 (if (stringp (car sub))
3350 ;; This is a gathered thread, so we look at the roots
3351 ;; below it to find whether this article is in this
3354 (setq sub (cdr sub))
3356 (when (member (caar sub) headers)
3357 (setq thread (car threads)
3360 (setq sub (cdr sub))))
3361 ;; It's an ordinary thread, so we check it.
3362 (when (eq (car sub) (car headers))
3365 (setq threads (cdr threads)))
3366 ;; If this article is in no thread, then it's a root.
3369 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3370 (setq thread (gnus-id-to-thread last-id)))
3373 thread ; We return this thread.
3375 (if (stringp (car thread))
3377 ;; If we use dummy roots, then we have to remove the
3378 ;; dummy root as well.
3379 (when (eq gnus-summary-make-false-root 'dummy)
3380 ;; We go to the dummy root by going to
3381 ;; the first sub-"thread", and then one line up.
3382 (gnus-summary-goto-article
3383 (mail-header-number (caadr thread)))
3386 (gnus-data-compute-positions))
3387 (setq thread (cdr thread))
3389 (gnus-remove-thread-1 (car thread))
3390 (setq thread (cdr thread))))
3391 (gnus-remove-thread-1 thread))))))))
3393 (defun gnus-remove-thread-1 (thread)
3394 "Remove the thread THREAD recursively."
3395 (let ((number (mail-header-number (pop thread)))
3397 (setq thread (reverse thread))
3399 (gnus-remove-thread-1 (pop thread)))
3400 (when (setq d (gnus-data-find number))
3401 (goto-char (gnus-data-pos d))
3404 (- (gnus-point-at-bol)
3406 (1+ (gnus-point-at-eol))
3407 (gnus-delete-line)))))))
3409 (defun gnus-sort-threads (threads)
3411 (if (not gnus-thread-sort-functions)
3413 (gnus-message 7 "Sorting threads...")
3415 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3416 (gnus-message 7 "Sorting threads...done"))))
3418 (defun gnus-sort-articles (articles)
3420 (when gnus-article-sort-functions
3421 (gnus-message 7 "Sorting articles...")
3423 (setq gnus-newsgroup-headers
3424 (sort articles (gnus-make-sort-function
3425 gnus-article-sort-functions)))
3426 (gnus-message 7 "Sorting articles...done"))))
3428 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3429 (defmacro gnus-thread-header (thread)
3430 ;; Return header of first article in THREAD.
3431 ;; Note that THREAD must never, ever be anything else than a variable -
3432 ;; using some other form will lead to serious barfage.
3433 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3434 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3435 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
3438 (defsubst gnus-article-sort-by-number (h1 h2)
3439 "Sort articles by article number."
3440 (< (mail-header-number h1)
3441 (mail-header-number h2)))
3443 (defun gnus-thread-sort-by-number (h1 h2)
3444 "Sort threads by root article number."
3445 (gnus-article-sort-by-number
3446 (gnus-thread-header h1) (gnus-thread-header h2)))
3448 (defsubst gnus-article-sort-by-lines (h1 h2)
3449 "Sort articles by article Lines header."
3450 (< (mail-header-lines h1)
3451 (mail-header-lines h2)))
3453 (defun gnus-thread-sort-by-lines (h1 h2)
3454 "Sort threads by root article Lines header."
3455 (gnus-article-sort-by-lines
3456 (gnus-thread-header h1) (gnus-thread-header h2)))
3458 (defsubst gnus-article-sort-by-author (h1 h2)
3459 "Sort articles by root author."
3461 (let ((extract (funcall
3462 gnus-extract-address-components
3463 (mail-header-from h1))))
3464 (or (car extract) (cadr extract) ""))
3465 (let ((extract (funcall
3466 gnus-extract-address-components
3467 (mail-header-from h2))))
3468 (or (car extract) (cadr extract) ""))))
3470 (defun gnus-thread-sort-by-author (h1 h2)
3471 "Sort threads by root author."
3472 (gnus-article-sort-by-author
3473 (gnus-thread-header h1) (gnus-thread-header h2)))
3475 (defsubst gnus-article-sort-by-subject (h1 h2)
3476 "Sort articles by root subject."
3478 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3479 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3481 (defun gnus-thread-sort-by-subject (h1 h2)
3482 "Sort threads by root subject."
3483 (gnus-article-sort-by-subject
3484 (gnus-thread-header h1) (gnus-thread-header h2)))
3486 (defsubst gnus-article-sort-by-date (h1 h2)
3487 "Sort articles by root article date."
3489 (gnus-date-get-time (mail-header-date h1))
3490 (gnus-date-get-time (mail-header-date h2))))
3492 (defun gnus-thread-sort-by-date (h1 h2)
3493 "Sort threads by root article date."
3494 (gnus-article-sort-by-date
3495 (gnus-thread-header h1) (gnus-thread-header h2)))
3497 (defsubst gnus-article-sort-by-score (h1 h2)
3498 "Sort articles by root article score.
3499 Unscored articles will be counted as having a score of zero."
3500 (> (or (cdr (assq (mail-header-number h1)
3501 gnus-newsgroup-scored))
3502 gnus-summary-default-score 0)
3503 (or (cdr (assq (mail-header-number h2)
3504 gnus-newsgroup-scored))
3505 gnus-summary-default-score 0)))
3507 (defun gnus-thread-sort-by-score (h1 h2)
3508 "Sort threads by root article score."
3509 (gnus-article-sort-by-score
3510 (gnus-thread-header h1) (gnus-thread-header h2)))
3512 (defun gnus-thread-sort-by-total-score (h1 h2)
3513 "Sort threads by the sum of all scores in the thread.
3514 Unscored articles will be counted as having a score of zero."
3515 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3517 (defun gnus-thread-total-score (thread)
3518 ;; This function find the total score of THREAD.
3519 (cond ((null thread)
3522 (if (stringp (car thread))
3523 (apply gnus-thread-score-function 0
3524 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3525 (gnus-thread-total-score-1 thread)))
3527 (gnus-thread-total-score-1 (list thread)))))
3529 (defun gnus-thread-total-score-1 (root)
3530 ;; This function find the total score of the thread below ROOT.
3531 (setq root (car root))
3532 (apply gnus-thread-score-function
3534 (mapcar 'gnus-thread-total-score
3535 (cdr (gnus-id-to-thread (mail-header-id root))))
3536 (when (> (mail-header-number root) 0)
3537 (list (or (cdr (assq (mail-header-number root)
3538 gnus-newsgroup-scored))
3539 gnus-summary-default-score 0))))
3540 (list gnus-summary-default-score)
3543 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3544 (defvar gnus-tmp-prev-subject nil)
3545 (defvar gnus-tmp-false-parent nil)
3546 (defvar gnus-tmp-root-expunged nil)
3547 (defvar gnus-tmp-dummy-line nil)
3549 (defun gnus-summary-prepare-threads (threads)
3550 "Prepare summary buffer from THREADS and indentation LEVEL.
3551 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3552 or a straight list of headers."
3553 (gnus-message 7 "Generating summary...")
3555 (setq gnus-newsgroup-threads threads)
3558 (let ((gnus-tmp-level 0)
3559 (default-score (or gnus-summary-default-score 0))
3560 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3561 thread number subject stack state gnus-tmp-gathered beg-match
3562 new-roots gnus-tmp-new-adopts thread-end
3563 gnus-tmp-header gnus-tmp-unread
3564 gnus-tmp-replied gnus-tmp-subject-or-nil
3565 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3566 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3567 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3569 (setq gnus-tmp-prev-subject nil)
3571 (if (vectorp (car threads))
3572 ;; If this is a straight (sic) list of headers, then a
3573 ;; threaded summary display isn't required, so we just create
3574 ;; an unthreaded one.
3575 (gnus-summary-prepare-unthreaded threads)
3577 ;; Do the threaded display.
3579 (while (or threads stack gnus-tmp-new-adopts new-roots)
3581 (if (and (= gnus-tmp-level 0)
3584 (not gnus-tmp-false-parent)
3585 (or gnus-tmp-new-adopts new-roots))
3586 (if gnus-tmp-new-adopts
3587 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3588 thread (list (car gnus-tmp-new-adopts))
3589 gnus-tmp-header (caar thread)
3590 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3592 (setq thread (list (car new-roots))
3593 gnus-tmp-header (caar thread)
3594 new-roots (cdr new-roots))))
3597 ;; If there are some threads, we do them before the
3598 ;; threads on the stack.
3599 (setq thread threads
3600 gnus-tmp-header (caar thread))
3601 ;; There were no current threads, so we pop something off
3603 (setq state (car stack)
3604 gnus-tmp-level (car state)
3607 gnus-tmp-header (caar thread))))
3609 (setq gnus-tmp-false-parent nil)
3610 (setq gnus-tmp-root-expunged nil)
3611 (setq thread-end nil)
3613 (if (stringp gnus-tmp-header)
3614 ;; The header is a dummy root.
3616 ((eq gnus-summary-make-false-root 'adopt)
3617 ;; We let the first article adopt the rest.
3618 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3620 (setq gnus-tmp-gathered
3622 (lambda (h) (mail-header-number (car h)))
3625 (setq thread (cons (list (caar thread)
3628 (setq gnus-tmp-level -1
3629 gnus-tmp-false-parent t))
3630 ((eq gnus-summary-make-false-root 'empty)
3631 ;; We print adopted articles with empty subject fields.
3632 (setq gnus-tmp-gathered
3634 (lambda (h) (mail-header-number (car h)))
3637 (setq gnus-tmp-level -1))
3638 ((eq gnus-summary-make-false-root 'dummy)
3639 ;; We remember that we probably want to output a dummy
3641 (setq gnus-tmp-dummy-line gnus-tmp-header)
3642 (setq gnus-tmp-prev-subject gnus-tmp-header))
3644 ;; We do not make a root for the gathered
3645 ;; sub-threads at all.
3646 (setq gnus-tmp-level -1)))
3648 (setq number (mail-header-number gnus-tmp-header)
3649 subject (mail-header-subject gnus-tmp-header))
3652 ;; If the thread has changed subject, we might want to make
3653 ;; this subthread into a root.
3654 ((and (null gnus-thread-ignore-subject)
3655 (not (zerop gnus-tmp-level))
3656 gnus-tmp-prev-subject
3658 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3659 (setq new-roots (nconc new-roots (list (car thread)))
3661 gnus-tmp-header nil))
3662 ;; If the article lies outside the current limit,
3663 ;; then we do not display it.
3664 ((not (memq number gnus-newsgroup-limit))
3665 (setq gnus-tmp-gathered
3667 (lambda (h) (mail-header-number (car h)))
3670 (setq gnus-tmp-new-adopts (if (cdar thread)
3671 (append gnus-tmp-new-adopts
3673 gnus-tmp-new-adopts)
3675 gnus-tmp-header nil)
3676 (when (zerop gnus-tmp-level)
3677 (setq gnus-tmp-root-expunged t)))
3678 ;; Perhaps this article is to be marked as read?
3679 ((and gnus-summary-mark-below
3680 (< (or (cdr (assq number gnus-newsgroup-scored))
3682 gnus-summary-mark-below)
3683 ;; Don't touch sparse articles.
3684 (not (gnus-summary-article-sparse-p number))
3685 (not (gnus-summary-article-ancient-p number)))
3686 (setq gnus-newsgroup-unreads
3687 (delq number gnus-newsgroup-unreads))
3688 (if gnus-newsgroup-auto-expire
3689 (push number gnus-newsgroup-expirable)
3690 (push (cons number gnus-low-score-mark)
3691 gnus-newsgroup-reads))))
3693 (when gnus-tmp-header
3694 ;; We may have an old dummy line to output before this
3696 (when (and gnus-tmp-dummy-line
3699 (mail-header-subject gnus-tmp-header)))
3700 (gnus-summary-insert-dummy-line
3701 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3702 (setq gnus-tmp-dummy-line nil))
3704 ;; Compute the mark.
3705 (setq gnus-tmp-unread (gnus-article-mark number))
3707 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3708 gnus-tmp-header gnus-tmp-level)
3709 gnus-newsgroup-data)
3711 ;; Actually insert the line.
3713 gnus-tmp-subject-or-nil
3715 ((and gnus-thread-ignore-subject
3716 gnus-tmp-prev-subject
3717 (not (inline (gnus-subject-equal
3718 gnus-tmp-prev-subject subject))))
3720 ((zerop gnus-tmp-level)
3721 (if (and (eq gnus-summary-make-false-root 'empty)
3722 (memq number gnus-tmp-gathered)
3723 gnus-tmp-prev-subject
3724 (inline (gnus-subject-equal
3725 gnus-tmp-prev-subject subject)))
3726 gnus-summary-same-subject
3728 (t gnus-summary-same-subject)))
3729 (if (and (eq gnus-summary-make-false-root 'adopt)
3730 (= gnus-tmp-level 1)
3731 (memq number gnus-tmp-gathered))
3732 (setq gnus-tmp-opening-bracket ?\<
3733 gnus-tmp-closing-bracket ?\>)
3734 (setq gnus-tmp-opening-bracket ?\[
3735 gnus-tmp-closing-bracket ?\]))
3737 gnus-tmp-indentation
3738 (aref gnus-thread-indent-array gnus-tmp-level)
3739 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3740 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3741 gnus-summary-default-score 0)
3743 (if (or (null gnus-summary-default-score)
3744 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3745 gnus-summary-zcore-fuzz))
3747 (if (< gnus-tmp-score gnus-summary-default-score)
3748 gnus-score-below-mark gnus-score-over-mark))
3750 (cond ((memq number gnus-newsgroup-processable)
3752 ((memq number gnus-newsgroup-cached)
3754 ((memq number gnus-newsgroup-replied)
3756 ((memq number gnus-newsgroup-saved)
3758 (t gnus-unread-mark))
3759 gnus-tmp-from (mail-header-from gnus-tmp-header)
3762 ((string-match "<[^>]+> *$" gnus-tmp-from)
3763 (setq beg-match (match-beginning 0))
3764 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3765 (substring gnus-tmp-from (1+ (match-beginning 0))
3766 (1- (match-end 0))))
3767 (substring gnus-tmp-from 0 beg-match)))
3768 ((string-match "(.+)" gnus-tmp-from)
3769 (substring gnus-tmp-from
3770 (1+ (match-beginning 0)) (1- (match-end 0))))
3772 (when (string= gnus-tmp-name "")
3773 (setq gnus-tmp-name gnus-tmp-from))
3774 (unless (numberp gnus-tmp-lines)
3775 (setq gnus-tmp-lines 0))
3776 (gnus-put-text-property-excluding-characters-with-faces
3778 (progn (eval gnus-summary-line-format-spec) (point))
3779 'gnus-number number)
3782 (gnus-run-hooks 'gnus-summary-update-hook)
3785 (setq gnus-tmp-prev-subject subject)))
3787 (when (nth 1 thread)
3788 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3789 (incf gnus-tmp-level)
3790 (setq threads (if thread-end nil (cdar thread)))
3792 (setq gnus-tmp-level 0)))))
3793 (gnus-message 7 "Generating summary...done"))
3795 (defun gnus-summary-prepare-unthreaded (headers)
3796 "Generate an unthreaded summary buffer based on HEADERS."
3797 (let (header number mark)
3802 ;; We may have to root out some bad articles...
3803 (when (memq (setq number (mail-header-number
3804 (setq header (pop headers))))
3805 gnus-newsgroup-limit)
3806 ;; Mark article as read when it has a low score.
3807 (when (and gnus-summary-mark-below
3808 (< (or (cdr (assq number gnus-newsgroup-scored))
3809 gnus-summary-default-score 0)
3810 gnus-summary-mark-below)
3811 (not (gnus-summary-article-ancient-p number)))
3812 (setq gnus-newsgroup-unreads
3813 (delq number gnus-newsgroup-unreads))
3814 (if gnus-newsgroup-auto-expire
3815 (push number gnus-newsgroup-expirable)
3816 (push (cons number gnus-low-score-mark)
3817 gnus-newsgroup-reads)))
3819 (setq mark (gnus-article-mark number))
3820 (push (gnus-data-make number mark (1+ (point)) header 0)
3821 gnus-newsgroup-data)
3822 (gnus-summary-insert-line
3824 mark (memq number gnus-newsgroup-replied)
3825 (memq number gnus-newsgroup-expirable)
3826 (mail-header-subject header) nil
3827 (cdr (assq number gnus-newsgroup-scored))
3828 (memq number gnus-newsgroup-processable))))))
3830 (defun gnus-select-newsgroup (group &optional read-all select-articles)
3831 "Select newsgroup GROUP.
3832 If READ-ALL is non-nil, all articles in the group are selected.
3833 If SELECT-ARTICLES, only select those articles from GROUP."
3834 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3835 ;;!!! Dirty hack; should be removed.
3836 (gnus-summary-ignore-duplicates
3837 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
3839 gnus-summary-ignore-duplicates))
3840 (info (nth 2 entry))
3841 articles fetched-articles cached)
3843 (unless (gnus-check-server
3844 (setq gnus-current-select-method
3845 (gnus-find-method-for-group group)))
3846 (error "Couldn't open server"))
3848 (or (and entry (not (eq (car entry) t))) ; Either it's active...
3849 (gnus-activate-group group) ; Or we can activate it...
3850 (progn ; Or we bug out.
3851 (when (equal major-mode 'gnus-summary-mode)
3852 (kill-buffer (current-buffer)))
3853 (error "Couldn't request group %s: %s"
3854 group (gnus-status-message group))))
3856 (unless (gnus-request-group group t)
3857 (when (equal major-mode 'gnus-summary-mode)
3858 (kill-buffer (current-buffer)))
3859 (error "Couldn't request group %s: %s"
3860 group (gnus-status-message group)))
3862 (setq gnus-newsgroup-name group)
3863 (setq gnus-newsgroup-unselected nil)
3864 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
3866 ;; Adjust and set lists of article marks.
3868 (gnus-adjust-marked-articles info))
3870 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3871 (when (gnus-virtual-group-p group)
3872 (setq cached gnus-newsgroup-cached))
3874 (setq gnus-newsgroup-unreads
3875 (gnus-set-difference
3876 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
3877 gnus-newsgroup-dormant))
3879 (setq gnus-newsgroup-processable nil)
3881 (gnus-update-read-articles group gnus-newsgroup-unreads)
3882 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
3883 (gnus-group-update-group group))
3885 (if (setq articles select-articles)
3886 (setq gnus-newsgroup-unselected
3887 (gnus-sorted-intersection
3888 gnus-newsgroup-unreads
3889 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
3890 (setq articles (gnus-articles-to-read group read-all)))
3894 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
3896 ((eq articles 0) nil)
3898 ;; Init the dependencies hash table.
3899 (setq gnus-newsgroup-dependencies
3900 (gnus-make-hashtable (length articles)))
3901 ;; Retrieve the headers and read them in.
3902 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
3903 (setq gnus-newsgroup-headers
3905 (setq gnus-headers-retrieved-by
3906 (gnus-retrieve-headers
3907 articles gnus-newsgroup-name
3908 ;; We might want to fetch old headers, but
3909 ;; not if there is only 1 article.
3911 (not (eq gnus-fetch-old-headers 'some))
3912 (not (numberp gnus-fetch-old-headers)))
3913 (> (length articles) 1))
3914 gnus-fetch-old-headers))))
3915 (gnus-get-newsgroup-headers-xover
3916 articles nil nil gnus-newsgroup-name t)
3917 (gnus-get-newsgroup-headers)))
3918 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
3920 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3922 (setq gnus-newsgroup-cached cached))
3924 ;; Suppress duplicates?
3925 (when gnus-suppress-duplicates
3926 (gnus-dup-suppress-articles))
3928 ;; Set the initial limit.
3929 (setq gnus-newsgroup-limit (copy-sequence articles))
3930 ;; Remove canceled articles from the list of unread articles.
3931 (setq gnus-newsgroup-unreads
3932 (gnus-set-sorted-intersection
3933 gnus-newsgroup-unreads
3934 (setq fetched-articles
3935 (mapcar (lambda (headers) (mail-header-number headers))
3936 gnus-newsgroup-headers))))
3937 ;; Removed marked articles that do not exist.
3938 (gnus-update-missing-marks
3939 (gnus-sorted-complement fetched-articles articles))
3940 ;; We might want to build some more threads first.
3941 (when (and gnus-fetch-old-headers
3942 (eq gnus-headers-retrieved-by 'nov))
3943 (if (eq gnus-fetch-old-headers 'invisible)
3944 (gnus-build-all-threads)
3945 (gnus-build-old-threads)))
3946 ;; Let the Gnus agent mark articles as read.
3948 (gnus-agent-get-undownloaded-list))
3949 ;; Check whether auto-expire is to be done in this group.
3950 (setq gnus-newsgroup-auto-expire
3951 (gnus-group-auto-expirable-p group))
3952 ;; Set up the article buffer now, if necessary.
3953 (unless gnus-single-article-buffer
3954 (gnus-article-setup-buffer))
3955 ;; First and last article in this newsgroup.
3956 (when gnus-newsgroup-headers
3957 (setq gnus-newsgroup-begin
3958 (mail-header-number (car gnus-newsgroup-headers))
3961 (gnus-last-element gnus-newsgroup-headers))))
3962 ;; GROUP is successfully selected.
3963 (or gnus-newsgroup-headers t)))))
3965 (defun gnus-articles-to-read (group &optional read-all)
3966 ;; Find out what articles the user wants to read.
3968 ;; Select all articles if `read-all' is non-nil, or if there
3969 ;; are no unread articles.
3971 (and (zerop (length gnus-newsgroup-marked))
3972 (zerop (length gnus-newsgroup-unreads)))
3973 (eq (gnus-group-find-parameter group 'display)
3975 (gnus-uncompress-range (gnus-active group))
3976 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
3977 (copy-sequence gnus-newsgroup-unreads))
3979 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
3980 (scored (length scored-list))
3981 (number (length articles))
3982 (marked (+ (length gnus-newsgroup-marked)
3983 (length gnus-newsgroup-dormant)))
3991 ((and (or (<= scored marked) (= scored number))
3992 (numberp gnus-large-newsgroup)
3993 (> number gnus-large-newsgroup))
3997 "How many articles from %s (default %d): "
3998 (gnus-limit-string gnus-newsgroup-name 35)
4000 (if (string-match "^[ \t]*$" input) number input)))
4001 ((and (> scored marked) (< scored number)
4002 (> (- scored number) 20))
4005 (format "%s %s (%d scored, %d total): "
4006 "How many articles from"
4007 group scored number))))
4008 (if (string-match "^[ \t]*$" input)
4012 (setq select (if (stringp select) (string-to-number select) select))
4013 (if (or (null select) (zerop select))
4015 (if (and (not (zerop scored)) (<= (abs select) scored))
4017 (setq articles (sort scored-list '<))
4018 (setq number (length articles)))
4019 (setq articles (copy-sequence articles)))
4021 (when (< (abs select) number)
4023 ;; Select the N oldest articles.
4024 (setcdr (nthcdr (1- (abs select)) articles) nil)
4025 ;; Select the N most recent articles.
4026 (setq articles (nthcdr (- number select) articles))))
4027 (setq gnus-newsgroup-unselected
4028 (gnus-sorted-intersection
4029 gnus-newsgroup-unreads
4030 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4033 (defun gnus-killed-articles (killed articles)
4036 (when (inline (gnus-member-of-range (car articles) killed))
4037 (push (car articles) out))
4038 (setq articles (cdr articles)))
4041 (defun gnus-uncompress-marks (marks)
4042 "Uncompress the mark ranges in MARKS."
4043 (let ((uncompressed '(score bookmark))
4046 (if (memq (caar marks) uncompressed)
4047 (push (car marks) out)
4048 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4049 (setq marks (cdr marks)))
4052 (defun gnus-adjust-marked-articles (info)
4053 "Set all article lists and remove all marks that are no longer legal."
4054 (let* ((marked-lists (gnus-info-marks info))
4055 (active (gnus-active (gnus-info-group info)))
4058 (types gnus-article-mark-lists)
4059 (uncompressed '(score bookmark killed))
4060 marks var articles article mark)
4063 (setq marks (pop marked-lists))
4064 (set (setq var (intern (format "gnus-newsgroup-%s"
4065 (car (rassq (setq mark (car marks))
4067 (if (memq (car marks) uncompressed) (cdr marks)
4068 (gnus-uncompress-range (cdr marks))))
4070 (setq articles (symbol-value var))
4072 ;; All articles have to be subsets of the active articles.
4074 ;; Adjust "simple" lists.
4075 ((memq mark '(tick dormant expire reply save))
4077 (when (or (< (setq article (pop articles)) min) (> article max))
4078 (set var (delq article (symbol-value var))))))
4080 ((memq mark uncompressed)
4081 (when (not (listp (cdr (symbol-value var))))
4082 (set var (list (symbol-value var))))
4083 (when (not (listp (cdr articles)))
4084 (setq articles (list articles)))
4086 (when (or (not (consp (setq article (pop articles))))
4087 (< (car article) min)
4088 (> (car article) max))
4089 (set var (delq article (symbol-value var))))))))))
4091 (defun gnus-update-missing-marks (missing)
4092 "Go through the list of MISSING articles and remove them from the mark lists."
4094 (let ((types gnus-article-mark-lists)
4096 ;; Go through all types.
4098 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4099 (when (symbol-value var)
4100 ;; This list has articles. So we delete all missing articles
4104 (set var (delq (pop m) (symbol-value var)))))))))
4106 (defun gnus-update-marks ()
4107 "Enter the various lists of marked articles into the newsgroup info list."
4108 (let ((types gnus-article-mark-lists)
4109 (info (gnus-get-info gnus-newsgroup-name))
4110 (uncompressed '(score bookmark killed))
4111 type list newmarked symbol)
4113 ;; Add all marks lists that are non-nil to the list of marks lists.
4114 (while (setq type (pop types))
4115 (when (setq list (symbol-value
4117 (intern (format "gnus-newsgroup-%s"
4120 ;; Get rid of the entries of the articles that have the
4122 (when (and (eq (cdr type) 'score)
4126 (prev (cons nil list))
4129 (if (or (not (consp (car arts)))
4130 (= (cdar arts) gnus-summary-default-score))
4131 (setcdr prev (cdr arts))
4133 (setq arts (cdr arts)))
4134 (setq list (cdr all))))
4136 (push (cons (cdr type)
4137 (if (memq (cdr type) uncompressed) list
4138 (gnus-compress-sequence
4139 (set symbol (sort list '<)) t)))
4142 ;; Enter these new marks into the info of the group.
4144 (setcar (nthcdr 3 info) newmarked)
4145 ;; Add the marks lists to the end of the info.
4147 (setcdr (nthcdr 2 info) (list newmarked))))
4149 ;; Cut off the end of the info if there's nothing else there.
4153 (when (nthcdr (decf i) info)
4154 (setcdr (nthcdr i info) nil)))))))
4156 (defun gnus-set-mode-line (where)
4157 "This function sets the mode line of the article or summary buffers.
4158 If WHERE is `summary', the summary mode line format will be used."
4159 ;; Is this mode line one we keep updated?
4160 (when (memq where gnus-updated-mode-lines)
4163 ;; We evaluate this in the summary buffer since these
4164 ;; variables are buffer-local to that buffer.
4165 (set-buffer gnus-summary-buffer)
4166 ;; We bind all these variables that are used in the `eval' form
4168 (let* ((mformat (symbol-value
4170 (format "gnus-%s-mode-line-format-spec" where))))
4171 (gnus-tmp-group-name gnus-newsgroup-name)
4172 (gnus-tmp-article-number (or gnus-current-article 0))
4173 (gnus-tmp-unread gnus-newsgroup-unreads)
4174 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4175 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4176 (gnus-tmp-unread-and-unselected
4177 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4178 (zerop gnus-tmp-unselected))
4180 ((zerop gnus-tmp-unselected)
4181 (format "{%d more}" gnus-tmp-unread-and-unticked))
4182 (t (format "{%d(+%d) more}"
4183 gnus-tmp-unread-and-unticked
4184 gnus-tmp-unselected))))
4186 (if (and gnus-current-headers
4187 (vectorp gnus-current-headers))
4188 (gnus-mode-string-quote
4189 (mail-header-subject gnus-current-headers))
4191 bufname-length max-len
4192 gnus-tmp-header);; passed as argument to any user-format-funcs
4193 (setq mode-string (eval mformat))
4194 (setq bufname-length (if (string-match "%b" mode-string)
4197 (if (eq where 'summary)
4199 (get-buffer gnus-article-buffer))))
4202 (setq max-len (max 4 (if gnus-mode-non-string-length
4204 gnus-mode-non-string-length
4206 (length mode-string))))
4207 ;; We might have to chop a bit of the string off...
4208 (when (> (length mode-string) max-len)
4210 (concat (gnus-truncate-string mode-string (- max-len 3))
4212 ;; Pad the mode string a bit.
4213 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4214 ;; Update the mode line.
4215 (setq mode-line-buffer-identification
4216 (gnus-mode-line-buffer-identification (list mode-string)))
4217 (set-buffer-modified-p t))))
4219 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4220 "Go through the HEADERS list and add all Xrefs to a hash table.
4221 The resulting hash table is returned, or nil if no Xrefs were found."
4222 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4223 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4224 (xref-hashtb (gnus-make-hashtable))
4225 start group entry number xrefs header)
4227 (setq header (pop headers))
4228 (when (and (setq xrefs (mail-header-xref header))
4229 (not (memq (setq number (mail-header-number header))
4232 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4233 (setq start (match-end 0))
4234 (setq group (if prefix
4235 (concat prefix (substring xrefs (match-beginning 1)
4237 (substring xrefs (match-beginning 1) (match-end 1))))
4239 (string-to-int (substring xrefs (match-beginning 2)
4241 (if (setq entry (gnus-gethash group xref-hashtb))
4242 (setcdr entry (cons number (cdr entry)))
4243 (gnus-sethash group (cons number nil) xref-hashtb)))))
4244 (and start xref-hashtb)))
4246 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4247 "Look through all the headers and mark the Xrefs as read."
4248 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4249 name entry info xref-hashtb idlist method nth4)
4251 (set-buffer gnus-group-buffer)
4252 (when (setq xref-hashtb
4253 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4256 (unless (string= from-newsgroup (setq name (symbol-name group)))
4257 (setq idlist (symbol-value group))
4258 ;; Dead groups are not updated.
4260 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4262 (when (stringp (setq nth4 (gnus-info-method info)))
4263 (setq nth4 (gnus-server-to-method nth4))))
4264 ;; Only do the xrefs if the group has the same
4265 ;; select method as the group we have just read.
4266 (or (gnus-methods-equal-p
4267 nth4 (gnus-find-method-for-group from-newsgroup))
4269 (equal nth4 (setq method (gnus-find-method-for-group
4271 (and (equal (car nth4) (car method))
4272 (equal (nth 1 nth4) (nth 1 method))))
4273 gnus-use-cross-reference
4274 (or (not (eq gnus-use-cross-reference t))
4276 ;; Only do cross-references on subscribed
4277 ;; groups, if that is what is wanted.
4278 (<= (gnus-info-level info) gnus-level-subscribed))
4279 (gnus-group-make-articles-read name idlist))))
4282 (defun gnus-compute-read-articles (group articles)
4283 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4284 (info (nth 2 entry))
4285 (active (gnus-active group))
4288 ;; First peel off all illegal article numbers.
4290 (let ((ids articles)
4292 (while (setq id (pop ids))
4293 (when (and first (> id (cdr active)))
4294 ;; We'll end up in this situation in one particular
4295 ;; obscure situation. If you re-scan a group and get
4296 ;; a new article that is cross-posted to a different
4297 ;; group that has not been re-scanned, you might get
4298 ;; crossposted article that has a higher number than
4299 ;; Gnus believes possible. So we re-activate this
4300 ;; group as well. This might mean doing the
4301 ;; crossposting thingy will *increase* the number
4302 ;; of articles in some groups. Tsk, tsk.
4303 (setq active (or (gnus-activate-group group) active)))
4304 (when (or (> id (cdr active))
4305 (< id (car active)))
4306 (setq articles (delq id articles))))))
4307 ;; If the read list is nil, we init it.
4309 (null (gnus-info-read info))
4311 (setq ninfo (cons 1 (1- (car active))))
4312 (setq ninfo (gnus-info-read info)))
4313 ;; Then we add the read articles to the range.
4315 ninfo (setq articles (sort articles '<))))))
4317 (defun gnus-group-make-articles-read (group articles)
4318 "Update the info of GROUP to say that ARTICLES are read."
4320 (entry (gnus-gethash group gnus-newsrc-hashtb))
4321 (info (nth 2 entry))
4322 (active (gnus-active group))
4325 (setq range (gnus-compute-read-articles group articles))
4327 (set-buffer gnus-group-buffer)
4330 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4331 (gnus-info-set-read ',info ',(gnus-info-read info))
4332 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4333 (gnus-group-update-group ,group t))))
4334 ;; Add the read articles to the range.
4335 (gnus-info-set-read info range)
4336 ;; Then we have to re-compute how many unread
4337 ;; articles there are in this group.
4341 (setq num (- (1+ (cdr active)) (car active))))
4342 ((not (listp (cdr range)))
4343 (setq num (- (cdr active) (- (1+ (cdr range))
4347 (if (numberp (car range))
4349 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4350 (setq range (cdr range)))
4351 (setq num (- (cdr active) num))))
4352 ;; Update the number of unread articles.
4354 ;; Update the group buffer.
4355 (gnus-group-update-group group t)))))
4357 (defun gnus-methods-equal-p (m1 m2)
4358 (let ((m1 (or m1 gnus-select-method))
4359 (m2 (or m2 gnus-select-method)))
4361 (and (eq (car m1) (car m2))
4362 (or (not (memq 'address (assoc (symbol-name (car m1))
4363 gnus-valid-select-methods)))
4364 (equal (nth 1 m1) (nth 1 m2)))))))
4366 (defvar gnus-newsgroup-none-id 0)
4368 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4369 (let ((cur nntp-server-buffer)
4372 (save-excursion (set-buffer gnus-summary-buffer)
4373 gnus-newsgroup-dependencies)))
4374 headers id id-dep ref-dep end ref)
4376 (set-buffer nntp-server-buffer)
4377 ;; Translate all TAB characters into SPACE characters.
4378 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4379 (gnus-run-hooks 'gnus-parse-headers-hook)
4380 (let ((case-fold-search t)
4381 in-reply-to header p lines chars)
4382 (goto-char (point-min))
4383 ;; Search to the beginning of the next header. Error messages
4384 ;; do not begin with 2 or 3.
4385 (while (re-search-forward "^[23][0-9]+ " nil t)
4388 ;; This implementation of this function, with nine
4389 ;; search-forwards instead of the one re-search-forward and
4390 ;; a case (which basically was the old function) is actually
4391 ;; about twice as fast, even though it looks messier. You
4392 ;; can't have everything, I guess. Speed and elegance
4393 ;; doesn't always go hand in hand.
4402 (narrow-to-region (point)
4403 (or (and (search-forward "\n.\n" nil t)
4409 (if (search-forward "\nsubject: " nil t)
4411 gnus-unstructured-field-decoder (nnheader-header-value))
4416 (if (search-forward "\nfrom: " nil t)
4418 gnus-structured-field-decoder (nnheader-header-value))
4423 (if (search-forward "\ndate: " nil t)
4424 (nnheader-header-value) ""))
4428 (setq id (if (re-search-forward
4429 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4430 ;; We do it this way to make sure the Message-ID
4431 ;; is (somewhat) syntactically valid.
4432 (buffer-substring (match-beginning 1)
4434 ;; If there was no message-id, we just fake one
4435 ;; to make subsequent routines simpler.
4436 (nnheader-generate-fake-message-id))))
4440 (if (search-forward "\nreferences: " nil t)
4444 (nnheader-header-value)
4449 (search-backward ">" end t)
4452 (search-backward "<" end t)
4454 ;; Get the references from the in-reply-to header if there
4455 ;; were no references and the in-reply-to header looks
4457 (if (and (search-forward "\nin-reply-to: " nil t)
4458 (setq in-reply-to (nnheader-header-value))
4459 (string-match "<[^>]+>" in-reply-to))
4461 (setq ref (substring in-reply-to (match-beginning 0)
4463 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4464 (setq ref2 (substring in-reply-to (match-beginning 0)
4466 (when (> (length ref2) (length ref))
4472 (if (search-forward "\nchars: " nil t)
4473 (if (numberp (setq chars (ignore-errors (read cur))))
4479 (if (search-forward "\nlines: " nil t)
4480 (if (numberp (setq lines (ignore-errors (read cur))))
4486 (and (search-forward "\nxref: " nil t)
4487 (nnheader-header-value)))))
4488 (when (equal id ref)
4491 (when gnus-alter-header-function
4492 (funcall gnus-alter-header-function header)
4493 (setq id (mail-header-id header)
4494 ref (gnus-parent-id (mail-header-references header))))
4497 (gnus-dependencies-add-header
4498 header dependencies force-new))
4499 (push header headers))
4500 (goto-char (point-max))
4502 (nreverse headers)))))
4504 ;; Goes through the xover lines and returns a list of vectors
4505 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4506 force-new dependencies
4507 group also-fetch-heads)
4508 "Parse the news overview data in the server buffer, and return a
4509 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4510 ;; Get the Xref when the users reads the articles since most/some
4511 ;; NNTP servers do not include Xrefs when using XOVER.
4512 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4513 (let ((cur nntp-server-buffer)
4514 (dependencies (or dependencies gnus-newsgroup-dependencies))
4515 number headers header)
4517 (set-buffer nntp-server-buffer)
4518 ;; Allow the user to mangle the headers before parsing them.
4519 (gnus-run-hooks 'gnus-parse-headers-hook)
4520 (goto-char (point-min))
4523 (while (and sequence (not (eobp)))
4524 (setq number (read cur))
4525 (while (and sequence
4526 (< (car sequence) number))
4527 (setq sequence (cdr sequence)))
4529 (eq number (car sequence))
4531 (setq sequence (cdr sequence))
4532 (setq header (inline
4533 (gnus-nov-parse-line
4534 number dependencies force-new))))
4535 (push header headers))
4538 (gnus-error 4 "Strange nov line (%d)"
4539 (count-lines (point-min) (point)))))
4541 ;; A common bug in inn is that if you have posted an article and
4542 ;; then retrieves the active file, it will answer correctly --
4543 ;; the new article is included. However, a NOV entry for the
4544 ;; article may not have been generated yet, so this may fail.
4545 ;; We work around this problem by retrieving the last few
4546 ;; headers using HEAD.
4547 (if (or (not also-fetch-heads)
4549 ;; We (probably) got all the headers.
4551 (let ((gnus-nov-is-evil t))
4554 (when (gnus-retrieve-headers sequence group)
4555 (gnus-get-newsgroup-headers))))))))
4557 (defun gnus-article-get-xrefs ()
4558 "Fill in the Xref value in `gnus-current-headers', if necessary.
4559 This is meant to be called in `gnus-article-internal-prepare-hook'."
4560 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4561 gnus-current-headers)))
4562 (or (not gnus-use-cross-reference)
4564 (and (mail-header-xref headers)
4565 (not (string= (mail-header-xref headers) "")))
4566 (let ((case-fold-search t)
4569 (nnheader-narrow-to-headers)
4570 (goto-char (point-min))
4571 (when (or (and (eq (downcase (following-char)) ?x)
4572 (looking-at "Xref:"))
4573 (search-forward "\nXref:" nil t))
4574 (goto-char (1+ (match-end 0)))
4575 (setq xref (buffer-substring (point)
4576 (progn (end-of-line) (point))))
4577 (mail-header-set-xref headers xref)))))))
4579 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4580 "Find article ID and insert the summary line for that article.
4581 OLD-HEADER can either be a header or a line number to insert
4582 the subject line on."
4583 (let* ((line (and (numberp old-header) old-header))
4584 (old-header (and (vectorp old-header) old-header))
4585 (header (cond ((and old-header use-old-header)
4588 (gnus-number-to-header id))
4589 (gnus-number-to-header id))
4591 (gnus-read-header id))))
4592 (number (and (numberp id) id))
4595 ;; Rebuild the thread that this article is part of and go to the
4596 ;; article we have fetched.
4597 (when (and (not gnus-show-threads)
4600 (setq d (gnus-data-find (mail-header-number old-header))))
4601 (goto-char (gnus-data-pos d))
4604 (- (gnus-point-at-bol)
4606 (1+ (gnus-point-at-eol))
4607 (gnus-delete-line))))))
4609 (mail-header-set-number header (mail-header-number old-header)))
4610 (setq gnus-newsgroup-sparse
4611 (delq (setq number (mail-header-number header))
4612 gnus-newsgroup-sparse))
4613 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4614 (push number gnus-newsgroup-limit)
4615 (gnus-rebuild-thread (mail-header-id header) line)
4616 (gnus-summary-goto-subject number nil t))
4617 (when (and (numberp number)
4619 ;; We have to update the boundaries even if we can't fetch the
4620 ;; article if ID is a number -- so that the next `P' or `N'
4621 ;; command will fetch the previous (or next) article even
4622 ;; if the one we tried to fetch this time has been canceled.
4623 (when (> number gnus-newsgroup-end)
4624 (setq gnus-newsgroup-end number))
4625 (when (< number gnus-newsgroup-begin)
4626 (setq gnus-newsgroup-begin number))
4627 (setq gnus-newsgroup-unselected
4628 (delq number gnus-newsgroup-unselected)))
4629 ;; Report back a success?
4630 (and header (mail-header-number header))))
4632 ;;; Process/prefix in the summary buffer
4634 (defun gnus-summary-work-articles (n)
4635 "Return a list of articles to be worked upon.
4636 The prefix argument, the list of process marked articles, and the
4637 current article will be taken into consideration."
4639 (set-buffer gnus-summary-buffer)
4642 ;; A numerical prefix has been given.
4643 (setq n (prefix-numeric-value n))
4644 (let ((backward (< n 0))
4645 (n (abs (prefix-numeric-value n)))
4650 (push (setq article (gnus-summary-article-number))
4653 (gnus-summary-find-prev nil article)
4654 (gnus-summary-find-next nil article)))
4656 (nreverse articles)))
4657 ((and (gnus-region-active-p) (mark))
4658 (message "region active")
4659 ;; Work on the region between point and mark.
4660 (let ((max (max (point) (mark)))
4663 (goto-char (min (min (point) (mark))))
4666 (push (setq article (gnus-summary-article-number)) articles)
4667 (gnus-summary-find-next nil article)
4669 (nreverse articles))))
4670 (gnus-newsgroup-processable
4671 ;; There are process-marked articles present.
4672 ;; Save current state.
4673 (gnus-summary-save-process-mark)
4675 (reverse gnus-newsgroup-processable))
4677 ;; Just return the current article.
4678 (list (gnus-summary-article-number))))))
4680 (defmacro gnus-summary-iterate (arg &rest forms)
4681 "Iterate over the process/prefixed articles and do FORMS.
4682 ARG is the interactive prefix given to the command. FORMS will be
4683 executed with point over the summary line of the articles."
4684 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
4685 `(let ((,articles (gnus-summary-work-articles ,arg)))
4687 (gnus-summary-goto-subject (car ,articles))
4690 (put 'gnus-summary-iterate 'lisp-indent-function 1)
4691 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
4693 (defun gnus-summary-save-process-mark ()
4694 "Push the current set of process marked articles on the stack."
4696 (push (copy-sequence gnus-newsgroup-processable)
4697 gnus-newsgroup-process-stack))
4699 (defun gnus-summary-kill-process-mark ()
4700 "Push the current set of process marked articles on the stack and unmark."
4702 (gnus-summary-save-process-mark)
4703 (gnus-summary-unmark-all-processable))
4705 (defun gnus-summary-yank-process-mark ()
4706 "Pop the last process mark state off the stack and restore it."
4708 (unless gnus-newsgroup-process-stack
4709 (error "Empty mark stack"))
4710 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4712 (defun gnus-summary-process-mark-set (set)
4713 "Make SET into the current process marked articles."
4714 (gnus-summary-unmark-all-processable)
4716 (gnus-summary-set-process-mark (pop set))))
4718 ;;; Searching and stuff
4720 (defun gnus-summary-search-group (&optional backward use-level)
4721 "Search for next unread newsgroup.
4722 If optional argument BACKWARD is non-nil, search backward instead."
4724 (set-buffer gnus-group-buffer)
4725 (when (gnus-group-search-forward
4726 backward nil (if use-level (gnus-group-group-level) nil))
4727 (gnus-group-group-name))))
4729 (defun gnus-summary-best-group (&optional exclude-group)
4730 "Find the name of the best unread group.
4731 If EXCLUDE-GROUP, do not go to this group."
4733 (set-buffer gnus-group-buffer)
4735 (gnus-group-best-unread-group exclude-group))))
4737 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
4738 (if backward (gnus-summary-find-prev)
4739 (let* ((dummy (gnus-summary-article-intangible-p))
4740 (article (or article (gnus-summary-article-number)))
4741 (arts (gnus-data-find-list article))
4743 (when (and (not dummy)
4744 (or (not gnus-summary-check-current)
4746 (not (gnus-data-unread-p (car arts)))))
4747 (setq arts (cdr arts)))
4752 (when (or (and undownloaded
4753 (eq gnus-undownloaded-mark
4754 (gnus-data-mark (car arts))))
4755 (gnus-data-unread-p (car arts)))
4756 (setq result (car arts)
4758 (setq arts (cdr arts)))
4761 (goto-char (gnus-data-pos result))
4762 (gnus-data-number result)))))
4764 (defun gnus-summary-find-prev (&optional unread article)
4765 (let* ((eobp (eobp))
4766 (article (or article (gnus-summary-article-number)))
4767 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
4769 (when (and (not eobp)
4770 (or (not gnus-summary-check-current)
4772 (not (gnus-data-unread-p (car arts)))))
4773 (setq arts (cdr arts)))
4778 (when (gnus-data-unread-p (car arts))
4779 (setq result (car arts)
4781 (setq arts (cdr arts)))
4784 (goto-char (gnus-data-pos result))
4785 (gnus-data-number result))))
4787 (defun gnus-summary-find-subject (subject &optional unread backward article)
4788 (let* ((simp-subject (gnus-simplify-subject-fully subject))
4789 (article (or article (gnus-summary-article-number)))
4790 (articles (gnus-data-list backward))
4791 (arts (gnus-data-find-list article articles))
4793 (when (or (not gnus-summary-check-current)
4795 (not (gnus-data-unread-p (car arts))))
4796 (setq arts (cdr arts)))
4798 (and (or (not unread)
4799 (gnus-data-unread-p (car arts)))
4800 (vectorp (gnus-data-header (car arts)))
4802 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
4803 (setq result (car arts)
4805 (setq arts (cdr arts)))
4807 (goto-char (gnus-data-pos result))
4808 (gnus-data-number result))))
4810 (defun gnus-summary-search-forward (&optional unread subject backward)
4811 "Search forward for an article.
4812 If UNREAD, look for unread articles. If SUBJECT, look for
4813 articles with that subject. If BACKWARD, search backward instead."
4814 (cond (subject (gnus-summary-find-subject subject unread backward))
4815 (backward (gnus-summary-find-prev unread))
4816 (t (gnus-summary-find-next unread))))
4818 (defun gnus-recenter (&optional n)
4819 "Center point in window and redisplay frame.
4820 Also do horizontal recentering."
4822 (when (and gnus-auto-center-summary
4823 (not (eq gnus-auto-center-summary 'vertical)))
4824 (gnus-horizontal-recenter))
4827 (defun gnus-summary-recenter ()
4828 "Center point in the summary window.
4829 If `gnus-auto-center-summary' is nil, or the article buffer isn't
4830 displayed, no centering will be performed."
4831 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
4832 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
4833 (let* ((top (cond ((< (window-height) 4) 0)
4834 ((< (window-height) 7) 1)
4836 (height (1- (window-height)))
4837 (bottom (save-excursion (goto-char (point-max))
4838 (forward-line (- height))
4840 (window (get-buffer-window (current-buffer))))
4841 ;; The user has to want it.
4842 (when gnus-auto-center-summary
4843 (when (get-buffer-window gnus-article-buffer)
4844 ;; Only do recentering when the article buffer is displayed,
4845 ;; Set the window start to either `bottom', which is the biggest
4846 ;; possible valid number, or the second line from the top,
4847 ;; whichever is the least.
4849 window (min bottom (save-excursion
4850 (forward-line (- top)) (point)))))
4851 ;; Do horizontal recentering while we're at it.
4852 (when (and (get-buffer-window (current-buffer) t)
4853 (not (eq gnus-auto-center-summary 'vertical)))
4854 (let ((selected (selected-window)))
4855 (select-window (get-buffer-window (current-buffer) t))
4856 (gnus-summary-position-point)
4857 (gnus-horizontal-recenter)
4858 (select-window selected))))))
4860 (defun gnus-summary-jump-to-group (newsgroup)
4861 "Move point to NEWSGROUP in group mode buffer."
4862 ;; Keep update point of group mode buffer if visible.
4863 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
4864 (save-window-excursion
4865 ;; Take care of tree window mode.
4866 (when (get-buffer-window gnus-group-buffer)
4867 (pop-to-buffer gnus-group-buffer))
4868 (gnus-group-jump-to-group newsgroup))
4870 ;; Take care of tree window mode.
4871 (if (get-buffer-window gnus-group-buffer)
4872 (pop-to-buffer gnus-group-buffer)
4873 (set-buffer gnus-group-buffer))
4874 (gnus-group-jump-to-group newsgroup))))
4876 ;; This function returns a list of article numbers based on the
4877 ;; difference between the ranges of read articles in this group and
4878 ;; the range of active articles.
4879 (defun gnus-list-of-unread-articles (group)
4880 (let* ((read (gnus-info-read (gnus-get-info group)))
4881 (active (or (gnus-active group) (gnus-activate-group group)))
4884 ;; If none are read, then all are unread.
4886 (setq first (car active))
4887 ;; If the range of read articles is a single range, then the
4888 ;; first unread article is the article after the last read
4889 ;; article. Sounds logical, doesn't it?
4890 (if (not (listp (cdr read)))
4891 (setq first (max (car active) (1+ (cdr read))))
4892 ;; `read' is a list of ranges.
4893 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
4896 (setq first (car active)))
4899 (while (< first nlast)
4901 (setq first (1+ first))))
4902 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
4903 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
4904 (setq read (cdr read)))))
4905 ;; And add the last unread articles.
4906 (while (<= first last)
4908 (setq first (1+ first)))
4909 ;; Return the list of unread articles.
4910 (delq 0 (nreverse unread))))
4912 (defun gnus-list-of-read-articles (group)
4913 "Return a list of unread, unticked and non-dormant articles."
4914 (let* ((info (gnus-get-info group))
4915 (marked (gnus-info-marks info))
4916 (active (gnus-active group)))
4918 (gnus-set-difference
4919 (gnus-sorted-complement
4920 (gnus-uncompress-range active)
4921 (gnus-list-of-unread-articles group))
4923 (gnus-uncompress-range (cdr (assq 'dormant marked)))
4924 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
4926 ;; Various summary commands
4928 (defun gnus-summary-select-article-buffer ()
4929 "Reconfigure windows to show article buffer."
4931 (if (not (gnus-buffer-live-p gnus-article-buffer))
4932 (error "There is no article buffer for this summary buffer")
4933 (gnus-configure-windows 'article)
4934 (select-window (get-buffer-window gnus-article-buffer))))
4936 (defun gnus-summary-universal-argument (arg)
4937 "Perform any operation on all articles that are process/prefixed."
4939 (let ((articles (gnus-summary-work-articles arg))
4946 (substitute-command-keys
4947 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
4950 (gnus-error 1 "Undefined key")
4953 (gnus-summary-goto-subject (setq article (pop articles)))
4954 (let (gnus-newsgroup-processable)
4955 (command-execute func))
4956 (gnus-summary-remove-process-mark article)))))
4957 (gnus-summary-position-point))
4959 (defun gnus-summary-toggle-truncation (&optional arg)
4960 "Toggle truncation of summary lines.
4961 With arg, turn line truncation on iff arg is positive."
4963 (setq truncate-lines
4964 (if (null arg) (not truncate-lines)
4965 (> (prefix-numeric-value arg) 0)))
4968 (defun gnus-summary-reselect-current-group (&optional all rescan)
4969 "Exit and then reselect the current newsgroup.
4970 The prefix argument ALL means to select all articles."
4972 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
4973 (error "Ephemeral groups can't be reselected"))
4974 (let ((current-subject (gnus-summary-article-number))
4975 (group gnus-newsgroup-name))
4976 (setq gnus-newsgroup-begin nil)
4978 ;; We have to adjust the point of group mode buffer because
4979 ;; point was moved to the next unread newsgroup by exiting.
4980 (gnus-summary-jump-to-group group)
4983 (gnus-group-get-new-news-this-group 1)))
4984 (gnus-group-read-group all t)
4985 (gnus-summary-goto-subject current-subject nil t)))
4987 (defun gnus-summary-rescan-group (&optional all)
4988 "Exit the newsgroup, ask for new articles, and select the newsgroup."
4990 (gnus-summary-reselect-current-group all t))
4992 (defun gnus-summary-update-info (&optional non-destructive)
4994 (let ((group gnus-newsgroup-name))
4996 (when gnus-newsgroup-kill-headers
4997 (setq gnus-newsgroup-killed
4998 (gnus-compress-sequence
5000 (gnus-set-sorted-intersection
5001 (gnus-uncompress-range gnus-newsgroup-killed)
5002 (setq gnus-newsgroup-unselected
5003 (sort gnus-newsgroup-unselected '<)))
5004 (setq gnus-newsgroup-unreads
5005 (sort gnus-newsgroup-unreads '<)))
5007 (unless (listp (cdr gnus-newsgroup-killed))
5008 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5009 (let ((headers gnus-newsgroup-headers))
5010 ;; Set the new ranges of read articles.
5012 (set-buffer gnus-group-buffer)
5013 (gnus-undo-force-boundary))
5014 (gnus-update-read-articles
5015 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5016 ;; Set the current article marks.
5017 (let ((gnus-newsgroup-scored
5018 (if (and (not gnus-save-score)
5019 (not non-destructive))
5021 gnus-newsgroup-scored)))
5023 (gnus-update-marks)))
5024 ;; Do the cross-ref thing.
5025 (when gnus-use-cross-reference
5026 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5027 ;; Do not switch windows but change the buffer to work.
5028 (set-buffer gnus-group-buffer)
5029 (unless (gnus-ephemeral-group-p group)
5030 (gnus-group-update-group group)))))))
5032 (defun gnus-summary-save-newsrc (&optional force)
5033 "Save the current number of read/marked articles in the dribble buffer.
5034 The dribble buffer will then be saved.
5035 If FORCE (the prefix), also save the .newsrc file(s)."
5037 (gnus-summary-update-info t)
5039 (gnus-save-newsrc-file)
5040 (gnus-dribble-save)))
5042 (defun gnus-summary-exit (&optional temporary)
5043 "Exit reading current newsgroup, and then return to group selection mode.
5044 gnus-exit-group-hook is called with no arguments if that value is non-nil."
5046 (gnus-set-global-variables)
5047 (gnus-kill-save-kill-buffer)
5048 (gnus-async-halt-prefetch)
5049 (let* ((group gnus-newsgroup-name)
5050 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5053 (buf (current-buffer)))
5054 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5055 ;; If we have several article buffers, we kill them at exit.
5056 (unless gnus-single-article-buffer
5057 (gnus-kill-buffer gnus-original-article-buffer)
5058 (setq gnus-article-current nil))
5059 (when gnus-use-cache
5060 (gnus-cache-possibly-remove-articles)
5061 (gnus-cache-save-buffers))
5062 (gnus-async-prefetch-remove-group group)
5063 (when gnus-suppress-duplicates
5064 (gnus-dup-enter-articles))
5065 (when gnus-use-trees
5066 (gnus-tree-close group))
5067 ;; Remove entries for this group.
5068 (nnmail-purge-split-history (gnus-group-real-name group))
5069 ;; Make all changes in this group permanent.
5071 (gnus-run-hooks 'gnus-exit-group-hook)
5072 (gnus-summary-update-info)
5073 ;; Do adaptive scoring, and possibly save score files.
5074 (when gnus-newsgroup-adaptive
5075 (gnus-score-adaptive))
5076 (when gnus-use-scoring
5078 (gnus-close-group group)
5079 ;; Make sure where we were, and go to next newsgroup.
5080 (set-buffer gnus-group-buffer)
5082 (gnus-group-jump-to-group group))
5083 (gnus-run-hooks 'gnus-summary-exit-hook)
5084 (unless (or quit-config
5085 ;; If this group has disappeared from the summary
5086 ;; buffer, don't skip forwards.
5087 (not (string= group (gnus-group-group-name))))
5088 (gnus-group-next-unread-group 1))
5089 (setq group-point (point))
5092 ;; If we have several article buffers, we kill them at exit.
5093 (unless gnus-single-article-buffer
5094 (gnus-kill-buffer gnus-article-buffer)
5095 (gnus-kill-buffer gnus-original-article-buffer)
5096 (setq gnus-article-current nil))
5098 (if (not gnus-kill-summary-on-exit)
5099 (gnus-deaden-summary)
5100 ;; We set all buffer-local variables to nil. It is unclear why
5101 ;; this is needed, but if we don't, buffer-local variables are
5102 ;; not garbage-collected, it seems. This would the lead to en
5103 ;; ever-growing Emacs.
5104 (gnus-summary-clear-local-variables)
5105 (when (get-buffer gnus-article-buffer)
5106 (bury-buffer gnus-article-buffer))
5107 ;; We clear the global counterparts of the buffer-local
5108 ;; variables as well, just to be on the safe side.
5109 (set-buffer gnus-group-buffer)
5110 (gnus-summary-clear-local-variables)
5111 ;; Return to group mode buffer.
5112 (when (eq mode 'gnus-summary-mode)
5113 (gnus-kill-buffer buf)))
5114 (setq gnus-current-select-method gnus-select-method)
5115 (pop-to-buffer gnus-group-buffer)
5116 ;; Clear the current group name.
5117 (if (not quit-config)
5119 (goto-char group-point)
5120 (gnus-configure-windows 'group 'force))
5121 (gnus-handle-ephemeral-exit quit-config))
5123 (setq gnus-newsgroup-name nil)))))
5125 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5126 (defun gnus-summary-exit-no-update (&optional no-questions)
5127 "Quit reading current newsgroup without updating read article info."
5129 (let* ((group gnus-newsgroup-name)
5130 (quit-config (gnus-group-quit-config group)))
5131 (when (or no-questions
5133 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5134 (gnus-async-halt-prefetch)
5135 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5136 ;; If we have several article buffers, we kill them at exit.
5137 (unless gnus-single-article-buffer
5138 (gnus-kill-buffer gnus-article-buffer)
5139 (gnus-kill-buffer gnus-original-article-buffer)
5140 (setq gnus-article-current nil))
5141 (if (not gnus-kill-summary-on-exit)
5142 (gnus-deaden-summary)
5143 (gnus-close-group group)
5144 (gnus-summary-clear-local-variables)
5145 (set-buffer gnus-group-buffer)
5146 (gnus-summary-clear-local-variables)
5147 (when (get-buffer gnus-summary-buffer)
5148 (kill-buffer gnus-summary-buffer)))
5149 (unless gnus-single-article-buffer
5150 (setq gnus-article-current nil))
5151 (when gnus-use-trees
5152 (gnus-tree-close group))
5153 (gnus-async-prefetch-remove-group group)
5154 (when (get-buffer gnus-article-buffer)
5155 (bury-buffer gnus-article-buffer))
5156 ;; Return to the group buffer.
5157 (gnus-configure-windows 'group 'force)
5158 ;; Clear the current group name.
5159 (setq gnus-newsgroup-name nil)
5160 (when (equal (gnus-group-group-name) group)
5161 (gnus-group-next-unread-group 1))
5163 (gnus-handle-ephemeral-exit quit-config)))))
5165 (defun gnus-handle-ephemeral-exit (quit-config)
5166 "Handle movement when leaving an ephemeral group.
5167 The state which existed when entering the ephemeral is reset."
5168 (if (not (buffer-name (car quit-config)))
5169 (gnus-configure-windows 'group 'force)
5170 (set-buffer (car quit-config))
5171 (cond ((eq major-mode 'gnus-summary-mode)
5172 (gnus-set-global-variables))
5173 ((eq major-mode 'gnus-article-mode)
5175 ;; The `gnus-summary-buffer' variable may point
5176 ;; to the old summary buffer when using a single
5178 (unless (gnus-buffer-live-p gnus-summary-buffer)
5179 (set-buffer gnus-group-buffer))
5180 (set-buffer gnus-summary-buffer)
5181 (gnus-set-global-variables))))
5182 (if (or (eq (cdr quit-config) 'article)
5183 (eq (cdr quit-config) 'pick))
5185 ;; The current article may be from the ephemeral group
5186 ;; thus it is best that we reload this article
5187 (gnus-summary-show-article)
5188 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5189 (gnus-configure-windows 'pick 'force)
5190 (gnus-configure-windows (cdr quit-config) 'force)))
5191 (gnus-configure-windows (cdr quit-config) 'force))
5192 (when (eq major-mode 'gnus-summary-mode)
5193 (gnus-summary-next-subject 1 nil t)
5194 (gnus-summary-recenter)
5195 (gnus-summary-position-point))))
5199 (defvar gnus-dead-summary-mode-map nil)
5201 (unless gnus-dead-summary-mode-map
5202 (setq gnus-dead-summary-mode-map (make-keymap))
5203 (suppress-keymap gnus-dead-summary-mode-map)
5204 (substitute-key-definition
5205 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5206 (let ((keys '("\C-d" "\r" "\177" [delete])))
5208 (define-key gnus-dead-summary-mode-map
5209 (pop keys) 'gnus-summary-wake-up-the-dead))))
5211 (defvar gnus-dead-summary-mode nil
5212 "Minor mode for Gnus summary buffers.")
5214 (defun gnus-dead-summary-mode (&optional arg)
5215 "Minor mode for Gnus summary buffers."
5217 (when (eq major-mode 'gnus-summary-mode)
5218 (make-local-variable 'gnus-dead-summary-mode)
5219 (setq gnus-dead-summary-mode
5220 (if (null arg) (not gnus-dead-summary-mode)
5221 (> (prefix-numeric-value arg) 0)))
5222 (when gnus-dead-summary-mode
5223 (gnus-add-minor-mode
5224 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5226 (defun gnus-deaden-summary ()
5227 "Make the current summary buffer into a dead summary buffer."
5228 ;; Kill any previous dead summary buffer.
5229 (when (and gnus-dead-summary
5230 (buffer-name gnus-dead-summary))
5232 (set-buffer gnus-dead-summary)
5233 (when gnus-dead-summary-mode
5234 (kill-buffer (current-buffer)))))
5235 ;; Make this the current dead summary.
5236 (setq gnus-dead-summary (current-buffer))
5237 (gnus-dead-summary-mode 1)
5238 (let ((name (buffer-name)))
5239 (when (string-match "Summary" name)
5241 (concat (substring name 0 (match-beginning 0)) "Dead "
5242 (substring name (match-beginning 0)))
5245 (defun gnus-kill-or-deaden-summary (buffer)
5246 "Kill or deaden the summary BUFFER."
5248 (when (and (buffer-name buffer)
5249 (not gnus-single-article-buffer))
5252 (gnus-kill-buffer gnus-article-buffer)
5253 (gnus-kill-buffer gnus-original-article-buffer)))
5254 (cond (gnus-kill-summary-on-exit
5255 (when (and gnus-use-trees
5256 (gnus-buffer-exists-p buffer))
5259 (gnus-tree-close gnus-newsgroup-name)))
5260 (gnus-kill-buffer buffer))
5261 ((gnus-buffer-exists-p buffer)
5264 (gnus-deaden-summary))))))
5266 (defun gnus-summary-wake-up-the-dead (&rest args)
5267 "Wake up the dead summary buffer."
5269 (gnus-dead-summary-mode -1)
5270 (let ((name (buffer-name)))
5271 (when (string-match "Dead " name)
5273 (concat (substring name 0 (match-beginning 0))
5274 (substring name (match-end 0)))
5276 (gnus-message 3 "This dead summary is now alive again"))
5278 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5279 (defun gnus-summary-fetch-faq (&optional faq-dir)
5280 "Fetch the FAQ for the current group.
5281 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5285 (when current-prefix-arg
5287 "Faq dir: " (and (listp gnus-group-faq-directory)
5288 (mapcar (lambda (file) (list file))
5289 gnus-group-faq-directory))))))
5290 (let (gnus-faq-buffer)
5291 (when (setq gnus-faq-buffer
5292 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5293 (gnus-configure-windows 'summary-faq))))
5295 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5296 (defun gnus-summary-describe-group (&optional force)
5297 "Describe the current newsgroup."
5299 (gnus-group-describe-group force gnus-newsgroup-name))
5301 (defun gnus-summary-describe-briefly ()
5302 "Describe summary mode commands briefly."
5305 (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")))
5307 ;; Walking around group mode buffer from summary mode.
5309 (defun gnus-summary-next-group (&optional no-article target-group backward)
5310 "Exit current newsgroup and then select next unread newsgroup.
5311 If prefix argument NO-ARTICLE is non-nil, no article is selected
5312 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5313 previous group instead."
5315 ;; Stop pre-fetching.
5316 (gnus-async-halt-prefetch)
5317 (let ((current-group gnus-newsgroup-name)
5318 (current-buffer (current-buffer))
5320 ;; First we semi-exit this group to update Xrefs and all variables.
5321 ;; We can't do a real exit, because the window conf must remain
5322 ;; the same in case the user is prompted for info, and we don't
5323 ;; want the window conf to change before that...
5324 (gnus-summary-exit t)
5325 (while (not entered)
5326 ;; Then we find what group we are supposed to enter.
5327 (set-buffer gnus-group-buffer)
5328 (gnus-group-jump-to-group current-group)
5331 (if (eq gnus-keep-same-level 'best)
5332 (gnus-summary-best-group gnus-newsgroup-name)
5333 (gnus-summary-search-group backward gnus-keep-same-level))))
5334 (if (not target-group)
5335 ;; There are no further groups, so we return to the group
5338 (gnus-message 5 "Returning to the group buffer")
5340 (when (gnus-buffer-live-p current-buffer)
5341 (set-buffer current-buffer)
5342 (gnus-summary-exit))
5343 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5344 ;; We try to enter the target group.
5345 (gnus-group-jump-to-group target-group)
5346 (let ((unreads (gnus-group-group-unread)))
5347 (if (and (or (eq t unreads)
5348 (and unreads (not (zerop unreads))))
5349 (gnus-summary-read-group
5350 target-group nil no-article
5351 (and (buffer-name current-buffer) current-buffer)
5354 (setq current-group target-group
5355 target-group nil)))))))
5357 (defun gnus-summary-prev-group (&optional no-article)
5358 "Exit current newsgroup and then select previous unread newsgroup.
5359 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5361 (gnus-summary-next-group no-article nil t))
5363 ;; Walking around summary lines.
5365 (defun gnus-summary-first-subject (&optional unread undownloaded)
5366 "Go to the first unread subject.
5367 If UNREAD is non-nil, go to the first unread article.
5368 Returns the article selected or nil if there are no unread articles."
5373 ((null gnus-newsgroup-data)
5374 (gnus-message 3 "No articles in the group")
5376 ;; Pick the first article.
5378 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5379 (gnus-data-number (car gnus-newsgroup-data)))
5380 ;; No unread articles.
5381 ((null gnus-newsgroup-unreads)
5382 (gnus-message 3 "No more unread articles")
5384 ;; Find the first unread article.
5386 (let ((data gnus-newsgroup-data))
5388 (and (not (and undownloaded
5389 (eq gnus-undownloaded-mark
5390 (gnus-data-mark (car data)))))
5391 (not (gnus-data-unread-p (car data)))))
5392 (setq data (cdr data)))
5394 (goto-char (gnus-data-pos (car data)))
5395 (gnus-data-number (car data))))))
5396 (gnus-summary-position-point)))
5398 (defun gnus-summary-next-subject (n &optional unread dont-display)
5399 "Go to next N'th summary line.
5400 If N is negative, go to the previous N'th subject line.
5401 If UNREAD is non-nil, only unread articles are selected.
5402 The difference between N and the actual number of steps taken is
5405 (let ((backward (< n 0))
5409 (gnus-summary-find-prev unread)
5410 (gnus-summary-find-next unread)))
5411 (gnus-summary-show-thread)
5414 (gnus-message 7 "No more%s articles"
5415 (if unread " unread" "")))
5416 (unless dont-display
5417 (gnus-summary-recenter)
5418 (gnus-summary-position-point))
5421 (defun gnus-summary-next-unread-subject (n)
5422 "Go to next N'th unread summary line."
5424 (gnus-summary-next-subject n t))
5426 (defun gnus-summary-prev-subject (n &optional unread)
5427 "Go to previous N'th summary line.
5428 If optional argument UNREAD is non-nil, only unread article is selected."
5430 (gnus-summary-next-subject (- n) unread))
5432 (defun gnus-summary-prev-unread-subject (n)
5433 "Go to previous N'th unread summary line."
5435 (gnus-summary-next-subject (- n) t))
5437 (defun gnus-summary-goto-subject (article &optional force silent)
5438 "Go the subject line of ARTICLE.
5439 If FORCE, also allow jumping to articles not currently shown."
5440 (interactive "nArticle number: ")
5442 (data (gnus-data-find article)))
5443 ;; We read in the article if we have to.
5446 (gnus-summary-insert-subject
5448 (if (or (numberp force) (vectorp force)) force)
5450 (setq data (gnus-data-find article)))
5455 (gnus-message 3 "Can't find article %d" article))
5457 (goto-char (gnus-data-pos data))
5458 (gnus-summary-position-point)
5461 ;; Walking around summary lines with displaying articles.
5463 (defun gnus-summary-expand-window (&optional arg)
5464 "Make the summary buffer take up the entire Emacs frame.
5465 Given a prefix, will force an `article' buffer configuration."
5468 (gnus-configure-windows 'article 'force)
5469 (gnus-configure-windows 'summary 'force)))
5471 (defun gnus-summary-display-article (article &optional all-header)
5472 "Display ARTICLE in article buffer."
5473 (gnus-set-global-variables)
5477 (if gnus-summary-display-article-function
5478 (funcall gnus-summary-display-article-function article all-header)
5479 (gnus-article-prepare article all-header))
5480 (gnus-run-hooks 'gnus-select-article-hook)
5481 (when (and gnus-current-article
5482 (not (zerop gnus-current-article)))
5483 (gnus-summary-goto-subject gnus-current-article))
5484 (gnus-summary-recenter)
5485 (when (and gnus-use-trees gnus-show-threads)
5486 (gnus-possibly-generate-tree article)
5487 (gnus-highlight-selected-tree article))
5488 ;; Successfully display article.
5489 (gnus-article-set-window-start
5490 (cdr (assq article gnus-newsgroup-bookmarks))))))
5492 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5493 "Select the current article.
5494 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5495 non-nil, the article will be re-fetched even if it already present in
5496 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5498 ;; Make sure we are in the summary buffer to work around bbdb bug.
5499 (unless (eq major-mode 'gnus-summary-mode)
5500 (set-buffer gnus-summary-buffer))
5501 (let ((article (or article (gnus-summary-article-number)))
5502 (all-headers (not (not all-headers))) ;Must be T or NIL.
5503 gnus-summary-display-article-function
5506 (gnus-summary-article-pseudo-p article)
5507 (error "This is a pseudo-article"))
5510 (set-buffer gnus-summary-buffer)
5511 (if (or (and gnus-single-article-buffer
5512 (or (null gnus-current-article)
5513 (null gnus-article-current)
5514 (null (get-buffer gnus-article-buffer))
5515 (not (eq article (cdr gnus-article-current)))
5516 (not (equal (car gnus-article-current)
5517 gnus-newsgroup-name))))
5518 (and (not gnus-single-article-buffer)
5519 (or (null gnus-current-article)
5520 (not (eq gnus-current-article article))))
5522 ;; The requested article is different from the current article.
5524 (gnus-summary-display-article article all-headers)
5526 (when (or all-headers gnus-show-all-headers)
5527 (gnus-article-show-all-headers))
5530 (gnus-article-set-window-start
5531 (cdr (assq article gnus-newsgroup-bookmarks)))))))
5533 (defun gnus-summary-set-current-mark (&optional current-mark)
5534 "Obsolete function."
5537 (defun gnus-summary-next-article (&optional unread subject backward push)
5538 "Select the next article.
5539 If UNREAD, only unread articles are selected.
5540 If SUBJECT, only articles with SUBJECT are selected.
5541 If BACKWARD, the previous article is selected instead of the next."
5544 ;; Is there such an article?
5545 ((and (gnus-summary-search-forward unread subject backward)
5546 (or (gnus-summary-display-article (gnus-summary-article-number))
5547 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5548 (gnus-summary-position-point))
5549 ;; If not, we try the first unread, if that is wanted.
5551 gnus-auto-select-same
5552 (gnus-summary-first-unread-article))
5553 (gnus-summary-position-point)
5554 (gnus-message 6 "Wrapped"))
5555 ;; Try to get next/previous article not displayed in this group.
5556 ((and gnus-auto-extend-newsgroup
5557 (not unread) (not subject))
5558 (gnus-summary-goto-article
5559 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5560 nil (count-lines (point-min) (point))))
5561 ;; Go to next/previous group.
5563 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5564 (gnus-summary-jump-to-group gnus-newsgroup-name))
5565 (let ((cmd last-command-char)
5568 (set-buffer gnus-group-buffer)
5571 (if (eq gnus-keep-same-level 'best)
5572 (gnus-summary-best-group gnus-newsgroup-name)
5573 (gnus-summary-search-group backward gnus-keep-same-level))))
5574 ;; For some reason, the group window gets selected. We change
5576 (select-window (get-buffer-window (current-buffer)))
5577 ;; Select next unread newsgroup automagically.
5579 ((or (not gnus-auto-select-next)
5581 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5582 ((or (eq gnus-auto-select-next 'quietly)
5583 (and (eq gnus-auto-select-next 'slightly-quietly)
5585 (and (eq gnus-auto-select-next 'almost-quietly)
5586 (gnus-summary-last-article-p)))
5588 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5590 (gnus-message 7 "No more%s articles (%s)..."
5591 (if unread " unread" "")
5592 (if group (concat "selecting " group)
5594 (gnus-summary-next-group nil group backward)))
5596 (when (gnus-key-press-event-p last-input-event)
5597 (gnus-summary-walk-group-buffer
5598 gnus-newsgroup-name cmd unread backward point))))))))
5600 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5601 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5602 (?\C-p (gnus-group-prev-unread-group 1))))
5603 (cursor-in-echo-area t)
5604 keve key group ended)
5606 (set-buffer gnus-group-buffer)
5609 (if (eq gnus-keep-same-level 'best)
5610 (gnus-summary-best-group gnus-newsgroup-name)
5611 (gnus-summary-search-group backward gnus-keep-same-level))))
5614 5 "No more%s articles%s" (if unread " unread" "")
5616 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5617 (format " (Type %s for %s [%s])"
5618 (single-key-description cmd) group
5619 (car (gnus-gethash group gnus-newsrc-hashtb)))
5620 (format " (Type %s to exit %s)"
5621 (single-key-description cmd)
5622 gnus-newsgroup-name)))
5623 ;; Confirm auto selection.
5624 (setq key (car (setq keve (gnus-read-event-char))))
5627 ((assq key keystrokes)
5628 (let ((obuf (current-buffer)))
5629 (switch-to-buffer gnus-group-buffer)
5631 (gnus-group-jump-to-group group))
5632 (eval (cadr (assq key keystrokes)))
5633 (setq group (gnus-group-group-name))
5634 (switch-to-buffer obuf))
5638 (gnus-ephemeral-group-p gnus-newsgroup-name))
5640 (gnus-summary-next-group nil group backward)))
5642 (push (cdr keve) unread-command-events))))))
5644 (defun gnus-summary-next-unread-article ()
5645 "Select unread article after current one."
5647 (gnus-summary-next-article
5648 (or (not (eq gnus-summary-goto-unread 'never))
5649 (gnus-summary-last-article-p (gnus-summary-article-number)))
5650 (and gnus-auto-select-same
5651 (gnus-summary-article-subject))))
5653 (defun gnus-summary-prev-article (&optional unread subject)
5654 "Select the article after the current one.
5655 If UNREAD is non-nil, only unread articles are selected."
5657 (gnus-summary-next-article unread subject t))
5659 (defun gnus-summary-prev-unread-article ()
5660 "Select unread article before current one."
5662 (gnus-summary-prev-article
5663 (or (not (eq gnus-summary-goto-unread 'never))
5664 (gnus-summary-first-article-p (gnus-summary-article-number)))
5665 (and gnus-auto-select-same
5666 (gnus-summary-article-subject))))
5668 (defun gnus-summary-next-page (&optional lines circular)
5669 "Show next page of the selected article.
5670 If at the end of the current article, select the next article.
5671 LINES says how many lines should be scrolled up.
5673 If CIRCULAR is non-nil, go to the start of the article instead of
5674 selecting the next article when reaching the end of the current
5677 (setq gnus-summary-buffer (current-buffer))
5678 (gnus-set-global-variables)
5679 (let ((article (gnus-summary-article-number))
5680 (article-window (get-buffer-window gnus-article-buffer t))
5682 ;; If the buffer is empty, we have no article.
5684 (error "No article to select"))
5685 (gnus-configure-windows 'article)
5686 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
5687 (if (and (eq gnus-summary-goto-unread 'never)
5688 (not (gnus-summary-last-article-p article)))
5689 (gnus-summary-next-article)
5690 (gnus-summary-next-unread-article))
5691 (if (or (null gnus-current-article)
5692 (null gnus-article-current)
5693 (/= article (cdr gnus-article-current))
5694 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5695 ;; Selected subject is different from current article's.
5696 (gnus-summary-display-article article)
5697 (when article-window
5698 (gnus-eval-in-buffer-window gnus-article-buffer
5699 (setq endp (gnus-article-next-page lines)))
5702 (gnus-summary-beginning-of-article))
5704 (gnus-message 3 "End of message"))
5706 (if (and (eq gnus-summary-goto-unread 'never)
5707 (not (gnus-summary-last-article-p article)))
5708 (gnus-summary-next-article)
5709 (gnus-summary-next-unread-article))))))))
5710 (gnus-summary-recenter)
5711 (gnus-summary-position-point)))
5713 (defun gnus-summary-prev-page (&optional lines move)
5714 "Show previous page of selected article.
5715 Argument LINES specifies lines to be scrolled down.
5716 If MOVE, move to the previous unread article if point is at
5717 the beginning of the buffer."
5719 (let ((article (gnus-summary-article-number))
5720 (article-window (get-buffer-window gnus-article-buffer t))
5722 (gnus-configure-windows 'article)
5723 (if (or (null gnus-current-article)
5724 (null gnus-article-current)
5725 (/= article (cdr gnus-article-current))
5726 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5727 ;; Selected subject is different from current article's.
5728 (gnus-summary-display-article article)
5729 (gnus-summary-recenter)
5730 (when article-window
5731 (gnus-eval-in-buffer-window gnus-article-buffer
5732 (setq endp (gnus-article-prev-page lines)))
5733 (when (and move endp)
5735 (gnus-message 3 "Beginning of message"))
5737 (if (and (eq gnus-summary-goto-unread 'never)
5738 (not (gnus-summary-first-article-p article)))
5739 (gnus-summary-prev-article)
5740 (gnus-summary-prev-unread-article))))))))
5741 (gnus-summary-position-point))
5743 (defun gnus-summary-prev-page-or-article (&optional lines)
5744 "Show previous page of selected article.
5745 Argument LINES specifies lines to be scrolled down.
5746 If at the beginning of the article, go to the next article."
5748 (gnus-summary-prev-page lines t))
5750 (defun gnus-summary-scroll-up (lines)
5751 "Scroll up (or down) one line current article.
5752 Argument LINES specifies lines to be scrolled up (or down if negative)."
5754 (gnus-configure-windows 'article)
5755 (gnus-summary-show-thread)
5756 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
5757 (gnus-eval-in-buffer-window gnus-article-buffer
5759 (when (gnus-article-next-page lines)
5760 (gnus-message 3 "End of message")))
5762 (gnus-article-prev-page (- lines))))))
5763 (gnus-summary-recenter)
5764 (gnus-summary-position-point))
5766 (defun gnus-summary-next-same-subject ()
5767 "Select next article which has the same subject as current one."
5769 (gnus-summary-next-article nil (gnus-summary-article-subject)))
5771 (defun gnus-summary-prev-same-subject ()
5772 "Select previous article which has the same subject as current one."
5774 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
5776 (defun gnus-summary-next-unread-same-subject ()
5777 "Select next unread article which has the same subject as current one."
5779 (gnus-summary-next-article t (gnus-summary-article-subject)))
5781 (defun gnus-summary-prev-unread-same-subject ()
5782 "Select previous unread article which has the same subject as current one."
5784 (gnus-summary-prev-article t (gnus-summary-article-subject)))
5786 (defun gnus-summary-first-unread-article ()
5787 "Select the first unread article.
5788 Return nil if there are no unread articles."
5791 (when (gnus-summary-first-subject t)
5792 (gnus-summary-show-thread)
5793 (gnus-summary-first-subject t)
5794 (gnus-summary-display-article (gnus-summary-article-number)))
5795 (gnus-summary-position-point)))
5797 (defun gnus-summary-first-article ()
5798 "Select the first article.
5799 Return nil if there are no articles."
5802 (when (gnus-summary-first-subject)
5803 (gnus-summary-show-thread)
5804 (gnus-summary-first-subject)
5805 (gnus-summary-display-article (gnus-summary-article-number)))
5806 (gnus-summary-position-point)))
5808 (defun gnus-summary-best-unread-article ()
5809 "Select the unread article with the highest score."
5811 (let ((best -1000000)
5812 (data gnus-newsgroup-data)
5815 (and (gnus-data-unread-p (car data))
5817 (gnus-summary-article-score (gnus-data-number (car data))))
5820 article (gnus-data-number (car data))))
5821 (setq data (cdr data)))
5824 (gnus-summary-goto-article article)
5825 (error "No unread articles"))
5826 (gnus-summary-position-point))))
5828 (defun gnus-summary-last-subject ()
5829 "Go to the last displayed subject line in the group."
5830 (let ((article (gnus-data-number (car (gnus-data-list t)))))
5832 (gnus-summary-goto-subject article))))
5834 (defun gnus-summary-goto-article (article &optional all-headers force)
5835 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
5836 If ALL-HEADERS is non-nil, no header lines are hidden.
5837 If FORCE, go to the article even if it isn't displayed. If FORCE
5838 is a number, it is the line the article is to be displayed on."
5842 "Article number or Message-ID: "
5843 (mapcar (lambda (number) (list (int-to-string number)))
5844 gnus-newsgroup-limit))
5848 (if (and (stringp article)
5849 (string-match "@" article))
5850 (gnus-summary-refer-article article)
5851 (when (stringp article)
5852 (setq article (string-to-number article)))
5853 (if (gnus-summary-goto-subject article force)
5854 (gnus-summary-display-article article all-headers)
5855 (gnus-message 4 "Couldn't go to article %s" article) nil))
5856 (gnus-summary-position-point)))
5858 (defun gnus-summary-goto-last-article ()
5859 "Go to the previously read article."
5862 (when gnus-last-article
5863 (gnus-summary-goto-article gnus-last-article nil t))
5864 (gnus-summary-position-point)))
5866 (defun gnus-summary-pop-article (number)
5867 "Pop one article off the history and go to the previous.
5868 NUMBER articles will be popped off."
5871 (setq gnus-newsgroup-history
5872 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
5874 (gnus-summary-goto-article (car to) nil t)
5875 (error "Article history empty")))
5876 (gnus-summary-position-point))
5878 ;; Summary commands and functions for limiting the summary buffer.
5880 (defun gnus-summary-limit-to-articles (n)
5881 "Limit the summary buffer to the next N articles.
5882 If not given a prefix, use the process marked articles instead."
5885 (let ((articles (gnus-summary-work-articles n)))
5886 (setq gnus-newsgroup-processable nil)
5887 (gnus-summary-limit articles))
5888 (gnus-summary-position-point)))
5890 (defun gnus-summary-pop-limit (&optional total)
5891 "Restore the previous limit.
5892 If given a prefix, remove all limits."
5895 (setq gnus-newsgroup-limits
5896 (list (mapcar (lambda (h) (mail-header-number h))
5897 gnus-newsgroup-headers))))
5898 (unless gnus-newsgroup-limits
5899 (error "No limit to pop"))
5901 (gnus-summary-limit nil 'pop)
5902 (gnus-summary-position-point)))
5904 (defun gnus-summary-limit-to-subject (subject &optional header)
5905 "Limit the summary buffer to articles that have subjects that match a regexp."
5906 (interactive "sLimit to subject (regexp): ")
5908 (setq header "subject"))
5909 (when (not (equal "" subject))
5911 (let ((articles (gnus-summary-find-matching
5912 (or header "subject") subject 'all)))
5914 (error "Found no matches for \"%s\"" subject))
5915 (gnus-summary-limit articles))
5916 (gnus-summary-position-point))))
5918 (defun gnus-summary-limit-to-author (from)
5919 "Limit the summary buffer to articles that have authors that match a regexp."
5920 (interactive "sLimit to author (regexp): ")
5921 (gnus-summary-limit-to-subject from "from"))
5923 (defun gnus-summary-limit-to-age (age &optional younger-p)
5924 "Limit the summary buffer to articles that are older than (or equal) AGE days.
5925 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
5926 articles that are younger than AGE days."
5927 (interactive "nTime in days: \nP")
5929 (let ((data gnus-newsgroup-data)
5930 (cutoff (nnmail-days-to-time age))
5931 articles d date is-younger)
5932 (while (setq d (pop data))
5933 (when (and (vectorp (gnus-data-header d))
5934 (setq date (mail-header-date (gnus-data-header d))))
5935 (setq is-younger (nnmail-time-less
5936 (nnmail-time-since (nnmail-date-to-time date))
5941 (push (gnus-data-number d) articles))))
5942 (gnus-summary-limit (nreverse articles)))
5943 (gnus-summary-position-point)))
5945 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5947 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5949 (defun gnus-summary-limit-to-unread (&optional all)
5950 "Limit the summary buffer to articles that are not marked as read.
5951 If ALL is non-nil, limit strictly to unread articles."
5954 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
5955 (gnus-summary-limit-to-marks
5956 ;; Concat all the marks that say that an article is read and have
5958 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
5959 gnus-killed-mark gnus-kill-file-mark
5960 gnus-low-score-mark gnus-expirable-mark
5961 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
5962 gnus-duplicate-mark gnus-souped-mark)
5965 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
5966 (make-obsolete 'gnus-summary-delete-marked-with
5967 'gnus-summary-limit-exlude-marks)
5969 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
5970 "Exclude articles that are marked with MARKS (e.g. \"DK\").
5971 If REVERSE, limit the summary buffer to articles that are marked
5972 with MARKS. MARKS can either be a string of marks or a list of marks.
5973 Returns how many articles were removed."
5974 (interactive "sMarks: ")
5975 (gnus-summary-limit-to-marks marks t))
5977 (defun gnus-summary-limit-to-marks (marks &optional reverse)
5978 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
5979 If REVERSE (the prefix), limit the summary buffer to articles that are
5980 not marked with MARKS. MARKS can either be a string of marks or a
5982 Returns how many articles were removed."
5983 (interactive "sMarks: \nP")
5985 (let ((data gnus-newsgroup-data)
5986 (marks (if (listp marks) marks
5987 (append marks nil))) ; Transform to list.
5990 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
5991 (memq (gnus-data-mark (car data)) marks))
5992 (push (gnus-data-number (car data)) articles))
5993 (setq data (cdr data)))
5994 (gnus-summary-limit articles))
5995 (gnus-summary-position-point)))
5997 (defun gnus-summary-limit-to-score (&optional score)
5998 "Limit to articles with score at or above SCORE."
6000 (setq score (if score
6001 (prefix-numeric-value score)
6002 (or gnus-summary-default-score 0)))
6003 (let ((data gnus-newsgroup-data)
6006 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6008 (push (gnus-data-number (car data)) articles))
6009 (setq data (cdr data)))
6011 (gnus-summary-limit articles)
6012 (gnus-summary-position-point))))
6014 (defun gnus-summary-limit-include-thread (id)
6015 "Display all the hidden articles that in the current thread."
6016 (interactive (list (mail-header-id (gnus-summary-article-header))))
6017 (let ((articles (gnus-articles-in-thread
6018 (gnus-id-to-thread (gnus-root-id id)))))
6020 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6021 (gnus-summary-position-point))))
6023 (defun gnus-summary-limit-include-dormant ()
6024 "Display all the hidden articles that are marked as dormant.
6025 Note that this command only works on a subset of the articles currently
6026 fetched for this group."
6028 (unless gnus-newsgroup-dormant
6029 (error "There are no dormant articles in this group"))
6031 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6032 (gnus-summary-position-point)))
6034 (defun gnus-summary-limit-exclude-dormant ()
6035 "Hide all dormant articles."
6038 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6039 (gnus-summary-position-point)))
6041 (defun gnus-summary-limit-exclude-childless-dormant ()
6042 "Hide all dormant articles that have no children."
6044 (let ((data (gnus-data-list t))
6045 articles d children)
6046 ;; Find all articles that are either not dormant or have
6048 (while (setq d (pop data))
6049 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6051 (gnus-article-children (gnus-data-number d)))
6054 (when (memq (car children) articles)
6059 (push (gnus-data-number d) articles)))
6062 (gnus-summary-limit articles)
6063 (gnus-summary-position-point))))
6065 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6066 "Mark all unread excluded articles as read.
6067 If ALL, mark even excluded ticked and dormants as read."
6069 (let ((articles (gnus-sorted-complement
6071 (mapcar (lambda (h) (mail-header-number h))
6072 gnus-newsgroup-headers)
6074 (sort gnus-newsgroup-limit '<)))
6076 (setq gnus-newsgroup-unreads
6077 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6079 (setq gnus-newsgroup-dormant nil
6080 gnus-newsgroup-marked nil
6081 gnus-newsgroup-reads
6083 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6084 gnus-newsgroup-reads))
6085 (while (setq article (pop articles))
6086 (unless (or (memq article gnus-newsgroup-dormant)
6087 (memq article gnus-newsgroup-marked))
6088 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6090 (defun gnus-summary-limit (articles &optional pop)
6092 ;; We pop the previous limit off the stack and use that.
6093 (setq articles (car gnus-newsgroup-limits)
6094 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6095 ;; We use the new limit, so we push the old limit on the stack.
6096 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6098 (setq gnus-newsgroup-limit articles)
6099 (let ((total (length gnus-newsgroup-data))
6100 (data (gnus-data-find-list (gnus-summary-article-number)))
6101 (gnus-summary-mark-below nil) ; Inhibit this.
6103 ;; This will do all the work of generating the new summary buffer
6104 ;; according to the new limit.
6105 (gnus-summary-prepare)
6106 ;; Hide any threads, possibly.
6107 (and gnus-show-threads
6108 gnus-thread-hide-subtree
6109 (gnus-summary-hide-all-threads))
6110 ;; Try to return to the article you were at, or one in the
6113 ;; We try to find some article after the current one.
6115 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6118 (setq data (cdr data))))
6120 ;; If there is no data, that means that we were after the last
6121 ;; article. The same goes when we can't find any articles
6122 ;; after the current one.
6123 (goto-char (point-max))
6124 (gnus-summary-find-prev))
6125 (gnus-set-mode-line 'summary)
6126 ;; We return how many articles were removed from the summary
6127 ;; buffer as a result of the new limit.
6128 (- total (length gnus-newsgroup-data))))
6130 (defsubst gnus-invisible-cut-children (threads)
6133 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6138 (defsubst gnus-cut-thread (thread)
6139 "Go forwards in the thread until we find an article that we want to display."
6140 (when (or (eq gnus-fetch-old-headers 'some)
6141 (eq gnus-fetch-old-headers 'invisible)
6142 (eq gnus-build-sparse-threads 'some)
6143 (eq gnus-build-sparse-threads 'more))
6144 ;; Deal with old-fetched headers and sparse threads.
6148 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6149 (gnus-summary-article-ancient-p
6150 (mail-header-number (car thread))))
6151 (if (or (<= (length (cdr thread)) 1)
6152 (eq gnus-fetch-old-headers 'invisible))
6153 (setq gnus-newsgroup-limit
6154 (delq (mail-header-number (car thread))
6155 gnus-newsgroup-limit)
6156 thread (cadr thread))
6157 (when (gnus-invisible-cut-children (cdr thread))
6158 (let ((th (cdr thread)))
6160 (if (memq (mail-header-number (caar th))
6161 gnus-newsgroup-limit)
6162 (setq thread (car th)
6164 (setq th (cdr th))))))))))
6167 (defun gnus-cut-threads (threads)
6168 "Cut off all uninteresting articles from the beginning of threads."
6169 (when (or (eq gnus-fetch-old-headers 'some)
6170 (eq gnus-fetch-old-headers 'invisible)
6171 (eq gnus-build-sparse-threads 'some)
6172 (eq gnus-build-sparse-threads 'more))
6175 (setcar th (gnus-cut-thread (car th)))
6176 (setq th (cdr th)))))
6177 ;; Remove nixed out threads.
6180 (defun gnus-summary-initial-limit (&optional show-if-empty)
6181 "Figure out what the initial limit is supposed to be on group entry.
6182 This entails weeding out unwanted dormants, low-scored articles,
6183 fetch-old-headers verbiage, and so on."
6184 ;; Most groups have nothing to remove.
6185 (if (or gnus-inhibit-limiting
6186 (and (null gnus-newsgroup-dormant)
6187 (not (eq gnus-fetch-old-headers 'some))
6188 (not (eq gnus-fetch-old-headers 'invisible))
6189 (null gnus-summary-expunge-below)
6190 (not (eq gnus-build-sparse-threads 'some))
6191 (not (eq gnus-build-sparse-threads 'more))
6192 (null gnus-thread-expunge-below)
6193 (not gnus-use-nocem)))
6195 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6196 (setq gnus-newsgroup-limit nil)
6199 (unless (car (symbol-value node))
6200 ;; These threads have no parents -- they are roots.
6201 (let ((nodes (cdr (symbol-value node)))
6204 (if (and gnus-thread-expunge-below
6205 (< (gnus-thread-total-score (car nodes))
6206 gnus-thread-expunge-below))
6207 (gnus-expunge-thread (pop nodes))
6208 (setq thread (pop nodes))
6209 (gnus-summary-limit-children thread))))))
6210 gnus-newsgroup-dependencies)
6211 ;; If this limitation resulted in an empty group, we might
6212 ;; pop the previous limit and use it instead.
6213 (when (and (not gnus-newsgroup-limit)
6215 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6216 gnus-newsgroup-limit))
6218 (defun gnus-summary-limit-children (thread)
6219 "Return 1 if this subthread is visible and 0 if it is not."
6220 ;; First we get the number of visible children to this thread. This
6221 ;; is done by recursing down the thread using this function, so this
6222 ;; will really go down to a leaf article first, before slowly
6223 ;; working its way up towards the root.
6227 (apply '+ (mapcar 'gnus-summary-limit-children
6230 (number (mail-header-number (car thread)))
6233 (not (memq number gnus-newsgroup-marked))
6235 ;; If this article is dormant and has absolutely no visible
6236 ;; children, then this article isn't visible.
6237 (and (memq number gnus-newsgroup-dormant)
6239 ;; If this is "fetch-old-headered" and there is no
6240 ;; visible children, then we don't want this article.
6241 (and (eq gnus-fetch-old-headers 'some)
6242 (gnus-summary-article-ancient-p number)
6244 ;; If this is "fetch-old-headered" and `invisible', then
6245 ;; we don't want this article.
6246 (and (eq gnus-fetch-old-headers 'invisible)
6247 (gnus-summary-article-ancient-p number))
6248 ;; If this is a sparsely inserted article with no children,
6249 ;; we don't want it.
6250 (and (eq gnus-build-sparse-threads 'some)
6251 (gnus-summary-article-sparse-p number)
6253 ;; If we use expunging, and this article is really
6254 ;; low-scored, then we don't want this article.
6255 (when (and gnus-summary-expunge-below
6257 (or (cdr (assq number gnus-newsgroup-scored))
6258 gnus-summary-default-score))
6259 gnus-summary-expunge-below))
6260 ;; We increase the expunge-tally here, but that has
6261 ;; nothing to do with the limits, really.
6262 (incf gnus-newsgroup-expunged-tally)
6263 ;; We also mark as read here, if that's wanted.
6264 (when (and gnus-summary-mark-below
6265 (< score gnus-summary-mark-below))
6266 (setq gnus-newsgroup-unreads
6267 (delq number gnus-newsgroup-unreads))
6268 (if gnus-newsgroup-auto-expire
6269 (push number gnus-newsgroup-expirable)
6270 (push (cons number gnus-low-score-mark)
6271 gnus-newsgroup-reads)))
6273 ;; Check NoCeM things.
6274 (if (and gnus-use-nocem
6275 (gnus-nocem-unwanted-article-p
6276 (mail-header-id (car thread))))
6278 (setq gnus-newsgroup-unreads
6279 (delq number gnus-newsgroup-unreads))
6281 ;; Nope, invisible article.
6283 ;; Ok, this article is to be visible, so we add it to the limit
6285 (push number gnus-newsgroup-limit)
6288 (defun gnus-expunge-thread (thread)
6289 "Mark all articles in THREAD as read."
6290 (let* ((number (mail-header-number (car thread))))
6291 (incf gnus-newsgroup-expunged-tally)
6292 ;; We also mark as read here, if that's wanted.
6293 (setq gnus-newsgroup-unreads
6294 (delq number gnus-newsgroup-unreads))
6295 (if gnus-newsgroup-auto-expire
6296 (push number gnus-newsgroup-expirable)
6297 (push (cons number gnus-low-score-mark)
6298 gnus-newsgroup-reads)))
6299 ;; Go recursively through all subthreads.
6300 (mapcar 'gnus-expunge-thread (cdr thread)))
6302 ;; Summary article oriented commands
6304 (defun gnus-summary-refer-parent-article (n)
6305 "Refer parent article N times.
6306 If N is negative, go to ancestor -N instead.
6307 The difference between N and the number of articles fetched is returned."
6311 (when (not (natnump n))
6316 (setq header (gnus-summary-article-header))
6317 (if (and (eq (mail-header-number header)
6318 (cdr gnus-article-current))
6319 (equal gnus-newsgroup-name
6320 (car gnus-article-current)))
6321 ;; If we try to find the parent of the currently
6322 ;; displayed article, then we take a look at the actual
6323 ;; References header, since this is slightly more
6324 ;; reliable than the References field we got from the
6327 (set-buffer gnus-original-article-buffer)
6328 (nnheader-narrow-to-headers)
6329 (unless (setq ref (message-fetch-field "references"))
6330 (setq ref (message-fetch-field "in-reply-to")))
6333 ;; It's not the current article, so we take a bet on
6334 ;; the value we got from the server.
6335 (mail-header-references header)))
6337 (not (equal ref "")))
6338 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6339 (gnus-message 1 "Couldn't find parent"))
6340 (gnus-message 1 "No references in article %d"
6341 (gnus-summary-article-number))
6344 (gnus-summary-position-point)
6347 (defun gnus-summary-refer-references ()
6348 "Fetch all articles mentioned in the References header.
6349 Return the number of articles fetched."
6351 (let ((ref (mail-header-references (gnus-summary-article-header)))
6352 (current (gnus-summary-article-number))
6356 (error "No References in the current article")
6357 ;; For each Message-ID in the References header...
6358 (while (string-match "<[^>]*>" ref)
6360 ;; ... fetch that article.
6361 (gnus-summary-refer-article
6362 (prog1 (match-string 0 ref)
6363 (setq ref (substring ref (match-end 0))))))
6364 (gnus-summary-goto-subject current)
6365 (gnus-summary-position-point)
6368 (defun gnus-summary-refer-thread (&optional limit)
6369 "Fetch all articles in the current thread.
6370 If LIMIT (the numerical prefix), fetch that many old headers instead
6371 of what's specified by the `gnus-refer-thread-limit' variable."
6373 (let ((id (mail-header-id (gnus-summary-article-header)))
6374 (limit (if limit (prefix-numeric-value limit)
6375 gnus-refer-thread-limit))
6377 ;; We want to fetch LIMIT *old* headers, but we also have to
6378 ;; re-fetch all the headers in the current buffer, because many of
6379 ;; them may be undisplayed. So we adjust LIMIT.
6380 (when (numberp limit)
6381 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6382 (unless (eq gnus-fetch-old-headers 'invisible)
6383 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6384 ;; Retrieve the headers and read them in.
6385 (if (eq (gnus-retrieve-headers
6386 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6388 (gnus-build-all-threads)
6389 (error "Can't fetch thread from backends that don't support NOV"))
6390 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6391 (gnus-summary-limit-include-thread id)))
6393 (defun gnus-summary-refer-article (message-id &optional arg)
6394 "Fetch an article specified by MESSAGE-ID.
6395 If ARG (the prefix), fetch the article using `gnus-refer-article-method'
6396 or `gnus-select-method', no matter what backend the article comes from."
6397 (interactive "sMessage-ID: \nP")
6398 (when (and (stringp message-id)
6399 (not (zerop (length message-id))))
6400 ;; Construct the correct Message-ID if necessary.
6401 ;; Suggested by tale@pawl.rpi.edu.
6402 (unless (string-match "^<" message-id)
6403 (setq message-id (concat "<" message-id)))
6404 (unless (string-match ">$" message-id)
6405 (setq message-id (concat message-id ">")))
6406 (let* ((header (gnus-id-to-header message-id))
6408 (gnus-summary-article-sparse-p
6409 (mail-header-number header))
6410 (memq (mail-header-number header)
6411 gnus-newsgroup-limit)))
6414 ;; If the article is present in the buffer we just go to it.
6416 (or (not (gnus-summary-article-sparse-p
6417 (mail-header-number header)))
6420 (gnus-summary-goto-article
6421 (mail-header-number header) nil t)
6423 (gnus-summary-update-article (mail-header-number header)))))
6425 ;; We fetch the article
6426 (let ((gnus-override-method
6427 (cond ((gnus-news-group-p gnus-newsgroup-name)
6428 gnus-refer-article-method)
6430 (or gnus-refer-article-method gnus-select-method))
6433 ;; Start the special refer-article method, if necessary.
6434 (when (and gnus-refer-article-method
6435 (gnus-news-group-p gnus-newsgroup-name))
6436 (gnus-check-server gnus-refer-article-method))
6437 ;; Fetch the header, and display the article.
6438 (if (setq number (gnus-summary-insert-subject message-id))
6439 (gnus-summary-select-article nil nil nil number)
6440 (gnus-message 3 "Couldn't fetch article %s" message-id))))))))
6442 (defun gnus-summary-edit-parameters ()
6443 "Edit the group parameters of the current group."
6445 (gnus-group-edit-group gnus-newsgroup-name 'params))
6447 (defun gnus-summary-enter-digest-group (&optional force)
6448 "Enter an nndoc group based on the current article.
6449 If FORCE, force a digest interpretation. If not, try
6450 to guess what the document format is."
6452 (let ((conf gnus-current-window-configuration))
6454 (gnus-summary-select-article))
6455 (setq gnus-current-window-configuration conf)
6456 (let* ((name (format "%s-%d"
6457 (gnus-group-prefixed-name
6458 gnus-newsgroup-name (list 'nndoc ""))
6460 (set-buffer gnus-summary-buffer)
6461 gnus-current-article)))
6462 (ogroup gnus-newsgroup-name)
6463 (params (append (gnus-info-params (gnus-get-info ogroup))
6464 (list (cons 'to-group ogroup))
6465 (list (cons 'save-article-group ogroup))))
6466 (case-fold-search t)
6467 (buf (current-buffer))
6470 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6471 (insert-buffer-substring gnus-original-article-buffer)
6472 ;; Remove lines that may lead nndoc to misinterpret the
6475 (goto-char (point-min))
6476 (or (search-forward "\n\n" nil t) (point)))
6477 (goto-char (point-min))
6478 (delete-matching-lines "^\\(Path\\):\\|^From ")
6481 (if (gnus-group-read-ephemeral-group
6482 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6484 ,(if force 'digest 'guess))) t)
6485 ;; Make all postings to this group go to the parent group.
6486 (nconc (gnus-info-params (gnus-get-info name))
6488 ;; Couldn't select this doc group.
6489 (switch-to-buffer buf)
6490 (gnus-set-global-variables)
6491 (gnus-configure-windows 'summary)
6492 (gnus-message 3 "Article couldn't be entered?"))
6493 (kill-buffer dig)))))
6495 (defun gnus-summary-read-document (n)
6496 "Open a new group based on the current article(s).
6497 This will allow you to read digests and other similar
6498 documents as newsgroups.
6499 Obeys the standard process/prefix convention."
6501 (let* ((articles (gnus-summary-work-articles n))
6502 (ogroup gnus-newsgroup-name)
6503 (params (append (gnus-info-params (gnus-get-info ogroup))
6504 (list (cons 'to-group ogroup))))
6505 article group egroup groups vgroup)
6506 (while (setq article (pop articles))
6507 (setq group (format "%s-%d" gnus-newsgroup-name article))
6508 (gnus-summary-remove-process-mark article)
6509 (when (gnus-summary-display-article article)
6511 (nnheader-temp-write nil
6512 (insert-buffer-substring gnus-original-article-buffer)
6513 ;; Remove some headers that may lead nndoc to make
6515 (message-narrow-to-head)
6516 (goto-char (point-min))
6517 (delete-matching-lines "^\\(Path\\):\\|^From ")
6520 (gnus-group-read-ephemeral-group
6521 group `(nndoc ,group (nndoc-address ,(current-buffer))
6522 (nndoc-article-type guess))
6525 ;; Make all postings to this group go to the parent group.
6526 (nconc (gnus-info-params (gnus-get-info egroup))
6528 (push egroup groups))
6529 ;; Couldn't select this doc group.
6530 (gnus-error 3 "Article couldn't be entered"))))))
6531 ;; Now we have selected all the documents.
6534 (error "None of the articles could be interpreted as documents"))
6535 ((gnus-group-read-ephemeral-group
6536 (setq vgroup (format
6537 "nnvirtual:%s-%s" gnus-newsgroup-name
6538 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6539 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6541 (cons (current-buffer) 'summary)))
6543 (error "Couldn't select virtual nndoc group")))))
6545 (defun gnus-summary-isearch-article (&optional regexp-p)
6546 "Do incremental search forward on the current article.
6547 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6549 (gnus-summary-select-article)
6550 (gnus-configure-windows 'article)
6551 (gnus-eval-in-buffer-window gnus-article-buffer
6554 (isearch-forward regexp-p))))
6556 (defun gnus-summary-search-article-forward (regexp &optional backward)
6557 "Search for an article containing REGEXP forward.
6558 If BACKWARD, search backward instead."
6561 (format "Search article %s (regexp%s): "
6562 (if current-prefix-arg "backward" "forward")
6563 (if gnus-last-search-regexp
6564 (concat ", default " gnus-last-search-regexp)
6566 current-prefix-arg))
6567 (if (string-equal regexp "")
6568 (setq regexp (or gnus-last-search-regexp ""))
6569 (setq gnus-last-search-regexp regexp))
6570 (if (gnus-summary-search-article regexp backward)
6571 (gnus-summary-show-thread)
6572 (error "Search failed: \"%s\"" regexp)))
6574 (defun gnus-summary-search-article-backward (regexp)
6575 "Search for an article containing REGEXP backward."
6578 (format "Search article backward (regexp%s): "
6579 (if gnus-last-search-regexp
6580 (concat ", default " gnus-last-search-regexp)
6582 (gnus-summary-search-article-forward regexp 'backward))
6584 (defun gnus-summary-search-article (regexp &optional backward)
6585 "Search for an article containing REGEXP.
6586 Optional argument BACKWARD means do search for backward.
6587 `gnus-select-article-hook' is not called during the search."
6588 ;; We have to require this here to make sure that the following
6589 ;; dynamic binding isn't shadowed by autoloading.
6590 (require 'gnus-async)
6591 (let ((gnus-select-article-hook nil) ;Disable hook.
6592 (gnus-article-display-hook nil)
6593 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6594 (gnus-use-article-prefetch nil)
6595 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
6596 (gnus-use-trees nil) ;Inhibit updating tree buffer.
6597 (sum (current-buffer))
6600 (gnus-save-hidden-threads
6601 (gnus-summary-select-article)
6602 (set-buffer gnus-article-buffer)
6606 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
6608 (re-search-backward regexp nil t)
6609 (re-search-forward regexp nil t))
6610 ;; We found the regexp.
6615 (get-buffer-window (current-buffer))
6619 (setq point (point)))
6620 ;; We didn't find it, so we go to the next article.
6623 (while (eq found 'not)
6624 (if (not (if backward (gnus-summary-find-prev)
6625 (gnus-summary-find-next)))
6626 ;; No more articles.
6628 ;; Select the next article and adjust point.
6629 (unless (gnus-summary-article-sparse-p
6630 (gnus-summary-article-number))
6632 (gnus-summary-select-article)
6633 (set-buffer gnus-article-buffer)
6635 (goto-char (if backward (point-max) (point-min))))))))
6636 (gnus-message 7 ""))
6637 ;; Return whether we found the regexp.
6638 (when (eq found 'found)
6640 (gnus-summary-show-thread)
6641 (gnus-summary-goto-subject gnus-current-article)
6642 (gnus-summary-position-point)
6645 (defun gnus-summary-find-matching (header regexp &optional backward unread
6647 "Return a list of all articles that match REGEXP on HEADER.
6648 The search stars on the current article and goes forwards unless
6649 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
6650 If UNREAD is non-nil, only unread articles will
6651 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
6652 in the comparisons."
6653 (let ((data (if (eq backward 'all) gnus-newsgroup-data
6654 (gnus-data-find-list
6655 (gnus-summary-article-number) (gnus-data-list backward))))
6656 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
6657 (case-fold-search (not not-case-fold))
6659 (unless (fboundp (intern (concat "mail-header-" header)))
6660 (error "%s is not a valid header" header))
6663 (and (or (not unread) ; We want all articles...
6664 (gnus-data-unread-p d)) ; Or just unreads.
6665 (vectorp (gnus-data-header d)) ; It's not a pseudo.
6666 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
6667 (push (gnus-data-number d) articles)) ; Success!
6668 (setq data (cdr data)))
6669 (nreverse articles)))
6671 (defun gnus-summary-execute-command (header regexp command &optional backward)
6672 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
6673 If HEADER is an empty string (or nil), the match is done on the entire
6674 article. If BACKWARD (the prefix) is non-nil, search backward instead."
6676 (list (let ((completion-ignore-case t))
6679 (mapcar (lambda (string) (list string))
6680 '("Number" "Subject" "From" "Lines" "Date"
6681 "Message-ID" "Xref" "References" "Body"))
6682 nil 'require-match))
6683 (read-string "Regexp: ")
6684 (read-key-sequence "Command: ")
6685 current-prefix-arg))
6686 (when (equal header "Body")
6688 ;; Hidden thread subtrees must be searched as well.
6689 (gnus-summary-show-all-threads)
6690 ;; We don't want to change current point nor window configuration.
6692 (save-window-excursion
6693 (gnus-message 6 "Executing %s..." (key-description command))
6694 ;; We'd like to execute COMMAND interactively so as to give arguments.
6695 (gnus-execute header regexp
6696 `(call-interactively ',(key-binding command))
6698 (gnus-message 6 "Executing %s...done" (key-description command)))))
6700 (defun gnus-summary-beginning-of-article ()
6701 "Scroll the article back to the beginning."
6703 (gnus-summary-select-article)
6704 (gnus-configure-windows 'article)
6705 (gnus-eval-in-buffer-window gnus-article-buffer
6707 (goto-char (point-min))
6708 (when gnus-page-broken
6709 (gnus-narrow-to-page))))
6711 (defun gnus-summary-end-of-article ()
6712 "Scroll to the end of the article."
6714 (gnus-summary-select-article)
6715 (gnus-configure-windows 'article)
6716 (gnus-eval-in-buffer-window gnus-article-buffer
6718 (goto-char (point-max))
6720 (when gnus-page-broken
6721 (gnus-narrow-to-page))))
6723 (defun gnus-summary-print-article (&optional filename n)
6724 "Generate and print a PostScript image of the N next (mail) articles.
6726 If N is negative, print the N previous articles. If N is nil and articles
6727 have been marked with the process mark, print these instead.
6729 If the optional second argument FILENAME is nil, send the image to the
6730 printer. If FILENAME is a string, save the PostScript image in a file with
6731 that name. If FILENAME is a number, prompt the user for the name of the file
6733 (interactive (list (ps-print-preprint current-prefix-arg)
6734 current-prefix-arg))
6735 (dolist (article (gnus-summary-work-articles n))
6736 (gnus-summary-select-article nil nil 'pseudo article)
6737 (gnus-eval-in-buffer-window gnus-article-buffer
6738 (let ((buffer (generate-new-buffer " *print*")))
6741 (copy-to-buffer buffer (point-min) (point-max))
6743 (gnus-article-delete-invisible-text)
6744 (let ((ps-left-header
6747 (mail-header-subject gnus-current-headers) ")")
6749 (mail-header-from gnus-current-headers) ")")))
6752 "/pagenumberstring load"
6754 (mail-header-date gnus-current-headers) ")"))))
6755 (gnus-run-hooks 'gnus-ps-print-hook)
6757 (ps-print-buffer-with-faces filename))))
6758 (kill-buffer buffer))))))
6760 (defun gnus-summary-show-article (&optional arg)
6761 "Force re-fetching of the current article.
6762 If ARG (the prefix) is non-nil, show the raw article without any
6763 article massaging functions being run."
6766 ;; Select the article the normal way.
6767 (gnus-summary-select-article nil 'force)
6768 ;; Bind the article treatment functions to nil.
6769 (let ((gnus-have-all-headers t)
6770 gnus-article-display-hook
6771 gnus-article-prepare-hook
6775 (gnus-summary-select-article nil 'force)))
6776 (gnus-summary-goto-subject gnus-current-article)
6777 (gnus-summary-position-point))
6779 (defun gnus-summary-verbose-headers (&optional arg)
6780 "Toggle permanent full header display.
6781 If ARG is a positive number, turn header display on.
6782 If ARG is a negative number, turn header display off."
6784 (setq gnus-show-all-headers
6785 (cond ((or (not (numberp arg))
6787 (not gnus-show-all-headers))
6790 (gnus-summary-show-article))
6792 (defun gnus-summary-toggle-header (&optional arg)
6793 "Show the headers if they are hidden, or hide them if they are shown.
6794 If ARG is a positive number, show the entire header.
6795 If ARG is a negative number, hide the unwanted header lines."
6798 (set-buffer gnus-article-buffer)
6799 (let* ((buffer-read-only nil)
6800 (inhibit-point-motion-hooks t)
6801 (hidden (text-property-any
6802 (goto-char (point-min)) (search-forward "\n\n")
6805 (goto-char (point-min))
6806 (when (search-forward "\n\n" nil t)
6807 (delete-region (point-min) (1- (point))))
6808 (goto-char (point-min))
6810 (set-buffer gnus-original-article-buffer)
6811 (goto-char (point-min))
6812 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
6813 (insert-buffer-substring gnus-original-article-buffer 1 e)
6814 (let ((article-inhibit-hiding t))
6815 (gnus-run-hooks 'gnus-article-display-hook))
6816 (when (or (not hidden) (and (numberp arg) (< arg 0)))
6817 (gnus-article-hide-headers)))))
6819 (defun gnus-summary-show-all-headers ()
6820 "Make all header lines visible."
6822 (gnus-article-show-all-headers))
6824 (defun gnus-summary-toggle-mime (&optional arg)
6825 "Toggle MIME processing.
6826 If ARG is a positive number, turn MIME processing on."
6828 (setq gnus-show-mime
6829 (if (null arg) (not gnus-show-mime)
6830 (> (prefix-numeric-value arg) 0)))
6831 (gnus-summary-select-article t 'force))
6833 (defun gnus-summary-caesar-message (&optional arg)
6834 "Caesar rotate the current article by 13.
6835 The numerical prefix specifies how many places to rotate each letter
6838 (gnus-summary-select-article)
6839 (let ((mail-header-separator ""))
6840 (gnus-eval-in-buffer-window gnus-article-buffer
6843 (let ((start (window-start))
6845 (message-caesar-buffer-body arg)
6846 (set-window-start (get-buffer-window (current-buffer)) start))))))
6848 (defun gnus-summary-stop-page-breaking ()
6849 "Stop page breaking in the current article."
6851 (gnus-summary-select-article)
6852 (gnus-eval-in-buffer-window gnus-article-buffer
6854 (when (gnus-visual-p 'page-marker)
6855 (let ((buffer-read-only nil))
6856 (gnus-remove-text-with-property 'gnus-prev)
6857 (gnus-remove-text-with-property 'gnus-next))
6858 (setq gnus-page-broken nil))))
6860 (defun gnus-summary-move-article (&optional n to-newsgroup
6861 select-method action)
6862 "Move the current article to a different newsgroup.
6863 If N is a positive number, move the N next articles.
6864 If N is a negative number, move the N previous articles.
6865 If N is nil and any articles have been marked with the process mark,
6866 move those articles instead.
6867 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6868 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6869 re-spool using this method.
6871 For this function to work, both the current newsgroup and the
6872 newsgroup that you want to move to have to support the `request-move'
6873 and `request-accept' functions."
6876 (setq action 'move))
6877 ;; Disable marking as read.
6878 (let (gnus-mark-article-hook)
6879 (save-window-excursion
6880 (gnus-summary-select-article)))
6881 ;; Check whether the source group supports the required functions.
6882 (cond ((and (eq action 'move)
6883 (not (gnus-check-backend-function
6884 'request-move-article gnus-newsgroup-name)))
6885 (error "The current group does not support article moving"))
6886 ((and (eq action 'crosspost)
6887 (not (gnus-check-backend-function
6888 'request-replace-article gnus-newsgroup-name)))
6889 (error "The current group does not support article editing")))
6890 (let ((articles (gnus-summary-work-articles n))
6891 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
6892 (names '((move "Move" "Moving")
6893 (copy "Copy" "Copying")
6894 (crosspost "Crosspost" "Crossposting")))
6895 (copy-buf (save-excursion
6896 (nnheader-set-temp-buffer " *copy article*")))
6897 art-group to-method new-xref article to-groups)
6898 (unless (assq action names)
6899 (error "Unknown action %s" action))
6900 ;; Read the newsgroup name.
6901 (when (and (not to-newsgroup)
6902 (not select-method))
6904 (gnus-read-move-group-name
6905 (cadr (assq action names))
6906 (symbol-value (intern (format "gnus-current-%s-group" action)))
6908 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
6909 (setq to-method (or select-method
6910 (gnus-group-name-to-method to-newsgroup)))
6911 ;; Check the method we are to move this article to...
6912 (unless (gnus-check-backend-function
6913 'request-accept-article (car to-method))
6914 (error "%s does not support article copying" (car to-method)))
6915 (unless (gnus-check-server to-method)
6916 (error "Can't open server %s" (car to-method)))
6917 (gnus-message 6 "%s to %s: %s..."
6918 (caddr (assq action names))
6919 (or (car select-method) to-newsgroup) articles)
6921 (setq article (pop articles))
6925 ;; Move the article.
6927 ;; Remove this article from future suppression.
6928 (gnus-dup-unsuppress-article article)
6929 (gnus-request-move-article
6930 article ; Article to move
6931 gnus-newsgroup-name ; From newsgroup
6932 (nth 1 (gnus-find-method-for-group
6933 gnus-newsgroup-name)) ; Server
6934 (list 'gnus-request-accept-article
6935 to-newsgroup (list 'quote select-method)
6936 (not articles)) ; Accept form
6937 (not articles))) ; Only save nov last time
6938 ;; Copy the article.
6941 (set-buffer copy-buf)
6942 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
6943 (gnus-request-accept-article
6944 to-newsgroup select-method (not articles)))))
6945 ;; Crosspost the article.
6946 ((eq action 'crosspost)
6947 (let ((xref (message-tokenize-header
6948 (mail-header-xref (gnus-summary-article-header article))
6950 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
6953 (setq xref (list (system-name))))
6956 (mapconcat 'identity
6957 (delete "Xref:" (delete new-xref xref))
6961 (set-buffer copy-buf)
6962 ;; First put the article in the destination group.
6963 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6964 (when (consp (setq art-group
6965 (gnus-request-accept-article
6966 to-newsgroup select-method (not articles))))
6967 (setq new-xref (concat new-xref " " (car art-group)
6968 ":" (cdr art-group)))
6969 ;; Now we have the new Xrefs header, so we insert
6970 ;; it and replace the new article.
6971 (nnheader-replace-header "Xref" new-xref)
6972 (gnus-request-replace-article
6973 (cdr art-group) to-newsgroup (current-buffer))
6977 (gnus-message 1 "Couldn't %s article %s"
6978 (cadr (assq action names)) article))
6979 ((and (eq art-group 'junk)
6981 (gnus-summary-mark-article article gnus-canceled-mark)
6982 (gnus-message 4 "Deleted article %s" article))
6986 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
6988 (gnus-group-prefixed-name
6991 (gnus-find-method-for-group to-newsgroup)))
6992 gnus-newsrc-hashtb)))
6993 (info (nth 2 entry))
6994 (to-group (gnus-info-group info)))
6995 ;; Update the group that has been moved to.
6997 (memq action '(move copy)))
6998 (unless (member to-group to-groups)
6999 (push to-group to-groups))
7001 (unless (memq article gnus-newsgroup-unreads)
7003 info (gnus-add-to-range (gnus-info-read info)
7004 (list (cdr art-group)))))
7006 ;; Copy any marks over to the new group.
7007 (let ((marks gnus-article-mark-lists)
7008 (to-article (cdr art-group)))
7010 ;; See whether the article is to be put in the cache.
7011 (when gnus-use-cache
7012 (gnus-cache-possibly-enter-article
7014 (let ((header (copy-sequence
7015 (gnus-summary-article-header article))))
7016 (mail-header-set-number header to-article)
7018 (memq article gnus-newsgroup-marked)
7019 (memq article gnus-newsgroup-dormant)
7020 (memq article gnus-newsgroup-unreads)))
7022 (when (and (equal to-group gnus-newsgroup-name)
7023 (not (memq article gnus-newsgroup-unreads)))
7024 ;; Mark this article as read in this group.
7025 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7026 (setcdr (gnus-active to-group) to-article)
7027 (setcdr gnus-newsgroup-active to-article))
7030 (when (memq article (symbol-value
7031 (intern (format "gnus-newsgroup-%s"
7033 ;; If the other group is the same as this group,
7034 ;; then we have to add the mark to the list.
7035 (when (equal to-group gnus-newsgroup-name)
7036 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7039 (intern (format "gnus-newsgroup-%s"
7041 ;; Copy the marks to other group.
7042 (gnus-add-marked-articles
7043 to-group (cdar marks) (list to-article) info))
7044 (setq marks (cdr marks)))
7047 (concat "(gnus-group-set-info '"
7048 (gnus-prin1-to-string (gnus-get-info to-group))
7051 ;; Update the Xref header in this article to point to
7052 ;; the new crossposted article we have just created.
7053 (when (eq action 'crosspost)
7055 (set-buffer copy-buf)
7056 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7057 (nnheader-replace-header "Xref" new-xref)
7058 (gnus-request-replace-article
7059 article gnus-newsgroup-name (current-buffer)))))
7061 ;;;!!!Why is this necessary?
7062 (set-buffer gnus-summary-buffer)
7064 (gnus-summary-goto-subject article)
7065 (when (eq action 'move)
7066 (gnus-summary-mark-article article gnus-canceled-mark))))
7067 (gnus-summary-remove-process-mark article))
7068 ;; Re-activate all groups that have been moved to.
7071 (set-buffer gnus-group-buffer)
7072 (when (gnus-group-goto-group (car to-groups) t)
7073 (gnus-group-get-new-news-this-group 1 t))
7076 (gnus-kill-buffer copy-buf)
7077 (gnus-summary-position-point)
7078 (gnus-set-mode-line 'summary)))
7080 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7081 "Move the current article to a different newsgroup.
7082 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7083 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7084 re-spool using this method."
7086 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7088 (defun gnus-summary-crosspost-article (&optional n)
7089 "Crosspost the current article to some other group."
7091 (gnus-summary-move-article n nil nil 'crosspost))
7093 (defcustom gnus-summary-respool-default-method nil
7094 "Default method for respooling an article.
7095 If nil, use to the current newsgroup method."
7096 :type `(choice (gnus-select-method :value (nnml ""))
7098 :group 'gnus-summary-mail)
7100 (defun gnus-summary-respool-article (&optional n method)
7101 "Respool the current article.
7102 The article will be squeezed through the mail spooling process again,
7103 which means that it will be put in some mail newsgroup or other
7104 depending on `nnmail-split-methods'.
7105 If N is a positive number, respool the N next articles.
7106 If N is a negative number, respool the N previous articles.
7107 If N is nil and any articles have been marked with the process mark,
7108 respool those articles instead.
7110 Respooling can be done both from mail groups and \"real\" newsgroups.
7111 In the former case, the articles in question will be moved from the
7112 current group into whatever groups they are destined to. In the
7113 latter case, they will be copied into the relevant groups."
7115 (list current-prefix-arg
7116 (let* ((methods (gnus-methods-using 'respool))
7118 (symbol-name (or gnus-summary-respool-default-method
7119 (car (gnus-find-method-for-group
7120 gnus-newsgroup-name)))))
7122 (gnus-completing-read
7123 methname "What backend do you want to use when respooling?"
7124 methods nil t nil 'gnus-mail-method-history))
7127 ((zerop (length (setq ms (gnus-servers-using-backend
7129 (list (intern method) ""))
7133 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7134 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7137 (error "No method given for respooling"))
7138 (if (assoc (symbol-name
7139 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7140 (gnus-methods-using 'respool))
7141 (gnus-summary-move-article n nil method)
7142 (gnus-summary-copy-article n nil method)))
7144 (defun gnus-summary-import-article (file)
7145 "Import an arbitrary file into a mail newsgroup."
7146 (interactive "fImport file: ")
7147 (let ((group gnus-newsgroup-name)
7148 (now (current-time))
7150 (unless (gnus-check-backend-function 'request-accept-article group)
7151 (error "%s does not support article importing" group))
7152 (or (file-readable-p file)
7153 (not (file-regular-p file))
7154 (error "Can't read %s" file))
7156 (set-buffer (get-buffer-create " *import file*"))
7157 (buffer-disable-undo (current-buffer))
7159 (insert-file-contents file)
7160 (goto-char (point-min))
7161 (unless (nnheader-article-p)
7162 ;; This doesn't look like an article, so we fudge some headers.
7163 (setq atts (file-attributes file)
7164 lines (count-lines (point-min) (point-max)))
7165 (insert "From: " (read-string "From: ") "\n"
7166 "Subject: " (read-string "Subject: ") "\n"
7167 "Date: " (timezone-make-date-arpa-standard
7168 (current-time-string (nth 5 atts))
7169 (current-time-zone now)
7170 (current-time-zone now))
7172 "Message-ID: " (message-make-message-id) "\n"
7173 "Lines: " (int-to-string lines) "\n"
7174 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7175 (gnus-request-accept-article group nil t)
7176 (kill-buffer (current-buffer)))))
7178 (defun gnus-summary-article-posted-p ()
7179 "Say whether the current (mail) article is available from `gnus-select-method' as well.
7180 This will be the case if the article has both been mailed and posted."
7182 (let ((id (mail-header-references (gnus-summary-article-header)))
7183 (gnus-override-method
7184 (or gnus-refer-article-method gnus-select-method)))
7185 (if (gnus-request-head id "")
7186 (gnus-message 2 "The current message was found on %s"
7187 gnus-override-method)
7188 (gnus-message 2 "The current message couldn't be found on %s"
7189 gnus-override-method)
7192 (defun gnus-summary-expire-articles (&optional now)
7193 "Expire all articles that are marked as expirable in the current group."
7195 (when (gnus-check-backend-function
7196 'request-expire-articles gnus-newsgroup-name)
7197 ;; This backend supports expiry.
7198 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7199 (expirable (if total
7201 ;; We need to update the info for
7202 ;; this group for `gnus-list-of-read-articles'
7203 ;; to give us the right answer.
7204 (gnus-run-hooks 'gnus-exit-group-hook)
7205 (gnus-summary-update-info)
7206 (gnus-list-of-read-articles gnus-newsgroup-name))
7207 (setq gnus-newsgroup-expirable
7208 (sort gnus-newsgroup-expirable '<))))
7209 (expiry-wait (if now 'immediate
7210 (gnus-group-find-parameter
7211 gnus-newsgroup-name 'expiry-wait)))
7214 ;; There are expirable articles in this group, so we run them
7215 ;; through the expiry process.
7216 (gnus-message 6 "Expiring articles...")
7217 ;; The list of articles that weren't expired is returned.
7220 (let ((nnmail-expiry-wait-function nil)
7221 (nnmail-expiry-wait expiry-wait))
7222 (setq es (gnus-request-expire-articles
7223 expirable gnus-newsgroup-name)))
7224 (setq es (gnus-request-expire-articles
7225 expirable gnus-newsgroup-name))))
7227 (setq gnus-newsgroup-expirable es))
7228 ;; We go through the old list of expirable, and mark all
7229 ;; really expired articles as nonexistent.
7230 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7231 (let ((gnus-use-cache nil))
7233 (unless (memq (car expirable) es)
7234 (when (gnus-data-find (car expirable))
7235 (gnus-summary-mark-article
7236 (car expirable) gnus-canceled-mark)))
7237 (setq expirable (cdr expirable)))))
7238 (gnus-message 6 "Expiring articles...done")))))
7240 (defun gnus-summary-expire-articles-now ()
7241 "Expunge all expirable articles in the current group.
7242 This means that *all* articles that are marked as expirable will be
7243 deleted forever, right now."
7245 (or gnus-expert-user
7247 "Are you really, really, really sure you want to delete all these messages? ")
7249 (gnus-summary-expire-articles t))
7251 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7252 (defun gnus-summary-delete-article (&optional n)
7253 "Delete the N next (mail) articles.
7254 This command actually deletes articles. This is not a marking
7255 command. The article will disappear forever from your life, never to
7257 If N is negative, delete backwards.
7258 If N is nil and articles have been marked with the process mark,
7259 delete these instead."
7261 (unless (gnus-check-backend-function 'request-expire-articles
7262 gnus-newsgroup-name)
7263 (error "The current newsgroup does not support article deletion"))
7264 ;; Compute the list of articles to delete.
7265 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
7267 (if (and gnus-novice-user
7268 (not (gnus-yes-or-no-p
7269 (format "Do you really want to delete %s forever? "
7270 (if (> (length articles) 1)
7271 (format "these %s articles" (length articles))
7274 ;; Delete the articles.
7275 (setq not-deleted (gnus-request-expire-articles
7276 articles gnus-newsgroup-name 'force))
7278 (gnus-summary-remove-process-mark (car articles))
7279 ;; The backend might not have been able to delete the article
7281 (unless (memq (car articles) not-deleted)
7282 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7283 (setq articles (cdr articles)))
7285 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7286 (gnus-summary-position-point)
7287 (gnus-set-mode-line 'summary)
7290 (defun gnus-summary-edit-article (&optional force)
7291 "Edit the current article.
7292 This will have permanent effect only in mail groups.
7293 If FORCE is non-nil, allow editing of articles even in read-only
7297 (set-buffer gnus-summary-buffer)
7298 (gnus-set-global-variables)
7299 (when (and (not force)
7300 (gnus-group-read-only-p))
7301 (error "The current newsgroup does not support article editing"))
7302 ;; Select article if needed.
7303 (unless (eq (gnus-summary-article-number)
7304 gnus-current-article)
7305 (gnus-summary-select-article t))
7306 (gnus-article-date-original)
7307 (gnus-article-edit-article
7308 `(lambda (no-highlight)
7309 (gnus-summary-edit-article-done
7310 ,(or (mail-header-references gnus-current-headers) "")
7311 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))
7313 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7315 (defun gnus-summary-edit-article-done (&optional references read-only buffer
7317 "Make edits to the current article permanent."
7319 ;; Replace the article.
7320 (let ((buf (current-buffer)))
7321 (nnheader-temp-write nil
7323 (if (and (not read-only)
7324 (not (gnus-request-replace-article
7325 (cdr gnus-article-current) (car gnus-article-current)
7327 (error "Couldn't replace article")
7328 ;; Update the summary buffer.
7330 (equal (message-tokenize-header references " ")
7331 (message-tokenize-header
7332 (or (message-fetch-field "references") "") " ")))
7333 ;; We only have to update this line.
7336 (message-narrow-to-head)
7337 (let ((head (buffer-string))
7339 (nnheader-temp-write nil
7340 (insert (format "211 %d Article retrieved.\n"
7341 (cdr gnus-article-current)))
7344 (let ((nntp-server-buffer (current-buffer)))
7345 (setq header (car (gnus-get-newsgroup-headers
7347 (set-buffer gnus-summary-buffer)
7348 gnus-newsgroup-dependencies)
7351 (set-buffer gnus-summary-buffer)
7352 (gnus-data-set-header
7353 (gnus-data-find (cdr gnus-article-current))
7355 (gnus-summary-update-article-line
7356 (cdr gnus-article-current) header))))))
7358 (set-buffer (or buffer gnus-summary-buffer))
7359 (gnus-summary-update-article (cdr gnus-article-current)))
7360 ;; Prettify the article buffer again.
7361 (unless no-highlight
7363 (set-buffer gnus-article-buffer)
7364 (gnus-run-hooks 'gnus-article-display-hook)
7365 (set-buffer gnus-original-article-buffer)
7366 (gnus-request-article
7367 (cdr gnus-article-current)
7368 (car gnus-article-current) (current-buffer))))
7369 ;; Prettify the summary buffer line.
7370 (when (gnus-visual-p 'summary-highlight 'highlight)
7371 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
7373 (defun gnus-summary-edit-wash (key)
7374 "Perform editing command KEY in the article buffer."
7378 (message "%s" (concat (this-command-keys) "- "))
7381 (gnus-summary-edit-article)
7382 (execute-kbd-macro (concat (this-command-keys) key))
7383 (gnus-article-edit-done))
7387 (defun gnus-summary-respool-query (&optional silent trace)
7388 "Query where the respool algorithm would put this article."
7390 (let (gnus-mark-article-hook)
7391 (gnus-summary-select-article)
7393 (set-buffer gnus-original-article-buffer)
7395 (message-narrow-to-head)
7396 (let ((groups (nnmail-article-group 'identity trace)))
7399 (message "This message would go to %s"
7400 (mapconcat 'car groups ", "))
7401 (message "This message would go to no groups"))
7404 (defun gnus-summary-respool-trace ()
7405 "Trace where the respool algorithm would put this article.
7406 Display a buffer showing all fancy splitting patterns which matched."
7408 (gnus-summary-respool-query nil t))
7410 ;; Summary marking commands.
7412 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
7413 "Mark articles which has the same subject as read, and then select the next.
7414 If UNMARK is positive, remove any kind of mark.
7415 If UNMARK is negative, tick articles."
7418 (setq unmark (prefix-numeric-value unmark)))
7420 (gnus-summary-mark-same-subject
7421 (gnus-summary-article-subject) unmark)))
7422 ;; Select next unread article. If auto-select-same mode, should
7423 ;; select the first unread article.
7424 (gnus-summary-next-article t (and gnus-auto-select-same
7425 (gnus-summary-article-subject)))
7426 (gnus-message 7 "%d article%s marked as %s"
7427 count (if (= count 1) " is" "s are")
7428 (if unmark "unread" "read"))))
7430 (defun gnus-summary-kill-same-subject (&optional unmark)
7431 "Mark articles which has the same subject as read.
7432 If UNMARK is positive, remove any kind of mark.
7433 If UNMARK is negative, tick articles."
7436 (setq unmark (prefix-numeric-value unmark)))
7438 (gnus-summary-mark-same-subject
7439 (gnus-summary-article-subject) unmark)))
7440 ;; If marked as read, go to next unread subject.
7442 ;; Go to next unread subject.
7443 (gnus-summary-next-subject 1 t))
7444 (gnus-message 7 "%d articles are marked as %s"
7445 count (if unmark "unread" "read"))))
7447 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7448 "Mark articles with same SUBJECT as read, and return marked number.
7449 If optional argument UNMARK is positive, remove any kinds of marks.
7450 If optional argument UNMARK is negative, mark articles as unread instead."
7454 ((null unmark) ; Mark as read.
7457 (gnus-summary-mark-article-as-read gnus-killed-mark)
7458 (gnus-summary-show-thread) t)
7459 (gnus-summary-find-subject subject))
7460 (setq count (1+ count))))
7461 ((> unmark 0) ; Tick.
7464 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
7465 (gnus-summary-show-thread) t)
7466 (gnus-summary-find-subject subject))
7467 (setq count (1+ count))))
7468 (t ; Mark as unread.
7471 (gnus-summary-mark-article-as-unread gnus-unread-mark)
7472 (gnus-summary-show-thread) t)
7473 (gnus-summary-find-subject subject))
7474 (setq count (1+ count)))))
7475 (gnus-set-mode-line 'summary)
7476 ;; Return the number of marked articles.
7479 (defun gnus-summary-mark-as-processable (n &optional unmark)
7480 "Set the process mark on the next N articles.
7481 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7482 the process mark instead. The difference between N and the actual
7483 number of articles marked is returned."
7485 (let ((backward (< n 0))
7490 (gnus-summary-remove-process-mark
7491 (gnus-summary-article-number))
7492 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7493 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7496 (gnus-message 7 "No more articles"))
7497 (gnus-summary-recenter)
7498 (gnus-summary-position-point)
7501 (defun gnus-summary-unmark-as-processable (n)
7502 "Remove the process mark from the next N articles.
7503 If N is negative, unmark backward instead. The difference between N and
7504 the actual number of articles unmarked is returned."
7506 (gnus-summary-mark-as-processable n t))
7508 (defun gnus-summary-unmark-all-processable ()
7509 "Remove the process mark from all articles."
7512 (while gnus-newsgroup-processable
7513 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7514 (gnus-summary-position-point))
7516 (defun gnus-summary-mark-as-expirable (n)
7517 "Mark N articles forward as expirable.
7518 If N is negative, mark backward instead. The difference between N and
7519 the actual number of articles marked is returned."
7521 (gnus-summary-mark-forward n gnus-expirable-mark))
7523 (defun gnus-summary-mark-article-as-replied (article)
7524 "Mark ARTICLE replied and update the summary line."
7525 (push article gnus-newsgroup-replied)
7526 (let ((buffer-read-only nil))
7527 (when (gnus-summary-goto-subject article)
7528 (gnus-summary-update-secondary-mark article))))
7530 (defun gnus-summary-set-bookmark (article)
7531 "Set a bookmark in current article."
7532 (interactive (list (gnus-summary-article-number)))
7533 (when (or (not (get-buffer gnus-article-buffer))
7534 (not gnus-current-article)
7535 (not gnus-article-current)
7536 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7537 (error "No current article selected"))
7538 ;; Remove old bookmark, if one exists.
7539 (let ((old (assq article gnus-newsgroup-bookmarks)))
7541 (setq gnus-newsgroup-bookmarks
7542 (delq old gnus-newsgroup-bookmarks))))
7543 ;; Set the new bookmark, which is on the form
7544 ;; (article-number . line-number-in-body).
7548 (set-buffer gnus-article-buffer)
7552 (goto-char (point-min))
7553 (search-forward "\n\n" nil t)
7556 gnus-newsgroup-bookmarks)
7557 (gnus-message 6 "A bookmark has been added to the current article."))
7559 (defun gnus-summary-remove-bookmark (article)
7560 "Remove the bookmark from the current article."
7561 (interactive (list (gnus-summary-article-number)))
7562 ;; Remove old bookmark, if one exists.
7563 (let ((old (assq article gnus-newsgroup-bookmarks)))
7566 (setq gnus-newsgroup-bookmarks
7567 (delq old gnus-newsgroup-bookmarks))
7568 (gnus-message 6 "Removed bookmark."))
7569 (gnus-message 6 "No bookmark in current article."))))
7571 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7572 (defun gnus-summary-mark-as-dormant (n)
7573 "Mark N articles forward as dormant.
7574 If N is negative, mark backward instead. The difference between N and
7575 the actual number of articles marked is returned."
7577 (gnus-summary-mark-forward n gnus-dormant-mark))
7579 (defun gnus-summary-set-process-mark (article)
7580 "Set the process mark on ARTICLE and update the summary line."
7581 (setq gnus-newsgroup-processable
7583 (delq article gnus-newsgroup-processable)))
7584 (when (gnus-summary-goto-subject article)
7585 (gnus-summary-show-thread)
7586 (gnus-summary-update-secondary-mark article)))
7588 (defun gnus-summary-remove-process-mark (article)
7589 "Remove the process mark from ARTICLE and update the summary line."
7590 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7591 (when (gnus-summary-goto-subject article)
7592 (gnus-summary-show-thread)
7593 (gnus-summary-update-secondary-mark article)))
7595 (defun gnus-summary-set-saved-mark (article)
7596 "Set the process mark on ARTICLE and update the summary line."
7597 (push article gnus-newsgroup-saved)
7598 (when (gnus-summary-goto-subject article)
7599 (gnus-summary-update-secondary-mark article)))
7601 (defun gnus-summary-mark-forward (n &optional mark no-expire)
7602 "Mark N articles as read forwards.
7603 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
7604 The difference between N and the actual number of articles marked is
7607 (let ((backward (< n 0))
7608 (gnus-summary-goto-unread
7609 (and gnus-summary-goto-unread
7610 (not (eq gnus-summary-goto-unread 'never))
7611 (not (memq mark (list gnus-unread-mark
7612 gnus-ticked-mark gnus-dormant-mark)))))
7614 (mark (or mark gnus-del-mark)))
7616 (gnus-summary-mark-article nil mark no-expire)
7617 (zerop (gnus-summary-next-subject
7619 (and gnus-summary-goto-unread
7620 (not (eq gnus-summary-goto-unread 'never)))
7624 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
7625 (gnus-summary-recenter)
7626 (gnus-summary-position-point)
7627 (gnus-set-mode-line 'summary)
7630 (defun gnus-summary-mark-article-as-read (mark)
7631 "Mark the current article quickly as read with MARK."
7632 (let ((article (gnus-summary-article-number)))
7633 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7634 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7635 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7636 (push (cons article mark) gnus-newsgroup-reads)
7637 ;; Possibly remove from cache, if that is used.
7638 (when gnus-use-cache
7639 (gnus-cache-enter-remove-article article))
7640 ;; Allow the backend to change the mark.
7641 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7642 ;; Check for auto-expiry.
7643 (when (and gnus-newsgroup-auto-expire
7644 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7645 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7646 (= mark gnus-ancient-mark)
7647 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7648 (= mark gnus-duplicate-mark)))
7649 (setq mark gnus-expirable-mark)
7650 (push article gnus-newsgroup-expirable))
7651 ;; Set the mark in the buffer.
7652 (gnus-summary-update-mark mark 'unread)
7655 (defun gnus-summary-mark-article-as-unread (mark)
7656 "Mark the current article quickly as unread with MARK."
7657 (let* ((article (gnus-summary-article-number))
7658 (old-mark (gnus-summary-article-mark article)))
7659 (if (eq mark old-mark)
7663 (gnus-error 1 "Can't mark negative article numbers")
7665 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7666 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7667 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
7668 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
7669 (cond ((= mark gnus-ticked-mark)
7670 (push article gnus-newsgroup-marked))
7671 ((= mark gnus-dormant-mark)
7672 (push article gnus-newsgroup-dormant))
7674 (push article gnus-newsgroup-unreads)))
7675 (gnus-pull article gnus-newsgroup-reads)
7677 ;; See whether the article is to be put in the cache.
7679 (vectorp (gnus-summary-article-header article))
7681 (gnus-cache-possibly-enter-article
7682 gnus-newsgroup-name article
7683 (gnus-summary-article-header article)
7684 (= mark gnus-ticked-mark)
7685 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7688 (gnus-summary-update-mark mark 'unread)
7691 (defun gnus-summary-mark-article (&optional article mark no-expire)
7692 "Mark ARTICLE with MARK. MARK can be any character.
7693 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
7694 `??' (dormant) and `?E' (expirable).
7695 If MARK is nil, then the default character `?D' is used.
7696 If ARTICLE is nil, then the article on the current line will be
7698 ;; The mark might be a string.
7699 (when (stringp mark)
7700 (setq mark (aref mark 0)))
7701 ;; If no mark is given, then we check auto-expiring.
7702 (and (not no-expire)
7703 gnus-newsgroup-auto-expire
7705 (and (gnus-characterp mark)
7706 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7707 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7708 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7709 (= mark gnus-duplicate-mark))))
7710 (setq mark gnus-expirable-mark))
7711 (let* ((mark (or mark gnus-del-mark))
7712 (article (or article (gnus-summary-article-number)))
7713 (old-mark (gnus-summary-article-mark article)))
7714 (if (eq mark old-mark)
7717 (error "No article on current line"))
7718 (if (not (if (or (= mark gnus-unread-mark)
7719 (= mark gnus-ticked-mark)
7720 (= mark gnus-dormant-mark))
7721 (gnus-mark-article-as-unread article mark)
7722 (gnus-mark-article-as-read article mark)))
7724 ;; See whether the article is to be put in the cache.
7726 (not (= mark gnus-canceled-mark))
7727 (vectorp (gnus-summary-article-header article))
7729 (gnus-cache-possibly-enter-article
7730 gnus-newsgroup-name article
7731 (gnus-summary-article-header article)
7732 (= mark gnus-ticked-mark)
7733 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7735 (when (gnus-summary-goto-subject article nil t)
7736 (let ((buffer-read-only nil))
7737 (gnus-summary-show-thread)
7739 (gnus-summary-update-mark mark 'unread)
7742 (defun gnus-summary-update-secondary-mark (article)
7743 "Update the secondary (read, process, cache) mark."
7744 (gnus-summary-update-mark
7745 (cond ((memq article gnus-newsgroup-processable)
7747 ((memq article gnus-newsgroup-cached)
7749 ((memq article gnus-newsgroup-replied)
7751 ((memq article gnus-newsgroup-saved)
7753 (t gnus-unread-mark))
7755 (when (gnus-visual-p 'summary-highlight 'highlight)
7756 (gnus-run-hooks 'gnus-summary-update-hook))
7759 (defun gnus-summary-update-mark (mark type)
7760 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
7761 (buffer-read-only nil))
7762 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
7763 (when (looking-at "\r")
7766 (<= (+ forward (point)) (point-max)))
7767 ;; Go to the right position on the line.
7768 (goto-char (+ forward (point)))
7769 ;; Replace the old mark with the new mark.
7770 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
7771 ;; Optionally update the marks by some user rule.
7772 (when (eq type 'unread)
7774 (gnus-data-find (gnus-summary-article-number)) mark)
7775 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
7777 (defun gnus-mark-article-as-read (article &optional mark)
7778 "Enter ARTICLE in the pertinent lists and remove it from others."
7779 ;; Make the article expirable.
7780 (let ((mark (or mark gnus-del-mark)))
7781 (if (= mark gnus-expirable-mark)
7782 (push article gnus-newsgroup-expirable)
7783 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
7784 ;; Remove from unread and marked lists.
7785 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7786 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7787 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7788 (push (cons article mark) gnus-newsgroup-reads)
7789 ;; Possibly remove from cache, if that is used.
7790 (when gnus-use-cache
7791 (gnus-cache-enter-remove-article article))
7794 (defun gnus-mark-article-as-unread (article &optional mark)
7795 "Enter ARTICLE in the pertinent lists and remove it from others."
7796 (let ((mark (or mark gnus-ticked-mark)))
7799 (gnus-error 1 "Can't mark negative article numbers")
7801 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
7802 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
7803 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
7804 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7806 ;; Unsuppress duplicates?
7807 (when gnus-suppress-duplicates
7808 (gnus-dup-unsuppress-article article))
7810 (cond ((= mark gnus-ticked-mark)
7811 (push article gnus-newsgroup-marked))
7812 ((= mark gnus-dormant-mark)
7813 (push article gnus-newsgroup-dormant))
7815 (push article gnus-newsgroup-unreads)))
7816 (gnus-pull article gnus-newsgroup-reads)
7819 (defalias 'gnus-summary-mark-as-unread-forward
7820 'gnus-summary-tick-article-forward)
7821 (make-obsolete 'gnus-summary-mark-as-unread-forward
7822 'gnus-summary-tick-article-forward)
7823 (defun gnus-summary-tick-article-forward (n)
7824 "Tick N articles forwards.
7825 If N is negative, tick backwards instead.
7826 The difference between N and the number of articles ticked is returned."
7828 (gnus-summary-mark-forward n gnus-ticked-mark))
7830 (defalias 'gnus-summary-mark-as-unread-backward
7831 'gnus-summary-tick-article-backward)
7832 (make-obsolete 'gnus-summary-mark-as-unread-backward
7833 'gnus-summary-tick-article-backward)
7834 (defun gnus-summary-tick-article-backward (n)
7835 "Tick N articles backwards.
7836 The difference between N and the number of articles ticked is returned."
7838 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
7840 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7841 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7842 (defun gnus-summary-tick-article (&optional article clear-mark)
7843 "Mark current article as unread.
7844 Optional 1st argument ARTICLE specifies article number to be marked as unread.
7845 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
7847 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
7850 (defun gnus-summary-mark-as-read-forward (n)
7851 "Mark N articles as read forwards.
7852 If N is negative, mark backwards instead.
7853 The difference between N and the actual number of articles marked is
7856 (gnus-summary-mark-forward n gnus-del-mark t))
7858 (defun gnus-summary-mark-as-read-backward (n)
7859 "Mark the N articles as read backwards.
7860 The difference between N and the actual number of articles marked is
7863 (gnus-summary-mark-forward (- n) gnus-del-mark t))
7865 (defun gnus-summary-mark-as-read (&optional article mark)
7866 "Mark current article as read.
7867 ARTICLE specifies the article to be marked as read.
7868 MARK specifies a string to be inserted at the beginning of the line."
7869 (gnus-summary-mark-article article mark))
7871 (defun gnus-summary-clear-mark-forward (n)
7872 "Clear marks from N articles forward.
7873 If N is negative, clear backward instead.
7874 The difference between N and the number of marks cleared is returned."
7876 (gnus-summary-mark-forward n gnus-unread-mark))
7878 (defun gnus-summary-clear-mark-backward (n)
7879 "Clear marks from N articles backward.
7880 The difference between N and the number of marks cleared is returned."
7882 (gnus-summary-mark-forward (- n) gnus-unread-mark))
7884 (defun gnus-summary-mark-unread-as-read ()
7885 "Intended to be used by `gnus-summary-mark-article-hook'."
7886 (when (memq gnus-current-article gnus-newsgroup-unreads)
7887 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
7889 (defun gnus-summary-mark-read-and-unread-as-read ()
7890 "Intended to be used by `gnus-summary-mark-article-hook'."
7891 (let ((mark (gnus-summary-article-mark)))
7892 (when (or (gnus-unread-mark-p mark)
7893 (gnus-read-mark-p mark))
7894 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
7896 (defun gnus-summary-mark-region-as-read (point mark all)
7897 "Mark all unread articles between point and mark as read.
7898 If given a prefix, mark all articles between point and mark as read,
7899 even ticked and dormant ones."
7900 (interactive "r\nP")
7909 (memq (setq article (gnus-summary-article-number))
7910 gnus-newsgroup-unreads))
7911 (gnus-summary-mark-article article gnus-del-mark))
7913 (gnus-summary-find-next))))))
7915 (defun gnus-summary-mark-below (score mark)
7916 "Mark articles with score less than SCORE with MARK."
7917 (interactive "P\ncMark: ")
7918 (setq score (if score
7919 (prefix-numeric-value score)
7920 (or gnus-summary-default-score 0)))
7922 (set-buffer gnus-summary-buffer)
7923 (goto-char (point-min))
7926 (and (< (gnus-summary-article-score) score)
7927 (gnus-summary-mark-article nil mark))
7928 (gnus-summary-find-next)))))
7930 (defun gnus-summary-kill-below (&optional score)
7931 "Mark articles with score below SCORE as read."
7933 (gnus-summary-mark-below score gnus-killed-mark))
7935 (defun gnus-summary-clear-above (&optional score)
7936 "Clear all marks from articles with score above SCORE."
7938 (gnus-summary-mark-above score gnus-unread-mark))
7940 (defun gnus-summary-tick-above (&optional score)
7941 "Tick all articles with score above SCORE."
7943 (gnus-summary-mark-above score gnus-ticked-mark))
7945 (defun gnus-summary-mark-above (score mark)
7946 "Mark articles with score over SCORE with MARK."
7947 (interactive "P\ncMark: ")
7948 (setq score (if score
7949 (prefix-numeric-value score)
7950 (or gnus-summary-default-score 0)))
7952 (set-buffer gnus-summary-buffer)
7953 (goto-char (point-min))
7955 (when (> (gnus-summary-article-score) score)
7956 (gnus-summary-mark-article nil mark))
7958 (gnus-summary-find-next)))))
7960 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7961 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
7962 (defun gnus-summary-limit-include-expunged (&optional no-error)
7963 "Display all the hidden articles that were expunged for low scores."
7965 (let ((buffer-read-only nil))
7966 (let ((scored gnus-newsgroup-scored)
7969 (unless (gnus-summary-goto-subject (caar scored))
7970 (and (setq h (gnus-summary-article-header (caar scored)))
7971 (< (cdar scored) gnus-summary-expunge-below)
7973 (setq scored (cdr scored)))
7975 (when (not no-error)
7976 (error "No expunged articles hidden"))
7977 (goto-char (point-min))
7978 (gnus-summary-prepare-unthreaded (nreverse headers))
7979 (goto-char (point-min))
7980 (gnus-summary-position-point)
7983 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
7984 "Mark all unread articles in this newsgroup as read.
7985 If prefix argument ALL is non-nil, ticked and dormant articles will
7986 also be marked as read.
7987 If QUIETLY is non-nil, no questions will be asked.
7988 If TO-HERE is non-nil, it should be a point in the buffer. All
7989 articles before this point will be marked as read.
7990 Note that this function will only catch up the unread article
7991 in the current summary buffer limitation.
7992 The number of articles marked as read is returned."
7997 (not gnus-interactive-catchup) ;Without confirmation?
8001 "Mark absolutely all articles as read? "
8002 "Mark all unread articles as read? ")))
8004 (not gnus-newsgroup-adaptive)
8005 (not gnus-newsgroup-auto-expire)
8006 (not gnus-suppress-duplicates)
8007 (or (not gnus-use-cache)
8008 (eq gnus-use-cache 'passive)))
8011 (setq gnus-newsgroup-marked nil
8012 gnus-newsgroup-dormant nil))
8013 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8014 ;; We actually mark all articles as canceled, which we
8015 ;; have to do when using auto-expiry or adaptive scoring.
8016 (gnus-summary-show-all-threads)
8017 (when (gnus-summary-first-subject (not all) t)
8019 (if to-here (< (point) to-here) t)
8020 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8021 (gnus-summary-find-next (not all) nil nil t))))
8022 (gnus-set-mode-line 'summary))
8024 (gnus-summary-position-point)))
8026 (defun gnus-summary-catchup-to-here (&optional all)
8027 "Mark all unticked articles before the current one as read.
8028 If ALL is non-nil, also mark ticked and dormant articles as read."
8031 (gnus-save-hidden-threads
8032 (let ((beg (point)))
8033 ;; We check that there are unread articles.
8034 (when (or all (gnus-summary-find-prev))
8035 (gnus-summary-catchup all t beg)))))
8036 (gnus-summary-position-point))
8038 (defun gnus-summary-catchup-all (&optional quietly)
8039 "Mark all articles in this newsgroup as read."
8041 (gnus-summary-catchup t quietly))
8043 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8044 "Mark all articles not marked as unread in this newsgroup as read, then exit.
8045 If prefix argument ALL is non-nil, all articles are marked as read."
8047 (when (gnus-summary-catchup all quietly nil 'fast)
8048 ;; Select next newsgroup or exit.
8049 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
8050 (eq gnus-auto-select-next 'quietly))
8051 (gnus-summary-next-group nil)
8052 (gnus-summary-exit))))
8054 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8055 "Mark all articles in this newsgroup as read, and then exit."
8057 (gnus-summary-catchup-and-exit t quietly))
8059 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
8060 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8061 "Mark all articles in this group as read and select the next group.
8062 If given a prefix, mark all articles, unread as well as ticked, as
8066 (gnus-summary-catchup all))
8067 (gnus-summary-next-article t nil nil t))
8069 ;; Thread-based commands.
8071 (defun gnus-summary-articles-in-thread (&optional article)
8072 "Return a list of all articles in the current thread.
8073 If ARTICLE is non-nil, return all articles in the thread that starts
8075 (let* ((article (or article (gnus-summary-article-number)))
8076 (data (gnus-data-find-list article))
8077 (top-level (gnus-data-level (car data)))
8079 (cond ((null gnus-thread-operation-ignore-subject)
8080 (gnus-simplify-subject-re
8081 (mail-header-subject (gnus-data-header (car data)))))
8082 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8083 (gnus-simplify-subject-fuzzy
8084 (mail-header-subject (gnus-data-header (car data)))))
8086 (end-point (save-excursion
8087 (if (gnus-summary-go-to-next-thread)
8088 (point) (point-max))))
8091 (< (gnus-data-pos (car data)) end-point))
8092 (when (or (not top-subject)
8093 (string= top-subject
8094 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8095 (gnus-simplify-subject-fuzzy
8096 (mail-header-subject
8097 (gnus-data-header (car data))))
8098 (gnus-simplify-subject-re
8099 (mail-header-subject
8100 (gnus-data-header (car data)))))))
8101 (push (gnus-data-number (car data)) articles))
8102 (unless (and (setq data (cdr data))
8103 (> (gnus-data-level (car data)) top-level))
8105 ;; Return the list of articles.
8106 (nreverse articles)))
8108 (defun gnus-summary-rethread-current ()
8109 "Rethread the thread the current article is part of."
8111 (let* ((gnus-show-threads t)
8112 (article (gnus-summary-article-number))
8113 (id (mail-header-id (gnus-summary-article-header)))
8114 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8116 (error "No article on the current line"))
8117 (gnus-rebuild-thread id)
8118 (gnus-summary-goto-subject article)))
8120 (defun gnus-summary-reparent-thread ()
8121 "Make the current article child of the marked (or previous) article.
8123 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8124 is non-nil or the Subject: of both articles are the same."
8126 (unless (not (gnus-group-read-only-p))
8127 (error "The current newsgroup does not support article editing"))
8128 (unless (<= (length gnus-newsgroup-processable) 1)
8129 (error "No more than one article may be marked"))
8130 (save-window-excursion
8131 (let ((gnus-article-buffer " *reparent*")
8132 (current-article (gnus-summary-article-number))
8133 ;; First grab the marked article, otherwise one line up.
8134 (parent-article (if (not (null gnus-newsgroup-processable))
8135 (car gnus-newsgroup-processable)
8137 (if (eq (forward-line -1) 0)
8138 (gnus-summary-article-number)
8139 (error "Beginning of summary buffer"))))))
8140 (unless (not (eq current-article parent-article))
8141 (error "An article may not be self-referential"))
8142 (let ((message-id (mail-header-id
8143 (gnus-summary-article-header parent-article))))
8144 (unless (and message-id (not (equal message-id "")))
8145 (error "No message-id in desired parent"))
8146 ;; We don't want the article to be marked as read.
8147 (let (gnus-mark-article-hook)
8148 (gnus-summary-select-article t t nil current-article))
8149 (set-buffer gnus-original-article-buffer)
8150 (let ((buf (format "%s" (buffer-string))))
8151 (nnheader-temp-write nil
8153 (goto-char (point-min))
8154 (if (re-search-forward "^References: " nil t)
8156 (re-search-forward "^[^ \t]" nil t)
8159 (insert " " message-id))
8160 (insert "References: " message-id "\n"))
8161 (unless (gnus-request-replace-article
8162 current-article (car gnus-article-current)
8164 (error "Couldn't replace article"))))
8165 (set-buffer gnus-summary-buffer)
8166 (gnus-summary-unmark-all-processable)
8167 (gnus-summary-update-article current-article)
8168 (gnus-summary-rethread-current)
8169 (gnus-message 3 "Article %d is now the child of article %d"
8170 current-article parent-article)))))
8172 (defun gnus-summary-toggle-threads (&optional arg)
8173 "Toggle showing conversation threads.
8174 If ARG is positive number, turn showing conversation threads on."
8176 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8177 (setq gnus-show-threads
8178 (if (null arg) (not gnus-show-threads)
8179 (> (prefix-numeric-value arg) 0)))
8180 (gnus-summary-prepare)
8181 (gnus-summary-goto-subject current)
8182 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8183 (gnus-summary-position-point)))
8185 (defun gnus-summary-show-all-threads ()
8189 (let ((buffer-read-only nil))
8190 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8191 (gnus-summary-position-point))
8193 (defun gnus-summary-show-thread ()
8194 "Show thread subtrees.
8195 Returns nil if no thread was there to be shown."
8197 (let ((buffer-read-only nil)
8199 ;; first goto end then to beg, to have point at beg after let
8200 (end (progn (end-of-line) (point)))
8201 (beg (progn (beginning-of-line) (point))))
8203 ;; Any hidden lines here?
8204 (search-forward "\r" end t)
8205 (subst-char-in-region beg end ?\^M ?\n t)
8207 (gnus-summary-position-point))))
8209 (defun gnus-summary-hide-all-threads ()
8210 "Hide all thread subtrees."
8213 (goto-char (point-min))
8214 (gnus-summary-hide-thread)
8215 (while (zerop (gnus-summary-next-thread 1 t))
8216 (gnus-summary-hide-thread)))
8217 (gnus-summary-position-point))
8219 (defun gnus-summary-hide-thread ()
8220 "Hide thread subtrees.
8221 Returns nil if no threads were there to be hidden."
8223 (let ((buffer-read-only nil)
8225 (article (gnus-summary-article-number)))
8227 ;; Go forward until either the buffer ends or the subthread
8229 (when (and (not (eobp))
8230 (or (zerop (gnus-summary-next-thread 1 t))
8231 (goto-char (point-max))))
8233 (if (and (> (point) start)
8234 (search-backward "\n" start t))
8236 (subst-char-in-region start (point) ?\n ?\^M)
8237 (gnus-summary-goto-subject article))
8240 ;;(gnus-summary-position-point)
8243 (defun gnus-summary-go-to-next-thread (&optional previous)
8244 "Go to the same level (or less) next thread.
8245 If PREVIOUS is non-nil, go to previous thread instead.
8246 Return the article number moved to, or nil if moving was impossible."
8247 (let ((level (gnus-summary-thread-level))
8248 (way (if previous -1 1))
8251 (while (and (not (eobp))
8252 (< level (gnus-summary-thread-level)))
8260 (gnus-summary-article-number)
8263 (defun gnus-summary-next-thread (n &optional silent)
8264 "Go to the same level next N'th thread.
8265 If N is negative, search backward instead.
8266 Returns the difference between N and the number of skips actually
8269 If SILENT, don't output messages."
8271 (let ((backward (< n 0))
8274 (gnus-summary-go-to-next-thread backward))
8277 (gnus-summary-position-point))
8278 (when (and (not silent) (/= 0 n))
8279 (gnus-message 7 "No more threads"))
8282 (defun gnus-summary-prev-thread (n)
8283 "Go to the same level previous N'th thread.
8284 Returns the difference between N and the number of skips actually
8287 (gnus-summary-next-thread (- n)))
8289 (defun gnus-summary-go-down-thread ()
8290 "Go down one level in the current thread."
8291 (let ((children (gnus-summary-article-children)))
8293 (gnus-summary-goto-subject (car children)))))
8295 (defun gnus-summary-go-up-thread ()
8296 "Go up one level in the current thread."
8297 (let ((parent (gnus-summary-article-parent)))
8299 (gnus-summary-goto-subject parent))))
8301 (defun gnus-summary-down-thread (n)
8302 "Go down thread N steps.
8303 If N is negative, go up instead.
8304 Returns the difference between N and how many steps down that were
8310 (if up (gnus-summary-go-up-thread)
8311 (gnus-summary-go-down-thread)))
8313 (gnus-summary-position-point)
8315 (gnus-message 7 "Can't go further"))
8318 (defun gnus-summary-up-thread (n)
8319 "Go up thread N steps.
8320 If N is negative, go up instead.
8321 Returns the difference between N and how many steps down that were
8324 (gnus-summary-down-thread (- n)))
8326 (defun gnus-summary-top-thread ()
8327 "Go to the top of the thread."
8329 (while (gnus-summary-go-up-thread))
8330 (gnus-summary-article-number))
8332 (defun gnus-summary-kill-thread (&optional unmark)
8333 "Mark articles under current thread as read.
8334 If the prefix argument is positive, remove any kinds of marks.
8335 If the prefix argument is negative, tick articles instead."
8338 (setq unmark (prefix-numeric-value unmark)))
8339 (let ((articles (gnus-summary-articles-in-thread)))
8341 ;; Expand the thread.
8342 (gnus-summary-show-thread)
8343 ;; Mark all the articles.
8345 (gnus-summary-goto-subject (car articles))
8346 (cond ((null unmark)
8347 (gnus-summary-mark-article-as-read gnus-killed-mark))
8349 (gnus-summary-mark-article-as-unread gnus-unread-mark))
8351 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
8352 (setq articles (cdr articles))))
8353 ;; Hide killed subtrees.
8355 gnus-thread-hide-killed
8356 (gnus-summary-hide-thread))
8357 ;; If marked as read, go to next unread subject.
8359 ;; Go to next unread subject.
8360 (gnus-summary-next-subject 1 t)))
8361 (gnus-set-mode-line 'summary))
8363 ;; Summary sorting commands
8365 (defun gnus-summary-sort-by-number (&optional reverse)
8366 "Sort the summary buffer by article number.
8367 Argument REVERSE means reverse order."
8369 (gnus-summary-sort 'number reverse))
8371 (defun gnus-summary-sort-by-author (&optional reverse)
8372 "Sort the summary buffer by author name alphabetically.
8373 If case-fold-search is non-nil, case of letters is ignored.
8374 Argument REVERSE means reverse order."
8376 (gnus-summary-sort 'author reverse))
8378 (defun gnus-summary-sort-by-subject (&optional reverse)
8379 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8380 If case-fold-search is non-nil, case of letters is ignored.
8381 Argument REVERSE means reverse order."
8383 (gnus-summary-sort 'subject reverse))
8385 (defun gnus-summary-sort-by-date (&optional reverse)
8386 "Sort the summary buffer by date.
8387 Argument REVERSE means reverse order."
8389 (gnus-summary-sort 'date reverse))
8391 (defun gnus-summary-sort-by-score (&optional reverse)
8392 "Sort the summary buffer by score.
8393 Argument REVERSE means reverse order."
8395 (gnus-summary-sort 'score reverse))
8397 (defun gnus-summary-sort-by-lines (&optional reverse)
8398 "Sort the summary buffer by article length.
8399 Argument REVERSE means reverse order."
8401 (gnus-summary-sort 'lines reverse))
8403 (defun gnus-summary-sort (predicate reverse)
8404 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
8405 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
8406 (article (intern (format "gnus-article-sort-by-%s" predicate)))
8407 (gnus-thread-sort-functions
8413 (gnus-article-sort-functions
8418 (,article t2 t1)))))
8420 (gnus-summary-prepare-hook nil))
8421 ;; We do the sorting by regenerating the threads.
8422 (gnus-summary-prepare)
8423 ;; Hide subthreads if needed.
8424 (when (and gnus-show-threads gnus-thread-hide-subtree)
8425 (gnus-summary-hide-all-threads))))
8427 ;; Summary saving commands.
8429 (defun gnus-summary-save-article (&optional n not-saved)
8430 "Save the current article using the default saver function.
8431 If N is a positive number, save the N next articles.
8432 If N is a negative number, save the N previous articles.
8433 If N is nil and any articles have been marked with the process mark,
8434 save those articles instead.
8435 The variable `gnus-default-article-saver' specifies the saver function."
8437 (let* ((articles (gnus-summary-work-articles n))
8438 (save-buffer (save-excursion
8439 (nnheader-set-temp-buffer " *Gnus Save*")))
8440 (num (length articles))
8441 header article file)
8443 (setq header (gnus-summary-article-header
8444 (setq article (pop articles))))
8445 (if (not (vectorp header))
8446 ;; This is a pseudo-article.
8447 (if (assq 'name header)
8448 (gnus-copy-file (cdr (assq 'name header)))
8449 (gnus-message 1 "Article %d is unsaveable" article))
8450 ;; This is a real article.
8451 (save-window-excursion
8452 (gnus-summary-select-article t nil nil article))
8454 (set-buffer save-buffer)
8456 (insert-buffer-substring gnus-original-article-buffer))
8457 (setq file (gnus-article-save save-buffer file num))
8458 (gnus-summary-remove-process-mark article)
8460 (gnus-summary-set-saved-mark article))))
8461 (gnus-kill-buffer save-buffer)
8462 (gnus-summary-position-point)
8463 (gnus-set-mode-line 'summary)
8466 (defun gnus-summary-pipe-output (&optional arg)
8467 "Pipe the current article to a subprocess.
8468 If N is a positive number, pipe the N next articles.
8469 If N is a negative number, pipe the N previous articles.
8470 If N is nil and any articles have been marked with the process mark,
8471 pipe those articles instead."
8473 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8474 (gnus-summary-save-article arg t))
8475 (gnus-configure-windows 'pipe))
8477 (defun gnus-summary-save-article-mail (&optional arg)
8478 "Append the current article to an mail file.
8479 If N is a positive number, save the N next articles.
8480 If N is a negative number, save the N previous articles.
8481 If N is nil and any articles have been marked with the process mark,
8482 save those articles instead."
8484 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8485 (gnus-summary-save-article arg)))
8487 (defun gnus-summary-save-article-rmail (&optional arg)
8488 "Append the current article to an rmail file.
8489 If N is a positive number, save the N next articles.
8490 If N is a negative number, save the N previous articles.
8491 If N is nil and any articles have been marked with the process mark,
8492 save those articles instead."
8494 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
8495 (gnus-summary-save-article arg)))
8497 (defun gnus-summary-save-article-file (&optional arg)
8498 "Append the current article to a file.
8499 If N is a positive number, save the N next articles.
8500 If N is a negative number, save the N previous articles.
8501 If N is nil and any articles have been marked with the process mark,
8502 save those articles instead."
8504 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8505 (gnus-summary-save-article arg)))
8507 (defun gnus-summary-write-article-file (&optional arg)
8508 "Write the current article to a file, deleting the previous file.
8509 If N is a positive number, save the N next articles.
8510 If N is a negative number, save the N previous articles.
8511 If N is nil and any articles have been marked with the process mark,
8512 save those articles instead."
8514 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
8515 (gnus-summary-save-article arg)))
8517 (defun gnus-summary-save-article-body-file (&optional arg)
8518 "Append the current article body to a file.
8519 If N is a positive number, save the N next articles.
8520 If N is a negative number, save the N previous articles.
8521 If N is nil and any articles have been marked with the process mark,
8522 save those articles instead."
8524 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
8525 (gnus-summary-save-article arg)))
8527 (defun gnus-summary-pipe-message (program)
8528 "Pipe the current article through PROGRAM."
8529 (interactive "sProgram: ")
8530 (gnus-summary-select-article)
8531 (let ((mail-header-separator "")
8532 (art-buf (get-buffer gnus-article-buffer)))
8533 (gnus-eval-in-buffer-window gnus-article-buffer
8536 (let ((start (window-start))
8538 (message-pipe-buffer-body program)
8539 (set-window-start (get-buffer-window (current-buffer)) start))))))
8541 (defun gnus-get-split-value (methods)
8542 "Return a value based on the split METHODS."
8543 (let (split-name method result match)
8546 (set-buffer gnus-original-article-buffer)
8548 (nnheader-narrow-to-headers)
8550 (goto-char (point-min))
8551 (setq method (pop methods))
8552 (setq match (car method))
8555 ;; Regular expression.
8557 (re-search-forward match nil t)))
8558 ((gnus-functionp match)
8562 (setq result (funcall match gnus-newsgroup-name))))
8567 (setq result (eval match)))))
8568 (setq split-name (append (cdr method) split-name))
8569 (cond ((stringp result)
8570 (push (expand-file-name
8571 result gnus-article-save-directory)
8574 (setq split-name (append result split-name)))))))))
8577 (defun gnus-valid-move-group-p (group)
8582 (car (gnus-find-method-for-group
8583 (symbol-name group))))
8584 gnus-valid-select-methods))))
8586 (defun gnus-read-move-group-name (prompt default articles prefix)
8587 "Read a group name."
8588 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
8589 (minibuffer-confirm-incomplete nil) ; XEmacs
8593 (if (> (length articles) 1)
8594 (format "these %d articles" (length articles))
8599 (gnus-completing-read default prom
8601 'gnus-valid-move-group-p
8603 'gnus-group-history))
8604 ((= 1 (length split-name))
8605 (gnus-completing-read (car split-name) prom
8607 'gnus-valid-move-group-p
8609 'gnus-group-history))
8611 (gnus-completing-read nil prom
8612 (mapcar (lambda (el) (list el))
8613 (nreverse split-name))
8615 'gnus-group-history)))))
8617 (if (or (string= to-newsgroup "")
8618 (string= to-newsgroup prefix))
8619 (setq to-newsgroup default))
8620 (unless to-newsgroup
8621 (error "No group name entered"))
8622 (or (gnus-active to-newsgroup)
8623 (gnus-activate-group to-newsgroup)
8624 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
8626 (or (and (gnus-request-create-group
8627 to-newsgroup (gnus-group-name-to-method to-newsgroup))
8628 (gnus-activate-group to-newsgroup nil nil
8629 (gnus-group-name-to-method
8631 (error "Couldn't create group %s" to-newsgroup)))
8632 (error "No such group: %s" to-newsgroup)))
8635 ;; Summary extract commands
8637 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
8638 (let ((buffer-read-only nil)
8639 (article (gnus-summary-article-number))
8641 (unless (gnus-summary-goto-subject article)
8642 (error "No such article: %d" article))
8643 (gnus-summary-position-point)
8644 ;; If all commands are to be bunched up on one line, we collect
8646 (unless gnus-view-pseudos-separately
8647 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
8650 (setq action (cdr (assq 'action (car ps))))
8651 (setq files (list (cdr (assq 'name (car ps)))))
8652 (while (and ps (cdr ps)
8653 (string= (or action "1")
8654 (or (cdr (assq 'action (cadr ps))) "2")))
8655 (push (cdr (assq 'name (cadr ps))) files)
8656 (setcdr ps (cddr ps)))
8658 (when (not (string-match "%s" action))
8661 (when (assq 'execute (car ps))
8662 (setcdr (assq 'execute (car ps))
8663 (funcall (if (string-match "%s" action)
8670 (gnus-quote-arg-for-sh-or-csh f)))
8672 (setq ps (cdr ps)))))
8673 (if (and gnus-view-pseudos (not not-view))
8675 (when (assq 'execute (car pslist))
8676 (gnus-execute-command (cdr (assq 'execute (car pslist)))
8677 (eq gnus-view-pseudos 'not-confirm)))
8678 (setq pslist (cdr pslist)))
8681 (setq after-article (or (cdr (assq 'article (car pslist)))
8682 (gnus-summary-article-number)))
8683 (gnus-summary-goto-subject after-article)
8686 (insert " " (file-name-nondirectory
8687 (cdr (assq 'name (car pslist))))
8688 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
8690 (forward-line -1) ; back to `b'
8691 (gnus-add-text-properties
8692 b (1- e) (list 'gnus-number gnus-reffed-article-number
8693 gnus-mouse-face-prop gnus-mouse-face))
8695 after-article gnus-reffed-article-number
8696 gnus-unread-mark b (car pslist) 0 (- e b))
8697 (push gnus-reffed-article-number gnus-newsgroup-unreads)
8698 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
8699 (setq pslist (cdr pslist)))))))
8701 (defun gnus-pseudos< (p1 p2)
8702 (let ((c1 (cdr (assq 'action p1)))
8703 (c2 (cdr (assq 'action p2))))
8704 (and c1 c2 (string< c1 c2))))
8706 (defun gnus-request-pseudo-article (props)
8707 (cond ((assq 'execute props)
8708 (gnus-execute-command (cdr (assq 'execute props)))))
8709 (let ((gnus-current-article (gnus-summary-article-number)))
8710 (gnus-run-hooks 'gnus-mark-article-hook)))
8712 (defun gnus-execute-command (command &optional automatic)
8714 (gnus-article-setup-buffer)
8715 (set-buffer gnus-article-buffer)
8716 (setq buffer-read-only nil)
8717 (let ((command (if automatic command
8718 (read-string "Command: " (cons command 0)))))
8720 (insert "$ " command "\n\n")
8721 (if gnus-view-pseudo-asynchronously
8722 (start-process "gnus-execute" (current-buffer) shell-file-name
8723 shell-command-switch command)
8724 (call-process shell-file-name nil t nil
8725 shell-command-switch command)))))
8727 ;; Summary kill commands.
8729 (defun gnus-summary-edit-global-kill (article)
8730 "Edit the \"global\" kill file."
8731 (interactive (list (gnus-summary-article-number)))
8732 (gnus-group-edit-global-kill article))
8734 (defun gnus-summary-edit-local-kill ()
8735 "Edit a local kill file applied to the current newsgroup."
8737 (setq gnus-current-headers (gnus-summary-article-header))
8738 (gnus-group-edit-local-kill
8739 (gnus-summary-article-number) gnus-newsgroup-name))
8743 (defun gnus-read-header (id &optional header)
8744 "Read the headers of article ID and enter them into the Gnus system."
8745 (let ((group gnus-newsgroup-name)
8746 (gnus-override-method
8747 (and (gnus-news-group-p gnus-newsgroup-name)
8748 gnus-refer-article-method))
8750 ;; First we check to see whether the header in question is already
8753 ;; This is a Message-ID.
8754 (setq header (or header (gnus-id-to-header id)))
8755 ;; This is an article number.
8756 (setq header (or header (gnus-summary-article-header id))))
8758 (not (gnus-summary-article-sparse-p (mail-header-number header))))
8759 ;; We have found the header.
8761 ;; If this is a sparse article, we have to nix out its
8762 ;; previous entry in the thread hashtb.
8764 (gnus-summary-article-sparse-p (mail-header-number header)))
8765 (let* ((parent (gnus-parent-id (mail-header-references header)))
8766 (thread (and parent (gnus-id-to-thread parent))))
8768 (delq (assq header thread) thread))))
8769 ;; We have to really fetch the header to this article.
8771 (set-buffer nntp-server-buffer)
8772 (when (setq where (gnus-request-head id group))
8773 (nnheader-fold-continuation-lines)
8774 (goto-char (point-max))
8776 (goto-char (point-min))
8780 ((cdr where) (cdr where))
8781 (header (mail-header-number header))
8782 (t gnus-reffed-article-number))
8784 (insert " Article retrieved.\n"))
8786 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
8787 () ; Malformed head.
8788 (unless (gnus-summary-article-sparse-p (mail-header-number header))
8789 (when (and (stringp id)
8790 (not (string= (gnus-group-real-name group)
8792 ;; If we fetched by Message-ID and the article came
8793 ;; from a different group, we fudge some bogus article
8794 ;; numbers for this article.
8795 (mail-header-set-number header gnus-reffed-article-number))
8797 (set-buffer gnus-summary-buffer)
8798 (decf gnus-reffed-article-number)
8799 (gnus-remove-header (mail-header-number header))
8800 (push header gnus-newsgroup-headers)
8801 (setq gnus-current-headers header)
8802 (push (mail-header-number header) gnus-newsgroup-limit)))
8805 (defun gnus-remove-header (number)
8806 "Remove header NUMBER from `gnus-newsgroup-headers'."
8807 (if (and gnus-newsgroup-headers
8808 (= number (mail-header-number (car gnus-newsgroup-headers))))
8809 (pop gnus-newsgroup-headers)
8810 (let ((headers gnus-newsgroup-headers))
8811 (while (and (cdr headers)
8812 (not (= number (mail-header-number (cadr headers)))))
8815 (setcdr headers (cddr headers))))))
8818 ;;; summary highlights
8821 (defun gnus-highlight-selected-summary ()
8822 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8823 ;; Highlight selected article in summary buffer
8824 (when gnus-summary-selected-face
8826 (let* ((beg (progn (beginning-of-line) (point)))
8827 (end (progn (end-of-line) (point)))
8828 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
8829 (from (if (get-text-property beg gnus-mouse-face-prop)
8831 (or (next-single-property-change
8832 beg gnus-mouse-face-prop nil end)
8837 (or (next-single-property-change
8838 from gnus-mouse-face-prop nil end)
8840 ;; If no mouse-face prop on line we will have to = from = end,
8841 ;; so we highlight the entire line instead.
8842 (when (= (+ to 2) from)
8845 (if gnus-newsgroup-selected-overlay
8846 ;; Move old overlay.
8848 gnus-newsgroup-selected-overlay from to (current-buffer))
8849 ;; Create new overlay.
8851 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
8852 'face gnus-summary-selected-face))))))
8854 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
8855 (defun gnus-summary-highlight-line ()
8856 "Highlight current line according to `gnus-summary-highlight'."
8857 (let* ((list gnus-summary-highlight)
8859 (end (progn (end-of-line) (point)))
8860 ;; now find out where the line starts and leave point there.
8861 (beg (progn (beginning-of-line) (point)))
8862 (article (gnus-summary-article-number))
8863 (score (or (cdr (assq (or article gnus-current-article)
8864 gnus-newsgroup-scored))
8865 gnus-summary-default-score 0))
8866 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
8867 (inhibit-read-only t))
8868 ;; Eval the cars of the lists until we find a match.
8869 (let ((default gnus-summary-default-score))
8871 (not (eval (caar list))))
8872 (setq list (cdr list))))
8873 (let ((face (cdar list)))
8874 (unless (eq face (get-text-property beg 'face))
8875 (gnus-put-text-property-excluding-characters-with-faces
8877 (setq face (if (boundp face) (symbol-value face) face)))
8878 (when gnus-summary-highlight-line-function
8879 (funcall gnus-summary-highlight-line-function article face))))
8882 (defun gnus-update-read-articles (group unread &optional compute)
8883 "Update the list of read articles in GROUP."
8884 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
8885 (entry (gnus-gethash group gnus-newsrc-hashtb))
8886 (info (nth 2 entry))
8888 (unread (sort (copy-sequence unread) '<))
8890 (if (or (not info) (not active))
8891 ;; There is no info on this group if it was, in fact,
8892 ;; killed. Gnus stores no information on killed groups, so
8893 ;; there's nothing to be done.
8894 ;; One could store the information somewhere temporarily,
8895 ;; perhaps... Hmmm...
8897 ;; Remove any negative articles numbers.
8898 (while (and unread (< (car unread) 0))
8899 (setq unread (cdr unread)))
8900 ;; Remove any expired article numbers
8901 (while (and unread (< (car unread) (car active)))
8902 (setq unread (cdr unread)))
8903 ;; Compute the ranges of read articles by looking at the list of
8906 (when (/= (car unread) prev)
8907 (push (if (= prev (1- (car unread))) prev
8908 (cons prev (1- (car unread))))
8910 (setq prev (1+ (car unread)))
8911 (setq unread (cdr unread)))
8912 (when (<= prev (cdr active))
8913 (push (cons prev (cdr active)) read))
8915 (if (> (length read) 1) (nreverse read) read)
8917 (set-buffer gnus-group-buffer)
8920 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
8921 (gnus-info-set-read ',info ',(gnus-info-read info))
8922 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
8923 (gnus-group-update-group ,group t))))
8924 ;; Enter this list into the group info.
8926 info (if (> (length read) 1) (nreverse read) read))
8927 ;; Set the number of unread articles in gnus-newsrc-hashtb.
8928 (gnus-get-unread-articles-in-group info (gnus-active group))
8931 (defun gnus-offer-save-summaries ()
8932 "Offer to save all active summary buffers."
8934 (let ((buflist (buffer-list))
8936 ;; Go through all buffers and find all summaries.
8938 (and (setq bufname (buffer-name (car buflist)))
8939 (string-match "Summary" bufname)
8941 (set-buffer bufname)
8942 ;; We check that this is, indeed, a summary buffer.
8943 (and (eq major-mode 'gnus-summary-mode)
8944 ;; Also make sure this isn't bogus.
8945 gnus-newsgroup-prepared
8946 ;; Also make sure that this isn't a dead summary buffer.
8947 (not gnus-dead-summary-mode)))
8948 (push bufname buffers))
8949 (setq buflist (cdr buflist)))
8950 ;; Go through all these summary buffers and offer to save them.
8953 "Update summary buffer %s? "
8955 (switch-to-buffer buf)
8956 (gnus-summary-exit))
8963 (run-hooks 'gnus-sum-load-hook)
8965 ;;; gnus-sum.el ends here