1 ;;; gnus-sum.el --- summary mode commands for Gnus
2 ;; Copyright (C) 1996,97,98,99 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))
38 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
40 (defcustom gnus-kill-summary-on-exit t
41 "*If non-nil, kill the summary buffer when you exit from it.
42 If nil, the summary will become a \"*Dead Summary*\" buffer, and
43 it will be killed sometime later."
44 :group 'gnus-summary-exit
47 (defcustom gnus-fetch-old-headers nil
48 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
49 If an unread article in the group refers to an older, already read (or
50 just marked as read) article, the old article will not normally be
51 displayed in the Summary buffer. If this variable is non-nil, Gnus
52 will attempt to grab the headers to the old articles, and thereby
53 build complete threads. If it has the value `some', only enough
54 headers to connect otherwise loose threads will be displayed. This
55 variable can also be a number. In that case, no more than that number
56 of old headers will be fetched. If it has the value `invisible', all
57 old headers will be fetched, but none will be displayed.
59 The server has to support NOV for any of this to work."
61 :type '(choice (const :tag "off" nil)
64 (sexp :menu-tag "other" t)))
66 (defcustom gnus-refer-thread-limit 200
67 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
68 If t, fetch all the available old headers."
71 (sexp :menu-tag "other" t)))
73 (defcustom gnus-summary-make-false-root 'adopt
74 "*nil means that Gnus won't gather loose threads.
75 If the root of a thread has expired or been read in a previous
76 session, the information necessary to build a complete thread has been
77 lost. Instead of having many small sub-threads from this original thread
78 scattered all over the summary buffer, Gnus can gather them.
80 If non-nil, Gnus will try to gather all loose sub-threads from an
81 original thread into one large thread.
83 If this variable is non-nil, it should be one of `none', `adopt',
86 If this variable is `none', Gnus will not make a false root, but just
87 present the sub-threads after another.
88 If this variable is `dummy', Gnus will create a dummy root that will
89 have all the sub-threads as children.
90 If this variable is `adopt', Gnus will make one of the \"children\"
91 the parent and mark all the step-children as such.
92 If this variable is `empty', the \"children\" are printed with empty
93 subject fields. (Or rather, they will be printed with a string
94 given by the `gnus-summary-same-subject' variable.)"
96 :type '(choice (const :tag "off" nil)
102 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
103 "*A regexp to match subjects to be excluded from loose thread gathering.
104 As loose thread gathering is done on subjects only, that means that
105 there can be many false gatherings performed. By rooting out certain
106 common subjects, gathering might become saner."
110 (defcustom gnus-summary-gather-subject-limit nil
111 "*Maximum length of subject comparisons when gathering loose threads.
112 Use nil to compare full subjects. Setting this variable to a low
113 number will help gather threads that have been corrupted by
114 newsreaders chopping off subject lines, but it might also mean that
115 unrelated articles that have subject that happen to begin with the
116 same few characters will be incorrectly gathered.
118 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
121 :type '(choice (const :tag "off" nil)
123 (sexp :menu-tag "on" t)))
125 (defcustom gnus-simplify-subject-functions nil
126 "List of functions taking a string argument that simplify subjects.
127 The functions are applied recursively.
129 Useful functions to put in this list include: `gnus-simplify-subject-re',
130 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
132 :type '(repeat function))
134 (defcustom gnus-simplify-ignored-prefixes nil
135 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
137 :type '(choice (const :tag "off" nil)
140 (defcustom gnus-build-sparse-threads nil
141 "*If non-nil, fill in the gaps in threads.
142 If `some', only fill in the gaps that are needed to tie loose threads
143 together. If `more', fill in all leaf nodes that Gnus can find. If
144 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
146 :type '(choice (const :tag "off" nil)
149 (sexp :menu-tag "all" t)))
151 (defcustom gnus-summary-thread-gathering-function
152 'gnus-gather-threads-by-subject
153 "*Function used for gathering loose threads.
154 There are two pre-defined functions: `gnus-gather-threads-by-subject',
155 which only takes Subjects into consideration; and
156 `gnus-gather-threads-by-references', which compared the References
157 headers of the articles to find matches."
159 :type '(radio (function-item gnus-gather-threads-by-subject)
160 (function-item gnus-gather-threads-by-references)
161 (function :tag "other")))
163 (defcustom gnus-summary-same-subject ""
164 "*String indicating that the current article has the same subject as the previous.
165 This variable will only be used if the value of
166 `gnus-summary-make-false-root' is `empty'."
167 :group 'gnus-summary-format
170 (defcustom gnus-summary-goto-unread t
171 "*If t, marking commands will go to the next unread article.
172 If `never', commands that usually go to the next unread article, will
173 go to the next article, whether it is read or not.
174 If nil, only the marking commands will go to the next (un)read article."
175 :group 'gnus-summary-marks
176 :link '(custom-manual "(gnus)Setting Marks")
177 :type '(choice (const :tag "off" nil)
179 (sexp :menu-tag "on" t)))
181 (defcustom gnus-summary-default-score 0
182 "*Default article score level.
183 All scores generated by the score files will be added to this score.
184 If this variable is nil, scoring will be disabled."
185 :group 'gnus-score-default
186 :type '(choice (const :tag "disable")
189 (defcustom gnus-summary-zcore-fuzz 0
190 "*Fuzziness factor for the zcore in the summary buffer.
191 Articles with scores closer than this to `gnus-summary-default-score'
193 :group 'gnus-summary-format
196 (defcustom gnus-simplify-subject-fuzzy-regexp nil
197 "*Strings to be removed when doing fuzzy matches.
198 This can either be a regular expression or list of regular expressions
199 that will be removed from subject strings if fuzzy subject
200 simplification is selected."
202 :type '(repeat regexp))
204 (defcustom gnus-show-threads t
205 "*If non-nil, display threads in summary mode."
209 (defcustom gnus-thread-hide-subtree nil
210 "*If non-nil, hide all threads initially.
211 If threads are hidden, you have to run the command
212 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
213 to expose hidden threads."
217 (defcustom gnus-thread-hide-killed t
218 "*If non-nil, hide killed threads automatically."
222 (defcustom gnus-thread-ignore-subject t
223 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
224 If nil, articles that have different subjects from their parents will
225 start separate threads."
229 (defcustom gnus-thread-operation-ignore-subject t
230 "*If non-nil, subjects will be ignored when doing thread commands.
231 This affects commands like `gnus-summary-kill-thread' and
232 `gnus-summary-lower-thread'.
234 If this variable is nil, articles in the same thread with different
235 subjects will not be included in the operation in question. If this
236 variable is `fuzzy', only articles that have subjects that are fuzzily
237 equal will be included."
239 :type '(choice (const :tag "off" nil)
243 (defcustom gnus-thread-indent-level 4
244 "*Number that says how much each sub-thread should be indented."
248 (defcustom gnus-auto-extend-newsgroup t
249 "*If non-nil, extend newsgroup forward and backward when requested."
250 :group 'gnus-summary-choose
253 (defcustom gnus-auto-select-first t
254 "*If nil, don't select the first unread article when entering a group.
255 If this variable is `best', select the highest-scored unread article
256 in the group. If t, select the first unread article.
258 This variable can also be a function to place point on a likely
259 subject line. Useful values include `gnus-summary-first-unread-subject',
260 `gnus-summary-first-unread-article' and
261 `gnus-summary-best-unread-article'.
263 If you want to prevent automatic selection of the first unread article
264 in some newsgroups, set the variable to nil in
265 `gnus-select-group-hook'."
266 :group 'gnus-group-select
267 :type '(choice (const :tag "none" nil)
269 (sexp :menu-tag "first" t)
270 (function-item gnus-summary-first-unread-subject)
271 (function-item gnus-summary-first-unread-article)
272 (function-item gnus-summary-best-unread-article)))
274 (defcustom gnus-auto-select-next t
275 "*If non-nil, offer to go to the next group from the end of the previous.
276 If the value is t and the next newsgroup is empty, Gnus will exit
277 summary mode and go back to group mode. If the value is neither nil
278 nor t, Gnus will select the following unread newsgroup. In
279 particular, if the value is the symbol `quietly', the next unread
280 newsgroup will be selected without any confirmation, and if it is
281 `almost-quietly', the next group will be selected without any
282 confirmation if you are located on the last article in the group.
283 Finally, if this variable is `slightly-quietly', the `Z n' command
284 will go to the next group without confirmation."
285 :group 'gnus-summary-maneuvering
286 :type '(choice (const :tag "off" nil)
288 (const almost-quietly)
289 (const slightly-quietly)
290 (sexp :menu-tag "on" t)))
292 (defcustom gnus-auto-select-same nil
293 "*If non-nil, select the next article with the same subject.
294 If there are no more articles with the same subject, go to
295 the first unread article."
296 :group 'gnus-summary-maneuvering
299 (defcustom gnus-summary-check-current nil
300 "*If non-nil, consider the current article when moving.
301 The \"unread\" movement commands will stay on the same line if the
302 current article is unread."
303 :group 'gnus-summary-maneuvering
306 (defcustom gnus-auto-center-summary t
307 "*If non-nil, always center the current summary buffer.
308 In particular, if `vertical' do only vertical recentering. If non-nil
309 and non-`vertical', do both horizontal and vertical recentering."
310 :group 'gnus-summary-maneuvering
311 :type '(choice (const :tag "none" nil)
313 (integer :tag "height")
314 (sexp :menu-tag "both" t)))
316 (defcustom gnus-show-all-headers nil
317 "*If non-nil, don't hide any headers."
318 :group 'gnus-article-hiding
319 :group 'gnus-article-headers
322 (defcustom gnus-summary-ignore-duplicates nil
323 "*If non-nil, ignore articles with identical Message-ID headers."
327 (defcustom gnus-single-article-buffer t
328 "*If non-nil, display all articles in the same buffer.
329 If nil, each group will get its own article buffer."
330 :group 'gnus-article-various
333 (defcustom gnus-break-pages t
334 "*If non-nil, do page breaking on articles.
335 The page delimiter is specified by the `gnus-page-delimiter'
337 :group 'gnus-article-various
340 (defcustom gnus-move-split-methods nil
341 "*Variable used to suggest where articles are to be moved to.
342 It uses the same syntax as the `gnus-split-methods' variable."
343 :group 'gnus-summary-mail
344 :type '(repeat (choice (list :value (fun) function)
345 (cons :value ("" "") regexp (repeat string))
348 (defcustom gnus-unread-mark ? ;Whitespace
349 "*Mark used for unread articles."
350 :group 'gnus-summary-marks
353 (defcustom gnus-ticked-mark ?!
354 "*Mark used for ticked articles."
355 :group 'gnus-summary-marks
358 (defcustom gnus-dormant-mark ??
359 "*Mark used for dormant articles."
360 :group 'gnus-summary-marks
363 (defcustom gnus-del-mark ?r
364 "*Mark used for del'd articles."
365 :group 'gnus-summary-marks
368 (defcustom gnus-read-mark ?R
369 "*Mark used for read articles."
370 :group 'gnus-summary-marks
373 (defcustom gnus-expirable-mark ?E
374 "*Mark used for expirable articles."
375 :group 'gnus-summary-marks
378 (defcustom gnus-killed-mark ?K
379 "*Mark used for killed articles."
380 :group 'gnus-summary-marks
383 (defcustom gnus-souped-mark ?F
384 "*Mark used for killed articles."
385 :group 'gnus-summary-marks
388 (defcustom gnus-kill-file-mark ?X
389 "*Mark used for articles killed by kill files."
390 :group 'gnus-summary-marks
393 (defcustom gnus-low-score-mark ?Y
394 "*Mark used for articles with a low score."
395 :group 'gnus-summary-marks
398 (defcustom gnus-catchup-mark ?C
399 "*Mark used for articles that are caught up."
400 :group 'gnus-summary-marks
403 (defcustom gnus-replied-mark ?A
404 "*Mark used for articles that have been replied to."
405 :group 'gnus-summary-marks
408 (defcustom gnus-cached-mark ?*
409 "*Mark used for articles that are in the cache."
410 :group 'gnus-summary-marks
413 (defcustom gnus-saved-mark ?S
414 "*Mark used for articles that have been saved to."
415 :group 'gnus-summary-marks
418 (defcustom gnus-ancient-mark ?O
419 "*Mark used for ancient articles."
420 :group 'gnus-summary-marks
423 (defcustom gnus-sparse-mark ?Q
424 "*Mark used for sparsely reffed articles."
425 :group 'gnus-summary-marks
428 (defcustom gnus-canceled-mark ?G
429 "*Mark used for canceled articles."
430 :group 'gnus-summary-marks
433 (defcustom gnus-duplicate-mark ?M
434 "*Mark used for duplicate articles."
435 :group 'gnus-summary-marks
438 (defcustom gnus-undownloaded-mark ?@
439 "*Mark used for articles that weren't downloaded."
440 :group 'gnus-summary-marks
443 (defcustom gnus-downloadable-mark ?%
444 "*Mark used for articles that are to be downloaded."
445 :group 'gnus-summary-marks
448 (defcustom gnus-unsendable-mark ?=
449 "*Mark used for articles that won't be sent."
450 :group 'gnus-summary-marks
453 (defcustom gnus-score-over-mark ?+
454 "*Score mark used for articles with high scores."
455 :group 'gnus-summary-marks
458 (defcustom gnus-score-below-mark ?-
459 "*Score mark used for articles with low scores."
460 :group 'gnus-summary-marks
463 (defcustom gnus-empty-thread-mark ? ;Whitespace
464 "*There is no thread under the article."
465 :group 'gnus-summary-marks
468 (defcustom gnus-not-empty-thread-mark ?=
469 "*There is a thread under the article."
470 :group 'gnus-summary-marks
473 (defcustom gnus-view-pseudo-asynchronously nil
474 "*If non-nil, Gnus will view pseudo-articles asynchronously."
475 :group 'gnus-extract-view
478 (defcustom gnus-auto-expirable-marks
479 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
480 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
481 gnus-souped-mark gnus-duplicate-mark)
482 "*The list of marks converted into expiration if a group is auto-expirable."
484 :type '(repeat character))
486 (defcustom gnus-inhibit-user-auto-expire t
487 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
491 (defcustom gnus-view-pseudos nil
492 "*If `automatic', pseudo-articles will be viewed automatically.
493 If `not-confirm', pseudos will be viewed automatically, and the user
494 will not be asked to confirm the command."
495 :group 'gnus-extract-view
496 :type '(choice (const :tag "off" nil)
498 (const not-confirm)))
500 (defcustom gnus-view-pseudos-separately t
501 "*If non-nil, one pseudo-article will be created for each file to be viewed.
502 If nil, all files that use the same viewing command will be given as a
503 list of parameters to that command."
504 :group 'gnus-extract-view
507 (defcustom gnus-insert-pseudo-articles t
508 "*If non-nil, insert pseudo-articles when decoding articles."
509 :group 'gnus-extract-view
512 (defcustom gnus-summary-dummy-line-format
514 "*The format specification for the dummy roots in the summary buffer.
515 It works along the same lines as a normal formatting string,
516 with some simple extensions.
519 :group 'gnus-threading
522 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
523 "*The format specification for the summary mode line.
524 It works along the same lines as a normal formatting string,
525 with some simple extensions:
528 %p Unprefixed group name
529 %A Current article number
530 %z Current article score
532 %U Number of unread articles in the group
533 %e Number of unselected articles in the group
534 %Z A string with unread/unselected article counts
535 %g Shortish group name
536 %S Subject of the current article
538 %s Current score file name
539 %d Number of dormant articles
540 %r Number of articles that have been marked as read in this session
541 %E Number of articles expunged by the score files"
542 :group 'gnus-summary-format
545 (defcustom gnus-list-identifiers nil
546 "Regexp that matches list identifiers to be removed from subject.
547 This can also be a list of regexps."
548 :group 'gnus-summary-format
549 :group 'gnus-article-hiding
550 :type '(choice (const :tag "none" nil)
552 (repeat :value (".*") regexp)))
554 (defcustom gnus-summary-mark-below 0
555 "*Mark all articles with a score below this variable as read.
556 This variable is local to each summary buffer and usually set by the
558 :group 'gnus-score-default
561 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
562 "*List of functions used for sorting articles in the summary buffer.
563 This variable is only used when not using a threaded display."
564 :group 'gnus-summary-sort
565 :type '(repeat (choice (function-item gnus-article-sort-by-number)
566 (function-item gnus-article-sort-by-author)
567 (function-item gnus-article-sort-by-subject)
568 (function-item gnus-article-sort-by-date)
569 (function-item gnus-article-sort-by-score)
570 (function :tag "other"))))
572 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
573 "*List of functions used for sorting threads in the summary buffer.
574 By default, threads are sorted by article number.
576 Each function takes two threads and return non-nil if the first thread
577 should be sorted before the other. If you use more than one function,
578 the primary sort function should be the last. You should probably
579 always include `gnus-thread-sort-by-number' in the list of sorting
580 functions -- preferably first.
582 Ready-made functions include `gnus-thread-sort-by-number',
583 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
584 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
585 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
586 :group 'gnus-summary-sort
587 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
588 (function-item gnus-thread-sort-by-author)
589 (function-item gnus-thread-sort-by-subject)
590 (function-item gnus-thread-sort-by-date)
591 (function-item gnus-thread-sort-by-score)
592 (function-item gnus-thread-sort-by-total-score)
593 (function :tag "other"))))
595 (defcustom gnus-thread-score-function '+
596 "*Function used for calculating the total score of a thread.
598 The function is called with the scores of the article and each
599 subthread and should then return the score of the thread.
601 Some functions you can use are `+', `max', or `min'."
602 :group 'gnus-summary-sort
605 (defcustom gnus-summary-expunge-below nil
606 "All articles that have a score less than this variable will be expunged.
607 This variable is local to the summary buffers."
608 :group 'gnus-score-default
609 :type '(choice (const :tag "off" nil)
612 (defcustom gnus-thread-expunge-below nil
613 "All threads that have a total score less than this variable will be expunged.
614 See `gnus-thread-score-function' for en explanation of what a
617 This variable is local to the summary buffers."
618 :group 'gnus-threading
619 :group 'gnus-score-default
620 :type '(choice (const :tag "off" nil)
623 (defcustom gnus-summary-mode-hook nil
624 "*A hook for Gnus summary mode.
625 This hook is run before any variables are set in the summary buffer."
626 :group 'gnus-summary-various
629 (defcustom gnus-summary-menu-hook nil
630 "*Hook run after the creation of the summary mode menu."
631 :group 'gnus-summary-visual
634 (defcustom gnus-summary-exit-hook nil
635 "*A hook called on exit from the summary buffer.
636 It will be called with point in the group buffer."
637 :group 'gnus-summary-exit
640 (defcustom gnus-summary-prepare-hook nil
641 "*A hook called after the summary buffer has been generated.
642 If you want to modify the summary buffer, you can use this hook."
643 :group 'gnus-summary-various
646 (defcustom gnus-summary-prepared-hook nil
647 "*A hook called as the last thing after the summary buffer has been generated."
648 :group 'gnus-summary-various
651 (defcustom gnus-summary-generate-hook nil
652 "*A hook run just before generating the summary buffer.
653 This hook is commonly used to customize threading variables and the
655 :group 'gnus-summary-various
658 (defcustom gnus-select-group-hook nil
659 "*A hook called when a newsgroup is selected.
661 If you'd like to simplify subjects like the
662 `gnus-summary-next-same-subject' command does, you can use the
665 (setq gnus-select-group-hook
668 (mapcar (lambda (header)
669 (mail-header-set-subject
671 (gnus-simplify-subject
672 (mail-header-subject header) 're-only)))
673 gnus-newsgroup-headers))))"
674 :group 'gnus-group-select
677 (defcustom gnus-select-article-hook nil
678 "*A hook called when an article is selected."
679 :group 'gnus-summary-choose
682 (defcustom gnus-visual-mark-article-hook
683 (list 'gnus-highlight-selected-summary)
684 "*Hook run after selecting an article in the summary buffer.
685 It is meant to be used for highlighting the article in some way. It
686 is not run if `gnus-visual' is nil."
687 :group 'gnus-summary-visual
690 (defcustom gnus-parse-headers-hook nil
691 "*A hook called before parsing the headers."
695 (defcustom gnus-exit-group-hook nil
696 "*A hook called when exiting (not quitting) summary mode."
700 (defcustom gnus-summary-update-hook
701 (list 'gnus-summary-highlight-line)
702 "*A hook called when a summary line is changed.
703 The hook will not be called if `gnus-visual' is nil.
705 The default function `gnus-summary-highlight-line' will
706 highlight the line according to the `gnus-summary-highlight'
708 :group 'gnus-summary-visual
711 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
712 "*A hook called when an article is selected for the first time.
713 The hook is intended to mark an article as read (or unread)
714 automatically when it is selected."
715 :group 'gnus-summary-choose
718 (defcustom gnus-group-no-more-groups-hook nil
719 "*A hook run when returning to group mode having no more (unread) groups."
720 :group 'gnus-group-select
723 (defcustom gnus-ps-print-hook nil
724 "*A hook run before ps-printing something from Gnus."
728 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
729 "Face used for highlighting the current article in the summary buffer."
730 :group 'gnus-summary-visual
733 (defcustom gnus-summary-highlight
734 '(((= mark gnus-canceled-mark)
735 . gnus-summary-cancelled-face)
736 ((and (> score default)
737 (or (= mark gnus-dormant-mark)
738 (= mark gnus-ticked-mark)))
739 . gnus-summary-high-ticked-face)
740 ((and (< score default)
741 (or (= mark gnus-dormant-mark)
742 (= mark gnus-ticked-mark)))
743 . gnus-summary-low-ticked-face)
744 ((or (= mark gnus-dormant-mark)
745 (= mark gnus-ticked-mark))
746 . gnus-summary-normal-ticked-face)
747 ((and (> score default) (= mark gnus-ancient-mark))
748 . gnus-summary-high-ancient-face)
749 ((and (< score default) (= mark gnus-ancient-mark))
750 . gnus-summary-low-ancient-face)
751 ((= mark gnus-ancient-mark)
752 . gnus-summary-normal-ancient-face)
753 ((and (> score default) (= mark gnus-unread-mark))
754 . gnus-summary-high-unread-face)
755 ((and (< score default) (= mark gnus-unread-mark))
756 . gnus-summary-low-unread-face)
757 ((= mark gnus-unread-mark)
758 . gnus-summary-normal-unread-face)
759 ((and (> score default) (memq mark (list gnus-downloadable-mark
760 gnus-undownloaded-mark)))
761 . gnus-summary-high-unread-face)
762 ((and (< score default) (memq mark (list gnus-downloadable-mark
763 gnus-undownloaded-mark)))
764 . gnus-summary-low-unread-face)
765 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
766 . gnus-summary-normal-unread-face)
768 . gnus-summary-high-read-face)
770 . gnus-summary-low-read-face)
772 . gnus-summary-normal-read-face))
773 "*Controls the highlighting of summary buffer lines.
775 A list of (FORM . FACE) pairs. When deciding how a a particular
776 summary line should be displayed, each form is evaluated. The content
777 of the face field after the first true form is used. You can change
778 how those summary lines are displayed, by editing the face field.
780 You can use the following variables in the FORM field.
782 score: The articles score
783 default: The default article score.
784 below: The score below which articles are automatically marked as read.
785 mark: The articles mark."
786 :group 'gnus-summary-visual
787 :type '(repeat (cons (sexp :tag "Form" nil)
790 (defcustom gnus-alter-header-function nil
791 "Function called to allow alteration of article header structures.
792 The function is called with one parameter, the article header vector,
793 which it may alter in any way.")
795 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
796 "Variable that says which function should be used to decode a string with encoded words.")
798 (defcustom gnus-extra-headers nil
799 "*Extra headers to parse."
801 :type '(repeat symbol))
803 (defcustom gnus-ignored-from-addresses
804 (and user-mail-address (regexp-quote user-mail-address))
805 "*Regexp of From headers that may be suppressed in favor of To headers."
809 (defcustom gnus-group-charset-alist
810 '(("^hk\\>\\|^tw\\>\\|\\<big5\\>" cn-big5)
811 ("^cn\\>\\|\\<chinese\\>" cn-gb-2312)
812 ("^fj\\>\\|^japan\\>" iso-2022-jp-2)
813 ("^relcom\\>" koi8-r)
815 ("^\\(cz\\|hun\\|pl\\|sk\\|hr\\)\\>" iso-8859-2)
816 ("^israel\\>" iso-8859-1)
818 ("^\\(comp\\|rec\\|alt\\|sci\\|soc\\|news\\|gnu\\|bofh\\)\\>" iso-8859-1)
820 "Alist of regexps (to match group names) and default charsets to be used when reading."
821 :type '(repeat (list (regexp :tag "Group")
822 (symbol :tag "Charset")))
823 :group 'gnus-charset)
825 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
826 "List of charsets that should be ignored.
827 When these charsets are used in the \"charset\" parameter, the
828 default charset will be used instead."
829 :type '(repeat symbol)
830 :group 'gnus-charset)
832 (defcustom gnus-group-ignored-charsets-alist
833 '(("alt\\.chinese\\.text" iso-8859-1))
834 "Alist of regexps (to match group names) and charsets that should be ignored.
835 When these charsets are used in the \"charset\" parameter, the
836 default charset will be used instead."
837 :type '(repeat (cons (regexp :tag "Group")
839 :group 'gnus-charset)
841 (defcustom gnus-group-highlight-words-alist nil
842 "Alist of group regexps and highlight regexps.
843 This variable uses the same syntax as `gnus-emphasis-alist'."
844 :type '(repeat (cons (regexp :tag "Group")
845 (repeat (list (regexp :tag "Highlight regexp")
846 (number :tag "Group for entire word" 0)
847 (number :tag "Group for displayed part" 0)
849 gnus-emphasis-highlight-words)))))
850 :group 'gnus-summary-visual)
852 ;;; Internal variables
854 (defvar gnus-article-mime-handles nil)
855 (defvar gnus-article-decoded-p nil)
856 (defvar gnus-scores-exclude-files nil)
857 (defvar gnus-page-broken nil)
858 (defvar gnus-inhibit-mime-unbuttonizing nil)
860 (defvar gnus-original-article nil)
861 (defvar gnus-article-internal-prepare-hook nil)
862 (defvar gnus-newsgroup-process-stack nil)
864 (defvar gnus-thread-indent-array nil)
865 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
866 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
867 "Function called to sort the articles within a thread after it has
868 been gathered together.")
870 ;; Avoid highlighting in kill files.
871 (defvar gnus-summary-inhibit-highlight nil)
872 (defvar gnus-newsgroup-selected-overlay nil)
873 (defvar gnus-inhibit-limiting nil)
874 (defvar gnus-newsgroup-adaptive-score-file nil)
875 (defvar gnus-current-score-file nil)
876 (defvar gnus-current-move-group nil)
877 (defvar gnus-current-copy-group nil)
878 (defvar gnus-current-crosspost-group nil)
880 (defvar gnus-newsgroup-dependencies nil)
881 (defvar gnus-newsgroup-adaptive nil)
882 (defvar gnus-summary-display-article-function nil)
883 (defvar gnus-summary-highlight-line-function nil
884 "Function called after highlighting a summary line.")
886 (defvar gnus-summary-line-format-alist
887 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
888 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
889 (?s gnus-tmp-subject-or-nil ?s)
890 (?n gnus-tmp-name ?s)
891 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
893 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
895 (?F gnus-tmp-from ?s)
896 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
897 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
898 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
899 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
900 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
901 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
902 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
903 (?L gnus-tmp-lines ?d)
904 (?I gnus-tmp-indentation ?s)
905 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
906 (?R gnus-tmp-replied ?c)
907 (?\[ gnus-tmp-opening-bracket ?c)
908 (?\] gnus-tmp-closing-bracket ?c)
909 (?\> (make-string gnus-tmp-level ? ) ?s)
910 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
911 (?i gnus-tmp-score ?d)
912 (?z gnus-tmp-score-char ?c)
913 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
914 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
915 (?U gnus-tmp-unread ?c)
916 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header) ?s)
917 (?t (gnus-summary-number-of-articles-in-thread
918 (and (boundp 'thread) (car thread)) gnus-tmp-level)
920 (?e (gnus-summary-number-of-articles-in-thread
921 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
923 (?u gnus-tmp-user-defined ?s)
924 (?P (gnus-pick-line-number) ?d))
925 "An alist of format specifications that can appear in summary lines,
926 and what variables they correspond with, along with the type of the
927 variable (string, integer, character, etc).")
929 (defvar gnus-summary-dummy-line-format-alist
930 `((?S gnus-tmp-subject ?s)
931 (?N gnus-tmp-number ?d)
932 (?u gnus-tmp-user-defined ?s)))
934 (defvar gnus-summary-mode-line-format-alist
935 `((?G gnus-tmp-group-name ?s)
936 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
937 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
938 (?A gnus-tmp-article-number ?d)
939 (?Z gnus-tmp-unread-and-unselected ?s)
941 (?U gnus-tmp-unread-and-unticked ?d)
942 (?S gnus-tmp-subject ?s)
943 (?e gnus-tmp-unselected ?d)
944 (?u gnus-tmp-user-defined ?s)
945 (?d (length gnus-newsgroup-dormant) ?d)
946 (?t (length gnus-newsgroup-marked) ?d)
947 (?r (length gnus-newsgroup-reads) ?d)
948 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
949 (?E gnus-newsgroup-expunged-tally ?d)
950 (?s (gnus-current-score-file-nondirectory) ?s)))
952 (defvar gnus-last-search-regexp nil
953 "Default regexp for article search command.")
955 (defvar gnus-last-shell-command nil
956 "Default shell command on article.")
958 (defvar gnus-newsgroup-begin nil)
959 (defvar gnus-newsgroup-end nil)
960 (defvar gnus-newsgroup-last-rmail nil)
961 (defvar gnus-newsgroup-last-mail nil)
962 (defvar gnus-newsgroup-last-folder nil)
963 (defvar gnus-newsgroup-last-file nil)
964 (defvar gnus-newsgroup-auto-expire nil)
965 (defvar gnus-newsgroup-active nil)
967 (defvar gnus-newsgroup-data nil)
968 (defvar gnus-newsgroup-data-reverse nil)
969 (defvar gnus-newsgroup-limit nil)
970 (defvar gnus-newsgroup-limits nil)
972 (defvar gnus-newsgroup-unreads nil
973 "List of unread articles in the current newsgroup.")
975 (defvar gnus-newsgroup-unselected nil
976 "List of unselected unread articles in the current newsgroup.")
978 (defvar gnus-newsgroup-reads nil
979 "Alist of read articles and article marks in the current newsgroup.")
981 (defvar gnus-newsgroup-expunged-tally nil)
983 (defvar gnus-newsgroup-marked nil
984 "List of ticked articles in the current newsgroup (a subset of unread art).")
986 (defvar gnus-newsgroup-killed nil
987 "List of ranges of articles that have been through the scoring process.")
989 (defvar gnus-newsgroup-cached nil
990 "List of articles that come from the article cache.")
992 (defvar gnus-newsgroup-saved nil
993 "List of articles that have been saved.")
995 (defvar gnus-newsgroup-kill-headers nil)
997 (defvar gnus-newsgroup-replied nil
998 "List of articles that have been replied to in the current newsgroup.")
1000 (defvar gnus-newsgroup-expirable nil
1001 "List of articles in the current newsgroup that can be expired.")
1003 (defvar gnus-newsgroup-processable nil
1004 "List of articles in the current newsgroup that can be processed.")
1006 (defvar gnus-newsgroup-downloadable nil
1007 "List of articles in the current newsgroup that can be processed.")
1009 (defvar gnus-newsgroup-undownloaded nil
1010 "List of articles in the current newsgroup that haven't been downloaded..")
1012 (defvar gnus-newsgroup-unsendable nil
1013 "List of articles in the current newsgroup that won't be sent.")
1015 (defvar gnus-newsgroup-bookmarks nil
1016 "List of articles in the current newsgroup that have bookmarks.")
1018 (defvar gnus-newsgroup-dormant nil
1019 "List of dormant articles in the current newsgroup.")
1021 (defvar gnus-newsgroup-scored nil
1022 "List of scored articles in the current newsgroup.")
1024 (defvar gnus-newsgroup-headers nil
1025 "List of article headers in the current newsgroup.")
1027 (defvar gnus-newsgroup-threads nil)
1029 (defvar gnus-newsgroup-prepared nil
1030 "Whether the current group has been prepared properly.")
1032 (defvar gnus-newsgroup-ancient nil
1033 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1035 (defvar gnus-newsgroup-sparse nil)
1037 (defvar gnus-current-article nil)
1038 (defvar gnus-article-current nil)
1039 (defvar gnus-current-headers nil)
1040 (defvar gnus-have-all-headers nil)
1041 (defvar gnus-last-article nil)
1042 (defvar gnus-newsgroup-history nil)
1043 (defvar gnus-newsgroup-charset nil)
1044 (defvar gnus-newsgroup-ephemeral-charset nil)
1045 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1047 (defconst gnus-summary-local-variables
1048 '(gnus-newsgroup-name
1049 gnus-newsgroup-begin gnus-newsgroup-end
1050 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1051 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1052 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1053 gnus-newsgroup-unselected gnus-newsgroup-marked
1054 gnus-newsgroup-reads gnus-newsgroup-saved
1055 gnus-newsgroup-replied gnus-newsgroup-expirable
1056 gnus-newsgroup-processable gnus-newsgroup-killed
1057 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1058 gnus-newsgroup-unsendable
1059 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1060 gnus-newsgroup-headers gnus-newsgroup-threads
1061 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1062 gnus-current-article gnus-current-headers gnus-have-all-headers
1063 gnus-last-article gnus-article-internal-prepare-hook
1064 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1065 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1066 gnus-thread-expunge-below
1067 gnus-score-alist gnus-current-score-file
1068 (gnus-summary-expunge-below . global)
1069 (gnus-summary-mark-below . global)
1070 gnus-newsgroup-active gnus-scores-exclude-files
1071 gnus-newsgroup-history gnus-newsgroup-ancient
1072 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1073 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1074 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1075 (gnus-newsgroup-expunged-tally . 0)
1076 gnus-cache-removable-articles gnus-newsgroup-cached
1077 gnus-newsgroup-data gnus-newsgroup-data-reverse
1078 gnus-newsgroup-limit gnus-newsgroup-limits
1079 gnus-newsgroup-charset)
1080 "Variables that are buffer-local to the summary buffers.")
1082 ;; Byte-compiler warning.
1083 (defvar gnus-article-mode-map)
1087 (defvar gnus-decode-encoded-word-methods
1088 '(mail-decode-encoded-word-string)
1089 "List of methods used to decode encoded words.
1091 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item is
1092 FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1093 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1094 whose names match REGEXP.
1097 ((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1098 mail-decode-encoded-word-string
1099 (\"chinese\" . rfc1843-decode-string))
1102 (defvar gnus-decode-encoded-word-methods-cache nil)
1104 (defun gnus-multi-decode-encoded-word-string (string)
1105 "Apply the functions from `gnus-encoded-word-methods' that match."
1106 (unless (and gnus-decode-encoded-word-methods-cache
1107 (eq gnus-newsgroup-name
1108 (car gnus-decode-encoded-word-methods-cache)))
1109 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1112 (nconc gnus-decode-encoded-word-methods-cache (list x))
1113 (if (and gnus-newsgroup-name
1114 (string-match (car x) gnus-newsgroup-name))
1115 (nconc gnus-decode-encoded-word-methods-cache
1117 gnus-decode-encoded-word-methods))
1118 (let ((xlist gnus-decode-encoded-word-methods-cache))
1121 (setq string (funcall (pop xlist) string))))
1124 ;; Subject simplification.
1126 (defun gnus-simplify-whitespace (str)
1127 "Remove excessive whitespace."
1130 (while (string-match "[ \t][ \t]+" mystr)
1131 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1133 (substring mystr (match-end 0)))))
1135 (when (string-match "^[ \t]+" mystr)
1136 (setq mystr (substring mystr (match-end 0))))
1138 (when (string-match "[ \t]+$" mystr)
1139 (setq mystr (substring mystr 0 (match-beginning 0))))
1142 (defsubst gnus-simplify-subject-re (subject)
1143 "Remove \"Re:\" from subject lines."
1144 (if (string-match "^[Rr][Ee]: *" subject)
1145 (substring subject (match-end 0))
1148 (defun gnus-simplify-subject (subject &optional re-only)
1149 "Remove `Re:' and words in parentheses.
1150 If RE-ONLY is non-nil, strip leading `Re:'s only."
1151 (let ((case-fold-search t)) ;Ignore case.
1152 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1153 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1154 (setq subject (substring subject (match-end 0))))
1155 ;; Remove uninteresting prefixes.
1156 (when (and (not re-only)
1157 gnus-simplify-ignored-prefixes
1158 (string-match gnus-simplify-ignored-prefixes subject))
1159 (setq subject (substring subject (match-end 0))))
1160 ;; Remove words in parentheses from end.
1162 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1163 (setq subject (substring subject 0 (match-beginning 0)))))
1164 ;; Return subject string.
1167 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1169 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1170 (goto-char (point-min))
1171 (while (re-search-forward regexp nil t)
1172 (replace-match (or newtext ""))))
1174 (defun gnus-simplify-buffer-fuzzy ()
1175 "Simplify string in the buffer fuzzily.
1176 The string in the accessible portion of the current buffer is simplified.
1177 It is assumed to be a single-line subject.
1178 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1179 matter is removed. Additional things can be deleted by setting
1180 gnus-simplify-subject-fuzzy-regexp."
1181 (let ((case-fold-search t)
1183 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1185 (while (not (eq modified-tick (buffer-modified-tick)))
1186 (setq modified-tick (buffer-modified-tick))
1188 ((listp gnus-simplify-subject-fuzzy-regexp)
1189 (mapcar 'gnus-simplify-buffer-fuzzy-step
1190 gnus-simplify-subject-fuzzy-regexp))
1191 (gnus-simplify-subject-fuzzy-regexp
1192 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1193 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1194 (gnus-simplify-buffer-fuzzy-step
1195 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1196 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1198 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1199 (gnus-simplify-buffer-fuzzy-step " +" " ")
1200 (gnus-simplify-buffer-fuzzy-step " $")
1201 (gnus-simplify-buffer-fuzzy-step "^ +")))
1203 (defun gnus-simplify-subject-fuzzy (subject)
1204 "Simplify a subject string fuzzily.
1205 See `gnus-simplify-buffer-fuzzy' for details."
1207 (gnus-set-work-buffer)
1208 (let ((case-fold-search t))
1209 ;; Remove uninteresting prefixes.
1210 (when (and gnus-simplify-ignored-prefixes
1211 (string-match gnus-simplify-ignored-prefixes subject))
1212 (setq subject (substring subject (match-end 0))))
1214 (inline (gnus-simplify-buffer-fuzzy))
1217 (defsubst gnus-simplify-subject-fully (subject)
1218 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1220 (gnus-simplify-subject-functions
1221 (gnus-map-function gnus-simplify-subject-functions subject))
1222 ((null gnus-summary-gather-subject-limit)
1223 (gnus-simplify-subject-re subject))
1224 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1225 (gnus-simplify-subject-fuzzy subject))
1226 ((numberp gnus-summary-gather-subject-limit)
1227 (gnus-limit-string (gnus-simplify-subject-re subject)
1228 gnus-summary-gather-subject-limit))
1232 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1233 "Check whether two subjects are equal.
1234 If optional argument simple-first is t, first argument is already
1237 ((null simple-first)
1238 (equal (gnus-simplify-subject-fully s1)
1239 (gnus-simplify-subject-fully s2)))
1242 (gnus-simplify-subject-fully s2)))))
1244 (defun gnus-summary-bubble-group ()
1245 "Increase the score of the current group.
1246 This is a handy function to add to `gnus-summary-exit-hook' to
1247 increase the score of each group you read."
1248 (gnus-group-add-score gnus-newsgroup-name))
1252 ;;; Gnus summary mode
1255 (put 'gnus-summary-mode 'mode-class 'special)
1258 ;; Non-orthogonal keys
1260 (gnus-define-keys gnus-summary-mode-map
1261 " " gnus-summary-next-page
1262 "\177" gnus-summary-prev-page
1263 [delete] gnus-summary-prev-page
1264 [backspace] gnus-summary-prev-page
1265 "\r" gnus-summary-scroll-up
1266 "\M-\r" gnus-summary-scroll-down
1267 "n" gnus-summary-next-unread-article
1268 "p" gnus-summary-prev-unread-article
1269 "N" gnus-summary-next-article
1270 "P" gnus-summary-prev-article
1271 "\M-\C-n" gnus-summary-next-same-subject
1272 "\M-\C-p" gnus-summary-prev-same-subject
1273 "\M-n" gnus-summary-next-unread-subject
1274 "\M-p" gnus-summary-prev-unread-subject
1275 "." gnus-summary-first-unread-article
1276 "," gnus-summary-best-unread-article
1277 "\M-s" gnus-summary-search-article-forward
1278 "\M-r" gnus-summary-search-article-backward
1279 "<" gnus-summary-beginning-of-article
1280 ">" gnus-summary-end-of-article
1281 "j" gnus-summary-goto-article
1282 "^" gnus-summary-refer-parent-article
1283 "\M-^" gnus-summary-refer-article
1284 "u" gnus-summary-tick-article-forward
1285 "!" gnus-summary-tick-article-forward
1286 "U" gnus-summary-tick-article-backward
1287 "d" gnus-summary-mark-as-read-forward
1288 "D" gnus-summary-mark-as-read-backward
1289 "E" gnus-summary-mark-as-expirable
1290 "\M-u" gnus-summary-clear-mark-forward
1291 "\M-U" gnus-summary-clear-mark-backward
1292 "k" gnus-summary-kill-same-subject-and-select
1293 "\C-k" gnus-summary-kill-same-subject
1294 "\M-\C-k" gnus-summary-kill-thread
1295 "\M-\C-l" gnus-summary-lower-thread
1296 "e" gnus-summary-edit-article
1297 "#" gnus-summary-mark-as-processable
1298 "\M-#" gnus-summary-unmark-as-processable
1299 "\M-\C-t" gnus-summary-toggle-threads
1300 "\M-\C-s" gnus-summary-show-thread
1301 "\M-\C-h" gnus-summary-hide-thread
1302 "\M-\C-f" gnus-summary-next-thread
1303 "\M-\C-b" gnus-summary-prev-thread
1304 "\M-\C-u" gnus-summary-up-thread
1305 "\M-\C-d" gnus-summary-down-thread
1306 "&" gnus-summary-execute-command
1307 "c" gnus-summary-catchup-and-exit
1308 "\C-w" gnus-summary-mark-region-as-read
1309 "\C-t" gnus-summary-toggle-truncation
1310 "?" gnus-summary-mark-as-dormant
1311 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1312 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1313 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1314 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1315 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1316 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1317 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1318 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1319 "=" gnus-summary-expand-window
1320 "\C-x\C-s" gnus-summary-reselect-current-group
1321 "\M-g" gnus-summary-rescan-group
1322 "w" gnus-summary-stop-page-breaking
1323 "\C-c\C-r" gnus-summary-caesar-message
1324 "f" gnus-summary-followup
1325 "F" gnus-summary-followup-with-original
1326 "C" gnus-summary-cancel-article
1327 "r" gnus-summary-reply
1328 "R" gnus-summary-reply-with-original
1329 "\C-c\C-f" gnus-summary-mail-forward
1330 "o" gnus-summary-save-article
1331 "\C-o" gnus-summary-save-article-mail
1332 "|" gnus-summary-pipe-output
1333 "\M-k" gnus-summary-edit-local-kill
1334 "\M-K" gnus-summary-edit-global-kill
1336 "\C-c\C-d" gnus-summary-describe-group
1337 "q" gnus-summary-exit
1338 "Q" gnus-summary-exit-no-update
1339 "\C-c\C-i" gnus-info-find-node
1340 gnus-mouse-2 gnus-mouse-pick-article
1341 "m" gnus-summary-mail-other-window
1342 "a" gnus-summary-post-news
1343 "x" gnus-summary-limit-to-unread
1344 "s" gnus-summary-isearch-article
1345 "t" gnus-summary-toggle-header
1346 "g" gnus-summary-show-article
1347 "l" gnus-summary-goto-last-article
1348 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1349 "\C-d" gnus-summary-enter-digest-group
1350 "\M-\C-d" gnus-summary-read-document
1351 "\M-\C-e" gnus-summary-edit-parameters
1352 "\M-\C-g" gnus-summary-customize-parameters
1354 "*" gnus-cache-enter-article
1355 "\M-*" gnus-cache-remove-article
1356 "\M-&" gnus-summary-universal-argument
1357 "\C-l" gnus-recenter
1358 "I" gnus-summary-increase-score
1359 "L" gnus-summary-lower-score
1360 "\M-i" gnus-symbolic-argument
1361 "h" gnus-summary-select-article-buffer
1363 "b" gnus-article-view-part
1364 "\M-t" gnus-summary-toggle-display-buttonized
1366 "V" gnus-summary-score-map
1367 "X" gnus-uu-extract-map
1368 "S" gnus-summary-send-map)
1370 ;; Sort of orthogonal keymap
1371 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1372 "t" gnus-summary-tick-article-forward
1373 "!" gnus-summary-tick-article-forward
1374 "d" gnus-summary-mark-as-read-forward
1375 "r" gnus-summary-mark-as-read-forward
1376 "c" gnus-summary-clear-mark-forward
1377 " " gnus-summary-clear-mark-forward
1378 "e" gnus-summary-mark-as-expirable
1379 "x" gnus-summary-mark-as-expirable
1380 "?" gnus-summary-mark-as-dormant
1381 "b" gnus-summary-set-bookmark
1382 "B" gnus-summary-remove-bookmark
1383 "#" gnus-summary-mark-as-processable
1384 "\M-#" gnus-summary-unmark-as-processable
1385 "S" gnus-summary-limit-include-expunged
1386 "C" gnus-summary-catchup
1387 "H" gnus-summary-catchup-to-here
1388 "\C-c" gnus-summary-catchup-all
1389 "k" gnus-summary-kill-same-subject-and-select
1390 "K" gnus-summary-kill-same-subject
1391 "P" gnus-uu-mark-map)
1393 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1394 "c" gnus-summary-clear-above
1395 "u" gnus-summary-tick-above
1396 "m" gnus-summary-mark-above
1397 "k" gnus-summary-kill-below)
1399 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1400 "/" gnus-summary-limit-to-subject
1401 "n" gnus-summary-limit-to-articles
1402 "w" gnus-summary-pop-limit
1403 "s" gnus-summary-limit-to-subject
1404 "a" gnus-summary-limit-to-author
1405 "u" gnus-summary-limit-to-unread
1406 "m" gnus-summary-limit-to-marks
1407 "M" gnus-summary-limit-exclude-marks
1408 "v" gnus-summary-limit-to-score
1409 "*" gnus-summary-limit-include-cached
1410 "D" gnus-summary-limit-include-dormant
1411 "T" gnus-summary-limit-include-thread
1412 "d" gnus-summary-limit-exclude-dormant
1413 "t" gnus-summary-limit-to-age
1414 "x" gnus-summary-limit-to-extra
1415 "E" gnus-summary-limit-include-expunged
1416 "c" gnus-summary-limit-exclude-childless-dormant
1417 "C" gnus-summary-limit-mark-excluded-as-read)
1419 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1420 "n" gnus-summary-next-unread-article
1421 "p" gnus-summary-prev-unread-article
1422 "N" gnus-summary-next-article
1423 "P" gnus-summary-prev-article
1424 "\C-n" gnus-summary-next-same-subject
1425 "\C-p" gnus-summary-prev-same-subject
1426 "\M-n" gnus-summary-next-unread-subject
1427 "\M-p" gnus-summary-prev-unread-subject
1428 "f" gnus-summary-first-unread-article
1429 "b" gnus-summary-best-unread-article
1430 "j" gnus-summary-goto-article
1431 "g" gnus-summary-goto-subject
1432 "l" gnus-summary-goto-last-article
1433 "o" gnus-summary-pop-article)
1435 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1436 "k" gnus-summary-kill-thread
1437 "l" gnus-summary-lower-thread
1438 "i" gnus-summary-raise-thread
1439 "T" gnus-summary-toggle-threads
1440 "t" gnus-summary-rethread-current
1441 "^" gnus-summary-reparent-thread
1442 "s" gnus-summary-show-thread
1443 "S" gnus-summary-show-all-threads
1444 "h" gnus-summary-hide-thread
1445 "H" gnus-summary-hide-all-threads
1446 "n" gnus-summary-next-thread
1447 "p" gnus-summary-prev-thread
1448 "u" gnus-summary-up-thread
1449 "o" gnus-summary-top-thread
1450 "d" gnus-summary-down-thread
1451 "#" gnus-uu-mark-thread
1452 "\M-#" gnus-uu-unmark-thread)
1454 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1455 "g" gnus-summary-prepare
1456 "c" gnus-summary-insert-cached-articles)
1458 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1459 "c" gnus-summary-catchup-and-exit
1460 "C" gnus-summary-catchup-all-and-exit
1461 "E" gnus-summary-exit-no-update
1462 "Q" gnus-summary-exit
1463 "Z" gnus-summary-exit
1464 "n" gnus-summary-catchup-and-goto-next-group
1465 "R" gnus-summary-reselect-current-group
1466 "G" gnus-summary-rescan-group
1467 "N" gnus-summary-next-group
1468 "s" gnus-summary-save-newsrc
1469 "P" gnus-summary-prev-group)
1471 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1472 " " gnus-summary-next-page
1473 "n" gnus-summary-next-page
1474 "\177" gnus-summary-prev-page
1475 [delete] gnus-summary-prev-page
1476 "p" gnus-summary-prev-page
1477 "\r" gnus-summary-scroll-up
1478 "\M-\r" gnus-summary-scroll-down
1479 "<" gnus-summary-beginning-of-article
1480 ">" gnus-summary-end-of-article
1481 "b" gnus-summary-beginning-of-article
1482 "e" gnus-summary-end-of-article
1483 "^" gnus-summary-refer-parent-article
1484 "r" gnus-summary-refer-parent-article
1485 "D" gnus-summary-enter-digest-group
1486 "R" gnus-summary-refer-references
1487 "T" gnus-summary-refer-thread
1488 "g" gnus-summary-show-article
1489 "s" gnus-summary-isearch-article
1490 "P" gnus-summary-print-article
1491 "t" gnus-article-babel)
1493 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1494 "b" gnus-article-add-buttons
1495 "B" gnus-article-add-buttons-to-head
1496 "o" gnus-article-treat-overstrike
1497 "e" gnus-article-emphasize
1498 "w" gnus-article-fill-cited-article
1499 "Q" gnus-article-fill-long-lines
1500 "C" gnus-article-capitalize-sentences
1501 "c" gnus-article-remove-cr
1502 "q" gnus-article-de-quoted-unreadable
1503 "f" gnus-article-display-x-face
1504 "l" gnus-summary-stop-page-breaking
1505 "r" gnus-summary-caesar-message
1506 "t" gnus-article-hide-headers
1507 "v" gnus-summary-verbose-headers
1508 "H" gnus-article-strip-headers-in-body
1509 "d" gnus-article-treat-dumbquotes)
1511 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1512 "a" gnus-article-hide
1513 "h" gnus-article-hide-headers
1514 "b" gnus-article-hide-boring-headers
1515 "s" gnus-article-hide-signature
1516 "c" gnus-article-hide-citation
1517 "C" gnus-article-hide-citation-in-followups
1518 "l" gnus-article-hide-list-identifiers
1519 "p" gnus-article-hide-pgp
1520 "B" gnus-article-strip-banner
1521 "P" gnus-article-hide-pem
1522 "\C-c" gnus-article-hide-citation-maybe)
1524 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1525 "a" gnus-article-highlight
1526 "h" gnus-article-highlight-headers
1527 "c" gnus-article-highlight-citation
1528 "s" gnus-article-highlight-signature)
1530 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1531 "w" gnus-article-decode-mime-words
1532 "c" gnus-article-decode-charset
1533 "v" gnus-mime-view-all-parts
1534 "b" gnus-article-view-part)
1536 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1537 "z" gnus-article-date-ut
1538 "u" gnus-article-date-ut
1539 "l" gnus-article-date-local
1540 "e" gnus-article-date-lapsed
1541 "o" gnus-article-date-original
1542 "i" gnus-article-date-iso8601
1543 "s" gnus-article-date-user)
1545 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1546 "t" gnus-article-remove-trailing-blank-lines
1547 "l" gnus-article-strip-leading-blank-lines
1548 "m" gnus-article-strip-multiple-blank-lines
1549 "a" gnus-article-strip-blank-lines
1550 "A" gnus-article-strip-all-blank-lines
1551 "s" gnus-article-strip-leading-space
1552 "e" gnus-article-strip-trailing-space)
1554 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1556 "f" gnus-summary-fetch-faq
1557 "d" gnus-summary-describe-group
1558 "h" gnus-summary-describe-briefly
1559 "i" gnus-info-find-node)
1561 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1562 "e" gnus-summary-expire-articles
1563 "\M-\C-e" gnus-summary-expire-articles-now
1564 "\177" gnus-summary-delete-article
1565 [delete] gnus-summary-delete-article
1566 [backspace] gnus-summary-delete-article
1567 "m" gnus-summary-move-article
1568 "r" gnus-summary-respool-article
1569 "w" gnus-summary-edit-article
1570 "c" gnus-summary-copy-article
1571 "B" gnus-summary-crosspost-article
1572 "q" gnus-summary-respool-query
1573 "t" gnus-summary-respool-trace
1574 "i" gnus-summary-import-article
1575 "p" gnus-summary-article-posted-p)
1577 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1578 "o" gnus-summary-save-article
1579 "m" gnus-summary-save-article-mail
1580 "F" gnus-summary-write-article-file
1581 "r" gnus-summary-save-article-rmail
1582 "f" gnus-summary-save-article-file
1583 "b" gnus-summary-save-article-body-file
1584 "h" gnus-summary-save-article-folder
1585 "v" gnus-summary-save-article-vm
1586 "p" gnus-summary-pipe-output
1587 "s" gnus-soup-add-article)
1589 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1590 "b" gnus-summary-display-buttonized
1591 "m" gnus-summary-repair-multipart
1592 "v" gnus-article-view-part
1593 "o" gnus-article-save-part
1594 "c" gnus-article-copy-part
1595 "e" gnus-article-externalize-part
1596 "i" gnus-article-inline-part
1597 "|" gnus-article-pipe-part)
1600 (defun gnus-summary-make-menu-bar ()
1601 (gnus-turn-off-edit-menu 'summary)
1603 (unless (boundp 'gnus-summary-misc-menu)
1606 gnus-summary-kill-menu gnus-summary-mode-map ""
1611 ["Enter score..." gnus-summary-score-entry t]
1612 ["Customize" gnus-score-customize t])
1613 (gnus-make-score-map 'increase)
1614 (gnus-make-score-map 'lower)
1616 ["Kill below" gnus-summary-kill-below t]
1617 ["Mark above" gnus-summary-mark-above t]
1618 ["Tick above" gnus-summary-tick-above t]
1619 ["Clear above" gnus-summary-clear-above t])
1620 ["Current score" gnus-summary-current-score t]
1621 ["Set score" gnus-summary-set-score t]
1622 ["Switch current score file..." gnus-score-change-score-file t]
1623 ["Set mark below..." gnus-score-set-mark-below t]
1624 ["Set expunge below..." gnus-score-set-expunge-below t]
1625 ["Edit current score file" gnus-score-edit-current-scores t]
1626 ["Edit score file" gnus-score-edit-file t]
1627 ["Trace score" gnus-score-find-trace t]
1628 ["Find words" gnus-score-find-favourite-words t]
1629 ["Rescore buffer" gnus-summary-rescore t]
1630 ["Increase score..." gnus-summary-increase-score t]
1631 ["Lower score..." gnus-summary-lower-score t]))))
1633 ;; Define both the Article menu in the summary buffer and the equivalent
1634 ;; Commands menu in the article buffer here for consistency.
1637 ["All" gnus-article-hide t]
1638 ["Headers" gnus-article-hide-headers t]
1639 ["Signature" gnus-article-hide-signature t]
1640 ["Citation" gnus-article-hide-citation t]
1641 ["List identifiers" gnus-article-hide-list-identifiers t]
1642 ["PGP" gnus-article-hide-pgp t]
1643 ["Banner" gnus-article-strip-banner t]
1644 ["Boring headers" gnus-article-hide-boring-headers t])
1646 ["All" gnus-article-highlight t]
1647 ["Headers" gnus-article-highlight-headers t]
1648 ["Signature" gnus-article-highlight-signature t]
1649 ["Citation" gnus-article-highlight-citation t])
1651 ["Words" gnus-article-decode-mime-words t]
1652 ["Charset" gnus-article-decode-charset t]
1653 ["QP" gnus-article-de-quoted-unreadable t]
1654 ["View all" gnus-mime-view-all-parts t])
1656 ["Local" gnus-article-date-local t]
1657 ["ISO8601" gnus-article-date-iso8601 t]
1658 ["UT" gnus-article-date-ut t]
1659 ["Original" gnus-article-date-original t]
1660 ["Lapsed" gnus-article-date-lapsed t]
1661 ["User-defined" gnus-article-date-user t])
1664 ["Leading" gnus-article-strip-leading-blank-lines t]
1665 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1666 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1667 ["All of the above" gnus-article-strip-blank-lines t]
1668 ["All" gnus-article-strip-all-blank-lines t]
1669 ["Leading space" gnus-article-strip-leading-space t]
1670 ["Trailing space" gnus-article-strip-trailing-space t])
1671 ["Overstrike" gnus-article-treat-overstrike t]
1672 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1673 ["Emphasis" gnus-article-emphasize t]
1674 ["Word wrap" gnus-article-fill-cited-article t]
1675 ["Fill long lines" gnus-article-fill-long-lines t]
1676 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1677 ["CR" gnus-article-remove-cr t]
1678 ["Show X-Face" gnus-article-display-x-face t]
1679 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1680 ["Rot 13" gnus-summary-caesar-message t]
1681 ["Unix pipe" gnus-summary-pipe-message t]
1682 ["Add buttons" gnus-article-add-buttons t]
1683 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1684 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1685 ["Verbose header" gnus-summary-verbose-headers t]
1686 ["Toggle header" gnus-summary-toggle-header t])
1688 ["Save in default format" gnus-summary-save-article t]
1689 ["Save in file" gnus-summary-save-article-file t]
1690 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1691 ["Save in MH folder" gnus-summary-save-article-folder t]
1692 ["Save in VM folder" gnus-summary-save-article-vm t]
1693 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1694 ["Save body in file" gnus-summary-save-article-body-file t]
1695 ["Pipe through a filter" gnus-summary-pipe-output t]
1696 ["Add to SOUP packet" gnus-soup-add-article t]
1697 ["Print" gnus-summary-print-article t])
1699 ["Respool article..." gnus-summary-respool-article t]
1700 ["Move article..." gnus-summary-move-article
1701 (gnus-check-backend-function
1702 'request-move-article gnus-newsgroup-name)]
1703 ["Copy article..." gnus-summary-copy-article t]
1704 ["Crosspost article..." gnus-summary-crosspost-article
1705 (gnus-check-backend-function
1706 'request-replace-article gnus-newsgroup-name)]
1707 ["Import file..." gnus-summary-import-article t]
1708 ["Check if posted" gnus-summary-article-posted-p t]
1709 ["Edit article" gnus-summary-edit-article
1710 (not (gnus-group-read-only-p))]
1711 ["Delete article" gnus-summary-delete-article
1712 (gnus-check-backend-function
1713 'request-expire-articles gnus-newsgroup-name)]
1714 ["Query respool" gnus-summary-respool-query t]
1715 ["Trace respool" gnus-summary-respool-trace t]
1716 ["Delete expirable articles" gnus-summary-expire-articles-now
1717 (gnus-check-backend-function
1718 'request-expire-articles gnus-newsgroup-name)])
1720 ["Uudecode" gnus-uu-decode-uu t]
1721 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1722 ["Unshar" gnus-uu-decode-unshar t]
1723 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1724 ["Save" gnus-uu-decode-save t]
1725 ["Binhex" gnus-uu-decode-binhex t]
1726 ["Postscript" gnus-uu-decode-postscript t])
1728 ["Enter article" gnus-cache-enter-article t]
1729 ["Remove article" gnus-cache-remove-article t])
1730 ["Translate" gnus-article-babel t]
1731 ["Select article buffer" gnus-summary-select-article-buffer t]
1732 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1733 ["Isearch article..." gnus-summary-isearch-article t]
1734 ["Beginning of the article" gnus-summary-beginning-of-article t]
1735 ["End of the article" gnus-summary-end-of-article t]
1736 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1737 ["Fetch referenced articles" gnus-summary-refer-references t]
1738 ["Fetch current thread" gnus-summary-refer-thread t]
1739 ["Fetch article with id..." gnus-summary-refer-article t]
1740 ["Redisplay" gnus-summary-show-article t])))
1742 gnus-summary-article-menu gnus-summary-mode-map ""
1743 (cons "Article" innards))
1746 gnus-article-commands-menu gnus-article-mode-map ""
1747 (cons "Commands" innards)))
1750 gnus-summary-thread-menu gnus-summary-mode-map ""
1752 ["Toggle threading" gnus-summary-toggle-threads t]
1753 ["Hide threads" gnus-summary-hide-all-threads t]
1754 ["Show threads" gnus-summary-show-all-threads t]
1755 ["Hide thread" gnus-summary-hide-thread t]
1756 ["Show thread" gnus-summary-show-thread t]
1757 ["Go to next thread" gnus-summary-next-thread t]
1758 ["Go to previous thread" gnus-summary-prev-thread t]
1759 ["Go down thread" gnus-summary-down-thread t]
1760 ["Go up thread" gnus-summary-up-thread t]
1761 ["Top of thread" gnus-summary-top-thread t]
1762 ["Mark thread as read" gnus-summary-kill-thread t]
1763 ["Lower thread score" gnus-summary-lower-thread t]
1764 ["Raise thread score" gnus-summary-raise-thread t]
1765 ["Rethread current" gnus-summary-rethread-current t]
1769 gnus-summary-post-menu gnus-summary-mode-map ""
1771 ["Post an article" gnus-summary-post-news t]
1772 ["Followup" gnus-summary-followup t]
1773 ["Followup and yank" gnus-summary-followup-with-original t]
1774 ["Supersede article" gnus-summary-supersede-article t]
1775 ["Cancel article" gnus-summary-cancel-article t]
1776 ["Reply" gnus-summary-reply t]
1777 ["Reply and yank" gnus-summary-reply-with-original t]
1778 ["Wide reply" gnus-summary-wide-reply t]
1779 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1780 ["Mail forward" gnus-summary-mail-forward t]
1781 ["Post forward" gnus-summary-post-forward t]
1782 ["Digest and mail" gnus-uu-digest-mail-forward t]
1783 ["Digest and post" gnus-uu-digest-post-forward t]
1784 ["Resend message" gnus-summary-resend-message t]
1785 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1786 ["Send a mail" gnus-summary-mail-other-window t]
1787 ["Uuencode and post" gnus-uu-post-news t]
1788 ["Followup via news" gnus-summary-followup-to-mail t]
1789 ["Followup via news and yank"
1790 gnus-summary-followup-to-mail-with-original t]
1792 ;;["Send" gnus-summary-send-draft t]
1793 ;;["Send bounced" gnus-resend-bounced-mail t])
1797 gnus-summary-misc-menu gnus-summary-mode-map ""
1800 ["Mark as read" gnus-summary-mark-as-read-forward t]
1801 ["Mark same subject and select"
1802 gnus-summary-kill-same-subject-and-select t]
1803 ["Mark same subject" gnus-summary-kill-same-subject t]
1804 ["Catchup" gnus-summary-catchup t]
1805 ["Catchup all" gnus-summary-catchup-all t]
1806 ["Catchup to here" gnus-summary-catchup-to-here t]
1807 ["Catchup region" gnus-summary-mark-region-as-read t]
1808 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1810 ["Tick" gnus-summary-tick-article-forward t]
1811 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1812 ["Remove marks" gnus-summary-clear-mark-forward t]
1813 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1814 ["Set bookmark" gnus-summary-set-bookmark t]
1815 ["Remove bookmark" gnus-summary-remove-bookmark t])
1817 ["Marks..." gnus-summary-limit-to-marks t]
1818 ["Subject..." gnus-summary-limit-to-subject t]
1819 ["Author..." gnus-summary-limit-to-author t]
1820 ["Age..." gnus-summary-limit-to-age t]
1821 ["Extra..." gnus-summary-limit-to-extra t]
1822 ["Score" gnus-summary-limit-to-score t]
1823 ["Unread" gnus-summary-limit-to-unread t]
1824 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1825 ["Articles" gnus-summary-limit-to-articles t]
1826 ["Pop limit" gnus-summary-pop-limit t]
1827 ["Show dormant" gnus-summary-limit-include-dormant t]
1828 ["Hide childless dormant"
1829 gnus-summary-limit-exclude-childless-dormant t]
1830 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1831 ["Hide marked" gnus-summary-limit-exclude-marks t]
1832 ["Show expunged" gnus-summary-show-all-expunged t])
1834 ["Set mark" gnus-summary-mark-as-processable t]
1835 ["Remove mark" gnus-summary-unmark-as-processable t]
1836 ["Remove all marks" gnus-summary-unmark-all-processable t]
1837 ["Mark above" gnus-uu-mark-over t]
1838 ["Mark series" gnus-uu-mark-series t]
1839 ["Mark region" gnus-uu-mark-region t]
1840 ["Unmark region" gnus-uu-unmark-region t]
1841 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1842 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1843 ["Mark all" gnus-uu-mark-all t]
1844 ["Mark buffer" gnus-uu-mark-buffer t]
1845 ["Mark sparse" gnus-uu-mark-sparse t]
1846 ["Mark thread" gnus-uu-mark-thread t]
1847 ["Unmark thread" gnus-uu-unmark-thread t]
1848 ("Process Mark Sets"
1849 ["Kill" gnus-summary-kill-process-mark t]
1850 ["Yank" gnus-summary-yank-process-mark
1851 gnus-newsgroup-process-stack]
1852 ["Save" gnus-summary-save-process-mark t]))
1854 ["Page forward" gnus-summary-next-page t]
1855 ["Page backward" gnus-summary-prev-page t]
1856 ["Line forward" gnus-summary-scroll-up t])
1858 ["Next unread article" gnus-summary-next-unread-article t]
1859 ["Previous unread article" gnus-summary-prev-unread-article t]
1860 ["Next article" gnus-summary-next-article t]
1861 ["Previous article" gnus-summary-prev-article t]
1862 ["Next unread subject" gnus-summary-next-unread-subject t]
1863 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1864 ["Next article same subject" gnus-summary-next-same-subject t]
1865 ["Previous article same subject" gnus-summary-prev-same-subject t]
1866 ["First unread article" gnus-summary-first-unread-article t]
1867 ["Best unread article" gnus-summary-best-unread-article t]
1868 ["Go to subject number..." gnus-summary-goto-subject t]
1869 ["Go to article number..." gnus-summary-goto-article t]
1870 ["Go to the last article" gnus-summary-goto-last-article t]
1871 ["Pop article off history" gnus-summary-pop-article t])
1873 ["Sort by number" gnus-summary-sort-by-number t]
1874 ["Sort by author" gnus-summary-sort-by-author t]
1875 ["Sort by subject" gnus-summary-sort-by-subject t]
1876 ["Sort by date" gnus-summary-sort-by-date t]
1877 ["Sort by score" gnus-summary-sort-by-score t]
1878 ["Sort by lines" gnus-summary-sort-by-lines t]
1879 ["Sort by characters" gnus-summary-sort-by-chars t])
1881 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1882 ["Describe group" gnus-summary-describe-group t]
1883 ["Read manual" gnus-info-find-node t])
1885 ["Pick and read" gnus-pick-mode t]
1886 ["Binary" gnus-binary-mode t])
1888 ["Regenerate" gnus-summary-prepare t]
1889 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1890 ["Toggle threading" gnus-summary-toggle-threads t])
1891 ["Filter articles..." gnus-summary-execute-command t]
1892 ["Run command on subjects..." gnus-summary-universal-argument t]
1893 ["Search articles forward..." gnus-summary-search-article-forward t]
1894 ["Search articles backward..." gnus-summary-search-article-backward t]
1895 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1896 ["Expand window" gnus-summary-expand-window t]
1897 ["Expire expirable articles" gnus-summary-expire-articles
1898 (gnus-check-backend-function
1899 'request-expire-articles gnus-newsgroup-name)]
1900 ["Edit local kill file" gnus-summary-edit-local-kill t]
1901 ["Edit main kill file" gnus-summary-edit-global-kill t]
1902 ["Edit group parameters" gnus-summary-edit-parameters t]
1903 ["Customize group parameters" gnus-summary-customize-parameters t]
1904 ["Send a bug report" gnus-bug t]
1906 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1907 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
1908 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1909 ["Exit group" gnus-summary-exit t]
1910 ["Exit group without updating" gnus-summary-exit-no-update t]
1911 ["Exit and goto next group" gnus-summary-next-group t]
1912 ["Exit and goto prev group" gnus-summary-prev-group t]
1913 ["Reselect group" gnus-summary-reselect-current-group t]
1914 ["Rescan group" gnus-summary-rescan-group t]
1915 ["Update dribble" gnus-summary-save-newsrc t])))
1917 (gnus-run-hooks 'gnus-summary-menu-hook)))
1919 (defun gnus-score-set-default (var value)
1920 "A version of set that updates the GNU Emacs menu-bar."
1922 ;; It is the message that forces the active status to be updated.
1925 (defun gnus-make-score-map (type)
1926 "Make a summary score map of type TYPE."
1929 (let ((headers '(("author" "from" string)
1930 ("subject" "subject" string)
1931 ("article body" "body" string)
1932 ("article head" "head" string)
1933 ("xref" "xref" string)
1934 ("extra header" "extra" string)
1935 ("lines" "lines" number)
1936 ("followups to author" "followup" string)))
1937 (types '((number ("less than" <)
1940 (string ("substring" s)
1944 (perms '(("temporary" (current-time-string))
1952 (if (eq type 'lower)
1957 (setq header (car headers))
1963 (let ((ts (cdr (assoc (nth 2 header) types)))
1979 'gnus-summary-score-entry
1981 (if (or (string= (nth 1 header)
1983 (string= (nth 1 header)
1986 (list 'gnus-summary-header
1988 (list 'quote (nth 1 (car ts)))
1989 (list 'gnus-score-default nil)
1995 (list (nreverse outp))))
1998 (list (nreverse outt))))
2000 (setq headers (cdr headers)))
2001 (list (nreverse outh))))))))
2005 (defun gnus-summary-mode (&optional group)
2006 "Major mode for reading articles.
2008 All normal editing commands are switched off.
2009 \\<gnus-summary-mode-map>
2010 Each line in this buffer represents one article. To read an
2011 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2012 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2015 You can also post articles and send mail from this buffer. To
2016 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2017 of an article, type `\\[gnus-summary-reply]'.
2019 There are approx. one gazillion commands you can execute in this
2020 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2022 The following commands are available:
2024 \\{gnus-summary-mode-map}"
2026 (when (gnus-visual-p 'summary-menu 'menu)
2027 (gnus-summary-make-menu-bar))
2028 (kill-all-local-variables)
2029 (gnus-summary-make-local-variables)
2030 (gnus-make-thread-indent-array)
2031 (gnus-simplify-mode-line)
2032 (setq major-mode 'gnus-summary-mode)
2033 (setq mode-name "Summary")
2034 (make-local-variable 'minor-mode-alist)
2035 (use-local-map gnus-summary-mode-map)
2036 (buffer-disable-undo)
2037 (setq buffer-read-only t) ;Disable modification
2038 (setq truncate-lines t)
2039 (setq selective-display t)
2040 (setq selective-display-ellipses t) ;Display `...'
2041 (gnus-summary-set-display-table)
2042 (gnus-set-default-directory)
2043 (setq gnus-newsgroup-name group)
2044 (make-local-variable 'gnus-summary-line-format)
2045 (make-local-variable 'gnus-summary-line-format-spec)
2046 (make-local-variable 'gnus-summary-dummy-line-format)
2047 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2048 (make-local-variable 'gnus-summary-mark-positions)
2049 (make-local-hook 'pre-command-hook)
2050 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2051 (gnus-run-hooks 'gnus-summary-mode-hook)
2052 (mm-enable-multibyte)
2053 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2054 (gnus-update-summary-mark-positions))
2056 (defun gnus-summary-make-local-variables ()
2057 "Make all the local summary buffer variables."
2059 (dolist (local gnus-summary-local-variables)
2062 (if (eq (cdr local) 'global)
2063 ;; Copy the global value of the variable.
2064 (setq global (symbol-value (car local)))
2065 ;; Use the value from the list.
2066 (setq global (eval (cdr local))))
2067 (set (make-local-variable (car local)) global))
2068 ;; Simple nil-valued local variable.
2069 (set (make-local-variable local) nil)))))
2071 (defun gnus-summary-clear-local-variables ()
2072 (let ((locals gnus-summary-local-variables))
2074 (if (consp (car locals))
2075 (and (vectorp (caar locals))
2076 (set (caar locals) nil))
2077 (and (vectorp (car locals))
2078 (set (car locals) nil)))
2079 (setq locals (cdr locals)))))
2081 ;; Summary data functions.
2083 (defmacro gnus-data-number (data)
2086 (defmacro gnus-data-set-number (data number)
2087 `(setcar ,data ,number))
2089 (defmacro gnus-data-mark (data)
2092 (defmacro gnus-data-set-mark (data mark)
2093 `(setcar (nthcdr 1 ,data) ,mark))
2095 (defmacro gnus-data-pos (data)
2098 (defmacro gnus-data-set-pos (data pos)
2099 `(setcar (nthcdr 2 ,data) ,pos))
2101 (defmacro gnus-data-header (data)
2104 (defmacro gnus-data-set-header (data header)
2105 `(setf (nth 3 ,data) ,header))
2107 (defmacro gnus-data-level (data)
2110 (defmacro gnus-data-unread-p (data)
2111 `(= (nth 1 ,data) gnus-unread-mark))
2113 (defmacro gnus-data-read-p (data)
2114 `(/= (nth 1 ,data) gnus-unread-mark))
2116 (defmacro gnus-data-pseudo-p (data)
2117 `(consp (nth 3 ,data)))
2119 (defmacro gnus-data-find (number)
2120 `(assq ,number gnus-newsgroup-data))
2122 (defmacro gnus-data-find-list (number &optional data)
2123 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2124 (memq (assq ,number bdata)
2127 (defmacro gnus-data-make (number mark pos header level)
2128 `(list ,number ,mark ,pos ,header ,level))
2130 (defun gnus-data-enter (after-article number mark pos header level offset)
2131 (let ((data (gnus-data-find-list after-article)))
2133 (error "No such article: %d" after-article))
2134 (setcdr data (cons (gnus-data-make number mark pos header level)
2136 (setq gnus-newsgroup-data-reverse nil)
2137 (gnus-data-update-list (cddr data) offset)))
2139 (defun gnus-data-enter-list (after-article list &optional offset)
2141 (let ((data (and after-article (gnus-data-find-list after-article)))
2145 (let ((odata gnus-newsgroup-data))
2146 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2148 (gnus-data-update-list odata offset)))
2149 ;; Find the last element in the list to be spliced into the main
2152 (setq list (cdr list)))
2155 (setcdr list gnus-newsgroup-data)
2156 (setq gnus-newsgroup-data ilist)
2158 (gnus-data-update-list (cdr list) offset)))
2159 (setcdr list (cdr data))
2162 (gnus-data-update-list (cdr list) offset))))
2163 (setq gnus-newsgroup-data-reverse nil))))
2165 (defun gnus-data-remove (article &optional offset)
2166 (let ((data gnus-newsgroup-data))
2167 (if (= (gnus-data-number (car data)) article)
2169 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2170 gnus-newsgroup-data-reverse nil)
2172 (gnus-data-update-list gnus-newsgroup-data offset)))
2174 (when (= (gnus-data-number (cadr data)) article)
2175 (setcdr data (cddr data))
2177 (gnus-data-update-list (cdr data) offset))
2179 gnus-newsgroup-data-reverse nil))
2180 (setq data (cdr data))))))
2182 (defmacro gnus-data-list (backward)
2184 (or gnus-newsgroup-data-reverse
2185 (setq gnus-newsgroup-data-reverse
2186 (reverse gnus-newsgroup-data)))
2187 gnus-newsgroup-data))
2189 (defun gnus-data-update-list (data offset)
2190 "Add OFFSET to the POS of all data entries in DATA."
2191 (setq gnus-newsgroup-data-reverse nil)
2193 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2194 (setq data (cdr data))))
2196 (defun gnus-summary-article-pseudo-p (article)
2197 "Say whether this article is a pseudo article or not."
2198 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2200 (defmacro gnus-summary-article-sparse-p (article)
2201 "Say whether this article is a sparse article or not."
2202 `(memq ,article gnus-newsgroup-sparse))
2204 (defmacro gnus-summary-article-ancient-p (article)
2205 "Say whether this article is a sparse article or not."
2206 `(memq ,article gnus-newsgroup-ancient))
2208 (defun gnus-article-parent-p (number)
2209 "Say whether this article is a parent or not."
2210 (let ((data (gnus-data-find-list number)))
2211 (and (cdr data) ; There has to be an article after...
2212 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2213 (gnus-data-level (nth 1 data))))))
2215 (defun gnus-article-children (number)
2216 "Return a list of all children to NUMBER."
2217 (let* ((data (gnus-data-find-list number))
2218 (level (gnus-data-level (car data)))
2220 (setq data (cdr data))
2222 (= (gnus-data-level (car data)) (1+ level)))
2223 (push (gnus-data-number (car data)) children)
2224 (setq data (cdr data)))
2227 (defmacro gnus-summary-skip-intangible ()
2228 "If the current article is intangible, then jump to a different article."
2229 '(let ((to (get-text-property (point) 'gnus-intangible)))
2230 (and to (gnus-summary-goto-subject to))))
2232 (defmacro gnus-summary-article-intangible-p ()
2233 "Say whether this article is intangible or not."
2234 '(get-text-property (point) 'gnus-intangible))
2236 (defun gnus-article-read-p (article)
2237 "Say whether ARTICLE is read or not."
2238 (not (or (memq article gnus-newsgroup-marked)
2239 (memq article gnus-newsgroup-unreads)
2240 (memq article gnus-newsgroup-unselected)
2241 (memq article gnus-newsgroup-dormant))))
2243 ;; Some summary mode macros.
2245 (defmacro gnus-summary-article-number ()
2246 "The article number of the article on the current line.
2247 If there isn's an article number here, then we return the current
2250 (gnus-summary-skip-intangible)
2251 (or (get-text-property (point) 'gnus-number)
2252 (gnus-summary-last-subject))))
2254 (defmacro gnus-summary-article-header (&optional number)
2255 "Return the header of article NUMBER."
2256 `(gnus-data-header (gnus-data-find
2257 ,(or number '(gnus-summary-article-number)))))
2259 (defmacro gnus-summary-thread-level (&optional number)
2260 "Return the level of thread that starts with article NUMBER."
2261 `(if (and (eq gnus-summary-make-false-root 'dummy)
2262 (get-text-property (point) 'gnus-intangible))
2264 (gnus-data-level (gnus-data-find
2265 ,(or number '(gnus-summary-article-number))))))
2267 (defmacro gnus-summary-article-mark (&optional number)
2268 "Return the mark of article NUMBER."
2269 `(gnus-data-mark (gnus-data-find
2270 ,(or number '(gnus-summary-article-number)))))
2272 (defmacro gnus-summary-article-pos (&optional number)
2273 "Return the position of the line of article NUMBER."
2274 `(gnus-data-pos (gnus-data-find
2275 ,(or number '(gnus-summary-article-number)))))
2277 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2278 (defmacro gnus-summary-article-subject (&optional number)
2279 "Return current subject string or nil if nothing."
2282 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2283 '(gnus-data-header (assq (gnus-summary-article-number)
2284 gnus-newsgroup-data)))))
2287 (mail-header-subject headers))))
2289 (defmacro gnus-summary-article-score (&optional number)
2290 "Return current article score."
2291 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2292 gnus-newsgroup-scored))
2293 gnus-summary-default-score 0))
2295 (defun gnus-summary-article-children (&optional number)
2296 "Return a list of article numbers that are children of article NUMBER."
2297 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2298 (level (gnus-data-level (car data)))
2300 (while (and (setq data (cdr data))
2301 (> (setq l (gnus-data-level (car data))) level))
2302 (and (= (1+ level) l)
2303 (push (gnus-data-number (car data))
2305 (nreverse children)))
2307 (defun gnus-summary-article-parent (&optional number)
2308 "Return the article number of the parent of article NUMBER."
2309 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2310 (gnus-data-list t)))
2311 (level (gnus-data-level (car data))))
2313 () ; This is a root.
2314 ;; We search until we find an article with a level less than
2315 ;; this one. That function has to be the parent.
2316 (while (and (setq data (cdr data))
2317 (not (< (gnus-data-level (car data)) level))))
2318 (and data (gnus-data-number (car data))))))
2320 (defun gnus-unread-mark-p (mark)
2321 "Say whether MARK is the unread mark."
2322 (= mark gnus-unread-mark))
2324 (defun gnus-read-mark-p (mark)
2325 "Say whether MARK is one of the marks that mark as read.
2326 This is all marks except unread, ticked, dormant, and expirable."
2327 (not (or (= mark gnus-unread-mark)
2328 (= mark gnus-ticked-mark)
2329 (= mark gnus-dormant-mark)
2330 (= mark gnus-expirable-mark))))
2332 (defmacro gnus-article-mark (number)
2333 "Return the MARK of article NUMBER.
2334 This macro should only be used when computing the mark the \"first\"
2335 time; i.e., when generating the summary lines. After that,
2336 `gnus-summary-article-mark' should be used to examine the
2339 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2340 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2341 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2342 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2343 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2344 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2345 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2346 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2347 gnus-ancient-mark))))
2349 ;; Saving hidden threads.
2351 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2352 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2354 (defmacro gnus-save-hidden-threads (&rest forms)
2355 "Save hidden threads, eval FORMS, and restore the hidden threads."
2356 (let ((config (make-symbol "config")))
2357 `(let ((,config (gnus-hidden-threads-configuration)))
2361 (gnus-restore-hidden-threads-configuration ,config)))))
2363 (defun gnus-data-compute-positions ()
2364 "Compute the positions of all articles."
2365 (setq gnus-newsgroup-data-reverse nil)
2366 (let ((data gnus-newsgroup-data))
2368 (gnus-save-hidden-threads
2369 (gnus-summary-show-all-threads)
2370 (goto-char (point-min))
2372 (while (get-text-property (point) 'gnus-intangible)
2374 (gnus-data-set-pos (car data) (+ (point) 3))
2375 (setq data (cdr data))
2376 (forward-line 1))))))
2378 (defun gnus-hidden-threads-configuration ()
2379 "Return the current hidden threads configuration."
2382 (goto-char (point-min))
2383 (while (search-forward "\r" nil t)
2384 (push (1- (point)) config))
2387 (defun gnus-restore-hidden-threads-configuration (config)
2388 "Restore hidden threads configuration from CONFIG."
2389 (let (point buffer-read-only)
2390 (while (setq point (pop config))
2391 (when (and (< point (point-max))
2393 (eq (char-after) ?\n))
2394 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2396 ;; Various summary mode internalish functions.
2398 (defun gnus-mouse-pick-article (e)
2401 (gnus-summary-next-page nil t))
2403 (defun gnus-summary-set-display-table ()
2404 ;; Change the display table. Odd characters have a tendency to mess
2405 ;; up nicely formatted displays - we make all possible glyphs
2406 ;; display only a single character.
2408 ;; We start from the standard display table, if any.
2409 (let ((table (or (copy-sequence standard-display-table)
2410 (make-display-table)))
2412 ;; Nix out all the control chars...
2413 (while (>= (setq i (1- i)) 0)
2414 (aset table i [??]))
2415 ;; ... but not newline and cr, of course. (cr is necessary for the
2416 ;; selective display).
2417 (aset table ?\n nil)
2418 (aset table ?\r nil)
2419 ;; We keep TAB as well.
2420 (aset table ?\t nil)
2421 ;; We nix out any glyphs over 126 that are not set already.
2423 (while (>= (setq i (1- i)) 127)
2424 ;; Only modify if the entry is nil.
2425 (unless (aref table i)
2426 (aset table i [??]))))
2427 (setq buffer-display-table table)))
2429 (defun gnus-summary-setup-buffer (group)
2430 "Initialize summary buffer."
2431 (let ((buffer (concat "*Summary " group "*")))
2432 (if (get-buffer buffer)
2435 (setq gnus-summary-buffer (current-buffer))
2436 (not gnus-newsgroup-prepared))
2437 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2438 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2439 (gnus-summary-mode group)
2441 (gnus-carpal-setup-buffer 'summary))
2442 (unless gnus-single-article-buffer
2443 (make-local-variable 'gnus-article-buffer)
2444 (make-local-variable 'gnus-article-current)
2445 (make-local-variable 'gnus-original-article-buffer))
2446 (setq gnus-newsgroup-name group)
2449 (defun gnus-set-global-variables ()
2450 ;; Set the global equivalents of the summary buffer-local variables
2451 ;; to the latest values they had. These reflect the summary buffer
2452 ;; that was in action when the last article was fetched.
2453 (when (eq major-mode 'gnus-summary-mode)
2454 (setq gnus-summary-buffer (current-buffer))
2455 (let ((name gnus-newsgroup-name)
2456 (marked gnus-newsgroup-marked)
2457 (unread gnus-newsgroup-unreads)
2458 (headers gnus-current-headers)
2459 (data gnus-newsgroup-data)
2460 (summary gnus-summary-buffer)
2461 (article-buffer gnus-article-buffer)
2462 (original gnus-original-article-buffer)
2463 (gac gnus-article-current)
2464 (reffed gnus-reffed-article-number)
2465 (score-file gnus-current-score-file)
2466 (default-charset gnus-newsgroup-charset))
2468 (set-buffer gnus-group-buffer)
2469 (setq gnus-newsgroup-name name
2470 gnus-newsgroup-marked marked
2471 gnus-newsgroup-unreads unread
2472 gnus-current-headers headers
2473 gnus-newsgroup-data data
2474 gnus-article-current gac
2475 gnus-summary-buffer summary
2476 gnus-article-buffer article-buffer
2477 gnus-original-article-buffer original
2478 gnus-reffed-article-number reffed
2479 gnus-current-score-file score-file
2480 gnus-newsgroup-charset default-charset)
2481 ;; The article buffer also has local variables.
2482 (when (gnus-buffer-live-p gnus-article-buffer)
2483 (set-buffer gnus-article-buffer)
2484 (setq gnus-summary-buffer summary))))))
2486 (defun gnus-summary-article-unread-p (article)
2487 "Say whether ARTICLE is unread or not."
2488 (memq article gnus-newsgroup-unreads))
2490 (defun gnus-summary-first-article-p (&optional article)
2491 "Return whether ARTICLE is the first article in the buffer."
2492 (if (not (setq article (or article (gnus-summary-article-number))))
2494 (eq article (caar gnus-newsgroup-data))))
2496 (defun gnus-summary-last-article-p (&optional article)
2497 "Return whether ARTICLE is the last article in the buffer."
2498 (if (not (setq article (or article (gnus-summary-article-number))))
2499 ;; All non-existent numbers are the last article. :-)
2501 (not (cdr (gnus-data-find-list article)))))
2503 (defun gnus-make-thread-indent-array ()
2505 (unless (and gnus-thread-indent-array
2506 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2507 (setq gnus-thread-indent-array (make-vector 201 "")
2508 gnus-thread-indent-array-level gnus-thread-indent-level)
2510 (aset gnus-thread-indent-array n
2511 (make-string (* n gnus-thread-indent-level) ? ))
2514 (defun gnus-update-summary-mark-positions ()
2515 "Compute where the summary marks are to go."
2517 (when (gnus-buffer-exists-p gnus-summary-buffer)
2518 (set-buffer gnus-summary-buffer))
2519 (let ((gnus-replied-mark 129)
2520 (gnus-score-below-mark 130)
2521 (gnus-score-over-mark 130)
2522 (gnus-download-mark 131)
2523 (spec gnus-summary-line-format-spec)
2526 (gnus-set-work-buffer)
2527 (let ((gnus-summary-line-format-spec spec)
2528 (gnus-newsgroup-downloadable '((0 . t))))
2529 (gnus-summary-insert-line
2530 [0 "" "" "" "" "" 0 0 "" nil] 0 nil 128 t nil "" nil 1)
2531 (goto-char (point-min))
2532 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2534 (goto-char (point-min))
2535 (push (cons 'replied (and (search-forward "\201" nil t)
2538 (goto-char (point-min))
2539 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2541 (goto-char (point-min))
2542 (push (cons 'download
2543 (and (search-forward "\203" nil t) (- (point) 2)))
2545 (setq gnus-summary-mark-positions pos))))
2547 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2548 "Insert a dummy root in the summary buffer."
2550 (gnus-add-text-properties
2551 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2552 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2554 (defun gnus-summary-from-or-to-or-newsgroups (header)
2555 (let ((to (cdr (assq 'To (mail-header-extra header))))
2556 (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header))))
2557 (mail-parse-charset gnus-newsgroup-charset)
2558 (mail-parse-ignored-charsets
2559 (save-excursion (set-buffer gnus-summary-buffer)
2560 gnus-newsgroup-ignored-charsets)))
2563 gnus-ignored-from-addresses
2564 (string-match gnus-ignored-from-addresses
2565 (mail-header-from header)))
2567 (or (car (funcall gnus-extract-address-components
2569 gnus-decode-encoded-word-function to)))
2570 (funcall gnus-decode-encoded-word-function to))))
2572 gnus-ignored-from-addresses
2573 (string-match gnus-ignored-from-addresses
2574 (mail-header-from header)))
2575 (concat "=> " newsgroups))
2577 (or (car (funcall gnus-extract-address-components
2578 (mail-header-from header)))
2579 (mail-header-from header))))))
2581 (defun gnus-summary-insert-line (gnus-tmp-header
2582 gnus-tmp-level gnus-tmp-current
2583 gnus-tmp-unread gnus-tmp-replied
2584 gnus-tmp-expirable gnus-tmp-subject-or-nil
2585 &optional gnus-tmp-dummy gnus-tmp-score
2587 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2588 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2589 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2590 (gnus-tmp-score-char
2591 (if (or (null gnus-summary-default-score)
2592 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2593 gnus-summary-zcore-fuzz))
2595 (if (< gnus-tmp-score gnus-summary-default-score)
2596 gnus-score-below-mark gnus-score-over-mark)))
2598 (cond (gnus-tmp-process gnus-process-mark)
2599 ((memq gnus-tmp-current gnus-newsgroup-cached)
2601 (gnus-tmp-replied gnus-replied-mark)
2602 ((memq gnus-tmp-current gnus-newsgroup-saved)
2604 (t gnus-unread-mark)))
2605 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2608 ((string-match "<[^>]+> *$" gnus-tmp-from)
2609 (let ((beg (match-beginning 0)))
2610 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2611 (substring gnus-tmp-from (1+ (match-beginning 0))
2612 (1- (match-end 0))))
2613 (substring gnus-tmp-from 0 beg))))
2614 ((string-match "(.+)" gnus-tmp-from)
2615 (substring gnus-tmp-from
2616 (1+ (match-beginning 0)) (1- (match-end 0))))
2618 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2619 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2620 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2621 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2622 (buffer-read-only nil))
2623 (when (string= gnus-tmp-name "")
2624 (setq gnus-tmp-name gnus-tmp-from))
2625 (unless (numberp gnus-tmp-lines)
2626 (setq gnus-tmp-lines 0))
2627 (gnus-put-text-property
2629 (progn (eval gnus-summary-line-format-spec) (point))
2630 'gnus-number gnus-tmp-number)
2631 (when (gnus-visual-p 'summary-highlight 'highlight)
2633 (gnus-run-hooks 'gnus-summary-update-hook)
2636 (defun gnus-summary-update-line (&optional dont-update)
2637 ;; Update summary line after change.
2638 (when (and gnus-summary-default-score
2639 (not gnus-summary-inhibit-highlight))
2640 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2641 (article (gnus-summary-article-number))
2642 (score (gnus-summary-article-score article)))
2644 (if (and gnus-summary-mark-below
2645 (< (gnus-summary-article-score)
2646 gnus-summary-mark-below))
2647 ;; This article has a low score, so we mark it as read.
2648 (when (memq article gnus-newsgroup-unreads)
2649 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2650 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2651 ;; This article was previously marked as read on account
2652 ;; of a low score, but now it has risen, so we mark it as
2654 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2655 (gnus-summary-update-mark
2656 (if (or (null gnus-summary-default-score)
2657 (<= (abs (- score gnus-summary-default-score))
2658 gnus-summary-zcore-fuzz))
2660 (if (< score gnus-summary-default-score)
2661 gnus-score-below-mark gnus-score-over-mark))
2663 ;; Do visual highlighting.
2664 (when (gnus-visual-p 'summary-highlight 'highlight)
2665 (gnus-run-hooks 'gnus-summary-update-hook)))))
2667 (defvar gnus-tmp-new-adopts nil)
2669 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2670 "Return the number of articles in THREAD.
2671 This may be 0 in some cases -- if none of the articles in
2672 the thread are to be displayed."
2674 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2676 ((not (listp thread))
2678 ((and (consp thread) (cdr thread))
2681 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2684 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2687 (when (and level (zerop level) gnus-tmp-new-adopts)
2690 'gnus-summary-number-of-articles-in-thread
2691 gnus-tmp-new-adopts))))
2693 (if (> number 1) gnus-not-empty-thread-mark
2694 gnus-empty-thread-mark)
2697 (defun gnus-summary-set-local-parameters (group)
2698 "Go through the local params of GROUP and set all variable specs in that list."
2699 (let ((params (gnus-group-find-parameter group))
2702 (setq elem (car params)
2703 params (cdr params))
2704 (and (consp elem) ; Has to be a cons.
2705 (consp (cdr elem)) ; The cdr has to be a list.
2706 (symbolp (car elem)) ; Has to be a symbol in there.
2707 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2708 (ignore-errors ; So we set it.
2709 (make-local-variable (car elem))
2710 (set (car elem) (eval (nth 1 elem))))))))
2712 (defun gnus-summary-read-group (group &optional show-all no-article
2713 kill-buffer no-display backward
2715 "Start reading news in newsgroup GROUP.
2716 If SHOW-ALL is non-nil, already read articles are also listed.
2717 If NO-ARTICLE is non-nil, no article is selected initially.
2718 If NO-DISPLAY, don't generate a summary buffer."
2722 (let ((gnus-auto-select-next nil))
2723 (or (gnus-summary-read-group-1
2724 group show-all no-article
2725 kill-buffer no-display
2728 select-articles nil)))))
2729 (eq gnus-auto-select-next 'quietly))
2730 (set-buffer gnus-group-buffer)
2731 ;; The entry function called above goes to the next
2732 ;; group automatically, so we go two groups back
2733 ;; if we are searching for the previous group.
2735 (gnus-group-prev-unread-group 2))
2736 (if (not (equal group (gnus-group-group-name)))
2737 (setq group (gnus-group-group-name))
2741 (defun gnus-summary-read-group-1 (group show-all no-article
2742 kill-buffer no-display
2743 &optional select-articles)
2744 ;; Killed foreign groups can't be entered.
2745 (when (and (not (gnus-group-native-p group))
2746 (not (gnus-gethash group gnus-newsrc-hashtb)))
2747 (error "Dead non-native groups can't be entered"))
2748 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2749 (let* ((new-group (gnus-summary-setup-buffer group))
2750 (quit-config (gnus-group-quit-config group))
2751 (did-select (and new-group (gnus-select-newsgroup
2752 group show-all select-articles))))
2754 ;; This summary buffer exists already, so we just select it.
2756 (gnus-set-global-variables)
2758 (gnus-kill-or-deaden-summary kill-buffer))
2759 (gnus-configure-windows 'summary 'force)
2760 (gnus-set-mode-line 'summary)
2761 (gnus-summary-position-point)
2764 ;; We couldn't select this group.
2766 (when (and (eq major-mode 'gnus-summary-mode)
2767 (not (equal (current-buffer) kill-buffer)))
2768 (kill-buffer (current-buffer))
2769 (if (not quit-config)
2771 ;; Update the info -- marks might need to be removed,
2773 (gnus-summary-update-info)
2774 (set-buffer gnus-group-buffer)
2775 (gnus-group-jump-to-group group)
2776 (gnus-group-next-unread-group 1))
2777 (gnus-handle-ephemeral-exit quit-config)))
2778 (gnus-message 3 "Can't select group")
2780 ;; The user did a `C-g' while prompting for number of articles,
2781 ;; so we exit this group.
2782 ((eq did-select 'quit)
2783 (and (eq major-mode 'gnus-summary-mode)
2784 (not (equal (current-buffer) kill-buffer))
2785 (kill-buffer (current-buffer)))
2787 (gnus-kill-or-deaden-summary kill-buffer))
2788 (if (not quit-config)
2790 (set-buffer gnus-group-buffer)
2791 (gnus-group-jump-to-group group)
2792 (gnus-group-next-unread-group 1)
2793 (gnus-configure-windows 'group 'force))
2794 (gnus-handle-ephemeral-exit quit-config))
2795 ;; Finally signal the quit.
2797 ;; The group was successfully selected.
2799 (gnus-set-global-variables)
2800 ;; Save the active value in effect when the group was entered.
2801 (setq gnus-newsgroup-active
2803 (gnus-active gnus-newsgroup-name)))
2804 ;; You can change the summary buffer in some way with this hook.
2805 (gnus-run-hooks 'gnus-select-group-hook)
2806 ;; Set any local variables in the group parameters.
2807 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2808 (gnus-update-format-specifications
2809 nil 'summary 'summary-mode 'summary-dummy)
2810 (gnus-update-summary-mark-positions)
2811 ;; Do score processing.
2812 (when gnus-use-scoring
2813 (gnus-possibly-score-headers))
2814 ;; Check whether to fill in the gaps in the threads.
2815 (when gnus-build-sparse-threads
2816 (gnus-build-sparse-threads))
2817 ;; Find the initial limit.
2818 (if gnus-show-threads
2820 (let ((gnus-newsgroup-dormant nil))
2821 (gnus-summary-initial-limit show-all))
2822 (gnus-summary-initial-limit show-all))
2823 ;; When untreaded, all articles are always shown.
2824 (setq gnus-newsgroup-limit
2826 (lambda (header) (mail-header-number header))
2827 gnus-newsgroup-headers)))
2828 ;; Generate the summary buffer.
2830 (gnus-summary-prepare))
2831 (when gnus-use-trees
2832 (gnus-tree-open group)
2833 (setq gnus-summary-highlight-line-function
2834 'gnus-tree-highlight-article))
2835 ;; If the summary buffer is empty, but there are some low-scored
2836 ;; articles or some excluded dormants, we include these in the
2838 (when (and (zerop (buffer-size))
2840 (cond (gnus-newsgroup-dormant
2841 (gnus-summary-limit-include-dormant))
2842 ((and gnus-newsgroup-scored show-all)
2843 (gnus-summary-limit-include-expunged t))))
2844 ;; Function `gnus-apply-kill-file' must be called in this hook.
2845 (gnus-run-hooks 'gnus-apply-kill-hook)
2846 (if (and (zerop (buffer-size))
2849 ;; This newsgroup is empty.
2850 (gnus-summary-catchup-and-exit nil t)
2851 (gnus-message 6 "No unread news")
2853 (gnus-kill-or-deaden-summary kill-buffer))
2854 ;; Return nil from this function.
2856 ;; Hide conversation thread subtrees. We cannot do this in
2857 ;; gnus-summary-prepare-hook since kill processing may not
2858 ;; work with hidden articles.
2859 (and gnus-show-threads
2860 gnus-thread-hide-subtree
2861 (gnus-summary-hide-all-threads))
2863 (gnus-kill-or-deaden-summary kill-buffer))
2864 ;; Show first unread article if requested.
2865 (if (and (not no-article)
2867 gnus-newsgroup-unreads
2868 gnus-auto-select-first)
2870 (gnus-configure-windows 'summary)
2872 ((eq gnus-auto-select-first 'best)
2873 (gnus-summary-best-unread-article))
2874 ((eq gnus-auto-select-first t)
2875 (gnus-summary-first-unread-article))
2876 ((gnus-functionp gnus-auto-select-first)
2877 (funcall gnus-auto-select-first))))
2878 ;; Don't select any articles, just move point to the first
2879 ;; article in the group.
2880 (goto-char (point-min))
2881 (gnus-summary-position-point)
2882 (gnus-configure-windows 'summary 'force)
2883 (gnus-set-mode-line 'summary))
2884 (when (get-buffer-window gnus-group-buffer t)
2885 ;; Gotta use windows, because recenter does weird stuff if
2886 ;; the current buffer ain't the displayed window.
2887 (let ((owin (selected-window)))
2888 (select-window (get-buffer-window gnus-group-buffer t))
2889 (when (gnus-group-goto-group group)
2891 (select-window owin)))
2892 ;; Mark this buffer as "prepared".
2893 (setq gnus-newsgroup-prepared t)
2894 (gnus-run-hooks 'gnus-summary-prepared-hook)
2897 (defun gnus-summary-prepare ()
2898 "Generate the summary buffer."
2900 (let ((buffer-read-only nil))
2902 (setq gnus-newsgroup-data nil
2903 gnus-newsgroup-data-reverse nil)
2904 (gnus-run-hooks 'gnus-summary-generate-hook)
2905 ;; Generate the buffer, either with threads or without.
2906 (when gnus-newsgroup-headers
2907 (gnus-summary-prepare-threads
2908 (if gnus-show-threads
2909 (gnus-sort-gathered-threads
2910 (funcall gnus-summary-thread-gathering-function
2912 (gnus-cut-threads (gnus-make-threads)))))
2913 ;; Unthreaded display.
2914 (gnus-sort-articles gnus-newsgroup-headers))))
2915 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2916 ;; Call hooks for modifying summary buffer.
2917 (goto-char (point-min))
2918 (gnus-run-hooks 'gnus-summary-prepare-hook)))
2920 (defsubst gnus-general-simplify-subject (subject)
2921 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2924 ;; Truncate the subject.
2925 (gnus-simplify-subject-functions
2926 (gnus-map-function gnus-simplify-subject-functions subject))
2927 ((numberp gnus-summary-gather-subject-limit)
2928 (setq subject (gnus-simplify-subject-re subject))
2929 (if (> (length subject) gnus-summary-gather-subject-limit)
2930 (substring subject 0 gnus-summary-gather-subject-limit)
2932 ;; Fuzzily simplify it.
2933 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2934 (gnus-simplify-subject-fuzzy subject))
2935 ;; Just remove the leading "Re:".
2937 (gnus-simplify-subject-re subject))))
2939 (if (and gnus-summary-gather-exclude-subject
2940 (string-match gnus-summary-gather-exclude-subject subject))
2941 nil ; This article shouldn't be gathered
2944 (defun gnus-summary-simplify-subject-query ()
2945 "Query where the respool algorithm would put this article."
2947 (gnus-summary-select-article)
2948 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2950 (defun gnus-gather-threads-by-subject (threads)
2951 "Gather threads by looking at Subject headers."
2952 (if (not gnus-summary-make-false-root)
2954 (let ((hashtb (gnus-make-hashtable 1024))
2957 subject hthread whole-subject)
2959 (setq subject (gnus-general-simplify-subject
2960 (setq whole-subject (mail-header-subject
2963 (if (setq hthread (gnus-gethash subject hashtb))
2965 ;; We enter a dummy root into the thread, if we
2966 ;; haven't done that already.
2967 (unless (stringp (caar hthread))
2968 (setcar hthread (list whole-subject (car hthread))))
2969 ;; We add this new gathered thread to this gathered
2971 (setcdr (car hthread)
2972 (nconc (cdar hthread) (list (car threads))))
2973 ;; Remove it from the list of threads.
2974 (setcdr prev (cdr threads))
2975 (setq threads prev))
2976 ;; Enter this thread into the hash table.
2977 (gnus-sethash subject threads hashtb)))
2979 (setq threads (cdr threads)))
2982 (defun gnus-gather-threads-by-references (threads)
2983 "Gather threads by looking at References headers."
2984 (let ((idhashtb (gnus-make-hashtable 1024))
2985 (thhashtb (gnus-make-hashtable 1024))
2988 ids references id gthread gid entered ref)
2990 (when (setq references (mail-header-references (caar threads)))
2991 (setq id (mail-header-id (caar threads))
2992 ids (gnus-split-references references)
2994 (while (setq ref (pop ids))
2995 (setq ids (delete ref ids))
2996 (if (not (setq gid (gnus-gethash ref idhashtb)))
2998 (gnus-sethash ref id idhashtb)
2999 (gnus-sethash id threads thhashtb))
3000 (setq gthread (gnus-gethash gid thhashtb))
3002 ;; We enter a dummy root into the thread, if we
3003 ;; haven't done that already.
3004 (unless (stringp (caar gthread))
3005 (setcar gthread (list (mail-header-subject (caar gthread))
3007 ;; We add this new gathered thread to this gathered
3009 (setcdr (car gthread)
3010 (nconc (cdar gthread) (list (car threads)))))
3011 ;; Add it into the thread hash table.
3012 (gnus-sethash id gthread thhashtb)
3014 ;; Remove it from the list of threads.
3015 (setcdr prev (cdr threads))
3016 (setq threads prev))))
3018 (setq threads (cdr threads)))
3021 (defun gnus-sort-gathered-threads (threads)
3022 "Sort subtreads inside each gathered thread by article number."
3023 (let ((result threads))
3025 (when (stringp (caar threads))
3026 (setcdr (car threads)
3027 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3028 (setq threads (cdr threads)))
3031 (defun gnus-thread-loop-p (root thread)
3032 "Say whether ROOT is in THREAD."
3033 (let ((stack (list thread))
3036 (while (setq thread (pop stack))
3037 (setq th (cdr thread))
3039 (not (eq (caar th) root)))
3042 ;; We have found a loop.
3044 (setcdr thread (delq (car th) (cdr thread)))
3045 (if (boundp (setq ref-dep (intern "none"
3046 gnus-newsgroup-dependencies)))
3047 (setcdr (symbol-value ref-dep)
3048 (nconc (cdr (symbol-value ref-dep))
3050 (set ref-dep (list nil (car th))))
3053 ;; Push all the subthreads onto the stack.
3054 (push (cdr thread) stack)))
3057 (defun gnus-make-threads ()
3058 "Go through the dependency hashtb and find the roots. Return all threads."
3060 (while (catch 'infloop
3063 ;; Deal with self-referencing References loops.
3064 (when (and (car (symbol-value refs))
3071 (car (symbol-value refs)) thread))
3072 (cdr (symbol-value refs)))))))
3075 (unless (car (symbol-value refs))
3076 ;; These threads do not refer back to any other articles,
3077 ;; so they're roots.
3078 (setq threads (append (cdr (symbol-value refs)) threads))))
3079 gnus-newsgroup-dependencies)))
3082 ;; Build the thread tree.
3083 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3084 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3086 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3087 if it was already present.
3089 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3090 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3091 Message-IDs will be renamed be renamed to a unique Message-ID before
3094 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3095 (let* ((id (mail-header-id header))
3096 (id-dep (and id (intern id dependencies)))
3097 ref ref-dep ref-header)
3098 ;; Enter this `header' in the `dependencies' table.
3102 ;; The first two cases do the normal part: enter a new `header'
3103 ;; in the `dependencies' table.
3104 ((not (boundp id-dep))
3105 (set id-dep (list header)))
3106 ((null (car (symbol-value id-dep)))
3107 (setcar (symbol-value id-dep) header))
3109 ;; From here the `header' was already present in the
3110 ;; `dependencies' table.
3112 ;; Overrides an existing entry;
3113 ;; just set the header part of the entry.
3114 (setcar (symbol-value id-dep) header))
3116 ;; Renames the existing `header' to a unique Message-ID.
3117 ((not gnus-summary-ignore-duplicates)
3118 ;; An article with this Message-ID has already been seen.
3119 ;; We rename the Message-ID.
3120 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3122 (mail-header-set-id header id))
3124 ;; The last case ignores an existing entry, except it adds any
3125 ;; additional Xrefs (in case the two articles came from different
3127 ;; Also sets `header' to `nil' meaning that the `dependencies'
3128 ;; table was *not* modified.
3130 (mail-header-set-xref
3131 (car (symbol-value id-dep))
3132 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3134 (or (mail-header-xref header) "")))
3138 ;; First check if that we are not creating a References loop.
3139 (setq ref (gnus-parent-id (mail-header-references header)))
3141 (setq ref-dep (intern-soft ref dependencies))
3143 (setq ref-header (car (symbol-value ref-dep))))
3144 (if (string= id ref)
3145 ;; Yuk! This is a reference loop. Make the article be a
3148 (mail-header-set-references (car (symbol-value id-dep)) "none")
3150 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3151 (setq ref (gnus-parent-id (mail-header-references header)))
3152 (setq ref-dep (intern (or ref "none") dependencies))
3153 (if (boundp ref-dep)
3154 (setcdr (symbol-value ref-dep)
3155 (nconc (cdr (symbol-value ref-dep))
3156 (list (symbol-value id-dep))))
3157 (set ref-dep (list nil (symbol-value id-dep)))))
3160 (defun gnus-build-sparse-threads ()
3161 (let ((headers gnus-newsgroup-headers)
3162 (mail-parse-charset gnus-newsgroup-charset)
3163 (gnus-summary-ignore-duplicates t)
3164 header references generation relations
3165 subject child end new-child date)
3166 ;; First we create an alist of generations/relations, where
3167 ;; generations is how much we trust the relation, and the relation
3169 (gnus-message 7 "Making sparse threads...")
3171 (nnheader-set-temp-buffer " *gnus sparse threads*")
3172 (while (setq header (pop headers))
3173 (when (and (setq references (mail-header-references header))
3174 (not (string= references "")))
3176 (setq child (mail-header-id header)
3177 subject (mail-header-subject header)
3178 date (mail-header-date header)
3180 (while (search-backward ">" nil t)
3181 (setq end (1+ (point)))
3182 (when (search-backward "<" nil t)
3183 (setq new-child (buffer-substring (point) end))
3184 (push (list (incf generation)
3185 child (setq child new-child)
3189 (push (list (1+ generation) child nil subject) relations))
3191 (kill-buffer (current-buffer)))
3192 ;; Sort over trustworthiness.
3195 (when (gnus-dependencies-add-header
3196 (make-full-mail-header
3197 gnus-reffed-article-number
3198 (nth 3 relation) "" (or (nth 4 relation) "")
3200 (or (nth 2 relation) "") 0 0 "")
3201 gnus-newsgroup-dependencies nil)
3202 (push gnus-reffed-article-number gnus-newsgroup-limit)
3203 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3204 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3205 gnus-newsgroup-reads)
3206 (decf gnus-reffed-article-number)))
3207 (sort relations 'car-less-than-car))
3208 (gnus-message 7 "Making sparse threads...done")))
3210 (defun gnus-build-old-threads ()
3211 ;; Look at all the articles that refer back to old articles, and
3212 ;; fetch the headers for the articles that aren't there. This will
3213 ;; build complete threads - if the roots haven't been expired by the
3215 (let ((mail-parse-charset gnus-newsgroup-charset)
3219 (when (not (car (symbol-value refs)))
3220 (setq heads (cdr (symbol-value refs)))
3222 (if (memq (mail-header-number (caar heads))
3223 gnus-newsgroup-dormant)
3224 (setq heads (cdr heads))
3225 (setq id (symbol-name refs))
3226 (while (and (setq id (gnus-build-get-header id))
3227 (not (car (gnus-id-to-thread id)))))
3228 (setq heads nil)))))
3229 gnus-newsgroup-dependencies)))
3231 ;; This function has to be called with point after the article number
3232 ;; on the beginning of the line.
3233 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3234 (let ((eol (gnus-point-at-eol))
3235 (buffer (current-buffer))
3238 ;; overview: [num subject from date id refs chars lines misc]
3241 (narrow-to-region (point) eol)
3246 (make-full-mail-header
3248 (funcall gnus-decode-encoded-word-function
3249 (nnheader-nov-field)) ; subject
3250 (funcall gnus-decode-encoded-word-function
3251 (nnheader-nov-field)) ; from
3252 (nnheader-nov-field) ; date
3253 (nnheader-nov-read-message-id) ; id
3254 (nnheader-nov-field) ; refs
3255 (nnheader-nov-read-integer) ; chars
3256 (nnheader-nov-read-integer) ; lines
3258 (nnheader-nov-field)) ; misc
3259 (nnheader-nov-parse-extra)))) ; extra
3263 (when gnus-alter-header-function
3264 (funcall gnus-alter-header-function header))
3265 (gnus-dependencies-add-header header dependencies force-new)))
3267 (defun gnus-build-get-header (id)
3268 ;; Look through the buffer of NOV lines and find the header to
3269 ;; ID. Enter this line into the dependencies hash table, and return
3270 ;; the id of the parent article (if any).
3271 (let ((deps gnus-newsgroup-dependencies)
3275 (set-buffer nntp-server-buffer)
3276 (let ((case-fold-search nil))
3277 (goto-char (point-min))
3278 (while (and (not found)
3279 (search-forward id nil t))
3281 (setq found (looking-at
3282 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3283 (regexp-quote id))))
3284 (or found (beginning-of-line 2)))
3288 (setq header (gnus-nov-parse-line
3289 (read (current-buffer)) deps))
3290 (gnus-parent-id (mail-header-references header))))))
3292 (let ((number (mail-header-number header)))
3293 (push number gnus-newsgroup-limit)
3294 (push header gnus-newsgroup-headers)
3295 (if (memq number gnus-newsgroup-unselected)
3297 (push number gnus-newsgroup-unreads)
3298 (setq gnus-newsgroup-unselected
3299 (delq number gnus-newsgroup-unselected)))
3300 (push number gnus-newsgroup-ancient)))))))
3302 (defun gnus-build-all-threads ()
3303 "Read all the headers."
3304 (let ((gnus-summary-ignore-duplicates t)
3305 (mail-parse-charset gnus-newsgroup-charset)
3306 (dependencies gnus-newsgroup-dependencies)
3309 (set-buffer nntp-server-buffer)
3310 (let ((case-fold-search nil))
3311 (goto-char (point-min))
3314 (setq article (read (current-buffer))
3315 header (gnus-nov-parse-line article dependencies)))
3318 (set-buffer gnus-summary-buffer)
3319 (push header gnus-newsgroup-headers)
3320 (if (memq (setq article (mail-header-number header))
3321 gnus-newsgroup-unselected)
3323 (push article gnus-newsgroup-unreads)
3324 (setq gnus-newsgroup-unselected
3325 (delq article gnus-newsgroup-unselected)))
3326 (push article gnus-newsgroup-ancient)))
3327 (forward-line 1)))))))
3329 (defun gnus-summary-update-article-line (article header)
3330 "Update the line for ARTICLE using HEADERS."
3331 (let* ((id (mail-header-id header))
3332 (thread (gnus-id-to-thread id)))
3334 (error "Article in no thread"))
3335 ;; Update the thread.
3336 (setcar thread header)
3337 (gnus-summary-goto-subject article)
3338 (let* ((datal (gnus-data-find-list article))
3340 (length (when (cdr datal)
3341 (- (gnus-data-pos data)
3342 (gnus-data-pos (cadr datal)))))
3343 (buffer-read-only nil)
3344 (level (gnus-summary-thread-level)))
3346 (gnus-summary-insert-line
3347 header level nil (gnus-article-mark article)
3348 (memq article gnus-newsgroup-replied)
3349 (memq article gnus-newsgroup-expirable)
3350 ;; Only insert the Subject string when it's different
3351 ;; from the previous Subject string.
3352 (if (gnus-subject-equal
3354 (mail-header-subject
3357 (gnus-data-find-list
3359 (gnus-data-list t)))))
3360 ;; Error on the side of excessive subjects.
3362 (mail-header-subject header))
3364 (mail-header-subject header))
3365 nil (cdr (assq article gnus-newsgroup-scored))
3366 (memq article gnus-newsgroup-processable))
3368 (gnus-data-update-list
3369 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3371 (defun gnus-summary-update-article (article &optional iheader)
3372 "Update ARTICLE in the summary buffer."
3373 (set-buffer gnus-summary-buffer)
3374 (let* ((header (gnus-summary-article-header article))
3375 (id (mail-header-id header))
3376 (data (gnus-data-find article))
3377 (thread (gnus-id-to-thread id))
3378 (references (mail-header-references header))
3382 (when (and references
3383 (not (equal "" references)))
3386 (buffer-read-only nil)
3392 (delq thread parent)))
3393 (if (gnus-summary-insert-subject id header)
3394 ;; Set the (possibly) new article number in the data structure.
3395 (gnus-data-set-number data (gnus-id-to-article id))
3399 (defun gnus-rebuild-thread (id &optional line)
3400 "Rebuild the thread containing ID.
3401 If LINE, insert the rebuilt thread starting on line LINE."
3402 (let ((buffer-read-only nil)
3403 old-pos current thread data)
3404 (if (not gnus-show-threads)
3405 (setq thread (list (car (gnus-id-to-thread id))))
3406 ;; Get the thread this article is part of.
3407 (setq thread (gnus-remove-thread id)))
3408 (setq old-pos (gnus-point-at-bol))
3409 (setq current (save-excursion
3410 (and (zerop (forward-line -1))
3411 (gnus-summary-article-number))))
3412 ;; If this is a gathered thread, we have to go some re-gathering.
3413 (when (stringp (car thread))
3414 (let ((subject (car thread))
3416 (setq thread (cdr thread))
3418 (unless (memq (setq thr (gnus-id-to-thread
3420 (mail-header-id (caar thread)))))
3423 (setq thread (cdr thread)))
3424 ;; We now have all (unique) roots.
3425 (if (= (length roots) 1)
3426 ;; All the loose roots are now one solid root.
3427 (setq thread (car roots))
3428 (setq thread (cons subject (gnus-sort-threads roots))))))
3430 ;; We then insert this thread into the summary buffer.
3432 (goto-char (point-min))
3433 (forward-line (1- line)))
3434 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3435 (if gnus-show-threads
3436 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3437 (gnus-summary-prepare-unthreaded thread))
3438 (setq data (nreverse gnus-newsgroup-data))
3439 (setq threads gnus-newsgroup-threads))
3440 ;; We splice the new data into the data structure.
3441 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3442 ;;!!! then we want to insert at the beginning of the buffer.
3443 ;;!!! That happens to be true with Gnus now, but that may
3444 ;;!!! change in the future. Perhaps.
3445 (gnus-data-enter-list
3446 (if line nil current) data (- (point) old-pos))
3447 (setq gnus-newsgroup-threads
3448 (nconc threads gnus-newsgroup-threads))
3449 (gnus-data-compute-positions))))
3451 (defun gnus-number-to-header (number)
3452 "Return the header for article NUMBER."
3453 (let ((headers gnus-newsgroup-headers))
3455 (not (= number (mail-header-number (car headers)))))
3460 (defun gnus-parent-headers (in-headers &optional generation)
3461 "Return the headers of the GENERATIONeth parent of HEADERS."
3463 (setq generation 1))
3465 (headers in-headers)
3468 (not (zerop generation))
3469 (setq references (mail-header-references headers)))
3470 (setq headers (if (and references
3471 (setq parent (gnus-parent-id references)))
3472 (car (gnus-id-to-thread parent))
3475 (and (not (eq headers in-headers))
3478 (defun gnus-id-to-thread (id)
3479 "Return the (sub-)thread where ID appears."
3480 (gnus-gethash id gnus-newsgroup-dependencies))
3482 (defun gnus-id-to-article (id)
3483 "Return the article number of ID."
3484 (let ((thread (gnus-id-to-thread id)))
3487 (mail-header-number (car thread)))))
3489 (defun gnus-id-to-header (id)
3490 "Return the article headers of ID."
3491 (car (gnus-id-to-thread id)))
3493 (defun gnus-article-displayed-root-p (article)
3494 "Say whether ARTICLE is a root(ish) article."
3495 (let ((level (gnus-summary-thread-level article))
3496 (refs (mail-header-references (gnus-summary-article-header article)))
3502 ((null (gnus-parent-id refs)) t)
3504 (null (setq particle (gnus-id-to-article
3505 (gnus-parent-id refs))))
3506 (null (gnus-summary-thread-level particle)))))))
3508 (defun gnus-root-id (id)
3509 "Return the id of the root of the thread where ID appears."
3511 (while (and id (setq prev (car (gnus-id-to-thread id))))
3513 id (gnus-parent-id (mail-header-references prev))))
3516 (defun gnus-articles-in-thread (thread)
3517 "Return the list of articles in THREAD."
3518 (cons (mail-header-number (car thread))
3519 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3521 (defun gnus-remove-thread (id &optional dont-remove)
3522 "Remove the thread that has ID in it."
3523 (let (headers thread last-id)
3524 ;; First go up in this thread until we find the root.
3525 (setq last-id (gnus-root-id id)
3526 headers (message-flatten-list (gnus-id-to-thread last-id)))
3527 ;; We have now found the real root of this thread. It might have
3528 ;; been gathered into some loose thread, so we have to search
3529 ;; through the threads to find the thread we wanted.
3530 (let ((threads gnus-newsgroup-threads)
3533 (setq sub (car threads))
3534 (if (stringp (car sub))
3535 ;; This is a gathered thread, so we look at the roots
3536 ;; below it to find whether this article is in this
3539 (setq sub (cdr sub))
3541 (when (member (caar sub) headers)
3542 (setq thread (car threads)
3545 (setq sub (cdr sub))))
3546 ;; It's an ordinary thread, so we check it.
3547 (when (eq (car sub) (car headers))
3550 (setq threads (cdr threads)))
3551 ;; If this article is in no thread, then it's a root.
3554 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3555 (setq thread (gnus-id-to-thread last-id)))
3558 thread ; We return this thread.
3560 (if (stringp (car thread))
3562 ;; If we use dummy roots, then we have to remove the
3563 ;; dummy root as well.
3564 (when (eq gnus-summary-make-false-root 'dummy)
3565 ;; We go to the dummy root by going to
3566 ;; the first sub-"thread", and then one line up.
3567 (gnus-summary-goto-article
3568 (mail-header-number (caadr thread)))
3571 (gnus-data-compute-positions))
3572 (setq thread (cdr thread))
3574 (gnus-remove-thread-1 (car thread))
3575 (setq thread (cdr thread))))
3576 (gnus-summary-show-all-threads)
3577 (gnus-remove-thread-1 thread))))))))
3579 (defun gnus-remove-thread-1 (thread)
3580 "Remove the thread THREAD recursively."
3581 (let ((number (mail-header-number (pop thread)))
3583 (setq thread (reverse thread))
3585 (gnus-remove-thread-1 (pop thread)))
3586 (when (setq d (gnus-data-find number))
3587 (goto-char (gnus-data-pos d))
3590 (- (gnus-point-at-bol)
3592 (1+ (gnus-point-at-eol))
3593 (gnus-delete-line)))))))
3595 (defun gnus-sort-threads (threads)
3597 (if (not gnus-thread-sort-functions)
3599 (gnus-message 8 "Sorting threads...")
3601 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3602 (gnus-message 8 "Sorting threads...done"))))
3604 (defun gnus-sort-articles (articles)
3606 (when gnus-article-sort-functions
3607 (gnus-message 7 "Sorting articles...")
3609 (setq gnus-newsgroup-headers
3610 (sort articles (gnus-make-sort-function
3611 gnus-article-sort-functions)))
3612 (gnus-message 7 "Sorting articles...done"))))
3614 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3615 (defmacro gnus-thread-header (thread)
3616 ;; Return header of first article in THREAD.
3617 ;; Note that THREAD must never, ever be anything else than a variable -
3618 ;; using some other form will lead to serious barfage.
3619 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3620 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3621 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
3624 (defsubst gnus-article-sort-by-number (h1 h2)
3625 "Sort articles by article number."
3626 (< (mail-header-number h1)
3627 (mail-header-number h2)))
3629 (defun gnus-thread-sort-by-number (h1 h2)
3630 "Sort threads by root article number."
3631 (gnus-article-sort-by-number
3632 (gnus-thread-header h1) (gnus-thread-header h2)))
3634 (defsubst gnus-article-sort-by-lines (h1 h2)
3635 "Sort articles by article Lines header."
3636 (< (mail-header-lines h1)
3637 (mail-header-lines h2)))
3639 (defun gnus-thread-sort-by-lines (h1 h2)
3640 "Sort threads by root article Lines header."
3641 (gnus-article-sort-by-lines
3642 (gnus-thread-header h1) (gnus-thread-header h2)))
3644 (defsubst gnus-article-sort-by-chars (h1 h2)
3645 "Sort articles by octet length."
3646 (< (mail-header-chars h1)
3647 (mail-header-chars h2)))
3649 (defun gnus-thread-sort-by-chars (h1 h2)
3650 "Sort threads by root article octet length."
3651 (gnus-article-sort-by-chars
3652 (gnus-thread-header h1) (gnus-thread-header h2)))
3654 (defsubst gnus-article-sort-by-author (h1 h2)
3655 "Sort articles by root author."
3657 (let ((extract (funcall
3658 gnus-extract-address-components
3659 (mail-header-from h1))))
3660 (or (car extract) (cadr extract) ""))
3661 (let ((extract (funcall
3662 gnus-extract-address-components
3663 (mail-header-from h2))))
3664 (or (car extract) (cadr extract) ""))))
3666 (defun gnus-thread-sort-by-author (h1 h2)
3667 "Sort threads by root author."
3668 (gnus-article-sort-by-author
3669 (gnus-thread-header h1) (gnus-thread-header h2)))
3671 (defsubst gnus-article-sort-by-subject (h1 h2)
3672 "Sort articles by root subject."
3674 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3675 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3677 (defun gnus-thread-sort-by-subject (h1 h2)
3678 "Sort threads by root subject."
3679 (gnus-article-sort-by-subject
3680 (gnus-thread-header h1) (gnus-thread-header h2)))
3682 (defsubst gnus-article-sort-by-date (h1 h2)
3683 "Sort articles by root article date."
3685 (gnus-date-get-time (mail-header-date h1))
3686 (gnus-date-get-time (mail-header-date h2))))
3688 (defun gnus-thread-sort-by-date (h1 h2)
3689 "Sort threads by root article date."
3690 (gnus-article-sort-by-date
3691 (gnus-thread-header h1) (gnus-thread-header h2)))
3693 (defsubst gnus-article-sort-by-score (h1 h2)
3694 "Sort articles by root article score.
3695 Unscored articles will be counted as having a score of zero."
3696 (> (or (cdr (assq (mail-header-number h1)
3697 gnus-newsgroup-scored))
3698 gnus-summary-default-score 0)
3699 (or (cdr (assq (mail-header-number h2)
3700 gnus-newsgroup-scored))
3701 gnus-summary-default-score 0)))
3703 (defun gnus-thread-sort-by-score (h1 h2)
3704 "Sort threads by root article score."
3705 (gnus-article-sort-by-score
3706 (gnus-thread-header h1) (gnus-thread-header h2)))
3708 (defun gnus-thread-sort-by-total-score (h1 h2)
3709 "Sort threads by the sum of all scores in the thread.
3710 Unscored articles will be counted as having a score of zero."
3711 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3713 (defun gnus-thread-total-score (thread)
3714 ;; This function find the total score of THREAD.
3715 (cond ((null thread)
3718 (if (stringp (car thread))
3719 (apply gnus-thread-score-function 0
3720 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3721 (gnus-thread-total-score-1 thread)))
3723 (gnus-thread-total-score-1 (list thread)))))
3725 (defun gnus-thread-total-score-1 (root)
3726 ;; This function find the total score of the thread below ROOT.
3727 (setq root (car root))
3728 (apply gnus-thread-score-function
3730 (mapcar 'gnus-thread-total-score
3731 (cdr (gnus-id-to-thread (mail-header-id root))))
3732 (when (> (mail-header-number root) 0)
3733 (list (or (cdr (assq (mail-header-number root)
3734 gnus-newsgroup-scored))
3735 gnus-summary-default-score 0))))
3736 (list gnus-summary-default-score)
3739 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3740 (defvar gnus-tmp-prev-subject nil)
3741 (defvar gnus-tmp-false-parent nil)
3742 (defvar gnus-tmp-root-expunged nil)
3743 (defvar gnus-tmp-dummy-line nil)
3745 (defvar gnus-tmp-header)
3746 (defun gnus-extra-header (type &optional header)
3747 "Return the extra header of TYPE."
3748 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
3751 (defun gnus-summary-prepare-threads (threads)
3752 "Prepare summary buffer from THREADS and indentation LEVEL.
3753 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3754 or a straight list of headers."
3755 (gnus-message 7 "Generating summary...")
3757 (setq gnus-newsgroup-threads threads)
3760 (let ((gnus-tmp-level 0)
3761 (default-score (or gnus-summary-default-score 0))
3762 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3763 thread number subject stack state gnus-tmp-gathered beg-match
3764 new-roots gnus-tmp-new-adopts thread-end
3765 gnus-tmp-header gnus-tmp-unread
3766 gnus-tmp-replied gnus-tmp-subject-or-nil
3767 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3768 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3769 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3771 (setq gnus-tmp-prev-subject nil)
3773 (if (vectorp (car threads))
3774 ;; If this is a straight (sic) list of headers, then a
3775 ;; threaded summary display isn't required, so we just create
3776 ;; an unthreaded one.
3777 (gnus-summary-prepare-unthreaded threads)
3779 ;; Do the threaded display.
3781 (while (or threads stack gnus-tmp-new-adopts new-roots)
3783 (if (and (= gnus-tmp-level 0)
3786 (not gnus-tmp-false-parent)
3787 (or gnus-tmp-new-adopts new-roots))
3788 (if gnus-tmp-new-adopts
3789 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3790 thread (list (car gnus-tmp-new-adopts))
3791 gnus-tmp-header (caar thread)
3792 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3794 (setq thread (list (car new-roots))
3795 gnus-tmp-header (caar thread)
3796 new-roots (cdr new-roots))))
3799 ;; If there are some threads, we do them before the
3800 ;; threads on the stack.
3801 (setq thread threads
3802 gnus-tmp-header (caar thread))
3803 ;; There were no current threads, so we pop something off
3805 (setq state (car stack)
3806 gnus-tmp-level (car state)
3809 gnus-tmp-header (caar thread))))
3811 (setq gnus-tmp-false-parent nil)
3812 (setq gnus-tmp-root-expunged nil)
3813 (setq thread-end nil)
3815 (if (stringp gnus-tmp-header)
3816 ;; The header is a dummy root.
3818 ((eq gnus-summary-make-false-root 'adopt)
3819 ;; We let the first article adopt the rest.
3820 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3822 (setq gnus-tmp-gathered
3824 (lambda (h) (mail-header-number (car h)))
3827 (setq thread (cons (list (caar thread)
3830 (setq gnus-tmp-level -1
3831 gnus-tmp-false-parent t))
3832 ((eq gnus-summary-make-false-root 'empty)
3833 ;; We print adopted articles with empty subject fields.
3834 (setq gnus-tmp-gathered
3836 (lambda (h) (mail-header-number (car h)))
3839 (setq gnus-tmp-level -1))
3840 ((eq gnus-summary-make-false-root 'dummy)
3841 ;; We remember that we probably want to output a dummy
3843 (setq gnus-tmp-dummy-line gnus-tmp-header)
3844 (setq gnus-tmp-prev-subject gnus-tmp-header))
3846 ;; We do not make a root for the gathered
3847 ;; sub-threads at all.
3848 (setq gnus-tmp-level -1)))
3850 (setq number (mail-header-number gnus-tmp-header)
3851 subject (mail-header-subject gnus-tmp-header))
3854 ;; If the thread has changed subject, we might want to make
3855 ;; this subthread into a root.
3856 ((and (null gnus-thread-ignore-subject)
3857 (not (zerop gnus-tmp-level))
3858 gnus-tmp-prev-subject
3860 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3861 (setq new-roots (nconc new-roots (list (car thread)))
3863 gnus-tmp-header nil))
3864 ;; If the article lies outside the current limit,
3865 ;; then we do not display it.
3866 ((not (memq number gnus-newsgroup-limit))
3867 (setq gnus-tmp-gathered
3869 (lambda (h) (mail-header-number (car h)))
3872 (setq gnus-tmp-new-adopts (if (cdar thread)
3873 (append gnus-tmp-new-adopts
3875 gnus-tmp-new-adopts)
3877 gnus-tmp-header nil)
3878 (when (zerop gnus-tmp-level)
3879 (setq gnus-tmp-root-expunged t)))
3880 ;; Perhaps this article is to be marked as read?
3881 ((and gnus-summary-mark-below
3882 (< (or (cdr (assq number gnus-newsgroup-scored))
3884 gnus-summary-mark-below)
3885 ;; Don't touch sparse articles.
3886 (not (gnus-summary-article-sparse-p number))
3887 (not (gnus-summary-article-ancient-p number)))
3888 (setq gnus-newsgroup-unreads
3889 (delq number gnus-newsgroup-unreads))
3890 (if gnus-newsgroup-auto-expire
3891 (push number gnus-newsgroup-expirable)
3892 (push (cons number gnus-low-score-mark)
3893 gnus-newsgroup-reads))))
3895 (when gnus-tmp-header
3896 ;; We may have an old dummy line to output before this
3898 (when (and gnus-tmp-dummy-line
3901 (mail-header-subject gnus-tmp-header)))
3902 (gnus-summary-insert-dummy-line
3903 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3904 (setq gnus-tmp-dummy-line nil))
3906 ;; Compute the mark.
3907 (setq gnus-tmp-unread (gnus-article-mark number))
3909 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3910 gnus-tmp-header gnus-tmp-level)
3911 gnus-newsgroup-data)
3913 ;; Actually insert the line.
3915 gnus-tmp-subject-or-nil
3917 ((and gnus-thread-ignore-subject
3918 gnus-tmp-prev-subject
3919 (not (inline (gnus-subject-equal
3920 gnus-tmp-prev-subject subject))))
3922 ((zerop gnus-tmp-level)
3923 (if (and (eq gnus-summary-make-false-root 'empty)
3924 (memq number gnus-tmp-gathered)
3925 gnus-tmp-prev-subject
3926 (inline (gnus-subject-equal
3927 gnus-tmp-prev-subject subject)))
3928 gnus-summary-same-subject
3930 (t gnus-summary-same-subject)))
3931 (if (and (eq gnus-summary-make-false-root 'adopt)
3932 (= gnus-tmp-level 1)
3933 (memq number gnus-tmp-gathered))
3934 (setq gnus-tmp-opening-bracket ?\<
3935 gnus-tmp-closing-bracket ?\>)
3936 (setq gnus-tmp-opening-bracket ?\[
3937 gnus-tmp-closing-bracket ?\]))
3939 gnus-tmp-indentation
3940 (aref gnus-thread-indent-array gnus-tmp-level)
3941 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3942 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3943 gnus-summary-default-score 0)
3945 (if (or (null gnus-summary-default-score)
3946 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3947 gnus-summary-zcore-fuzz))
3949 (if (< gnus-tmp-score gnus-summary-default-score)
3950 gnus-score-below-mark gnus-score-over-mark))
3952 (cond ((memq number gnus-newsgroup-processable)
3954 ((memq number gnus-newsgroup-cached)
3956 ((memq number gnus-newsgroup-replied)
3958 ((memq number gnus-newsgroup-saved)
3960 (t gnus-unread-mark))
3961 gnus-tmp-from (mail-header-from gnus-tmp-header)
3964 ((string-match "<[^>]+> *$" gnus-tmp-from)
3965 (setq beg-match (match-beginning 0))
3966 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3967 (substring gnus-tmp-from (1+ (match-beginning 0))
3968 (1- (match-end 0))))
3969 (substring gnus-tmp-from 0 beg-match)))
3970 ((string-match "(.+)" gnus-tmp-from)
3971 (substring gnus-tmp-from
3972 (1+ (match-beginning 0)) (1- (match-end 0))))
3974 (when (string= gnus-tmp-name "")
3975 (setq gnus-tmp-name gnus-tmp-from))
3976 (unless (numberp gnus-tmp-lines)
3977 (setq gnus-tmp-lines 0))
3978 (gnus-put-text-property
3980 (progn (eval gnus-summary-line-format-spec) (point))
3981 'gnus-number number)
3984 (gnus-run-hooks 'gnus-summary-update-hook)
3987 (setq gnus-tmp-prev-subject subject)))
3989 (when (nth 1 thread)
3990 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3991 (incf gnus-tmp-level)
3992 (setq threads (if thread-end nil (cdar thread)))
3994 (setq gnus-tmp-level 0)))))
3995 (gnus-message 7 "Generating summary...done"))
3997 (defun gnus-summary-prepare-unthreaded (headers)
3998 "Generate an unthreaded summary buffer based on HEADERS."
3999 (let (header number mark)
4004 ;; We may have to root out some bad articles...
4005 (when (memq (setq number (mail-header-number
4006 (setq header (pop headers))))
4007 gnus-newsgroup-limit)
4008 ;; Mark article as read when it has a low score.
4009 (when (and gnus-summary-mark-below
4010 (< (or (cdr (assq number gnus-newsgroup-scored))
4011 gnus-summary-default-score 0)
4012 gnus-summary-mark-below)
4013 (not (gnus-summary-article-ancient-p number)))
4014 (setq gnus-newsgroup-unreads
4015 (delq number gnus-newsgroup-unreads))
4016 (if gnus-newsgroup-auto-expire
4017 (push number gnus-newsgroup-expirable)
4018 (push (cons number gnus-low-score-mark)
4019 gnus-newsgroup-reads)))
4021 (setq mark (gnus-article-mark number))
4022 (push (gnus-data-make number mark (1+ (point)) header 0)
4023 gnus-newsgroup-data)
4024 (gnus-summary-insert-line
4026 mark (memq number gnus-newsgroup-replied)
4027 (memq number gnus-newsgroup-expirable)
4028 (mail-header-subject header) nil
4029 (cdr (assq number gnus-newsgroup-scored))
4030 (memq number gnus-newsgroup-processable))))))
4032 (defun gnus-summary-remove-list-identifiers ()
4033 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4034 (let ((regexp (if (stringp gnus-list-identifiers)
4035 gnus-list-identifiers
4036 (mapconcat 'identity gnus-list-identifiers " *\\|"))))
4037 (dolist (header gnus-newsgroup-headers)
4038 (when (string-match (concat "\\(Re: +\\)?\\(" regexp " *\\)")
4039 (mail-header-subject header))
4040 (mail-header-set-subject
4041 header (concat (substring (mail-header-subject header)
4042 0 (match-beginning 2))
4043 (substring (mail-header-subject header)
4044 (match-end 2))))))))
4046 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4047 "Select newsgroup GROUP.
4048 If READ-ALL is non-nil, all articles in the group are selected.
4049 If SELECT-ARTICLES, only select those articles from GROUP."
4050 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4051 ;;!!! Dirty hack; should be removed.
4052 (gnus-summary-ignore-duplicates
4053 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4055 gnus-summary-ignore-duplicates))
4056 (info (nth 2 entry))
4057 articles fetched-articles cached)
4059 (unless (gnus-check-server
4060 (setq gnus-current-select-method
4061 (gnus-find-method-for-group group)))
4062 (error "Couldn't open server"))
4064 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4065 (gnus-activate-group group) ; Or we can activate it...
4066 (progn ; Or we bug out.
4067 (when (equal major-mode 'gnus-summary-mode)
4068 (kill-buffer (current-buffer)))
4069 (error "Couldn't request group %s: %s"
4070 group (gnus-status-message group))))
4072 (unless (gnus-request-group group t)
4073 (when (equal major-mode 'gnus-summary-mode)
4074 (kill-buffer (current-buffer)))
4075 (error "Couldn't request group %s: %s"
4076 group (gnus-status-message group)))
4078 (setq gnus-newsgroup-name group)
4079 (setq gnus-newsgroup-unselected nil)
4080 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4081 (gnus-summary-setup-default-charset)
4083 ;; Adjust and set lists of article marks.
4085 (gnus-adjust-marked-articles info))
4087 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4088 (when (gnus-virtual-group-p group)
4089 (setq cached gnus-newsgroup-cached))
4091 (setq gnus-newsgroup-unreads
4092 (gnus-set-difference
4093 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4094 gnus-newsgroup-dormant))
4096 (setq gnus-newsgroup-processable nil)
4098 (gnus-update-read-articles group gnus-newsgroup-unreads)
4100 (if (setq articles select-articles)
4101 (setq gnus-newsgroup-unselected
4102 (gnus-sorted-intersection
4103 gnus-newsgroup-unreads
4104 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4105 (setq articles (gnus-articles-to-read group read-all)))
4109 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4111 ((eq articles 0) nil)
4113 ;; Init the dependencies hash table.
4114 (setq gnus-newsgroup-dependencies
4115 (gnus-make-hashtable (length articles)))
4116 (gnus-set-global-variables)
4117 ;; Retrieve the headers and read them in.
4118 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
4119 (setq gnus-newsgroup-headers
4121 (setq gnus-headers-retrieved-by
4122 (gnus-retrieve-headers
4123 articles gnus-newsgroup-name
4124 ;; We might want to fetch old headers, but
4125 ;; not if there is only 1 article.
4127 (not (eq gnus-fetch-old-headers 'some))
4128 (not (numberp gnus-fetch-old-headers)))
4129 (> (length articles) 1))
4130 gnus-fetch-old-headers))))
4131 (gnus-get-newsgroup-headers-xover
4132 articles nil nil gnus-newsgroup-name t)
4133 (gnus-get-newsgroup-headers)))
4134 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
4136 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4138 (setq gnus-newsgroup-cached cached))
4140 ;; Suppress duplicates?
4141 (when gnus-suppress-duplicates
4142 (gnus-dup-suppress-articles))
4144 ;; Set the initial limit.
4145 (setq gnus-newsgroup-limit (copy-sequence articles))
4146 ;; Remove canceled articles from the list of unread articles.
4147 (setq gnus-newsgroup-unreads
4148 (gnus-set-sorted-intersection
4149 gnus-newsgroup-unreads
4150 (setq fetched-articles
4151 (mapcar (lambda (headers) (mail-header-number headers))
4152 gnus-newsgroup-headers))))
4153 ;; Removed marked articles that do not exist.
4154 (gnus-update-missing-marks
4155 (gnus-sorted-complement fetched-articles articles))
4156 ;; We might want to build some more threads first.
4157 (when (and gnus-fetch-old-headers
4158 (eq gnus-headers-retrieved-by 'nov))
4159 (if (eq gnus-fetch-old-headers 'invisible)
4160 (gnus-build-all-threads)
4161 (gnus-build-old-threads)))
4162 ;; Let the Gnus agent mark articles as read.
4164 (gnus-agent-get-undownloaded-list))
4165 ;; Remove list identifiers from subject
4166 (when gnus-list-identifiers
4167 (gnus-summary-remove-list-identifiers))
4168 ;; Check whether auto-expire is to be done in this group.
4169 (setq gnus-newsgroup-auto-expire
4170 (gnus-group-auto-expirable-p group))
4171 ;; Set up the article buffer now, if necessary.
4172 (unless gnus-single-article-buffer
4173 (gnus-article-setup-buffer))
4174 ;; First and last article in this newsgroup.
4175 (when gnus-newsgroup-headers
4176 (setq gnus-newsgroup-begin
4177 (mail-header-number (car gnus-newsgroup-headers))
4180 (gnus-last-element gnus-newsgroup-headers))))
4181 ;; GROUP is successfully selected.
4182 (or gnus-newsgroup-headers t)))))
4184 (defun gnus-articles-to-read (group &optional read-all)
4185 ;; Find out what articles the user wants to read.
4187 ;; Select all articles if `read-all' is non-nil, or if there
4188 ;; are no unread articles.
4190 (and (zerop (length gnus-newsgroup-marked))
4191 (zerop (length gnus-newsgroup-unreads)))
4192 (eq (gnus-group-find-parameter group 'display)
4195 (gnus-uncompress-range (gnus-active group))
4196 (gnus-cache-articles-in-group group))
4197 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4198 (copy-sequence gnus-newsgroup-unreads))
4200 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4201 (scored (length scored-list))
4202 (number (length articles))
4203 (marked (+ (length gnus-newsgroup-marked)
4204 (length gnus-newsgroup-dormant)))
4212 ((and (or (<= scored marked) (= scored number))
4213 (numberp gnus-large-newsgroup)
4214 (> number gnus-large-newsgroup))
4218 "How many articles from %s (default %d): "
4219 (gnus-limit-string gnus-newsgroup-name 35)
4221 (if (string-match "^[ \t]*$" input) number input)))
4222 ((and (> scored marked) (< scored number)
4223 (> (- scored number) 20))
4226 (format "%s %s (%d scored, %d total): "
4227 "How many articles from"
4228 group scored number))))
4229 (if (string-match "^[ \t]*$" input)
4233 (setq select (if (stringp select) (string-to-number select) select))
4234 (if (or (null select) (zerop select))
4236 (if (and (not (zerop scored)) (<= (abs select) scored))
4238 (setq articles (sort scored-list '<))
4239 (setq number (length articles)))
4240 (setq articles (copy-sequence articles)))
4242 (when (< (abs select) number)
4244 ;; Select the N oldest articles.
4245 (setcdr (nthcdr (1- (abs select)) articles) nil)
4246 ;; Select the N most recent articles.
4247 (setq articles (nthcdr (- number select) articles))))
4248 (setq gnus-newsgroup-unselected
4249 (gnus-sorted-intersection
4250 gnus-newsgroup-unreads
4251 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4254 (defun gnus-killed-articles (killed articles)
4257 (when (inline (gnus-member-of-range (car articles) killed))
4258 (push (car articles) out))
4259 (setq articles (cdr articles)))
4262 (defun gnus-uncompress-marks (marks)
4263 "Uncompress the mark ranges in MARKS."
4264 (let ((uncompressed '(score bookmark))
4267 (if (memq (caar marks) uncompressed)
4268 (push (car marks) out)
4269 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4270 (setq marks (cdr marks)))
4273 (defun gnus-adjust-marked-articles (info)
4274 "Set all article lists and remove all marks that are no longer valid."
4275 (let* ((marked-lists (gnus-info-marks info))
4276 (active (gnus-active (gnus-info-group info)))
4279 (types gnus-article-mark-lists)
4280 (uncompressed '(score bookmark killed))
4281 marks var articles article mark)
4284 (setq marks (pop marked-lists))
4285 (set (setq var (intern (format "gnus-newsgroup-%s"
4286 (car (rassq (setq mark (car marks))
4288 (if (memq (car marks) uncompressed) (cdr marks)
4289 (gnus-uncompress-range (cdr marks))))
4291 (setq articles (symbol-value var))
4293 ;; All articles have to be subsets of the active articles.
4295 ;; Adjust "simple" lists.
4296 ((memq mark '(tick dormant expire reply save))
4298 (when (or (< (setq article (pop articles)) min) (> article max))
4299 (set var (delq article (symbol-value var))))))
4301 ((memq mark uncompressed)
4302 (when (not (listp (cdr (symbol-value var))))
4303 (set var (list (symbol-value var))))
4304 (when (not (listp (cdr articles)))
4305 (setq articles (list articles)))
4307 (when (or (not (consp (setq article (pop articles))))
4308 (< (car article) min)
4309 (> (car article) max))
4310 (set var (delq article (symbol-value var))))))))))
4312 (defun gnus-update-missing-marks (missing)
4313 "Go through the list of MISSING articles and remove them from the mark lists."
4315 (let ((types gnus-article-mark-lists)
4317 ;; Go through all types.
4319 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4320 (when (symbol-value var)
4321 ;; This list has articles. So we delete all missing articles
4325 (set var (delq (pop m) (symbol-value var)))))))))
4327 (defun gnus-update-marks ()
4328 "Enter the various lists of marked articles into the newsgroup info list."
4329 (let ((types gnus-article-mark-lists)
4330 (info (gnus-get-info gnus-newsgroup-name))
4331 (uncompressed '(score bookmark killed))
4332 type list newmarked symbol delta-marks)
4334 ;; Add all marks lists to the list of marks lists.
4335 (while (setq type (pop types))
4336 (setq list (symbol-value
4338 (intern (format "gnus-newsgroup-%s"
4342 ;; Get rid of the entries of the articles that have the
4344 (when (and (eq (cdr type) 'score)
4348 (prev (cons nil list))
4351 (if (or (not (consp (car arts)))
4352 (= (cdar arts) gnus-summary-default-score))
4353 (setcdr prev (cdr arts))
4355 (setq arts (cdr arts)))
4356 (setq list (cdr all)))))
4358 (or (memq (cdr type) uncompressed)
4359 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
4361 (when (gnus-check-backend-function 'request-set-mark
4362 gnus-newsgroup-name)
4363 ;; uncompressed:s are not proper flags (they are cons cells)
4364 ;; cache is a internal gnus flag
4365 (unless (memq (cdr type) (cons 'cache uncompressed))
4366 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4367 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
4368 (add (gnus-remove-from-range (gnus-copy-sequence list) old)))
4370 (push (list add 'add (list (cdr type))) delta-marks))
4372 (push (list del 'del (list (cdr type))) delta-marks)))))
4375 (push (cons (cdr type) list) newmarked)))
4378 (unless (gnus-check-group gnus-newsgroup-name)
4379 (error "Can't open server for %s" gnus-newsgroup-name))
4380 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4382 ;; Enter these new marks into the info of the group.
4384 (setcar (nthcdr 3 info) newmarked)
4385 ;; Add the marks lists to the end of the info.
4387 (setcdr (nthcdr 2 info) (list newmarked))))
4389 ;; Cut off the end of the info if there's nothing else there.
4393 (when (nthcdr (decf i) info)
4394 (setcdr (nthcdr i info) nil)))))))
4396 (defun gnus-set-mode-line (where)
4397 "This function sets the mode line of the article or summary buffers.
4398 If WHERE is `summary', the summary mode line format will be used."
4399 ;; Is this mode line one we keep updated?
4400 (when (and (memq where gnus-updated-mode-lines)
4402 (intern (format "gnus-%s-mode-line-format-spec" where))))
4405 ;; We evaluate this in the summary buffer since these
4406 ;; variables are buffer-local to that buffer.
4407 (set-buffer gnus-summary-buffer)
4408 ;; We bind all these variables that are used in the `eval' form
4410 (let* ((mformat (symbol-value
4412 (format "gnus-%s-mode-line-format-spec" where))))
4413 (gnus-tmp-group-name gnus-newsgroup-name)
4414 (gnus-tmp-article-number (or gnus-current-article 0))
4415 (gnus-tmp-unread gnus-newsgroup-unreads)
4416 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4417 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4418 (gnus-tmp-unread-and-unselected
4419 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4420 (zerop gnus-tmp-unselected))
4422 ((zerop gnus-tmp-unselected)
4423 (format "{%d more}" gnus-tmp-unread-and-unticked))
4424 (t (format "{%d(+%d) more}"
4425 gnus-tmp-unread-and-unticked
4426 gnus-tmp-unselected))))
4428 (if (and gnus-current-headers
4429 (vectorp gnus-current-headers))
4430 (gnus-mode-string-quote
4431 (mail-header-subject gnus-current-headers))
4433 bufname-length max-len
4434 gnus-tmp-header);; passed as argument to any user-format-funcs
4435 (setq mode-string (eval mformat))
4436 (setq bufname-length (if (string-match "%b" mode-string)
4439 (if (eq where 'summary)
4441 (get-buffer gnus-article-buffer))))
4444 (setq max-len (max 4 (if gnus-mode-non-string-length
4446 gnus-mode-non-string-length
4448 (length mode-string))))
4449 ;; We might have to chop a bit of the string off...
4450 (when (> (length mode-string) max-len)
4452 (concat (truncate-string-to-width mode-string (- max-len 3))
4454 ;; Pad the mode string a bit.
4455 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4456 ;; Update the mode line.
4457 (setq mode-line-buffer-identification
4458 (gnus-mode-line-buffer-identification (list mode-string)))
4459 (set-buffer-modified-p t))))
4461 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4462 "Go through the HEADERS list and add all Xrefs to a hash table.
4463 The resulting hash table is returned, or nil if no Xrefs were found."
4464 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4465 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4466 (xref-hashtb (gnus-make-hashtable))
4467 start group entry number xrefs header)
4469 (setq header (pop headers))
4470 (when (and (setq xrefs (mail-header-xref header))
4471 (not (memq (setq number (mail-header-number header))
4474 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4475 (setq start (match-end 0))
4476 (setq group (if prefix
4477 (concat prefix (substring xrefs (match-beginning 1)
4479 (substring xrefs (match-beginning 1) (match-end 1))))
4481 (string-to-int (substring xrefs (match-beginning 2)
4483 (if (setq entry (gnus-gethash group xref-hashtb))
4484 (setcdr entry (cons number (cdr entry)))
4485 (gnus-sethash group (cons number nil) xref-hashtb)))))
4486 (and start xref-hashtb)))
4488 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4489 "Look through all the headers and mark the Xrefs as read."
4490 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4491 name entry info xref-hashtb idlist method nth4)
4493 (set-buffer gnus-group-buffer)
4494 (when (setq xref-hashtb
4495 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4498 (unless (string= from-newsgroup (setq name (symbol-name group)))
4499 (setq idlist (symbol-value group))
4500 ;; Dead groups are not updated.
4502 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4504 (when (stringp (setq nth4 (gnus-info-method info)))
4505 (setq nth4 (gnus-server-to-method nth4))))
4506 ;; Only do the xrefs if the group has the same
4507 ;; select method as the group we have just read.
4508 (or (gnus-methods-equal-p
4509 nth4 (gnus-find-method-for-group from-newsgroup))
4511 (equal nth4 (setq method (gnus-find-method-for-group
4513 (and (equal (car nth4) (car method))
4514 (equal (nth 1 nth4) (nth 1 method))))
4515 gnus-use-cross-reference
4516 (or (not (eq gnus-use-cross-reference t))
4518 ;; Only do cross-references on subscribed
4519 ;; groups, if that is what is wanted.
4520 (<= (gnus-info-level info) gnus-level-subscribed))
4521 (gnus-group-make-articles-read name idlist))))
4524 (defun gnus-compute-read-articles (group articles)
4525 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4526 (info (nth 2 entry))
4527 (active (gnus-active group))
4530 ;; First peel off all invalid article numbers.
4532 (let ((ids articles)
4534 (while (setq id (pop ids))
4535 (when (and first (> id (cdr active)))
4536 ;; We'll end up in this situation in one particular
4537 ;; obscure situation. If you re-scan a group and get
4538 ;; a new article that is cross-posted to a different
4539 ;; group that has not been re-scanned, you might get
4540 ;; crossposted article that has a higher number than
4541 ;; Gnus believes possible. So we re-activate this
4542 ;; group as well. This might mean doing the
4543 ;; crossposting thingy will *increase* the number
4544 ;; of articles in some groups. Tsk, tsk.
4545 (setq active (or (gnus-activate-group group) active)))
4546 (when (or (> id (cdr active))
4547 (< id (car active)))
4548 (setq articles (delq id articles))))))
4549 ;; If the read list is nil, we init it.
4551 (null (gnus-info-read info))
4553 (setq ninfo (cons 1 (1- (car active))))
4554 (setq ninfo (gnus-info-read info)))
4555 ;; Then we add the read articles to the range.
4557 ninfo (setq articles (sort articles '<))))))
4559 (defun gnus-group-make-articles-read (group articles)
4560 "Update the info of GROUP to say that ARTICLES are read."
4562 (entry (gnus-gethash group gnus-newsrc-hashtb))
4563 (info (nth 2 entry))
4564 (active (gnus-active group))
4567 (setq range (gnus-compute-read-articles group articles))
4569 (set-buffer gnus-group-buffer)
4572 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4573 (gnus-info-set-read ',info ',(gnus-info-read info))
4574 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4575 (gnus-group-update-group ,group t))))
4576 ;; Add the read articles to the range.
4577 (gnus-info-set-read info range)
4578 ;; Then we have to re-compute how many unread
4579 ;; articles there are in this group.
4583 (setq num (- (1+ (cdr active)) (car active))))
4584 ((not (listp (cdr range)))
4585 (setq num (- (cdr active) (- (1+ (cdr range))
4589 (if (numberp (car range))
4591 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4592 (setq range (cdr range)))
4593 (setq num (- (cdr active) num))))
4594 ;; Update the number of unread articles.
4596 ;; Update the group buffer.
4597 (gnus-group-update-group group t)))))
4599 (defvar gnus-newsgroup-none-id 0)
4601 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4602 (let ((cur nntp-server-buffer)
4605 (save-excursion (set-buffer gnus-summary-buffer)
4606 gnus-newsgroup-dependencies)))
4608 (mail-parse-charset gnus-newsgroup-charset)
4609 (mail-parse-ignored-charsets
4610 (save-excursion (condition-case nil
4611 (set-buffer gnus-summary-buffer)
4613 gnus-newsgroup-ignored-charsets)))
4615 (set-buffer nntp-server-buffer)
4616 ;; Translate all TAB characters into SPACE characters.
4617 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4618 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4619 (gnus-run-hooks 'gnus-parse-headers-hook)
4620 (let ((case-fold-search t)
4621 in-reply-to header p lines chars)
4622 (goto-char (point-min))
4623 ;; Search to the beginning of the next header. Error messages
4624 ;; do not begin with 2 or 3.
4625 (while (re-search-forward "^[23][0-9]+ " nil t)
4628 ;; This implementation of this function, with nine
4629 ;; search-forwards instead of the one re-search-forward and
4630 ;; a case (which basically was the old function) is actually
4631 ;; about twice as fast, even though it looks messier. You
4632 ;; can't have everything, I guess. Speed and elegance
4633 ;; doesn't always go hand in hand.
4642 (narrow-to-region (point)
4643 (or (and (search-forward "\n.\n" nil t)
4649 (if (search-forward "\nsubject: " nil t)
4650 (funcall gnus-decode-encoded-word-function
4651 (nnheader-header-value))
4656 (if (search-forward "\nfrom: " nil t)
4657 (funcall gnus-decode-encoded-word-function
4658 (nnheader-header-value))
4663 (if (search-forward "\ndate: " nil t)
4664 (nnheader-header-value) ""))
4668 (setq id (if (re-search-forward
4669 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4670 ;; We do it this way to make sure the Message-ID
4671 ;; is (somewhat) syntactically valid.
4672 (buffer-substring (match-beginning 1)
4674 ;; If there was no message-id, we just fake one
4675 ;; to make subsequent routines simpler.
4676 (nnheader-generate-fake-message-id))))
4680 (if (search-forward "\nreferences: " nil t)
4684 (nnheader-header-value)
4689 (search-backward ">" end t)
4692 (search-backward "<" end t)
4694 ;; Get the references from the in-reply-to header if there
4695 ;; were no references and the in-reply-to header looks
4697 (if (and (search-forward "\nin-reply-to: " nil t)
4698 (setq in-reply-to (nnheader-header-value))
4699 (string-match "<[^>]+>" in-reply-to))
4701 (setq ref (substring in-reply-to (match-beginning 0)
4703 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4704 (setq ref2 (substring in-reply-to (match-beginning 0)
4706 (when (> (length ref2) (length ref))
4713 (if (search-forward "\nchars: " nil t)
4714 (if (numberp (setq chars (ignore-errors (read cur))))
4720 (if (search-forward "\nlines: " nil t)
4721 (if (numberp (setq lines (ignore-errors (read cur))))
4727 (and (search-forward "\nxref: " nil t)
4728 (nnheader-header-value)))
4730 (when gnus-extra-headers
4731 (let ((extra gnus-extra-headers)
4735 (when (search-forward
4736 (concat "\n" (symbol-name (car extra)) ": ") nil t)
4737 (push (cons (car extra) (nnheader-header-value))
4741 (when (equal id ref)
4744 (when gnus-alter-header-function
4745 (funcall gnus-alter-header-function header)
4746 (setq id (mail-header-id header)
4747 ref (gnus-parent-id (mail-header-references header))))
4750 (gnus-dependencies-add-header
4751 header dependencies force-new))
4752 (push header headers))
4753 (goto-char (point-max))
4755 (nreverse headers)))))
4757 ;; Goes through the xover lines and returns a list of vectors
4758 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4759 force-new dependencies
4760 group also-fetch-heads)
4761 "Parse the news overview data in the server buffer, and return a
4762 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4763 ;; Get the Xref when the users reads the articles since most/some
4764 ;; NNTP servers do not include Xrefs when using XOVER.
4765 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4766 (let ((mail-parse-charset gnus-newsgroup-charset)
4767 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
4768 (cur nntp-server-buffer)
4769 (dependencies (or dependencies gnus-newsgroup-dependencies))
4770 number headers header)
4772 (set-buffer nntp-server-buffer)
4773 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4774 ;; Allow the user to mangle the headers before parsing them.
4775 (gnus-run-hooks 'gnus-parse-headers-hook)
4776 (goto-char (point-min))
4779 (while (and sequence (not (eobp)))
4780 (setq number (read cur))
4781 (while (and sequence
4782 (< (car sequence) number))
4783 (setq sequence (cdr sequence)))
4785 (eq number (car sequence))
4787 (setq sequence (cdr sequence))
4788 (setq header (inline
4789 (gnus-nov-parse-line
4790 number dependencies force-new))))
4791 (push header headers))
4794 (gnus-error 4 "Strange nov line (%d)"
4795 (count-lines (point-min) (point)))))
4797 ;; A common bug in inn is that if you have posted an article and
4798 ;; then retrieves the active file, it will answer correctly --
4799 ;; the new article is included. However, a NOV entry for the
4800 ;; article may not have been generated yet, so this may fail.
4801 ;; We work around this problem by retrieving the last few
4802 ;; headers using HEAD.
4803 (if (or (not also-fetch-heads)
4805 ;; We (probably) got all the headers.
4807 (let ((gnus-nov-is-evil t))
4810 (when (gnus-retrieve-headers sequence group)
4811 (gnus-get-newsgroup-headers))))))))
4813 (defun gnus-article-get-xrefs ()
4814 "Fill in the Xref value in `gnus-current-headers', if necessary.
4815 This is meant to be called in `gnus-article-internal-prepare-hook'."
4816 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4817 gnus-current-headers)))
4818 (or (not gnus-use-cross-reference)
4820 (and (mail-header-xref headers)
4821 (not (string= (mail-header-xref headers) "")))
4822 (let ((case-fold-search t)
4825 (nnheader-narrow-to-headers)
4826 (goto-char (point-min))
4827 (when (or (and (not (eobp))
4828 (eq (downcase (char-after)) ?x)
4829 (looking-at "Xref:"))
4830 (search-forward "\nXref:" nil t))
4831 (goto-char (1+ (match-end 0)))
4832 (setq xref (buffer-substring (point)
4833 (progn (end-of-line) (point))))
4834 (mail-header-set-xref headers xref)))))))
4836 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4837 "Find article ID and insert the summary line for that article.
4838 OLD-HEADER can either be a header or a line number to insert
4839 the subject line on."
4840 (let* ((line (and (numberp old-header) old-header))
4841 (old-header (and (vectorp old-header) old-header))
4842 (header (cond ((and old-header use-old-header)
4845 (gnus-number-to-header id))
4846 (gnus-number-to-header id))
4848 (gnus-read-header id))))
4849 (number (and (numberp id) id))
4852 ;; Rebuild the thread that this article is part of and go to the
4853 ;; article we have fetched.
4854 (when (and (not gnus-show-threads)
4857 (setq d (gnus-data-find (mail-header-number old-header))))
4858 (goto-char (gnus-data-pos d))
4861 (- (gnus-point-at-bol)
4863 (1+ (gnus-point-at-eol))
4864 (gnus-delete-line))))))
4866 (mail-header-set-number header (mail-header-number old-header)))
4867 (setq gnus-newsgroup-sparse
4868 (delq (setq number (mail-header-number header))
4869 gnus-newsgroup-sparse))
4870 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4871 (push number gnus-newsgroup-limit)
4872 (gnus-rebuild-thread (mail-header-id header) line)
4873 (gnus-summary-goto-subject number nil t))
4874 (when (and (numberp number)
4876 ;; We have to update the boundaries even if we can't fetch the
4877 ;; article if ID is a number -- so that the next `P' or `N'
4878 ;; command will fetch the previous (or next) article even
4879 ;; if the one we tried to fetch this time has been canceled.
4880 (when (> number gnus-newsgroup-end)
4881 (setq gnus-newsgroup-end number))
4882 (when (< number gnus-newsgroup-begin)
4883 (setq gnus-newsgroup-begin number))
4884 (setq gnus-newsgroup-unselected
4885 (delq number gnus-newsgroup-unselected)))
4886 ;; Report back a success?
4887 (and header (mail-header-number header))))
4889 ;;; Process/prefix in the summary buffer
4891 (defun gnus-summary-work-articles (n)
4892 "Return a list of articles to be worked upon.
4893 The prefix argument, the list of process marked articles, and the
4894 current article will be taken into consideration."
4896 (set-buffer gnus-summary-buffer)
4899 ;; A numerical prefix has been given.
4900 (setq n (prefix-numeric-value n))
4901 (let ((backward (< n 0))
4902 (n (abs (prefix-numeric-value n)))
4907 (push (setq article (gnus-summary-article-number))
4910 (gnus-summary-find-prev nil article)
4911 (gnus-summary-find-next nil article)))
4913 (nreverse articles)))
4914 ((and (gnus-region-active-p) (mark))
4915 (message "region active")
4916 ;; Work on the region between point and mark.
4917 (let ((max (max (point) (mark)))
4920 (goto-char (min (min (point) (mark))))
4923 (push (setq article (gnus-summary-article-number)) articles)
4924 (gnus-summary-find-next nil article)
4926 (nreverse articles))))
4927 (gnus-newsgroup-processable
4928 ;; There are process-marked articles present.
4929 ;; Save current state.
4930 (gnus-summary-save-process-mark)
4932 (reverse gnus-newsgroup-processable))
4934 ;; Just return the current article.
4935 (list (gnus-summary-article-number))))))
4937 (defmacro gnus-summary-iterate (arg &rest forms)
4938 "Iterate over the process/prefixed articles and do FORMS.
4939 ARG is the interactive prefix given to the command. FORMS will be
4940 executed with point over the summary line of the articles."
4941 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
4942 `(let ((,articles (gnus-summary-work-articles ,arg)))
4944 (gnus-summary-goto-subject (car ,articles))
4948 (put 'gnus-summary-iterate 'lisp-indent-function 1)
4949 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
4951 (defun gnus-summary-save-process-mark ()
4952 "Push the current set of process marked articles on the stack."
4954 (push (copy-sequence gnus-newsgroup-processable)
4955 gnus-newsgroup-process-stack))
4957 (defun gnus-summary-kill-process-mark ()
4958 "Push the current set of process marked articles on the stack and unmark."
4960 (gnus-summary-save-process-mark)
4961 (gnus-summary-unmark-all-processable))
4963 (defun gnus-summary-yank-process-mark ()
4964 "Pop the last process mark state off the stack and restore it."
4966 (unless gnus-newsgroup-process-stack
4967 (error "Empty mark stack"))
4968 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4970 (defun gnus-summary-process-mark-set (set)
4971 "Make SET into the current process marked articles."
4972 (gnus-summary-unmark-all-processable)
4974 (gnus-summary-set-process-mark (pop set))))
4976 ;;; Searching and stuff
4978 (defun gnus-summary-search-group (&optional backward use-level)
4979 "Search for next unread newsgroup.
4980 If optional argument BACKWARD is non-nil, search backward instead."
4982 (set-buffer gnus-group-buffer)
4983 (when (gnus-group-search-forward
4984 backward nil (if use-level (gnus-group-group-level) nil))
4985 (gnus-group-group-name))))
4987 (defun gnus-summary-best-group (&optional exclude-group)
4988 "Find the name of the best unread group.
4989 If EXCLUDE-GROUP, do not go to this group."
4991 (set-buffer gnus-group-buffer)
4993 (gnus-group-best-unread-group exclude-group))))
4995 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
4996 (if backward (gnus-summary-find-prev)
4997 (let* ((dummy (gnus-summary-article-intangible-p))
4998 (article (or article (gnus-summary-article-number)))
4999 (arts (gnus-data-find-list article))
5001 (when (and (not dummy)
5002 (or (not gnus-summary-check-current)
5004 (not (gnus-data-unread-p (car arts)))))
5005 (setq arts (cdr arts)))
5010 (when (or (and undownloaded
5011 (eq gnus-undownloaded-mark
5012 (gnus-data-mark (car arts))))
5013 (gnus-data-unread-p (car arts)))
5014 (setq result (car arts)
5016 (setq arts (cdr arts)))
5019 (goto-char (gnus-data-pos result))
5020 (gnus-data-number result)))))
5022 (defun gnus-summary-find-prev (&optional unread article)
5023 (let* ((eobp (eobp))
5024 (article (or article (gnus-summary-article-number)))
5025 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5027 (when (and (not eobp)
5028 (or (not gnus-summary-check-current)
5030 (not (gnus-data-unread-p (car arts)))))
5031 (setq arts (cdr arts)))
5036 (when (gnus-data-unread-p (car arts))
5037 (setq result (car arts)
5039 (setq arts (cdr arts)))
5042 (goto-char (gnus-data-pos result))
5043 (gnus-data-number result))))
5045 (defun gnus-summary-find-subject (subject &optional unread backward article)
5046 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5047 (article (or article (gnus-summary-article-number)))
5048 (articles (gnus-data-list backward))
5049 (arts (gnus-data-find-list article articles))
5051 (when (or (not gnus-summary-check-current)
5053 (not (gnus-data-unread-p (car arts))))
5054 (setq arts (cdr arts)))
5056 (and (or (not unread)
5057 (gnus-data-unread-p (car arts)))
5058 (vectorp (gnus-data-header (car arts)))
5060 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5061 (setq result (car arts)
5063 (setq arts (cdr arts)))
5065 (goto-char (gnus-data-pos result))
5066 (gnus-data-number result))))
5068 (defun gnus-summary-search-forward (&optional unread subject backward)
5069 "Search forward for an article.
5070 If UNREAD, look for unread articles. If SUBJECT, look for
5071 articles with that subject. If BACKWARD, search backward instead."
5072 (cond (subject (gnus-summary-find-subject subject unread backward))
5073 (backward (gnus-summary-find-prev unread))
5074 (t (gnus-summary-find-next unread))))
5076 (defun gnus-recenter (&optional n)
5077 "Center point in window and redisplay frame.
5078 Also do horizontal recentering."
5080 (when (and gnus-auto-center-summary
5081 (not (eq gnus-auto-center-summary 'vertical)))
5082 (gnus-horizontal-recenter))
5085 (defun gnus-summary-recenter ()
5086 "Center point in the summary window.
5087 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5088 displayed, no centering will be performed."
5089 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5090 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5091 (let* ((top (cond ((< (window-height) 4) 0)
5092 ((< (window-height) 7) 1)
5093 (t (if (numberp gnus-auto-center-summary)
5094 gnus-auto-center-summary
5096 (height (1- (window-height)))
5097 (bottom (save-excursion (goto-char (point-max))
5098 (forward-line (- height))
5100 (window (get-buffer-window (current-buffer))))
5101 ;; The user has to want it.
5102 (when gnus-auto-center-summary
5103 (when (get-buffer-window gnus-article-buffer)
5104 ;; Only do recentering when the article buffer is displayed,
5105 ;; Set the window start to either `bottom', which is the biggest
5106 ;; possible valid number, or the second line from the top,
5107 ;; whichever is the least.
5109 window (min bottom (save-excursion
5110 (forward-line (- top)) (point)))
5112 ;; Do horizontal recentering while we're at it.
5113 (when (and (get-buffer-window (current-buffer) t)
5114 (not (eq gnus-auto-center-summary 'vertical)))
5115 (let ((selected (selected-window)))
5116 (select-window (get-buffer-window (current-buffer) t))
5117 (gnus-summary-position-point)
5118 (gnus-horizontal-recenter)
5119 (select-window selected))))))
5121 (defun gnus-summary-jump-to-group (newsgroup)
5122 "Move point to NEWSGROUP in group mode buffer."
5123 ;; Keep update point of group mode buffer if visible.
5124 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5125 (save-window-excursion
5126 ;; Take care of tree window mode.
5127 (when (get-buffer-window gnus-group-buffer)
5128 (pop-to-buffer gnus-group-buffer))
5129 (gnus-group-jump-to-group newsgroup))
5131 ;; Take care of tree window mode.
5132 (if (get-buffer-window gnus-group-buffer)
5133 (pop-to-buffer gnus-group-buffer)
5134 (set-buffer gnus-group-buffer))
5135 (gnus-group-jump-to-group newsgroup))))
5137 ;; This function returns a list of article numbers based on the
5138 ;; difference between the ranges of read articles in this group and
5139 ;; the range of active articles.
5140 (defun gnus-list-of-unread-articles (group)
5141 (let* ((read (gnus-info-read (gnus-get-info group)))
5142 (active (or (gnus-active group) (gnus-activate-group group)))
5145 ;; If none are read, then all are unread.
5147 (setq first (car active))
5148 ;; If the range of read articles is a single range, then the
5149 ;; first unread article is the article after the last read
5150 ;; article. Sounds logical, doesn't it?
5151 (if (not (listp (cdr read)))
5152 (setq first (max (car active) (1+ (cdr read))))
5153 ;; `read' is a list of ranges.
5154 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5157 (setq first (car active)))
5160 (while (< first nlast)
5162 (setq first (1+ first))))
5163 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5164 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5165 (setq read (cdr read)))))
5166 ;; And add the last unread articles.
5167 (while (<= first last)
5169 (setq first (1+ first)))
5170 ;; Return the list of unread articles.
5171 (delq 0 (nreverse unread))))
5173 (defun gnus-list-of-read-articles (group)
5174 "Return a list of unread, unticked and non-dormant articles."
5175 (let* ((info (gnus-get-info group))
5176 (marked (gnus-info-marks info))
5177 (active (gnus-active group)))
5179 (gnus-set-difference
5180 (gnus-sorted-complement
5181 (gnus-uncompress-range active)
5182 (gnus-list-of-unread-articles group))
5184 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5185 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5187 ;; Various summary commands
5189 (defun gnus-summary-select-article-buffer ()
5190 "Reconfigure windows to show article buffer."
5192 (if (not (gnus-buffer-live-p gnus-article-buffer))
5193 (error "There is no article buffer for this summary buffer")
5194 (gnus-configure-windows 'article)
5195 (select-window (get-buffer-window gnus-article-buffer))))
5197 (defun gnus-summary-universal-argument (arg)
5198 "Perform any operation on all articles that are process/prefixed."
5200 (let ((articles (gnus-summary-work-articles arg))
5207 (substitute-command-keys
5208 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
5211 (gnus-error 1 "Undefined key")
5214 (gnus-summary-goto-subject (setq article (pop articles)))
5215 (let (gnus-newsgroup-processable)
5216 (command-execute func))
5217 (gnus-summary-remove-process-mark article)))))
5218 (gnus-summary-position-point))
5220 (defun gnus-summary-toggle-truncation (&optional arg)
5221 "Toggle truncation of summary lines.
5222 With arg, turn line truncation on iff arg is positive."
5224 (setq truncate-lines
5225 (if (null arg) (not truncate-lines)
5226 (> (prefix-numeric-value arg) 0)))
5229 (defun gnus-summary-reselect-current-group (&optional all rescan)
5230 "Exit and then reselect the current newsgroup.
5231 The prefix argument ALL means to select all articles."
5233 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5234 (error "Ephemeral groups can't be reselected"))
5235 (let ((current-subject (gnus-summary-article-number))
5236 (group gnus-newsgroup-name))
5237 (setq gnus-newsgroup-begin nil)
5239 ;; We have to adjust the point of group mode buffer because
5240 ;; point was moved to the next unread newsgroup by exiting.
5241 (gnus-summary-jump-to-group group)
5244 (gnus-group-get-new-news-this-group 1)))
5245 (gnus-group-read-group all t)
5246 (gnus-summary-goto-subject current-subject nil t)))
5248 (defun gnus-summary-rescan-group (&optional all)
5249 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5251 (gnus-summary-reselect-current-group all t))
5253 (defun gnus-summary-update-info (&optional non-destructive)
5255 (let ((group gnus-newsgroup-name))
5257 (when gnus-newsgroup-kill-headers
5258 (setq gnus-newsgroup-killed
5259 (gnus-compress-sequence
5261 (gnus-set-sorted-intersection
5262 (gnus-uncompress-range gnus-newsgroup-killed)
5263 (setq gnus-newsgroup-unselected
5264 (sort gnus-newsgroup-unselected '<)))
5265 (setq gnus-newsgroup-unreads
5266 (sort gnus-newsgroup-unreads '<)))
5268 (unless (listp (cdr gnus-newsgroup-killed))
5269 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5270 (let ((headers gnus-newsgroup-headers))
5271 ;; Set the new ranges of read articles.
5273 (set-buffer gnus-group-buffer)
5274 (gnus-undo-force-boundary))
5275 (gnus-update-read-articles
5276 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5277 ;; Set the current article marks.
5278 (let ((gnus-newsgroup-scored
5279 (if (and (not gnus-save-score)
5280 (not non-destructive))
5282 gnus-newsgroup-scored)))
5284 (gnus-update-marks)))
5285 ;; Do the cross-ref thing.
5286 (when gnus-use-cross-reference
5287 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5288 ;; Do not switch windows but change the buffer to work.
5289 (set-buffer gnus-group-buffer)
5290 (unless (gnus-ephemeral-group-p group)
5291 (gnus-group-update-group group)))))))
5293 (defun gnus-summary-save-newsrc (&optional force)
5294 "Save the current number of read/marked articles in the dribble buffer.
5295 The dribble buffer will then be saved.
5296 If FORCE (the prefix), also save the .newsrc file(s)."
5298 (gnus-summary-update-info t)
5300 (gnus-save-newsrc-file)
5301 (gnus-dribble-save)))
5303 (defun gnus-summary-exit (&optional temporary)
5304 "Exit reading current newsgroup, and then return to group selection mode.
5305 gnus-exit-group-hook is called with no arguments if that value is non-nil."
5307 (gnus-set-global-variables)
5308 (when (gnus-buffer-live-p gnus-article-buffer)
5310 (set-buffer gnus-article-buffer)
5311 (mm-destroy-parts gnus-article-mime-handles)))
5312 (gnus-kill-save-kill-buffer)
5313 (gnus-async-halt-prefetch)
5314 (let* ((group gnus-newsgroup-name)
5315 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5318 (buf (current-buffer)))
5320 ;; Do adaptive scoring, and possibly save score files.
5321 (when gnus-newsgroup-adaptive
5322 (gnus-score-adaptive))
5323 (when gnus-use-scoring
5325 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5326 ;; If we have several article buffers, we kill them at exit.
5327 (unless gnus-single-article-buffer
5328 (gnus-kill-buffer gnus-original-article-buffer)
5329 (setq gnus-article-current nil))
5330 (when gnus-use-cache
5331 (gnus-cache-possibly-remove-articles)
5332 (gnus-cache-save-buffers))
5333 (gnus-async-prefetch-remove-group group)
5334 (when gnus-suppress-duplicates
5335 (gnus-dup-enter-articles))
5336 (when gnus-use-trees
5337 (gnus-tree-close group))
5338 ;; Remove entries for this group.
5339 (nnmail-purge-split-history (gnus-group-real-name group))
5340 ;; Make all changes in this group permanent.
5342 (gnus-run-hooks 'gnus-exit-group-hook)
5343 (gnus-summary-update-info))
5344 (gnus-close-group group)
5345 ;; Make sure where we were, and go to next newsgroup.
5346 (set-buffer gnus-group-buffer)
5348 (gnus-group-jump-to-group group))
5349 (gnus-run-hooks 'gnus-summary-exit-hook)
5350 (unless (or quit-config
5351 ;; If this group has disappeared from the summary
5352 ;; buffer, don't skip forwards.
5353 (not (string= group (gnus-group-group-name))))
5354 (gnus-group-next-unread-group 1))
5355 (setq group-point (point))
5358 ;; If we have several article buffers, we kill them at exit.
5359 (unless gnus-single-article-buffer
5360 (gnus-kill-buffer gnus-article-buffer)
5361 (gnus-kill-buffer gnus-original-article-buffer)
5362 (setq gnus-article-current nil))
5364 (if (not gnus-kill-summary-on-exit)
5365 (gnus-deaden-summary)
5366 ;; We set all buffer-local variables to nil. It is unclear why
5367 ;; this is needed, but if we don't, buffer-local variables are
5368 ;; not garbage-collected, it seems. This would the lead to en
5369 ;; ever-growing Emacs.
5370 (gnus-summary-clear-local-variables)
5371 (when (get-buffer gnus-article-buffer)
5372 (bury-buffer gnus-article-buffer))
5373 ;; We clear the global counterparts of the buffer-local
5374 ;; variables as well, just to be on the safe side.
5375 (set-buffer gnus-group-buffer)
5376 (gnus-summary-clear-local-variables)
5377 ;; Return to group mode buffer.
5378 (when (eq mode 'gnus-summary-mode)
5379 (gnus-kill-buffer buf)))
5380 (setq gnus-current-select-method gnus-select-method)
5381 (pop-to-buffer gnus-group-buffer)
5382 (if (not quit-config)
5384 (goto-char group-point)
5385 (gnus-configure-windows 'group 'force))
5386 (gnus-handle-ephemeral-exit quit-config))
5387 ;; Clear the current group name.
5389 (setq gnus-newsgroup-name nil)))))
5391 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5392 (defun gnus-summary-exit-no-update (&optional no-questions)
5393 "Quit reading current newsgroup without updating read article info."
5395 (let* ((group gnus-newsgroup-name)
5396 (quit-config (gnus-group-quit-config group)))
5397 (when (or no-questions
5399 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5400 (gnus-async-halt-prefetch)
5402 (delq 'gnus-summary-expire-articles
5403 (copy-list gnus-summary-prepare-exit-hook)))
5404 (when (gnus-buffer-live-p gnus-article-buffer)
5406 (set-buffer gnus-article-buffer)
5407 (mm-destroy-parts gnus-article-mime-handles)))
5408 ;; If we have several article buffers, we kill them at exit.
5409 (unless gnus-single-article-buffer
5410 (gnus-kill-buffer gnus-article-buffer)
5411 (gnus-kill-buffer gnus-original-article-buffer)
5412 (setq gnus-article-current nil))
5413 (if (not gnus-kill-summary-on-exit)
5414 (gnus-deaden-summary)
5415 (gnus-close-group group)
5416 (gnus-summary-clear-local-variables)
5417 (set-buffer gnus-group-buffer)
5418 (gnus-summary-clear-local-variables)
5419 (when (get-buffer gnus-summary-buffer)
5420 (kill-buffer gnus-summary-buffer)))
5421 (unless gnus-single-article-buffer
5422 (setq gnus-article-current nil))
5423 (when gnus-use-trees
5424 (gnus-tree-close group))
5425 (gnus-async-prefetch-remove-group group)
5426 (when (get-buffer gnus-article-buffer)
5427 (bury-buffer gnus-article-buffer))
5428 ;; Return to the group buffer.
5429 (gnus-configure-windows 'group 'force)
5430 ;; Clear the current group name.
5431 (setq gnus-newsgroup-name nil)
5432 (when (equal (gnus-group-group-name) group)
5433 (gnus-group-next-unread-group 1))
5435 (gnus-handle-ephemeral-exit quit-config)))))
5437 (defun gnus-handle-ephemeral-exit (quit-config)
5438 "Handle movement when leaving an ephemeral group.
5439 The state which existed when entering the ephemeral is reset."
5440 (if (not (buffer-name (car quit-config)))
5441 (gnus-configure-windows 'group 'force)
5442 (set-buffer (car quit-config))
5443 (cond ((eq major-mode 'gnus-summary-mode)
5444 (gnus-set-global-variables))
5445 ((eq major-mode 'gnus-article-mode)
5447 ;; The `gnus-summary-buffer' variable may point
5448 ;; to the old summary buffer when using a single
5450 (unless (gnus-buffer-live-p gnus-summary-buffer)
5451 (set-buffer gnus-group-buffer))
5452 (set-buffer gnus-summary-buffer)
5453 (gnus-set-global-variables))))
5454 (if (or (eq (cdr quit-config) 'article)
5455 (eq (cdr quit-config) 'pick))
5457 ;; The current article may be from the ephemeral group
5458 ;; thus it is best that we reload this article
5459 (gnus-summary-show-article)
5460 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5461 (gnus-configure-windows 'pick 'force)
5462 (gnus-configure-windows (cdr quit-config) 'force)))
5463 (gnus-configure-windows (cdr quit-config) 'force))
5464 (when (eq major-mode 'gnus-summary-mode)
5465 (gnus-summary-next-subject 1 nil t)
5466 (gnus-summary-recenter)
5467 (gnus-summary-position-point))))
5471 (defvar gnus-dead-summary-mode-map nil)
5473 (unless gnus-dead-summary-mode-map
5474 (setq gnus-dead-summary-mode-map (make-keymap))
5475 (suppress-keymap gnus-dead-summary-mode-map)
5476 (substitute-key-definition
5477 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5478 (let ((keys '("\C-d" "\r" "\177" [delete])))
5480 (define-key gnus-dead-summary-mode-map
5481 (pop keys) 'gnus-summary-wake-up-the-dead))))
5483 (defvar gnus-dead-summary-mode nil
5484 "Minor mode for Gnus summary buffers.")
5486 (defun gnus-dead-summary-mode (&optional arg)
5487 "Minor mode for Gnus summary buffers."
5489 (when (eq major-mode 'gnus-summary-mode)
5490 (make-local-variable 'gnus-dead-summary-mode)
5491 (setq gnus-dead-summary-mode
5492 (if (null arg) (not gnus-dead-summary-mode)
5493 (> (prefix-numeric-value arg) 0)))
5494 (when gnus-dead-summary-mode
5495 (gnus-add-minor-mode
5496 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5498 (defun gnus-deaden-summary ()
5499 "Make the current summary buffer into a dead summary buffer."
5500 ;; Kill any previous dead summary buffer.
5501 (when (and gnus-dead-summary
5502 (buffer-name gnus-dead-summary))
5504 (set-buffer gnus-dead-summary)
5505 (when gnus-dead-summary-mode
5506 (kill-buffer (current-buffer)))))
5507 ;; Make this the current dead summary.
5508 (setq gnus-dead-summary (current-buffer))
5509 (gnus-dead-summary-mode 1)
5510 (let ((name (buffer-name)))
5511 (when (string-match "Summary" name)
5513 (concat (substring name 0 (match-beginning 0)) "Dead "
5514 (substring name (match-beginning 0)))
5517 (defun gnus-kill-or-deaden-summary (buffer)
5518 "Kill or deaden the summary BUFFER."
5520 (when (and (buffer-name buffer)
5521 (not gnus-single-article-buffer))
5524 (gnus-kill-buffer gnus-article-buffer)
5525 (gnus-kill-buffer gnus-original-article-buffer)))
5526 (cond (gnus-kill-summary-on-exit
5527 (when (and gnus-use-trees
5528 (gnus-buffer-exists-p buffer))
5531 (gnus-tree-close gnus-newsgroup-name)))
5532 (gnus-kill-buffer buffer))
5533 ((gnus-buffer-exists-p buffer)
5536 (gnus-deaden-summary))))))
5538 (defun gnus-summary-wake-up-the-dead (&rest args)
5539 "Wake up the dead summary buffer."
5541 (gnus-dead-summary-mode -1)
5542 (let ((name (buffer-name)))
5543 (when (string-match "Dead " name)
5545 (concat (substring name 0 (match-beginning 0))
5546 (substring name (match-end 0)))
5548 (gnus-message 3 "This dead summary is now alive again"))
5550 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5551 (defun gnus-summary-fetch-faq (&optional faq-dir)
5552 "Fetch the FAQ for the current group.
5553 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5557 (when current-prefix-arg
5559 "Faq dir: " (and (listp gnus-group-faq-directory)
5560 (mapcar (lambda (file) (list file))
5561 gnus-group-faq-directory))))))
5562 (let (gnus-faq-buffer)
5563 (when (setq gnus-faq-buffer
5564 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5565 (gnus-configure-windows 'summary-faq))))
5567 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5568 (defun gnus-summary-describe-group (&optional force)
5569 "Describe the current newsgroup."
5571 (gnus-group-describe-group force gnus-newsgroup-name))
5573 (defun gnus-summary-describe-briefly ()
5574 "Describe summary mode commands briefly."
5576 (gnus-message 6 (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")))
5578 ;; Walking around group mode buffer from summary mode.
5580 (defun gnus-summary-next-group (&optional no-article target-group backward)
5581 "Exit current newsgroup and then select next unread newsgroup.
5582 If prefix argument NO-ARTICLE is non-nil, no article is selected
5583 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5584 previous group instead."
5586 ;; Stop pre-fetching.
5587 (gnus-async-halt-prefetch)
5588 (let ((current-group gnus-newsgroup-name)
5589 (current-buffer (current-buffer))
5591 ;; First we semi-exit this group to update Xrefs and all variables.
5592 ;; We can't do a real exit, because the window conf must remain
5593 ;; the same in case the user is prompted for info, and we don't
5594 ;; want the window conf to change before that...
5595 (gnus-summary-exit t)
5596 (while (not entered)
5597 ;; Then we find what group we are supposed to enter.
5598 (set-buffer gnus-group-buffer)
5599 (gnus-group-jump-to-group current-group)
5602 (if (eq gnus-keep-same-level 'best)
5603 (gnus-summary-best-group gnus-newsgroup-name)
5604 (gnus-summary-search-group backward gnus-keep-same-level))))
5605 (if (not target-group)
5606 ;; There are no further groups, so we return to the group
5609 (gnus-message 5 "Returning to the group buffer")
5611 (when (gnus-buffer-live-p current-buffer)
5612 (set-buffer current-buffer)
5613 (gnus-summary-exit))
5614 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5615 ;; We try to enter the target group.
5616 (gnus-group-jump-to-group target-group)
5617 (let ((unreads (gnus-group-group-unread)))
5618 (if (and (or (eq t unreads)
5619 (and unreads (not (zerop unreads))))
5620 (gnus-summary-read-group
5621 target-group nil no-article
5622 (and (buffer-name current-buffer) current-buffer)
5625 (setq current-group target-group
5626 target-group nil)))))))
5628 (defun gnus-summary-prev-group (&optional no-article)
5629 "Exit current newsgroup and then select previous unread newsgroup.
5630 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5632 (gnus-summary-next-group no-article nil t))
5634 ;; Walking around summary lines.
5636 (defun gnus-summary-first-subject (&optional unread undownloaded)
5637 "Go to the first unread subject.
5638 If UNREAD is non-nil, go to the first unread article.
5639 Returns the article selected or nil if there are no unread articles."
5644 ((null gnus-newsgroup-data)
5645 (gnus-message 3 "No articles in the group")
5647 ;; Pick the first article.
5649 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5650 (gnus-data-number (car gnus-newsgroup-data)))
5651 ;; No unread articles.
5652 ((null gnus-newsgroup-unreads)
5653 (gnus-message 3 "No more unread articles")
5655 ;; Find the first unread article.
5657 (let ((data gnus-newsgroup-data))
5659 (and (not (and undownloaded
5660 (eq gnus-undownloaded-mark
5661 (gnus-data-mark (car data)))))
5662 (not (gnus-data-unread-p (car data)))))
5663 (setq data (cdr data)))
5665 (goto-char (gnus-data-pos (car data)))
5666 (gnus-data-number (car data))))))
5667 (gnus-summary-position-point)))
5669 (defun gnus-summary-next-subject (n &optional unread dont-display)
5670 "Go to next N'th summary line.
5671 If N is negative, go to the previous N'th subject line.
5672 If UNREAD is non-nil, only unread articles are selected.
5673 The difference between N and the actual number of steps taken is
5676 (let ((backward (< n 0))
5680 (gnus-summary-find-prev unread)
5681 (gnus-summary-find-next unread)))
5682 (gnus-summary-show-thread)
5685 (gnus-message 7 "No more%s articles"
5686 (if unread " unread" "")))
5687 (unless dont-display
5688 (gnus-summary-recenter)
5689 (gnus-summary-position-point))
5692 (defun gnus-summary-next-unread-subject (n)
5693 "Go to next N'th unread summary line."
5695 (gnus-summary-next-subject n t))
5697 (defun gnus-summary-prev-subject (n &optional unread)
5698 "Go to previous N'th summary line.
5699 If optional argument UNREAD is non-nil, only unread article is selected."
5701 (gnus-summary-next-subject (- n) unread))
5703 (defun gnus-summary-prev-unread-subject (n)
5704 "Go to previous N'th unread summary line."
5706 (gnus-summary-next-subject (- n) t))
5708 (defun gnus-summary-goto-subject (article &optional force silent)
5709 "Go the subject line of ARTICLE.
5710 If FORCE, also allow jumping to articles not currently shown."
5711 (interactive "nArticle number: ")
5713 (data (gnus-data-find article)))
5714 ;; We read in the article if we have to.
5717 (gnus-summary-insert-subject
5719 (if (or (numberp force) (vectorp force)) force)
5721 (setq data (gnus-data-find article)))
5726 (gnus-message 3 "Can't find article %d" article))
5728 (goto-char (gnus-data-pos data))
5729 (gnus-summary-position-point)
5732 ;; Walking around summary lines with displaying articles.
5734 (defun gnus-summary-expand-window (&optional arg)
5735 "Make the summary buffer take up the entire Emacs frame.
5736 Given a prefix, will force an `article' buffer configuration."
5739 (gnus-configure-windows 'article 'force)
5740 (gnus-configure-windows 'summary 'force)))
5742 (defun gnus-summary-display-article (article &optional all-header)
5743 "Display ARTICLE in article buffer."
5744 (gnus-set-global-variables)
5748 (if gnus-summary-display-article-function
5749 (funcall gnus-summary-display-article-function article all-header)
5750 (gnus-article-prepare article all-header))
5751 (gnus-run-hooks 'gnus-select-article-hook)
5752 (when (and gnus-current-article
5753 (not (zerop gnus-current-article)))
5754 (gnus-summary-goto-subject gnus-current-article))
5755 (gnus-summary-recenter)
5756 (when (and gnus-use-trees gnus-show-threads)
5757 (gnus-possibly-generate-tree article)
5758 (gnus-highlight-selected-tree article))
5759 ;; Successfully display article.
5760 (gnus-article-set-window-start
5761 (cdr (assq article gnus-newsgroup-bookmarks))))))
5763 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5764 "Select the current article.
5765 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5766 non-nil, the article will be re-fetched even if it already present in
5767 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5769 ;; Make sure we are in the summary buffer to work around bbdb bug.
5770 (unless (eq major-mode 'gnus-summary-mode)
5771 (set-buffer gnus-summary-buffer))
5772 (let ((article (or article (gnus-summary-article-number)))
5773 (all-headers (not (not all-headers))) ;Must be T or NIL.
5774 gnus-summary-display-article-function
5777 (gnus-summary-article-pseudo-p article)
5778 (error "This is a pseudo-article"))
5781 (set-buffer gnus-summary-buffer)
5782 (if (or (and gnus-single-article-buffer
5783 (or (null gnus-current-article)
5784 (null gnus-article-current)
5785 (null (get-buffer gnus-article-buffer))
5786 (not (eq article (cdr gnus-article-current)))
5787 (not (equal (car gnus-article-current)
5788 gnus-newsgroup-name))))
5789 (and (not gnus-single-article-buffer)
5790 (or (null gnus-current-article)
5791 (not (eq gnus-current-article article))))
5793 ;; The requested article is different from the current article.
5795 (gnus-summary-display-article article all-headers)
5797 (when (or all-headers gnus-show-all-headers)
5798 (gnus-article-show-all-headers)))
5799 (when (or all-headers gnus-show-all-headers)
5800 (gnus-article-show-all-headers))
5803 (gnus-article-set-window-start
5804 (cdr (assq article gnus-newsgroup-bookmarks)))))))
5806 (defun gnus-summary-set-current-mark (&optional current-mark)
5807 "Obsolete function."
5810 (defun gnus-summary-next-article (&optional unread subject backward push)
5811 "Select the next article.
5812 If UNREAD, only unread articles are selected.
5813 If SUBJECT, only articles with SUBJECT are selected.
5814 If BACKWARD, the previous article is selected instead of the next."
5817 ;; Is there such an article?
5818 ((and (gnus-summary-search-forward unread subject backward)
5819 (or (gnus-summary-display-article (gnus-summary-article-number))
5820 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5821 (gnus-summary-position-point))
5822 ;; If not, we try the first unread, if that is wanted.
5824 gnus-auto-select-same
5825 (gnus-summary-first-unread-article))
5826 (gnus-summary-position-point)
5827 (gnus-message 6 "Wrapped"))
5828 ;; Try to get next/previous article not displayed in this group.
5829 ((and gnus-auto-extend-newsgroup
5830 (not unread) (not subject))
5831 (gnus-summary-goto-article
5832 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5833 nil (count-lines (point-min) (point))))
5834 ;; Go to next/previous group.
5836 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5837 (gnus-summary-jump-to-group gnus-newsgroup-name))
5838 (let ((cmd last-command-char)
5841 (set-buffer gnus-group-buffer)
5844 (if (eq gnus-keep-same-level 'best)
5845 (gnus-summary-best-group gnus-newsgroup-name)
5846 (gnus-summary-search-group backward gnus-keep-same-level))))
5847 ;; For some reason, the group window gets selected. We change
5849 (select-window (get-buffer-window (current-buffer)))
5850 ;; Select next unread newsgroup automagically.
5852 ((or (not gnus-auto-select-next)
5854 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5855 ((or (eq gnus-auto-select-next 'quietly)
5856 (and (eq gnus-auto-select-next 'slightly-quietly)
5858 (and (eq gnus-auto-select-next 'almost-quietly)
5859 (gnus-summary-last-article-p)))
5861 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5863 (gnus-message 7 "No more%s articles (%s)..."
5864 (if unread " unread" "")
5865 (if group (concat "selecting " group)
5867 (gnus-summary-next-group nil group backward)))
5869 (when (gnus-key-press-event-p last-input-event)
5870 (gnus-summary-walk-group-buffer
5871 gnus-newsgroup-name cmd unread backward point))))))))
5873 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5874 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5875 (?\C-p (gnus-group-prev-unread-group 1))))
5876 (cursor-in-echo-area t)
5877 keve key group ended)
5879 (set-buffer gnus-group-buffer)
5882 (if (eq gnus-keep-same-level 'best)
5883 (gnus-summary-best-group gnus-newsgroup-name)
5884 (gnus-summary-search-group backward gnus-keep-same-level))))
5887 5 "No more%s articles%s" (if unread " unread" "")
5889 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5890 (format " (Type %s for %s [%s])"
5891 (single-key-description cmd) group
5892 (car (gnus-gethash group gnus-newsrc-hashtb)))
5893 (format " (Type %s to exit %s)"
5894 (single-key-description cmd)
5895 gnus-newsgroup-name)))
5896 ;; Confirm auto selection.
5897 (setq key (car (setq keve (gnus-read-event-char))))
5900 ((assq key keystrokes)
5901 (let ((obuf (current-buffer)))
5902 (switch-to-buffer gnus-group-buffer)
5904 (gnus-group-jump-to-group group))
5905 (eval (cadr (assq key keystrokes)))
5906 (setq group (gnus-group-group-name))
5907 (switch-to-buffer obuf))
5911 (gnus-ephemeral-group-p gnus-newsgroup-name))
5913 (gnus-summary-next-group nil group backward)))
5915 (push (cdr keve) unread-command-events))))))
5917 (defun gnus-summary-next-unread-article ()
5918 "Select unread article after current one."
5920 (gnus-summary-next-article
5921 (or (not (eq gnus-summary-goto-unread 'never))
5922 (gnus-summary-last-article-p (gnus-summary-article-number)))
5923 (and gnus-auto-select-same
5924 (gnus-summary-article-subject))))
5926 (defun gnus-summary-prev-article (&optional unread subject)
5927 "Select the article after the current one.
5928 If UNREAD is non-nil, only unread articles are selected."
5930 (gnus-summary-next-article unread subject t))
5932 (defun gnus-summary-prev-unread-article ()
5933 "Select unread article before current one."
5935 (gnus-summary-prev-article
5936 (or (not (eq gnus-summary-goto-unread 'never))
5937 (gnus-summary-first-article-p (gnus-summary-article-number)))
5938 (and gnus-auto-select-same
5939 (gnus-summary-article-subject))))
5941 (defun gnus-summary-next-page (&optional lines circular)
5942 "Show next page of the selected article.
5943 If at the end of the current article, select the next article.
5944 LINES says how many lines should be scrolled up.
5946 If CIRCULAR is non-nil, go to the start of the article instead of
5947 selecting the next article when reaching the end of the current
5950 (setq gnus-summary-buffer (current-buffer))
5951 (gnus-set-global-variables)
5952 (let ((article (gnus-summary-article-number))
5953 (article-window (get-buffer-window gnus-article-buffer t))
5955 ;; If the buffer is empty, we have no article.
5957 (error "No article to select"))
5958 (gnus-configure-windows 'article)
5959 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
5960 (if (and (eq gnus-summary-goto-unread 'never)
5961 (not (gnus-summary-last-article-p article)))
5962 (gnus-summary-next-article)
5963 (gnus-summary-next-unread-article))
5964 (if (or (null gnus-current-article)
5965 (null gnus-article-current)
5966 (/= article (cdr gnus-article-current))
5967 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5968 ;; Selected subject is different from current article's.
5969 (gnus-summary-display-article article)
5970 (when article-window
5971 (gnus-eval-in-buffer-window gnus-article-buffer
5972 (setq endp (gnus-article-next-page lines)))
5975 (gnus-summary-beginning-of-article))
5977 (gnus-message 3 "End of message"))
5979 (if (and (eq gnus-summary-goto-unread 'never)
5980 (not (gnus-summary-last-article-p article)))
5981 (gnus-summary-next-article)
5982 (gnus-summary-next-unread-article))))))))
5983 (gnus-summary-recenter)
5984 (gnus-summary-position-point)))
5986 (defun gnus-summary-prev-page (&optional lines move)
5987 "Show previous page of selected article.
5988 Argument LINES specifies lines to be scrolled down.
5989 If MOVE, move to the previous unread article if point is at
5990 the beginning of the buffer."
5992 (let ((article (gnus-summary-article-number))
5993 (article-window (get-buffer-window gnus-article-buffer t))
5995 (gnus-configure-windows 'article)
5996 (if (or (null gnus-current-article)
5997 (null gnus-article-current)
5998 (/= article (cdr gnus-article-current))
5999 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6000 ;; Selected subject is different from current article's.
6001 (gnus-summary-display-article article)
6002 (gnus-summary-recenter)
6003 (when article-window
6004 (gnus-eval-in-buffer-window gnus-article-buffer
6005 (setq endp (gnus-article-prev-page lines)))
6006 (when (and move endp)
6008 (gnus-message 3 "Beginning of message"))
6010 (if (and (eq gnus-summary-goto-unread 'never)
6011 (not (gnus-summary-first-article-p article)))
6012 (gnus-summary-prev-article)
6013 (gnus-summary-prev-unread-article))))))))
6014 (gnus-summary-position-point))
6016 (defun gnus-summary-prev-page-or-article (&optional lines)
6017 "Show previous page of selected article.
6018 Argument LINES specifies lines to be scrolled down.
6019 If at the beginning of the article, go to the next article."
6021 (gnus-summary-prev-page lines t))
6023 (defun gnus-summary-scroll-up (lines)
6024 "Scroll up (or down) one line current article.
6025 Argument LINES specifies lines to be scrolled up (or down if negative)."
6027 (gnus-configure-windows 'article)
6028 (gnus-summary-show-thread)
6029 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6030 (gnus-eval-in-buffer-window gnus-article-buffer
6032 (when (gnus-article-next-page lines)
6033 (gnus-message 3 "End of message")))
6035 (gnus-article-prev-page (- lines))))))
6036 (gnus-summary-recenter)
6037 (gnus-summary-position-point))
6039 (defun gnus-summary-scroll-down (lines)
6040 "Scroll down (or up) one line current article.
6041 Argument LINES specifies lines to be scrolled down (or up if negative)."
6043 (gnus-summary-scroll-up (- lines)))
6045 (defun gnus-summary-next-same-subject ()
6046 "Select next article which has the same subject as current one."
6048 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6050 (defun gnus-summary-prev-same-subject ()
6051 "Select previous article which has the same subject as current one."
6053 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6055 (defun gnus-summary-next-unread-same-subject ()
6056 "Select next unread article which has the same subject as current one."
6058 (gnus-summary-next-article t (gnus-summary-article-subject)))
6060 (defun gnus-summary-prev-unread-same-subject ()
6061 "Select previous unread article which has the same subject as current one."
6063 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6065 (defun gnus-summary-first-unread-article ()
6066 "Select the first unread article.
6067 Return nil if there are no unread articles."
6070 (when (gnus-summary-first-subject t)
6071 (gnus-summary-show-thread)
6072 (gnus-summary-first-subject t)
6073 (gnus-summary-display-article (gnus-summary-article-number)))
6074 (gnus-summary-position-point)))
6076 (defun gnus-summary-first-unread-subject ()
6077 "Place the point on the subject line of the first unread article.
6078 Return nil if there are no unread articles."
6081 (when (gnus-summary-first-subject t)
6082 (gnus-summary-show-thread)
6083 (gnus-summary-first-subject t))
6084 (gnus-summary-position-point)))
6086 (defun gnus-summary-first-article ()
6087 "Select the first article.
6088 Return nil if there are no articles."
6091 (when (gnus-summary-first-subject)
6092 (gnus-summary-show-thread)
6093 (gnus-summary-first-subject)
6094 (gnus-summary-display-article (gnus-summary-article-number)))
6095 (gnus-summary-position-point)))
6097 (defun gnus-summary-best-unread-article ()
6098 "Select the unread article with the highest score."
6100 (let ((best -1000000)
6101 (data gnus-newsgroup-data)
6104 (and (gnus-data-unread-p (car data))
6106 (gnus-summary-article-score (gnus-data-number (car data))))
6109 article (gnus-data-number (car data))))
6110 (setq data (cdr data)))
6113 (gnus-summary-goto-article article)
6114 (error "No unread articles"))
6115 (gnus-summary-position-point))))
6117 (defun gnus-summary-last-subject ()
6118 "Go to the last displayed subject line in the group."
6119 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6121 (gnus-summary-goto-subject article))))
6123 (defun gnus-summary-goto-article (article &optional all-headers force)
6124 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6125 If ALL-HEADERS is non-nil, no header lines are hidden.
6126 If FORCE, go to the article even if it isn't displayed. If FORCE
6127 is a number, it is the line the article is to be displayed on."
6131 "Article number or Message-ID: "
6132 (mapcar (lambda (number) (list (int-to-string number)))
6133 gnus-newsgroup-limit))
6137 (if (and (stringp article)
6138 (string-match "@" article))
6139 (gnus-summary-refer-article article)
6140 (when (stringp article)
6141 (setq article (string-to-number article)))
6142 (if (gnus-summary-goto-subject article force)
6143 (gnus-summary-display-article article all-headers)
6144 (gnus-message 4 "Couldn't go to article %s" article) nil))
6145 (gnus-summary-position-point)))
6147 (defun gnus-summary-goto-last-article ()
6148 "Go to the previously read article."
6151 (when gnus-last-article
6152 (gnus-summary-goto-article gnus-last-article nil t))
6153 (gnus-summary-position-point)))
6155 (defun gnus-summary-pop-article (number)
6156 "Pop one article off the history and go to the previous.
6157 NUMBER articles will be popped off."
6160 (setq gnus-newsgroup-history
6161 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6163 (gnus-summary-goto-article (car to) nil t)
6164 (error "Article history empty")))
6165 (gnus-summary-position-point))
6167 ;; Summary commands and functions for limiting the summary buffer.
6169 (defun gnus-summary-limit-to-articles (n)
6170 "Limit the summary buffer to the next N articles.
6171 If not given a prefix, use the process marked articles instead."
6174 (let ((articles (gnus-summary-work-articles n)))
6175 (setq gnus-newsgroup-processable nil)
6176 (gnus-summary-limit articles))
6177 (gnus-summary-position-point)))
6179 (defun gnus-summary-pop-limit (&optional total)
6180 "Restore the previous limit.
6181 If given a prefix, remove all limits."
6184 (setq gnus-newsgroup-limits
6185 (list (mapcar (lambda (h) (mail-header-number h))
6186 gnus-newsgroup-headers))))
6187 (unless gnus-newsgroup-limits
6188 (error "No limit to pop"))
6190 (gnus-summary-limit nil 'pop)
6191 (gnus-summary-position-point)))
6193 (defun gnus-summary-limit-to-subject (subject &optional header)
6194 "Limit the summary buffer to articles that have subjects that match a regexp."
6195 (interactive "sLimit to subject (regexp): ")
6197 (setq header "subject"))
6198 (when (not (equal "" subject))
6200 (let ((articles (gnus-summary-find-matching
6201 (or header "subject") subject 'all)))
6203 (error "Found no matches for \"%s\"" subject))
6204 (gnus-summary-limit articles))
6205 (gnus-summary-position-point))))
6207 (defun gnus-summary-limit-to-author (from)
6208 "Limit the summary buffer to articles that have authors that match a regexp."
6209 (interactive "sLimit to author (regexp): ")
6210 (gnus-summary-limit-to-subject from "from"))
6212 (defun gnus-summary-limit-to-age (age &optional younger-p)
6213 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6214 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6215 articles that are younger than AGE days."
6217 (let ((younger current-prefix-arg)
6220 (while (not days-got)
6221 (setq days (if younger
6222 (read-string "Limit to articles within (in days): ")
6223 (read-string "Limit to articles old than (in days): ")))
6224 (when (> (length days) 0)
6225 (setq days (read days)))
6228 (message "Please enter a number.")
6230 (list days younger)))
6232 (let ((data gnus-newsgroup-data)
6233 (cutoff (days-to-time age))
6234 articles d date is-younger)
6235 (while (setq d (pop data))
6236 (when (and (vectorp (gnus-data-header d))
6237 (setq date (mail-header-date (gnus-data-header d))))
6238 (setq is-younger (time-less-p
6239 (time-since (condition-case ()
6246 (push (gnus-data-number d) articles))))
6247 (gnus-summary-limit (nreverse articles)))
6248 (gnus-summary-position-point)))
6250 (defun gnus-summary-limit-to-extra (header regexp)
6251 "Limit the summary buffer to articles that match an 'extra' header."
6255 (gnus-completing-read
6256 (symbol-name (car gnus-extra-headers))
6257 "Limit extra header:"
6259 (cons (symbol-name x) x))
6264 (read-string (format "Limit to header %s (regexp): " header)))))
6265 (when (not (equal "" regexp))
6267 (let ((articles (gnus-summary-find-matching
6268 (cons 'extra header) regexp 'all)))
6270 (error "Found no matches for \"%s\"" regexp))
6271 (gnus-summary-limit articles))
6272 (gnus-summary-position-point))))
6274 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6276 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6278 (defun gnus-summary-limit-to-unread (&optional all)
6279 "Limit the summary buffer to articles that are not marked as read.
6280 If ALL is non-nil, limit strictly to unread articles."
6283 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6284 (gnus-summary-limit-to-marks
6285 ;; Concat all the marks that say that an article is read and have
6287 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6288 gnus-killed-mark gnus-kill-file-mark
6289 gnus-low-score-mark gnus-expirable-mark
6290 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6291 gnus-duplicate-mark gnus-souped-mark)
6294 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6295 (make-obsolete 'gnus-summary-delete-marked-with
6296 'gnus-summary-limit-exlude-marks)
6298 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6299 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6300 If REVERSE, limit the summary buffer to articles that are marked
6301 with MARKS. MARKS can either be a string of marks or a list of marks.
6302 Returns how many articles were removed."
6303 (interactive "sMarks: ")
6304 (gnus-summary-limit-to-marks marks t))
6306 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6307 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6308 If REVERSE (the prefix), limit the summary buffer to articles that are
6309 not marked with MARKS. MARKS can either be a string of marks or a
6311 Returns how many articles were removed."
6312 (interactive "sMarks: \nP")
6314 (let ((data gnus-newsgroup-data)
6315 (marks (if (listp marks) marks
6316 (append marks nil))) ; Transform to list.
6319 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6320 (memq (gnus-data-mark (car data)) marks))
6321 (push (gnus-data-number (car data)) articles))
6322 (setq data (cdr data)))
6323 (gnus-summary-limit articles))
6324 (gnus-summary-position-point)))
6326 (defun gnus-summary-limit-to-score (&optional score)
6327 "Limit to articles with score at or above SCORE."
6329 (setq score (if score
6330 (prefix-numeric-value score)
6331 (or gnus-summary-default-score 0)))
6332 (let ((data gnus-newsgroup-data)
6335 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6337 (push (gnus-data-number (car data)) articles))
6338 (setq data (cdr data)))
6340 (gnus-summary-limit articles)
6341 (gnus-summary-position-point))))
6343 (defun gnus-summary-limit-include-thread (id)
6344 "Display all the hidden articles that in the current thread."
6345 (interactive (list (mail-header-id (gnus-summary-article-header))))
6346 (let ((articles (gnus-articles-in-thread
6347 (gnus-id-to-thread (gnus-root-id id)))))
6349 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6350 (gnus-summary-position-point))))
6352 (defun gnus-summary-limit-include-dormant ()
6353 "Display all the hidden articles that are marked as dormant.
6354 Note that this command only works on a subset of the articles currently
6355 fetched for this group."
6357 (unless gnus-newsgroup-dormant
6358 (error "There are no dormant articles in this group"))
6360 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6361 (gnus-summary-position-point)))
6363 (defun gnus-summary-limit-exclude-dormant ()
6364 "Hide all dormant articles."
6367 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6368 (gnus-summary-position-point)))
6370 (defun gnus-summary-limit-exclude-childless-dormant ()
6371 "Hide all dormant articles that have no children."
6373 (let ((data (gnus-data-list t))
6374 articles d children)
6375 ;; Find all articles that are either not dormant or have
6377 (while (setq d (pop data))
6378 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6380 (gnus-article-children (gnus-data-number d)))
6383 (when (memq (car children) articles)
6388 (push (gnus-data-number d) articles)))
6391 (gnus-summary-limit articles)
6392 (gnus-summary-position-point))))
6394 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6395 "Mark all unread excluded articles as read.
6396 If ALL, mark even excluded ticked and dormants as read."
6398 (let ((articles (gnus-sorted-complement
6400 (mapcar (lambda (h) (mail-header-number h))
6401 gnus-newsgroup-headers)
6403 (sort gnus-newsgroup-limit '<)))
6405 (setq gnus-newsgroup-unreads
6406 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6408 (setq gnus-newsgroup-dormant nil
6409 gnus-newsgroup-marked nil
6410 gnus-newsgroup-reads
6412 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6413 gnus-newsgroup-reads))
6414 (while (setq article (pop articles))
6415 (unless (or (memq article gnus-newsgroup-dormant)
6416 (memq article gnus-newsgroup-marked))
6417 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6419 (defun gnus-summary-limit (articles &optional pop)
6421 ;; We pop the previous limit off the stack and use that.
6422 (setq articles (car gnus-newsgroup-limits)
6423 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6424 ;; We use the new limit, so we push the old limit on the stack.
6425 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6427 (setq gnus-newsgroup-limit articles)
6428 (let ((total (length gnus-newsgroup-data))
6429 (data (gnus-data-find-list (gnus-summary-article-number)))
6430 (gnus-summary-mark-below nil) ; Inhibit this.
6432 ;; This will do all the work of generating the new summary buffer
6433 ;; according to the new limit.
6434 (gnus-summary-prepare)
6435 ;; Hide any threads, possibly.
6436 (and gnus-show-threads
6437 gnus-thread-hide-subtree
6438 (gnus-summary-hide-all-threads))
6439 ;; Try to return to the article you were at, or one in the
6442 ;; We try to find some article after the current one.
6444 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6447 (setq data (cdr data))))
6449 ;; If there is no data, that means that we were after the last
6450 ;; article. The same goes when we can't find any articles
6451 ;; after the current one.
6452 (goto-char (point-max))
6453 (gnus-summary-find-prev))
6454 (gnus-set-mode-line 'summary)
6455 ;; We return how many articles were removed from the summary
6456 ;; buffer as a result of the new limit.
6457 (- total (length gnus-newsgroup-data))))
6459 (defsubst gnus-invisible-cut-children (threads)
6462 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6467 (defsubst gnus-cut-thread (thread)
6468 "Go forwards in the thread until we find an article that we want to display."
6469 (when (or (eq gnus-fetch-old-headers 'some)
6470 (eq gnus-fetch-old-headers 'invisible)
6471 (numberp gnus-fetch-old-headers)
6472 (eq gnus-build-sparse-threads 'some)
6473 (eq gnus-build-sparse-threads 'more))
6474 ;; Deal with old-fetched headers and sparse threads.
6478 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6479 (gnus-summary-article-ancient-p
6480 (mail-header-number (car thread))))
6481 (if (or (<= (length (cdr thread)) 1)
6482 (eq gnus-fetch-old-headers 'invisible))
6483 (setq gnus-newsgroup-limit
6484 (delq (mail-header-number (car thread))
6485 gnus-newsgroup-limit)
6486 thread (cadr thread))
6487 (when (gnus-invisible-cut-children (cdr thread))
6488 (let ((th (cdr thread)))
6490 (if (memq (mail-header-number (caar th))
6491 gnus-newsgroup-limit)
6492 (setq thread (car th)
6494 (setq th (cdr th))))))))))
6497 (defun gnus-cut-threads (threads)
6498 "Cut off all uninteresting articles from the beginning of threads."
6499 (when (or (eq gnus-fetch-old-headers 'some)
6500 (eq gnus-fetch-old-headers 'invisible)
6501 (numberp gnus-fetch-old-headers)
6502 (eq gnus-build-sparse-threads 'some)
6503 (eq gnus-build-sparse-threads 'more))
6506 (setcar th (gnus-cut-thread (car th)))
6507 (setq th (cdr th)))))
6508 ;; Remove nixed out threads.
6511 (defun gnus-summary-initial-limit (&optional show-if-empty)
6512 "Figure out what the initial limit is supposed to be on group entry.
6513 This entails weeding out unwanted dormants, low-scored articles,
6514 fetch-old-headers verbiage, and so on."
6515 ;; Most groups have nothing to remove.
6516 (if (or gnus-inhibit-limiting
6517 (and (null gnus-newsgroup-dormant)
6518 (not (eq gnus-fetch-old-headers 'some))
6519 (not (numberp gnus-fetch-old-headers))
6520 (not (eq gnus-fetch-old-headers 'invisible))
6521 (null gnus-summary-expunge-below)
6522 (not (eq gnus-build-sparse-threads 'some))
6523 (not (eq gnus-build-sparse-threads 'more))
6524 (null gnus-thread-expunge-below)
6525 (not gnus-use-nocem)))
6527 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6528 (setq gnus-newsgroup-limit nil)
6531 (unless (car (symbol-value node))
6532 ;; These threads have no parents -- they are roots.
6533 (let ((nodes (cdr (symbol-value node)))
6536 (if (and gnus-thread-expunge-below
6537 (< (gnus-thread-total-score (car nodes))
6538 gnus-thread-expunge-below))
6539 (gnus-expunge-thread (pop nodes))
6540 (setq thread (pop nodes))
6541 (gnus-summary-limit-children thread))))))
6542 gnus-newsgroup-dependencies)
6543 ;; If this limitation resulted in an empty group, we might
6544 ;; pop the previous limit and use it instead.
6545 (when (and (not gnus-newsgroup-limit)
6547 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6548 gnus-newsgroup-limit))
6550 (defun gnus-summary-limit-children (thread)
6551 "Return 1 if this subthread is visible and 0 if it is not."
6552 ;; First we get the number of visible children to this thread. This
6553 ;; is done by recursing down the thread using this function, so this
6554 ;; will really go down to a leaf article first, before slowly
6555 ;; working its way up towards the root.
6559 (apply '+ (mapcar 'gnus-summary-limit-children
6562 (number (mail-header-number (car thread)))
6565 (not (memq number gnus-newsgroup-marked))
6567 ;; If this article is dormant and has absolutely no visible
6568 ;; children, then this article isn't visible.
6569 (and (memq number gnus-newsgroup-dormant)
6571 ;; If this is "fetch-old-headered" and there is no
6572 ;; visible children, then we don't want this article.
6573 (and (or (eq gnus-fetch-old-headers 'some)
6574 (numberp gnus-fetch-old-headers))
6575 (gnus-summary-article-ancient-p number)
6577 ;; If this is "fetch-old-headered" and `invisible', then
6578 ;; we don't want this article.
6579 (and (eq gnus-fetch-old-headers 'invisible)
6580 (gnus-summary-article-ancient-p number))
6581 ;; If this is a sparsely inserted article with no children,
6582 ;; we don't want it.
6583 (and (eq gnus-build-sparse-threads 'some)
6584 (gnus-summary-article-sparse-p number)
6586 ;; If we use expunging, and this article is really
6587 ;; low-scored, then we don't want this article.
6588 (when (and gnus-summary-expunge-below
6590 (or (cdr (assq number gnus-newsgroup-scored))
6591 gnus-summary-default-score))
6592 gnus-summary-expunge-below))
6593 ;; We increase the expunge-tally here, but that has
6594 ;; nothing to do with the limits, really.
6595 (incf gnus-newsgroup-expunged-tally)
6596 ;; We also mark as read here, if that's wanted.
6597 (when (and gnus-summary-mark-below
6598 (< score gnus-summary-mark-below))
6599 (setq gnus-newsgroup-unreads
6600 (delq number gnus-newsgroup-unreads))
6601 (if gnus-newsgroup-auto-expire
6602 (push number gnus-newsgroup-expirable)
6603 (push (cons number gnus-low-score-mark)
6604 gnus-newsgroup-reads)))
6606 ;; Check NoCeM things.
6607 (if (and gnus-use-nocem
6608 (gnus-nocem-unwanted-article-p
6609 (mail-header-id (car thread))))
6611 (setq gnus-newsgroup-unreads
6612 (delq number gnus-newsgroup-unreads))
6614 ;; Nope, invisible article.
6616 ;; Ok, this article is to be visible, so we add it to the limit
6618 (push number gnus-newsgroup-limit)
6621 (defun gnus-expunge-thread (thread)
6622 "Mark all articles in THREAD as read."
6623 (let* ((number (mail-header-number (car thread))))
6624 (incf gnus-newsgroup-expunged-tally)
6625 ;; We also mark as read here, if that's wanted.
6626 (setq gnus-newsgroup-unreads
6627 (delq number gnus-newsgroup-unreads))
6628 (if gnus-newsgroup-auto-expire
6629 (push number gnus-newsgroup-expirable)
6630 (push (cons number gnus-low-score-mark)
6631 gnus-newsgroup-reads)))
6632 ;; Go recursively through all subthreads.
6633 (mapcar 'gnus-expunge-thread (cdr thread)))
6635 ;; Summary article oriented commands
6637 (defun gnus-summary-refer-parent-article (n)
6638 "Refer parent article N times.
6639 If N is negative, go to ancestor -N instead.
6640 The difference between N and the number of articles fetched is returned."
6644 (when (not (natnump n))
6649 (setq header (gnus-summary-article-header))
6650 (if (and (eq (mail-header-number header)
6651 (cdr gnus-article-current))
6652 (equal gnus-newsgroup-name
6653 (car gnus-article-current)))
6654 ;; If we try to find the parent of the currently
6655 ;; displayed article, then we take a look at the actual
6656 ;; References header, since this is slightly more
6657 ;; reliable than the References field we got from the
6660 (set-buffer gnus-original-article-buffer)
6661 (nnheader-narrow-to-headers)
6662 (unless (setq ref (message-fetch-field "references"))
6663 (setq ref (message-fetch-field "in-reply-to")))
6666 ;; It's not the current article, so we take a bet on
6667 ;; the value we got from the server.
6668 (mail-header-references header)))
6670 (not (equal ref "")))
6671 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6672 (gnus-message 1 "Couldn't find parent"))
6673 (gnus-message 1 "No references in article %d"
6674 (gnus-summary-article-number))
6677 (gnus-summary-position-point)
6680 (defun gnus-summary-refer-references ()
6681 "Fetch all articles mentioned in the References header.
6682 Return the number of articles fetched."
6684 (let ((ref (mail-header-references (gnus-summary-article-header)))
6685 (current (gnus-summary-article-number))
6689 (error "No References in the current article")
6690 ;; For each Message-ID in the References header...
6691 (while (string-match "<[^>]*>" ref)
6693 ;; ... fetch that article.
6694 (gnus-summary-refer-article
6695 (prog1 (match-string 0 ref)
6696 (setq ref (substring ref (match-end 0))))))
6697 (gnus-summary-goto-subject current)
6698 (gnus-summary-position-point)
6701 (defun gnus-summary-refer-thread (&optional limit)
6702 "Fetch all articles in the current thread.
6703 If LIMIT (the numerical prefix), fetch that many old headers instead
6704 of what's specified by the `gnus-refer-thread-limit' variable."
6706 (let ((id (mail-header-id (gnus-summary-article-header)))
6707 (limit (if limit (prefix-numeric-value limit)
6708 gnus-refer-thread-limit)))
6709 ;; We want to fetch LIMIT *old* headers, but we also have to
6710 ;; re-fetch all the headers in the current buffer, because many of
6711 ;; them may be undisplayed. So we adjust LIMIT.
6712 (when (numberp limit)
6713 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6714 (unless (eq gnus-fetch-old-headers 'invisible)
6715 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6716 ;; Retrieve the headers and read them in.
6717 (if (eq (gnus-retrieve-headers
6718 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6720 (gnus-build-all-threads)
6721 (error "Can't fetch thread from backends that don't support NOV"))
6722 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6723 (gnus-summary-limit-include-thread id)))
6725 (defun gnus-summary-refer-article (message-id)
6726 "Fetch an article specified by MESSAGE-ID."
6727 (interactive "sMessage-ID: ")
6728 (when (and (stringp message-id)
6729 (not (zerop (length message-id))))
6730 ;; Construct the correct Message-ID if necessary.
6731 ;; Suggested by tale@pawl.rpi.edu.
6732 (unless (string-match "^<" message-id)
6733 (setq message-id (concat "<" message-id)))
6734 (unless (string-match ">$" message-id)
6735 (setq message-id (concat message-id ">")))
6736 (let* ((header (gnus-id-to-header message-id))
6738 (gnus-summary-article-sparse-p
6739 (mail-header-number header))
6740 (memq (mail-header-number header)
6741 gnus-newsgroup-limit)))
6744 ;; If the article is present in the buffer we just go to it.
6746 (or (not (gnus-summary-article-sparse-p
6747 (mail-header-number header)))
6750 (gnus-summary-goto-article
6751 (mail-header-number header) nil t)
6753 (gnus-summary-update-article (mail-header-number header)))))
6755 ;; We fetch the article.
6757 (dolist (gnus-override-method
6758 (cond ((null gnus-refer-article-method)
6759 (list 'current gnus-select-method))
6760 ((consp (car gnus-refer-article-method))
6761 gnus-refer-article-method)
6763 (list gnus-refer-article-method))))
6764 (when (eq 'current gnus-override-method)
6765 (setq gnus-override-method gnus-current-select-method))
6766 (gnus-check-server gnus-override-method)
6767 ;; Fetch the header, and display the article.
6768 (when (setq number (gnus-summary-insert-subject message-id))
6769 (gnus-summary-select-article nil nil nil number)
6771 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
6773 (defun gnus-summary-edit-parameters ()
6774 "Edit the group parameters of the current group."
6776 (gnus-group-edit-group gnus-newsgroup-name 'params))
6778 (defun gnus-summary-customize-parameters ()
6779 "Customize the group parameters of the current group."
6781 (gnus-group-customize gnus-newsgroup-name))
6783 (defun gnus-summary-enter-digest-group (&optional force)
6784 "Enter an nndoc group based on the current article.
6785 If FORCE, force a digest interpretation. If not, try
6786 to guess what the document format is."
6788 (let ((conf gnus-current-window-configuration))
6790 (gnus-summary-select-article))
6791 (setq gnus-current-window-configuration conf)
6792 (let* ((name (format "%s-%d"
6793 (gnus-group-prefixed-name
6794 gnus-newsgroup-name (list 'nndoc ""))
6796 (set-buffer gnus-summary-buffer)
6797 gnus-current-article)))
6798 (ogroup gnus-newsgroup-name)
6799 (params (append (gnus-info-params (gnus-get-info ogroup))
6800 (list (cons 'to-group ogroup))
6801 (list (cons 'save-article-group ogroup))))
6802 (case-fold-search t)
6803 (buf (current-buffer))
6806 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6807 (insert-buffer-substring gnus-original-article-buffer)
6808 ;; Remove lines that may lead nndoc to misinterpret the
6811 (goto-char (point-min))
6812 (or (search-forward "\n\n" nil t) (point)))
6813 (goto-char (point-min))
6814 (delete-matching-lines "^Path:\\|^From ")
6817 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
6818 (gnus-newsgroup-ephemeral-ignored-charsets
6819 gnus-newsgroup-ignored-charsets))
6820 (gnus-group-read-ephemeral-group
6821 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6823 ,(if force 'mbox 'guess))) t))
6824 ;; Make all postings to this group go to the parent group.
6825 (nconc (gnus-info-params (gnus-get-info name))
6827 ;; Couldn't select this doc group.
6828 (switch-to-buffer buf)
6829 (gnus-set-global-variables)
6830 (gnus-configure-windows 'summary)
6831 (gnus-message 3 "Article couldn't be entered?"))
6832 (kill-buffer dig)))))
6834 (defun gnus-summary-read-document (n)
6835 "Open a new group based on the current article(s).
6836 This will allow you to read digests and other similar
6837 documents as newsgroups.
6838 Obeys the standard process/prefix convention."
6840 (let* ((articles (gnus-summary-work-articles n))
6841 (ogroup gnus-newsgroup-name)
6842 (params (append (gnus-info-params (gnus-get-info ogroup))
6843 (list (cons 'to-group ogroup))))
6844 article group egroup groups vgroup)
6845 (while (setq article (pop articles))
6846 (setq group (format "%s-%d" gnus-newsgroup-name article))
6847 (gnus-summary-remove-process-mark article)
6848 (when (gnus-summary-display-article article)
6851 (insert-buffer-substring gnus-original-article-buffer)
6852 ;; Remove some headers that may lead nndoc to make
6854 (message-narrow-to-head)
6855 (goto-char (point-min))
6856 (delete-matching-lines "^\\(Path\\):\\|^From ")
6859 (gnus-group-read-ephemeral-group
6860 group `(nndoc ,group (nndoc-address ,(current-buffer))
6861 (nndoc-article-type guess))
6864 ;; Make all postings to this group go to the parent group.
6865 (nconc (gnus-info-params (gnus-get-info egroup))
6867 (push egroup groups))
6868 ;; Couldn't select this doc group.
6869 (gnus-error 3 "Article couldn't be entered"))))))
6870 ;; Now we have selected all the documents.
6873 (error "None of the articles could be interpreted as documents"))
6874 ((gnus-group-read-ephemeral-group
6875 (setq vgroup (format
6876 "nnvirtual:%s-%s" gnus-newsgroup-name
6877 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6878 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6880 (cons (current-buffer) 'summary)))
6882 (error "Couldn't select virtual nndoc group")))))
6884 (defun gnus-summary-isearch-article (&optional regexp-p)
6885 "Do incremental search forward on the current article.
6886 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6888 (gnus-summary-select-article)
6889 (gnus-configure-windows 'article)
6890 (gnus-eval-in-buffer-window gnus-article-buffer
6893 (isearch-forward regexp-p))))
6895 (defun gnus-summary-search-article-forward (regexp &optional backward)
6896 "Search for an article containing REGEXP forward.
6897 If BACKWARD, search backward instead."
6900 (format "Search article %s (regexp%s): "
6901 (if current-prefix-arg "backward" "forward")
6902 (if gnus-last-search-regexp
6903 (concat ", default " gnus-last-search-regexp)
6905 current-prefix-arg))
6906 (if (string-equal regexp "")
6907 (setq regexp (or gnus-last-search-regexp ""))
6908 (setq gnus-last-search-regexp regexp))
6909 (if (gnus-summary-search-article regexp backward)
6910 (gnus-summary-show-thread)
6911 (error "Search failed: \"%s\"" regexp)))
6913 (defun gnus-summary-search-article-backward (regexp)
6914 "Search for an article containing REGEXP backward."
6917 (format "Search article backward (regexp%s): "
6918 (if gnus-last-search-regexp
6919 (concat ", default " gnus-last-search-regexp)
6921 (gnus-summary-search-article-forward regexp 'backward))
6923 (defun gnus-summary-search-article (regexp &optional backward)
6924 "Search for an article containing REGEXP.
6925 Optional argument BACKWARD means do search for backward.
6926 `gnus-select-article-hook' is not called during the search."
6927 ;; We have to require this here to make sure that the following
6928 ;; dynamic binding isn't shadowed by autoloading.
6929 (require 'gnus-async)
6931 (let ((gnus-select-article-hook nil) ;Disable hook.
6932 (gnus-article-prepare-hook nil)
6933 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6934 (gnus-use-article-prefetch nil)
6935 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
6936 (gnus-use-trees nil) ;Inhibit updating tree buffer.
6937 (sum (current-buffer))
6938 (gnus-display-mime-function nil)
6941 (gnus-save-hidden-threads
6942 (gnus-summary-select-article)
6943 (set-buffer gnus-article-buffer)
6947 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
6949 (re-search-backward regexp nil t)
6950 (re-search-forward regexp nil t))
6951 ;; We found the regexp.
6956 (get-buffer-window (current-buffer))
6960 (get-buffer-window (current-buffer))
6963 (setq point (point)))
6964 ;; We didn't find it, so we go to the next article.
6967 (while (eq found 'not)
6968 (if (not (if backward (gnus-summary-find-prev)
6969 (gnus-summary-find-next)))
6970 ;; No more articles.
6972 ;; Select the next article and adjust point.
6973 (unless (gnus-summary-article-sparse-p
6974 (gnus-summary-article-number))
6976 (gnus-summary-select-article)
6977 (set-buffer gnus-article-buffer)
6979 (goto-char (if backward (point-max) (point-min))))))))
6980 (gnus-message 7 ""))
6981 ;; Return whether we found the regexp.
6982 (when (eq found 'found)
6984 (gnus-summary-show-thread)
6985 (gnus-summary-goto-subject gnus-current-article)
6986 (gnus-summary-position-point)
6989 (defun gnus-summary-find-matching (header regexp &optional backward unread
6991 "Return a list of all articles that match REGEXP on HEADER.
6992 The search stars on the current article and goes forwards unless
6993 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
6994 If UNREAD is non-nil, only unread articles will
6995 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
6996 in the comparisons."
6997 (let ((data (if (eq backward 'all) gnus-newsgroup-data
6998 (gnus-data-find-list
6999 (gnus-summary-article-number) (gnus-data-list backward))))
7000 (case-fold-search (not not-case-fold))
7003 (if (eq (car header) 'extra)
7006 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
7008 (error "%s is an invalid header" header))
7009 (unless (fboundp (intern (concat "mail-header-" header)))
7010 (error "%s is not a valid header" header))
7011 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
7014 (and (or (not unread) ; We want all articles...
7015 (gnus-data-unread-p d)) ; Or just unreads.
7016 (vectorp (gnus-data-header d)) ; It's not a pseudo.
7017 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
7018 (push (gnus-data-number d) articles)) ; Success!
7019 (setq data (cdr data)))
7020 (nreverse articles)))
7022 (defun gnus-summary-execute-command (header regexp command &optional backward)
7023 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7024 If HEADER is an empty string (or nil), the match is done on the entire
7025 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7027 (list (let ((completion-ignore-case t))
7030 (mapcar (lambda (string) (list string))
7031 '("Number" "Subject" "From" "Lines" "Date"
7032 "Message-ID" "Xref" "References" "Body"))
7033 nil 'require-match))
7034 (read-string "Regexp: ")
7035 (read-key-sequence "Command: ")
7036 current-prefix-arg))
7037 (when (equal header "Body")
7039 ;; Hidden thread subtrees must be searched as well.
7040 (gnus-summary-show-all-threads)
7041 ;; We don't want to change current point nor window configuration.
7043 (save-window-excursion
7044 (gnus-message 6 "Executing %s..." (key-description command))
7045 ;; We'd like to execute COMMAND interactively so as to give arguments.
7046 (gnus-execute header regexp
7047 `(call-interactively ',(key-binding command))
7049 (gnus-message 6 "Executing %s...done" (key-description command)))))
7051 (defun gnus-summary-beginning-of-article ()
7052 "Scroll the article back to the beginning."
7054 (gnus-summary-select-article)
7055 (gnus-configure-windows 'article)
7056 (gnus-eval-in-buffer-window gnus-article-buffer
7058 (goto-char (point-min))
7059 (when gnus-page-broken
7060 (gnus-narrow-to-page))))
7062 (defun gnus-summary-end-of-article ()
7063 "Scroll to the end of the article."
7065 (gnus-summary-select-article)
7066 (gnus-configure-windows 'article)
7067 (gnus-eval-in-buffer-window gnus-article-buffer
7069 (goto-char (point-max))
7071 (when gnus-page-broken
7072 (gnus-narrow-to-page))))
7074 (defun gnus-summary-print-article (&optional filename n)
7075 "Generate and print a PostScript image of the N next (mail) articles.
7077 If N is negative, print the N previous articles. If N is nil and articles
7078 have been marked with the process mark, print these instead.
7080 If the optional first argument FILENAME is nil, send the image to the
7081 printer. If FILENAME is a string, save the PostScript image in a file with
7082 that name. If FILENAME is a number, prompt the user for the name of the file
7084 (interactive (list (ps-print-preprint current-prefix-arg)
7085 current-prefix-arg))
7086 (dolist (article (gnus-summary-work-articles n))
7087 (gnus-summary-select-article nil nil 'pseudo article)
7088 (gnus-eval-in-buffer-window gnus-article-buffer
7089 (let ((buffer (generate-new-buffer " *print*")))
7092 (copy-to-buffer buffer (point-min) (point-max))
7094 (gnus-article-delete-invisible-text)
7095 (let ((ps-left-header
7098 (mail-header-subject gnus-current-headers) ")")
7100 (mail-header-from gnus-current-headers) ")")))
7103 "/pagenumberstring load"
7105 (mail-header-date gnus-current-headers) ")"))))
7106 (gnus-run-hooks 'gnus-ps-print-hook)
7108 (ps-print-buffer-with-faces filename))))
7109 (kill-buffer buffer))))))
7111 (defun gnus-summary-show-article (&optional arg)
7112 "Force re-fetching of the current article.
7113 If ARG (the prefix) is non-nil, show the raw article without any
7114 article massaging functions being run."
7117 ;; Select the article the normal way.
7118 (gnus-summary-select-article nil 'force)
7119 ;; We have to require this here to make sure that the following
7120 ;; dynamic binding isn't shadowed by autoloading.
7121 (require 'gnus-async)
7123 ;; Bind the article treatment functions to nil.
7124 (let ((gnus-have-all-headers t)
7125 gnus-article-prepare-hook
7126 gnus-article-decode-hook
7127 gnus-display-mime-function
7130 ;; Destroy any MIME parts.
7131 (when (gnus-buffer-live-p gnus-article-buffer)
7133 (set-buffer gnus-article-buffer)
7134 (mm-destroy-parts gnus-article-mime-handles)))
7135 (gnus-summary-select-article nil 'force)))
7136 (gnus-summary-goto-subject gnus-current-article)
7137 (gnus-summary-position-point))
7139 (defun gnus-summary-verbose-headers (&optional arg)
7140 "Toggle permanent full header display.
7141 If ARG is a positive number, turn header display on.
7142 If ARG is a negative number, turn header display off."
7144 (setq gnus-show-all-headers
7145 (cond ((or (not (numberp arg))
7147 (not gnus-show-all-headers))
7150 (gnus-summary-show-article))
7152 (defun gnus-summary-toggle-header (&optional arg)
7153 "Show the headers if they are hidden, or hide them if they are shown.
7154 If ARG is a positive number, show the entire header.
7155 If ARG is a negative number, hide the unwanted header lines."
7158 (set-buffer gnus-article-buffer)
7160 (let* ((buffer-read-only nil)
7161 (inhibit-point-motion-hooks t)
7167 (article-narrow-to-head)
7168 (gnus-article-hidden-text-p 'headers))))
7169 (goto-char (point-min))
7170 (when (search-forward "\n\n" nil t)
7171 (delete-region (point-min) (1- (point))))
7172 (goto-char (point-min))
7174 (set-buffer gnus-original-article-buffer)
7175 (goto-char (point-min))
7176 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
7177 (insert-buffer-substring gnus-original-article-buffer 1 e)
7179 (narrow-to-region (point-min) (point))
7180 (article-decode-encoded-words)
7182 (let ((gnus-treat-hide-headers nil)
7183 (gnus-treat-hide-boring-headers nil))
7184 (gnus-treat-article 'head))
7185 (gnus-treat-article 'head)))))))
7187 (defun gnus-summary-show-all-headers ()
7188 "Make all header lines visible."
7190 (gnus-article-show-all-headers))
7192 (defun gnus-summary-caesar-message (&optional arg)
7193 "Caesar rotate the current article by 13.
7194 The numerical prefix specifies how many places to rotate each letter
7197 (gnus-summary-select-article)
7198 (let ((mail-header-separator ""))
7199 (gnus-eval-in-buffer-window gnus-article-buffer
7202 (let ((start (window-start))
7204 (message-caesar-buffer-body arg)
7205 (set-window-start (get-buffer-window (current-buffer)) start))))))
7207 (defun gnus-summary-stop-page-breaking ()
7208 "Stop page breaking in the current article."
7210 (gnus-summary-select-article)
7211 (gnus-eval-in-buffer-window gnus-article-buffer
7213 (when (gnus-visual-p 'page-marker)
7214 (let ((buffer-read-only nil))
7215 (gnus-remove-text-with-property 'gnus-prev)
7216 (gnus-remove-text-with-property 'gnus-next))
7217 (setq gnus-page-broken nil))))
7219 (defun gnus-summary-move-article (&optional n to-newsgroup
7220 select-method action)
7221 "Move the current article to a different newsgroup.
7222 If N is a positive number, move the N next articles.
7223 If N is a negative number, move the N previous articles.
7224 If N is nil and any articles have been marked with the process mark,
7225 move those articles instead.
7226 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7227 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7228 re-spool using this method.
7230 For this function to work, both the current newsgroup and the
7231 newsgroup that you want to move to have to support the `request-move'
7232 and `request-accept' functions."
7235 (setq action 'move))
7236 ;; Disable marking as read.
7237 (let (gnus-mark-article-hook)
7238 (save-window-excursion
7239 (gnus-summary-select-article)))
7240 ;; Check whether the source group supports the required functions.
7241 (cond ((and (eq action 'move)
7242 (not (gnus-check-backend-function
7243 'request-move-article gnus-newsgroup-name)))
7244 (error "The current group does not support article moving"))
7245 ((and (eq action 'crosspost)
7246 (not (gnus-check-backend-function
7247 'request-replace-article gnus-newsgroup-name)))
7248 (error "The current group does not support article editing")))
7249 (let ((articles (gnus-summary-work-articles n))
7250 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
7251 (names '((move "Move" "Moving")
7252 (copy "Copy" "Copying")
7253 (crosspost "Crosspost" "Crossposting")))
7254 (copy-buf (save-excursion
7255 (nnheader-set-temp-buffer " *copy article*")))
7256 art-group to-method new-xref article to-groups)
7257 (unless (assq action names)
7258 (error "Unknown action %s" action))
7259 ;; Read the newsgroup name.
7260 (when (and (not to-newsgroup)
7261 (not select-method))
7263 (gnus-read-move-group-name
7264 (cadr (assq action names))
7265 (symbol-value (intern (format "gnus-current-%s-group" action)))
7267 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
7268 (setq to-method (or select-method
7269 (gnus-group-name-to-method to-newsgroup)))
7270 ;; Check the method we are to move this article to...
7271 (unless (gnus-check-backend-function
7272 'request-accept-article (car to-method))
7273 (error "%s does not support article copying" (car to-method)))
7274 (unless (gnus-check-server to-method)
7275 (error "Can't open server %s" (car to-method)))
7276 (gnus-message 6 "%s to %s: %s..."
7277 (caddr (assq action names))
7278 (or (car select-method) to-newsgroup) articles)
7280 (setq article (pop articles))
7284 ;; Move the article.
7286 ;; Remove this article from future suppression.
7287 (gnus-dup-unsuppress-article article)
7288 (gnus-request-move-article
7289 article ; Article to move
7290 gnus-newsgroup-name ; From newsgroup
7291 (nth 1 (gnus-find-method-for-group
7292 gnus-newsgroup-name)) ; Server
7293 (list 'gnus-request-accept-article
7294 to-newsgroup (list 'quote select-method)
7295 (not articles) t) ; Accept form
7296 (not articles))) ; Only save nov last time
7297 ;; Copy the article.
7300 (set-buffer copy-buf)
7301 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
7302 (gnus-request-accept-article
7303 to-newsgroup select-method (not articles) t))))
7304 ;; Crosspost the article.
7305 ((eq action 'crosspost)
7306 (let ((xref (message-tokenize-header
7307 (mail-header-xref (gnus-summary-article-header article))
7309 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
7312 (setq xref (list (system-name))))
7315 (mapconcat 'identity
7316 (delete "Xref:" (delete new-xref xref))
7320 (set-buffer copy-buf)
7321 ;; First put the article in the destination group.
7322 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7323 (when (consp (setq art-group
7324 (gnus-request-accept-article
7325 to-newsgroup select-method (not articles))))
7326 (setq new-xref (concat new-xref " " (car art-group)
7327 ":" (cdr art-group)))
7328 ;; Now we have the new Xrefs header, so we insert
7329 ;; it and replace the new article.
7330 (nnheader-replace-header "Xref" new-xref)
7331 (gnus-request-replace-article
7332 (cdr art-group) to-newsgroup (current-buffer))
7336 (gnus-message 1 "Couldn't %s article %s: %s"
7337 (cadr (assq action names)) article
7338 (nnheader-get-report (car to-method))))
7339 ((and (eq art-group 'junk)
7341 (gnus-summary-mark-article article gnus-canceled-mark)
7342 (gnus-message 4 "Deleted article %s" article))
7344 (let* ((pto-group (gnus-group-prefixed-name
7345 (car art-group) to-method))
7347 (gnus-gethash pto-group gnus-newsrc-hashtb))
7348 (info (nth 2 entry))
7349 (to-group (gnus-info-group info))
7351 ;; Update the group that has been moved to.
7353 (memq action '(move copy)))
7354 (unless (member to-group to-groups)
7355 (push to-group to-groups))
7357 (unless (memq article gnus-newsgroup-unreads)
7358 (push 'read to-marks)
7360 info (gnus-add-to-range (gnus-info-read info)
7361 (list (cdr art-group)))))
7363 ;; Copy any marks over to the new group.
7364 (let ((marks gnus-article-mark-lists)
7365 (to-article (cdr art-group)))
7367 ;; See whether the article is to be put in the cache.
7368 (when gnus-use-cache
7369 (gnus-cache-possibly-enter-article
7371 (memq article gnus-newsgroup-marked)
7372 (memq article gnus-newsgroup-dormant)
7373 (memq article gnus-newsgroup-unreads)))
7375 (when (and (equal to-group gnus-newsgroup-name)
7376 (not (memq article gnus-newsgroup-unreads)))
7377 ;; Mark this article as read in this group.
7378 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7379 (setcdr (gnus-active to-group) to-article)
7380 (setcdr gnus-newsgroup-active to-article))
7383 (when (memq article (symbol-value
7384 (intern (format "gnus-newsgroup-%s"
7386 (push (cdar marks) to-marks)
7387 ;; If the other group is the same as this group,
7388 ;; then we have to add the mark to the list.
7389 (when (equal to-group gnus-newsgroup-name)
7390 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7393 (intern (format "gnus-newsgroup-%s"
7395 ;; Copy the marks to other group.
7396 (gnus-add-marked-articles
7397 to-group (cdar marks) (list to-article) info))
7398 (setq marks (cdr marks)))
7400 (gnus-request-set-mark to-group (list (list (list to-article)
7405 (concat "(gnus-group-set-info '"
7406 (gnus-prin1-to-string (gnus-get-info to-group))
7409 ;; Update the Xref header in this article to point to
7410 ;; the new crossposted article we have just created.
7411 (when (eq action 'crosspost)
7413 (set-buffer copy-buf)
7414 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7415 (nnheader-replace-header "Xref" new-xref)
7416 (gnus-request-replace-article
7417 article gnus-newsgroup-name (current-buffer)))))
7419 ;;;!!!Why is this necessary?
7420 (set-buffer gnus-summary-buffer)
7422 (gnus-summary-goto-subject article)
7423 (when (eq action 'move)
7424 (gnus-summary-mark-article article gnus-canceled-mark))))
7425 (gnus-summary-remove-process-mark article))
7426 ;; Re-activate all groups that have been moved to.
7429 (set-buffer gnus-group-buffer)
7430 (when (gnus-group-goto-group (car to-groups) t)
7431 (gnus-group-get-new-news-this-group 1 t))
7434 (gnus-kill-buffer copy-buf)
7435 (gnus-summary-position-point)
7436 (gnus-set-mode-line 'summary)))
7438 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7439 "Move the current article to a different newsgroup.
7440 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7441 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7442 re-spool using this method."
7444 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7446 (defun gnus-summary-crosspost-article (&optional n)
7447 "Crosspost the current article to some other group."
7449 (gnus-summary-move-article n nil nil 'crosspost))
7451 (defcustom gnus-summary-respool-default-method nil
7452 "Default method for respooling an article.
7453 If nil, use to the current newsgroup method."
7454 :type '(choice (gnus-select-method :value (nnml ""))
7456 :group 'gnus-summary-mail)
7458 (defun gnus-summary-respool-article (&optional n method)
7459 "Respool the current article.
7460 The article will be squeezed through the mail spooling process again,
7461 which means that it will be put in some mail newsgroup or other
7462 depending on `nnmail-split-methods'.
7463 If N is a positive number, respool the N next articles.
7464 If N is a negative number, respool the N previous articles.
7465 If N is nil and any articles have been marked with the process mark,
7466 respool those articles instead.
7468 Respooling can be done both from mail groups and \"real\" newsgroups.
7469 In the former case, the articles in question will be moved from the
7470 current group into whatever groups they are destined to. In the
7471 latter case, they will be copied into the relevant groups."
7473 (list current-prefix-arg
7474 (let* ((methods (gnus-methods-using 'respool))
7476 (symbol-name (or gnus-summary-respool-default-method
7477 (car (gnus-find-method-for-group
7478 gnus-newsgroup-name)))))
7480 (gnus-completing-read
7481 methname "What backend do you want to use when respooling?"
7482 methods nil t nil 'gnus-mail-method-history))
7485 ((zerop (length (setq ms (gnus-servers-using-backend
7487 (list (intern method) ""))
7491 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7492 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7495 (error "No method given for respooling"))
7496 (if (assoc (symbol-name
7497 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7498 (gnus-methods-using 'respool))
7499 (gnus-summary-move-article n nil method)
7500 (gnus-summary-copy-article n nil method)))
7502 (defun gnus-summary-import-article (file)
7503 "Import an arbitrary file into a mail newsgroup."
7504 (interactive "fImport file: ")
7505 (let ((group gnus-newsgroup-name)
7506 (now (current-time))
7508 (unless (gnus-check-backend-function 'request-accept-article group)
7509 (error "%s does not support article importing" group))
7510 (or (file-readable-p file)
7511 (not (file-regular-p file))
7512 (error "Can't read %s" file))
7514 (set-buffer (gnus-get-buffer-create " *import file*"))
7516 (insert-file-contents file)
7517 (goto-char (point-min))
7518 (unless (nnheader-article-p)
7519 ;; This doesn't look like an article, so we fudge some headers.
7520 (setq atts (file-attributes file)
7521 lines (count-lines (point-min) (point-max)))
7522 (insert "From: " (read-string "From: ") "\n"
7523 "Subject: " (read-string "Subject: ") "\n"
7524 "Date: " (message-make-date (nth 5 atts))
7526 "Message-ID: " (message-make-message-id) "\n"
7527 "Lines: " (int-to-string lines) "\n"
7528 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7529 (gnus-request-accept-article group nil t)
7530 (kill-buffer (current-buffer)))))
7532 (defun gnus-summary-article-posted-p ()
7533 "Say whether the current (mail) article is available from `gnus-select-method' as well.
7534 This will be the case if the article has both been mailed and posted."
7536 (let ((id (mail-header-references (gnus-summary-article-header)))
7537 (gnus-override-method
7538 (or gnus-refer-article-method gnus-select-method)))
7539 (if (gnus-request-head id "")
7540 (gnus-message 2 "The current message was found on %s"
7541 gnus-override-method)
7542 (gnus-message 2 "The current message couldn't be found on %s"
7543 gnus-override-method)
7546 (defun gnus-summary-expire-articles (&optional now)
7547 "Expire all articles that are marked as expirable in the current group."
7549 (when (gnus-check-backend-function
7550 'request-expire-articles gnus-newsgroup-name)
7551 ;; This backend supports expiry.
7552 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7553 (expirable (if total
7555 ;; We need to update the info for
7556 ;; this group for `gnus-list-of-read-articles'
7557 ;; to give us the right answer.
7558 (gnus-run-hooks 'gnus-exit-group-hook)
7559 (gnus-summary-update-info)
7560 (gnus-list-of-read-articles gnus-newsgroup-name))
7561 (setq gnus-newsgroup-expirable
7562 (sort gnus-newsgroup-expirable '<))))
7563 (expiry-wait (if now 'immediate
7564 (gnus-group-find-parameter
7565 gnus-newsgroup-name 'expiry-wait)))
7568 ;; There are expirable articles in this group, so we run them
7569 ;; through the expiry process.
7570 (gnus-message 6 "Expiring articles...")
7571 (unless (gnus-check-group gnus-newsgroup-name)
7572 (error "Can't open server for %s" gnus-newsgroup-name))
7573 ;; The list of articles that weren't expired is returned.
7576 (let ((nnmail-expiry-wait-function nil)
7577 (nnmail-expiry-wait expiry-wait))
7578 (setq es (gnus-request-expire-articles
7579 expirable gnus-newsgroup-name)))
7580 (setq es (gnus-request-expire-articles
7581 expirable gnus-newsgroup-name))))
7583 (setq gnus-newsgroup-expirable es))
7584 ;; We go through the old list of expirable, and mark all
7585 ;; really expired articles as nonexistent.
7586 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7587 (let ((gnus-use-cache nil))
7589 (unless (memq (car expirable) es)
7590 (when (gnus-data-find (car expirable))
7591 (gnus-summary-mark-article
7592 (car expirable) gnus-canceled-mark)))
7593 (setq expirable (cdr expirable)))))
7594 (gnus-message 6 "Expiring articles...done")))))
7596 (defun gnus-summary-expire-articles-now ()
7597 "Expunge all expirable articles in the current group.
7598 This means that *all* articles that are marked as expirable will be
7599 deleted forever, right now."
7601 (or gnus-expert-user
7603 "Are you really, really, really sure you want to delete all these messages? ")
7605 (gnus-summary-expire-articles t))
7607 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7608 (defun gnus-summary-delete-article (&optional n)
7609 "Delete the N next (mail) articles.
7610 This command actually deletes articles. This is not a marking
7611 command. The article will disappear forever from your life, never to
7613 If N is negative, delete backwards.
7614 If N is nil and articles have been marked with the process mark,
7615 delete these instead."
7617 (unless (gnus-check-backend-function 'request-expire-articles
7618 gnus-newsgroup-name)
7619 (error "The current newsgroup does not support article deletion"))
7620 ;; Compute the list of articles to delete.
7621 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
7623 (if (and gnus-novice-user
7624 (not (gnus-yes-or-no-p
7625 (format "Do you really want to delete %s forever? "
7626 (if (> (length articles) 1)
7627 (format "these %s articles" (length articles))
7630 ;; Delete the articles.
7631 (setq not-deleted (gnus-request-expire-articles
7632 articles gnus-newsgroup-name 'force))
7634 (gnus-summary-remove-process-mark (car articles))
7635 ;; The backend might not have been able to delete the article
7637 (unless (memq (car articles) not-deleted)
7638 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7639 (setq articles (cdr articles)))
7641 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7642 (gnus-summary-position-point)
7643 (gnus-set-mode-line 'summary)
7646 (defun gnus-summary-edit-article (&optional force)
7647 "Edit the current article.
7648 This will have permanent effect only in mail groups.
7649 If FORCE is non-nil, allow editing of articles even in read-only
7653 (set-buffer gnus-summary-buffer)
7654 (let ((mail-parse-charset gnus-newsgroup-charset)
7655 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
7656 (gnus-set-global-variables)
7657 (when (and (not force)
7658 (gnus-group-read-only-p))
7659 (error "The current newsgroup does not support article editing"))
7660 (gnus-summary-show-article t)
7661 (gnus-article-edit-article
7663 `(lambda (no-highlight)
7664 (let ((mail-parse-charset ',gnus-newsgroup-charset)
7665 (mail-parse-ignored-charsets
7666 ',gnus-newsgroup-ignored-charsets))
7668 (gnus-summary-edit-article-done
7669 ,(or (mail-header-references gnus-current-headers) "")
7670 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
7672 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7674 (defun gnus-summary-edit-article-done (&optional references read-only buffer
7676 "Make edits to the current article permanent."
7678 ;; Replace the article.
7679 (let ((buf (current-buffer)))
7681 (insert-buffer-substring buf)
7682 (if (and (not read-only)
7683 (not (gnus-request-replace-article
7684 (cdr gnus-article-current) (car gnus-article-current)
7685 (current-buffer) t)))
7686 (error "Couldn't replace article")
7687 ;; Update the summary buffer.
7689 (equal (message-tokenize-header references " ")
7690 (message-tokenize-header
7691 (or (message-fetch-field "references") "") " ")))
7692 ;; We only have to update this line.
7695 (message-narrow-to-head)
7696 (let ((head (buffer-string))
7699 (insert (format "211 %d Article retrieved.\n"
7700 (cdr gnus-article-current)))
7703 (let ((nntp-server-buffer (current-buffer)))
7704 (setq header (car (gnus-get-newsgroup-headers
7706 (set-buffer gnus-summary-buffer)
7707 gnus-newsgroup-dependencies)
7710 (set-buffer gnus-summary-buffer)
7711 (gnus-data-set-header
7712 (gnus-data-find (cdr gnus-article-current))
7714 (gnus-summary-update-article-line
7715 (cdr gnus-article-current) header))))))
7717 (set-buffer (or buffer gnus-summary-buffer))
7718 (gnus-summary-update-article (cdr gnus-article-current)))
7719 ;; Prettify the article buffer again.
7720 (unless no-highlight
7722 (set-buffer gnus-article-buffer)
7723 ;;;!!! Fix this -- article should be rehighlighted.
7724 ;;;(gnus-run-hooks 'gnus-article-display-hook)
7725 (set-buffer gnus-original-article-buffer)
7726 (gnus-request-article
7727 (cdr gnus-article-current)
7728 (car gnus-article-current) (current-buffer))))
7729 ;; Prettify the summary buffer line.
7730 (when (gnus-visual-p 'summary-highlight 'highlight)
7731 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
7733 (defun gnus-summary-edit-wash (key)
7734 "Perform editing command KEY in the article buffer."
7738 (message "%s" (concat (this-command-keys) "- "))
7741 (gnus-summary-edit-article)
7742 (execute-kbd-macro (concat (this-command-keys) key))
7743 (gnus-article-edit-done))
7747 (defun gnus-summary-respool-query (&optional silent trace)
7748 "Query where the respool algorithm would put this article."
7750 (let (gnus-mark-article-hook)
7751 (gnus-summary-select-article)
7753 (set-buffer gnus-original-article-buffer)
7755 (message-narrow-to-head)
7756 (let ((groups (nnmail-article-group 'identity trace)))
7759 (message "This message would go to %s"
7760 (mapconcat 'car groups ", "))
7761 (message "This message would go to no groups"))
7764 (defun gnus-summary-respool-trace ()
7765 "Trace where the respool algorithm would put this article.
7766 Display a buffer showing all fancy splitting patterns which matched."
7768 (gnus-summary-respool-query nil t))
7770 ;; Summary marking commands.
7772 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
7773 "Mark articles which has the same subject as read, and then select the next.
7774 If UNMARK is positive, remove any kind of mark.
7775 If UNMARK is negative, tick articles."
7778 (setq unmark (prefix-numeric-value unmark)))
7780 (gnus-summary-mark-same-subject
7781 (gnus-summary-article-subject) unmark)))
7782 ;; Select next unread article. If auto-select-same mode, should
7783 ;; select the first unread article.
7784 (gnus-summary-next-article t (and gnus-auto-select-same
7785 (gnus-summary-article-subject)))
7786 (gnus-message 7 "%d article%s marked as %s"
7787 count (if (= count 1) " is" "s are")
7788 (if unmark "unread" "read"))))
7790 (defun gnus-summary-kill-same-subject (&optional unmark)
7791 "Mark articles which has the same subject as read.
7792 If UNMARK is positive, remove any kind of mark.
7793 If UNMARK is negative, tick articles."
7796 (setq unmark (prefix-numeric-value unmark)))
7798 (gnus-summary-mark-same-subject
7799 (gnus-summary-article-subject) unmark)))
7800 ;; If marked as read, go to next unread subject.
7802 ;; Go to next unread subject.
7803 (gnus-summary-next-subject 1 t))
7804 (gnus-message 7 "%d articles are marked as %s"
7805 count (if unmark "unread" "read"))))
7807 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7808 "Mark articles with same SUBJECT as read, and return marked number.
7809 If optional argument UNMARK is positive, remove any kinds of marks.
7810 If optional argument UNMARK is negative, mark articles as unread instead."
7814 ((null unmark) ; Mark as read.
7817 (gnus-summary-mark-article-as-read gnus-killed-mark)
7818 (gnus-summary-show-thread) t)
7819 (gnus-summary-find-subject subject))
7820 (setq count (1+ count))))
7821 ((> unmark 0) ; Tick.
7824 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
7825 (gnus-summary-show-thread) t)
7826 (gnus-summary-find-subject subject))
7827 (setq count (1+ count))))
7828 (t ; Mark as unread.
7831 (gnus-summary-mark-article-as-unread gnus-unread-mark)
7832 (gnus-summary-show-thread) t)
7833 (gnus-summary-find-subject subject))
7834 (setq count (1+ count)))))
7835 (gnus-set-mode-line 'summary)
7836 ;; Return the number of marked articles.
7839 (defun gnus-summary-mark-as-processable (n &optional unmark)
7840 "Set the process mark on the next N articles.
7841 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7842 the process mark instead. The difference between N and the actual
7843 number of articles marked is returned."
7845 (let ((backward (< n 0))
7850 (gnus-summary-remove-process-mark
7851 (gnus-summary-article-number))
7852 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7853 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7856 (gnus-message 7 "No more articles"))
7857 (gnus-summary-recenter)
7858 (gnus-summary-position-point)
7861 (defun gnus-summary-unmark-as-processable (n)
7862 "Remove the process mark from the next N articles.
7863 If N is negative, unmark backward instead. The difference between N and
7864 the actual number of articles unmarked is returned."
7866 (gnus-summary-mark-as-processable n t))
7868 (defun gnus-summary-unmark-all-processable ()
7869 "Remove the process mark from all articles."
7872 (while gnus-newsgroup-processable
7873 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7874 (gnus-summary-position-point))
7876 (defun gnus-summary-mark-as-expirable (n)
7877 "Mark N articles forward as expirable.
7878 If N is negative, mark backward instead. The difference between N and
7879 the actual number of articles marked is returned."
7881 (gnus-summary-mark-forward n gnus-expirable-mark))
7883 (defun gnus-summary-mark-article-as-replied (article)
7884 "Mark ARTICLE replied and update the summary line."
7885 (push article gnus-newsgroup-replied)
7886 (let ((buffer-read-only nil))
7887 (when (gnus-summary-goto-subject article nil t)
7888 (gnus-summary-update-secondary-mark article))))
7890 (defun gnus-summary-set-bookmark (article)
7891 "Set a bookmark in current article."
7892 (interactive (list (gnus-summary-article-number)))
7893 (when (or (not (get-buffer gnus-article-buffer))
7894 (not gnus-current-article)
7895 (not gnus-article-current)
7896 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7897 (error "No current article selected"))
7898 ;; Remove old bookmark, if one exists.
7899 (let ((old (assq article gnus-newsgroup-bookmarks)))
7901 (setq gnus-newsgroup-bookmarks
7902 (delq old gnus-newsgroup-bookmarks))))
7903 ;; Set the new bookmark, which is on the form
7904 ;; (article-number . line-number-in-body).
7908 (set-buffer gnus-article-buffer)
7912 (goto-char (point-min))
7913 (search-forward "\n\n" nil t)
7916 gnus-newsgroup-bookmarks)
7917 (gnus-message 6 "A bookmark has been added to the current article."))
7919 (defun gnus-summary-remove-bookmark (article)
7920 "Remove the bookmark from the current article."
7921 (interactive (list (gnus-summary-article-number)))
7922 ;; Remove old bookmark, if one exists.
7923 (let ((old (assq article gnus-newsgroup-bookmarks)))
7926 (setq gnus-newsgroup-bookmarks
7927 (delq old gnus-newsgroup-bookmarks))
7928 (gnus-message 6 "Removed bookmark."))
7929 (gnus-message 6 "No bookmark in current article."))))
7931 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7932 (defun gnus-summary-mark-as-dormant (n)
7933 "Mark N articles forward as dormant.
7934 If N is negative, mark backward instead. The difference between N and
7935 the actual number of articles marked is returned."
7937 (gnus-summary-mark-forward n gnus-dormant-mark))
7939 (defun gnus-summary-set-process-mark (article)
7940 "Set the process mark on ARTICLE and update the summary line."
7941 (setq gnus-newsgroup-processable
7943 (delq article gnus-newsgroup-processable)))
7944 (when (gnus-summary-goto-subject article)
7945 (gnus-summary-show-thread)
7946 (gnus-summary-goto-subject article)
7947 (gnus-summary-update-secondary-mark article)))
7949 (defun gnus-summary-remove-process-mark (article)
7950 "Remove the process mark from ARTICLE and update the summary line."
7951 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7952 (when (gnus-summary-goto-subject article)
7953 (gnus-summary-show-thread)
7954 (gnus-summary-goto-subject article)
7955 (gnus-summary-update-secondary-mark article)))
7957 (defun gnus-summary-set-saved-mark (article)
7958 "Set the process mark on ARTICLE and update the summary line."
7959 (push article gnus-newsgroup-saved)
7960 (when (gnus-summary-goto-subject article)
7961 (gnus-summary-update-secondary-mark article)))
7963 (defun gnus-summary-mark-forward (n &optional mark no-expire)
7964 "Mark N articles as read forwards.
7965 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
7966 The difference between N and the actual number of articles marked is
7969 (gnus-summary-show-thread)
7970 (let ((backward (< n 0))
7971 (gnus-summary-goto-unread
7972 (and gnus-summary-goto-unread
7973 (not (eq gnus-summary-goto-unread 'never))
7974 (not (memq mark (list gnus-unread-mark
7975 gnus-ticked-mark gnus-dormant-mark)))))
7977 (mark (or mark gnus-del-mark)))
7979 (gnus-summary-mark-article nil mark no-expire)
7980 (zerop (gnus-summary-next-subject
7982 (and gnus-summary-goto-unread
7983 (not (eq gnus-summary-goto-unread 'never)))
7987 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
7988 (gnus-summary-recenter)
7989 (gnus-summary-position-point)
7990 (gnus-set-mode-line 'summary)
7993 (defun gnus-summary-mark-article-as-read (mark)
7994 "Mark the current article quickly as read with MARK."
7995 (let ((article (gnus-summary-article-number)))
7996 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7997 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7998 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7999 (push (cons article mark) gnus-newsgroup-reads)
8000 ;; Possibly remove from cache, if that is used.
8001 (when gnus-use-cache
8002 (gnus-cache-enter-remove-article article))
8003 ;; Allow the backend to change the mark.
8004 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8005 ;; Check for auto-expiry.
8006 (when (and gnus-newsgroup-auto-expire
8007 (memq mark gnus-auto-expirable-marks))
8008 (setq mark gnus-expirable-mark)
8009 ;; Let the backend know about the mark change.
8010 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8011 (push article gnus-newsgroup-expirable))
8012 ;; Set the mark in the buffer.
8013 (gnus-summary-update-mark mark 'unread)
8016 (defun gnus-summary-mark-article-as-unread (mark)
8017 "Mark the current article quickly as unread with MARK."
8018 (let* ((article (gnus-summary-article-number))
8019 (old-mark (gnus-summary-article-mark article)))
8020 ;; Allow the backend to change the mark.
8021 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8022 (if (eq mark old-mark)
8026 (gnus-error 1 "Can't mark negative article numbers")
8028 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8029 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8030 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
8031 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
8032 (cond ((= mark gnus-ticked-mark)
8033 (push article gnus-newsgroup-marked))
8034 ((= mark gnus-dormant-mark)
8035 (push article gnus-newsgroup-dormant))
8037 (push article gnus-newsgroup-unreads)))
8038 (gnus-pull article gnus-newsgroup-reads)
8040 ;; See whether the article is to be put in the cache.
8042 (vectorp (gnus-summary-article-header article))
8044 (gnus-cache-possibly-enter-article
8045 gnus-newsgroup-name article
8046 (= mark gnus-ticked-mark)
8047 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8050 (gnus-summary-update-mark mark 'unread)
8053 (defun gnus-summary-mark-article (&optional article mark no-expire)
8054 "Mark ARTICLE with MARK. MARK can be any character.
8055 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
8056 `??' (dormant) and `?E' (expirable).
8057 If MARK is nil, then the default character `?r' is used.
8058 If ARTICLE is nil, then the article on the current line will be
8060 ;; The mark might be a string.
8061 (when (stringp mark)
8062 (setq mark (aref mark 0)))
8063 ;; If no mark is given, then we check auto-expiring.
8065 (setq mark gnus-del-mark))
8066 (when (and (not no-expire)
8067 gnus-newsgroup-auto-expire
8068 (memq mark gnus-auto-expirable-marks))
8069 (setq mark gnus-expirable-mark))
8070 (let ((article (or article (gnus-summary-article-number)))
8071 (old-mark (gnus-summary-article-mark article)))
8072 ;; Allow the backend to change the mark.
8073 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8074 (if (eq mark old-mark)
8077 (error "No article on current line"))
8078 (if (not (if (or (= mark gnus-unread-mark)
8079 (= mark gnus-ticked-mark)
8080 (= mark gnus-dormant-mark))
8081 (gnus-mark-article-as-unread article mark)
8082 (gnus-mark-article-as-read article mark)))
8084 ;; See whether the article is to be put in the cache.
8086 (not (= mark gnus-canceled-mark))
8087 (vectorp (gnus-summary-article-header article))
8089 (gnus-cache-possibly-enter-article
8090 gnus-newsgroup-name article
8091 (= mark gnus-ticked-mark)
8092 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8094 (when (gnus-summary-goto-subject article nil t)
8095 (let ((buffer-read-only nil))
8096 (gnus-summary-show-thread)
8098 (gnus-summary-update-mark mark 'unread)
8101 (defun gnus-summary-update-secondary-mark (article)
8102 "Update the secondary (read, process, cache) mark."
8103 (gnus-summary-update-mark
8104 (cond ((memq article gnus-newsgroup-processable)
8106 ((memq article gnus-newsgroup-cached)
8108 ((memq article gnus-newsgroup-replied)
8110 ((memq article gnus-newsgroup-saved)
8112 (t gnus-unread-mark))
8114 (when (gnus-visual-p 'summary-highlight 'highlight)
8115 (gnus-run-hooks 'gnus-summary-update-hook))
8118 (defun gnus-summary-update-mark (mark type)
8119 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
8120 (buffer-read-only nil))
8121 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
8123 (when (looking-at "\r")
8125 (when (<= (+ forward (point)) (point-max))
8126 ;; Go to the right position on the line.
8127 (goto-char (+ forward (point)))
8128 ;; Replace the old mark with the new mark.
8129 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
8130 ;; Optionally update the marks by some user rule.
8131 (when (eq type 'unread)
8133 (gnus-data-find (gnus-summary-article-number)) mark)
8134 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
8136 (defun gnus-mark-article-as-read (article &optional mark)
8137 "Enter ARTICLE in the pertinent lists and remove it from others."
8138 ;; Make the article expirable.
8139 (let ((mark (or mark gnus-del-mark)))
8140 (if (= mark gnus-expirable-mark)
8141 (push article gnus-newsgroup-expirable)
8142 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
8143 ;; Remove from unread and marked lists.
8144 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8145 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8146 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8147 (push (cons article mark) gnus-newsgroup-reads)
8148 ;; Possibly remove from cache, if that is used.
8149 (when gnus-use-cache
8150 (gnus-cache-enter-remove-article article))
8153 (defun gnus-mark-article-as-unread (article &optional mark)
8154 "Enter ARTICLE in the pertinent lists and remove it from others."
8155 (let ((mark (or mark gnus-ticked-mark)))
8158 (gnus-error 1 "Can't mark negative article numbers")
8160 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
8161 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
8162 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
8163 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8165 ;; Unsuppress duplicates?
8166 (when gnus-suppress-duplicates
8167 (gnus-dup-unsuppress-article article))
8169 (cond ((= mark gnus-ticked-mark)
8170 (push article gnus-newsgroup-marked))
8171 ((= mark gnus-dormant-mark)
8172 (push article gnus-newsgroup-dormant))
8174 (push article gnus-newsgroup-unreads)))
8175 (gnus-pull article gnus-newsgroup-reads)
8178 (defalias 'gnus-summary-mark-as-unread-forward
8179 'gnus-summary-tick-article-forward)
8180 (make-obsolete 'gnus-summary-mark-as-unread-forward
8181 'gnus-summary-tick-article-forward)
8182 (defun gnus-summary-tick-article-forward (n)
8183 "Tick N articles forwards.
8184 If N is negative, tick backwards instead.
8185 The difference between N and the number of articles ticked is returned."
8187 (gnus-summary-mark-forward n gnus-ticked-mark))
8189 (defalias 'gnus-summary-mark-as-unread-backward
8190 'gnus-summary-tick-article-backward)
8191 (make-obsolete 'gnus-summary-mark-as-unread-backward
8192 'gnus-summary-tick-article-backward)
8193 (defun gnus-summary-tick-article-backward (n)
8194 "Tick N articles backwards.
8195 The difference between N and the number of articles ticked is returned."
8197 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
8199 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8200 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8201 (defun gnus-summary-tick-article (&optional article clear-mark)
8202 "Mark current article as unread.
8203 Optional 1st argument ARTICLE specifies article number to be marked as unread.
8204 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
8206 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
8209 (defun gnus-summary-mark-as-read-forward (n)
8210 "Mark N articles as read forwards.
8211 If N is negative, mark backwards instead.
8212 The difference between N and the actual number of articles marked is
8215 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
8217 (defun gnus-summary-mark-as-read-backward (n)
8218 "Mark the N articles as read backwards.
8219 The difference between N and the actual number of articles marked is
8222 (gnus-summary-mark-forward
8223 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
8225 (defun gnus-summary-mark-as-read (&optional article mark)
8226 "Mark current article as read.
8227 ARTICLE specifies the article to be marked as read.
8228 MARK specifies a string to be inserted at the beginning of the line."
8229 (gnus-summary-mark-article article mark))
8231 (defun gnus-summary-clear-mark-forward (n)
8232 "Clear marks from N articles forward.
8233 If N is negative, clear backward instead.
8234 The difference between N and the number of marks cleared is returned."
8236 (gnus-summary-mark-forward n gnus-unread-mark))
8238 (defun gnus-summary-clear-mark-backward (n)
8239 "Clear marks from N articles backward.
8240 The difference between N and the number of marks cleared is returned."
8242 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8244 (defun gnus-summary-mark-unread-as-read ()
8245 "Intended to be used by `gnus-summary-mark-article-hook'."
8246 (when (memq gnus-current-article gnus-newsgroup-unreads)
8247 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
8249 (defun gnus-summary-mark-read-and-unread-as-read ()
8250 "Intended to be used by `gnus-summary-mark-article-hook'."
8251 (let ((mark (gnus-summary-article-mark)))
8252 (when (or (gnus-unread-mark-p mark)
8253 (gnus-read-mark-p mark))
8254 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
8256 (defun gnus-summary-mark-region-as-read (point mark all)
8257 "Mark all unread articles between point and mark as read.
8258 If given a prefix, mark all articles between point and mark as read,
8259 even ticked and dormant ones."
8260 (interactive "r\nP")
8269 (memq (setq article (gnus-summary-article-number))
8270 gnus-newsgroup-unreads))
8271 (gnus-summary-mark-article article gnus-del-mark))
8273 (gnus-summary-find-next))))))
8275 (defun gnus-summary-mark-below (score mark)
8276 "Mark articles with score less than SCORE with MARK."
8277 (interactive "P\ncMark: ")
8278 (setq score (if score
8279 (prefix-numeric-value score)
8280 (or gnus-summary-default-score 0)))
8282 (set-buffer gnus-summary-buffer)
8283 (goto-char (point-min))
8286 (and (< (gnus-summary-article-score) score)
8287 (gnus-summary-mark-article nil mark))
8288 (gnus-summary-find-next)))))
8290 (defun gnus-summary-kill-below (&optional score)
8291 "Mark articles with score below SCORE as read."
8293 (gnus-summary-mark-below score gnus-killed-mark))
8295 (defun gnus-summary-clear-above (&optional score)
8296 "Clear all marks from articles with score above SCORE."
8298 (gnus-summary-mark-above score gnus-unread-mark))
8300 (defun gnus-summary-tick-above (&optional score)
8301 "Tick all articles with score above SCORE."
8303 (gnus-summary-mark-above score gnus-ticked-mark))
8305 (defun gnus-summary-mark-above (score mark)
8306 "Mark articles with score over SCORE with MARK."
8307 (interactive "P\ncMark: ")
8308 (setq score (if score
8309 (prefix-numeric-value score)
8310 (or gnus-summary-default-score 0)))
8312 (set-buffer gnus-summary-buffer)
8313 (goto-char (point-min))
8315 (when (> (gnus-summary-article-score) score)
8316 (gnus-summary-mark-article nil mark))
8318 (gnus-summary-find-next)))))
8320 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8321 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
8322 (defun gnus-summary-limit-include-expunged (&optional no-error)
8323 "Display all the hidden articles that were expunged for low scores."
8325 (let ((buffer-read-only nil))
8326 (let ((scored gnus-newsgroup-scored)
8329 (unless (gnus-summary-goto-subject (caar scored))
8330 (and (setq h (gnus-summary-article-header (caar scored)))
8331 (< (cdar scored) gnus-summary-expunge-below)
8333 (setq scored (cdr scored)))
8335 (when (not no-error)
8336 (error "No expunged articles hidden"))
8337 (goto-char (point-min))
8338 (gnus-summary-prepare-unthreaded (nreverse headers))
8339 (goto-char (point-min))
8340 (gnus-summary-position-point)
8343 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
8344 "Mark all unread articles in this newsgroup as read.
8345 If prefix argument ALL is non-nil, ticked and dormant articles will
8346 also be marked as read.
8347 If QUIETLY is non-nil, no questions will be asked.
8348 If TO-HERE is non-nil, it should be a point in the buffer. All
8349 articles before this point will be marked as read.
8350 Note that this function will only catch up the unread article
8351 in the current summary buffer limitation.
8352 The number of articles marked as read is returned."
8357 (not gnus-interactive-catchup) ;Without confirmation?
8361 "Mark absolutely all articles as read? "
8362 "Mark all unread articles as read? ")))
8364 (not gnus-newsgroup-adaptive)
8365 (not gnus-newsgroup-auto-expire)
8366 (not gnus-suppress-duplicates)
8367 (or (not gnus-use-cache)
8368 (eq gnus-use-cache 'passive)))
8371 (setq gnus-newsgroup-marked nil
8372 gnus-newsgroup-dormant nil))
8373 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8374 ;; We actually mark all articles as canceled, which we
8375 ;; have to do when using auto-expiry or adaptive scoring.
8376 (gnus-summary-show-all-threads)
8377 (when (gnus-summary-first-subject (not all) t)
8379 (if to-here (< (point) to-here) t)
8380 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8381 (gnus-summary-find-next (not all) nil nil t))))
8382 (gnus-set-mode-line 'summary))
8384 (gnus-summary-position-point)))
8386 (defun gnus-summary-catchup-to-here (&optional all)
8387 "Mark all unticked articles before the current one as read.
8388 If ALL is non-nil, also mark ticked and dormant articles as read."
8391 (gnus-save-hidden-threads
8392 (let ((beg (point)))
8393 ;; We check that there are unread articles.
8394 (when (or all (gnus-summary-find-prev))
8395 (gnus-summary-catchup all t beg)))))
8396 (gnus-summary-position-point))
8398 (defun gnus-summary-catchup-all (&optional quietly)
8399 "Mark all articles in this newsgroup as read."
8401 (gnus-summary-catchup t quietly))
8403 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8404 "Mark all unread articles in this group as read, then exit.
8405 If prefix argument ALL is non-nil, all articles are marked as read."
8407 (when (gnus-summary-catchup all quietly nil 'fast)
8408 ;; Select next newsgroup or exit.
8409 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
8410 (eq gnus-auto-select-next 'quietly))
8411 (gnus-summary-next-group nil)
8412 (gnus-summary-exit))))
8414 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8415 "Mark all articles in this newsgroup as read, and then exit."
8417 (gnus-summary-catchup-and-exit t quietly))
8419 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8420 "Mark all articles in this group as read and select the next group.
8421 If given a prefix, mark all articles, unread as well as ticked, as
8425 (gnus-summary-catchup all))
8426 (gnus-summary-next-group))
8428 ;; Thread-based commands.
8430 (defun gnus-summary-articles-in-thread (&optional article)
8431 "Return a list of all articles in the current thread.
8432 If ARTICLE is non-nil, return all articles in the thread that starts
8434 (let* ((article (or article (gnus-summary-article-number)))
8435 (data (gnus-data-find-list article))
8436 (top-level (gnus-data-level (car data)))
8438 (cond ((null gnus-thread-operation-ignore-subject)
8439 (gnus-simplify-subject-re
8440 (mail-header-subject (gnus-data-header (car data)))))
8441 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8442 (gnus-simplify-subject-fuzzy
8443 (mail-header-subject (gnus-data-header (car data)))))
8445 (end-point (save-excursion
8446 (if (gnus-summary-go-to-next-thread)
8447 (point) (point-max))))
8450 (< (gnus-data-pos (car data)) end-point))
8451 (when (or (not top-subject)
8452 (string= top-subject
8453 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8454 (gnus-simplify-subject-fuzzy
8455 (mail-header-subject
8456 (gnus-data-header (car data))))
8457 (gnus-simplify-subject-re
8458 (mail-header-subject
8459 (gnus-data-header (car data)))))))
8460 (push (gnus-data-number (car data)) articles))
8461 (unless (and (setq data (cdr data))
8462 (> (gnus-data-level (car data)) top-level))
8464 ;; Return the list of articles.
8465 (nreverse articles)))
8467 (defun gnus-summary-rethread-current ()
8468 "Rethread the thread the current article is part of."
8470 (let* ((gnus-show-threads t)
8471 (article (gnus-summary-article-number))
8472 (id (mail-header-id (gnus-summary-article-header)))
8473 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8475 (error "No article on the current line"))
8476 (gnus-rebuild-thread id)
8477 (gnus-summary-goto-subject article)))
8479 (defun gnus-summary-reparent-thread ()
8480 "Make the current article child of the marked (or previous) article.
8482 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8483 is non-nil or the Subject: of both articles are the same."
8485 (unless (not (gnus-group-read-only-p))
8486 (error "The current newsgroup does not support article editing"))
8487 (unless (<= (length gnus-newsgroup-processable) 1)
8488 (error "No more than one article may be marked"))
8489 (save-window-excursion
8490 (let ((gnus-article-buffer " *reparent*")
8491 (current-article (gnus-summary-article-number))
8492 ;; First grab the marked article, otherwise one line up.
8493 (parent-article (if (not (null gnus-newsgroup-processable))
8494 (car gnus-newsgroup-processable)
8496 (if (eq (forward-line -1) 0)
8497 (gnus-summary-article-number)
8498 (error "Beginning of summary buffer"))))))
8499 (unless (not (eq current-article parent-article))
8500 (error "An article may not be self-referential"))
8501 (let ((message-id (mail-header-id
8502 (gnus-summary-article-header parent-article))))
8503 (unless (and message-id (not (equal message-id "")))
8504 (error "No message-id in desired parent"))
8505 (gnus-with-article current-article
8506 (goto-char (point-min))
8507 (if (re-search-forward "^References: " nil t)
8509 (re-search-forward "^[^ \t]" nil t)
8512 (insert " " message-id))
8513 (insert "References: " message-id "\n")))
8514 (set-buffer gnus-summary-buffer)
8515 (gnus-summary-unmark-all-processable)
8516 (gnus-summary-update-article current-article)
8517 (gnus-summary-rethread-current)
8518 (gnus-message 3 "Article %d is now the child of article %d"
8519 current-article parent-article)))))
8521 (defun gnus-summary-toggle-threads (&optional arg)
8522 "Toggle showing conversation threads.
8523 If ARG is positive number, turn showing conversation threads on."
8525 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8526 (setq gnus-show-threads
8527 (if (null arg) (not gnus-show-threads)
8528 (> (prefix-numeric-value arg) 0)))
8529 (gnus-summary-prepare)
8530 (gnus-summary-goto-subject current)
8531 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8532 (gnus-summary-position-point)))
8534 (defun gnus-summary-show-all-threads ()
8538 (let ((buffer-read-only nil))
8539 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8540 (gnus-summary-position-point))
8542 (defun gnus-summary-show-thread ()
8543 "Show thread subtrees.
8544 Returns nil if no thread was there to be shown."
8546 (let ((buffer-read-only nil)
8548 ;; first goto end then to beg, to have point at beg after let
8549 (end (progn (end-of-line) (point)))
8550 (beg (progn (beginning-of-line) (point))))
8552 ;; Any hidden lines here?
8553 (search-forward "\r" end t)
8554 (subst-char-in-region beg end ?\^M ?\n t)
8556 (gnus-summary-position-point))))
8558 (defun gnus-summary-hide-all-threads ()
8559 "Hide all thread subtrees."
8562 (goto-char (point-min))
8563 (gnus-summary-hide-thread)
8564 (while (zerop (gnus-summary-next-thread 1 t))
8565 (gnus-summary-hide-thread)))
8566 (gnus-summary-position-point))
8568 (defun gnus-summary-hide-thread ()
8569 "Hide thread subtrees.
8570 Returns nil if no threads were there to be hidden."
8572 (let ((buffer-read-only nil)
8574 (article (gnus-summary-article-number)))
8576 ;; Go forward until either the buffer ends or the subthread
8578 (when (and (not (eobp))
8579 (or (zerop (gnus-summary-next-thread 1 t))
8580 (goto-char (point-max))))
8582 (if (and (> (point) start)
8583 (search-backward "\n" start t))
8585 (subst-char-in-region start (point) ?\n ?\^M)
8586 (gnus-summary-goto-subject article))
8589 ;;(gnus-summary-position-point)
8592 (defun gnus-summary-go-to-next-thread (&optional previous)
8593 "Go to the same level (or less) next thread.
8594 If PREVIOUS is non-nil, go to previous thread instead.
8595 Return the article number moved to, or nil if moving was impossible."
8596 (let ((level (gnus-summary-thread-level))
8597 (way (if previous -1 1))
8600 (while (and (not (eobp))
8601 (< level (gnus-summary-thread-level)))
8609 (gnus-summary-article-number)
8612 (defun gnus-summary-next-thread (n &optional silent)
8613 "Go to the same level next N'th thread.
8614 If N is negative, search backward instead.
8615 Returns the difference between N and the number of skips actually
8618 If SILENT, don't output messages."
8620 (let ((backward (< n 0))
8623 (gnus-summary-go-to-next-thread backward))
8626 (gnus-summary-position-point))
8627 (when (and (not silent) (/= 0 n))
8628 (gnus-message 7 "No more threads"))
8631 (defun gnus-summary-prev-thread (n)
8632 "Go to the same level previous N'th thread.
8633 Returns the difference between N and the number of skips actually
8636 (gnus-summary-next-thread (- n)))
8638 (defun gnus-summary-go-down-thread ()
8639 "Go down one level in the current thread."
8640 (let ((children (gnus-summary-article-children)))
8642 (gnus-summary-goto-subject (car children)))))
8644 (defun gnus-summary-go-up-thread ()
8645 "Go up one level in the current thread."
8646 (let ((parent (gnus-summary-article-parent)))
8648 (gnus-summary-goto-subject parent))))
8650 (defun gnus-summary-down-thread (n)
8651 "Go down thread N steps.
8652 If N is negative, go up instead.
8653 Returns the difference between N and how many steps down that were
8659 (if up (gnus-summary-go-up-thread)
8660 (gnus-summary-go-down-thread)))
8662 (gnus-summary-position-point)
8664 (gnus-message 7 "Can't go further"))
8667 (defun gnus-summary-up-thread (n)
8668 "Go up thread N steps.
8669 If N is negative, go up instead.
8670 Returns the difference between N and how many steps down that were
8673 (gnus-summary-down-thread (- n)))
8675 (defun gnus-summary-top-thread ()
8676 "Go to the top of the thread."
8678 (while (gnus-summary-go-up-thread))
8679 (gnus-summary-article-number))
8681 (defun gnus-summary-kill-thread (&optional unmark)
8682 "Mark articles under current thread as read.
8683 If the prefix argument is positive, remove any kinds of marks.
8684 If the prefix argument is negative, tick articles instead."
8687 (setq unmark (prefix-numeric-value unmark)))
8688 (let ((articles (gnus-summary-articles-in-thread)))
8690 ;; Expand the thread.
8691 (gnus-summary-show-thread)
8692 ;; Mark all the articles.
8694 (gnus-summary-goto-subject (car articles))
8695 (cond ((null unmark)
8696 (gnus-summary-mark-article-as-read gnus-killed-mark))
8698 (gnus-summary-mark-article-as-unread gnus-unread-mark))
8700 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
8701 (setq articles (cdr articles))))
8702 ;; Hide killed subtrees.
8704 gnus-thread-hide-killed
8705 (gnus-summary-hide-thread))
8706 ;; If marked as read, go to next unread subject.
8708 ;; Go to next unread subject.
8709 (gnus-summary-next-subject 1 t)))
8710 (gnus-set-mode-line 'summary))
8712 ;; Summary sorting commands
8714 (defun gnus-summary-sort-by-number (&optional reverse)
8715 "Sort the summary buffer by article number.
8716 Argument REVERSE means reverse order."
8718 (gnus-summary-sort 'number reverse))
8720 (defun gnus-summary-sort-by-author (&optional reverse)
8721 "Sort the summary buffer by author name alphabetically.
8722 If case-fold-search is non-nil, case of letters is ignored.
8723 Argument REVERSE means reverse order."
8725 (gnus-summary-sort 'author reverse))
8727 (defun gnus-summary-sort-by-subject (&optional reverse)
8728 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8729 If case-fold-search is non-nil, case of letters is ignored.
8730 Argument REVERSE means reverse order."
8732 (gnus-summary-sort 'subject reverse))
8734 (defun gnus-summary-sort-by-date (&optional reverse)
8735 "Sort the summary buffer by date.
8736 Argument REVERSE means reverse order."
8738 (gnus-summary-sort 'date reverse))
8740 (defun gnus-summary-sort-by-score (&optional reverse)
8741 "Sort the summary buffer by score.
8742 Argument REVERSE means reverse order."
8744 (gnus-summary-sort 'score reverse))
8746 (defun gnus-summary-sort-by-lines (&optional reverse)
8747 "Sort the summary buffer by the number of lines.
8748 Argument REVERSE means reverse order."
8750 (gnus-summary-sort 'lines reverse))
8752 (defun gnus-summary-sort-by-chars (&optional reverse)
8753 "Sort the summary buffer by article length.
8754 Argument REVERSE means reverse order."
8756 (gnus-summary-sort 'chars reverse))
8758 (defun gnus-summary-sort (predicate reverse)
8759 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
8760 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
8761 (article (intern (format "gnus-article-sort-by-%s" predicate)))
8762 (gnus-thread-sort-functions
8767 (gnus-article-sort-functions
8773 (gnus-summary-prepare-hook nil))
8774 ;; We do the sorting by regenerating the threads.
8775 (gnus-summary-prepare)
8776 ;; Hide subthreads if needed.
8777 (when (and gnus-show-threads gnus-thread-hide-subtree)
8778 (gnus-summary-hide-all-threads))))
8780 ;; Summary saving commands.
8782 (defun gnus-summary-save-article (&optional n not-saved)
8783 "Save the current article using the default saver function.
8784 If N is a positive number, save the N next articles.
8785 If N is a negative number, save the N previous articles.
8786 If N is nil and any articles have been marked with the process mark,
8787 save those articles instead.
8788 The variable `gnus-default-article-saver' specifies the saver function."
8790 (let* ((articles (gnus-summary-work-articles n))
8791 (save-buffer (save-excursion
8792 (nnheader-set-temp-buffer " *Gnus Save*")))
8793 (num (length articles))
8795 (dolist (article articles)
8796 (setq header (gnus-summary-article-header article))
8797 (if (not (vectorp header))
8798 ;; This is a pseudo-article.
8799 (if (assq 'name header)
8800 (gnus-copy-file (cdr (assq 'name header)))
8801 (gnus-message 1 "Article %d is unsaveable" article))
8802 ;; This is a real article.
8803 (save-window-excursion
8804 (gnus-summary-select-article t nil nil article))
8806 (set-buffer save-buffer)
8808 (insert-buffer-substring gnus-original-article-buffer))
8809 (setq file (gnus-article-save save-buffer file num))
8810 (gnus-summary-remove-process-mark article)
8812 (gnus-summary-set-saved-mark article))))
8813 (gnus-kill-buffer save-buffer)
8814 (gnus-summary-position-point)
8815 (gnus-set-mode-line 'summary)
8818 (defun gnus-summary-pipe-output (&optional arg)
8819 "Pipe the current article to a subprocess.
8820 If N is a positive number, pipe the N next articles.
8821 If N is a negative number, pipe the N previous articles.
8822 If N is nil and any articles have been marked with the process mark,
8823 pipe those articles instead."
8825 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8826 (gnus-summary-save-article arg t))
8827 (gnus-configure-windows 'pipe))
8829 (defun gnus-summary-save-article-mail (&optional arg)
8830 "Append the current article to an mail file.
8831 If N is a positive number, save the N next articles.
8832 If N is a negative number, save the N previous articles.
8833 If N is nil and any articles have been marked with the process mark,
8834 save those articles instead."
8836 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8837 (gnus-summary-save-article arg)))
8839 (defun gnus-summary-save-article-rmail (&optional arg)
8840 "Append the current article to an rmail file.
8841 If N is a positive number, save the N next articles.
8842 If N is a negative number, save the N previous articles.
8843 If N is nil and any articles have been marked with the process mark,
8844 save those articles instead."
8846 (let ((gnus-default-article-saver 'rmail-output-to-rmail-file))
8847 (gnus-summary-save-article arg)))
8849 (defun gnus-summary-save-article-file (&optional arg)
8850 "Append the current article to a file.
8851 If N is a positive number, save the N next articles.
8852 If N is a negative number, save the N previous articles.
8853 If N is nil and any articles have been marked with the process mark,
8854 save those articles instead."
8856 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8857 (gnus-summary-save-article arg)))
8859 (defun gnus-summary-write-article-file (&optional arg)
8860 "Write the current article to a file, deleting the previous file.
8861 If N is a positive number, save the N next articles.
8862 If N is a negative number, save the N previous articles.
8863 If N is nil and any articles have been marked with the process mark,
8864 save those articles instead."
8866 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
8867 (gnus-summary-save-article arg)))
8869 (defun gnus-summary-save-article-body-file (&optional arg)
8870 "Append the current article body to a file.
8871 If N is a positive number, save the N next articles.
8872 If N is a negative number, save the N previous articles.
8873 If N is nil and any articles have been marked with the process mark,
8874 save those articles instead."
8876 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
8877 (gnus-summary-save-article arg)))
8879 (defun gnus-summary-pipe-message (program)
8880 "Pipe the current article through PROGRAM."
8881 (interactive "sProgram: ")
8882 (gnus-summary-select-article)
8883 (let ((mail-header-separator ""))
8884 (gnus-eval-in-buffer-window gnus-article-buffer
8887 (let ((start (window-start))
8889 (message-pipe-buffer-body program)
8890 (set-window-start (get-buffer-window (current-buffer)) start))))))
8892 (defun gnus-get-split-value (methods)
8893 "Return a value based on the split METHODS."
8894 (let (split-name method result match)
8897 (set-buffer gnus-original-article-buffer)
8899 (nnheader-narrow-to-headers)
8901 (goto-char (point-min))
8902 (setq method (pop methods))
8903 (setq match (car method))
8906 ;; Regular expression.
8908 (re-search-forward match nil t)))
8909 ((gnus-functionp match)
8913 (setq result (funcall match gnus-newsgroup-name))))
8918 (setq result (eval match)))))
8919 (setq split-name (append (cdr method) split-name))
8920 (cond ((stringp result)
8921 (push (expand-file-name
8922 result gnus-article-save-directory)
8925 (setq split-name (append result split-name)))))))))
8926 (nreverse split-name)))
8928 (defun gnus-valid-move-group-p (group)
8931 (symbol-value group)
8932 (gnus-get-function (gnus-find-method-for-group
8933 (symbol-name group)) 'request-accept-article t)))
8935 (defun gnus-read-move-group-name (prompt default articles prefix)
8936 "Read a group name."
8937 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
8938 (minibuffer-confirm-incomplete nil) ; XEmacs
8942 (if (> (length articles) 1)
8943 (format "these %d articles" (length articles))
8948 (gnus-completing-read default prom
8950 'gnus-valid-move-group-p
8952 'gnus-group-history))
8953 ((= 1 (length split-name))
8954 (gnus-completing-read (car split-name) prom
8956 'gnus-valid-move-group-p
8958 'gnus-group-history))
8960 (gnus-completing-read nil prom
8961 (mapcar (lambda (el) (list el))
8962 (nreverse split-name))
8964 'gnus-group-history)))))
8966 (if (or (string= to-newsgroup "")
8967 (string= to-newsgroup prefix))
8968 (setq to-newsgroup default))
8969 (unless to-newsgroup
8970 (error "No group name entered"))
8971 (or (gnus-active to-newsgroup)
8972 (gnus-activate-group to-newsgroup)
8973 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
8975 (or (and (gnus-request-create-group
8976 to-newsgroup (gnus-group-name-to-method to-newsgroup))
8977 (gnus-activate-group
8978 to-newsgroup nil nil
8979 (gnus-group-name-to-method to-newsgroup))
8980 (gnus-subscribe-group to-newsgroup))
8981 (error "Couldn't create group %s" to-newsgroup)))
8982 (error "No such group: %s" to-newsgroup)))
8985 (defun gnus-summary-save-parts (type dir n reverse)
8986 "Save parts matching TYPE to DIR.
8987 If REVERSE, save parts that do not match TYPE."
8989 (list (read-string "Save parts of type: " "image/.*")
8990 (read-file-name "Save to directory: " t nil t)
8991 current-prefix-arg))
8992 (gnus-summary-iterate n
8993 (let ((gnus-display-mime-function nil)
8994 (gnus-inhibit-treatment t))
8995 (gnus-summary-select-article))
8997 (set-buffer gnus-article-buffer)
8998 (let ((handles (or (mm-dissect-buffer) (mm-uu-dissect))))
9000 (gnus-summary-save-parts-1 type dir handles reverse)
9001 (mm-destroy-parts handles))))))
9003 (defun gnus-summary-save-parts-1 (type dir handle reverse)
9004 (if (stringp (car handle))
9005 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
9008 (not (string-match type (mm-handle-media-type handle)))
9009 (string-match type (mm-handle-media-type handle)))
9010 (let ((file (expand-file-name
9011 (file-name-nondirectory
9013 (mail-content-type-get
9014 (mm-handle-disposition handle) 'filename)
9015 (concat gnus-newsgroup-name "." gnus-current-article)))
9017 (unless (file-exists-p file)
9018 (mm-save-part-to-file handle file))))))
9020 ;; Summary extract commands
9022 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
9023 (let ((buffer-read-only nil)
9024 (article (gnus-summary-article-number))
9026 (unless (gnus-summary-goto-subject article)
9027 (error "No such article: %d" article))
9028 (gnus-summary-position-point)
9029 ;; If all commands are to be bunched up on one line, we collect
9031 (unless gnus-view-pseudos-separately
9032 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
9035 (setq action (cdr (assq 'action (car ps))))
9036 (setq files (list (cdr (assq 'name (car ps)))))
9037 (while (and ps (cdr ps)
9038 (string= (or action "1")
9039 (or (cdr (assq 'action (cadr ps))) "2")))
9040 (push (cdr (assq 'name (cadr ps))) files)
9041 (setcdr ps (cddr ps)))
9043 (when (not (string-match "%s" action))
9046 (when (assq 'execute (car ps))
9047 (setcdr (assq 'execute (car ps))
9048 (funcall (if (string-match "%s" action)
9057 (setq ps (cdr ps)))))
9058 (if (and gnus-view-pseudos (not not-view))
9060 (when (assq 'execute (car pslist))
9061 (gnus-execute-command (cdr (assq 'execute (car pslist)))
9062 (eq gnus-view-pseudos 'not-confirm)))
9063 (setq pslist (cdr pslist)))
9066 (setq after-article (or (cdr (assq 'article (car pslist)))
9067 (gnus-summary-article-number)))
9068 (gnus-summary-goto-subject after-article)
9071 (insert " " (file-name-nondirectory
9072 (cdr (assq 'name (car pslist))))
9073 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
9075 (forward-line -1) ; back to `b'
9076 (gnus-add-text-properties
9077 b (1- e) (list 'gnus-number gnus-reffed-article-number
9078 gnus-mouse-face-prop gnus-mouse-face))
9080 after-article gnus-reffed-article-number
9081 gnus-unread-mark b (car pslist) 0 (- e b))
9082 (push gnus-reffed-article-number gnus-newsgroup-unreads)
9083 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
9084 (setq pslist (cdr pslist)))))))
9086 (defun gnus-pseudos< (p1 p2)
9087 (let ((c1 (cdr (assq 'action p1)))
9088 (c2 (cdr (assq 'action p2))))
9089 (and c1 c2 (string< c1 c2))))
9091 (defun gnus-request-pseudo-article (props)
9092 (cond ((assq 'execute props)
9093 (gnus-execute-command (cdr (assq 'execute props)))))
9094 (let ((gnus-current-article (gnus-summary-article-number)))
9095 (gnus-run-hooks 'gnus-mark-article-hook)))
9097 (defun gnus-execute-command (command &optional automatic)
9099 (gnus-article-setup-buffer)
9100 (set-buffer gnus-article-buffer)
9101 (setq buffer-read-only nil)
9102 (let ((command (if automatic command
9103 (read-string "Command: " (cons command 0)))))
9105 (insert "$ " command "\n\n")
9106 (if gnus-view-pseudo-asynchronously
9107 (start-process "gnus-execute" (current-buffer) shell-file-name
9108 shell-command-switch command)
9109 (call-process shell-file-name nil t nil
9110 shell-command-switch command)))))
9112 ;; Summary kill commands.
9114 (defun gnus-summary-edit-global-kill (article)
9115 "Edit the \"global\" kill file."
9116 (interactive (list (gnus-summary-article-number)))
9117 (gnus-group-edit-global-kill article))
9119 (defun gnus-summary-edit-local-kill ()
9120 "Edit a local kill file applied to the current newsgroup."
9122 (setq gnus-current-headers (gnus-summary-article-header))
9123 (gnus-group-edit-local-kill
9124 (gnus-summary-article-number) gnus-newsgroup-name))
9128 (defun gnus-read-header (id &optional header)
9129 "Read the headers of article ID and enter them into the Gnus system."
9130 (let ((group gnus-newsgroup-name)
9131 (gnus-override-method
9132 (and (gnus-news-group-p gnus-newsgroup-name)
9133 gnus-refer-article-method))
9135 ;; First we check to see whether the header in question is already
9138 ;; This is a Message-ID.
9139 (setq header (or header (gnus-id-to-header id)))
9140 ;; This is an article number.
9141 (setq header (or header (gnus-summary-article-header id))))
9143 (not (gnus-summary-article-sparse-p (mail-header-number header))))
9144 ;; We have found the header.
9146 ;; If this is a sparse article, we have to nix out its
9147 ;; previous entry in the thread hashtb.
9149 (gnus-summary-article-sparse-p (mail-header-number header)))
9150 (let* ((parent (gnus-parent-id (mail-header-references header)))
9151 (thread (and parent (gnus-id-to-thread parent))))
9153 (delq (assq header thread) thread))))
9154 ;; We have to really fetch the header to this article.
9156 (set-buffer nntp-server-buffer)
9157 (when (setq where (gnus-request-head id group))
9158 (nnheader-fold-continuation-lines)
9159 (goto-char (point-max))
9161 (goto-char (point-min))
9165 ((cdr where) (cdr where))
9166 (header (mail-header-number header))
9167 (t gnus-reffed-article-number))
9169 (insert " Article retrieved.\n"))
9171 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
9172 () ; Malformed head.
9173 (unless (gnus-summary-article-sparse-p (mail-header-number header))
9174 (when (and (stringp id)
9175 (not (string= (gnus-group-real-name group)
9177 ;; If we fetched by Message-ID and the article came
9178 ;; from a different group, we fudge some bogus article
9179 ;; numbers for this article.
9180 (mail-header-set-number header gnus-reffed-article-number))
9182 (set-buffer gnus-summary-buffer)
9183 (decf gnus-reffed-article-number)
9184 (gnus-remove-header (mail-header-number header))
9185 (push header gnus-newsgroup-headers)
9186 (setq gnus-current-headers header)
9187 (push (mail-header-number header) gnus-newsgroup-limit)))
9190 (defun gnus-remove-header (number)
9191 "Remove header NUMBER from `gnus-newsgroup-headers'."
9192 (if (and gnus-newsgroup-headers
9193 (= number (mail-header-number (car gnus-newsgroup-headers))))
9194 (pop gnus-newsgroup-headers)
9195 (let ((headers gnus-newsgroup-headers))
9196 (while (and (cdr headers)
9197 (not (= number (mail-header-number (cadr headers)))))
9200 (setcdr headers (cddr headers))))))
9203 ;;; summary highlights
9206 (defun gnus-highlight-selected-summary ()
9207 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
9208 ;; Highlight selected article in summary buffer
9209 (when gnus-summary-selected-face
9211 (let* ((beg (progn (beginning-of-line) (point)))
9212 (end (progn (end-of-line) (point)))
9213 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
9214 (from (if (get-text-property beg gnus-mouse-face-prop)
9216 (or (next-single-property-change
9217 beg gnus-mouse-face-prop nil end)
9222 (or (next-single-property-change
9223 from gnus-mouse-face-prop nil end)
9225 ;; If no mouse-face prop on line we will have to = from = end,
9226 ;; so we highlight the entire line instead.
9227 (when (= (+ to 2) from)
9230 (if gnus-newsgroup-selected-overlay
9231 ;; Move old overlay.
9233 gnus-newsgroup-selected-overlay from to (current-buffer))
9234 ;; Create new overlay.
9236 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
9237 'face gnus-summary-selected-face))))))
9239 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
9240 (defun gnus-summary-highlight-line ()
9241 "Highlight current line according to `gnus-summary-highlight'."
9242 (let* ((list gnus-summary-highlight)
9244 (end (progn (end-of-line) (point)))
9245 ;; now find out where the line starts and leave point there.
9246 (beg (progn (beginning-of-line) (point)))
9247 (article (gnus-summary-article-number))
9248 (score (or (cdr (assq (or article gnus-current-article)
9249 gnus-newsgroup-scored))
9250 gnus-summary-default-score 0))
9251 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
9252 (inhibit-read-only t))
9253 ;; Eval the cars of the lists until we find a match.
9254 (let ((default gnus-summary-default-score))
9256 (not (eval (caar list))))
9257 (setq list (cdr list))))
9258 (let ((face (cdar list)))
9259 (unless (eq face (get-text-property beg 'face))
9260 (gnus-put-text-property-excluding-characters-with-faces
9262 (setq face (if (boundp face) (symbol-value face) face)))
9263 (when gnus-summary-highlight-line-function
9264 (funcall gnus-summary-highlight-line-function article face))))
9267 (defun gnus-update-read-articles (group unread &optional compute)
9268 "Update the list of read articles in GROUP."
9269 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
9270 (entry (gnus-gethash group gnus-newsrc-hashtb))
9271 (info (nth 2 entry))
9273 (unread (sort (copy-sequence unread) '<))
9275 (if (or (not info) (not active))
9276 ;; There is no info on this group if it was, in fact,
9277 ;; killed. Gnus stores no information on killed groups, so
9278 ;; there's nothing to be done.
9279 ;; One could store the information somewhere temporarily,
9280 ;; perhaps... Hmmm...
9282 ;; Remove any negative articles numbers.
9283 (while (and unread (< (car unread) 0))
9284 (setq unread (cdr unread)))
9285 ;; Remove any expired article numbers
9286 (while (and unread (< (car unread) (car active)))
9287 (setq unread (cdr unread)))
9288 ;; Compute the ranges of read articles by looking at the list of
9291 (when (/= (car unread) prev)
9292 (push (if (= prev (1- (car unread))) prev
9293 (cons prev (1- (car unread))))
9295 (setq prev (1+ (car unread)))
9296 (setq unread (cdr unread)))
9297 (when (<= prev (cdr active))
9298 (push (cons prev (cdr active)) read))
9299 (setq read (if (> (length read) 1) (nreverse read) read))
9303 (set-buffer gnus-group-buffer)
9306 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
9307 (gnus-info-set-read ',info ',(gnus-info-read info))
9308 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
9309 (gnus-group-update-group ,group t))))
9310 ;; Propagate the read marks to the backend.
9311 (if (gnus-check-backend-function 'request-set-mark group)
9312 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
9313 (add (gnus-remove-from-range read (gnus-info-read info))))
9315 (unless (gnus-check-group group)
9316 (error "Can't open server for %s" group))
9317 (gnus-request-set-mark
9318 group (delq nil (list (if add (list add 'add '(read)))
9319 (if del (list del 'del '(read)))))))))
9320 ;; Enter this list into the group info.
9321 (gnus-info-set-read info read)
9322 ;; Set the number of unread articles in gnus-newsrc-hashtb.
9323 (gnus-get-unread-articles-in-group info (gnus-active group))
9326 (defun gnus-offer-save-summaries ()
9327 "Offer to save all active summary buffers."
9329 (let ((buflist (buffer-list))
9331 ;; Go through all buffers and find all summaries.
9333 (and (setq bufname (buffer-name (car buflist)))
9334 (string-match "Summary" bufname)
9336 (set-buffer bufname)
9337 ;; We check that this is, indeed, a summary buffer.
9338 (and (eq major-mode 'gnus-summary-mode)
9339 ;; Also make sure this isn't bogus.
9340 gnus-newsgroup-prepared
9341 ;; Also make sure that this isn't a dead summary buffer.
9342 (not gnus-dead-summary-mode)))
9343 (push bufname buffers))
9344 (setq buflist (cdr buflist)))
9345 ;; Go through all these summary buffers and offer to save them.
9348 "Update summary buffer %s? "
9350 (switch-to-buffer buf)
9351 (gnus-summary-exit))
9354 (defun gnus-summary-setup-default-charset ()
9355 "Setup newsgroup default charset."
9356 (if (equal gnus-newsgroup-name "nndraft:drafts")
9357 (setq gnus-newsgroup-charset nil)
9358 (let* ((name (and gnus-newsgroup-name
9359 (gnus-group-real-name gnus-newsgroup-name)))
9361 (or gnus-newsgroup-ephemeral-ignored-charsets
9363 (and gnus-newsgroup-name
9364 (or (gnus-group-find-parameter gnus-newsgroup-name
9365 'ignored-charsets t)
9366 (let ((alist gnus-group-ignored-charsets-alist)
9367 elem (charsets nil))
9368 (while (setq elem (pop alist))
9370 (string-match (car elem) name))
9372 charsets (cdr elem))))
9374 gnus-newsgroup-ignored-charsets)))
9375 (setq gnus-newsgroup-charset
9376 (or gnus-newsgroup-ephemeral-charset
9377 (and gnus-newsgroup-name
9378 (or (gnus-group-find-parameter gnus-newsgroup-name
9380 (let ((alist gnus-group-charset-alist)
9382 (while (setq elem (pop alist))
9384 (string-match (car elem) name))
9386 charset (cadr elem))))
9388 gnus-default-charset))
9389 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
9390 ignored-charsets))))
9396 (defun gnus-summary-display-buttonized (&optional show-all-parts)
9397 "Display the current article buffer fully MIME-buttonized.
9398 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
9399 treated as multipart/mixed."
9402 (let ((gnus-unbuttonized-mime-types nil)
9403 (gnus-mime-display-multipart-as-mixed show-all-parts))
9404 (gnus-summary-show-article)))
9406 (defun gnus-summary-repair-multipart (article)
9407 "Add a Content-Type header to a multipart article without one."
9408 (interactive (list (gnus-summary-article-number)))
9409 (gnus-with-article article
9410 (message-narrow-to-head)
9411 (goto-char (point-max))
9413 (when (search-forward "\n--" nil t)
9414 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
9415 (message-narrow-to-head)
9416 (message-remove-header "Mime-Version")
9417 (message-remove-header "Content-Type")
9418 (goto-char (point-max))
9419 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
9421 (insert "Mime-Version: 1.0\n")
9423 (let (gnus-mark-article-hook)
9424 (gnus-summary-select-article t t nil article)))
9426 (defun gnus-summary-toggle-display-buttonized ()
9427 "Toggle the buttonizing of the article buffer."
9430 (if (setq gnus-inhibit-mime-unbuttonizing
9431 (not gnus-inhibit-mime-unbuttonizing))
9432 (let ((gnus-unbuttonized-mime-types nil))
9433 (gnus-summary-show-article))
9434 (gnus-summary-show-article)))
9440 (defmacro gnus-with-article (article &rest forms)
9441 "Select ARTICLE and perform FORMS in the original article buffer.
9442 Then replace the article with the result."
9444 ;; We don't want the article to be marked as read.
9445 (let (gnus-mark-article-hook)
9446 (gnus-summary-select-article t t nil ,article))
9447 (set-buffer gnus-original-article-buffer)
9449 (if (not (gnus-check-backend-function
9450 'request-replace-article (car gnus-article-current)))
9451 (gnus-message 5 "Read-only group; not replacing")
9452 (unless (gnus-request-replace-article
9453 ,article (car gnus-article-current)
9455 (error "Couldn't replace article")))
9456 ;; The cache and backlog have to be flushed somewhat.
9457 (when gnus-keep-backlog
9458 (gnus-backlog-remove-article
9459 (car gnus-article-current) (cdr gnus-article-current)))
9460 (when gnus-use-cache
9461 (gnus-cache-update-article
9462 (car gnus-article-current) (cdr gnus-article-current)))))
9464 (put 'gnus-with-article 'lisp-indent-function 1)
9465 (put 'gnus-with-article 'edebug-form-spec '(form body))
9468 ;;; Generic summary marking commands
9471 (defvar gnus-summary-marking-alist
9472 '((read gnus-del-mark "d")
9473 (unread gnus-unread-mark "u")
9474 (ticked gnus-ticked-mark "!")
9475 (dormant gnus-dormant-mark "?")
9476 (expirable gnus-expirable-mark "e"))
9477 "An alist of names/marks/keystrokes.")
9479 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
9480 (defvar gnus-summary-mark-map)
9482 (defun gnus-summary-make-all-marking-commands ()
9483 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
9484 (dolist (elem gnus-summary-marking-alist)
9485 (apply 'gnus-summary-make-marking-command elem)))
9487 (defun gnus-summary-make-marking-command (name mark keystroke)
9488 (let ((map (make-sparse-keymap)))
9489 (define-key gnus-summary-generic-mark-map keystroke map)
9490 (dolist (lway `((next "next" next nil "n")
9491 (next-unread "next unread" next t "N")
9492 (prev "previous" prev nil "p")
9493 (prev-unread "previous unread" prev t "P")
9494 (nomove "" nil nil ,keystroke)))
9495 (let ((func (gnus-summary-make-marking-command-1
9496 mark (car lway) lway name)))
9497 (setq func (eval func))
9498 (define-key map (nth 4 lway) func)))))
9500 (defun gnus-summary-make-marking-command-1 (mark way lway name)
9502 (format "gnus-summary-put-mark-as-%s%s"
9503 name (if (eq way 'nomove)
9505 (concat "-" (symbol-name way)))))
9508 "Mark the current article as %s%s.
9509 If N, the prefix, then repeat N times.
9510 If N is negative, move in reverse order.
9511 The difference between N and the actual number of articles marked is
9515 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
9517 (defun gnus-summary-generic-mark (n mark move unread)
9518 "Mark N articles with MARK."
9519 (unless (eq major-mode 'gnus-summary-mode)
9520 (error "This command can only be used in the summary buffer"))
9521 (gnus-summary-show-thread)
9525 ((eq move 'prev) -1)
9531 nummove (* -1 nummove))))
9533 (gnus-summary-mark-article nil mark)
9534 (zerop (gnus-summary-next-subject nummove unread t)))
9537 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9538 (gnus-summary-recenter)
9539 (gnus-summary-position-point)
9540 (gnus-set-mode-line 'summary)
9543 (gnus-summary-make-all-marking-commands)
9549 (run-hooks 'gnus-sum-load-hook)
9551 ;;; gnus-sum.el ends here