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 (defcustom gnus-summary-show-article-charset-alist
854 "Alist of number and charset.
855 The article will be shown with the charset corresponding to the
857 For example: ((1 . cn-gb-2312) (2 . big5))."
858 :type '(repeat (cons (number :tag "Argument" 1)
859 (symbol :tag "Charset")))
860 :group 'gnus-charset)
863 ;;; Internal variables
865 (defvar gnus-article-mime-handles nil)
866 (defvar gnus-article-decoded-p nil)
867 (defvar gnus-scores-exclude-files nil)
868 (defvar gnus-page-broken nil)
869 (defvar gnus-inhibit-mime-unbuttonizing nil)
871 (defvar gnus-original-article nil)
872 (defvar gnus-article-internal-prepare-hook nil)
873 (defvar gnus-newsgroup-process-stack nil)
875 (defvar gnus-thread-indent-array nil)
876 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
877 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
878 "Function called to sort the articles within a thread after it has
879 been gathered together.")
881 ;; Avoid highlighting in kill files.
882 (defvar gnus-summary-inhibit-highlight nil)
883 (defvar gnus-newsgroup-selected-overlay nil)
884 (defvar gnus-inhibit-limiting nil)
885 (defvar gnus-newsgroup-adaptive-score-file nil)
886 (defvar gnus-current-score-file nil)
887 (defvar gnus-current-move-group nil)
888 (defvar gnus-current-copy-group nil)
889 (defvar gnus-current-crosspost-group nil)
891 (defvar gnus-newsgroup-dependencies nil)
892 (defvar gnus-newsgroup-adaptive nil)
893 (defvar gnus-summary-display-article-function nil)
894 (defvar gnus-summary-highlight-line-function nil
895 "Function called after highlighting a summary line.")
897 (defvar gnus-summary-line-format-alist
898 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
899 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
900 (?s gnus-tmp-subject-or-nil ?s)
901 (?n gnus-tmp-name ?s)
902 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
904 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
906 (?F gnus-tmp-from ?s)
907 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
908 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
909 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
910 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
911 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
912 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
913 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
914 (?L gnus-tmp-lines ?d)
915 (?I gnus-tmp-indentation ?s)
916 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
917 (?R gnus-tmp-replied ?c)
918 (?\[ gnus-tmp-opening-bracket ?c)
919 (?\] gnus-tmp-closing-bracket ?c)
920 (?\> (make-string gnus-tmp-level ? ) ?s)
921 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
922 (?i gnus-tmp-score ?d)
923 (?z gnus-tmp-score-char ?c)
924 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
925 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
926 (?U gnus-tmp-unread ?c)
927 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header) ?s)
928 (?t (gnus-summary-number-of-articles-in-thread
929 (and (boundp 'thread) (car thread)) gnus-tmp-level)
931 (?e (gnus-summary-number-of-articles-in-thread
932 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
934 (?u gnus-tmp-user-defined ?s)
935 (?P (gnus-pick-line-number) ?d))
936 "An alist of format specifications that can appear in summary lines,
937 and what variables they correspond with, along with the type of the
938 variable (string, integer, character, etc).")
940 (defvar gnus-summary-dummy-line-format-alist
941 `((?S gnus-tmp-subject ?s)
942 (?N gnus-tmp-number ?d)
943 (?u gnus-tmp-user-defined ?s)))
945 (defvar gnus-summary-mode-line-format-alist
946 `((?G gnus-tmp-group-name ?s)
947 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
948 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
949 (?A gnus-tmp-article-number ?d)
950 (?Z gnus-tmp-unread-and-unselected ?s)
952 (?U gnus-tmp-unread-and-unticked ?d)
953 (?S gnus-tmp-subject ?s)
954 (?e gnus-tmp-unselected ?d)
955 (?u gnus-tmp-user-defined ?s)
956 (?d (length gnus-newsgroup-dormant) ?d)
957 (?t (length gnus-newsgroup-marked) ?d)
958 (?r (length gnus-newsgroup-reads) ?d)
959 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
960 (?E gnus-newsgroup-expunged-tally ?d)
961 (?s (gnus-current-score-file-nondirectory) ?s)))
963 (defvar gnus-last-search-regexp nil
964 "Default regexp for article search command.")
966 (defvar gnus-last-shell-command nil
967 "Default shell command on article.")
969 (defvar gnus-newsgroup-begin nil)
970 (defvar gnus-newsgroup-end nil)
971 (defvar gnus-newsgroup-last-rmail nil)
972 (defvar gnus-newsgroup-last-mail nil)
973 (defvar gnus-newsgroup-last-folder nil)
974 (defvar gnus-newsgroup-last-file nil)
975 (defvar gnus-newsgroup-auto-expire nil)
976 (defvar gnus-newsgroup-active nil)
978 (defvar gnus-newsgroup-data nil)
979 (defvar gnus-newsgroup-data-reverse nil)
980 (defvar gnus-newsgroup-limit nil)
981 (defvar gnus-newsgroup-limits nil)
983 (defvar gnus-newsgroup-unreads nil
984 "List of unread articles in the current newsgroup.")
986 (defvar gnus-newsgroup-unselected nil
987 "List of unselected unread articles in the current newsgroup.")
989 (defvar gnus-newsgroup-reads nil
990 "Alist of read articles and article marks in the current newsgroup.")
992 (defvar gnus-newsgroup-expunged-tally nil)
994 (defvar gnus-newsgroup-marked nil
995 "List of ticked articles in the current newsgroup (a subset of unread art).")
997 (defvar gnus-newsgroup-killed nil
998 "List of ranges of articles that have been through the scoring process.")
1000 (defvar gnus-newsgroup-cached nil
1001 "List of articles that come from the article cache.")
1003 (defvar gnus-newsgroup-saved nil
1004 "List of articles that have been saved.")
1006 (defvar gnus-newsgroup-kill-headers nil)
1008 (defvar gnus-newsgroup-replied nil
1009 "List of articles that have been replied to in the current newsgroup.")
1011 (defvar gnus-newsgroup-expirable nil
1012 "List of articles in the current newsgroup that can be expired.")
1014 (defvar gnus-newsgroup-processable nil
1015 "List of articles in the current newsgroup that can be processed.")
1017 (defvar gnus-newsgroup-downloadable nil
1018 "List of articles in the current newsgroup that can be processed.")
1020 (defvar gnus-newsgroup-undownloaded nil
1021 "List of articles in the current newsgroup that haven't been downloaded..")
1023 (defvar gnus-newsgroup-unsendable nil
1024 "List of articles in the current newsgroup that won't be sent.")
1026 (defvar gnus-newsgroup-bookmarks nil
1027 "List of articles in the current newsgroup that have bookmarks.")
1029 (defvar gnus-newsgroup-dormant nil
1030 "List of dormant articles in the current newsgroup.")
1032 (defvar gnus-newsgroup-scored nil
1033 "List of scored articles in the current newsgroup.")
1035 (defvar gnus-newsgroup-headers nil
1036 "List of article headers in the current newsgroup.")
1038 (defvar gnus-newsgroup-threads nil)
1040 (defvar gnus-newsgroup-prepared nil
1041 "Whether the current group has been prepared properly.")
1043 (defvar gnus-newsgroup-ancient nil
1044 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1046 (defvar gnus-newsgroup-sparse nil)
1048 (defvar gnus-current-article nil)
1049 (defvar gnus-article-current nil)
1050 (defvar gnus-current-headers nil)
1051 (defvar gnus-have-all-headers nil)
1052 (defvar gnus-last-article nil)
1053 (defvar gnus-newsgroup-history nil)
1054 (defvar gnus-newsgroup-charset nil)
1055 (defvar gnus-newsgroup-ephemeral-charset nil)
1056 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1058 (defconst gnus-summary-local-variables
1059 '(gnus-newsgroup-name
1060 gnus-newsgroup-begin gnus-newsgroup-end
1061 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1062 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1063 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1064 gnus-newsgroup-unselected gnus-newsgroup-marked
1065 gnus-newsgroup-reads gnus-newsgroup-saved
1066 gnus-newsgroup-replied gnus-newsgroup-expirable
1067 gnus-newsgroup-processable gnus-newsgroup-killed
1068 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1069 gnus-newsgroup-unsendable
1070 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1071 gnus-newsgroup-headers gnus-newsgroup-threads
1072 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1073 gnus-current-article gnus-current-headers gnus-have-all-headers
1074 gnus-last-article gnus-article-internal-prepare-hook
1075 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1076 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1077 gnus-thread-expunge-below
1078 gnus-score-alist gnus-current-score-file
1079 (gnus-summary-expunge-below . global)
1080 (gnus-summary-mark-below . global)
1081 gnus-newsgroup-active gnus-scores-exclude-files
1082 gnus-newsgroup-history gnus-newsgroup-ancient
1083 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1084 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1085 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1086 (gnus-newsgroup-expunged-tally . 0)
1087 gnus-cache-removable-articles gnus-newsgroup-cached
1088 gnus-newsgroup-data gnus-newsgroup-data-reverse
1089 gnus-newsgroup-limit gnus-newsgroup-limits
1090 gnus-newsgroup-charset)
1091 "Variables that are buffer-local to the summary buffers.")
1093 ;; Byte-compiler warning.
1094 (defvar gnus-article-mode-map)
1098 (defvar gnus-decode-encoded-word-methods
1099 '(mail-decode-encoded-word-string)
1100 "List of methods used to decode encoded words.
1102 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item is
1103 FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1104 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1105 whose names match REGEXP.
1108 ((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1109 mail-decode-encoded-word-string
1110 (\"chinese\" . rfc1843-decode-string))
1113 (defvar gnus-decode-encoded-word-methods-cache nil)
1115 (defun gnus-multi-decode-encoded-word-string (string)
1116 "Apply the functions from `gnus-encoded-word-methods' that match."
1117 (unless (and gnus-decode-encoded-word-methods-cache
1118 (eq gnus-newsgroup-name
1119 (car gnus-decode-encoded-word-methods-cache)))
1120 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1123 (nconc gnus-decode-encoded-word-methods-cache (list x))
1124 (if (and gnus-newsgroup-name
1125 (string-match (car x) gnus-newsgroup-name))
1126 (nconc gnus-decode-encoded-word-methods-cache
1128 gnus-decode-encoded-word-methods))
1129 (let ((xlist gnus-decode-encoded-word-methods-cache))
1132 (setq string (funcall (pop xlist) string))))
1135 ;; Subject simplification.
1137 (defun gnus-simplify-whitespace (str)
1138 "Remove excessive whitespace."
1141 (while (string-match "[ \t][ \t]+" mystr)
1142 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1144 (substring mystr (match-end 0)))))
1146 (when (string-match "^[ \t]+" mystr)
1147 (setq mystr (substring mystr (match-end 0))))
1149 (when (string-match "[ \t]+$" mystr)
1150 (setq mystr (substring mystr 0 (match-beginning 0))))
1153 (defsubst gnus-simplify-subject-re (subject)
1154 "Remove \"Re:\" from subject lines."
1155 (if (string-match "^[Rr][Ee]: *" subject)
1156 (substring subject (match-end 0))
1159 (defun gnus-simplify-subject (subject &optional re-only)
1160 "Remove `Re:' and words in parentheses.
1161 If RE-ONLY is non-nil, strip leading `Re:'s only."
1162 (let ((case-fold-search t)) ;Ignore case.
1163 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1164 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1165 (setq subject (substring subject (match-end 0))))
1166 ;; Remove uninteresting prefixes.
1167 (when (and (not re-only)
1168 gnus-simplify-ignored-prefixes
1169 (string-match gnus-simplify-ignored-prefixes subject))
1170 (setq subject (substring subject (match-end 0))))
1171 ;; Remove words in parentheses from end.
1173 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1174 (setq subject (substring subject 0 (match-beginning 0)))))
1175 ;; Return subject string.
1178 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1180 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1181 (goto-char (point-min))
1182 (while (re-search-forward regexp nil t)
1183 (replace-match (or newtext ""))))
1185 (defun gnus-simplify-buffer-fuzzy ()
1186 "Simplify string in the buffer fuzzily.
1187 The string in the accessible portion of the current buffer is simplified.
1188 It is assumed to be a single-line subject.
1189 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1190 matter is removed. Additional things can be deleted by setting
1191 gnus-simplify-subject-fuzzy-regexp."
1192 (let ((case-fold-search t)
1194 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1196 (while (not (eq modified-tick (buffer-modified-tick)))
1197 (setq modified-tick (buffer-modified-tick))
1199 ((listp gnus-simplify-subject-fuzzy-regexp)
1200 (mapcar 'gnus-simplify-buffer-fuzzy-step
1201 gnus-simplify-subject-fuzzy-regexp))
1202 (gnus-simplify-subject-fuzzy-regexp
1203 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1204 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1205 (gnus-simplify-buffer-fuzzy-step
1206 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1207 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1209 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1210 (gnus-simplify-buffer-fuzzy-step " +" " ")
1211 (gnus-simplify-buffer-fuzzy-step " $")
1212 (gnus-simplify-buffer-fuzzy-step "^ +")))
1214 (defun gnus-simplify-subject-fuzzy (subject)
1215 "Simplify a subject string fuzzily.
1216 See `gnus-simplify-buffer-fuzzy' for details."
1218 (gnus-set-work-buffer)
1219 (let ((case-fold-search t))
1220 ;; Remove uninteresting prefixes.
1221 (when (and gnus-simplify-ignored-prefixes
1222 (string-match gnus-simplify-ignored-prefixes subject))
1223 (setq subject (substring subject (match-end 0))))
1225 (inline (gnus-simplify-buffer-fuzzy))
1228 (defsubst gnus-simplify-subject-fully (subject)
1229 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1231 (gnus-simplify-subject-functions
1232 (gnus-map-function gnus-simplify-subject-functions subject))
1233 ((null gnus-summary-gather-subject-limit)
1234 (gnus-simplify-subject-re subject))
1235 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1236 (gnus-simplify-subject-fuzzy subject))
1237 ((numberp gnus-summary-gather-subject-limit)
1238 (gnus-limit-string (gnus-simplify-subject-re subject)
1239 gnus-summary-gather-subject-limit))
1243 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1244 "Check whether two subjects are equal.
1245 If optional argument simple-first is t, first argument is already
1248 ((null simple-first)
1249 (equal (gnus-simplify-subject-fully s1)
1250 (gnus-simplify-subject-fully s2)))
1253 (gnus-simplify-subject-fully s2)))))
1255 (defun gnus-summary-bubble-group ()
1256 "Increase the score of the current group.
1257 This is a handy function to add to `gnus-summary-exit-hook' to
1258 increase the score of each group you read."
1259 (gnus-group-add-score gnus-newsgroup-name))
1263 ;;; Gnus summary mode
1266 (put 'gnus-summary-mode 'mode-class 'special)
1269 ;; Non-orthogonal keys
1271 (gnus-define-keys gnus-summary-mode-map
1272 " " gnus-summary-next-page
1273 "\177" gnus-summary-prev-page
1274 [delete] gnus-summary-prev-page
1275 [backspace] gnus-summary-prev-page
1276 "\r" gnus-summary-scroll-up
1277 "\M-\r" gnus-summary-scroll-down
1278 "n" gnus-summary-next-unread-article
1279 "p" gnus-summary-prev-unread-article
1280 "N" gnus-summary-next-article
1281 "P" gnus-summary-prev-article
1282 "\M-\C-n" gnus-summary-next-same-subject
1283 "\M-\C-p" gnus-summary-prev-same-subject
1284 "\M-n" gnus-summary-next-unread-subject
1285 "\M-p" gnus-summary-prev-unread-subject
1286 "." gnus-summary-first-unread-article
1287 "," gnus-summary-best-unread-article
1288 "\M-s" gnus-summary-search-article-forward
1289 "\M-r" gnus-summary-search-article-backward
1290 "<" gnus-summary-beginning-of-article
1291 ">" gnus-summary-end-of-article
1292 "j" gnus-summary-goto-article
1293 "^" gnus-summary-refer-parent-article
1294 "\M-^" gnus-summary-refer-article
1295 "u" gnus-summary-tick-article-forward
1296 "!" gnus-summary-tick-article-forward
1297 "U" gnus-summary-tick-article-backward
1298 "d" gnus-summary-mark-as-read-forward
1299 "D" gnus-summary-mark-as-read-backward
1300 "E" gnus-summary-mark-as-expirable
1301 "\M-u" gnus-summary-clear-mark-forward
1302 "\M-U" gnus-summary-clear-mark-backward
1303 "k" gnus-summary-kill-same-subject-and-select
1304 "\C-k" gnus-summary-kill-same-subject
1305 "\M-\C-k" gnus-summary-kill-thread
1306 "\M-\C-l" gnus-summary-lower-thread
1307 "e" gnus-summary-edit-article
1308 "#" gnus-summary-mark-as-processable
1309 "\M-#" gnus-summary-unmark-as-processable
1310 "\M-\C-t" gnus-summary-toggle-threads
1311 "\M-\C-s" gnus-summary-show-thread
1312 "\M-\C-h" gnus-summary-hide-thread
1313 "\M-\C-f" gnus-summary-next-thread
1314 "\M-\C-b" gnus-summary-prev-thread
1315 "\M-\C-u" gnus-summary-up-thread
1316 "\M-\C-d" gnus-summary-down-thread
1317 "&" gnus-summary-execute-command
1318 "c" gnus-summary-catchup-and-exit
1319 "\C-w" gnus-summary-mark-region-as-read
1320 "\C-t" gnus-summary-toggle-truncation
1321 "?" gnus-summary-mark-as-dormant
1322 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1323 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1324 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1325 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1326 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1327 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1328 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1329 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1330 "=" gnus-summary-expand-window
1331 "\C-x\C-s" gnus-summary-reselect-current-group
1332 "\M-g" gnus-summary-rescan-group
1333 "w" gnus-summary-stop-page-breaking
1334 "\C-c\C-r" gnus-summary-caesar-message
1335 "f" gnus-summary-followup
1336 "F" gnus-summary-followup-with-original
1337 "C" gnus-summary-cancel-article
1338 "r" gnus-summary-reply
1339 "R" gnus-summary-reply-with-original
1340 "\C-c\C-f" gnus-summary-mail-forward
1341 "o" gnus-summary-save-article
1342 "\C-o" gnus-summary-save-article-mail
1343 "|" gnus-summary-pipe-output
1344 "\M-k" gnus-summary-edit-local-kill
1345 "\M-K" gnus-summary-edit-global-kill
1347 "\C-c\C-d" gnus-summary-describe-group
1348 "q" gnus-summary-exit
1349 "Q" gnus-summary-exit-no-update
1350 "\C-c\C-i" gnus-info-find-node
1351 gnus-mouse-2 gnus-mouse-pick-article
1352 "m" gnus-summary-mail-other-window
1353 "a" gnus-summary-post-news
1354 "x" gnus-summary-limit-to-unread
1355 "s" gnus-summary-isearch-article
1356 "t" gnus-summary-toggle-header
1357 "g" gnus-summary-show-article
1358 "l" gnus-summary-goto-last-article
1359 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1360 "\C-d" gnus-summary-enter-digest-group
1361 "\M-\C-d" gnus-summary-read-document
1362 "\M-\C-e" gnus-summary-edit-parameters
1363 "\M-\C-g" gnus-summary-customize-parameters
1365 "*" gnus-cache-enter-article
1366 "\M-*" gnus-cache-remove-article
1367 "\M-&" gnus-summary-universal-argument
1368 "\C-l" gnus-recenter
1369 "I" gnus-summary-increase-score
1370 "L" gnus-summary-lower-score
1371 "\M-i" gnus-symbolic-argument
1372 "h" gnus-summary-select-article-buffer
1374 "b" gnus-article-view-part
1375 "\M-t" gnus-summary-toggle-display-buttonized
1377 "V" gnus-summary-score-map
1378 "X" gnus-uu-extract-map
1379 "S" gnus-summary-send-map)
1381 ;; Sort of orthogonal keymap
1382 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1383 "t" gnus-summary-tick-article-forward
1384 "!" gnus-summary-tick-article-forward
1385 "d" gnus-summary-mark-as-read-forward
1386 "r" gnus-summary-mark-as-read-forward
1387 "c" gnus-summary-clear-mark-forward
1388 " " gnus-summary-clear-mark-forward
1389 "e" gnus-summary-mark-as-expirable
1390 "x" gnus-summary-mark-as-expirable
1391 "?" gnus-summary-mark-as-dormant
1392 "b" gnus-summary-set-bookmark
1393 "B" gnus-summary-remove-bookmark
1394 "#" gnus-summary-mark-as-processable
1395 "\M-#" gnus-summary-unmark-as-processable
1396 "S" gnus-summary-limit-include-expunged
1397 "C" gnus-summary-catchup
1398 "H" gnus-summary-catchup-to-here
1399 "\C-c" gnus-summary-catchup-all
1400 "k" gnus-summary-kill-same-subject-and-select
1401 "K" gnus-summary-kill-same-subject
1402 "P" gnus-uu-mark-map)
1404 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1405 "c" gnus-summary-clear-above
1406 "u" gnus-summary-tick-above
1407 "m" gnus-summary-mark-above
1408 "k" gnus-summary-kill-below)
1410 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1411 "/" gnus-summary-limit-to-subject
1412 "n" gnus-summary-limit-to-articles
1413 "w" gnus-summary-pop-limit
1414 "s" gnus-summary-limit-to-subject
1415 "a" gnus-summary-limit-to-author
1416 "u" gnus-summary-limit-to-unread
1417 "m" gnus-summary-limit-to-marks
1418 "M" gnus-summary-limit-exclude-marks
1419 "v" gnus-summary-limit-to-score
1420 "*" gnus-summary-limit-include-cached
1421 "D" gnus-summary-limit-include-dormant
1422 "T" gnus-summary-limit-include-thread
1423 "d" gnus-summary-limit-exclude-dormant
1424 "t" gnus-summary-limit-to-age
1425 "x" gnus-summary-limit-to-extra
1426 "E" gnus-summary-limit-include-expunged
1427 "c" gnus-summary-limit-exclude-childless-dormant
1428 "C" gnus-summary-limit-mark-excluded-as-read)
1430 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1431 "n" gnus-summary-next-unread-article
1432 "p" gnus-summary-prev-unread-article
1433 "N" gnus-summary-next-article
1434 "P" gnus-summary-prev-article
1435 "\C-n" gnus-summary-next-same-subject
1436 "\C-p" gnus-summary-prev-same-subject
1437 "\M-n" gnus-summary-next-unread-subject
1438 "\M-p" gnus-summary-prev-unread-subject
1439 "f" gnus-summary-first-unread-article
1440 "b" gnus-summary-best-unread-article
1441 "j" gnus-summary-goto-article
1442 "g" gnus-summary-goto-subject
1443 "l" gnus-summary-goto-last-article
1444 "o" gnus-summary-pop-article)
1446 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1447 "k" gnus-summary-kill-thread
1448 "l" gnus-summary-lower-thread
1449 "i" gnus-summary-raise-thread
1450 "T" gnus-summary-toggle-threads
1451 "t" gnus-summary-rethread-current
1452 "^" gnus-summary-reparent-thread
1453 "s" gnus-summary-show-thread
1454 "S" gnus-summary-show-all-threads
1455 "h" gnus-summary-hide-thread
1456 "H" gnus-summary-hide-all-threads
1457 "n" gnus-summary-next-thread
1458 "p" gnus-summary-prev-thread
1459 "u" gnus-summary-up-thread
1460 "o" gnus-summary-top-thread
1461 "d" gnus-summary-down-thread
1462 "#" gnus-uu-mark-thread
1463 "\M-#" gnus-uu-unmark-thread)
1465 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1466 "g" gnus-summary-prepare
1467 "c" gnus-summary-insert-cached-articles)
1469 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1470 "c" gnus-summary-catchup-and-exit
1471 "C" gnus-summary-catchup-all-and-exit
1472 "E" gnus-summary-exit-no-update
1473 "Q" gnus-summary-exit
1474 "Z" gnus-summary-exit
1475 "n" gnus-summary-catchup-and-goto-next-group
1476 "R" gnus-summary-reselect-current-group
1477 "G" gnus-summary-rescan-group
1478 "N" gnus-summary-next-group
1479 "s" gnus-summary-save-newsrc
1480 "P" gnus-summary-prev-group)
1482 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1483 " " gnus-summary-next-page
1484 "n" gnus-summary-next-page
1485 "\177" gnus-summary-prev-page
1486 [delete] gnus-summary-prev-page
1487 "p" gnus-summary-prev-page
1488 "\r" gnus-summary-scroll-up
1489 "\M-\r" gnus-summary-scroll-down
1490 "<" gnus-summary-beginning-of-article
1491 ">" gnus-summary-end-of-article
1492 "b" gnus-summary-beginning-of-article
1493 "e" gnus-summary-end-of-article
1494 "^" gnus-summary-refer-parent-article
1495 "r" gnus-summary-refer-parent-article
1496 "D" gnus-summary-enter-digest-group
1497 "R" gnus-summary-refer-references
1498 "T" gnus-summary-refer-thread
1499 "g" gnus-summary-show-article
1500 "s" gnus-summary-isearch-article
1501 "P" gnus-summary-print-article
1502 "t" gnus-article-babel)
1504 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1505 "b" gnus-article-add-buttons
1506 "B" gnus-article-add-buttons-to-head
1507 "o" gnus-article-treat-overstrike
1508 "e" gnus-article-emphasize
1509 "w" gnus-article-fill-cited-article
1510 "Q" gnus-article-fill-long-lines
1511 "C" gnus-article-capitalize-sentences
1512 "c" gnus-article-remove-cr
1513 "q" gnus-article-de-quoted-unreadable
1514 "f" gnus-article-display-x-face
1515 "l" gnus-summary-stop-page-breaking
1516 "r" gnus-summary-caesar-message
1517 "t" gnus-article-hide-headers
1518 "v" gnus-summary-verbose-headers
1519 "H" gnus-article-strip-headers-in-body
1520 "d" gnus-article-treat-dumbquotes)
1522 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1523 "a" gnus-article-hide
1524 "h" gnus-article-hide-headers
1525 "b" gnus-article-hide-boring-headers
1526 "s" gnus-article-hide-signature
1527 "c" gnus-article-hide-citation
1528 "C" gnus-article-hide-citation-in-followups
1529 "l" gnus-article-hide-list-identifiers
1530 "p" gnus-article-hide-pgp
1531 "B" gnus-article-strip-banner
1532 "P" gnus-article-hide-pem
1533 "\C-c" gnus-article-hide-citation-maybe)
1535 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1536 "a" gnus-article-highlight
1537 "h" gnus-article-highlight-headers
1538 "c" gnus-article-highlight-citation
1539 "s" gnus-article-highlight-signature)
1541 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1542 "w" gnus-article-decode-mime-words
1543 "c" gnus-article-decode-charset
1544 "v" gnus-mime-view-all-parts
1545 "b" gnus-article-view-part)
1547 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1548 "z" gnus-article-date-ut
1549 "u" gnus-article-date-ut
1550 "l" gnus-article-date-local
1551 "e" gnus-article-date-lapsed
1552 "o" gnus-article-date-original
1553 "i" gnus-article-date-iso8601
1554 "s" gnus-article-date-user)
1556 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1557 "t" gnus-article-remove-trailing-blank-lines
1558 "l" gnus-article-strip-leading-blank-lines
1559 "m" gnus-article-strip-multiple-blank-lines
1560 "a" gnus-article-strip-blank-lines
1561 "A" gnus-article-strip-all-blank-lines
1562 "s" gnus-article-strip-leading-space
1563 "e" gnus-article-strip-trailing-space)
1565 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1567 "f" gnus-summary-fetch-faq
1568 "d" gnus-summary-describe-group
1569 "h" gnus-summary-describe-briefly
1570 "i" gnus-info-find-node)
1572 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1573 "e" gnus-summary-expire-articles
1574 "\M-\C-e" gnus-summary-expire-articles-now
1575 "\177" gnus-summary-delete-article
1576 [delete] gnus-summary-delete-article
1577 [backspace] gnus-summary-delete-article
1578 "m" gnus-summary-move-article
1579 "r" gnus-summary-respool-article
1580 "w" gnus-summary-edit-article
1581 "c" gnus-summary-copy-article
1582 "B" gnus-summary-crosspost-article
1583 "q" gnus-summary-respool-query
1584 "t" gnus-summary-respool-trace
1585 "i" gnus-summary-import-article
1586 "p" gnus-summary-article-posted-p)
1588 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1589 "o" gnus-summary-save-article
1590 "m" gnus-summary-save-article-mail
1591 "F" gnus-summary-write-article-file
1592 "r" gnus-summary-save-article-rmail
1593 "f" gnus-summary-save-article-file
1594 "b" gnus-summary-save-article-body-file
1595 "h" gnus-summary-save-article-folder
1596 "v" gnus-summary-save-article-vm
1597 "p" gnus-summary-pipe-output
1598 "s" gnus-soup-add-article)
1600 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1601 "b" gnus-summary-display-buttonized
1602 "m" gnus-summary-repair-multipart
1603 "v" gnus-article-view-part
1604 "o" gnus-article-save-part
1605 "c" gnus-article-copy-part
1606 "e" gnus-article-externalize-part
1607 "i" gnus-article-inline-part
1608 "|" gnus-article-pipe-part)
1611 (defun gnus-summary-make-menu-bar ()
1612 (gnus-turn-off-edit-menu 'summary)
1614 (unless (boundp 'gnus-summary-misc-menu)
1617 gnus-summary-kill-menu gnus-summary-mode-map ""
1622 ["Enter score..." gnus-summary-score-entry t]
1623 ["Customize" gnus-score-customize t])
1624 (gnus-make-score-map 'increase)
1625 (gnus-make-score-map 'lower)
1627 ["Kill below" gnus-summary-kill-below t]
1628 ["Mark above" gnus-summary-mark-above t]
1629 ["Tick above" gnus-summary-tick-above t]
1630 ["Clear above" gnus-summary-clear-above t])
1631 ["Current score" gnus-summary-current-score t]
1632 ["Set score" gnus-summary-set-score t]
1633 ["Switch current score file..." gnus-score-change-score-file t]
1634 ["Set mark below..." gnus-score-set-mark-below t]
1635 ["Set expunge below..." gnus-score-set-expunge-below t]
1636 ["Edit current score file" gnus-score-edit-current-scores t]
1637 ["Edit score file" gnus-score-edit-file t]
1638 ["Trace score" gnus-score-find-trace t]
1639 ["Find words" gnus-score-find-favourite-words t]
1640 ["Rescore buffer" gnus-summary-rescore t]
1641 ["Increase score..." gnus-summary-increase-score t]
1642 ["Lower score..." gnus-summary-lower-score t]))))
1644 ;; Define both the Article menu in the summary buffer and the equivalent
1645 ;; Commands menu in the article buffer here for consistency.
1648 ["All" gnus-article-hide t]
1649 ["Headers" gnus-article-hide-headers t]
1650 ["Signature" gnus-article-hide-signature t]
1651 ["Citation" gnus-article-hide-citation t]
1652 ["List identifiers" gnus-article-hide-list-identifiers t]
1653 ["PGP" gnus-article-hide-pgp t]
1654 ["Banner" gnus-article-strip-banner t]
1655 ["Boring headers" gnus-article-hide-boring-headers t])
1657 ["All" gnus-article-highlight t]
1658 ["Headers" gnus-article-highlight-headers t]
1659 ["Signature" gnus-article-highlight-signature t]
1660 ["Citation" gnus-article-highlight-citation t])
1662 ["Words" gnus-article-decode-mime-words t]
1663 ["Charset" gnus-article-decode-charset t]
1664 ["QP" gnus-article-de-quoted-unreadable t]
1665 ["View all" gnus-mime-view-all-parts t])
1667 ["Local" gnus-article-date-local t]
1668 ["ISO8601" gnus-article-date-iso8601 t]
1669 ["UT" gnus-article-date-ut t]
1670 ["Original" gnus-article-date-original t]
1671 ["Lapsed" gnus-article-date-lapsed t]
1672 ["User-defined" gnus-article-date-user t])
1675 ["Leading" gnus-article-strip-leading-blank-lines t]
1676 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1677 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1678 ["All of the above" gnus-article-strip-blank-lines t]
1679 ["All" gnus-article-strip-all-blank-lines t]
1680 ["Leading space" gnus-article-strip-leading-space t]
1681 ["Trailing space" gnus-article-strip-trailing-space t])
1682 ["Overstrike" gnus-article-treat-overstrike t]
1683 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1684 ["Emphasis" gnus-article-emphasize t]
1685 ["Word wrap" gnus-article-fill-cited-article t]
1686 ["Fill long lines" gnus-article-fill-long-lines t]
1687 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1688 ["CR" gnus-article-remove-cr t]
1689 ["Show X-Face" gnus-article-display-x-face t]
1690 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1691 ["Rot 13" gnus-summary-caesar-message t]
1692 ["Unix pipe" gnus-summary-pipe-message t]
1693 ["Add buttons" gnus-article-add-buttons t]
1694 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1695 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1696 ["Verbose header" gnus-summary-verbose-headers t]
1697 ["Toggle header" gnus-summary-toggle-header t])
1699 ["Save in default format" gnus-summary-save-article t]
1700 ["Save in file" gnus-summary-save-article-file t]
1701 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1702 ["Save in MH folder" gnus-summary-save-article-folder t]
1703 ["Save in VM folder" gnus-summary-save-article-vm t]
1704 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1705 ["Save body in file" gnus-summary-save-article-body-file t]
1706 ["Pipe through a filter" gnus-summary-pipe-output t]
1707 ["Add to SOUP packet" gnus-soup-add-article t]
1708 ["Print" gnus-summary-print-article t])
1710 ["Respool article..." gnus-summary-respool-article t]
1711 ["Move article..." gnus-summary-move-article
1712 (gnus-check-backend-function
1713 'request-move-article gnus-newsgroup-name)]
1714 ["Copy article..." gnus-summary-copy-article t]
1715 ["Crosspost article..." gnus-summary-crosspost-article
1716 (gnus-check-backend-function
1717 'request-replace-article gnus-newsgroup-name)]
1718 ["Import file..." gnus-summary-import-article t]
1719 ["Check if posted" gnus-summary-article-posted-p t]
1720 ["Edit article" gnus-summary-edit-article
1721 (not (gnus-group-read-only-p))]
1722 ["Delete article" gnus-summary-delete-article
1723 (gnus-check-backend-function
1724 'request-expire-articles gnus-newsgroup-name)]
1725 ["Query respool" gnus-summary-respool-query t]
1726 ["Trace respool" gnus-summary-respool-trace t]
1727 ["Delete expirable articles" gnus-summary-expire-articles-now
1728 (gnus-check-backend-function
1729 'request-expire-articles gnus-newsgroup-name)])
1731 ["Uudecode" gnus-uu-decode-uu t]
1732 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1733 ["Unshar" gnus-uu-decode-unshar t]
1734 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1735 ["Save" gnus-uu-decode-save t]
1736 ["Binhex" gnus-uu-decode-binhex t]
1737 ["Postscript" gnus-uu-decode-postscript t])
1739 ["Enter article" gnus-cache-enter-article t]
1740 ["Remove article" gnus-cache-remove-article t])
1741 ["Translate" gnus-article-babel t]
1742 ["Select article buffer" gnus-summary-select-article-buffer t]
1743 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1744 ["Isearch article..." gnus-summary-isearch-article t]
1745 ["Beginning of the article" gnus-summary-beginning-of-article t]
1746 ["End of the article" gnus-summary-end-of-article t]
1747 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1748 ["Fetch referenced articles" gnus-summary-refer-references t]
1749 ["Fetch current thread" gnus-summary-refer-thread t]
1750 ["Fetch article with id..." gnus-summary-refer-article t]
1751 ["Redisplay" gnus-summary-show-article t])))
1753 gnus-summary-article-menu gnus-summary-mode-map ""
1754 (cons "Article" innards))
1757 gnus-article-commands-menu gnus-article-mode-map ""
1758 (cons "Commands" innards)))
1761 gnus-summary-thread-menu gnus-summary-mode-map ""
1763 ["Toggle threading" gnus-summary-toggle-threads t]
1764 ["Hide threads" gnus-summary-hide-all-threads t]
1765 ["Show threads" gnus-summary-show-all-threads t]
1766 ["Hide thread" gnus-summary-hide-thread t]
1767 ["Show thread" gnus-summary-show-thread t]
1768 ["Go to next thread" gnus-summary-next-thread t]
1769 ["Go to previous thread" gnus-summary-prev-thread t]
1770 ["Go down thread" gnus-summary-down-thread t]
1771 ["Go up thread" gnus-summary-up-thread t]
1772 ["Top of thread" gnus-summary-top-thread t]
1773 ["Mark thread as read" gnus-summary-kill-thread t]
1774 ["Lower thread score" gnus-summary-lower-thread t]
1775 ["Raise thread score" gnus-summary-raise-thread t]
1776 ["Rethread current" gnus-summary-rethread-current t]
1780 gnus-summary-post-menu gnus-summary-mode-map ""
1782 ["Post an article" gnus-summary-post-news t]
1783 ["Followup" gnus-summary-followup t]
1784 ["Followup and yank" gnus-summary-followup-with-original t]
1785 ["Supersede article" gnus-summary-supersede-article t]
1786 ["Cancel article" gnus-summary-cancel-article t]
1787 ["Reply" gnus-summary-reply t]
1788 ["Reply and yank" gnus-summary-reply-with-original t]
1789 ["Wide reply" gnus-summary-wide-reply t]
1790 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1791 ["Mail forward" gnus-summary-mail-forward t]
1792 ["Post forward" gnus-summary-post-forward t]
1793 ["Digest and mail" gnus-uu-digest-mail-forward t]
1794 ["Digest and post" gnus-uu-digest-post-forward t]
1795 ["Resend message" gnus-summary-resend-message t]
1796 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1797 ["Send a mail" gnus-summary-mail-other-window t]
1798 ["Uuencode and post" gnus-uu-post-news t]
1799 ["Followup via news" gnus-summary-followup-to-mail t]
1800 ["Followup via news and yank"
1801 gnus-summary-followup-to-mail-with-original t]
1803 ;;["Send" gnus-summary-send-draft t]
1804 ;;["Send bounced" gnus-resend-bounced-mail t])
1808 gnus-summary-misc-menu gnus-summary-mode-map ""
1811 ["Mark as read" gnus-summary-mark-as-read-forward t]
1812 ["Mark same subject and select"
1813 gnus-summary-kill-same-subject-and-select t]
1814 ["Mark same subject" gnus-summary-kill-same-subject t]
1815 ["Catchup" gnus-summary-catchup t]
1816 ["Catchup all" gnus-summary-catchup-all t]
1817 ["Catchup to here" gnus-summary-catchup-to-here t]
1818 ["Catchup region" gnus-summary-mark-region-as-read t]
1819 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1821 ["Tick" gnus-summary-tick-article-forward t]
1822 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1823 ["Remove marks" gnus-summary-clear-mark-forward t]
1824 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1825 ["Set bookmark" gnus-summary-set-bookmark t]
1826 ["Remove bookmark" gnus-summary-remove-bookmark t])
1828 ["Marks..." gnus-summary-limit-to-marks t]
1829 ["Subject..." gnus-summary-limit-to-subject t]
1830 ["Author..." gnus-summary-limit-to-author t]
1831 ["Age..." gnus-summary-limit-to-age t]
1832 ["Extra..." gnus-summary-limit-to-extra t]
1833 ["Score" gnus-summary-limit-to-score t]
1834 ["Unread" gnus-summary-limit-to-unread t]
1835 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1836 ["Articles" gnus-summary-limit-to-articles t]
1837 ["Pop limit" gnus-summary-pop-limit t]
1838 ["Show dormant" gnus-summary-limit-include-dormant t]
1839 ["Hide childless dormant"
1840 gnus-summary-limit-exclude-childless-dormant t]
1841 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1842 ["Hide marked" gnus-summary-limit-exclude-marks t]
1843 ["Show expunged" gnus-summary-show-all-expunged t])
1845 ["Set mark" gnus-summary-mark-as-processable t]
1846 ["Remove mark" gnus-summary-unmark-as-processable t]
1847 ["Remove all marks" gnus-summary-unmark-all-processable t]
1848 ["Mark above" gnus-uu-mark-over t]
1849 ["Mark series" gnus-uu-mark-series t]
1850 ["Mark region" gnus-uu-mark-region t]
1851 ["Unmark region" gnus-uu-unmark-region t]
1852 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1853 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1854 ["Mark all" gnus-uu-mark-all t]
1855 ["Mark buffer" gnus-uu-mark-buffer t]
1856 ["Mark sparse" gnus-uu-mark-sparse t]
1857 ["Mark thread" gnus-uu-mark-thread t]
1858 ["Unmark thread" gnus-uu-unmark-thread t]
1859 ("Process Mark Sets"
1860 ["Kill" gnus-summary-kill-process-mark t]
1861 ["Yank" gnus-summary-yank-process-mark
1862 gnus-newsgroup-process-stack]
1863 ["Save" gnus-summary-save-process-mark t]))
1865 ["Page forward" gnus-summary-next-page t]
1866 ["Page backward" gnus-summary-prev-page t]
1867 ["Line forward" gnus-summary-scroll-up t])
1869 ["Next unread article" gnus-summary-next-unread-article t]
1870 ["Previous unread article" gnus-summary-prev-unread-article t]
1871 ["Next article" gnus-summary-next-article t]
1872 ["Previous article" gnus-summary-prev-article t]
1873 ["Next unread subject" gnus-summary-next-unread-subject t]
1874 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1875 ["Next article same subject" gnus-summary-next-same-subject t]
1876 ["Previous article same subject" gnus-summary-prev-same-subject t]
1877 ["First unread article" gnus-summary-first-unread-article t]
1878 ["Best unread article" gnus-summary-best-unread-article t]
1879 ["Go to subject number..." gnus-summary-goto-subject t]
1880 ["Go to article number..." gnus-summary-goto-article t]
1881 ["Go to the last article" gnus-summary-goto-last-article t]
1882 ["Pop article off history" gnus-summary-pop-article t])
1884 ["Sort by number" gnus-summary-sort-by-number t]
1885 ["Sort by author" gnus-summary-sort-by-author t]
1886 ["Sort by subject" gnus-summary-sort-by-subject t]
1887 ["Sort by date" gnus-summary-sort-by-date t]
1888 ["Sort by score" gnus-summary-sort-by-score t]
1889 ["Sort by lines" gnus-summary-sort-by-lines t]
1890 ["Sort by characters" gnus-summary-sort-by-chars t])
1892 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1893 ["Describe group" gnus-summary-describe-group t]
1894 ["Read manual" gnus-info-find-node t])
1896 ["Pick and read" gnus-pick-mode t]
1897 ["Binary" gnus-binary-mode t])
1899 ["Regenerate" gnus-summary-prepare t]
1900 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1901 ["Toggle threading" gnus-summary-toggle-threads t])
1902 ["Filter articles..." gnus-summary-execute-command t]
1903 ["Run command on subjects..." gnus-summary-universal-argument t]
1904 ["Search articles forward..." gnus-summary-search-article-forward t]
1905 ["Search articles backward..." gnus-summary-search-article-backward t]
1906 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1907 ["Expand window" gnus-summary-expand-window t]
1908 ["Expire expirable articles" gnus-summary-expire-articles
1909 (gnus-check-backend-function
1910 'request-expire-articles gnus-newsgroup-name)]
1911 ["Edit local kill file" gnus-summary-edit-local-kill t]
1912 ["Edit main kill file" gnus-summary-edit-global-kill t]
1913 ["Edit group parameters" gnus-summary-edit-parameters t]
1914 ["Customize group parameters" gnus-summary-customize-parameters t]
1915 ["Send a bug report" gnus-bug t]
1917 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1918 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
1919 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1920 ["Exit group" gnus-summary-exit t]
1921 ["Exit group without updating" gnus-summary-exit-no-update t]
1922 ["Exit and goto next group" gnus-summary-next-group t]
1923 ["Exit and goto prev group" gnus-summary-prev-group t]
1924 ["Reselect group" gnus-summary-reselect-current-group t]
1925 ["Rescan group" gnus-summary-rescan-group t]
1926 ["Update dribble" gnus-summary-save-newsrc t])))
1928 (gnus-run-hooks 'gnus-summary-menu-hook)))
1930 (defun gnus-score-set-default (var value)
1931 "A version of set that updates the GNU Emacs menu-bar."
1933 ;; It is the message that forces the active status to be updated.
1936 (defun gnus-make-score-map (type)
1937 "Make a summary score map of type TYPE."
1940 (let ((headers '(("author" "from" string)
1941 ("subject" "subject" string)
1942 ("article body" "body" string)
1943 ("article head" "head" string)
1944 ("xref" "xref" string)
1945 ("extra header" "extra" string)
1946 ("lines" "lines" number)
1947 ("followups to author" "followup" string)))
1948 (types '((number ("less than" <)
1951 (string ("substring" s)
1955 (perms '(("temporary" (current-time-string))
1963 (if (eq type 'lower)
1968 (setq header (car headers))
1974 (let ((ts (cdr (assoc (nth 2 header) types)))
1990 'gnus-summary-score-entry
1992 (if (or (string= (nth 1 header)
1994 (string= (nth 1 header)
1997 (list 'gnus-summary-header
1999 (list 'quote (nth 1 (car ts)))
2000 (list 'gnus-score-default nil)
2006 (list (nreverse outp))))
2009 (list (nreverse outt))))
2011 (setq headers (cdr headers)))
2012 (list (nreverse outh))))))))
2016 (defun gnus-summary-mode (&optional group)
2017 "Major mode for reading articles.
2019 All normal editing commands are switched off.
2020 \\<gnus-summary-mode-map>
2021 Each line in this buffer represents one article. To read an
2022 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2023 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2026 You can also post articles and send mail from this buffer. To
2027 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2028 of an article, type `\\[gnus-summary-reply]'.
2030 There are approx. one gazillion commands you can execute in this
2031 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2033 The following commands are available:
2035 \\{gnus-summary-mode-map}"
2037 (when (gnus-visual-p 'summary-menu 'menu)
2038 (gnus-summary-make-menu-bar))
2039 (kill-all-local-variables)
2040 (gnus-summary-make-local-variables)
2041 (gnus-make-thread-indent-array)
2042 (gnus-simplify-mode-line)
2043 (setq major-mode 'gnus-summary-mode)
2044 (setq mode-name "Summary")
2045 (make-local-variable 'minor-mode-alist)
2046 (use-local-map gnus-summary-mode-map)
2047 (buffer-disable-undo)
2048 (setq buffer-read-only t) ;Disable modification
2049 (setq truncate-lines t)
2050 (setq selective-display t)
2051 (setq selective-display-ellipses t) ;Display `...'
2052 (gnus-summary-set-display-table)
2053 (gnus-set-default-directory)
2054 (setq gnus-newsgroup-name group)
2055 (make-local-variable 'gnus-summary-line-format)
2056 (make-local-variable 'gnus-summary-line-format-spec)
2057 (make-local-variable 'gnus-summary-dummy-line-format)
2058 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2059 (make-local-variable 'gnus-summary-mark-positions)
2060 (make-local-hook 'pre-command-hook)
2061 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2062 (gnus-run-hooks 'gnus-summary-mode-hook)
2063 (mm-enable-multibyte)
2064 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2065 (gnus-update-summary-mark-positions))
2067 (defun gnus-summary-make-local-variables ()
2068 "Make all the local summary buffer variables."
2070 (dolist (local gnus-summary-local-variables)
2073 (if (eq (cdr local) 'global)
2074 ;; Copy the global value of the variable.
2075 (setq global (symbol-value (car local)))
2076 ;; Use the value from the list.
2077 (setq global (eval (cdr local))))
2078 (set (make-local-variable (car local)) global))
2079 ;; Simple nil-valued local variable.
2080 (set (make-local-variable local) nil)))))
2082 (defun gnus-summary-clear-local-variables ()
2083 (let ((locals gnus-summary-local-variables))
2085 (if (consp (car locals))
2086 (and (vectorp (caar locals))
2087 (set (caar locals) nil))
2088 (and (vectorp (car locals))
2089 (set (car locals) nil)))
2090 (setq locals (cdr locals)))))
2092 ;; Summary data functions.
2094 (defmacro gnus-data-number (data)
2097 (defmacro gnus-data-set-number (data number)
2098 `(setcar ,data ,number))
2100 (defmacro gnus-data-mark (data)
2103 (defmacro gnus-data-set-mark (data mark)
2104 `(setcar (nthcdr 1 ,data) ,mark))
2106 (defmacro gnus-data-pos (data)
2109 (defmacro gnus-data-set-pos (data pos)
2110 `(setcar (nthcdr 2 ,data) ,pos))
2112 (defmacro gnus-data-header (data)
2115 (defmacro gnus-data-set-header (data header)
2116 `(setf (nth 3 ,data) ,header))
2118 (defmacro gnus-data-level (data)
2121 (defmacro gnus-data-unread-p (data)
2122 `(= (nth 1 ,data) gnus-unread-mark))
2124 (defmacro gnus-data-read-p (data)
2125 `(/= (nth 1 ,data) gnus-unread-mark))
2127 (defmacro gnus-data-pseudo-p (data)
2128 `(consp (nth 3 ,data)))
2130 (defmacro gnus-data-find (number)
2131 `(assq ,number gnus-newsgroup-data))
2133 (defmacro gnus-data-find-list (number &optional data)
2134 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2135 (memq (assq ,number bdata)
2138 (defmacro gnus-data-make (number mark pos header level)
2139 `(list ,number ,mark ,pos ,header ,level))
2141 (defun gnus-data-enter (after-article number mark pos header level offset)
2142 (let ((data (gnus-data-find-list after-article)))
2144 (error "No such article: %d" after-article))
2145 (setcdr data (cons (gnus-data-make number mark pos header level)
2147 (setq gnus-newsgroup-data-reverse nil)
2148 (gnus-data-update-list (cddr data) offset)))
2150 (defun gnus-data-enter-list (after-article list &optional offset)
2152 (let ((data (and after-article (gnus-data-find-list after-article)))
2156 (let ((odata gnus-newsgroup-data))
2157 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2159 (gnus-data-update-list odata offset)))
2160 ;; Find the last element in the list to be spliced into the main
2163 (setq list (cdr list)))
2166 (setcdr list gnus-newsgroup-data)
2167 (setq gnus-newsgroup-data ilist)
2169 (gnus-data-update-list (cdr list) offset)))
2170 (setcdr list (cdr data))
2173 (gnus-data-update-list (cdr list) offset))))
2174 (setq gnus-newsgroup-data-reverse nil))))
2176 (defun gnus-data-remove (article &optional offset)
2177 (let ((data gnus-newsgroup-data))
2178 (if (= (gnus-data-number (car data)) article)
2180 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2181 gnus-newsgroup-data-reverse nil)
2183 (gnus-data-update-list gnus-newsgroup-data offset)))
2185 (when (= (gnus-data-number (cadr data)) article)
2186 (setcdr data (cddr data))
2188 (gnus-data-update-list (cdr data) offset))
2190 gnus-newsgroup-data-reverse nil))
2191 (setq data (cdr data))))))
2193 (defmacro gnus-data-list (backward)
2195 (or gnus-newsgroup-data-reverse
2196 (setq gnus-newsgroup-data-reverse
2197 (reverse gnus-newsgroup-data)))
2198 gnus-newsgroup-data))
2200 (defun gnus-data-update-list (data offset)
2201 "Add OFFSET to the POS of all data entries in DATA."
2202 (setq gnus-newsgroup-data-reverse nil)
2204 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2205 (setq data (cdr data))))
2207 (defun gnus-summary-article-pseudo-p (article)
2208 "Say whether this article is a pseudo article or not."
2209 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2211 (defmacro gnus-summary-article-sparse-p (article)
2212 "Say whether this article is a sparse article or not."
2213 `(memq ,article gnus-newsgroup-sparse))
2215 (defmacro gnus-summary-article-ancient-p (article)
2216 "Say whether this article is a sparse article or not."
2217 `(memq ,article gnus-newsgroup-ancient))
2219 (defun gnus-article-parent-p (number)
2220 "Say whether this article is a parent or not."
2221 (let ((data (gnus-data-find-list number)))
2222 (and (cdr data) ; There has to be an article after...
2223 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2224 (gnus-data-level (nth 1 data))))))
2226 (defun gnus-article-children (number)
2227 "Return a list of all children to NUMBER."
2228 (let* ((data (gnus-data-find-list number))
2229 (level (gnus-data-level (car data)))
2231 (setq data (cdr data))
2233 (= (gnus-data-level (car data)) (1+ level)))
2234 (push (gnus-data-number (car data)) children)
2235 (setq data (cdr data)))
2238 (defmacro gnus-summary-skip-intangible ()
2239 "If the current article is intangible, then jump to a different article."
2240 '(let ((to (get-text-property (point) 'gnus-intangible)))
2241 (and to (gnus-summary-goto-subject to))))
2243 (defmacro gnus-summary-article-intangible-p ()
2244 "Say whether this article is intangible or not."
2245 '(get-text-property (point) 'gnus-intangible))
2247 (defun gnus-article-read-p (article)
2248 "Say whether ARTICLE is read or not."
2249 (not (or (memq article gnus-newsgroup-marked)
2250 (memq article gnus-newsgroup-unreads)
2251 (memq article gnus-newsgroup-unselected)
2252 (memq article gnus-newsgroup-dormant))))
2254 ;; Some summary mode macros.
2256 (defmacro gnus-summary-article-number ()
2257 "The article number of the article on the current line.
2258 If there isn's an article number here, then we return the current
2261 (gnus-summary-skip-intangible)
2262 (or (get-text-property (point) 'gnus-number)
2263 (gnus-summary-last-subject))))
2265 (defmacro gnus-summary-article-header (&optional number)
2266 "Return the header of article NUMBER."
2267 `(gnus-data-header (gnus-data-find
2268 ,(or number '(gnus-summary-article-number)))))
2270 (defmacro gnus-summary-thread-level (&optional number)
2271 "Return the level of thread that starts with article NUMBER."
2272 `(if (and (eq gnus-summary-make-false-root 'dummy)
2273 (get-text-property (point) 'gnus-intangible))
2275 (gnus-data-level (gnus-data-find
2276 ,(or number '(gnus-summary-article-number))))))
2278 (defmacro gnus-summary-article-mark (&optional number)
2279 "Return the mark of article NUMBER."
2280 `(gnus-data-mark (gnus-data-find
2281 ,(or number '(gnus-summary-article-number)))))
2283 (defmacro gnus-summary-article-pos (&optional number)
2284 "Return the position of the line of article NUMBER."
2285 `(gnus-data-pos (gnus-data-find
2286 ,(or number '(gnus-summary-article-number)))))
2288 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2289 (defmacro gnus-summary-article-subject (&optional number)
2290 "Return current subject string or nil if nothing."
2293 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2294 '(gnus-data-header (assq (gnus-summary-article-number)
2295 gnus-newsgroup-data)))))
2298 (mail-header-subject headers))))
2300 (defmacro gnus-summary-article-score (&optional number)
2301 "Return current article score."
2302 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2303 gnus-newsgroup-scored))
2304 gnus-summary-default-score 0))
2306 (defun gnus-summary-article-children (&optional number)
2307 "Return a list of article numbers that are children of article NUMBER."
2308 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2309 (level (gnus-data-level (car data)))
2311 (while (and (setq data (cdr data))
2312 (> (setq l (gnus-data-level (car data))) level))
2313 (and (= (1+ level) l)
2314 (push (gnus-data-number (car data))
2316 (nreverse children)))
2318 (defun gnus-summary-article-parent (&optional number)
2319 "Return the article number of the parent of article NUMBER."
2320 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2321 (gnus-data-list t)))
2322 (level (gnus-data-level (car data))))
2324 () ; This is a root.
2325 ;; We search until we find an article with a level less than
2326 ;; this one. That function has to be the parent.
2327 (while (and (setq data (cdr data))
2328 (not (< (gnus-data-level (car data)) level))))
2329 (and data (gnus-data-number (car data))))))
2331 (defun gnus-unread-mark-p (mark)
2332 "Say whether MARK is the unread mark."
2333 (= mark gnus-unread-mark))
2335 (defun gnus-read-mark-p (mark)
2336 "Say whether MARK is one of the marks that mark as read.
2337 This is all marks except unread, ticked, dormant, and expirable."
2338 (not (or (= mark gnus-unread-mark)
2339 (= mark gnus-ticked-mark)
2340 (= mark gnus-dormant-mark)
2341 (= mark gnus-expirable-mark))))
2343 (defmacro gnus-article-mark (number)
2344 "Return the MARK of article NUMBER.
2345 This macro should only be used when computing the mark the \"first\"
2346 time; i.e., when generating the summary lines. After that,
2347 `gnus-summary-article-mark' should be used to examine the
2350 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2351 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2352 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2353 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2354 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2355 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2356 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2357 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2358 gnus-ancient-mark))))
2360 ;; Saving hidden threads.
2362 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2363 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2365 (defmacro gnus-save-hidden-threads (&rest forms)
2366 "Save hidden threads, eval FORMS, and restore the hidden threads."
2367 (let ((config (make-symbol "config")))
2368 `(let ((,config (gnus-hidden-threads-configuration)))
2372 (gnus-restore-hidden-threads-configuration ,config)))))
2374 (defun gnus-data-compute-positions ()
2375 "Compute the positions of all articles."
2376 (setq gnus-newsgroup-data-reverse nil)
2377 (let ((data gnus-newsgroup-data))
2379 (gnus-save-hidden-threads
2380 (gnus-summary-show-all-threads)
2381 (goto-char (point-min))
2383 (while (get-text-property (point) 'gnus-intangible)
2385 (gnus-data-set-pos (car data) (+ (point) 3))
2386 (setq data (cdr data))
2387 (forward-line 1))))))
2389 (defun gnus-hidden-threads-configuration ()
2390 "Return the current hidden threads configuration."
2393 (goto-char (point-min))
2394 (while (search-forward "\r" nil t)
2395 (push (1- (point)) config))
2398 (defun gnus-restore-hidden-threads-configuration (config)
2399 "Restore hidden threads configuration from CONFIG."
2400 (let (point buffer-read-only)
2401 (while (setq point (pop config))
2402 (when (and (< point (point-max))
2404 (eq (char-after) ?\n))
2405 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2407 ;; Various summary mode internalish functions.
2409 (defun gnus-mouse-pick-article (e)
2412 (gnus-summary-next-page nil t))
2414 (defun gnus-summary-set-display-table ()
2415 ;; Change the display table. Odd characters have a tendency to mess
2416 ;; up nicely formatted displays - we make all possible glyphs
2417 ;; display only a single character.
2419 ;; We start from the standard display table, if any.
2420 (let ((table (or (copy-sequence standard-display-table)
2421 (make-display-table)))
2423 ;; Nix out all the control chars...
2424 (while (>= (setq i (1- i)) 0)
2425 (aset table i [??]))
2426 ;; ... but not newline and cr, of course. (cr is necessary for the
2427 ;; selective display).
2428 (aset table ?\n nil)
2429 (aset table ?\r nil)
2430 ;; We keep TAB as well.
2431 (aset table ?\t nil)
2432 ;; We nix out any glyphs over 126 that are not set already.
2434 (while (>= (setq i (1- i)) 127)
2435 ;; Only modify if the entry is nil.
2436 (unless (aref table i)
2437 (aset table i [??]))))
2438 (setq buffer-display-table table)))
2440 (defun gnus-summary-setup-buffer (group)
2441 "Initialize summary buffer."
2442 (let ((buffer (concat "*Summary " group "*")))
2443 (if (get-buffer buffer)
2446 (setq gnus-summary-buffer (current-buffer))
2447 (not gnus-newsgroup-prepared))
2448 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2449 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2450 (gnus-summary-mode group)
2452 (gnus-carpal-setup-buffer 'summary))
2453 (unless gnus-single-article-buffer
2454 (make-local-variable 'gnus-article-buffer)
2455 (make-local-variable 'gnus-article-current)
2456 (make-local-variable 'gnus-original-article-buffer))
2457 (setq gnus-newsgroup-name group)
2460 (defun gnus-set-global-variables ()
2461 ;; Set the global equivalents of the summary buffer-local variables
2462 ;; to the latest values they had. These reflect the summary buffer
2463 ;; that was in action when the last article was fetched.
2464 (when (eq major-mode 'gnus-summary-mode)
2465 (setq gnus-summary-buffer (current-buffer))
2466 (let ((name gnus-newsgroup-name)
2467 (marked gnus-newsgroup-marked)
2468 (unread gnus-newsgroup-unreads)
2469 (headers gnus-current-headers)
2470 (data gnus-newsgroup-data)
2471 (summary gnus-summary-buffer)
2472 (article-buffer gnus-article-buffer)
2473 (original gnus-original-article-buffer)
2474 (gac gnus-article-current)
2475 (reffed gnus-reffed-article-number)
2476 (score-file gnus-current-score-file)
2477 (default-charset gnus-newsgroup-charset))
2479 (set-buffer gnus-group-buffer)
2480 (setq gnus-newsgroup-name name
2481 gnus-newsgroup-marked marked
2482 gnus-newsgroup-unreads unread
2483 gnus-current-headers headers
2484 gnus-newsgroup-data data
2485 gnus-article-current gac
2486 gnus-summary-buffer summary
2487 gnus-article-buffer article-buffer
2488 gnus-original-article-buffer original
2489 gnus-reffed-article-number reffed
2490 gnus-current-score-file score-file
2491 gnus-newsgroup-charset default-charset)
2492 ;; The article buffer also has local variables.
2493 (when (gnus-buffer-live-p gnus-article-buffer)
2494 (set-buffer gnus-article-buffer)
2495 (setq gnus-summary-buffer summary))))))
2497 (defun gnus-summary-article-unread-p (article)
2498 "Say whether ARTICLE is unread or not."
2499 (memq article gnus-newsgroup-unreads))
2501 (defun gnus-summary-first-article-p (&optional article)
2502 "Return whether ARTICLE is the first article in the buffer."
2503 (if (not (setq article (or article (gnus-summary-article-number))))
2505 (eq article (caar gnus-newsgroup-data))))
2507 (defun gnus-summary-last-article-p (&optional article)
2508 "Return whether ARTICLE is the last article in the buffer."
2509 (if (not (setq article (or article (gnus-summary-article-number))))
2510 ;; All non-existent numbers are the last article. :-)
2512 (not (cdr (gnus-data-find-list article)))))
2514 (defun gnus-make-thread-indent-array ()
2516 (unless (and gnus-thread-indent-array
2517 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2518 (setq gnus-thread-indent-array (make-vector 201 "")
2519 gnus-thread-indent-array-level gnus-thread-indent-level)
2521 (aset gnus-thread-indent-array n
2522 (make-string (* n gnus-thread-indent-level) ? ))
2525 (defun gnus-update-summary-mark-positions ()
2526 "Compute where the summary marks are to go."
2528 (when (gnus-buffer-exists-p gnus-summary-buffer)
2529 (set-buffer gnus-summary-buffer))
2530 (let ((gnus-replied-mark 129)
2531 (gnus-score-below-mark 130)
2532 (gnus-score-over-mark 130)
2533 (gnus-download-mark 131)
2534 (spec gnus-summary-line-format-spec)
2537 (gnus-set-work-buffer)
2538 (let ((gnus-summary-line-format-spec spec)
2539 (gnus-newsgroup-downloadable '((0 . t))))
2540 (gnus-summary-insert-line
2541 [0 "" "" "" "" "" 0 0 "" nil] 0 nil 128 t nil "" nil 1)
2542 (goto-char (point-min))
2543 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2545 (goto-char (point-min))
2546 (push (cons 'replied (and (search-forward "\201" nil t)
2549 (goto-char (point-min))
2550 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2552 (goto-char (point-min))
2553 (push (cons 'download
2554 (and (search-forward "\203" nil t) (- (point) 2)))
2556 (setq gnus-summary-mark-positions pos))))
2558 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2559 "Insert a dummy root in the summary buffer."
2561 (gnus-add-text-properties
2562 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2563 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2565 (defun gnus-summary-from-or-to-or-newsgroups (header)
2566 (let ((to (cdr (assq 'To (mail-header-extra header))))
2567 (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header))))
2568 (mail-parse-charset gnus-newsgroup-charset)
2569 (mail-parse-ignored-charsets
2570 (save-excursion (set-buffer gnus-summary-buffer)
2571 gnus-newsgroup-ignored-charsets)))
2574 gnus-ignored-from-addresses
2575 (string-match gnus-ignored-from-addresses
2576 (mail-header-from header)))
2578 (or (car (funcall gnus-extract-address-components
2580 gnus-decode-encoded-word-function to)))
2581 (funcall gnus-decode-encoded-word-function to))))
2583 gnus-ignored-from-addresses
2584 (string-match gnus-ignored-from-addresses
2585 (mail-header-from header)))
2586 (concat "=> " newsgroups))
2588 (or (car (funcall gnus-extract-address-components
2589 (mail-header-from header)))
2590 (mail-header-from header))))))
2592 (defun gnus-summary-insert-line (gnus-tmp-header
2593 gnus-tmp-level gnus-tmp-current
2594 gnus-tmp-unread gnus-tmp-replied
2595 gnus-tmp-expirable gnus-tmp-subject-or-nil
2596 &optional gnus-tmp-dummy gnus-tmp-score
2598 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2599 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2600 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2601 (gnus-tmp-score-char
2602 (if (or (null gnus-summary-default-score)
2603 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2604 gnus-summary-zcore-fuzz))
2606 (if (< gnus-tmp-score gnus-summary-default-score)
2607 gnus-score-below-mark gnus-score-over-mark)))
2609 (cond (gnus-tmp-process gnus-process-mark)
2610 ((memq gnus-tmp-current gnus-newsgroup-cached)
2612 (gnus-tmp-replied gnus-replied-mark)
2613 ((memq gnus-tmp-current gnus-newsgroup-saved)
2615 (t gnus-unread-mark)))
2616 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2619 ((string-match "<[^>]+> *$" gnus-tmp-from)
2620 (let ((beg (match-beginning 0)))
2621 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2622 (substring gnus-tmp-from (1+ (match-beginning 0))
2623 (1- (match-end 0))))
2624 (substring gnus-tmp-from 0 beg))))
2625 ((string-match "(.+)" gnus-tmp-from)
2626 (substring gnus-tmp-from
2627 (1+ (match-beginning 0)) (1- (match-end 0))))
2629 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2630 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2631 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2632 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2633 (buffer-read-only nil))
2634 (when (string= gnus-tmp-name "")
2635 (setq gnus-tmp-name gnus-tmp-from))
2636 (unless (numberp gnus-tmp-lines)
2637 (setq gnus-tmp-lines 0))
2638 (gnus-put-text-property
2640 (progn (eval gnus-summary-line-format-spec) (point))
2641 'gnus-number gnus-tmp-number)
2642 (when (gnus-visual-p 'summary-highlight 'highlight)
2644 (gnus-run-hooks 'gnus-summary-update-hook)
2647 (defun gnus-summary-update-line (&optional dont-update)
2648 ;; Update summary line after change.
2649 (when (and gnus-summary-default-score
2650 (not gnus-summary-inhibit-highlight))
2651 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2652 (article (gnus-summary-article-number))
2653 (score (gnus-summary-article-score article)))
2655 (if (and gnus-summary-mark-below
2656 (< (gnus-summary-article-score)
2657 gnus-summary-mark-below))
2658 ;; This article has a low score, so we mark it as read.
2659 (when (memq article gnus-newsgroup-unreads)
2660 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2661 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2662 ;; This article was previously marked as read on account
2663 ;; of a low score, but now it has risen, so we mark it as
2665 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2666 (gnus-summary-update-mark
2667 (if (or (null gnus-summary-default-score)
2668 (<= (abs (- score gnus-summary-default-score))
2669 gnus-summary-zcore-fuzz))
2671 (if (< score gnus-summary-default-score)
2672 gnus-score-below-mark gnus-score-over-mark))
2674 ;; Do visual highlighting.
2675 (when (gnus-visual-p 'summary-highlight 'highlight)
2676 (gnus-run-hooks 'gnus-summary-update-hook)))))
2678 (defvar gnus-tmp-new-adopts nil)
2680 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2681 "Return the number of articles in THREAD.
2682 This may be 0 in some cases -- if none of the articles in
2683 the thread are to be displayed."
2685 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2687 ((not (listp thread))
2689 ((and (consp thread) (cdr thread))
2692 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2695 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2698 (when (and level (zerop level) gnus-tmp-new-adopts)
2701 'gnus-summary-number-of-articles-in-thread
2702 gnus-tmp-new-adopts))))
2704 (if (> number 1) gnus-not-empty-thread-mark
2705 gnus-empty-thread-mark)
2708 (defun gnus-summary-set-local-parameters (group)
2709 "Go through the local params of GROUP and set all variable specs in that list."
2710 (let ((params (gnus-group-find-parameter group))
2713 (setq elem (car params)
2714 params (cdr params))
2715 (and (consp elem) ; Has to be a cons.
2716 (consp (cdr elem)) ; The cdr has to be a list.
2717 (symbolp (car elem)) ; Has to be a symbol in there.
2718 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2719 (ignore-errors ; So we set it.
2720 (make-local-variable (car elem))
2721 (set (car elem) (eval (nth 1 elem))))))))
2723 (defun gnus-summary-read-group (group &optional show-all no-article
2724 kill-buffer no-display backward
2726 "Start reading news in newsgroup GROUP.
2727 If SHOW-ALL is non-nil, already read articles are also listed.
2728 If NO-ARTICLE is non-nil, no article is selected initially.
2729 If NO-DISPLAY, don't generate a summary buffer."
2733 (let ((gnus-auto-select-next nil))
2734 (or (gnus-summary-read-group-1
2735 group show-all no-article
2736 kill-buffer no-display
2739 select-articles nil)))))
2740 (eq gnus-auto-select-next 'quietly))
2741 (set-buffer gnus-group-buffer)
2742 ;; The entry function called above goes to the next
2743 ;; group automatically, so we go two groups back
2744 ;; if we are searching for the previous group.
2746 (gnus-group-prev-unread-group 2))
2747 (if (not (equal group (gnus-group-group-name)))
2748 (setq group (gnus-group-group-name))
2752 (defun gnus-summary-read-group-1 (group show-all no-article
2753 kill-buffer no-display
2754 &optional select-articles)
2755 ;; Killed foreign groups can't be entered.
2756 (when (and (not (gnus-group-native-p group))
2757 (not (gnus-gethash group gnus-newsrc-hashtb)))
2758 (error "Dead non-native groups can't be entered"))
2759 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2760 (let* ((new-group (gnus-summary-setup-buffer group))
2761 (quit-config (gnus-group-quit-config group))
2762 (did-select (and new-group (gnus-select-newsgroup
2763 group show-all select-articles))))
2765 ;; This summary buffer exists already, so we just select it.
2767 (gnus-set-global-variables)
2769 (gnus-kill-or-deaden-summary kill-buffer))
2770 (gnus-configure-windows 'summary 'force)
2771 (gnus-set-mode-line 'summary)
2772 (gnus-summary-position-point)
2775 ;; We couldn't select this group.
2777 (when (and (eq major-mode 'gnus-summary-mode)
2778 (not (equal (current-buffer) kill-buffer)))
2779 (kill-buffer (current-buffer))
2780 (if (not quit-config)
2782 ;; Update the info -- marks might need to be removed,
2784 (gnus-summary-update-info)
2785 (set-buffer gnus-group-buffer)
2786 (gnus-group-jump-to-group group)
2787 (gnus-group-next-unread-group 1))
2788 (gnus-handle-ephemeral-exit quit-config)))
2789 (gnus-message 3 "Can't select group")
2791 ;; The user did a `C-g' while prompting for number of articles,
2792 ;; so we exit this group.
2793 ((eq did-select 'quit)
2794 (and (eq major-mode 'gnus-summary-mode)
2795 (not (equal (current-buffer) kill-buffer))
2796 (kill-buffer (current-buffer)))
2798 (gnus-kill-or-deaden-summary kill-buffer))
2799 (if (not quit-config)
2801 (set-buffer gnus-group-buffer)
2802 (gnus-group-jump-to-group group)
2803 (gnus-group-next-unread-group 1)
2804 (gnus-configure-windows 'group 'force))
2805 (gnus-handle-ephemeral-exit quit-config))
2806 ;; Finally signal the quit.
2808 ;; The group was successfully selected.
2810 (gnus-set-global-variables)
2811 ;; Save the active value in effect when the group was entered.
2812 (setq gnus-newsgroup-active
2814 (gnus-active gnus-newsgroup-name)))
2815 ;; You can change the summary buffer in some way with this hook.
2816 (gnus-run-hooks 'gnus-select-group-hook)
2817 ;; Set any local variables in the group parameters.
2818 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2819 (gnus-update-format-specifications
2820 nil 'summary 'summary-mode 'summary-dummy)
2821 (gnus-update-summary-mark-positions)
2822 ;; Do score processing.
2823 (when gnus-use-scoring
2824 (gnus-possibly-score-headers))
2825 ;; Check whether to fill in the gaps in the threads.
2826 (when gnus-build-sparse-threads
2827 (gnus-build-sparse-threads))
2828 ;; Find the initial limit.
2829 (if gnus-show-threads
2831 (let ((gnus-newsgroup-dormant nil))
2832 (gnus-summary-initial-limit show-all))
2833 (gnus-summary-initial-limit show-all))
2834 ;; When untreaded, all articles are always shown.
2835 (setq gnus-newsgroup-limit
2837 (lambda (header) (mail-header-number header))
2838 gnus-newsgroup-headers)))
2839 ;; Generate the summary buffer.
2841 (gnus-summary-prepare))
2842 (when gnus-use-trees
2843 (gnus-tree-open group)
2844 (setq gnus-summary-highlight-line-function
2845 'gnus-tree-highlight-article))
2846 ;; If the summary buffer is empty, but there are some low-scored
2847 ;; articles or some excluded dormants, we include these in the
2849 (when (and (zerop (buffer-size))
2851 (cond (gnus-newsgroup-dormant
2852 (gnus-summary-limit-include-dormant))
2853 ((and gnus-newsgroup-scored show-all)
2854 (gnus-summary-limit-include-expunged t))))
2855 ;; Function `gnus-apply-kill-file' must be called in this hook.
2856 (gnus-run-hooks 'gnus-apply-kill-hook)
2857 (if (and (zerop (buffer-size))
2860 ;; This newsgroup is empty.
2861 (gnus-summary-catchup-and-exit nil t)
2862 (gnus-message 6 "No unread news")
2864 (gnus-kill-or-deaden-summary kill-buffer))
2865 ;; Return nil from this function.
2867 ;; Hide conversation thread subtrees. We cannot do this in
2868 ;; gnus-summary-prepare-hook since kill processing may not
2869 ;; work with hidden articles.
2870 (and gnus-show-threads
2871 gnus-thread-hide-subtree
2872 (gnus-summary-hide-all-threads))
2874 (gnus-kill-or-deaden-summary kill-buffer))
2875 ;; Show first unread article if requested.
2876 (if (and (not no-article)
2878 gnus-newsgroup-unreads
2879 gnus-auto-select-first)
2881 (gnus-configure-windows 'summary)
2883 ((eq gnus-auto-select-first 'best)
2884 (gnus-summary-best-unread-article))
2885 ((eq gnus-auto-select-first t)
2886 (gnus-summary-first-unread-article))
2887 ((gnus-functionp gnus-auto-select-first)
2888 (funcall gnus-auto-select-first))))
2889 ;; Don't select any articles, just move point to the first
2890 ;; article in the group.
2891 (goto-char (point-min))
2892 (gnus-summary-position-point)
2893 (gnus-configure-windows 'summary 'force)
2894 (gnus-set-mode-line 'summary))
2895 (when (get-buffer-window gnus-group-buffer t)
2896 ;; Gotta use windows, because recenter does weird stuff if
2897 ;; the current buffer ain't the displayed window.
2898 (let ((owin (selected-window)))
2899 (select-window (get-buffer-window gnus-group-buffer t))
2900 (when (gnus-group-goto-group group)
2902 (select-window owin)))
2903 ;; Mark this buffer as "prepared".
2904 (setq gnus-newsgroup-prepared t)
2905 (gnus-run-hooks 'gnus-summary-prepared-hook)
2908 (defun gnus-summary-prepare ()
2909 "Generate the summary buffer."
2911 (let ((buffer-read-only nil))
2913 (setq gnus-newsgroup-data nil
2914 gnus-newsgroup-data-reverse nil)
2915 (gnus-run-hooks 'gnus-summary-generate-hook)
2916 ;; Generate the buffer, either with threads or without.
2917 (when gnus-newsgroup-headers
2918 (gnus-summary-prepare-threads
2919 (if gnus-show-threads
2920 (gnus-sort-gathered-threads
2921 (funcall gnus-summary-thread-gathering-function
2923 (gnus-cut-threads (gnus-make-threads)))))
2924 ;; Unthreaded display.
2925 (gnus-sort-articles gnus-newsgroup-headers))))
2926 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2927 ;; Call hooks for modifying summary buffer.
2928 (goto-char (point-min))
2929 (gnus-run-hooks 'gnus-summary-prepare-hook)))
2931 (defsubst gnus-general-simplify-subject (subject)
2932 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2935 ;; Truncate the subject.
2936 (gnus-simplify-subject-functions
2937 (gnus-map-function gnus-simplify-subject-functions subject))
2938 ((numberp gnus-summary-gather-subject-limit)
2939 (setq subject (gnus-simplify-subject-re subject))
2940 (if (> (length subject) gnus-summary-gather-subject-limit)
2941 (substring subject 0 gnus-summary-gather-subject-limit)
2943 ;; Fuzzily simplify it.
2944 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2945 (gnus-simplify-subject-fuzzy subject))
2946 ;; Just remove the leading "Re:".
2948 (gnus-simplify-subject-re subject))))
2950 (if (and gnus-summary-gather-exclude-subject
2951 (string-match gnus-summary-gather-exclude-subject subject))
2952 nil ; This article shouldn't be gathered
2955 (defun gnus-summary-simplify-subject-query ()
2956 "Query where the respool algorithm would put this article."
2958 (gnus-summary-select-article)
2959 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2961 (defun gnus-gather-threads-by-subject (threads)
2962 "Gather threads by looking at Subject headers."
2963 (if (not gnus-summary-make-false-root)
2965 (let ((hashtb (gnus-make-hashtable 1024))
2968 subject hthread whole-subject)
2970 (setq subject (gnus-general-simplify-subject
2971 (setq whole-subject (mail-header-subject
2974 (if (setq hthread (gnus-gethash subject hashtb))
2976 ;; We enter a dummy root into the thread, if we
2977 ;; haven't done that already.
2978 (unless (stringp (caar hthread))
2979 (setcar hthread (list whole-subject (car hthread))))
2980 ;; We add this new gathered thread to this gathered
2982 (setcdr (car hthread)
2983 (nconc (cdar hthread) (list (car threads))))
2984 ;; Remove it from the list of threads.
2985 (setcdr prev (cdr threads))
2986 (setq threads prev))
2987 ;; Enter this thread into the hash table.
2988 (gnus-sethash subject threads hashtb)))
2990 (setq threads (cdr threads)))
2993 (defun gnus-gather-threads-by-references (threads)
2994 "Gather threads by looking at References headers."
2995 (let ((idhashtb (gnus-make-hashtable 1024))
2996 (thhashtb (gnus-make-hashtable 1024))
2999 ids references id gthread gid entered ref)
3001 (when (setq references (mail-header-references (caar threads)))
3002 (setq id (mail-header-id (caar threads))
3003 ids (gnus-split-references references)
3005 (while (setq ref (pop ids))
3006 (setq ids (delete ref ids))
3007 (if (not (setq gid (gnus-gethash ref idhashtb)))
3009 (gnus-sethash ref id idhashtb)
3010 (gnus-sethash id threads thhashtb))
3011 (setq gthread (gnus-gethash gid thhashtb))
3013 ;; We enter a dummy root into the thread, if we
3014 ;; haven't done that already.
3015 (unless (stringp (caar gthread))
3016 (setcar gthread (list (mail-header-subject (caar gthread))
3018 ;; We add this new gathered thread to this gathered
3020 (setcdr (car gthread)
3021 (nconc (cdar gthread) (list (car threads)))))
3022 ;; Add it into the thread hash table.
3023 (gnus-sethash id gthread thhashtb)
3025 ;; Remove it from the list of threads.
3026 (setcdr prev (cdr threads))
3027 (setq threads prev))))
3029 (setq threads (cdr threads)))
3032 (defun gnus-sort-gathered-threads (threads)
3033 "Sort subtreads inside each gathered thread by article number."
3034 (let ((result threads))
3036 (when (stringp (caar threads))
3037 (setcdr (car threads)
3038 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3039 (setq threads (cdr threads)))
3042 (defun gnus-thread-loop-p (root thread)
3043 "Say whether ROOT is in THREAD."
3044 (let ((stack (list thread))
3047 (while (setq thread (pop stack))
3048 (setq th (cdr thread))
3050 (not (eq (caar th) root)))
3053 ;; We have found a loop.
3055 (setcdr thread (delq (car th) (cdr thread)))
3056 (if (boundp (setq ref-dep (intern "none"
3057 gnus-newsgroup-dependencies)))
3058 (setcdr (symbol-value ref-dep)
3059 (nconc (cdr (symbol-value ref-dep))
3061 (set ref-dep (list nil (car th))))
3064 ;; Push all the subthreads onto the stack.
3065 (push (cdr thread) stack)))
3068 (defun gnus-make-threads ()
3069 "Go through the dependency hashtb and find the roots. Return all threads."
3071 (while (catch 'infloop
3074 ;; Deal with self-referencing References loops.
3075 (when (and (car (symbol-value refs))
3082 (car (symbol-value refs)) thread))
3083 (cdr (symbol-value refs)))))))
3086 (unless (car (symbol-value refs))
3087 ;; These threads do not refer back to any other articles,
3088 ;; so they're roots.
3089 (setq threads (append (cdr (symbol-value refs)) threads))))
3090 gnus-newsgroup-dependencies)))
3093 ;; Build the thread tree.
3094 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3095 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3097 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3098 if it was already present.
3100 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3101 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3102 Message-IDs will be renamed be renamed to a unique Message-ID before
3105 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3106 (let* ((id (mail-header-id header))
3107 (id-dep (and id (intern id dependencies)))
3108 ref ref-dep ref-header)
3109 ;; Enter this `header' in the `dependencies' table.
3113 ;; The first two cases do the normal part: enter a new `header'
3114 ;; in the `dependencies' table.
3115 ((not (boundp id-dep))
3116 (set id-dep (list header)))
3117 ((null (car (symbol-value id-dep)))
3118 (setcar (symbol-value id-dep) header))
3120 ;; From here the `header' was already present in the
3121 ;; `dependencies' table.
3123 ;; Overrides an existing entry;
3124 ;; just set the header part of the entry.
3125 (setcar (symbol-value id-dep) header))
3127 ;; Renames the existing `header' to a unique Message-ID.
3128 ((not gnus-summary-ignore-duplicates)
3129 ;; An article with this Message-ID has already been seen.
3130 ;; We rename the Message-ID.
3131 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3133 (mail-header-set-id header id))
3135 ;; The last case ignores an existing entry, except it adds any
3136 ;; additional Xrefs (in case the two articles came from different
3138 ;; Also sets `header' to `nil' meaning that the `dependencies'
3139 ;; table was *not* modified.
3141 (mail-header-set-xref
3142 (car (symbol-value id-dep))
3143 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3145 (or (mail-header-xref header) "")))
3149 ;; First check if that we are not creating a References loop.
3150 (setq ref (gnus-parent-id (mail-header-references header)))
3152 (setq ref-dep (intern-soft ref dependencies))
3154 (setq ref-header (car (symbol-value ref-dep))))
3155 (if (string= id ref)
3156 ;; Yuk! This is a reference loop. Make the article be a
3159 (mail-header-set-references (car (symbol-value id-dep)) "none")
3161 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3162 (setq ref (gnus-parent-id (mail-header-references header)))
3163 (setq ref-dep (intern (or ref "none") dependencies))
3164 (if (boundp ref-dep)
3165 (setcdr (symbol-value ref-dep)
3166 (nconc (cdr (symbol-value ref-dep))
3167 (list (symbol-value id-dep))))
3168 (set ref-dep (list nil (symbol-value id-dep)))))
3171 (defun gnus-build-sparse-threads ()
3172 (let ((headers gnus-newsgroup-headers)
3173 (mail-parse-charset gnus-newsgroup-charset)
3174 (gnus-summary-ignore-duplicates t)
3175 header references generation relations
3176 subject child end new-child date)
3177 ;; First we create an alist of generations/relations, where
3178 ;; generations is how much we trust the relation, and the relation
3180 (gnus-message 7 "Making sparse threads...")
3182 (nnheader-set-temp-buffer " *gnus sparse threads*")
3183 (while (setq header (pop headers))
3184 (when (and (setq references (mail-header-references header))
3185 (not (string= references "")))
3187 (setq child (mail-header-id header)
3188 subject (mail-header-subject header)
3189 date (mail-header-date header)
3191 (while (search-backward ">" nil t)
3192 (setq end (1+ (point)))
3193 (when (search-backward "<" nil t)
3194 (setq new-child (buffer-substring (point) end))
3195 (push (list (incf generation)
3196 child (setq child new-child)
3200 (push (list (1+ generation) child nil subject) relations))
3202 (kill-buffer (current-buffer)))
3203 ;; Sort over trustworthiness.
3206 (when (gnus-dependencies-add-header
3207 (make-full-mail-header
3208 gnus-reffed-article-number
3209 (nth 3 relation) "" (or (nth 4 relation) "")
3211 (or (nth 2 relation) "") 0 0 "")
3212 gnus-newsgroup-dependencies nil)
3213 (push gnus-reffed-article-number gnus-newsgroup-limit)
3214 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3215 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3216 gnus-newsgroup-reads)
3217 (decf gnus-reffed-article-number)))
3218 (sort relations 'car-less-than-car))
3219 (gnus-message 7 "Making sparse threads...done")))
3221 (defun gnus-build-old-threads ()
3222 ;; Look at all the articles that refer back to old articles, and
3223 ;; fetch the headers for the articles that aren't there. This will
3224 ;; build complete threads - if the roots haven't been expired by the
3226 (let ((mail-parse-charset gnus-newsgroup-charset)
3230 (when (not (car (symbol-value refs)))
3231 (setq heads (cdr (symbol-value refs)))
3233 (if (memq (mail-header-number (caar heads))
3234 gnus-newsgroup-dormant)
3235 (setq heads (cdr heads))
3236 (setq id (symbol-name refs))
3237 (while (and (setq id (gnus-build-get-header id))
3238 (not (car (gnus-id-to-thread id)))))
3239 (setq heads nil)))))
3240 gnus-newsgroup-dependencies)))
3242 ;; This function has to be called with point after the article number
3243 ;; on the beginning of the line.
3244 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3245 (let ((eol (gnus-point-at-eol))
3246 (buffer (current-buffer))
3249 ;; overview: [num subject from date id refs chars lines misc]
3252 (narrow-to-region (point) eol)
3257 (make-full-mail-header
3259 (funcall gnus-decode-encoded-word-function
3260 (nnheader-nov-field)) ; subject
3261 (funcall gnus-decode-encoded-word-function
3262 (nnheader-nov-field)) ; from
3263 (nnheader-nov-field) ; date
3264 (nnheader-nov-read-message-id) ; id
3265 (nnheader-nov-field) ; refs
3266 (nnheader-nov-read-integer) ; chars
3267 (nnheader-nov-read-integer) ; lines
3269 (nnheader-nov-field)) ; misc
3270 (nnheader-nov-parse-extra)))) ; extra
3274 (when gnus-alter-header-function
3275 (funcall gnus-alter-header-function header))
3276 (gnus-dependencies-add-header header dependencies force-new)))
3278 (defun gnus-build-get-header (id)
3279 ;; Look through the buffer of NOV lines and find the header to
3280 ;; ID. Enter this line into the dependencies hash table, and return
3281 ;; the id of the parent article (if any).
3282 (let ((deps gnus-newsgroup-dependencies)
3286 (set-buffer nntp-server-buffer)
3287 (let ((case-fold-search nil))
3288 (goto-char (point-min))
3289 (while (and (not found)
3290 (search-forward id nil t))
3292 (setq found (looking-at
3293 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3294 (regexp-quote id))))
3295 (or found (beginning-of-line 2)))
3299 (setq header (gnus-nov-parse-line
3300 (read (current-buffer)) deps))
3301 (gnus-parent-id (mail-header-references header))))))
3303 (let ((number (mail-header-number header)))
3304 (push number gnus-newsgroup-limit)
3305 (push header gnus-newsgroup-headers)
3306 (if (memq number gnus-newsgroup-unselected)
3308 (push number gnus-newsgroup-unreads)
3309 (setq gnus-newsgroup-unselected
3310 (delq number gnus-newsgroup-unselected)))
3311 (push number gnus-newsgroup-ancient)))))))
3313 (defun gnus-build-all-threads ()
3314 "Read all the headers."
3315 (let ((gnus-summary-ignore-duplicates t)
3316 (mail-parse-charset gnus-newsgroup-charset)
3317 (dependencies gnus-newsgroup-dependencies)
3320 (set-buffer nntp-server-buffer)
3321 (let ((case-fold-search nil))
3322 (goto-char (point-min))
3325 (setq article (read (current-buffer))
3326 header (gnus-nov-parse-line article dependencies)))
3329 (set-buffer gnus-summary-buffer)
3330 (push header gnus-newsgroup-headers)
3331 (if (memq (setq article (mail-header-number header))
3332 gnus-newsgroup-unselected)
3334 (push article gnus-newsgroup-unreads)
3335 (setq gnus-newsgroup-unselected
3336 (delq article gnus-newsgroup-unselected)))
3337 (push article gnus-newsgroup-ancient)))
3338 (forward-line 1)))))))
3340 (defun gnus-summary-update-article-line (article header)
3341 "Update the line for ARTICLE using HEADERS."
3342 (let* ((id (mail-header-id header))
3343 (thread (gnus-id-to-thread id)))
3345 (error "Article in no thread"))
3346 ;; Update the thread.
3347 (setcar thread header)
3348 (gnus-summary-goto-subject article)
3349 (let* ((datal (gnus-data-find-list article))
3351 (length (when (cdr datal)
3352 (- (gnus-data-pos data)
3353 (gnus-data-pos (cadr datal)))))
3354 (buffer-read-only nil)
3355 (level (gnus-summary-thread-level)))
3357 (gnus-summary-insert-line
3358 header level nil (gnus-article-mark article)
3359 (memq article gnus-newsgroup-replied)
3360 (memq article gnus-newsgroup-expirable)
3361 ;; Only insert the Subject string when it's different
3362 ;; from the previous Subject string.
3363 (if (gnus-subject-equal
3365 (mail-header-subject
3368 (gnus-data-find-list
3370 (gnus-data-list t)))))
3371 ;; Error on the side of excessive subjects.
3373 (mail-header-subject header))
3375 (mail-header-subject header))
3376 nil (cdr (assq article gnus-newsgroup-scored))
3377 (memq article gnus-newsgroup-processable))
3379 (gnus-data-update-list
3380 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3382 (defun gnus-summary-update-article (article &optional iheader)
3383 "Update ARTICLE in the summary buffer."
3384 (set-buffer gnus-summary-buffer)
3385 (let* ((header (gnus-summary-article-header article))
3386 (id (mail-header-id header))
3387 (data (gnus-data-find article))
3388 (thread (gnus-id-to-thread id))
3389 (references (mail-header-references header))
3393 (when (and references
3394 (not (equal "" references)))
3397 (buffer-read-only nil)
3403 (delq thread parent)))
3404 (if (gnus-summary-insert-subject id header)
3405 ;; Set the (possibly) new article number in the data structure.
3406 (gnus-data-set-number data (gnus-id-to-article id))
3410 (defun gnus-rebuild-thread (id &optional line)
3411 "Rebuild the thread containing ID.
3412 If LINE, insert the rebuilt thread starting on line LINE."
3413 (let ((buffer-read-only nil)
3414 old-pos current thread data)
3415 (if (not gnus-show-threads)
3416 (setq thread (list (car (gnus-id-to-thread id))))
3417 ;; Get the thread this article is part of.
3418 (setq thread (gnus-remove-thread id)))
3419 (setq old-pos (gnus-point-at-bol))
3420 (setq current (save-excursion
3421 (and (zerop (forward-line -1))
3422 (gnus-summary-article-number))))
3423 ;; If this is a gathered thread, we have to go some re-gathering.
3424 (when (stringp (car thread))
3425 (let ((subject (car thread))
3427 (setq thread (cdr thread))
3429 (unless (memq (setq thr (gnus-id-to-thread
3431 (mail-header-id (caar thread)))))
3434 (setq thread (cdr thread)))
3435 ;; We now have all (unique) roots.
3436 (if (= (length roots) 1)
3437 ;; All the loose roots are now one solid root.
3438 (setq thread (car roots))
3439 (setq thread (cons subject (gnus-sort-threads roots))))))
3441 ;; We then insert this thread into the summary buffer.
3443 (goto-char (point-min))
3444 (forward-line (1- line)))
3445 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3446 (if gnus-show-threads
3447 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3448 (gnus-summary-prepare-unthreaded thread))
3449 (setq data (nreverse gnus-newsgroup-data))
3450 (setq threads gnus-newsgroup-threads))
3451 ;; We splice the new data into the data structure.
3452 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3453 ;;!!! then we want to insert at the beginning of the buffer.
3454 ;;!!! That happens to be true with Gnus now, but that may
3455 ;;!!! change in the future. Perhaps.
3456 (gnus-data-enter-list
3457 (if line nil current) data (- (point) old-pos))
3458 (setq gnus-newsgroup-threads
3459 (nconc threads gnus-newsgroup-threads))
3460 (gnus-data-compute-positions))))
3462 (defun gnus-number-to-header (number)
3463 "Return the header for article NUMBER."
3464 (let ((headers gnus-newsgroup-headers))
3466 (not (= number (mail-header-number (car headers)))))
3471 (defun gnus-parent-headers (in-headers &optional generation)
3472 "Return the headers of the GENERATIONeth parent of HEADERS."
3474 (setq generation 1))
3476 (headers in-headers)
3479 (not (zerop generation))
3480 (setq references (mail-header-references headers)))
3481 (setq headers (if (and references
3482 (setq parent (gnus-parent-id references)))
3483 (car (gnus-id-to-thread parent))
3486 (and (not (eq headers in-headers))
3489 (defun gnus-id-to-thread (id)
3490 "Return the (sub-)thread where ID appears."
3491 (gnus-gethash id gnus-newsgroup-dependencies))
3493 (defun gnus-id-to-article (id)
3494 "Return the article number of ID."
3495 (let ((thread (gnus-id-to-thread id)))
3498 (mail-header-number (car thread)))))
3500 (defun gnus-id-to-header (id)
3501 "Return the article headers of ID."
3502 (car (gnus-id-to-thread id)))
3504 (defun gnus-article-displayed-root-p (article)
3505 "Say whether ARTICLE is a root(ish) article."
3506 (let ((level (gnus-summary-thread-level article))
3507 (refs (mail-header-references (gnus-summary-article-header article)))
3513 ((null (gnus-parent-id refs)) t)
3515 (null (setq particle (gnus-id-to-article
3516 (gnus-parent-id refs))))
3517 (null (gnus-summary-thread-level particle)))))))
3519 (defun gnus-root-id (id)
3520 "Return the id of the root of the thread where ID appears."
3522 (while (and id (setq prev (car (gnus-id-to-thread id))))
3524 id (gnus-parent-id (mail-header-references prev))))
3527 (defun gnus-articles-in-thread (thread)
3528 "Return the list of articles in THREAD."
3529 (cons (mail-header-number (car thread))
3530 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3532 (defun gnus-remove-thread (id &optional dont-remove)
3533 "Remove the thread that has ID in it."
3534 (let (headers thread last-id)
3535 ;; First go up in this thread until we find the root.
3536 (setq last-id (gnus-root-id id)
3537 headers (message-flatten-list (gnus-id-to-thread last-id)))
3538 ;; We have now found the real root of this thread. It might have
3539 ;; been gathered into some loose thread, so we have to search
3540 ;; through the threads to find the thread we wanted.
3541 (let ((threads gnus-newsgroup-threads)
3544 (setq sub (car threads))
3545 (if (stringp (car sub))
3546 ;; This is a gathered thread, so we look at the roots
3547 ;; below it to find whether this article is in this
3550 (setq sub (cdr sub))
3552 (when (member (caar sub) headers)
3553 (setq thread (car threads)
3556 (setq sub (cdr sub))))
3557 ;; It's an ordinary thread, so we check it.
3558 (when (eq (car sub) (car headers))
3561 (setq threads (cdr threads)))
3562 ;; If this article is in no thread, then it's a root.
3565 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3566 (setq thread (gnus-id-to-thread last-id)))
3569 thread ; We return this thread.
3571 (if (stringp (car thread))
3573 ;; If we use dummy roots, then we have to remove the
3574 ;; dummy root as well.
3575 (when (eq gnus-summary-make-false-root 'dummy)
3576 ;; We go to the dummy root by going to
3577 ;; the first sub-"thread", and then one line up.
3578 (gnus-summary-goto-article
3579 (mail-header-number (caadr thread)))
3582 (gnus-data-compute-positions))
3583 (setq thread (cdr thread))
3585 (gnus-remove-thread-1 (car thread))
3586 (setq thread (cdr thread))))
3587 (gnus-summary-show-all-threads)
3588 (gnus-remove-thread-1 thread))))))))
3590 (defun gnus-remove-thread-1 (thread)
3591 "Remove the thread THREAD recursively."
3592 (let ((number (mail-header-number (pop thread)))
3594 (setq thread (reverse thread))
3596 (gnus-remove-thread-1 (pop thread)))
3597 (when (setq d (gnus-data-find number))
3598 (goto-char (gnus-data-pos d))
3601 (- (gnus-point-at-bol)
3603 (1+ (gnus-point-at-eol))
3604 (gnus-delete-line)))))))
3606 (defun gnus-sort-threads (threads)
3608 (if (not gnus-thread-sort-functions)
3610 (gnus-message 8 "Sorting threads...")
3612 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3613 (gnus-message 8 "Sorting threads...done"))))
3615 (defun gnus-sort-articles (articles)
3617 (when gnus-article-sort-functions
3618 (gnus-message 7 "Sorting articles...")
3620 (setq gnus-newsgroup-headers
3621 (sort articles (gnus-make-sort-function
3622 gnus-article-sort-functions)))
3623 (gnus-message 7 "Sorting articles...done"))))
3625 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3626 (defmacro gnus-thread-header (thread)
3627 ;; Return header of first article in THREAD.
3628 ;; Note that THREAD must never, ever be anything else than a variable -
3629 ;; using some other form will lead to serious barfage.
3630 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3631 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3632 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
3635 (defsubst gnus-article-sort-by-number (h1 h2)
3636 "Sort articles by article number."
3637 (< (mail-header-number h1)
3638 (mail-header-number h2)))
3640 (defun gnus-thread-sort-by-number (h1 h2)
3641 "Sort threads by root article number."
3642 (gnus-article-sort-by-number
3643 (gnus-thread-header h1) (gnus-thread-header h2)))
3645 (defsubst gnus-article-sort-by-lines (h1 h2)
3646 "Sort articles by article Lines header."
3647 (< (mail-header-lines h1)
3648 (mail-header-lines h2)))
3650 (defun gnus-thread-sort-by-lines (h1 h2)
3651 "Sort threads by root article Lines header."
3652 (gnus-article-sort-by-lines
3653 (gnus-thread-header h1) (gnus-thread-header h2)))
3655 (defsubst gnus-article-sort-by-chars (h1 h2)
3656 "Sort articles by octet length."
3657 (< (mail-header-chars h1)
3658 (mail-header-chars h2)))
3660 (defun gnus-thread-sort-by-chars (h1 h2)
3661 "Sort threads by root article octet length."
3662 (gnus-article-sort-by-chars
3663 (gnus-thread-header h1) (gnus-thread-header h2)))
3665 (defsubst gnus-article-sort-by-author (h1 h2)
3666 "Sort articles by root author."
3668 (let ((extract (funcall
3669 gnus-extract-address-components
3670 (mail-header-from h1))))
3671 (or (car extract) (cadr extract) ""))
3672 (let ((extract (funcall
3673 gnus-extract-address-components
3674 (mail-header-from h2))))
3675 (or (car extract) (cadr extract) ""))))
3677 (defun gnus-thread-sort-by-author (h1 h2)
3678 "Sort threads by root author."
3679 (gnus-article-sort-by-author
3680 (gnus-thread-header h1) (gnus-thread-header h2)))
3682 (defsubst gnus-article-sort-by-subject (h1 h2)
3683 "Sort articles by root subject."
3685 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3686 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3688 (defun gnus-thread-sort-by-subject (h1 h2)
3689 "Sort threads by root subject."
3690 (gnus-article-sort-by-subject
3691 (gnus-thread-header h1) (gnus-thread-header h2)))
3693 (defsubst gnus-article-sort-by-date (h1 h2)
3694 "Sort articles by root article date."
3696 (gnus-date-get-time (mail-header-date h1))
3697 (gnus-date-get-time (mail-header-date h2))))
3699 (defun gnus-thread-sort-by-date (h1 h2)
3700 "Sort threads by root article date."
3701 (gnus-article-sort-by-date
3702 (gnus-thread-header h1) (gnus-thread-header h2)))
3704 (defsubst gnus-article-sort-by-score (h1 h2)
3705 "Sort articles by root article score.
3706 Unscored articles will be counted as having a score of zero."
3707 (> (or (cdr (assq (mail-header-number h1)
3708 gnus-newsgroup-scored))
3709 gnus-summary-default-score 0)
3710 (or (cdr (assq (mail-header-number h2)
3711 gnus-newsgroup-scored))
3712 gnus-summary-default-score 0)))
3714 (defun gnus-thread-sort-by-score (h1 h2)
3715 "Sort threads by root article score."
3716 (gnus-article-sort-by-score
3717 (gnus-thread-header h1) (gnus-thread-header h2)))
3719 (defun gnus-thread-sort-by-total-score (h1 h2)
3720 "Sort threads by the sum of all scores in the thread.
3721 Unscored articles will be counted as having a score of zero."
3722 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3724 (defun gnus-thread-total-score (thread)
3725 ;; This function find the total score of THREAD.
3726 (cond ((null thread)
3729 (if (stringp (car thread))
3730 (apply gnus-thread-score-function 0
3731 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3732 (gnus-thread-total-score-1 thread)))
3734 (gnus-thread-total-score-1 (list thread)))))
3736 (defun gnus-thread-total-score-1 (root)
3737 ;; This function find the total score of the thread below ROOT.
3738 (setq root (car root))
3739 (apply gnus-thread-score-function
3741 (mapcar 'gnus-thread-total-score
3742 (cdr (gnus-id-to-thread (mail-header-id root))))
3743 (when (> (mail-header-number root) 0)
3744 (list (or (cdr (assq (mail-header-number root)
3745 gnus-newsgroup-scored))
3746 gnus-summary-default-score 0))))
3747 (list gnus-summary-default-score)
3750 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3751 (defvar gnus-tmp-prev-subject nil)
3752 (defvar gnus-tmp-false-parent nil)
3753 (defvar gnus-tmp-root-expunged nil)
3754 (defvar gnus-tmp-dummy-line nil)
3756 (defvar gnus-tmp-header)
3757 (defun gnus-extra-header (type &optional header)
3758 "Return the extra header of TYPE."
3759 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
3762 (defun gnus-summary-prepare-threads (threads)
3763 "Prepare summary buffer from THREADS and indentation LEVEL.
3764 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3765 or a straight list of headers."
3766 (gnus-message 7 "Generating summary...")
3768 (setq gnus-newsgroup-threads threads)
3771 (let ((gnus-tmp-level 0)
3772 (default-score (or gnus-summary-default-score 0))
3773 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3774 thread number subject stack state gnus-tmp-gathered beg-match
3775 new-roots gnus-tmp-new-adopts thread-end
3776 gnus-tmp-header gnus-tmp-unread
3777 gnus-tmp-replied gnus-tmp-subject-or-nil
3778 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3779 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3780 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3782 (setq gnus-tmp-prev-subject nil)
3784 (if (vectorp (car threads))
3785 ;; If this is a straight (sic) list of headers, then a
3786 ;; threaded summary display isn't required, so we just create
3787 ;; an unthreaded one.
3788 (gnus-summary-prepare-unthreaded threads)
3790 ;; Do the threaded display.
3792 (while (or threads stack gnus-tmp-new-adopts new-roots)
3794 (if (and (= gnus-tmp-level 0)
3797 (not gnus-tmp-false-parent)
3798 (or gnus-tmp-new-adopts new-roots))
3799 (if gnus-tmp-new-adopts
3800 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3801 thread (list (car gnus-tmp-new-adopts))
3802 gnus-tmp-header (caar thread)
3803 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3805 (setq thread (list (car new-roots))
3806 gnus-tmp-header (caar thread)
3807 new-roots (cdr new-roots))))
3810 ;; If there are some threads, we do them before the
3811 ;; threads on the stack.
3812 (setq thread threads
3813 gnus-tmp-header (caar thread))
3814 ;; There were no current threads, so we pop something off
3816 (setq state (car stack)
3817 gnus-tmp-level (car state)
3820 gnus-tmp-header (caar thread))))
3822 (setq gnus-tmp-false-parent nil)
3823 (setq gnus-tmp-root-expunged nil)
3824 (setq thread-end nil)
3826 (if (stringp gnus-tmp-header)
3827 ;; The header is a dummy root.
3829 ((eq gnus-summary-make-false-root 'adopt)
3830 ;; We let the first article adopt the rest.
3831 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3833 (setq gnus-tmp-gathered
3835 (lambda (h) (mail-header-number (car h)))
3838 (setq thread (cons (list (caar thread)
3841 (setq gnus-tmp-level -1
3842 gnus-tmp-false-parent t))
3843 ((eq gnus-summary-make-false-root 'empty)
3844 ;; We print adopted articles with empty subject fields.
3845 (setq gnus-tmp-gathered
3847 (lambda (h) (mail-header-number (car h)))
3850 (setq gnus-tmp-level -1))
3851 ((eq gnus-summary-make-false-root 'dummy)
3852 ;; We remember that we probably want to output a dummy
3854 (setq gnus-tmp-dummy-line gnus-tmp-header)
3855 (setq gnus-tmp-prev-subject gnus-tmp-header))
3857 ;; We do not make a root for the gathered
3858 ;; sub-threads at all.
3859 (setq gnus-tmp-level -1)))
3861 (setq number (mail-header-number gnus-tmp-header)
3862 subject (mail-header-subject gnus-tmp-header))
3865 ;; If the thread has changed subject, we might want to make
3866 ;; this subthread into a root.
3867 ((and (null gnus-thread-ignore-subject)
3868 (not (zerop gnus-tmp-level))
3869 gnus-tmp-prev-subject
3871 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3872 (setq new-roots (nconc new-roots (list (car thread)))
3874 gnus-tmp-header nil))
3875 ;; If the article lies outside the current limit,
3876 ;; then we do not display it.
3877 ((not (memq number gnus-newsgroup-limit))
3878 (setq gnus-tmp-gathered
3880 (lambda (h) (mail-header-number (car h)))
3883 (setq gnus-tmp-new-adopts (if (cdar thread)
3884 (append gnus-tmp-new-adopts
3886 gnus-tmp-new-adopts)
3888 gnus-tmp-header nil)
3889 (when (zerop gnus-tmp-level)
3890 (setq gnus-tmp-root-expunged t)))
3891 ;; Perhaps this article is to be marked as read?
3892 ((and gnus-summary-mark-below
3893 (< (or (cdr (assq number gnus-newsgroup-scored))
3895 gnus-summary-mark-below)
3896 ;; Don't touch sparse articles.
3897 (not (gnus-summary-article-sparse-p number))
3898 (not (gnus-summary-article-ancient-p number)))
3899 (setq gnus-newsgroup-unreads
3900 (delq number gnus-newsgroup-unreads))
3901 (if gnus-newsgroup-auto-expire
3902 (push number gnus-newsgroup-expirable)
3903 (push (cons number gnus-low-score-mark)
3904 gnus-newsgroup-reads))))
3906 (when gnus-tmp-header
3907 ;; We may have an old dummy line to output before this
3909 (when (and gnus-tmp-dummy-line
3912 (mail-header-subject gnus-tmp-header)))
3913 (gnus-summary-insert-dummy-line
3914 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3915 (setq gnus-tmp-dummy-line nil))
3917 ;; Compute the mark.
3918 (setq gnus-tmp-unread (gnus-article-mark number))
3920 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3921 gnus-tmp-header gnus-tmp-level)
3922 gnus-newsgroup-data)
3924 ;; Actually insert the line.
3926 gnus-tmp-subject-or-nil
3928 ((and gnus-thread-ignore-subject
3929 gnus-tmp-prev-subject
3930 (not (inline (gnus-subject-equal
3931 gnus-tmp-prev-subject subject))))
3933 ((zerop gnus-tmp-level)
3934 (if (and (eq gnus-summary-make-false-root 'empty)
3935 (memq number gnus-tmp-gathered)
3936 gnus-tmp-prev-subject
3937 (inline (gnus-subject-equal
3938 gnus-tmp-prev-subject subject)))
3939 gnus-summary-same-subject
3941 (t gnus-summary-same-subject)))
3942 (if (and (eq gnus-summary-make-false-root 'adopt)
3943 (= gnus-tmp-level 1)
3944 (memq number gnus-tmp-gathered))
3945 (setq gnus-tmp-opening-bracket ?\<
3946 gnus-tmp-closing-bracket ?\>)
3947 (setq gnus-tmp-opening-bracket ?\[
3948 gnus-tmp-closing-bracket ?\]))
3950 gnus-tmp-indentation
3951 (aref gnus-thread-indent-array gnus-tmp-level)
3952 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3953 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3954 gnus-summary-default-score 0)
3956 (if (or (null gnus-summary-default-score)
3957 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3958 gnus-summary-zcore-fuzz))
3960 (if (< gnus-tmp-score gnus-summary-default-score)
3961 gnus-score-below-mark gnus-score-over-mark))
3963 (cond ((memq number gnus-newsgroup-processable)
3965 ((memq number gnus-newsgroup-cached)
3967 ((memq number gnus-newsgroup-replied)
3969 ((memq number gnus-newsgroup-saved)
3971 (t gnus-unread-mark))
3972 gnus-tmp-from (mail-header-from gnus-tmp-header)
3975 ((string-match "<[^>]+> *$" gnus-tmp-from)
3976 (setq beg-match (match-beginning 0))
3977 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3978 (substring gnus-tmp-from (1+ (match-beginning 0))
3979 (1- (match-end 0))))
3980 (substring gnus-tmp-from 0 beg-match)))
3981 ((string-match "(.+)" gnus-tmp-from)
3982 (substring gnus-tmp-from
3983 (1+ (match-beginning 0)) (1- (match-end 0))))
3985 (when (string= gnus-tmp-name "")
3986 (setq gnus-tmp-name gnus-tmp-from))
3987 (unless (numberp gnus-tmp-lines)
3988 (setq gnus-tmp-lines 0))
3989 (gnus-put-text-property
3991 (progn (eval gnus-summary-line-format-spec) (point))
3992 'gnus-number number)
3995 (gnus-run-hooks 'gnus-summary-update-hook)
3998 (setq gnus-tmp-prev-subject subject)))
4000 (when (nth 1 thread)
4001 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
4002 (incf gnus-tmp-level)
4003 (setq threads (if thread-end nil (cdar thread)))
4005 (setq gnus-tmp-level 0)))))
4006 (gnus-message 7 "Generating summary...done"))
4008 (defun gnus-summary-prepare-unthreaded (headers)
4009 "Generate an unthreaded summary buffer based on HEADERS."
4010 (let (header number mark)
4015 ;; We may have to root out some bad articles...
4016 (when (memq (setq number (mail-header-number
4017 (setq header (pop headers))))
4018 gnus-newsgroup-limit)
4019 ;; Mark article as read when it has a low score.
4020 (when (and gnus-summary-mark-below
4021 (< (or (cdr (assq number gnus-newsgroup-scored))
4022 gnus-summary-default-score 0)
4023 gnus-summary-mark-below)
4024 (not (gnus-summary-article-ancient-p number)))
4025 (setq gnus-newsgroup-unreads
4026 (delq number gnus-newsgroup-unreads))
4027 (if gnus-newsgroup-auto-expire
4028 (push number gnus-newsgroup-expirable)
4029 (push (cons number gnus-low-score-mark)
4030 gnus-newsgroup-reads)))
4032 (setq mark (gnus-article-mark number))
4033 (push (gnus-data-make number mark (1+ (point)) header 0)
4034 gnus-newsgroup-data)
4035 (gnus-summary-insert-line
4037 mark (memq number gnus-newsgroup-replied)
4038 (memq number gnus-newsgroup-expirable)
4039 (mail-header-subject header) nil
4040 (cdr (assq number gnus-newsgroup-scored))
4041 (memq number gnus-newsgroup-processable))))))
4043 (defun gnus-summary-remove-list-identifiers ()
4044 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4045 (let ((regexp (if (stringp gnus-list-identifiers)
4046 gnus-list-identifiers
4047 (mapconcat 'identity gnus-list-identifiers " *\\|"))))
4048 (dolist (header gnus-newsgroup-headers)
4049 (when (string-match (concat "\\(Re: +\\)?\\(" regexp " *\\)")
4050 (mail-header-subject header))
4051 (mail-header-set-subject
4052 header (concat (substring (mail-header-subject header)
4053 0 (match-beginning 2))
4054 (substring (mail-header-subject header)
4055 (match-end 2))))))))
4057 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4058 "Select newsgroup GROUP.
4059 If READ-ALL is non-nil, all articles in the group are selected.
4060 If SELECT-ARTICLES, only select those articles from GROUP."
4061 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4062 ;;!!! Dirty hack; should be removed.
4063 (gnus-summary-ignore-duplicates
4064 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4066 gnus-summary-ignore-duplicates))
4067 (info (nth 2 entry))
4068 articles fetched-articles cached)
4070 (unless (gnus-check-server
4071 (setq gnus-current-select-method
4072 (gnus-find-method-for-group group)))
4073 (error "Couldn't open server"))
4075 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4076 (gnus-activate-group group) ; Or we can activate it...
4077 (progn ; Or we bug out.
4078 (when (equal major-mode 'gnus-summary-mode)
4079 (kill-buffer (current-buffer)))
4080 (error "Couldn't request group %s: %s"
4081 group (gnus-status-message group))))
4083 (unless (gnus-request-group group t)
4084 (when (equal major-mode 'gnus-summary-mode)
4085 (kill-buffer (current-buffer)))
4086 (error "Couldn't request group %s: %s"
4087 group (gnus-status-message group)))
4089 (setq gnus-newsgroup-name group)
4090 (setq gnus-newsgroup-unselected nil)
4091 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4092 (gnus-summary-setup-default-charset)
4094 ;; Adjust and set lists of article marks.
4096 (gnus-adjust-marked-articles info))
4098 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4099 (when (gnus-virtual-group-p group)
4100 (setq cached gnus-newsgroup-cached))
4102 (setq gnus-newsgroup-unreads
4103 (gnus-set-difference
4104 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4105 gnus-newsgroup-dormant))
4107 (setq gnus-newsgroup-processable nil)
4109 (gnus-update-read-articles group gnus-newsgroup-unreads)
4111 (if (setq articles select-articles)
4112 (setq gnus-newsgroup-unselected
4113 (gnus-sorted-intersection
4114 gnus-newsgroup-unreads
4115 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4116 (setq articles (gnus-articles-to-read group read-all)))
4120 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4122 ((eq articles 0) nil)
4124 ;; Init the dependencies hash table.
4125 (setq gnus-newsgroup-dependencies
4126 (gnus-make-hashtable (length articles)))
4127 (gnus-set-global-variables)
4128 ;; Retrieve the headers and read them in.
4129 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
4130 (setq gnus-newsgroup-headers
4132 (setq gnus-headers-retrieved-by
4133 (gnus-retrieve-headers
4134 articles gnus-newsgroup-name
4135 ;; We might want to fetch old headers, but
4136 ;; not if there is only 1 article.
4138 (not (eq gnus-fetch-old-headers 'some))
4139 (not (numberp gnus-fetch-old-headers)))
4140 (> (length articles) 1))
4141 gnus-fetch-old-headers))))
4142 (gnus-get-newsgroup-headers-xover
4143 articles nil nil gnus-newsgroup-name t)
4144 (gnus-get-newsgroup-headers)))
4145 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
4147 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4149 (setq gnus-newsgroup-cached cached))
4151 ;; Suppress duplicates?
4152 (when gnus-suppress-duplicates
4153 (gnus-dup-suppress-articles))
4155 ;; Set the initial limit.
4156 (setq gnus-newsgroup-limit (copy-sequence articles))
4157 ;; Remove canceled articles from the list of unread articles.
4158 (setq gnus-newsgroup-unreads
4159 (gnus-set-sorted-intersection
4160 gnus-newsgroup-unreads
4161 (setq fetched-articles
4162 (mapcar (lambda (headers) (mail-header-number headers))
4163 gnus-newsgroup-headers))))
4164 ;; Removed marked articles that do not exist.
4165 (gnus-update-missing-marks
4166 (gnus-sorted-complement fetched-articles articles))
4167 ;; We might want to build some more threads first.
4168 (when (and gnus-fetch-old-headers
4169 (eq gnus-headers-retrieved-by 'nov))
4170 (if (eq gnus-fetch-old-headers 'invisible)
4171 (gnus-build-all-threads)
4172 (gnus-build-old-threads)))
4173 ;; Let the Gnus agent mark articles as read.
4175 (gnus-agent-get-undownloaded-list))
4176 ;; Remove list identifiers from subject
4177 (when gnus-list-identifiers
4178 (gnus-summary-remove-list-identifiers))
4179 ;; Check whether auto-expire is to be done in this group.
4180 (setq gnus-newsgroup-auto-expire
4181 (gnus-group-auto-expirable-p group))
4182 ;; Set up the article buffer now, if necessary.
4183 (unless gnus-single-article-buffer
4184 (gnus-article-setup-buffer))
4185 ;; First and last article in this newsgroup.
4186 (when gnus-newsgroup-headers
4187 (setq gnus-newsgroup-begin
4188 (mail-header-number (car gnus-newsgroup-headers))
4191 (gnus-last-element gnus-newsgroup-headers))))
4192 ;; GROUP is successfully selected.
4193 (or gnus-newsgroup-headers t)))))
4195 (defun gnus-articles-to-read (group &optional read-all)
4196 ;; Find out what articles the user wants to read.
4198 ;; Select all articles if `read-all' is non-nil, or if there
4199 ;; are no unread articles.
4201 (and (zerop (length gnus-newsgroup-marked))
4202 (zerop (length gnus-newsgroup-unreads)))
4203 (eq (gnus-group-find-parameter group 'display)
4206 (gnus-uncompress-range (gnus-active group))
4207 (gnus-cache-articles-in-group group))
4208 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4209 (copy-sequence gnus-newsgroup-unreads))
4211 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4212 (scored (length scored-list))
4213 (number (length articles))
4214 (marked (+ (length gnus-newsgroup-marked)
4215 (length gnus-newsgroup-dormant)))
4223 ((and (or (<= scored marked) (= scored number))
4224 (numberp gnus-large-newsgroup)
4225 (> number gnus-large-newsgroup))
4229 "How many articles from %s (default %d): "
4230 (gnus-limit-string gnus-newsgroup-name 35)
4232 (if (string-match "^[ \t]*$" input) number input)))
4233 ((and (> scored marked) (< scored number)
4234 (> (- scored number) 20))
4237 (format "%s %s (%d scored, %d total): "
4238 "How many articles from"
4239 group scored number))))
4240 (if (string-match "^[ \t]*$" input)
4244 (setq select (if (stringp select) (string-to-number select) select))
4245 (if (or (null select) (zerop select))
4247 (if (and (not (zerop scored)) (<= (abs select) scored))
4249 (setq articles (sort scored-list '<))
4250 (setq number (length articles)))
4251 (setq articles (copy-sequence articles)))
4253 (when (< (abs select) number)
4255 ;; Select the N oldest articles.
4256 (setcdr (nthcdr (1- (abs select)) articles) nil)
4257 ;; Select the N most recent articles.
4258 (setq articles (nthcdr (- number select) articles))))
4259 (setq gnus-newsgroup-unselected
4260 (gnus-sorted-intersection
4261 gnus-newsgroup-unreads
4262 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4265 (defun gnus-killed-articles (killed articles)
4268 (when (inline (gnus-member-of-range (car articles) killed))
4269 (push (car articles) out))
4270 (setq articles (cdr articles)))
4273 (defun gnus-uncompress-marks (marks)
4274 "Uncompress the mark ranges in MARKS."
4275 (let ((uncompressed '(score bookmark))
4278 (if (memq (caar marks) uncompressed)
4279 (push (car marks) out)
4280 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4281 (setq marks (cdr marks)))
4284 (defun gnus-adjust-marked-articles (info)
4285 "Set all article lists and remove all marks that are no longer valid."
4286 (let* ((marked-lists (gnus-info-marks info))
4287 (active (gnus-active (gnus-info-group info)))
4290 (types gnus-article-mark-lists)
4291 (uncompressed '(score bookmark killed))
4292 marks var articles article mark)
4295 (setq marks (pop marked-lists))
4296 (set (setq var (intern (format "gnus-newsgroup-%s"
4297 (car (rassq (setq mark (car marks))
4299 (if (memq (car marks) uncompressed) (cdr marks)
4300 (gnus-uncompress-range (cdr marks))))
4302 (setq articles (symbol-value var))
4304 ;; All articles have to be subsets of the active articles.
4306 ;; Adjust "simple" lists.
4307 ((memq mark '(tick dormant expire reply save))
4309 (when (or (< (setq article (pop articles)) min) (> article max))
4310 (set var (delq article (symbol-value var))))))
4312 ((memq mark uncompressed)
4313 (when (not (listp (cdr (symbol-value var))))
4314 (set var (list (symbol-value var))))
4315 (when (not (listp (cdr articles)))
4316 (setq articles (list articles)))
4318 (when (or (not (consp (setq article (pop articles))))
4319 (< (car article) min)
4320 (> (car article) max))
4321 (set var (delq article (symbol-value var))))))))))
4323 (defun gnus-update-missing-marks (missing)
4324 "Go through the list of MISSING articles and remove them from the mark lists."
4326 (let ((types gnus-article-mark-lists)
4328 ;; Go through all types.
4330 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4331 (when (symbol-value var)
4332 ;; This list has articles. So we delete all missing articles
4336 (set var (delq (pop m) (symbol-value var)))))))))
4338 (defun gnus-update-marks ()
4339 "Enter the various lists of marked articles into the newsgroup info list."
4340 (let ((types gnus-article-mark-lists)
4341 (info (gnus-get-info gnus-newsgroup-name))
4342 (uncompressed '(score bookmark killed))
4343 type list newmarked symbol delta-marks)
4345 ;; Add all marks lists to the list of marks lists.
4346 (while (setq type (pop types))
4347 (setq list (symbol-value
4349 (intern (format "gnus-newsgroup-%s"
4353 ;; Get rid of the entries of the articles that have the
4355 (when (and (eq (cdr type) 'score)
4359 (prev (cons nil list))
4362 (if (or (not (consp (car arts)))
4363 (= (cdar arts) gnus-summary-default-score))
4364 (setcdr prev (cdr arts))
4366 (setq arts (cdr arts)))
4367 (setq list (cdr all)))))
4369 (or (memq (cdr type) uncompressed)
4370 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
4372 (when (gnus-check-backend-function 'request-set-mark
4373 gnus-newsgroup-name)
4374 ;; uncompressed:s are not proper flags (they are cons cells)
4375 ;; cache is a internal gnus flag
4376 (unless (memq (cdr type) (cons 'cache uncompressed))
4377 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4378 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
4379 (add (gnus-remove-from-range (gnus-copy-sequence list) old)))
4381 (push (list add 'add (list (cdr type))) delta-marks))
4383 (push (list del 'del (list (cdr type))) delta-marks)))))
4386 (push (cons (cdr type) list) newmarked)))
4389 (unless (gnus-check-group gnus-newsgroup-name)
4390 (error "Can't open server for %s" gnus-newsgroup-name))
4391 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4393 ;; Enter these new marks into the info of the group.
4395 (setcar (nthcdr 3 info) newmarked)
4396 ;; Add the marks lists to the end of the info.
4398 (setcdr (nthcdr 2 info) (list newmarked))))
4400 ;; Cut off the end of the info if there's nothing else there.
4404 (when (nthcdr (decf i) info)
4405 (setcdr (nthcdr i info) nil)))))))
4407 (defun gnus-set-mode-line (where)
4408 "This function sets the mode line of the article or summary buffers.
4409 If WHERE is `summary', the summary mode line format will be used."
4410 ;; Is this mode line one we keep updated?
4411 (when (and (memq where gnus-updated-mode-lines)
4413 (intern (format "gnus-%s-mode-line-format-spec" where))))
4416 ;; We evaluate this in the summary buffer since these
4417 ;; variables are buffer-local to that buffer.
4418 (set-buffer gnus-summary-buffer)
4419 ;; We bind all these variables that are used in the `eval' form
4421 (let* ((mformat (symbol-value
4423 (format "gnus-%s-mode-line-format-spec" where))))
4424 (gnus-tmp-group-name gnus-newsgroup-name)
4425 (gnus-tmp-article-number (or gnus-current-article 0))
4426 (gnus-tmp-unread gnus-newsgroup-unreads)
4427 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4428 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4429 (gnus-tmp-unread-and-unselected
4430 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4431 (zerop gnus-tmp-unselected))
4433 ((zerop gnus-tmp-unselected)
4434 (format "{%d more}" gnus-tmp-unread-and-unticked))
4435 (t (format "{%d(+%d) more}"
4436 gnus-tmp-unread-and-unticked
4437 gnus-tmp-unselected))))
4439 (if (and gnus-current-headers
4440 (vectorp gnus-current-headers))
4441 (gnus-mode-string-quote
4442 (mail-header-subject gnus-current-headers))
4444 bufname-length max-len
4445 gnus-tmp-header);; passed as argument to any user-format-funcs
4446 (setq mode-string (eval mformat))
4447 (setq bufname-length (if (string-match "%b" mode-string)
4450 (if (eq where 'summary)
4452 (get-buffer gnus-article-buffer))))
4455 (setq max-len (max 4 (if gnus-mode-non-string-length
4457 gnus-mode-non-string-length
4459 (length mode-string))))
4460 ;; We might have to chop a bit of the string off...
4461 (when (> (length mode-string) max-len)
4463 (concat (truncate-string-to-width mode-string (- max-len 3))
4465 ;; Pad the mode string a bit.
4466 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4467 ;; Update the mode line.
4468 (setq mode-line-buffer-identification
4469 (gnus-mode-line-buffer-identification (list mode-string)))
4470 (set-buffer-modified-p t))))
4472 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4473 "Go through the HEADERS list and add all Xrefs to a hash table.
4474 The resulting hash table is returned, or nil if no Xrefs were found."
4475 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4476 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4477 (xref-hashtb (gnus-make-hashtable))
4478 start group entry number xrefs header)
4480 (setq header (pop headers))
4481 (when (and (setq xrefs (mail-header-xref header))
4482 (not (memq (setq number (mail-header-number header))
4485 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4486 (setq start (match-end 0))
4487 (setq group (if prefix
4488 (concat prefix (substring xrefs (match-beginning 1)
4490 (substring xrefs (match-beginning 1) (match-end 1))))
4492 (string-to-int (substring xrefs (match-beginning 2)
4494 (if (setq entry (gnus-gethash group xref-hashtb))
4495 (setcdr entry (cons number (cdr entry)))
4496 (gnus-sethash group (cons number nil) xref-hashtb)))))
4497 (and start xref-hashtb)))
4499 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4500 "Look through all the headers and mark the Xrefs as read."
4501 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4502 name entry info xref-hashtb idlist method nth4)
4504 (set-buffer gnus-group-buffer)
4505 (when (setq xref-hashtb
4506 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4509 (unless (string= from-newsgroup (setq name (symbol-name group)))
4510 (setq idlist (symbol-value group))
4511 ;; Dead groups are not updated.
4513 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4515 (when (stringp (setq nth4 (gnus-info-method info)))
4516 (setq nth4 (gnus-server-to-method nth4))))
4517 ;; Only do the xrefs if the group has the same
4518 ;; select method as the group we have just read.
4519 (or (gnus-methods-equal-p
4520 nth4 (gnus-find-method-for-group from-newsgroup))
4522 (equal nth4 (setq method (gnus-find-method-for-group
4524 (and (equal (car nth4) (car method))
4525 (equal (nth 1 nth4) (nth 1 method))))
4526 gnus-use-cross-reference
4527 (or (not (eq gnus-use-cross-reference t))
4529 ;; Only do cross-references on subscribed
4530 ;; groups, if that is what is wanted.
4531 (<= (gnus-info-level info) gnus-level-subscribed))
4532 (gnus-group-make-articles-read name idlist))))
4535 (defun gnus-compute-read-articles (group articles)
4536 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4537 (info (nth 2 entry))
4538 (active (gnus-active group))
4541 ;; First peel off all invalid article numbers.
4543 (let ((ids articles)
4545 (while (setq id (pop ids))
4546 (when (and first (> id (cdr active)))
4547 ;; We'll end up in this situation in one particular
4548 ;; obscure situation. If you re-scan a group and get
4549 ;; a new article that is cross-posted to a different
4550 ;; group that has not been re-scanned, you might get
4551 ;; crossposted article that has a higher number than
4552 ;; Gnus believes possible. So we re-activate this
4553 ;; group as well. This might mean doing the
4554 ;; crossposting thingy will *increase* the number
4555 ;; of articles in some groups. Tsk, tsk.
4556 (setq active (or (gnus-activate-group group) active)))
4557 (when (or (> id (cdr active))
4558 (< id (car active)))
4559 (setq articles (delq id articles))))))
4560 ;; If the read list is nil, we init it.
4562 (null (gnus-info-read info))
4564 (setq ninfo (cons 1 (1- (car active))))
4565 (setq ninfo (gnus-info-read info)))
4566 ;; Then we add the read articles to the range.
4568 ninfo (setq articles (sort articles '<))))))
4570 (defun gnus-group-make-articles-read (group articles)
4571 "Update the info of GROUP to say that ARTICLES are read."
4573 (entry (gnus-gethash group gnus-newsrc-hashtb))
4574 (info (nth 2 entry))
4575 (active (gnus-active group))
4578 (setq range (gnus-compute-read-articles group articles))
4580 (set-buffer gnus-group-buffer)
4583 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4584 (gnus-info-set-read ',info ',(gnus-info-read info))
4585 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4586 (gnus-group-update-group ,group t))))
4587 ;; Add the read articles to the range.
4588 (gnus-info-set-read info range)
4589 ;; Then we have to re-compute how many unread
4590 ;; articles there are in this group.
4594 (setq num (- (1+ (cdr active)) (car active))))
4595 ((not (listp (cdr range)))
4596 (setq num (- (cdr active) (- (1+ (cdr range))
4600 (if (numberp (car range))
4602 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4603 (setq range (cdr range)))
4604 (setq num (- (cdr active) num))))
4605 ;; Update the number of unread articles.
4607 ;; Update the group buffer.
4608 (gnus-group-update-group group t)))))
4610 (defvar gnus-newsgroup-none-id 0)
4612 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4613 (let ((cur nntp-server-buffer)
4616 (save-excursion (set-buffer gnus-summary-buffer)
4617 gnus-newsgroup-dependencies)))
4619 (mail-parse-charset gnus-newsgroup-charset)
4620 (mail-parse-ignored-charsets
4621 (save-excursion (condition-case nil
4622 (set-buffer gnus-summary-buffer)
4624 gnus-newsgroup-ignored-charsets)))
4626 (set-buffer nntp-server-buffer)
4627 ;; Translate all TAB characters into SPACE characters.
4628 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4629 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4630 (gnus-run-hooks 'gnus-parse-headers-hook)
4631 (let ((case-fold-search t)
4632 in-reply-to header p lines chars)
4633 (goto-char (point-min))
4634 ;; Search to the beginning of the next header. Error messages
4635 ;; do not begin with 2 or 3.
4636 (while (re-search-forward "^[23][0-9]+ " nil t)
4639 ;; This implementation of this function, with nine
4640 ;; search-forwards instead of the one re-search-forward and
4641 ;; a case (which basically was the old function) is actually
4642 ;; about twice as fast, even though it looks messier. You
4643 ;; can't have everything, I guess. Speed and elegance
4644 ;; doesn't always go hand in hand.
4653 (narrow-to-region (point)
4654 (or (and (search-forward "\n.\n" nil t)
4660 (if (search-forward "\nsubject: " nil t)
4661 (funcall gnus-decode-encoded-word-function
4662 (nnheader-header-value))
4667 (if (search-forward "\nfrom: " nil t)
4668 (funcall gnus-decode-encoded-word-function
4669 (nnheader-header-value))
4674 (if (search-forward "\ndate: " nil t)
4675 (nnheader-header-value) ""))
4679 (setq id (if (re-search-forward
4680 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4681 ;; We do it this way to make sure the Message-ID
4682 ;; is (somewhat) syntactically valid.
4683 (buffer-substring (match-beginning 1)
4685 ;; If there was no message-id, we just fake one
4686 ;; to make subsequent routines simpler.
4687 (nnheader-generate-fake-message-id))))
4691 (if (search-forward "\nreferences: " nil t)
4695 (nnheader-header-value)
4700 (search-backward ">" end t)
4703 (search-backward "<" end t)
4705 ;; Get the references from the in-reply-to header if there
4706 ;; were no references and the in-reply-to header looks
4708 (if (and (search-forward "\nin-reply-to: " nil t)
4709 (setq in-reply-to (nnheader-header-value))
4710 (string-match "<[^>]+>" in-reply-to))
4712 (setq ref (substring in-reply-to (match-beginning 0)
4714 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4715 (setq ref2 (substring in-reply-to (match-beginning 0)
4717 (when (> (length ref2) (length ref))
4724 (if (search-forward "\nchars: " nil t)
4725 (if (numberp (setq chars (ignore-errors (read cur))))
4731 (if (search-forward "\nlines: " nil t)
4732 (if (numberp (setq lines (ignore-errors (read cur))))
4738 (and (search-forward "\nxref: " nil t)
4739 (nnheader-header-value)))
4741 (when gnus-extra-headers
4742 (let ((extra gnus-extra-headers)
4746 (when (search-forward
4747 (concat "\n" (symbol-name (car extra)) ": ") nil t)
4748 (push (cons (car extra) (nnheader-header-value))
4752 (when (equal id ref)
4755 (when gnus-alter-header-function
4756 (funcall gnus-alter-header-function header)
4757 (setq id (mail-header-id header)
4758 ref (gnus-parent-id (mail-header-references header))))
4761 (gnus-dependencies-add-header
4762 header dependencies force-new))
4763 (push header headers))
4764 (goto-char (point-max))
4766 (nreverse headers)))))
4768 ;; Goes through the xover lines and returns a list of vectors
4769 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4770 force-new dependencies
4771 group also-fetch-heads)
4772 "Parse the news overview data in the server buffer, and return a
4773 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4774 ;; Get the Xref when the users reads the articles since most/some
4775 ;; NNTP servers do not include Xrefs when using XOVER.
4776 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4777 (let ((mail-parse-charset gnus-newsgroup-charset)
4778 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
4779 (cur nntp-server-buffer)
4780 (dependencies (or dependencies gnus-newsgroup-dependencies))
4781 number headers header)
4783 (set-buffer nntp-server-buffer)
4784 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4785 ;; Allow the user to mangle the headers before parsing them.
4786 (gnus-run-hooks 'gnus-parse-headers-hook)
4787 (goto-char (point-min))
4790 (while (and sequence (not (eobp)))
4791 (setq number (read cur))
4792 (while (and sequence
4793 (< (car sequence) number))
4794 (setq sequence (cdr sequence)))
4796 (eq number (car sequence))
4798 (setq sequence (cdr sequence))
4799 (setq header (inline
4800 (gnus-nov-parse-line
4801 number dependencies force-new))))
4802 (push header headers))
4805 (gnus-error 4 "Strange nov line (%d)"
4806 (count-lines (point-min) (point)))))
4808 ;; A common bug in inn is that if you have posted an article and
4809 ;; then retrieves the active file, it will answer correctly --
4810 ;; the new article is included. However, a NOV entry for the
4811 ;; article may not have been generated yet, so this may fail.
4812 ;; We work around this problem by retrieving the last few
4813 ;; headers using HEAD.
4814 (if (or (not also-fetch-heads)
4816 ;; We (probably) got all the headers.
4818 (let ((gnus-nov-is-evil t))
4821 (when (gnus-retrieve-headers sequence group)
4822 (gnus-get-newsgroup-headers))))))))
4824 (defun gnus-article-get-xrefs ()
4825 "Fill in the Xref value in `gnus-current-headers', if necessary.
4826 This is meant to be called in `gnus-article-internal-prepare-hook'."
4827 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4828 gnus-current-headers)))
4829 (or (not gnus-use-cross-reference)
4831 (and (mail-header-xref headers)
4832 (not (string= (mail-header-xref headers) "")))
4833 (let ((case-fold-search t)
4836 (nnheader-narrow-to-headers)
4837 (goto-char (point-min))
4838 (when (or (and (not (eobp))
4839 (eq (downcase (char-after)) ?x)
4840 (looking-at "Xref:"))
4841 (search-forward "\nXref:" nil t))
4842 (goto-char (1+ (match-end 0)))
4843 (setq xref (buffer-substring (point)
4844 (progn (end-of-line) (point))))
4845 (mail-header-set-xref headers xref)))))))
4847 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4848 "Find article ID and insert the summary line for that article.
4849 OLD-HEADER can either be a header or a line number to insert
4850 the subject line on."
4851 (let* ((line (and (numberp old-header) old-header))
4852 (old-header (and (vectorp old-header) old-header))
4853 (header (cond ((and old-header use-old-header)
4856 (gnus-number-to-header id))
4857 (gnus-number-to-header id))
4859 (gnus-read-header id))))
4860 (number (and (numberp id) id))
4863 ;; Rebuild the thread that this article is part of and go to the
4864 ;; article we have fetched.
4865 (when (and (not gnus-show-threads)
4868 (setq d (gnus-data-find (mail-header-number old-header))))
4869 (goto-char (gnus-data-pos d))
4872 (- (gnus-point-at-bol)
4874 (1+ (gnus-point-at-eol))
4875 (gnus-delete-line))))))
4877 (mail-header-set-number header (mail-header-number old-header)))
4878 (setq gnus-newsgroup-sparse
4879 (delq (setq number (mail-header-number header))
4880 gnus-newsgroup-sparse))
4881 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4882 (push number gnus-newsgroup-limit)
4883 (gnus-rebuild-thread (mail-header-id header) line)
4884 (gnus-summary-goto-subject number nil t))
4885 (when (and (numberp number)
4887 ;; We have to update the boundaries even if we can't fetch the
4888 ;; article if ID is a number -- so that the next `P' or `N'
4889 ;; command will fetch the previous (or next) article even
4890 ;; if the one we tried to fetch this time has been canceled.
4891 (when (> number gnus-newsgroup-end)
4892 (setq gnus-newsgroup-end number))
4893 (when (< number gnus-newsgroup-begin)
4894 (setq gnus-newsgroup-begin number))
4895 (setq gnus-newsgroup-unselected
4896 (delq number gnus-newsgroup-unselected)))
4897 ;; Report back a success?
4898 (and header (mail-header-number header))))
4900 ;;; Process/prefix in the summary buffer
4902 (defun gnus-summary-work-articles (n)
4903 "Return a list of articles to be worked upon.
4904 The prefix argument, the list of process marked articles, and the
4905 current article will be taken into consideration."
4907 (set-buffer gnus-summary-buffer)
4910 ;; A numerical prefix has been given.
4911 (setq n (prefix-numeric-value n))
4912 (let ((backward (< n 0))
4913 (n (abs (prefix-numeric-value n)))
4918 (push (setq article (gnus-summary-article-number))
4921 (gnus-summary-find-prev nil article)
4922 (gnus-summary-find-next nil article)))
4924 (nreverse articles)))
4925 ((and (gnus-region-active-p) (mark))
4926 (message "region active")
4927 ;; Work on the region between point and mark.
4928 (let ((max (max (point) (mark)))
4931 (goto-char (min (min (point) (mark))))
4934 (push (setq article (gnus-summary-article-number)) articles)
4935 (gnus-summary-find-next nil article)
4937 (nreverse articles))))
4938 (gnus-newsgroup-processable
4939 ;; There are process-marked articles present.
4940 ;; Save current state.
4941 (gnus-summary-save-process-mark)
4943 (reverse gnus-newsgroup-processable))
4945 ;; Just return the current article.
4946 (list (gnus-summary-article-number))))))
4948 (defmacro gnus-summary-iterate (arg &rest forms)
4949 "Iterate over the process/prefixed articles and do FORMS.
4950 ARG is the interactive prefix given to the command. FORMS will be
4951 executed with point over the summary line of the articles."
4952 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
4953 `(let ((,articles (gnus-summary-work-articles ,arg)))
4955 (gnus-summary-goto-subject (car ,articles))
4959 (put 'gnus-summary-iterate 'lisp-indent-function 1)
4960 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
4962 (defun gnus-summary-save-process-mark ()
4963 "Push the current set of process marked articles on the stack."
4965 (push (copy-sequence gnus-newsgroup-processable)
4966 gnus-newsgroup-process-stack))
4968 (defun gnus-summary-kill-process-mark ()
4969 "Push the current set of process marked articles on the stack and unmark."
4971 (gnus-summary-save-process-mark)
4972 (gnus-summary-unmark-all-processable))
4974 (defun gnus-summary-yank-process-mark ()
4975 "Pop the last process mark state off the stack and restore it."
4977 (unless gnus-newsgroup-process-stack
4978 (error "Empty mark stack"))
4979 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4981 (defun gnus-summary-process-mark-set (set)
4982 "Make SET into the current process marked articles."
4983 (gnus-summary-unmark-all-processable)
4985 (gnus-summary-set-process-mark (pop set))))
4987 ;;; Searching and stuff
4989 (defun gnus-summary-search-group (&optional backward use-level)
4990 "Search for next unread newsgroup.
4991 If optional argument BACKWARD is non-nil, search backward instead."
4993 (set-buffer gnus-group-buffer)
4994 (when (gnus-group-search-forward
4995 backward nil (if use-level (gnus-group-group-level) nil))
4996 (gnus-group-group-name))))
4998 (defun gnus-summary-best-group (&optional exclude-group)
4999 "Find the name of the best unread group.
5000 If EXCLUDE-GROUP, do not go to this group."
5002 (set-buffer gnus-group-buffer)
5004 (gnus-group-best-unread-group exclude-group))))
5006 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5007 (if backward (gnus-summary-find-prev)
5008 (let* ((dummy (gnus-summary-article-intangible-p))
5009 (article (or article (gnus-summary-article-number)))
5010 (arts (gnus-data-find-list article))
5012 (when (and (not dummy)
5013 (or (not gnus-summary-check-current)
5015 (not (gnus-data-unread-p (car arts)))))
5016 (setq arts (cdr arts)))
5021 (when (or (and undownloaded
5022 (eq gnus-undownloaded-mark
5023 (gnus-data-mark (car arts))))
5024 (gnus-data-unread-p (car arts)))
5025 (setq result (car arts)
5027 (setq arts (cdr arts)))
5030 (goto-char (gnus-data-pos result))
5031 (gnus-data-number result)))))
5033 (defun gnus-summary-find-prev (&optional unread article)
5034 (let* ((eobp (eobp))
5035 (article (or article (gnus-summary-article-number)))
5036 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5038 (when (and (not eobp)
5039 (or (not gnus-summary-check-current)
5041 (not (gnus-data-unread-p (car arts)))))
5042 (setq arts (cdr arts)))
5047 (when (gnus-data-unread-p (car arts))
5048 (setq result (car arts)
5050 (setq arts (cdr arts)))
5053 (goto-char (gnus-data-pos result))
5054 (gnus-data-number result))))
5056 (defun gnus-summary-find-subject (subject &optional unread backward article)
5057 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5058 (article (or article (gnus-summary-article-number)))
5059 (articles (gnus-data-list backward))
5060 (arts (gnus-data-find-list article articles))
5062 (when (or (not gnus-summary-check-current)
5064 (not (gnus-data-unread-p (car arts))))
5065 (setq arts (cdr arts)))
5067 (and (or (not unread)
5068 (gnus-data-unread-p (car arts)))
5069 (vectorp (gnus-data-header (car arts)))
5071 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5072 (setq result (car arts)
5074 (setq arts (cdr arts)))
5076 (goto-char (gnus-data-pos result))
5077 (gnus-data-number result))))
5079 (defun gnus-summary-search-forward (&optional unread subject backward)
5080 "Search forward for an article.
5081 If UNREAD, look for unread articles. If SUBJECT, look for
5082 articles with that subject. If BACKWARD, search backward instead."
5083 (cond (subject (gnus-summary-find-subject subject unread backward))
5084 (backward (gnus-summary-find-prev unread))
5085 (t (gnus-summary-find-next unread))))
5087 (defun gnus-recenter (&optional n)
5088 "Center point in window and redisplay frame.
5089 Also do horizontal recentering."
5091 (when (and gnus-auto-center-summary
5092 (not (eq gnus-auto-center-summary 'vertical)))
5093 (gnus-horizontal-recenter))
5096 (defun gnus-summary-recenter ()
5097 "Center point in the summary window.
5098 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5099 displayed, no centering will be performed."
5100 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5101 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5102 (let* ((top (cond ((< (window-height) 4) 0)
5103 ((< (window-height) 7) 1)
5104 (t (if (numberp gnus-auto-center-summary)
5105 gnus-auto-center-summary
5107 (height (1- (window-height)))
5108 (bottom (save-excursion (goto-char (point-max))
5109 (forward-line (- height))
5111 (window (get-buffer-window (current-buffer))))
5112 ;; The user has to want it.
5113 (when gnus-auto-center-summary
5114 (when (get-buffer-window gnus-article-buffer)
5115 ;; Only do recentering when the article buffer is displayed,
5116 ;; Set the window start to either `bottom', which is the biggest
5117 ;; possible valid number, or the second line from the top,
5118 ;; whichever is the least.
5120 window (min bottom (save-excursion
5121 (forward-line (- top)) (point)))
5123 ;; Do horizontal recentering while we're at it.
5124 (when (and (get-buffer-window (current-buffer) t)
5125 (not (eq gnus-auto-center-summary 'vertical)))
5126 (let ((selected (selected-window)))
5127 (select-window (get-buffer-window (current-buffer) t))
5128 (gnus-summary-position-point)
5129 (gnus-horizontal-recenter)
5130 (select-window selected))))))
5132 (defun gnus-summary-jump-to-group (newsgroup)
5133 "Move point to NEWSGROUP in group mode buffer."
5134 ;; Keep update point of group mode buffer if visible.
5135 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5136 (save-window-excursion
5137 ;; Take care of tree window mode.
5138 (when (get-buffer-window gnus-group-buffer)
5139 (pop-to-buffer gnus-group-buffer))
5140 (gnus-group-jump-to-group newsgroup))
5142 ;; Take care of tree window mode.
5143 (if (get-buffer-window gnus-group-buffer)
5144 (pop-to-buffer gnus-group-buffer)
5145 (set-buffer gnus-group-buffer))
5146 (gnus-group-jump-to-group newsgroup))))
5148 ;; This function returns a list of article numbers based on the
5149 ;; difference between the ranges of read articles in this group and
5150 ;; the range of active articles.
5151 (defun gnus-list-of-unread-articles (group)
5152 (let* ((read (gnus-info-read (gnus-get-info group)))
5153 (active (or (gnus-active group) (gnus-activate-group group)))
5156 ;; If none are read, then all are unread.
5158 (setq first (car active))
5159 ;; If the range of read articles is a single range, then the
5160 ;; first unread article is the article after the last read
5161 ;; article. Sounds logical, doesn't it?
5162 (if (not (listp (cdr read)))
5163 (setq first (max (car active) (1+ (cdr read))))
5164 ;; `read' is a list of ranges.
5165 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5168 (setq first (car active)))
5171 (while (< first nlast)
5173 (setq first (1+ first))))
5174 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5175 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5176 (setq read (cdr read)))))
5177 ;; And add the last unread articles.
5178 (while (<= first last)
5180 (setq first (1+ first)))
5181 ;; Return the list of unread articles.
5182 (delq 0 (nreverse unread))))
5184 (defun gnus-list-of-read-articles (group)
5185 "Return a list of unread, unticked and non-dormant articles."
5186 (let* ((info (gnus-get-info group))
5187 (marked (gnus-info-marks info))
5188 (active (gnus-active group)))
5190 (gnus-set-difference
5191 (gnus-sorted-complement
5192 (gnus-uncompress-range active)
5193 (gnus-list-of-unread-articles group))
5195 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5196 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5198 ;; Various summary commands
5200 (defun gnus-summary-select-article-buffer ()
5201 "Reconfigure windows to show article buffer."
5203 (if (not (gnus-buffer-live-p gnus-article-buffer))
5204 (error "There is no article buffer for this summary buffer")
5205 (gnus-configure-windows 'article)
5206 (select-window (get-buffer-window gnus-article-buffer))))
5208 (defun gnus-summary-universal-argument (arg)
5209 "Perform any operation on all articles that are process/prefixed."
5211 (let ((articles (gnus-summary-work-articles arg))
5218 (substitute-command-keys
5219 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
5222 (gnus-error 1 "Undefined key")
5225 (gnus-summary-goto-subject (setq article (pop articles)))
5226 (let (gnus-newsgroup-processable)
5227 (command-execute func))
5228 (gnus-summary-remove-process-mark article)))))
5229 (gnus-summary-position-point))
5231 (defun gnus-summary-toggle-truncation (&optional arg)
5232 "Toggle truncation of summary lines.
5233 With arg, turn line truncation on iff arg is positive."
5235 (setq truncate-lines
5236 (if (null arg) (not truncate-lines)
5237 (> (prefix-numeric-value arg) 0)))
5240 (defun gnus-summary-reselect-current-group (&optional all rescan)
5241 "Exit and then reselect the current newsgroup.
5242 The prefix argument ALL means to select all articles."
5244 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5245 (error "Ephemeral groups can't be reselected"))
5246 (let ((current-subject (gnus-summary-article-number))
5247 (group gnus-newsgroup-name))
5248 (setq gnus-newsgroup-begin nil)
5250 ;; We have to adjust the point of group mode buffer because
5251 ;; point was moved to the next unread newsgroup by exiting.
5252 (gnus-summary-jump-to-group group)
5255 (gnus-group-get-new-news-this-group 1)))
5256 (gnus-group-read-group all t)
5257 (gnus-summary-goto-subject current-subject nil t)))
5259 (defun gnus-summary-rescan-group (&optional all)
5260 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5262 (gnus-summary-reselect-current-group all t))
5264 (defun gnus-summary-update-info (&optional non-destructive)
5266 (let ((group gnus-newsgroup-name))
5268 (when gnus-newsgroup-kill-headers
5269 (setq gnus-newsgroup-killed
5270 (gnus-compress-sequence
5272 (gnus-set-sorted-intersection
5273 (gnus-uncompress-range gnus-newsgroup-killed)
5274 (setq gnus-newsgroup-unselected
5275 (sort gnus-newsgroup-unselected '<)))
5276 (setq gnus-newsgroup-unreads
5277 (sort gnus-newsgroup-unreads '<)))
5279 (unless (listp (cdr gnus-newsgroup-killed))
5280 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5281 (let ((headers gnus-newsgroup-headers))
5282 ;; Set the new ranges of read articles.
5284 (set-buffer gnus-group-buffer)
5285 (gnus-undo-force-boundary))
5286 (gnus-update-read-articles
5287 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5288 ;; Set the current article marks.
5289 (let ((gnus-newsgroup-scored
5290 (if (and (not gnus-save-score)
5291 (not non-destructive))
5293 gnus-newsgroup-scored)))
5295 (gnus-update-marks)))
5296 ;; Do the cross-ref thing.
5297 (when gnus-use-cross-reference
5298 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5299 ;; Do not switch windows but change the buffer to work.
5300 (set-buffer gnus-group-buffer)
5301 (unless (gnus-ephemeral-group-p group)
5302 (gnus-group-update-group group)))))))
5304 (defun gnus-summary-save-newsrc (&optional force)
5305 "Save the current number of read/marked articles in the dribble buffer.
5306 The dribble buffer will then be saved.
5307 If FORCE (the prefix), also save the .newsrc file(s)."
5309 (gnus-summary-update-info t)
5311 (gnus-save-newsrc-file)
5312 (gnus-dribble-save)))
5314 (defun gnus-summary-exit (&optional temporary)
5315 "Exit reading current newsgroup, and then return to group selection mode.
5316 gnus-exit-group-hook is called with no arguments if that value is non-nil."
5318 (gnus-set-global-variables)
5319 (when (gnus-buffer-live-p gnus-article-buffer)
5321 (set-buffer gnus-article-buffer)
5322 (mm-destroy-parts gnus-article-mime-handles)))
5323 (gnus-kill-save-kill-buffer)
5324 (gnus-async-halt-prefetch)
5325 (let* ((group gnus-newsgroup-name)
5326 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5329 (buf (current-buffer)))
5331 ;; Do adaptive scoring, and possibly save score files.
5332 (when gnus-newsgroup-adaptive
5333 (gnus-score-adaptive))
5334 (when gnus-use-scoring
5336 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5337 ;; If we have several article buffers, we kill them at exit.
5338 (unless gnus-single-article-buffer
5339 (gnus-kill-buffer gnus-original-article-buffer)
5340 (setq gnus-article-current nil))
5341 (when gnus-use-cache
5342 (gnus-cache-possibly-remove-articles)
5343 (gnus-cache-save-buffers))
5344 (gnus-async-prefetch-remove-group group)
5345 (when gnus-suppress-duplicates
5346 (gnus-dup-enter-articles))
5347 (when gnus-use-trees
5348 (gnus-tree-close group))
5349 ;; Remove entries for this group.
5350 (nnmail-purge-split-history (gnus-group-real-name group))
5351 ;; Make all changes in this group permanent.
5353 (gnus-run-hooks 'gnus-exit-group-hook)
5354 (gnus-summary-update-info))
5355 (gnus-close-group group)
5356 ;; Make sure where we were, and go to next newsgroup.
5357 (set-buffer gnus-group-buffer)
5359 (gnus-group-jump-to-group group))
5360 (gnus-run-hooks 'gnus-summary-exit-hook)
5361 (unless (or quit-config
5362 ;; If this group has disappeared from the summary
5363 ;; buffer, don't skip forwards.
5364 (not (string= group (gnus-group-group-name))))
5365 (gnus-group-next-unread-group 1))
5366 (setq group-point (point))
5369 ;; If we have several article buffers, we kill them at exit.
5370 (unless gnus-single-article-buffer
5371 (gnus-kill-buffer gnus-article-buffer)
5372 (gnus-kill-buffer gnus-original-article-buffer)
5373 (setq gnus-article-current nil))
5375 (if (not gnus-kill-summary-on-exit)
5376 (gnus-deaden-summary)
5377 ;; We set all buffer-local variables to nil. It is unclear why
5378 ;; this is needed, but if we don't, buffer-local variables are
5379 ;; not garbage-collected, it seems. This would the lead to en
5380 ;; ever-growing Emacs.
5381 (gnus-summary-clear-local-variables)
5382 (when (get-buffer gnus-article-buffer)
5383 (bury-buffer gnus-article-buffer))
5384 ;; We clear the global counterparts of the buffer-local
5385 ;; variables as well, just to be on the safe side.
5386 (set-buffer gnus-group-buffer)
5387 (gnus-summary-clear-local-variables)
5388 ;; Return to group mode buffer.
5389 (when (eq mode 'gnus-summary-mode)
5390 (gnus-kill-buffer buf)))
5391 (setq gnus-current-select-method gnus-select-method)
5392 (pop-to-buffer gnus-group-buffer)
5393 (if (not quit-config)
5395 (goto-char group-point)
5396 (gnus-configure-windows 'group 'force))
5397 (gnus-handle-ephemeral-exit quit-config))
5398 ;; Clear the current group name.
5400 (setq gnus-newsgroup-name nil)))))
5402 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5403 (defun gnus-summary-exit-no-update (&optional no-questions)
5404 "Quit reading current newsgroup without updating read article info."
5406 (let* ((group gnus-newsgroup-name)
5407 (quit-config (gnus-group-quit-config group)))
5408 (when (or no-questions
5410 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5411 (gnus-async-halt-prefetch)
5413 (delq 'gnus-summary-expire-articles
5414 (copy-list gnus-summary-prepare-exit-hook)))
5415 (when (gnus-buffer-live-p gnus-article-buffer)
5417 (set-buffer gnus-article-buffer)
5418 (mm-destroy-parts gnus-article-mime-handles)))
5419 ;; If we have several article buffers, we kill them at exit.
5420 (unless gnus-single-article-buffer
5421 (gnus-kill-buffer gnus-article-buffer)
5422 (gnus-kill-buffer gnus-original-article-buffer)
5423 (setq gnus-article-current nil))
5424 (if (not gnus-kill-summary-on-exit)
5425 (gnus-deaden-summary)
5426 (gnus-close-group group)
5427 (gnus-summary-clear-local-variables)
5428 (set-buffer gnus-group-buffer)
5429 (gnus-summary-clear-local-variables)
5430 (when (get-buffer gnus-summary-buffer)
5431 (kill-buffer gnus-summary-buffer)))
5432 (unless gnus-single-article-buffer
5433 (setq gnus-article-current nil))
5434 (when gnus-use-trees
5435 (gnus-tree-close group))
5436 (gnus-async-prefetch-remove-group group)
5437 (when (get-buffer gnus-article-buffer)
5438 (bury-buffer gnus-article-buffer))
5439 ;; Return to the group buffer.
5440 (gnus-configure-windows 'group 'force)
5441 ;; Clear the current group name.
5442 (setq gnus-newsgroup-name nil)
5443 (when (equal (gnus-group-group-name) group)
5444 (gnus-group-next-unread-group 1))
5446 (gnus-handle-ephemeral-exit quit-config)))))
5448 (defun gnus-handle-ephemeral-exit (quit-config)
5449 "Handle movement when leaving an ephemeral group.
5450 The state which existed when entering the ephemeral is reset."
5451 (if (not (buffer-name (car quit-config)))
5452 (gnus-configure-windows 'group 'force)
5453 (set-buffer (car quit-config))
5454 (cond ((eq major-mode 'gnus-summary-mode)
5455 (gnus-set-global-variables))
5456 ((eq major-mode 'gnus-article-mode)
5458 ;; The `gnus-summary-buffer' variable may point
5459 ;; to the old summary buffer when using a single
5461 (unless (gnus-buffer-live-p gnus-summary-buffer)
5462 (set-buffer gnus-group-buffer))
5463 (set-buffer gnus-summary-buffer)
5464 (gnus-set-global-variables))))
5465 (if (or (eq (cdr quit-config) 'article)
5466 (eq (cdr quit-config) 'pick))
5468 ;; The current article may be from the ephemeral group
5469 ;; thus it is best that we reload this article
5470 (gnus-summary-show-article)
5471 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5472 (gnus-configure-windows 'pick 'force)
5473 (gnus-configure-windows (cdr quit-config) 'force)))
5474 (gnus-configure-windows (cdr quit-config) 'force))
5475 (when (eq major-mode 'gnus-summary-mode)
5476 (gnus-summary-next-subject 1 nil t)
5477 (gnus-summary-recenter)
5478 (gnus-summary-position-point))))
5482 (defvar gnus-dead-summary-mode-map nil)
5484 (unless gnus-dead-summary-mode-map
5485 (setq gnus-dead-summary-mode-map (make-keymap))
5486 (suppress-keymap gnus-dead-summary-mode-map)
5487 (substitute-key-definition
5488 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5489 (let ((keys '("\C-d" "\r" "\177" [delete])))
5491 (define-key gnus-dead-summary-mode-map
5492 (pop keys) 'gnus-summary-wake-up-the-dead))))
5494 (defvar gnus-dead-summary-mode nil
5495 "Minor mode for Gnus summary buffers.")
5497 (defun gnus-dead-summary-mode (&optional arg)
5498 "Minor mode for Gnus summary buffers."
5500 (when (eq major-mode 'gnus-summary-mode)
5501 (make-local-variable 'gnus-dead-summary-mode)
5502 (setq gnus-dead-summary-mode
5503 (if (null arg) (not gnus-dead-summary-mode)
5504 (> (prefix-numeric-value arg) 0)))
5505 (when gnus-dead-summary-mode
5506 (gnus-add-minor-mode
5507 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5509 (defun gnus-deaden-summary ()
5510 "Make the current summary buffer into a dead summary buffer."
5511 ;; Kill any previous dead summary buffer.
5512 (when (and gnus-dead-summary
5513 (buffer-name gnus-dead-summary))
5515 (set-buffer gnus-dead-summary)
5516 (when gnus-dead-summary-mode
5517 (kill-buffer (current-buffer)))))
5518 ;; Make this the current dead summary.
5519 (setq gnus-dead-summary (current-buffer))
5520 (gnus-dead-summary-mode 1)
5521 (let ((name (buffer-name)))
5522 (when (string-match "Summary" name)
5524 (concat (substring name 0 (match-beginning 0)) "Dead "
5525 (substring name (match-beginning 0)))
5528 (defun gnus-kill-or-deaden-summary (buffer)
5529 "Kill or deaden the summary BUFFER."
5531 (when (and (buffer-name buffer)
5532 (not gnus-single-article-buffer))
5535 (gnus-kill-buffer gnus-article-buffer)
5536 (gnus-kill-buffer gnus-original-article-buffer)))
5537 (cond (gnus-kill-summary-on-exit
5538 (when (and gnus-use-trees
5539 (gnus-buffer-exists-p buffer))
5542 (gnus-tree-close gnus-newsgroup-name)))
5543 (gnus-kill-buffer buffer))
5544 ((gnus-buffer-exists-p buffer)
5547 (gnus-deaden-summary))))))
5549 (defun gnus-summary-wake-up-the-dead (&rest args)
5550 "Wake up the dead summary buffer."
5552 (gnus-dead-summary-mode -1)
5553 (let ((name (buffer-name)))
5554 (when (string-match "Dead " name)
5556 (concat (substring name 0 (match-beginning 0))
5557 (substring name (match-end 0)))
5559 (gnus-message 3 "This dead summary is now alive again"))
5561 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5562 (defun gnus-summary-fetch-faq (&optional faq-dir)
5563 "Fetch the FAQ for the current group.
5564 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5568 (when current-prefix-arg
5570 "Faq dir: " (and (listp gnus-group-faq-directory)
5571 (mapcar (lambda (file) (list file))
5572 gnus-group-faq-directory))))))
5573 (let (gnus-faq-buffer)
5574 (when (setq gnus-faq-buffer
5575 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5576 (gnus-configure-windows 'summary-faq))))
5578 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5579 (defun gnus-summary-describe-group (&optional force)
5580 "Describe the current newsgroup."
5582 (gnus-group-describe-group force gnus-newsgroup-name))
5584 (defun gnus-summary-describe-briefly ()
5585 "Describe summary mode commands briefly."
5587 (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")))
5589 ;; Walking around group mode buffer from summary mode.
5591 (defun gnus-summary-next-group (&optional no-article target-group backward)
5592 "Exit current newsgroup and then select next unread newsgroup.
5593 If prefix argument NO-ARTICLE is non-nil, no article is selected
5594 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5595 previous group instead."
5597 ;; Stop pre-fetching.
5598 (gnus-async-halt-prefetch)
5599 (let ((current-group gnus-newsgroup-name)
5600 (current-buffer (current-buffer))
5602 ;; First we semi-exit this group to update Xrefs and all variables.
5603 ;; We can't do a real exit, because the window conf must remain
5604 ;; the same in case the user is prompted for info, and we don't
5605 ;; want the window conf to change before that...
5606 (gnus-summary-exit t)
5607 (while (not entered)
5608 ;; Then we find what group we are supposed to enter.
5609 (set-buffer gnus-group-buffer)
5610 (gnus-group-jump-to-group current-group)
5613 (if (eq gnus-keep-same-level 'best)
5614 (gnus-summary-best-group gnus-newsgroup-name)
5615 (gnus-summary-search-group backward gnus-keep-same-level))))
5616 (if (not target-group)
5617 ;; There are no further groups, so we return to the group
5620 (gnus-message 5 "Returning to the group buffer")
5622 (when (gnus-buffer-live-p current-buffer)
5623 (set-buffer current-buffer)
5624 (gnus-summary-exit))
5625 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5626 ;; We try to enter the target group.
5627 (gnus-group-jump-to-group target-group)
5628 (let ((unreads (gnus-group-group-unread)))
5629 (if (and (or (eq t unreads)
5630 (and unreads (not (zerop unreads))))
5631 (gnus-summary-read-group
5632 target-group nil no-article
5633 (and (buffer-name current-buffer) current-buffer)
5636 (setq current-group target-group
5637 target-group nil)))))))
5639 (defun gnus-summary-prev-group (&optional no-article)
5640 "Exit current newsgroup and then select previous unread newsgroup.
5641 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5643 (gnus-summary-next-group no-article nil t))
5645 ;; Walking around summary lines.
5647 (defun gnus-summary-first-subject (&optional unread undownloaded)
5648 "Go to the first unread subject.
5649 If UNREAD is non-nil, go to the first unread article.
5650 Returns the article selected or nil if there are no unread articles."
5655 ((null gnus-newsgroup-data)
5656 (gnus-message 3 "No articles in the group")
5658 ;; Pick the first article.
5660 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5661 (gnus-data-number (car gnus-newsgroup-data)))
5662 ;; No unread articles.
5663 ((null gnus-newsgroup-unreads)
5664 (gnus-message 3 "No more unread articles")
5666 ;; Find the first unread article.
5668 (let ((data gnus-newsgroup-data))
5670 (and (not (and undownloaded
5671 (eq gnus-undownloaded-mark
5672 (gnus-data-mark (car data)))))
5673 (not (gnus-data-unread-p (car data)))))
5674 (setq data (cdr data)))
5676 (goto-char (gnus-data-pos (car data)))
5677 (gnus-data-number (car data))))))
5678 (gnus-summary-position-point)))
5680 (defun gnus-summary-next-subject (n &optional unread dont-display)
5681 "Go to next N'th summary line.
5682 If N is negative, go to the previous N'th subject line.
5683 If UNREAD is non-nil, only unread articles are selected.
5684 The difference between N and the actual number of steps taken is
5687 (let ((backward (< n 0))
5691 (gnus-summary-find-prev unread)
5692 (gnus-summary-find-next unread)))
5693 (gnus-summary-show-thread)
5696 (gnus-message 7 "No more%s articles"
5697 (if unread " unread" "")))
5698 (unless dont-display
5699 (gnus-summary-recenter)
5700 (gnus-summary-position-point))
5703 (defun gnus-summary-next-unread-subject (n)
5704 "Go to next N'th unread summary line."
5706 (gnus-summary-next-subject n t))
5708 (defun gnus-summary-prev-subject (n &optional unread)
5709 "Go to previous N'th summary line.
5710 If optional argument UNREAD is non-nil, only unread article is selected."
5712 (gnus-summary-next-subject (- n) unread))
5714 (defun gnus-summary-prev-unread-subject (n)
5715 "Go to previous N'th unread summary line."
5717 (gnus-summary-next-subject (- n) t))
5719 (defun gnus-summary-goto-subject (article &optional force silent)
5720 "Go the subject line of ARTICLE.
5721 If FORCE, also allow jumping to articles not currently shown."
5722 (interactive "nArticle number: ")
5724 (data (gnus-data-find article)))
5725 ;; We read in the article if we have to.
5728 (gnus-summary-insert-subject
5730 (if (or (numberp force) (vectorp force)) force)
5732 (setq data (gnus-data-find article)))
5737 (gnus-message 3 "Can't find article %d" article))
5739 (goto-char (gnus-data-pos data))
5740 (gnus-summary-position-point)
5743 ;; Walking around summary lines with displaying articles.
5745 (defun gnus-summary-expand-window (&optional arg)
5746 "Make the summary buffer take up the entire Emacs frame.
5747 Given a prefix, will force an `article' buffer configuration."
5750 (gnus-configure-windows 'article 'force)
5751 (gnus-configure-windows 'summary 'force)))
5753 (defun gnus-summary-display-article (article &optional all-header)
5754 "Display ARTICLE in article buffer."
5755 (gnus-set-global-variables)
5759 (if gnus-summary-display-article-function
5760 (funcall gnus-summary-display-article-function article all-header)
5761 (gnus-article-prepare article all-header))
5762 (gnus-run-hooks 'gnus-select-article-hook)
5763 (when (and gnus-current-article
5764 (not (zerop gnus-current-article)))
5765 (gnus-summary-goto-subject gnus-current-article))
5766 (gnus-summary-recenter)
5767 (when (and gnus-use-trees gnus-show-threads)
5768 (gnus-possibly-generate-tree article)
5769 (gnus-highlight-selected-tree article))
5770 ;; Successfully display article.
5771 (gnus-article-set-window-start
5772 (cdr (assq article gnus-newsgroup-bookmarks))))))
5774 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5775 "Select the current article.
5776 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5777 non-nil, the article will be re-fetched even if it already present in
5778 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5780 ;; Make sure we are in the summary buffer to work around bbdb bug.
5781 (unless (eq major-mode 'gnus-summary-mode)
5782 (set-buffer gnus-summary-buffer))
5783 (let ((article (or article (gnus-summary-article-number)))
5784 (all-headers (not (not all-headers))) ;Must be T or NIL.
5785 gnus-summary-display-article-function
5788 (gnus-summary-article-pseudo-p article)
5789 (error "This is a pseudo-article"))
5792 (set-buffer gnus-summary-buffer)
5793 (if (or (and gnus-single-article-buffer
5794 (or (null gnus-current-article)
5795 (null gnus-article-current)
5796 (null (get-buffer gnus-article-buffer))
5797 (not (eq article (cdr gnus-article-current)))
5798 (not (equal (car gnus-article-current)
5799 gnus-newsgroup-name))))
5800 (and (not gnus-single-article-buffer)
5801 (or (null gnus-current-article)
5802 (not (eq gnus-current-article article))))
5804 ;; The requested article is different from the current article.
5806 (gnus-summary-display-article article all-headers)
5808 (when (or all-headers gnus-show-all-headers)
5809 (gnus-article-show-all-headers)))
5810 (when (or all-headers gnus-show-all-headers)
5811 (gnus-article-show-all-headers))
5814 (gnus-article-set-window-start
5815 (cdr (assq article gnus-newsgroup-bookmarks)))))))
5817 (defun gnus-summary-set-current-mark (&optional current-mark)
5818 "Obsolete function."
5821 (defun gnus-summary-next-article (&optional unread subject backward push)
5822 "Select the next article.
5823 If UNREAD, only unread articles are selected.
5824 If SUBJECT, only articles with SUBJECT are selected.
5825 If BACKWARD, the previous article is selected instead of the next."
5828 ;; Is there such an article?
5829 ((and (gnus-summary-search-forward unread subject backward)
5830 (or (gnus-summary-display-article (gnus-summary-article-number))
5831 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5832 (gnus-summary-position-point))
5833 ;; If not, we try the first unread, if that is wanted.
5835 gnus-auto-select-same
5836 (gnus-summary-first-unread-article))
5837 (gnus-summary-position-point)
5838 (gnus-message 6 "Wrapped"))
5839 ;; Try to get next/previous article not displayed in this group.
5840 ((and gnus-auto-extend-newsgroup
5841 (not unread) (not subject))
5842 (gnus-summary-goto-article
5843 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5844 nil (count-lines (point-min) (point))))
5845 ;; Go to next/previous group.
5847 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5848 (gnus-summary-jump-to-group gnus-newsgroup-name))
5849 (let ((cmd last-command-char)
5852 (set-buffer gnus-group-buffer)
5855 (if (eq gnus-keep-same-level 'best)
5856 (gnus-summary-best-group gnus-newsgroup-name)
5857 (gnus-summary-search-group backward gnus-keep-same-level))))
5858 ;; For some reason, the group window gets selected. We change
5860 (select-window (get-buffer-window (current-buffer)))
5861 ;; Select next unread newsgroup automagically.
5863 ((or (not gnus-auto-select-next)
5865 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5866 ((or (eq gnus-auto-select-next 'quietly)
5867 (and (eq gnus-auto-select-next 'slightly-quietly)
5869 (and (eq gnus-auto-select-next 'almost-quietly)
5870 (gnus-summary-last-article-p)))
5872 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5874 (gnus-message 7 "No more%s articles (%s)..."
5875 (if unread " unread" "")
5876 (if group (concat "selecting " group)
5878 (gnus-summary-next-group nil group backward)))
5880 (when (gnus-key-press-event-p last-input-event)
5881 (gnus-summary-walk-group-buffer
5882 gnus-newsgroup-name cmd unread backward point))))))))
5884 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5885 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5886 (?\C-p (gnus-group-prev-unread-group 1))))
5887 (cursor-in-echo-area t)
5888 keve key group ended)
5890 (set-buffer gnus-group-buffer)
5893 (if (eq gnus-keep-same-level 'best)
5894 (gnus-summary-best-group gnus-newsgroup-name)
5895 (gnus-summary-search-group backward gnus-keep-same-level))))
5898 5 "No more%s articles%s" (if unread " unread" "")
5900 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5901 (format " (Type %s for %s [%s])"
5902 (single-key-description cmd) group
5903 (car (gnus-gethash group gnus-newsrc-hashtb)))
5904 (format " (Type %s to exit %s)"
5905 (single-key-description cmd)
5906 gnus-newsgroup-name)))
5907 ;; Confirm auto selection.
5908 (setq key (car (setq keve (gnus-read-event-char))))
5911 ((assq key keystrokes)
5912 (let ((obuf (current-buffer)))
5913 (switch-to-buffer gnus-group-buffer)
5915 (gnus-group-jump-to-group group))
5916 (eval (cadr (assq key keystrokes)))
5917 (setq group (gnus-group-group-name))
5918 (switch-to-buffer obuf))
5922 (gnus-ephemeral-group-p gnus-newsgroup-name))
5924 (gnus-summary-next-group nil group backward)))
5926 (push (cdr keve) unread-command-events))))))
5928 (defun gnus-summary-next-unread-article ()
5929 "Select unread article after current one."
5931 (gnus-summary-next-article
5932 (or (not (eq gnus-summary-goto-unread 'never))
5933 (gnus-summary-last-article-p (gnus-summary-article-number)))
5934 (and gnus-auto-select-same
5935 (gnus-summary-article-subject))))
5937 (defun gnus-summary-prev-article (&optional unread subject)
5938 "Select the article after the current one.
5939 If UNREAD is non-nil, only unread articles are selected."
5941 (gnus-summary-next-article unread subject t))
5943 (defun gnus-summary-prev-unread-article ()
5944 "Select unread article before current one."
5946 (gnus-summary-prev-article
5947 (or (not (eq gnus-summary-goto-unread 'never))
5948 (gnus-summary-first-article-p (gnus-summary-article-number)))
5949 (and gnus-auto-select-same
5950 (gnus-summary-article-subject))))
5952 (defun gnus-summary-next-page (&optional lines circular)
5953 "Show next page of the selected article.
5954 If at the end of the current article, select the next article.
5955 LINES says how many lines should be scrolled up.
5957 If CIRCULAR is non-nil, go to the start of the article instead of
5958 selecting the next article when reaching the end of the current
5961 (setq gnus-summary-buffer (current-buffer))
5962 (gnus-set-global-variables)
5963 (let ((article (gnus-summary-article-number))
5964 (article-window (get-buffer-window gnus-article-buffer t))
5966 ;; If the buffer is empty, we have no article.
5968 (error "No article to select"))
5969 (gnus-configure-windows 'article)
5970 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
5971 (if (and (eq gnus-summary-goto-unread 'never)
5972 (not (gnus-summary-last-article-p article)))
5973 (gnus-summary-next-article)
5974 (gnus-summary-next-unread-article))
5975 (if (or (null gnus-current-article)
5976 (null gnus-article-current)
5977 (/= article (cdr gnus-article-current))
5978 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5979 ;; Selected subject is different from current article's.
5980 (gnus-summary-display-article article)
5981 (when article-window
5982 (gnus-eval-in-buffer-window gnus-article-buffer
5983 (setq endp (gnus-article-next-page lines)))
5986 (gnus-summary-beginning-of-article))
5988 (gnus-message 3 "End of message"))
5990 (if (and (eq gnus-summary-goto-unread 'never)
5991 (not (gnus-summary-last-article-p article)))
5992 (gnus-summary-next-article)
5993 (gnus-summary-next-unread-article))))))))
5994 (gnus-summary-recenter)
5995 (gnus-summary-position-point)))
5997 (defun gnus-summary-prev-page (&optional lines move)
5998 "Show previous page of selected article.
5999 Argument LINES specifies lines to be scrolled down.
6000 If MOVE, move to the previous unread article if point is at
6001 the beginning of the buffer."
6003 (let ((article (gnus-summary-article-number))
6004 (article-window (get-buffer-window gnus-article-buffer t))
6006 (gnus-configure-windows 'article)
6007 (if (or (null gnus-current-article)
6008 (null gnus-article-current)
6009 (/= article (cdr gnus-article-current))
6010 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6011 ;; Selected subject is different from current article's.
6012 (gnus-summary-display-article article)
6013 (gnus-summary-recenter)
6014 (when article-window
6015 (gnus-eval-in-buffer-window gnus-article-buffer
6016 (setq endp (gnus-article-prev-page lines)))
6017 (when (and move endp)
6019 (gnus-message 3 "Beginning of message"))
6021 (if (and (eq gnus-summary-goto-unread 'never)
6022 (not (gnus-summary-first-article-p article)))
6023 (gnus-summary-prev-article)
6024 (gnus-summary-prev-unread-article))))))))
6025 (gnus-summary-position-point))
6027 (defun gnus-summary-prev-page-or-article (&optional lines)
6028 "Show previous page of selected article.
6029 Argument LINES specifies lines to be scrolled down.
6030 If at the beginning of the article, go to the next article."
6032 (gnus-summary-prev-page lines t))
6034 (defun gnus-summary-scroll-up (lines)
6035 "Scroll up (or down) one line current article.
6036 Argument LINES specifies lines to be scrolled up (or down if negative)."
6038 (gnus-configure-windows 'article)
6039 (gnus-summary-show-thread)
6040 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6041 (gnus-eval-in-buffer-window gnus-article-buffer
6043 (when (gnus-article-next-page lines)
6044 (gnus-message 3 "End of message")))
6046 (gnus-article-prev-page (- lines))))))
6047 (gnus-summary-recenter)
6048 (gnus-summary-position-point))
6050 (defun gnus-summary-scroll-down (lines)
6051 "Scroll down (or up) one line current article.
6052 Argument LINES specifies lines to be scrolled down (or up if negative)."
6054 (gnus-summary-scroll-up (- lines)))
6056 (defun gnus-summary-next-same-subject ()
6057 "Select next article which has the same subject as current one."
6059 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6061 (defun gnus-summary-prev-same-subject ()
6062 "Select previous article which has the same subject as current one."
6064 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6066 (defun gnus-summary-next-unread-same-subject ()
6067 "Select next unread article which has the same subject as current one."
6069 (gnus-summary-next-article t (gnus-summary-article-subject)))
6071 (defun gnus-summary-prev-unread-same-subject ()
6072 "Select previous unread article which has the same subject as current one."
6074 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6076 (defun gnus-summary-first-unread-article ()
6077 "Select 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-display-article (gnus-summary-article-number)))
6085 (gnus-summary-position-point)))
6087 (defun gnus-summary-first-unread-subject ()
6088 "Place the point on the subject line of the first unread article.
6089 Return nil if there are no unread articles."
6092 (when (gnus-summary-first-subject t)
6093 (gnus-summary-show-thread)
6094 (gnus-summary-first-subject t))
6095 (gnus-summary-position-point)))
6097 (defun gnus-summary-first-article ()
6098 "Select the first article.
6099 Return nil if there are no articles."
6102 (when (gnus-summary-first-subject)
6103 (gnus-summary-show-thread)
6104 (gnus-summary-first-subject)
6105 (gnus-summary-display-article (gnus-summary-article-number)))
6106 (gnus-summary-position-point)))
6108 (defun gnus-summary-best-unread-article ()
6109 "Select the unread article with the highest score."
6111 (let ((best -1000000)
6112 (data gnus-newsgroup-data)
6115 (and (gnus-data-unread-p (car data))
6117 (gnus-summary-article-score (gnus-data-number (car data))))
6120 article (gnus-data-number (car data))))
6121 (setq data (cdr data)))
6124 (gnus-summary-goto-article article)
6125 (error "No unread articles"))
6126 (gnus-summary-position-point))))
6128 (defun gnus-summary-last-subject ()
6129 "Go to the last displayed subject line in the group."
6130 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6132 (gnus-summary-goto-subject article))))
6134 (defun gnus-summary-goto-article (article &optional all-headers force)
6135 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6136 If ALL-HEADERS is non-nil, no header lines are hidden.
6137 If FORCE, go to the article even if it isn't displayed. If FORCE
6138 is a number, it is the line the article is to be displayed on."
6142 "Article number or Message-ID: "
6143 (mapcar (lambda (number) (list (int-to-string number)))
6144 gnus-newsgroup-limit))
6148 (if (and (stringp article)
6149 (string-match "@" article))
6150 (gnus-summary-refer-article article)
6151 (when (stringp article)
6152 (setq article (string-to-number article)))
6153 (if (gnus-summary-goto-subject article force)
6154 (gnus-summary-display-article article all-headers)
6155 (gnus-message 4 "Couldn't go to article %s" article) nil))
6156 (gnus-summary-position-point)))
6158 (defun gnus-summary-goto-last-article ()
6159 "Go to the previously read article."
6162 (when gnus-last-article
6163 (gnus-summary-goto-article gnus-last-article nil t))
6164 (gnus-summary-position-point)))
6166 (defun gnus-summary-pop-article (number)
6167 "Pop one article off the history and go to the previous.
6168 NUMBER articles will be popped off."
6171 (setq gnus-newsgroup-history
6172 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6174 (gnus-summary-goto-article (car to) nil t)
6175 (error "Article history empty")))
6176 (gnus-summary-position-point))
6178 ;; Summary commands and functions for limiting the summary buffer.
6180 (defun gnus-summary-limit-to-articles (n)
6181 "Limit the summary buffer to the next N articles.
6182 If not given a prefix, use the process marked articles instead."
6185 (let ((articles (gnus-summary-work-articles n)))
6186 (setq gnus-newsgroup-processable nil)
6187 (gnus-summary-limit articles))
6188 (gnus-summary-position-point)))
6190 (defun gnus-summary-pop-limit (&optional total)
6191 "Restore the previous limit.
6192 If given a prefix, remove all limits."
6195 (setq gnus-newsgroup-limits
6196 (list (mapcar (lambda (h) (mail-header-number h))
6197 gnus-newsgroup-headers))))
6198 (unless gnus-newsgroup-limits
6199 (error "No limit to pop"))
6201 (gnus-summary-limit nil 'pop)
6202 (gnus-summary-position-point)))
6204 (defun gnus-summary-limit-to-subject (subject &optional header)
6205 "Limit the summary buffer to articles that have subjects that match a regexp."
6206 (interactive "sLimit to subject (regexp): ")
6208 (setq header "subject"))
6209 (when (not (equal "" subject))
6211 (let ((articles (gnus-summary-find-matching
6212 (or header "subject") subject 'all)))
6214 (error "Found no matches for \"%s\"" subject))
6215 (gnus-summary-limit articles))
6216 (gnus-summary-position-point))))
6218 (defun gnus-summary-limit-to-author (from)
6219 "Limit the summary buffer to articles that have authors that match a regexp."
6220 (interactive "sLimit to author (regexp): ")
6221 (gnus-summary-limit-to-subject from "from"))
6223 (defun gnus-summary-limit-to-age (age &optional younger-p)
6224 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6225 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6226 articles that are younger than AGE days."
6228 (let ((younger current-prefix-arg)
6231 (while (not days-got)
6232 (setq days (if younger
6233 (read-string "Limit to articles within (in days): ")
6234 (read-string "Limit to articles old than (in days): ")))
6235 (when (> (length days) 0)
6236 (setq days (read days)))
6239 (message "Please enter a number.")
6241 (list days younger)))
6243 (let ((data gnus-newsgroup-data)
6244 (cutoff (days-to-time age))
6245 articles d date is-younger)
6246 (while (setq d (pop data))
6247 (when (and (vectorp (gnus-data-header d))
6248 (setq date (mail-header-date (gnus-data-header d))))
6249 (setq is-younger (time-less-p
6250 (time-since (condition-case ()
6257 (push (gnus-data-number d) articles))))
6258 (gnus-summary-limit (nreverse articles)))
6259 (gnus-summary-position-point)))
6261 (defun gnus-summary-limit-to-extra (header regexp)
6262 "Limit the summary buffer to articles that match an 'extra' header."
6266 (gnus-completing-read
6267 (symbol-name (car gnus-extra-headers))
6268 "Limit extra header:"
6270 (cons (symbol-name x) x))
6275 (read-string (format "Limit to header %s (regexp): " header)))))
6276 (when (not (equal "" regexp))
6278 (let ((articles (gnus-summary-find-matching
6279 (cons 'extra header) regexp 'all)))
6281 (error "Found no matches for \"%s\"" regexp))
6282 (gnus-summary-limit articles))
6283 (gnus-summary-position-point))))
6285 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6287 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6289 (defun gnus-summary-limit-to-unread (&optional all)
6290 "Limit the summary buffer to articles that are not marked as read.
6291 If ALL is non-nil, limit strictly to unread articles."
6294 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6295 (gnus-summary-limit-to-marks
6296 ;; Concat all the marks that say that an article is read and have
6298 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6299 gnus-killed-mark gnus-kill-file-mark
6300 gnus-low-score-mark gnus-expirable-mark
6301 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6302 gnus-duplicate-mark gnus-souped-mark)
6305 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6306 (make-obsolete 'gnus-summary-delete-marked-with
6307 'gnus-summary-limit-exlude-marks)
6309 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6310 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6311 If REVERSE, limit the summary buffer to articles that are marked
6312 with MARKS. MARKS can either be a string of marks or a list of marks.
6313 Returns how many articles were removed."
6314 (interactive "sMarks: ")
6315 (gnus-summary-limit-to-marks marks t))
6317 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6318 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6319 If REVERSE (the prefix), limit the summary buffer to articles that are
6320 not marked with MARKS. MARKS can either be a string of marks or a
6322 Returns how many articles were removed."
6323 (interactive "sMarks: \nP")
6325 (let ((data gnus-newsgroup-data)
6326 (marks (if (listp marks) marks
6327 (append marks nil))) ; Transform to list.
6330 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6331 (memq (gnus-data-mark (car data)) marks))
6332 (push (gnus-data-number (car data)) articles))
6333 (setq data (cdr data)))
6334 (gnus-summary-limit articles))
6335 (gnus-summary-position-point)))
6337 (defun gnus-summary-limit-to-score (&optional score)
6338 "Limit to articles with score at or above SCORE."
6340 (setq score (if score
6341 (prefix-numeric-value score)
6342 (or gnus-summary-default-score 0)))
6343 (let ((data gnus-newsgroup-data)
6346 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6348 (push (gnus-data-number (car data)) articles))
6349 (setq data (cdr data)))
6351 (gnus-summary-limit articles)
6352 (gnus-summary-position-point))))
6354 (defun gnus-summary-limit-include-thread (id)
6355 "Display all the hidden articles that in the current thread."
6356 (interactive (list (mail-header-id (gnus-summary-article-header))))
6357 (let ((articles (gnus-articles-in-thread
6358 (gnus-id-to-thread (gnus-root-id id)))))
6360 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6361 (gnus-summary-position-point))))
6363 (defun gnus-summary-limit-include-dormant ()
6364 "Display all the hidden articles that are marked as dormant.
6365 Note that this command only works on a subset of the articles currently
6366 fetched for this group."
6368 (unless gnus-newsgroup-dormant
6369 (error "There are no dormant articles in this group"))
6371 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6372 (gnus-summary-position-point)))
6374 (defun gnus-summary-limit-exclude-dormant ()
6375 "Hide all dormant articles."
6378 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6379 (gnus-summary-position-point)))
6381 (defun gnus-summary-limit-exclude-childless-dormant ()
6382 "Hide all dormant articles that have no children."
6384 (let ((data (gnus-data-list t))
6385 articles d children)
6386 ;; Find all articles that are either not dormant or have
6388 (while (setq d (pop data))
6389 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6391 (gnus-article-children (gnus-data-number d)))
6394 (when (memq (car children) articles)
6399 (push (gnus-data-number d) articles)))
6402 (gnus-summary-limit articles)
6403 (gnus-summary-position-point))))
6405 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6406 "Mark all unread excluded articles as read.
6407 If ALL, mark even excluded ticked and dormants as read."
6409 (let ((articles (gnus-sorted-complement
6411 (mapcar (lambda (h) (mail-header-number h))
6412 gnus-newsgroup-headers)
6414 (sort gnus-newsgroup-limit '<)))
6416 (setq gnus-newsgroup-unreads
6417 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6419 (setq gnus-newsgroup-dormant nil
6420 gnus-newsgroup-marked nil
6421 gnus-newsgroup-reads
6423 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6424 gnus-newsgroup-reads))
6425 (while (setq article (pop articles))
6426 (unless (or (memq article gnus-newsgroup-dormant)
6427 (memq article gnus-newsgroup-marked))
6428 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6430 (defun gnus-summary-limit (articles &optional pop)
6432 ;; We pop the previous limit off the stack and use that.
6433 (setq articles (car gnus-newsgroup-limits)
6434 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6435 ;; We use the new limit, so we push the old limit on the stack.
6436 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6438 (setq gnus-newsgroup-limit articles)
6439 (let ((total (length gnus-newsgroup-data))
6440 (data (gnus-data-find-list (gnus-summary-article-number)))
6441 (gnus-summary-mark-below nil) ; Inhibit this.
6443 ;; This will do all the work of generating the new summary buffer
6444 ;; according to the new limit.
6445 (gnus-summary-prepare)
6446 ;; Hide any threads, possibly.
6447 (and gnus-show-threads
6448 gnus-thread-hide-subtree
6449 (gnus-summary-hide-all-threads))
6450 ;; Try to return to the article you were at, or one in the
6453 ;; We try to find some article after the current one.
6455 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6458 (setq data (cdr data))))
6460 ;; If there is no data, that means that we were after the last
6461 ;; article. The same goes when we can't find any articles
6462 ;; after the current one.
6463 (goto-char (point-max))
6464 (gnus-summary-find-prev))
6465 (gnus-set-mode-line 'summary)
6466 ;; We return how many articles were removed from the summary
6467 ;; buffer as a result of the new limit.
6468 (- total (length gnus-newsgroup-data))))
6470 (defsubst gnus-invisible-cut-children (threads)
6473 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6478 (defsubst gnus-cut-thread (thread)
6479 "Go forwards in the thread until we find an article that we want to display."
6480 (when (or (eq gnus-fetch-old-headers 'some)
6481 (eq gnus-fetch-old-headers 'invisible)
6482 (numberp gnus-fetch-old-headers)
6483 (eq gnus-build-sparse-threads 'some)
6484 (eq gnus-build-sparse-threads 'more))
6485 ;; Deal with old-fetched headers and sparse threads.
6489 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6490 (gnus-summary-article-ancient-p
6491 (mail-header-number (car thread))))
6492 (if (or (<= (length (cdr thread)) 1)
6493 (eq gnus-fetch-old-headers 'invisible))
6494 (setq gnus-newsgroup-limit
6495 (delq (mail-header-number (car thread))
6496 gnus-newsgroup-limit)
6497 thread (cadr thread))
6498 (when (gnus-invisible-cut-children (cdr thread))
6499 (let ((th (cdr thread)))
6501 (if (memq (mail-header-number (caar th))
6502 gnus-newsgroup-limit)
6503 (setq thread (car th)
6505 (setq th (cdr th))))))))))
6508 (defun gnus-cut-threads (threads)
6509 "Cut off all uninteresting articles from the beginning of threads."
6510 (when (or (eq gnus-fetch-old-headers 'some)
6511 (eq gnus-fetch-old-headers 'invisible)
6512 (numberp gnus-fetch-old-headers)
6513 (eq gnus-build-sparse-threads 'some)
6514 (eq gnus-build-sparse-threads 'more))
6517 (setcar th (gnus-cut-thread (car th)))
6518 (setq th (cdr th)))))
6519 ;; Remove nixed out threads.
6522 (defun gnus-summary-initial-limit (&optional show-if-empty)
6523 "Figure out what the initial limit is supposed to be on group entry.
6524 This entails weeding out unwanted dormants, low-scored articles,
6525 fetch-old-headers verbiage, and so on."
6526 ;; Most groups have nothing to remove.
6527 (if (or gnus-inhibit-limiting
6528 (and (null gnus-newsgroup-dormant)
6529 (not (eq gnus-fetch-old-headers 'some))
6530 (not (numberp gnus-fetch-old-headers))
6531 (not (eq gnus-fetch-old-headers 'invisible))
6532 (null gnus-summary-expunge-below)
6533 (not (eq gnus-build-sparse-threads 'some))
6534 (not (eq gnus-build-sparse-threads 'more))
6535 (null gnus-thread-expunge-below)
6536 (not gnus-use-nocem)))
6538 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6539 (setq gnus-newsgroup-limit nil)
6542 (unless (car (symbol-value node))
6543 ;; These threads have no parents -- they are roots.
6544 (let ((nodes (cdr (symbol-value node)))
6547 (if (and gnus-thread-expunge-below
6548 (< (gnus-thread-total-score (car nodes))
6549 gnus-thread-expunge-below))
6550 (gnus-expunge-thread (pop nodes))
6551 (setq thread (pop nodes))
6552 (gnus-summary-limit-children thread))))))
6553 gnus-newsgroup-dependencies)
6554 ;; If this limitation resulted in an empty group, we might
6555 ;; pop the previous limit and use it instead.
6556 (when (and (not gnus-newsgroup-limit)
6558 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6559 gnus-newsgroup-limit))
6561 (defun gnus-summary-limit-children (thread)
6562 "Return 1 if this subthread is visible and 0 if it is not."
6563 ;; First we get the number of visible children to this thread. This
6564 ;; is done by recursing down the thread using this function, so this
6565 ;; will really go down to a leaf article first, before slowly
6566 ;; working its way up towards the root.
6570 (apply '+ (mapcar 'gnus-summary-limit-children
6573 (number (mail-header-number (car thread)))
6576 (not (memq number gnus-newsgroup-marked))
6578 ;; If this article is dormant and has absolutely no visible
6579 ;; children, then this article isn't visible.
6580 (and (memq number gnus-newsgroup-dormant)
6582 ;; If this is "fetch-old-headered" and there is no
6583 ;; visible children, then we don't want this article.
6584 (and (or (eq gnus-fetch-old-headers 'some)
6585 (numberp gnus-fetch-old-headers))
6586 (gnus-summary-article-ancient-p number)
6588 ;; If this is "fetch-old-headered" and `invisible', then
6589 ;; we don't want this article.
6590 (and (eq gnus-fetch-old-headers 'invisible)
6591 (gnus-summary-article-ancient-p number))
6592 ;; If this is a sparsely inserted article with no children,
6593 ;; we don't want it.
6594 (and (eq gnus-build-sparse-threads 'some)
6595 (gnus-summary-article-sparse-p number)
6597 ;; If we use expunging, and this article is really
6598 ;; low-scored, then we don't want this article.
6599 (when (and gnus-summary-expunge-below
6601 (or (cdr (assq number gnus-newsgroup-scored))
6602 gnus-summary-default-score))
6603 gnus-summary-expunge-below))
6604 ;; We increase the expunge-tally here, but that has
6605 ;; nothing to do with the limits, really.
6606 (incf gnus-newsgroup-expunged-tally)
6607 ;; We also mark as read here, if that's wanted.
6608 (when (and gnus-summary-mark-below
6609 (< score gnus-summary-mark-below))
6610 (setq gnus-newsgroup-unreads
6611 (delq number gnus-newsgroup-unreads))
6612 (if gnus-newsgroup-auto-expire
6613 (push number gnus-newsgroup-expirable)
6614 (push (cons number gnus-low-score-mark)
6615 gnus-newsgroup-reads)))
6617 ;; Check NoCeM things.
6618 (if (and gnus-use-nocem
6619 (gnus-nocem-unwanted-article-p
6620 (mail-header-id (car thread))))
6622 (setq gnus-newsgroup-unreads
6623 (delq number gnus-newsgroup-unreads))
6625 ;; Nope, invisible article.
6627 ;; Ok, this article is to be visible, so we add it to the limit
6629 (push number gnus-newsgroup-limit)
6632 (defun gnus-expunge-thread (thread)
6633 "Mark all articles in THREAD as read."
6634 (let* ((number (mail-header-number (car thread))))
6635 (incf gnus-newsgroup-expunged-tally)
6636 ;; We also mark as read here, if that's wanted.
6637 (setq gnus-newsgroup-unreads
6638 (delq number gnus-newsgroup-unreads))
6639 (if gnus-newsgroup-auto-expire
6640 (push number gnus-newsgroup-expirable)
6641 (push (cons number gnus-low-score-mark)
6642 gnus-newsgroup-reads)))
6643 ;; Go recursively through all subthreads.
6644 (mapcar 'gnus-expunge-thread (cdr thread)))
6646 ;; Summary article oriented commands
6648 (defun gnus-summary-refer-parent-article (n)
6649 "Refer parent article N times.
6650 If N is negative, go to ancestor -N instead.
6651 The difference between N and the number of articles fetched is returned."
6655 (when (not (natnump n))
6660 (setq header (gnus-summary-article-header))
6661 (if (and (eq (mail-header-number header)
6662 (cdr gnus-article-current))
6663 (equal gnus-newsgroup-name
6664 (car gnus-article-current)))
6665 ;; If we try to find the parent of the currently
6666 ;; displayed article, then we take a look at the actual
6667 ;; References header, since this is slightly more
6668 ;; reliable than the References field we got from the
6671 (set-buffer gnus-original-article-buffer)
6672 (nnheader-narrow-to-headers)
6673 (unless (setq ref (message-fetch-field "references"))
6674 (setq ref (message-fetch-field "in-reply-to")))
6677 ;; It's not the current article, so we take a bet on
6678 ;; the value we got from the server.
6679 (mail-header-references header)))
6681 (not (equal ref "")))
6682 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6683 (gnus-message 1 "Couldn't find parent"))
6684 (gnus-message 1 "No references in article %d"
6685 (gnus-summary-article-number))
6688 (gnus-summary-position-point)
6691 (defun gnus-summary-refer-references ()
6692 "Fetch all articles mentioned in the References header.
6693 Return the number of articles fetched."
6695 (let ((ref (mail-header-references (gnus-summary-article-header)))
6696 (current (gnus-summary-article-number))
6700 (error "No References in the current article")
6701 ;; For each Message-ID in the References header...
6702 (while (string-match "<[^>]*>" ref)
6704 ;; ... fetch that article.
6705 (gnus-summary-refer-article
6706 (prog1 (match-string 0 ref)
6707 (setq ref (substring ref (match-end 0))))))
6708 (gnus-summary-goto-subject current)
6709 (gnus-summary-position-point)
6712 (defun gnus-summary-refer-thread (&optional limit)
6713 "Fetch all articles in the current thread.
6714 If LIMIT (the numerical prefix), fetch that many old headers instead
6715 of what's specified by the `gnus-refer-thread-limit' variable."
6717 (let ((id (mail-header-id (gnus-summary-article-header)))
6718 (limit (if limit (prefix-numeric-value limit)
6719 gnus-refer-thread-limit)))
6720 ;; We want to fetch LIMIT *old* headers, but we also have to
6721 ;; re-fetch all the headers in the current buffer, because many of
6722 ;; them may be undisplayed. So we adjust LIMIT.
6723 (when (numberp limit)
6724 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6725 (unless (eq gnus-fetch-old-headers 'invisible)
6726 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6727 ;; Retrieve the headers and read them in.
6728 (if (eq (gnus-retrieve-headers
6729 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6731 (gnus-build-all-threads)
6732 (error "Can't fetch thread from backends that don't support NOV"))
6733 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6734 (gnus-summary-limit-include-thread id)))
6736 (defun gnus-summary-refer-article (message-id)
6737 "Fetch an article specified by MESSAGE-ID."
6738 (interactive "sMessage-ID: ")
6739 (when (and (stringp message-id)
6740 (not (zerop (length message-id))))
6741 ;; Construct the correct Message-ID if necessary.
6742 ;; Suggested by tale@pawl.rpi.edu.
6743 (unless (string-match "^<" message-id)
6744 (setq message-id (concat "<" message-id)))
6745 (unless (string-match ">$" message-id)
6746 (setq message-id (concat message-id ">")))
6747 (let* ((header (gnus-id-to-header message-id))
6749 (gnus-summary-article-sparse-p
6750 (mail-header-number header))
6751 (memq (mail-header-number header)
6752 gnus-newsgroup-limit)))
6755 ;; If the article is present in the buffer we just go to it.
6757 (or (not (gnus-summary-article-sparse-p
6758 (mail-header-number header)))
6761 (gnus-summary-goto-article
6762 (mail-header-number header) nil t)
6764 (gnus-summary-update-article (mail-header-number header)))))
6766 ;; We fetch the article.
6768 (dolist (gnus-override-method
6769 (cond ((null gnus-refer-article-method)
6770 (list 'current gnus-select-method))
6771 ((consp (car gnus-refer-article-method))
6772 gnus-refer-article-method)
6774 (list gnus-refer-article-method))))
6775 (when (eq 'current gnus-override-method)
6776 (setq gnus-override-method gnus-current-select-method))
6777 (gnus-check-server gnus-override-method)
6778 ;; Fetch the header, and display the article.
6779 (when (setq number (gnus-summary-insert-subject message-id))
6780 (gnus-summary-select-article nil nil nil number)
6782 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
6784 (defun gnus-summary-edit-parameters ()
6785 "Edit the group parameters of the current group."
6787 (gnus-group-edit-group gnus-newsgroup-name 'params))
6789 (defun gnus-summary-customize-parameters ()
6790 "Customize the group parameters of the current group."
6792 (gnus-group-customize gnus-newsgroup-name))
6794 (defun gnus-summary-enter-digest-group (&optional force)
6795 "Enter an nndoc group based on the current article.
6796 If FORCE, force a digest interpretation. If not, try
6797 to guess what the document format is."
6799 (let ((conf gnus-current-window-configuration))
6801 (gnus-summary-select-article))
6802 (setq gnus-current-window-configuration conf)
6803 (let* ((name (format "%s-%d"
6804 (gnus-group-prefixed-name
6805 gnus-newsgroup-name (list 'nndoc ""))
6807 (set-buffer gnus-summary-buffer)
6808 gnus-current-article)))
6809 (ogroup gnus-newsgroup-name)
6810 (params (append (gnus-info-params (gnus-get-info ogroup))
6811 (list (cons 'to-group ogroup))
6812 (list (cons 'save-article-group ogroup))))
6813 (case-fold-search t)
6814 (buf (current-buffer))
6817 (set-buffer gnus-original-article-buffer)
6818 ;; Have the digest group inherit the main mail address of
6819 ;; the parent article.
6820 (when (setq to-address (or (message-fetch-field "reply-to")
6821 (message-fetch-field "from")))
6822 (setq params (append (list (cons 'to-address to-address)))))
6823 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6824 (insert-buffer-substring gnus-original-article-buffer)
6825 ;; Remove lines that may lead nndoc to misinterpret the
6828 (goto-char (point-min))
6829 (or (search-forward "\n\n" nil t) (point)))
6830 (goto-char (point-min))
6831 (delete-matching-lines "^Path:\\|^From ")
6834 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
6835 (gnus-newsgroup-ephemeral-ignored-charsets
6836 gnus-newsgroup-ignored-charsets))
6837 (gnus-group-read-ephemeral-group
6838 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6840 ,(if force 'mbox 'guess))) t))
6841 ;; Make all postings to this group go to the parent group.
6842 (nconc (gnus-info-params (gnus-get-info name))
6844 ;; Couldn't select this doc group.
6845 (switch-to-buffer buf)
6846 (gnus-set-global-variables)
6847 (gnus-configure-windows 'summary)
6848 (gnus-message 3 "Article couldn't be entered?"))
6849 (kill-buffer dig)))))
6851 (defun gnus-summary-read-document (n)
6852 "Open a new group based on the current article(s).
6853 This will allow you to read digests and other similar
6854 documents as newsgroups.
6855 Obeys the standard process/prefix convention."
6857 (let* ((articles (gnus-summary-work-articles n))
6858 (ogroup gnus-newsgroup-name)
6859 (params (append (gnus-info-params (gnus-get-info ogroup))
6860 (list (cons 'to-group ogroup))))
6861 article group egroup groups vgroup)
6862 (while (setq article (pop articles))
6863 (setq group (format "%s-%d" gnus-newsgroup-name article))
6864 (gnus-summary-remove-process-mark article)
6865 (when (gnus-summary-display-article article)
6868 (insert-buffer-substring gnus-original-article-buffer)
6869 ;; Remove some headers that may lead nndoc to make
6871 (message-narrow-to-head)
6872 (goto-char (point-min))
6873 (delete-matching-lines "^\\(Path\\):\\|^From ")
6876 (gnus-group-read-ephemeral-group
6877 group `(nndoc ,group (nndoc-address ,(current-buffer))
6878 (nndoc-article-type guess))
6881 ;; Make all postings to this group go to the parent group.
6882 (nconc (gnus-info-params (gnus-get-info egroup))
6884 (push egroup groups))
6885 ;; Couldn't select this doc group.
6886 (gnus-error 3 "Article couldn't be entered"))))))
6887 ;; Now we have selected all the documents.
6890 (error "None of the articles could be interpreted as documents"))
6891 ((gnus-group-read-ephemeral-group
6892 (setq vgroup (format
6893 "nnvirtual:%s-%s" gnus-newsgroup-name
6894 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6895 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6897 (cons (current-buffer) 'summary)))
6899 (error "Couldn't select virtual nndoc group")))))
6901 (defun gnus-summary-isearch-article (&optional regexp-p)
6902 "Do incremental search forward on the current article.
6903 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6905 (gnus-summary-select-article)
6906 (gnus-configure-windows 'article)
6907 (gnus-eval-in-buffer-window gnus-article-buffer
6910 (isearch-forward regexp-p))))
6912 (defun gnus-summary-search-article-forward (regexp &optional backward)
6913 "Search for an article containing REGEXP forward.
6914 If BACKWARD, search backward instead."
6917 (format "Search article %s (regexp%s): "
6918 (if current-prefix-arg "backward" "forward")
6919 (if gnus-last-search-regexp
6920 (concat ", default " gnus-last-search-regexp)
6922 current-prefix-arg))
6923 (if (string-equal regexp "")
6924 (setq regexp (or gnus-last-search-regexp ""))
6925 (setq gnus-last-search-regexp regexp))
6926 (if (gnus-summary-search-article regexp backward)
6927 (gnus-summary-show-thread)
6928 (error "Search failed: \"%s\"" regexp)))
6930 (defun gnus-summary-search-article-backward (regexp)
6931 "Search for an article containing REGEXP backward."
6934 (format "Search article backward (regexp%s): "
6935 (if gnus-last-search-regexp
6936 (concat ", default " gnus-last-search-regexp)
6938 (gnus-summary-search-article-forward regexp 'backward))
6940 (defun gnus-summary-search-article (regexp &optional backward)
6941 "Search for an article containing REGEXP.
6942 Optional argument BACKWARD means do search for backward.
6943 `gnus-select-article-hook' is not called during the search."
6944 ;; We have to require this here to make sure that the following
6945 ;; dynamic binding isn't shadowed by autoloading.
6946 (require 'gnus-async)
6948 (let ((gnus-select-article-hook nil) ;Disable hook.
6949 (gnus-article-prepare-hook nil)
6950 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6951 (gnus-use-article-prefetch nil)
6952 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
6953 (gnus-use-trees nil) ;Inhibit updating tree buffer.
6954 (sum (current-buffer))
6955 (gnus-display-mime-function nil)
6958 (gnus-save-hidden-threads
6959 (gnus-summary-select-article)
6960 (set-buffer gnus-article-buffer)
6964 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
6966 (re-search-backward regexp nil t)
6967 (re-search-forward regexp nil t))
6968 ;; We found the regexp.
6973 (get-buffer-window (current-buffer))
6977 (get-buffer-window (current-buffer))
6980 (setq point (point)))
6981 ;; We didn't find it, so we go to the next article.
6984 (while (eq found 'not)
6985 (if (not (if backward (gnus-summary-find-prev)
6986 (gnus-summary-find-next)))
6987 ;; No more articles.
6989 ;; Select the next article and adjust point.
6990 (unless (gnus-summary-article-sparse-p
6991 (gnus-summary-article-number))
6993 (gnus-summary-select-article)
6994 (set-buffer gnus-article-buffer)
6996 (goto-char (if backward (point-max) (point-min))))))))
6997 (gnus-message 7 ""))
6998 ;; Return whether we found the regexp.
6999 (when (eq found 'found)
7001 (gnus-summary-show-thread)
7002 (gnus-summary-goto-subject gnus-current-article)
7003 (gnus-summary-position-point)
7006 (defun gnus-summary-find-matching (header regexp &optional backward unread
7008 "Return a list of all articles that match REGEXP on HEADER.
7009 The search stars on the current article and goes forwards unless
7010 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
7011 If UNREAD is non-nil, only unread articles will
7012 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
7013 in the comparisons."
7014 (let ((data (if (eq backward 'all) gnus-newsgroup-data
7015 (gnus-data-find-list
7016 (gnus-summary-article-number) (gnus-data-list backward))))
7017 (case-fold-search (not not-case-fold))
7020 (if (eq (car header) 'extra)
7023 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
7025 (error "%s is an invalid header" header))
7026 (unless (fboundp (intern (concat "mail-header-" header)))
7027 (error "%s is not a valid header" header))
7028 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
7031 (and (or (not unread) ; We want all articles...
7032 (gnus-data-unread-p d)) ; Or just unreads.
7033 (vectorp (gnus-data-header d)) ; It's not a pseudo.
7034 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
7035 (push (gnus-data-number d) articles)) ; Success!
7036 (setq data (cdr data)))
7037 (nreverse articles)))
7039 (defun gnus-summary-execute-command (header regexp command &optional backward)
7040 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7041 If HEADER is an empty string (or nil), the match is done on the entire
7042 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7044 (list (let ((completion-ignore-case t))
7047 (mapcar (lambda (string) (list string))
7048 '("Number" "Subject" "From" "Lines" "Date"
7049 "Message-ID" "Xref" "References" "Body"))
7050 nil 'require-match))
7051 (read-string "Regexp: ")
7052 (read-key-sequence "Command: ")
7053 current-prefix-arg))
7054 (when (equal header "Body")
7056 ;; Hidden thread subtrees must be searched as well.
7057 (gnus-summary-show-all-threads)
7058 ;; We don't want to change current point nor window configuration.
7060 (save-window-excursion
7061 (gnus-message 6 "Executing %s..." (key-description command))
7062 ;; We'd like to execute COMMAND interactively so as to give arguments.
7063 (gnus-execute header regexp
7064 `(call-interactively ',(key-binding command))
7066 (gnus-message 6 "Executing %s...done" (key-description command)))))
7068 (defun gnus-summary-beginning-of-article ()
7069 "Scroll the article back to the beginning."
7071 (gnus-summary-select-article)
7072 (gnus-configure-windows 'article)
7073 (gnus-eval-in-buffer-window gnus-article-buffer
7075 (goto-char (point-min))
7076 (when gnus-page-broken
7077 (gnus-narrow-to-page))))
7079 (defun gnus-summary-end-of-article ()
7080 "Scroll to the end of the article."
7082 (gnus-summary-select-article)
7083 (gnus-configure-windows 'article)
7084 (gnus-eval-in-buffer-window gnus-article-buffer
7086 (goto-char (point-max))
7088 (when gnus-page-broken
7089 (gnus-narrow-to-page))))
7091 (defun gnus-summary-print-article (&optional filename n)
7092 "Generate and print a PostScript image of the N next (mail) articles.
7094 If N is negative, print the N previous articles. If N is nil and articles
7095 have been marked with the process mark, print these instead.
7097 If the optional first argument FILENAME is nil, send the image to the
7098 printer. If FILENAME is a string, save the PostScript image in a file with
7099 that name. If FILENAME is a number, prompt the user for the name of the file
7101 (interactive (list (ps-print-preprint current-prefix-arg)
7102 current-prefix-arg))
7103 (dolist (article (gnus-summary-work-articles n))
7104 (gnus-summary-select-article nil nil 'pseudo article)
7105 (gnus-eval-in-buffer-window gnus-article-buffer
7106 (let ((buffer (generate-new-buffer " *print*")))
7109 (copy-to-buffer buffer (point-min) (point-max))
7111 (gnus-article-delete-invisible-text)
7112 (let ((ps-left-header
7115 (mail-header-subject gnus-current-headers) ")")
7117 (mail-header-from gnus-current-headers) ")")))
7120 "/pagenumberstring load"
7122 (mail-header-date gnus-current-headers) ")"))))
7123 (gnus-run-hooks 'gnus-ps-print-hook)
7125 (ps-print-buffer-with-faces filename))))
7126 (kill-buffer buffer))))))
7128 (defun gnus-summary-show-article (&optional arg)
7129 "Force re-fetching of the current article.
7130 If ARG (the prefix) is a number, show the article with the charset
7131 defined in `gnus-summary-show-article-charset-alist', or the charset
7133 If ARG (the prefix) is non-nil and not a number, show the raw article
7134 without any article massaging functions being run."
7138 (let ((gnus-newsgroup-charset
7139 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
7140 (read-coding-system "Charset: ")))
7141 (gnus-newsgroup-ignored-charsets 'gnus-all))
7142 (gnus-summary-select-article nil 'force)))
7144 ;; Select the article the normal way.
7145 (gnus-summary-select-article nil 'force))
7147 ;; We have to require this here to make sure that the following
7148 ;; dynamic binding isn't shadowed by autoloading.
7149 (require 'gnus-async)
7151 ;; Bind the article treatment functions to nil.
7152 (let ((gnus-have-all-headers t)
7153 gnus-article-prepare-hook
7154 gnus-article-decode-hook
7155 gnus-display-mime-function
7158 ;; Destroy any MIME parts.
7159 (when (gnus-buffer-live-p gnus-article-buffer)
7161 (set-buffer gnus-article-buffer)
7162 (mm-destroy-parts gnus-article-mime-handles)))
7163 (gnus-summary-select-article nil 'force))))
7164 (gnus-summary-goto-subject gnus-current-article)
7165 (gnus-summary-position-point))
7167 (defun gnus-summary-verbose-headers (&optional arg)
7168 "Toggle permanent full header display.
7169 If ARG is a positive number, turn header display on.
7170 If ARG is a negative number, turn header display off."
7172 (setq gnus-show-all-headers
7173 (cond ((or (not (numberp arg))
7175 (not gnus-show-all-headers))
7178 (gnus-summary-show-article))
7180 (defun gnus-summary-toggle-header (&optional arg)
7181 "Show the headers if they are hidden, or hide them if they are shown.
7182 If ARG is a positive number, show the entire header.
7183 If ARG is a negative number, hide the unwanted header lines."
7186 (set-buffer gnus-article-buffer)
7188 (let* ((buffer-read-only nil)
7189 (inhibit-point-motion-hooks t)
7195 (article-narrow-to-head)
7196 (gnus-article-hidden-text-p 'headers))))
7197 (goto-char (point-min))
7198 (when (search-forward "\n\n" nil t)
7199 (delete-region (point-min) (1- (point))))
7200 (goto-char (point-min))
7202 (set-buffer gnus-original-article-buffer)
7203 (goto-char (point-min))
7204 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
7205 (insert-buffer-substring gnus-original-article-buffer 1 e)
7207 (narrow-to-region (point-min) (point))
7208 (article-decode-encoded-words)
7210 (let ((gnus-treat-hide-headers nil)
7211 (gnus-treat-hide-boring-headers nil))
7212 (gnus-treat-article 'head))
7213 (gnus-treat-article 'head)))))))
7215 (defun gnus-summary-show-all-headers ()
7216 "Make all header lines visible."
7218 (gnus-article-show-all-headers))
7220 (defun gnus-summary-caesar-message (&optional arg)
7221 "Caesar rotate the current article by 13.
7222 The numerical prefix specifies how many places to rotate each letter
7225 (gnus-summary-select-article)
7226 (let ((mail-header-separator ""))
7227 (gnus-eval-in-buffer-window gnus-article-buffer
7230 (let ((start (window-start))
7232 (message-caesar-buffer-body arg)
7233 (set-window-start (get-buffer-window (current-buffer)) start))))))
7235 (defun gnus-summary-stop-page-breaking ()
7236 "Stop page breaking in the current article."
7238 (gnus-summary-select-article)
7239 (gnus-eval-in-buffer-window gnus-article-buffer
7241 (when (gnus-visual-p 'page-marker)
7242 (let ((buffer-read-only nil))
7243 (gnus-remove-text-with-property 'gnus-prev)
7244 (gnus-remove-text-with-property 'gnus-next))
7245 (setq gnus-page-broken nil))))
7247 (defun gnus-summary-move-article (&optional n to-newsgroup
7248 select-method action)
7249 "Move the current article to a different newsgroup.
7250 If N is a positive number, move the N next articles.
7251 If N is a negative number, move the N previous articles.
7252 If N is nil and any articles have been marked with the process mark,
7253 move those articles instead.
7254 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7255 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7256 re-spool using this method.
7258 For this function to work, both the current newsgroup and the
7259 newsgroup that you want to move to have to support the `request-move'
7260 and `request-accept' functions."
7263 (setq action 'move))
7264 ;; Disable marking as read.
7265 (let (gnus-mark-article-hook)
7266 (save-window-excursion
7267 (gnus-summary-select-article)))
7268 ;; Check whether the source group supports the required functions.
7269 (cond ((and (eq action 'move)
7270 (not (gnus-check-backend-function
7271 'request-move-article gnus-newsgroup-name)))
7272 (error "The current group does not support article moving"))
7273 ((and (eq action 'crosspost)
7274 (not (gnus-check-backend-function
7275 'request-replace-article gnus-newsgroup-name)))
7276 (error "The current group does not support article editing")))
7277 (let ((articles (gnus-summary-work-articles n))
7278 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
7279 (names '((move "Move" "Moving")
7280 (copy "Copy" "Copying")
7281 (crosspost "Crosspost" "Crossposting")))
7282 (copy-buf (save-excursion
7283 (nnheader-set-temp-buffer " *copy article*")))
7284 art-group to-method new-xref article to-groups)
7285 (unless (assq action names)
7286 (error "Unknown action %s" action))
7287 ;; Read the newsgroup name.
7288 (when (and (not to-newsgroup)
7289 (not select-method))
7291 (gnus-read-move-group-name
7292 (cadr (assq action names))
7293 (symbol-value (intern (format "gnus-current-%s-group" action)))
7295 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
7296 (setq to-method (or select-method
7297 (gnus-group-name-to-method to-newsgroup)))
7298 ;; Check the method we are to move this article to...
7299 (unless (gnus-check-backend-function
7300 'request-accept-article (car to-method))
7301 (error "%s does not support article copying" (car to-method)))
7302 (unless (gnus-check-server to-method)
7303 (error "Can't open server %s" (car to-method)))
7304 (gnus-message 6 "%s to %s: %s..."
7305 (caddr (assq action names))
7306 (or (car select-method) to-newsgroup) articles)
7308 (setq article (pop articles))
7312 ;; Move the article.
7314 ;; Remove this article from future suppression.
7315 (gnus-dup-unsuppress-article article)
7316 (gnus-request-move-article
7317 article ; Article to move
7318 gnus-newsgroup-name ; From newsgroup
7319 (nth 1 (gnus-find-method-for-group
7320 gnus-newsgroup-name)) ; Server
7321 (list 'gnus-request-accept-article
7322 to-newsgroup (list 'quote select-method)
7323 (not articles) t) ; Accept form
7324 (not articles))) ; Only save nov last time
7325 ;; Copy the article.
7328 (set-buffer copy-buf)
7329 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
7330 (gnus-request-accept-article
7331 to-newsgroup select-method (not articles) t))))
7332 ;; Crosspost the article.
7333 ((eq action 'crosspost)
7334 (let ((xref (message-tokenize-header
7335 (mail-header-xref (gnus-summary-article-header article))
7337 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
7340 (setq xref (list (system-name))))
7343 (mapconcat 'identity
7344 (delete "Xref:" (delete new-xref xref))
7348 (set-buffer copy-buf)
7349 ;; First put the article in the destination group.
7350 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7351 (when (consp (setq art-group
7352 (gnus-request-accept-article
7353 to-newsgroup select-method (not articles))))
7354 (setq new-xref (concat new-xref " " (car art-group)
7355 ":" (cdr art-group)))
7356 ;; Now we have the new Xrefs header, so we insert
7357 ;; it and replace the new article.
7358 (nnheader-replace-header "Xref" new-xref)
7359 (gnus-request-replace-article
7360 (cdr art-group) to-newsgroup (current-buffer))
7364 (gnus-message 1 "Couldn't %s article %s: %s"
7365 (cadr (assq action names)) article
7366 (nnheader-get-report (car to-method))))
7367 ((and (eq art-group 'junk)
7369 (gnus-summary-mark-article article gnus-canceled-mark)
7370 (gnus-message 4 "Deleted article %s" article))
7372 (let* ((pto-group (gnus-group-prefixed-name
7373 (car art-group) to-method))
7375 (gnus-gethash pto-group gnus-newsrc-hashtb))
7376 (info (nth 2 entry))
7377 (to-group (gnus-info-group info))
7379 ;; Update the group that has been moved to.
7381 (memq action '(move copy)))
7382 (unless (member to-group to-groups)
7383 (push to-group to-groups))
7385 (unless (memq article gnus-newsgroup-unreads)
7386 (push 'read to-marks)
7388 info (gnus-add-to-range (gnus-info-read info)
7389 (list (cdr art-group)))))
7391 ;; Copy any marks over to the new group.
7392 (let ((marks gnus-article-mark-lists)
7393 (to-article (cdr art-group)))
7395 ;; See whether the article is to be put in the cache.
7396 (when gnus-use-cache
7397 (gnus-cache-possibly-enter-article
7399 (memq article gnus-newsgroup-marked)
7400 (memq article gnus-newsgroup-dormant)
7401 (memq article gnus-newsgroup-unreads)))
7403 (when (and (equal to-group gnus-newsgroup-name)
7404 (not (memq article gnus-newsgroup-unreads)))
7405 ;; Mark this article as read in this group.
7406 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7407 (setcdr (gnus-active to-group) to-article)
7408 (setcdr gnus-newsgroup-active to-article))
7411 (when (memq article (symbol-value
7412 (intern (format "gnus-newsgroup-%s"
7414 (push (cdar marks) to-marks)
7415 ;; If the other group is the same as this group,
7416 ;; then we have to add the mark to the list.
7417 (when (equal to-group gnus-newsgroup-name)
7418 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7421 (intern (format "gnus-newsgroup-%s"
7423 ;; Copy the marks to other group.
7424 (gnus-add-marked-articles
7425 to-group (cdar marks) (list to-article) info))
7426 (setq marks (cdr marks)))
7428 (gnus-request-set-mark to-group (list (list (list to-article)
7433 (concat "(gnus-group-set-info '"
7434 (gnus-prin1-to-string (gnus-get-info to-group))
7437 ;; Update the Xref header in this article to point to
7438 ;; the new crossposted article we have just created.
7439 (when (eq action 'crosspost)
7441 (set-buffer copy-buf)
7442 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7443 (nnheader-replace-header "Xref" new-xref)
7444 (gnus-request-replace-article
7445 article gnus-newsgroup-name (current-buffer)))))
7447 ;;;!!!Why is this necessary?
7448 (set-buffer gnus-summary-buffer)
7450 (gnus-summary-goto-subject article)
7451 (when (eq action 'move)
7452 (gnus-summary-mark-article article gnus-canceled-mark))))
7453 (gnus-summary-remove-process-mark article))
7454 ;; Re-activate all groups that have been moved to.
7457 (set-buffer gnus-group-buffer)
7458 (when (gnus-group-goto-group (car to-groups) t)
7459 (gnus-group-get-new-news-this-group 1 t))
7462 (gnus-kill-buffer copy-buf)
7463 (gnus-summary-position-point)
7464 (gnus-set-mode-line 'summary)))
7466 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7467 "Move the current article to a different newsgroup.
7468 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7469 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7470 re-spool using this method."
7472 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7474 (defun gnus-summary-crosspost-article (&optional n)
7475 "Crosspost the current article to some other group."
7477 (gnus-summary-move-article n nil nil 'crosspost))
7479 (defcustom gnus-summary-respool-default-method nil
7480 "Default method for respooling an article.
7481 If nil, use to the current newsgroup method."
7482 :type '(choice (gnus-select-method :value (nnml ""))
7484 :group 'gnus-summary-mail)
7486 (defun gnus-summary-respool-article (&optional n method)
7487 "Respool the current article.
7488 The article will be squeezed through the mail spooling process again,
7489 which means that it will be put in some mail newsgroup or other
7490 depending on `nnmail-split-methods'.
7491 If N is a positive number, respool the N next articles.
7492 If N is a negative number, respool the N previous articles.
7493 If N is nil and any articles have been marked with the process mark,
7494 respool those articles instead.
7496 Respooling can be done both from mail groups and \"real\" newsgroups.
7497 In the former case, the articles in question will be moved from the
7498 current group into whatever groups they are destined to. In the
7499 latter case, they will be copied into the relevant groups."
7501 (list current-prefix-arg
7502 (let* ((methods (gnus-methods-using 'respool))
7504 (symbol-name (or gnus-summary-respool-default-method
7505 (car (gnus-find-method-for-group
7506 gnus-newsgroup-name)))))
7508 (gnus-completing-read
7509 methname "What backend do you want to use when respooling?"
7510 methods nil t nil 'gnus-mail-method-history))
7513 ((zerop (length (setq ms (gnus-servers-using-backend
7515 (list (intern method) ""))
7519 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7520 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7523 (error "No method given for respooling"))
7524 (if (assoc (symbol-name
7525 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7526 (gnus-methods-using 'respool))
7527 (gnus-summary-move-article n nil method)
7528 (gnus-summary-copy-article n nil method)))
7530 (defun gnus-summary-import-article (file)
7531 "Import an arbitrary file into a mail newsgroup."
7532 (interactive "fImport file: ")
7533 (let ((group gnus-newsgroup-name)
7534 (now (current-time))
7536 (unless (gnus-check-backend-function 'request-accept-article group)
7537 (error "%s does not support article importing" group))
7538 (or (file-readable-p file)
7539 (not (file-regular-p file))
7540 (error "Can't read %s" file))
7542 (set-buffer (gnus-get-buffer-create " *import file*"))
7544 (insert-file-contents file)
7545 (goto-char (point-min))
7546 (unless (nnheader-article-p)
7547 ;; This doesn't look like an article, so we fudge some headers.
7548 (setq atts (file-attributes file)
7549 lines (count-lines (point-min) (point-max)))
7550 (insert "From: " (read-string "From: ") "\n"
7551 "Subject: " (read-string "Subject: ") "\n"
7552 "Date: " (message-make-date (nth 5 atts))
7554 "Message-ID: " (message-make-message-id) "\n"
7555 "Lines: " (int-to-string lines) "\n"
7556 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7557 (gnus-request-accept-article group nil t)
7558 (kill-buffer (current-buffer)))))
7560 (defun gnus-summary-article-posted-p ()
7561 "Say whether the current (mail) article is available from `gnus-select-method' as well.
7562 This will be the case if the article has both been mailed and posted."
7564 (let ((id (mail-header-references (gnus-summary-article-header)))
7565 (gnus-override-method
7566 (or gnus-refer-article-method gnus-select-method)))
7567 (if (gnus-request-head id "")
7568 (gnus-message 2 "The current message was found on %s"
7569 gnus-override-method)
7570 (gnus-message 2 "The current message couldn't be found on %s"
7571 gnus-override-method)
7574 (defun gnus-summary-expire-articles (&optional now)
7575 "Expire all articles that are marked as expirable in the current group."
7577 (when (gnus-check-backend-function
7578 'request-expire-articles gnus-newsgroup-name)
7579 ;; This backend supports expiry.
7580 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7581 (expirable (if total
7583 ;; We need to update the info for
7584 ;; this group for `gnus-list-of-read-articles'
7585 ;; to give us the right answer.
7586 (gnus-run-hooks 'gnus-exit-group-hook)
7587 (gnus-summary-update-info)
7588 (gnus-list-of-read-articles gnus-newsgroup-name))
7589 (setq gnus-newsgroup-expirable
7590 (sort gnus-newsgroup-expirable '<))))
7591 (expiry-wait (if now 'immediate
7592 (gnus-group-find-parameter
7593 gnus-newsgroup-name 'expiry-wait)))
7596 ;; There are expirable articles in this group, so we run them
7597 ;; through the expiry process.
7598 (gnus-message 6 "Expiring articles...")
7599 (unless (gnus-check-group gnus-newsgroup-name)
7600 (error "Can't open server for %s" gnus-newsgroup-name))
7601 ;; The list of articles that weren't expired is returned.
7604 (let ((nnmail-expiry-wait-function nil)
7605 (nnmail-expiry-wait expiry-wait))
7606 (setq es (gnus-request-expire-articles
7607 expirable gnus-newsgroup-name)))
7608 (setq es (gnus-request-expire-articles
7609 expirable gnus-newsgroup-name))))
7611 (setq gnus-newsgroup-expirable es))
7612 ;; We go through the old list of expirable, and mark all
7613 ;; really expired articles as nonexistent.
7614 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7615 (let ((gnus-use-cache nil))
7617 (unless (memq (car expirable) es)
7618 (when (gnus-data-find (car expirable))
7619 (gnus-summary-mark-article
7620 (car expirable) gnus-canceled-mark)))
7621 (setq expirable (cdr expirable)))))
7622 (gnus-message 6 "Expiring articles...done")))))
7624 (defun gnus-summary-expire-articles-now ()
7625 "Expunge all expirable articles in the current group.
7626 This means that *all* articles that are marked as expirable will be
7627 deleted forever, right now."
7629 (or gnus-expert-user
7631 "Are you really, really, really sure you want to delete all these messages? ")
7633 (gnus-summary-expire-articles t))
7635 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7636 (defun gnus-summary-delete-article (&optional n)
7637 "Delete the N next (mail) articles.
7638 This command actually deletes articles. This is not a marking
7639 command. The article will disappear forever from your life, never to
7641 If N is negative, delete backwards.
7642 If N is nil and articles have been marked with the process mark,
7643 delete these instead."
7645 (unless (gnus-check-backend-function 'request-expire-articles
7646 gnus-newsgroup-name)
7647 (error "The current newsgroup does not support article deletion"))
7648 ;; Compute the list of articles to delete.
7649 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
7651 (if (and gnus-novice-user
7652 (not (gnus-yes-or-no-p
7653 (format "Do you really want to delete %s forever? "
7654 (if (> (length articles) 1)
7655 (format "these %s articles" (length articles))
7658 ;; Delete the articles.
7659 (setq not-deleted (gnus-request-expire-articles
7660 articles gnus-newsgroup-name 'force))
7662 (gnus-summary-remove-process-mark (car articles))
7663 ;; The backend might not have been able to delete the article
7665 (unless (memq (car articles) not-deleted)
7666 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7667 (setq articles (cdr articles)))
7669 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7670 (gnus-summary-position-point)
7671 (gnus-set-mode-line 'summary)
7674 (defun gnus-summary-edit-article (&optional force)
7675 "Edit the current article.
7676 This will have permanent effect only in mail groups.
7677 If FORCE is non-nil, allow editing of articles even in read-only
7681 (set-buffer gnus-summary-buffer)
7682 (let ((mail-parse-charset gnus-newsgroup-charset)
7683 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
7684 (gnus-set-global-variables)
7685 (when (and (not force)
7686 (gnus-group-read-only-p))
7687 (error "The current newsgroup does not support article editing"))
7688 (gnus-summary-show-article t)
7689 (gnus-article-edit-article
7691 `(lambda (no-highlight)
7692 (let ((mail-parse-charset ',gnus-newsgroup-charset)
7693 (mail-parse-ignored-charsets
7694 ',gnus-newsgroup-ignored-charsets))
7696 (gnus-summary-edit-article-done
7697 ,(or (mail-header-references gnus-current-headers) "")
7698 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
7700 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7702 (defun gnus-summary-edit-article-done (&optional references read-only buffer
7704 "Make edits to the current article permanent."
7706 ;; Replace the article.
7707 (let ((buf (current-buffer)))
7709 (insert-buffer-substring buf)
7710 (if (and (not read-only)
7711 (not (gnus-request-replace-article
7712 (cdr gnus-article-current) (car gnus-article-current)
7713 (current-buffer) t)))
7714 (error "Couldn't replace article")
7715 ;; Update the summary buffer.
7717 (equal (message-tokenize-header references " ")
7718 (message-tokenize-header
7719 (or (message-fetch-field "references") "") " ")))
7720 ;; We only have to update this line.
7723 (message-narrow-to-head)
7724 (let ((head (buffer-string))
7727 (insert (format "211 %d Article retrieved.\n"
7728 (cdr gnus-article-current)))
7731 (let ((nntp-server-buffer (current-buffer)))
7732 (setq header (car (gnus-get-newsgroup-headers
7734 (set-buffer gnus-summary-buffer)
7735 gnus-newsgroup-dependencies)
7738 (set-buffer gnus-summary-buffer)
7739 (gnus-data-set-header
7740 (gnus-data-find (cdr gnus-article-current))
7742 (gnus-summary-update-article-line
7743 (cdr gnus-article-current) header))))))
7745 (set-buffer (or buffer gnus-summary-buffer))
7746 (gnus-summary-update-article (cdr gnus-article-current)))
7747 ;; Prettify the article buffer again.
7748 (unless no-highlight
7750 (set-buffer gnus-article-buffer)
7751 ;;;!!! Fix this -- article should be rehighlighted.
7752 ;;;(gnus-run-hooks 'gnus-article-display-hook)
7753 (set-buffer gnus-original-article-buffer)
7754 (gnus-request-article
7755 (cdr gnus-article-current)
7756 (car gnus-article-current) (current-buffer))))
7757 ;; Prettify the summary buffer line.
7758 (when (gnus-visual-p 'summary-highlight 'highlight)
7759 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
7761 (defun gnus-summary-edit-wash (key)
7762 "Perform editing command KEY in the article buffer."
7766 (message "%s" (concat (this-command-keys) "- "))
7769 (gnus-summary-edit-article)
7770 (execute-kbd-macro (concat (this-command-keys) key))
7771 (gnus-article-edit-done))
7775 (defun gnus-summary-respool-query (&optional silent trace)
7776 "Query where the respool algorithm would put this article."
7778 (let (gnus-mark-article-hook)
7779 (gnus-summary-select-article)
7781 (set-buffer gnus-original-article-buffer)
7783 (message-narrow-to-head)
7784 (let ((groups (nnmail-article-group 'identity trace)))
7787 (message "This message would go to %s"
7788 (mapconcat 'car groups ", "))
7789 (message "This message would go to no groups"))
7792 (defun gnus-summary-respool-trace ()
7793 "Trace where the respool algorithm would put this article.
7794 Display a buffer showing all fancy splitting patterns which matched."
7796 (gnus-summary-respool-query nil t))
7798 ;; Summary marking commands.
7800 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
7801 "Mark articles which has the same subject as read, and then select the next.
7802 If UNMARK is positive, remove any kind of mark.
7803 If UNMARK is negative, tick articles."
7806 (setq unmark (prefix-numeric-value unmark)))
7808 (gnus-summary-mark-same-subject
7809 (gnus-summary-article-subject) unmark)))
7810 ;; Select next unread article. If auto-select-same mode, should
7811 ;; select the first unread article.
7812 (gnus-summary-next-article t (and gnus-auto-select-same
7813 (gnus-summary-article-subject)))
7814 (gnus-message 7 "%d article%s marked as %s"
7815 count (if (= count 1) " is" "s are")
7816 (if unmark "unread" "read"))))
7818 (defun gnus-summary-kill-same-subject (&optional unmark)
7819 "Mark articles which has the same subject as read.
7820 If UNMARK is positive, remove any kind of mark.
7821 If UNMARK is negative, tick articles."
7824 (setq unmark (prefix-numeric-value unmark)))
7826 (gnus-summary-mark-same-subject
7827 (gnus-summary-article-subject) unmark)))
7828 ;; If marked as read, go to next unread subject.
7830 ;; Go to next unread subject.
7831 (gnus-summary-next-subject 1 t))
7832 (gnus-message 7 "%d articles are marked as %s"
7833 count (if unmark "unread" "read"))))
7835 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7836 "Mark articles with same SUBJECT as read, and return marked number.
7837 If optional argument UNMARK is positive, remove any kinds of marks.
7838 If optional argument UNMARK is negative, mark articles as unread instead."
7842 ((null unmark) ; Mark as read.
7845 (gnus-summary-mark-article-as-read gnus-killed-mark)
7846 (gnus-summary-show-thread) t)
7847 (gnus-summary-find-subject subject))
7848 (setq count (1+ count))))
7849 ((> unmark 0) ; Tick.
7852 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
7853 (gnus-summary-show-thread) t)
7854 (gnus-summary-find-subject subject))
7855 (setq count (1+ count))))
7856 (t ; Mark as unread.
7859 (gnus-summary-mark-article-as-unread gnus-unread-mark)
7860 (gnus-summary-show-thread) t)
7861 (gnus-summary-find-subject subject))
7862 (setq count (1+ count)))))
7863 (gnus-set-mode-line 'summary)
7864 ;; Return the number of marked articles.
7867 (defun gnus-summary-mark-as-processable (n &optional unmark)
7868 "Set the process mark on the next N articles.
7869 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7870 the process mark instead. The difference between N and the actual
7871 number of articles marked is returned."
7873 (let ((backward (< n 0))
7878 (gnus-summary-remove-process-mark
7879 (gnus-summary-article-number))
7880 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7881 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7884 (gnus-message 7 "No more articles"))
7885 (gnus-summary-recenter)
7886 (gnus-summary-position-point)
7889 (defun gnus-summary-unmark-as-processable (n)
7890 "Remove the process mark from the next N articles.
7891 If N is negative, unmark backward instead. The difference between N and
7892 the actual number of articles unmarked is returned."
7894 (gnus-summary-mark-as-processable n t))
7896 (defun gnus-summary-unmark-all-processable ()
7897 "Remove the process mark from all articles."
7900 (while gnus-newsgroup-processable
7901 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7902 (gnus-summary-position-point))
7904 (defun gnus-summary-mark-as-expirable (n)
7905 "Mark N articles forward as expirable.
7906 If N is negative, mark backward instead. The difference between N and
7907 the actual number of articles marked is returned."
7909 (gnus-summary-mark-forward n gnus-expirable-mark))
7911 (defun gnus-summary-mark-article-as-replied (article)
7912 "Mark ARTICLE replied and update the summary line."
7913 (push article gnus-newsgroup-replied)
7914 (let ((buffer-read-only nil))
7915 (when (gnus-summary-goto-subject article nil t)
7916 (gnus-summary-update-secondary-mark article))))
7918 (defun gnus-summary-set-bookmark (article)
7919 "Set a bookmark in current article."
7920 (interactive (list (gnus-summary-article-number)))
7921 (when (or (not (get-buffer gnus-article-buffer))
7922 (not gnus-current-article)
7923 (not gnus-article-current)
7924 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7925 (error "No current article selected"))
7926 ;; Remove old bookmark, if one exists.
7927 (let ((old (assq article gnus-newsgroup-bookmarks)))
7929 (setq gnus-newsgroup-bookmarks
7930 (delq old gnus-newsgroup-bookmarks))))
7931 ;; Set the new bookmark, which is on the form
7932 ;; (article-number . line-number-in-body).
7936 (set-buffer gnus-article-buffer)
7940 (goto-char (point-min))
7941 (search-forward "\n\n" nil t)
7944 gnus-newsgroup-bookmarks)
7945 (gnus-message 6 "A bookmark has been added to the current article."))
7947 (defun gnus-summary-remove-bookmark (article)
7948 "Remove the bookmark from the current article."
7949 (interactive (list (gnus-summary-article-number)))
7950 ;; Remove old bookmark, if one exists.
7951 (let ((old (assq article gnus-newsgroup-bookmarks)))
7954 (setq gnus-newsgroup-bookmarks
7955 (delq old gnus-newsgroup-bookmarks))
7956 (gnus-message 6 "Removed bookmark."))
7957 (gnus-message 6 "No bookmark in current article."))))
7959 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7960 (defun gnus-summary-mark-as-dormant (n)
7961 "Mark N articles forward as dormant.
7962 If N is negative, mark backward instead. The difference between N and
7963 the actual number of articles marked is returned."
7965 (gnus-summary-mark-forward n gnus-dormant-mark))
7967 (defun gnus-summary-set-process-mark (article)
7968 "Set the process mark on ARTICLE and update the summary line."
7969 (setq gnus-newsgroup-processable
7971 (delq article gnus-newsgroup-processable)))
7972 (when (gnus-summary-goto-subject article)
7973 (gnus-summary-show-thread)
7974 (gnus-summary-goto-subject article)
7975 (gnus-summary-update-secondary-mark article)))
7977 (defun gnus-summary-remove-process-mark (article)
7978 "Remove the process mark from ARTICLE and update the summary line."
7979 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7980 (when (gnus-summary-goto-subject article)
7981 (gnus-summary-show-thread)
7982 (gnus-summary-goto-subject article)
7983 (gnus-summary-update-secondary-mark article)))
7985 (defun gnus-summary-set-saved-mark (article)
7986 "Set the process mark on ARTICLE and update the summary line."
7987 (push article gnus-newsgroup-saved)
7988 (when (gnus-summary-goto-subject article)
7989 (gnus-summary-update-secondary-mark article)))
7991 (defun gnus-summary-mark-forward (n &optional mark no-expire)
7992 "Mark N articles as read forwards.
7993 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
7994 The difference between N and the actual number of articles marked is
7997 (gnus-summary-show-thread)
7998 (let ((backward (< n 0))
7999 (gnus-summary-goto-unread
8000 (and gnus-summary-goto-unread
8001 (not (eq gnus-summary-goto-unread 'never))
8002 (not (memq mark (list gnus-unread-mark
8003 gnus-ticked-mark gnus-dormant-mark)))))
8005 (mark (or mark gnus-del-mark)))
8007 (gnus-summary-mark-article nil mark no-expire)
8008 (zerop (gnus-summary-next-subject
8010 (and gnus-summary-goto-unread
8011 (not (eq gnus-summary-goto-unread 'never)))
8015 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
8016 (gnus-summary-recenter)
8017 (gnus-summary-position-point)
8018 (gnus-set-mode-line 'summary)
8021 (defun gnus-summary-mark-article-as-read (mark)
8022 "Mark the current article quickly as read with MARK."
8023 (let ((article (gnus-summary-article-number)))
8024 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8025 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8026 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8027 (push (cons article mark) gnus-newsgroup-reads)
8028 ;; Possibly remove from cache, if that is used.
8029 (when gnus-use-cache
8030 (gnus-cache-enter-remove-article article))
8031 ;; Allow the backend to change the mark.
8032 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8033 ;; Check for auto-expiry.
8034 (when (and gnus-newsgroup-auto-expire
8035 (memq mark gnus-auto-expirable-marks))
8036 (setq mark gnus-expirable-mark)
8037 ;; Let the backend know about the mark change.
8038 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8039 (push article gnus-newsgroup-expirable))
8040 ;; Set the mark in the buffer.
8041 (gnus-summary-update-mark mark 'unread)
8044 (defun gnus-summary-mark-article-as-unread (mark)
8045 "Mark the current article quickly as unread with MARK."
8046 (let* ((article (gnus-summary-article-number))
8047 (old-mark (gnus-summary-article-mark article)))
8048 ;; Allow the backend to change the mark.
8049 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8050 (if (eq mark old-mark)
8054 (gnus-error 1 "Can't mark negative article numbers")
8056 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8057 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8058 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
8059 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
8060 (cond ((= mark gnus-ticked-mark)
8061 (push article gnus-newsgroup-marked))
8062 ((= mark gnus-dormant-mark)
8063 (push article gnus-newsgroup-dormant))
8065 (push article gnus-newsgroup-unreads)))
8066 (gnus-pull article gnus-newsgroup-reads)
8068 ;; See whether the article is to be put in the cache.
8070 (vectorp (gnus-summary-article-header article))
8072 (gnus-cache-possibly-enter-article
8073 gnus-newsgroup-name article
8074 (= mark gnus-ticked-mark)
8075 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8078 (gnus-summary-update-mark mark 'unread)
8081 (defun gnus-summary-mark-article (&optional article mark no-expire)
8082 "Mark ARTICLE with MARK. MARK can be any character.
8083 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
8084 `??' (dormant) and `?E' (expirable).
8085 If MARK is nil, then the default character `?r' is used.
8086 If ARTICLE is nil, then the article on the current line will be
8088 ;; The mark might be a string.
8089 (when (stringp mark)
8090 (setq mark (aref mark 0)))
8091 ;; If no mark is given, then we check auto-expiring.
8093 (setq mark gnus-del-mark))
8094 (when (and (not no-expire)
8095 gnus-newsgroup-auto-expire
8096 (memq mark gnus-auto-expirable-marks))
8097 (setq mark gnus-expirable-mark))
8098 (let ((article (or article (gnus-summary-article-number)))
8099 (old-mark (gnus-summary-article-mark article)))
8100 ;; Allow the backend to change the mark.
8101 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8102 (if (eq mark old-mark)
8105 (error "No article on current line"))
8106 (if (not (if (or (= mark gnus-unread-mark)
8107 (= mark gnus-ticked-mark)
8108 (= mark gnus-dormant-mark))
8109 (gnus-mark-article-as-unread article mark)
8110 (gnus-mark-article-as-read article mark)))
8112 ;; See whether the article is to be put in the cache.
8114 (not (= mark gnus-canceled-mark))
8115 (vectorp (gnus-summary-article-header article))
8117 (gnus-cache-possibly-enter-article
8118 gnus-newsgroup-name article
8119 (= mark gnus-ticked-mark)
8120 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8122 (when (gnus-summary-goto-subject article nil t)
8123 (let ((buffer-read-only nil))
8124 (gnus-summary-show-thread)
8126 (gnus-summary-update-mark mark 'unread)
8129 (defun gnus-summary-update-secondary-mark (article)
8130 "Update the secondary (read, process, cache) mark."
8131 (gnus-summary-update-mark
8132 (cond ((memq article gnus-newsgroup-processable)
8134 ((memq article gnus-newsgroup-cached)
8136 ((memq article gnus-newsgroup-replied)
8138 ((memq article gnus-newsgroup-saved)
8140 (t gnus-unread-mark))
8142 (when (gnus-visual-p 'summary-highlight 'highlight)
8143 (gnus-run-hooks 'gnus-summary-update-hook))
8146 (defun gnus-summary-update-mark (mark type)
8147 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
8148 (buffer-read-only nil))
8149 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
8151 (when (looking-at "\r")
8153 (when (<= (+ forward (point)) (point-max))
8154 ;; Go to the right position on the line.
8155 (goto-char (+ forward (point)))
8156 ;; Replace the old mark with the new mark.
8157 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
8158 ;; Optionally update the marks by some user rule.
8159 (when (eq type 'unread)
8161 (gnus-data-find (gnus-summary-article-number)) mark)
8162 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
8164 (defun gnus-mark-article-as-read (article &optional mark)
8165 "Enter ARTICLE in the pertinent lists and remove it from others."
8166 ;; Make the article expirable.
8167 (let ((mark (or mark gnus-del-mark)))
8168 (if (= mark gnus-expirable-mark)
8169 (push article gnus-newsgroup-expirable)
8170 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
8171 ;; Remove from unread and marked lists.
8172 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8173 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8174 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8175 (push (cons article mark) gnus-newsgroup-reads)
8176 ;; Possibly remove from cache, if that is used.
8177 (when gnus-use-cache
8178 (gnus-cache-enter-remove-article article))
8181 (defun gnus-mark-article-as-unread (article &optional mark)
8182 "Enter ARTICLE in the pertinent lists and remove it from others."
8183 (let ((mark (or mark gnus-ticked-mark)))
8186 (gnus-error 1 "Can't mark negative article numbers")
8188 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
8189 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
8190 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
8191 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8193 ;; Unsuppress duplicates?
8194 (when gnus-suppress-duplicates
8195 (gnus-dup-unsuppress-article article))
8197 (cond ((= mark gnus-ticked-mark)
8198 (push article gnus-newsgroup-marked))
8199 ((= mark gnus-dormant-mark)
8200 (push article gnus-newsgroup-dormant))
8202 (push article gnus-newsgroup-unreads)))
8203 (gnus-pull article gnus-newsgroup-reads)
8206 (defalias 'gnus-summary-mark-as-unread-forward
8207 'gnus-summary-tick-article-forward)
8208 (make-obsolete 'gnus-summary-mark-as-unread-forward
8209 'gnus-summary-tick-article-forward)
8210 (defun gnus-summary-tick-article-forward (n)
8211 "Tick N articles forwards.
8212 If N is negative, tick backwards instead.
8213 The difference between N and the number of articles ticked is returned."
8215 (gnus-summary-mark-forward n gnus-ticked-mark))
8217 (defalias 'gnus-summary-mark-as-unread-backward
8218 'gnus-summary-tick-article-backward)
8219 (make-obsolete 'gnus-summary-mark-as-unread-backward
8220 'gnus-summary-tick-article-backward)
8221 (defun gnus-summary-tick-article-backward (n)
8222 "Tick N articles backwards.
8223 The difference between N and the number of articles ticked is returned."
8225 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
8227 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8228 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8229 (defun gnus-summary-tick-article (&optional article clear-mark)
8230 "Mark current article as unread.
8231 Optional 1st argument ARTICLE specifies article number to be marked as unread.
8232 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
8234 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
8237 (defun gnus-summary-mark-as-read-forward (n)
8238 "Mark N articles as read forwards.
8239 If N is negative, mark backwards instead.
8240 The difference between N and the actual number of articles marked is
8243 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
8245 (defun gnus-summary-mark-as-read-backward (n)
8246 "Mark the N articles as read backwards.
8247 The difference between N and the actual number of articles marked is
8250 (gnus-summary-mark-forward
8251 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
8253 (defun gnus-summary-mark-as-read (&optional article mark)
8254 "Mark current article as read.
8255 ARTICLE specifies the article to be marked as read.
8256 MARK specifies a string to be inserted at the beginning of the line."
8257 (gnus-summary-mark-article article mark))
8259 (defun gnus-summary-clear-mark-forward (n)
8260 "Clear marks from N articles forward.
8261 If N is negative, clear backward instead.
8262 The difference between N and the number of marks cleared is returned."
8264 (gnus-summary-mark-forward n gnus-unread-mark))
8266 (defun gnus-summary-clear-mark-backward (n)
8267 "Clear marks from N articles backward.
8268 The difference between N and the number of marks cleared is returned."
8270 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8272 (defun gnus-summary-mark-unread-as-read ()
8273 "Intended to be used by `gnus-summary-mark-article-hook'."
8274 (when (memq gnus-current-article gnus-newsgroup-unreads)
8275 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
8277 (defun gnus-summary-mark-read-and-unread-as-read ()
8278 "Intended to be used by `gnus-summary-mark-article-hook'."
8279 (let ((mark (gnus-summary-article-mark)))
8280 (when (or (gnus-unread-mark-p mark)
8281 (gnus-read-mark-p mark))
8282 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
8284 (defun gnus-summary-mark-region-as-read (point mark all)
8285 "Mark all unread articles between point and mark as read.
8286 If given a prefix, mark all articles between point and mark as read,
8287 even ticked and dormant ones."
8288 (interactive "r\nP")
8297 (memq (setq article (gnus-summary-article-number))
8298 gnus-newsgroup-unreads))
8299 (gnus-summary-mark-article article gnus-del-mark))
8301 (gnus-summary-find-next))))))
8303 (defun gnus-summary-mark-below (score mark)
8304 "Mark articles with score less than SCORE with MARK."
8305 (interactive "P\ncMark: ")
8306 (setq score (if score
8307 (prefix-numeric-value score)
8308 (or gnus-summary-default-score 0)))
8310 (set-buffer gnus-summary-buffer)
8311 (goto-char (point-min))
8314 (and (< (gnus-summary-article-score) score)
8315 (gnus-summary-mark-article nil mark))
8316 (gnus-summary-find-next)))))
8318 (defun gnus-summary-kill-below (&optional score)
8319 "Mark articles with score below SCORE as read."
8321 (gnus-summary-mark-below score gnus-killed-mark))
8323 (defun gnus-summary-clear-above (&optional score)
8324 "Clear all marks from articles with score above SCORE."
8326 (gnus-summary-mark-above score gnus-unread-mark))
8328 (defun gnus-summary-tick-above (&optional score)
8329 "Tick all articles with score above SCORE."
8331 (gnus-summary-mark-above score gnus-ticked-mark))
8333 (defun gnus-summary-mark-above (score mark)
8334 "Mark articles with score over SCORE with MARK."
8335 (interactive "P\ncMark: ")
8336 (setq score (if score
8337 (prefix-numeric-value score)
8338 (or gnus-summary-default-score 0)))
8340 (set-buffer gnus-summary-buffer)
8341 (goto-char (point-min))
8343 (when (> (gnus-summary-article-score) score)
8344 (gnus-summary-mark-article nil mark))
8346 (gnus-summary-find-next)))))
8348 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8349 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
8350 (defun gnus-summary-limit-include-expunged (&optional no-error)
8351 "Display all the hidden articles that were expunged for low scores."
8353 (let ((buffer-read-only nil))
8354 (let ((scored gnus-newsgroup-scored)
8357 (unless (gnus-summary-goto-subject (caar scored))
8358 (and (setq h (gnus-summary-article-header (caar scored)))
8359 (< (cdar scored) gnus-summary-expunge-below)
8361 (setq scored (cdr scored)))
8363 (when (not no-error)
8364 (error "No expunged articles hidden"))
8365 (goto-char (point-min))
8366 (gnus-summary-prepare-unthreaded (nreverse headers))
8367 (goto-char (point-min))
8368 (gnus-summary-position-point)
8371 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
8372 "Mark all unread articles in this newsgroup as read.
8373 If prefix argument ALL is non-nil, ticked and dormant articles will
8374 also be marked as read.
8375 If QUIETLY is non-nil, no questions will be asked.
8376 If TO-HERE is non-nil, it should be a point in the buffer. All
8377 articles before this point will be marked as read.
8378 Note that this function will only catch up the unread article
8379 in the current summary buffer limitation.
8380 The number of articles marked as read is returned."
8385 (not gnus-interactive-catchup) ;Without confirmation?
8389 "Mark absolutely all articles as read? "
8390 "Mark all unread articles as read? ")))
8392 (not gnus-newsgroup-adaptive)
8393 (not gnus-newsgroup-auto-expire)
8394 (not gnus-suppress-duplicates)
8395 (or (not gnus-use-cache)
8396 (eq gnus-use-cache 'passive)))
8399 (setq gnus-newsgroup-marked nil
8400 gnus-newsgroup-dormant nil))
8401 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8402 ;; We actually mark all articles as canceled, which we
8403 ;; have to do when using auto-expiry or adaptive scoring.
8404 (gnus-summary-show-all-threads)
8405 (when (gnus-summary-first-subject (not all) t)
8407 (if to-here (< (point) to-here) t)
8408 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8409 (gnus-summary-find-next (not all) nil nil t))))
8410 (gnus-set-mode-line 'summary))
8412 (gnus-summary-position-point)))
8414 (defun gnus-summary-catchup-to-here (&optional all)
8415 "Mark all unticked articles before the current one as read.
8416 If ALL is non-nil, also mark ticked and dormant articles as read."
8419 (gnus-save-hidden-threads
8420 (let ((beg (point)))
8421 ;; We check that there are unread articles.
8422 (when (or all (gnus-summary-find-prev))
8423 (gnus-summary-catchup all t beg)))))
8424 (gnus-summary-position-point))
8426 (defun gnus-summary-catchup-all (&optional quietly)
8427 "Mark all articles in this newsgroup as read."
8429 (gnus-summary-catchup t quietly))
8431 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8432 "Mark all unread articles in this group as read, then exit.
8433 If prefix argument ALL is non-nil, all articles are marked as read."
8435 (when (gnus-summary-catchup all quietly nil 'fast)
8436 ;; Select next newsgroup or exit.
8437 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
8438 (eq gnus-auto-select-next 'quietly))
8439 (gnus-summary-next-group nil)
8440 (gnus-summary-exit))))
8442 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8443 "Mark all articles in this newsgroup as read, and then exit."
8445 (gnus-summary-catchup-and-exit t quietly))
8447 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8448 "Mark all articles in this group as read and select the next group.
8449 If given a prefix, mark all articles, unread as well as ticked, as
8453 (gnus-summary-catchup all))
8454 (gnus-summary-next-group))
8456 ;; Thread-based commands.
8458 (defun gnus-summary-articles-in-thread (&optional article)
8459 "Return a list of all articles in the current thread.
8460 If ARTICLE is non-nil, return all articles in the thread that starts
8462 (let* ((article (or article (gnus-summary-article-number)))
8463 (data (gnus-data-find-list article))
8464 (top-level (gnus-data-level (car data)))
8466 (cond ((null gnus-thread-operation-ignore-subject)
8467 (gnus-simplify-subject-re
8468 (mail-header-subject (gnus-data-header (car data)))))
8469 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8470 (gnus-simplify-subject-fuzzy
8471 (mail-header-subject (gnus-data-header (car data)))))
8473 (end-point (save-excursion
8474 (if (gnus-summary-go-to-next-thread)
8475 (point) (point-max))))
8478 (< (gnus-data-pos (car data)) end-point))
8479 (when (or (not top-subject)
8480 (string= top-subject
8481 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8482 (gnus-simplify-subject-fuzzy
8483 (mail-header-subject
8484 (gnus-data-header (car data))))
8485 (gnus-simplify-subject-re
8486 (mail-header-subject
8487 (gnus-data-header (car data)))))))
8488 (push (gnus-data-number (car data)) articles))
8489 (unless (and (setq data (cdr data))
8490 (> (gnus-data-level (car data)) top-level))
8492 ;; Return the list of articles.
8493 (nreverse articles)))
8495 (defun gnus-summary-rethread-current ()
8496 "Rethread the thread the current article is part of."
8498 (let* ((gnus-show-threads t)
8499 (article (gnus-summary-article-number))
8500 (id (mail-header-id (gnus-summary-article-header)))
8501 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8503 (error "No article on the current line"))
8504 (gnus-rebuild-thread id)
8505 (gnus-summary-goto-subject article)))
8507 (defun gnus-summary-reparent-thread ()
8508 "Make the current article child of the marked (or previous) article.
8510 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8511 is non-nil or the Subject: of both articles are the same."
8513 (unless (not (gnus-group-read-only-p))
8514 (error "The current newsgroup does not support article editing"))
8515 (unless (<= (length gnus-newsgroup-processable) 1)
8516 (error "No more than one article may be marked"))
8517 (save-window-excursion
8518 (let ((gnus-article-buffer " *reparent*")
8519 (current-article (gnus-summary-article-number))
8520 ;; First grab the marked article, otherwise one line up.
8521 (parent-article (if (not (null gnus-newsgroup-processable))
8522 (car gnus-newsgroup-processable)
8524 (if (eq (forward-line -1) 0)
8525 (gnus-summary-article-number)
8526 (error "Beginning of summary buffer"))))))
8527 (unless (not (eq current-article parent-article))
8528 (error "An article may not be self-referential"))
8529 (let ((message-id (mail-header-id
8530 (gnus-summary-article-header parent-article))))
8531 (unless (and message-id (not (equal message-id "")))
8532 (error "No message-id in desired parent"))
8533 (gnus-with-article current-article
8534 (goto-char (point-min))
8535 (if (re-search-forward "^References: " nil t)
8537 (re-search-forward "^[^ \t]" nil t)
8540 (insert " " message-id))
8541 (insert "References: " message-id "\n")))
8542 (set-buffer gnus-summary-buffer)
8543 (gnus-summary-unmark-all-processable)
8544 (gnus-summary-update-article current-article)
8545 (gnus-summary-rethread-current)
8546 (gnus-message 3 "Article %d is now the child of article %d"
8547 current-article parent-article)))))
8549 (defun gnus-summary-toggle-threads (&optional arg)
8550 "Toggle showing conversation threads.
8551 If ARG is positive number, turn showing conversation threads on."
8553 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8554 (setq gnus-show-threads
8555 (if (null arg) (not gnus-show-threads)
8556 (> (prefix-numeric-value arg) 0)))
8557 (gnus-summary-prepare)
8558 (gnus-summary-goto-subject current)
8559 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8560 (gnus-summary-position-point)))
8562 (defun gnus-summary-show-all-threads ()
8566 (let ((buffer-read-only nil))
8567 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8568 (gnus-summary-position-point))
8570 (defun gnus-summary-show-thread ()
8571 "Show thread subtrees.
8572 Returns nil if no thread was there to be shown."
8574 (let ((buffer-read-only nil)
8576 ;; first goto end then to beg, to have point at beg after let
8577 (end (progn (end-of-line) (point)))
8578 (beg (progn (beginning-of-line) (point))))
8580 ;; Any hidden lines here?
8581 (search-forward "\r" end t)
8582 (subst-char-in-region beg end ?\^M ?\n t)
8584 (gnus-summary-position-point))))
8586 (defun gnus-summary-hide-all-threads ()
8587 "Hide all thread subtrees."
8590 (goto-char (point-min))
8591 (gnus-summary-hide-thread)
8592 (while (zerop (gnus-summary-next-thread 1 t))
8593 (gnus-summary-hide-thread)))
8594 (gnus-summary-position-point))
8596 (defun gnus-summary-hide-thread ()
8597 "Hide thread subtrees.
8598 Returns nil if no threads were there to be hidden."
8600 (let ((buffer-read-only nil)
8602 (article (gnus-summary-article-number)))
8604 ;; Go forward until either the buffer ends or the subthread
8606 (when (and (not (eobp))
8607 (or (zerop (gnus-summary-next-thread 1 t))
8608 (goto-char (point-max))))
8610 (if (and (> (point) start)
8611 (search-backward "\n" start t))
8613 (subst-char-in-region start (point) ?\n ?\^M)
8614 (gnus-summary-goto-subject article))
8617 ;;(gnus-summary-position-point)
8620 (defun gnus-summary-go-to-next-thread (&optional previous)
8621 "Go to the same level (or less) next thread.
8622 If PREVIOUS is non-nil, go to previous thread instead.
8623 Return the article number moved to, or nil if moving was impossible."
8624 (let ((level (gnus-summary-thread-level))
8625 (way (if previous -1 1))
8628 (while (and (not (eobp))
8629 (< level (gnus-summary-thread-level)))
8637 (gnus-summary-article-number)
8640 (defun gnus-summary-next-thread (n &optional silent)
8641 "Go to the same level next N'th thread.
8642 If N is negative, search backward instead.
8643 Returns the difference between N and the number of skips actually
8646 If SILENT, don't output messages."
8648 (let ((backward (< n 0))
8651 (gnus-summary-go-to-next-thread backward))
8654 (gnus-summary-position-point))
8655 (when (and (not silent) (/= 0 n))
8656 (gnus-message 7 "No more threads"))
8659 (defun gnus-summary-prev-thread (n)
8660 "Go to the same level previous N'th thread.
8661 Returns the difference between N and the number of skips actually
8664 (gnus-summary-next-thread (- n)))
8666 (defun gnus-summary-go-down-thread ()
8667 "Go down one level in the current thread."
8668 (let ((children (gnus-summary-article-children)))
8670 (gnus-summary-goto-subject (car children)))))
8672 (defun gnus-summary-go-up-thread ()
8673 "Go up one level in the current thread."
8674 (let ((parent (gnus-summary-article-parent)))
8676 (gnus-summary-goto-subject parent))))
8678 (defun gnus-summary-down-thread (n)
8679 "Go down thread N steps.
8680 If N is negative, go up instead.
8681 Returns the difference between N and how many steps down that were
8687 (if up (gnus-summary-go-up-thread)
8688 (gnus-summary-go-down-thread)))
8690 (gnus-summary-position-point)
8692 (gnus-message 7 "Can't go further"))
8695 (defun gnus-summary-up-thread (n)
8696 "Go up thread N steps.
8697 If N is negative, go up instead.
8698 Returns the difference between N and how many steps down that were
8701 (gnus-summary-down-thread (- n)))
8703 (defun gnus-summary-top-thread ()
8704 "Go to the top of the thread."
8706 (while (gnus-summary-go-up-thread))
8707 (gnus-summary-article-number))
8709 (defun gnus-summary-kill-thread (&optional unmark)
8710 "Mark articles under current thread as read.
8711 If the prefix argument is positive, remove any kinds of marks.
8712 If the prefix argument is negative, tick articles instead."
8715 (setq unmark (prefix-numeric-value unmark)))
8716 (let ((articles (gnus-summary-articles-in-thread)))
8718 ;; Expand the thread.
8719 (gnus-summary-show-thread)
8720 ;; Mark all the articles.
8722 (gnus-summary-goto-subject (car articles))
8723 (cond ((null unmark)
8724 (gnus-summary-mark-article-as-read gnus-killed-mark))
8726 (gnus-summary-mark-article-as-unread gnus-unread-mark))
8728 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
8729 (setq articles (cdr articles))))
8730 ;; Hide killed subtrees.
8732 gnus-thread-hide-killed
8733 (gnus-summary-hide-thread))
8734 ;; If marked as read, go to next unread subject.
8736 ;; Go to next unread subject.
8737 (gnus-summary-next-subject 1 t)))
8738 (gnus-set-mode-line 'summary))
8740 ;; Summary sorting commands
8742 (defun gnus-summary-sort-by-number (&optional reverse)
8743 "Sort the summary buffer by article number.
8744 Argument REVERSE means reverse order."
8746 (gnus-summary-sort 'number reverse))
8748 (defun gnus-summary-sort-by-author (&optional reverse)
8749 "Sort the summary buffer by author name alphabetically.
8750 If case-fold-search is non-nil, case of letters is ignored.
8751 Argument REVERSE means reverse order."
8753 (gnus-summary-sort 'author reverse))
8755 (defun gnus-summary-sort-by-subject (&optional reverse)
8756 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8757 If case-fold-search is non-nil, case of letters is ignored.
8758 Argument REVERSE means reverse order."
8760 (gnus-summary-sort 'subject reverse))
8762 (defun gnus-summary-sort-by-date (&optional reverse)
8763 "Sort the summary buffer by date.
8764 Argument REVERSE means reverse order."
8766 (gnus-summary-sort 'date reverse))
8768 (defun gnus-summary-sort-by-score (&optional reverse)
8769 "Sort the summary buffer by score.
8770 Argument REVERSE means reverse order."
8772 (gnus-summary-sort 'score reverse))
8774 (defun gnus-summary-sort-by-lines (&optional reverse)
8775 "Sort the summary buffer by the number of lines.
8776 Argument REVERSE means reverse order."
8778 (gnus-summary-sort 'lines reverse))
8780 (defun gnus-summary-sort-by-chars (&optional reverse)
8781 "Sort the summary buffer by article length.
8782 Argument REVERSE means reverse order."
8784 (gnus-summary-sort 'chars reverse))
8786 (defun gnus-summary-sort (predicate reverse)
8787 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
8788 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
8789 (article (intern (format "gnus-article-sort-by-%s" predicate)))
8790 (gnus-thread-sort-functions
8795 (gnus-article-sort-functions
8801 (gnus-summary-prepare-hook nil))
8802 ;; We do the sorting by regenerating the threads.
8803 (gnus-summary-prepare)
8804 ;; Hide subthreads if needed.
8805 (when (and gnus-show-threads gnus-thread-hide-subtree)
8806 (gnus-summary-hide-all-threads))))
8808 ;; Summary saving commands.
8810 (defun gnus-summary-save-article (&optional n not-saved)
8811 "Save the current article using the default saver function.
8812 If N is a positive number, save the N next articles.
8813 If N is a negative number, save the N previous articles.
8814 If N is nil and any articles have been marked with the process mark,
8815 save those articles instead.
8816 The variable `gnus-default-article-saver' specifies the saver function."
8818 (let* ((articles (gnus-summary-work-articles n))
8819 (save-buffer (save-excursion
8820 (nnheader-set-temp-buffer " *Gnus Save*")))
8821 (num (length articles))
8823 (dolist (article articles)
8824 (setq header (gnus-summary-article-header article))
8825 (if (not (vectorp header))
8826 ;; This is a pseudo-article.
8827 (if (assq 'name header)
8828 (gnus-copy-file (cdr (assq 'name header)))
8829 (gnus-message 1 "Article %d is unsaveable" article))
8830 ;; This is a real article.
8831 (save-window-excursion
8832 (gnus-summary-select-article t nil nil article))
8834 (set-buffer save-buffer)
8836 (insert-buffer-substring gnus-original-article-buffer))
8837 (setq file (gnus-article-save save-buffer file num))
8838 (gnus-summary-remove-process-mark article)
8840 (gnus-summary-set-saved-mark article))))
8841 (gnus-kill-buffer save-buffer)
8842 (gnus-summary-position-point)
8843 (gnus-set-mode-line 'summary)
8846 (defun gnus-summary-pipe-output (&optional arg)
8847 "Pipe the current article to a subprocess.
8848 If N is a positive number, pipe the N next articles.
8849 If N is a negative number, pipe the N previous articles.
8850 If N is nil and any articles have been marked with the process mark,
8851 pipe those articles instead."
8853 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8854 (gnus-summary-save-article arg t))
8855 (gnus-configure-windows 'pipe))
8857 (defun gnus-summary-save-article-mail (&optional arg)
8858 "Append the current article to an mail file.
8859 If N is a positive number, save the N next articles.
8860 If N is a negative number, save the N previous articles.
8861 If N is nil and any articles have been marked with the process mark,
8862 save those articles instead."
8864 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8865 (gnus-summary-save-article arg)))
8867 (defun gnus-summary-save-article-rmail (&optional arg)
8868 "Append the current article to an rmail file.
8869 If N is a positive number, save the N next articles.
8870 If N is a negative number, save the N previous articles.
8871 If N is nil and any articles have been marked with the process mark,
8872 save those articles instead."
8874 (let ((gnus-default-article-saver 'rmail-output-to-rmail-file))
8875 (gnus-summary-save-article arg)))
8877 (defun gnus-summary-save-article-file (&optional arg)
8878 "Append the current article to a file.
8879 If N is a positive number, save the N next articles.
8880 If N is a negative number, save the N previous articles.
8881 If N is nil and any articles have been marked with the process mark,
8882 save those articles instead."
8884 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8885 (gnus-summary-save-article arg)))
8887 (defun gnus-summary-write-article-file (&optional arg)
8888 "Write the current article to a file, deleting the previous file.
8889 If N is a positive number, save the N next articles.
8890 If N is a negative number, save the N previous articles.
8891 If N is nil and any articles have been marked with the process mark,
8892 save those articles instead."
8894 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
8895 (gnus-summary-save-article arg)))
8897 (defun gnus-summary-save-article-body-file (&optional arg)
8898 "Append the current article body to a file.
8899 If N is a positive number, save the N next articles.
8900 If N is a negative number, save the N previous articles.
8901 If N is nil and any articles have been marked with the process mark,
8902 save those articles instead."
8904 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
8905 (gnus-summary-save-article arg)))
8907 (defun gnus-summary-pipe-message (program)
8908 "Pipe the current article through PROGRAM."
8909 (interactive "sProgram: ")
8910 (gnus-summary-select-article)
8911 (let ((mail-header-separator ""))
8912 (gnus-eval-in-buffer-window gnus-article-buffer
8915 (let ((start (window-start))
8917 (message-pipe-buffer-body program)
8918 (set-window-start (get-buffer-window (current-buffer)) start))))))
8920 (defun gnus-get-split-value (methods)
8921 "Return a value based on the split METHODS."
8922 (let (split-name method result match)
8925 (set-buffer gnus-original-article-buffer)
8927 (nnheader-narrow-to-headers)
8929 (goto-char (point-min))
8930 (setq method (pop methods))
8931 (setq match (car method))
8934 ;; Regular expression.
8936 (re-search-forward match nil t)))
8937 ((gnus-functionp match)
8941 (setq result (funcall match gnus-newsgroup-name))))
8946 (setq result (eval match)))))
8947 (setq split-name (append (cdr method) split-name))
8948 (cond ((stringp result)
8949 (push (expand-file-name
8950 result gnus-article-save-directory)
8953 (setq split-name (append result split-name)))))))))
8954 (nreverse split-name)))
8956 (defun gnus-valid-move-group-p (group)
8959 (symbol-value group)
8960 (gnus-get-function (gnus-find-method-for-group
8961 (symbol-name group)) 'request-accept-article t)))
8963 (defun gnus-read-move-group-name (prompt default articles prefix)
8964 "Read a group name."
8965 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
8966 (minibuffer-confirm-incomplete nil) ; XEmacs
8970 (if (> (length articles) 1)
8971 (format "these %d articles" (length articles))
8976 (gnus-completing-read default prom
8978 'gnus-valid-move-group-p
8980 'gnus-group-history))
8981 ((= 1 (length split-name))
8982 (gnus-completing-read (car split-name) prom
8984 'gnus-valid-move-group-p
8986 'gnus-group-history))
8988 (gnus-completing-read nil prom
8989 (mapcar (lambda (el) (list el))
8990 (nreverse split-name))
8992 'gnus-group-history)))))
8994 (if (or (string= to-newsgroup "")
8995 (string= to-newsgroup prefix))
8996 (setq to-newsgroup default))
8997 (unless to-newsgroup
8998 (error "No group name entered"))
8999 (or (gnus-active to-newsgroup)
9000 (gnus-activate-group to-newsgroup)
9001 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
9003 (or (and (gnus-request-create-group
9004 to-newsgroup (gnus-group-name-to-method to-newsgroup))
9005 (gnus-activate-group
9006 to-newsgroup nil nil
9007 (gnus-group-name-to-method to-newsgroup))
9008 (gnus-subscribe-group to-newsgroup))
9009 (error "Couldn't create group %s" to-newsgroup)))
9010 (error "No such group: %s" to-newsgroup)))
9013 (defun gnus-summary-save-parts (type dir n reverse)
9014 "Save parts matching TYPE to DIR.
9015 If REVERSE, save parts that do not match TYPE."
9017 (list (read-string "Save parts of type: " "image/.*")
9018 (read-file-name "Save to directory: " t nil t)
9019 current-prefix-arg))
9020 (gnus-summary-iterate n
9021 (let ((gnus-display-mime-function nil)
9022 (gnus-inhibit-treatment t))
9023 (gnus-summary-select-article))
9025 (set-buffer gnus-article-buffer)
9026 (let ((handles (or (mm-dissect-buffer) (mm-uu-dissect))))
9028 (gnus-summary-save-parts-1 type dir handles reverse)
9029 (mm-destroy-parts handles))))))
9031 (defun gnus-summary-save-parts-1 (type dir handle reverse)
9032 (if (stringp (car handle))
9033 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
9036 (not (string-match type (mm-handle-media-type handle)))
9037 (string-match type (mm-handle-media-type handle)))
9038 (let ((file (expand-file-name
9039 (file-name-nondirectory
9041 (mail-content-type-get
9042 (mm-handle-disposition handle) 'filename)
9043 (concat gnus-newsgroup-name "." gnus-current-article)))
9045 (unless (file-exists-p file)
9046 (mm-save-part-to-file handle file))))))
9048 ;; Summary extract commands
9050 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
9051 (let ((buffer-read-only nil)
9052 (article (gnus-summary-article-number))
9054 (unless (gnus-summary-goto-subject article)
9055 (error "No such article: %d" article))
9056 (gnus-summary-position-point)
9057 ;; If all commands are to be bunched up on one line, we collect
9059 (unless gnus-view-pseudos-separately
9060 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
9063 (setq action (cdr (assq 'action (car ps))))
9064 (setq files (list (cdr (assq 'name (car ps)))))
9065 (while (and ps (cdr ps)
9066 (string= (or action "1")
9067 (or (cdr (assq 'action (cadr ps))) "2")))
9068 (push (cdr (assq 'name (cadr ps))) files)
9069 (setcdr ps (cddr ps)))
9071 (when (not (string-match "%s" action))
9074 (when (assq 'execute (car ps))
9075 (setcdr (assq 'execute (car ps))
9076 (funcall (if (string-match "%s" action)
9085 (setq ps (cdr ps)))))
9086 (if (and gnus-view-pseudos (not not-view))
9088 (when (assq 'execute (car pslist))
9089 (gnus-execute-command (cdr (assq 'execute (car pslist)))
9090 (eq gnus-view-pseudos 'not-confirm)))
9091 (setq pslist (cdr pslist)))
9094 (setq after-article (or (cdr (assq 'article (car pslist)))
9095 (gnus-summary-article-number)))
9096 (gnus-summary-goto-subject after-article)
9099 (insert " " (file-name-nondirectory
9100 (cdr (assq 'name (car pslist))))
9101 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
9103 (forward-line -1) ; back to `b'
9104 (gnus-add-text-properties
9105 b (1- e) (list 'gnus-number gnus-reffed-article-number
9106 gnus-mouse-face-prop gnus-mouse-face))
9108 after-article gnus-reffed-article-number
9109 gnus-unread-mark b (car pslist) 0 (- e b))
9110 (push gnus-reffed-article-number gnus-newsgroup-unreads)
9111 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
9112 (setq pslist (cdr pslist)))))))
9114 (defun gnus-pseudos< (p1 p2)
9115 (let ((c1 (cdr (assq 'action p1)))
9116 (c2 (cdr (assq 'action p2))))
9117 (and c1 c2 (string< c1 c2))))
9119 (defun gnus-request-pseudo-article (props)
9120 (cond ((assq 'execute props)
9121 (gnus-execute-command (cdr (assq 'execute props)))))
9122 (let ((gnus-current-article (gnus-summary-article-number)))
9123 (gnus-run-hooks 'gnus-mark-article-hook)))
9125 (defun gnus-execute-command (command &optional automatic)
9127 (gnus-article-setup-buffer)
9128 (set-buffer gnus-article-buffer)
9129 (setq buffer-read-only nil)
9130 (let ((command (if automatic command
9131 (read-string "Command: " (cons command 0)))))
9133 (insert "$ " command "\n\n")
9134 (if gnus-view-pseudo-asynchronously
9135 (start-process "gnus-execute" (current-buffer) shell-file-name
9136 shell-command-switch command)
9137 (call-process shell-file-name nil t nil
9138 shell-command-switch command)))))
9140 ;; Summary kill commands.
9142 (defun gnus-summary-edit-global-kill (article)
9143 "Edit the \"global\" kill file."
9144 (interactive (list (gnus-summary-article-number)))
9145 (gnus-group-edit-global-kill article))
9147 (defun gnus-summary-edit-local-kill ()
9148 "Edit a local kill file applied to the current newsgroup."
9150 (setq gnus-current-headers (gnus-summary-article-header))
9151 (gnus-group-edit-local-kill
9152 (gnus-summary-article-number) gnus-newsgroup-name))
9156 (defun gnus-read-header (id &optional header)
9157 "Read the headers of article ID and enter them into the Gnus system."
9158 (let ((group gnus-newsgroup-name)
9159 (gnus-override-method
9160 (and (gnus-news-group-p gnus-newsgroup-name)
9161 gnus-refer-article-method))
9163 ;; First we check to see whether the header in question is already
9166 ;; This is a Message-ID.
9167 (setq header (or header (gnus-id-to-header id)))
9168 ;; This is an article number.
9169 (setq header (or header (gnus-summary-article-header id))))
9171 (not (gnus-summary-article-sparse-p (mail-header-number header))))
9172 ;; We have found the header.
9174 ;; If this is a sparse article, we have to nix out its
9175 ;; previous entry in the thread hashtb.
9177 (gnus-summary-article-sparse-p (mail-header-number header)))
9178 (let* ((parent (gnus-parent-id (mail-header-references header)))
9179 (thread (and parent (gnus-id-to-thread parent))))
9181 (delq (assq header thread) thread))))
9182 ;; We have to really fetch the header to this article.
9184 (set-buffer nntp-server-buffer)
9185 (when (setq where (gnus-request-head id group))
9186 (nnheader-fold-continuation-lines)
9187 (goto-char (point-max))
9189 (goto-char (point-min))
9193 ((cdr where) (cdr where))
9194 (header (mail-header-number header))
9195 (t gnus-reffed-article-number))
9197 (insert " Article retrieved.\n"))
9199 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
9200 () ; Malformed head.
9201 (unless (gnus-summary-article-sparse-p (mail-header-number header))
9202 (when (and (stringp id)
9203 (not (string= (gnus-group-real-name group)
9205 ;; If we fetched by Message-ID and the article came
9206 ;; from a different group, we fudge some bogus article
9207 ;; numbers for this article.
9208 (mail-header-set-number header gnus-reffed-article-number))
9210 (set-buffer gnus-summary-buffer)
9211 (decf gnus-reffed-article-number)
9212 (gnus-remove-header (mail-header-number header))
9213 (push header gnus-newsgroup-headers)
9214 (setq gnus-current-headers header)
9215 (push (mail-header-number header) gnus-newsgroup-limit)))
9218 (defun gnus-remove-header (number)
9219 "Remove header NUMBER from `gnus-newsgroup-headers'."
9220 (if (and gnus-newsgroup-headers
9221 (= number (mail-header-number (car gnus-newsgroup-headers))))
9222 (pop gnus-newsgroup-headers)
9223 (let ((headers gnus-newsgroup-headers))
9224 (while (and (cdr headers)
9225 (not (= number (mail-header-number (cadr headers)))))
9228 (setcdr headers (cddr headers))))))
9231 ;;; summary highlights
9234 (defun gnus-highlight-selected-summary ()
9235 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
9236 ;; Highlight selected article in summary buffer
9237 (when gnus-summary-selected-face
9239 (let* ((beg (progn (beginning-of-line) (point)))
9240 (end (progn (end-of-line) (point)))
9241 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
9242 (from (if (get-text-property beg gnus-mouse-face-prop)
9244 (or (next-single-property-change
9245 beg gnus-mouse-face-prop nil end)
9250 (or (next-single-property-change
9251 from gnus-mouse-face-prop nil end)
9253 ;; If no mouse-face prop on line we will have to = from = end,
9254 ;; so we highlight the entire line instead.
9255 (when (= (+ to 2) from)
9258 (if gnus-newsgroup-selected-overlay
9259 ;; Move old overlay.
9261 gnus-newsgroup-selected-overlay from to (current-buffer))
9262 ;; Create new overlay.
9264 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
9265 'face gnus-summary-selected-face))))))
9267 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
9268 (defun gnus-summary-highlight-line ()
9269 "Highlight current line according to `gnus-summary-highlight'."
9270 (let* ((list gnus-summary-highlight)
9272 (end (progn (end-of-line) (point)))
9273 ;; now find out where the line starts and leave point there.
9274 (beg (progn (beginning-of-line) (point)))
9275 (article (gnus-summary-article-number))
9276 (score (or (cdr (assq (or article gnus-current-article)
9277 gnus-newsgroup-scored))
9278 gnus-summary-default-score 0))
9279 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
9280 (inhibit-read-only t))
9281 ;; Eval the cars of the lists until we find a match.
9282 (let ((default gnus-summary-default-score))
9284 (not (eval (caar list))))
9285 (setq list (cdr list))))
9286 (let ((face (cdar list)))
9287 (unless (eq face (get-text-property beg 'face))
9288 (gnus-put-text-property-excluding-characters-with-faces
9290 (setq face (if (boundp face) (symbol-value face) face)))
9291 (when gnus-summary-highlight-line-function
9292 (funcall gnus-summary-highlight-line-function article face))))
9295 (defun gnus-update-read-articles (group unread &optional compute)
9296 "Update the list of read articles in GROUP."
9297 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
9298 (entry (gnus-gethash group gnus-newsrc-hashtb))
9299 (info (nth 2 entry))
9301 (unread (sort (copy-sequence unread) '<))
9303 (if (or (not info) (not active))
9304 ;; There is no info on this group if it was, in fact,
9305 ;; killed. Gnus stores no information on killed groups, so
9306 ;; there's nothing to be done.
9307 ;; One could store the information somewhere temporarily,
9308 ;; perhaps... Hmmm...
9310 ;; Remove any negative articles numbers.
9311 (while (and unread (< (car unread) 0))
9312 (setq unread (cdr unread)))
9313 ;; Remove any expired article numbers
9314 (while (and unread (< (car unread) (car active)))
9315 (setq unread (cdr unread)))
9316 ;; Compute the ranges of read articles by looking at the list of
9319 (when (/= (car unread) prev)
9320 (push (if (= prev (1- (car unread))) prev
9321 (cons prev (1- (car unread))))
9323 (setq prev (1+ (car unread)))
9324 (setq unread (cdr unread)))
9325 (when (<= prev (cdr active))
9326 (push (cons prev (cdr active)) read))
9327 (setq read (if (> (length read) 1) (nreverse read) read))
9331 (set-buffer gnus-group-buffer)
9334 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
9335 (gnus-info-set-read ',info ',(gnus-info-read info))
9336 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
9337 (gnus-group-update-group ,group t))))
9338 ;; Propagate the read marks to the backend.
9339 (if (gnus-check-backend-function 'request-set-mark group)
9340 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
9341 (add (gnus-remove-from-range read (gnus-info-read info))))
9343 (unless (gnus-check-group group)
9344 (error "Can't open server for %s" group))
9345 (gnus-request-set-mark
9346 group (delq nil (list (if add (list add 'add '(read)))
9347 (if del (list del 'del '(read)))))))))
9348 ;; Enter this list into the group info.
9349 (gnus-info-set-read info read)
9350 ;; Set the number of unread articles in gnus-newsrc-hashtb.
9351 (gnus-get-unread-articles-in-group info (gnus-active group))
9354 (defun gnus-offer-save-summaries ()
9355 "Offer to save all active summary buffers."
9357 (let ((buflist (buffer-list))
9359 ;; Go through all buffers and find all summaries.
9361 (and (setq bufname (buffer-name (car buflist)))
9362 (string-match "Summary" bufname)
9364 (set-buffer bufname)
9365 ;; We check that this is, indeed, a summary buffer.
9366 (and (eq major-mode 'gnus-summary-mode)
9367 ;; Also make sure this isn't bogus.
9368 gnus-newsgroup-prepared
9369 ;; Also make sure that this isn't a dead summary buffer.
9370 (not gnus-dead-summary-mode)))
9371 (push bufname buffers))
9372 (setq buflist (cdr buflist)))
9373 ;; Go through all these summary buffers and offer to save them.
9376 "Update summary buffer %s? "
9378 (switch-to-buffer buf)
9379 (gnus-summary-exit))
9382 (defun gnus-summary-setup-default-charset ()
9383 "Setup newsgroup default charset."
9384 (if (equal gnus-newsgroup-name "nndraft:drafts")
9385 (setq gnus-newsgroup-charset nil)
9386 (let* ((name (and gnus-newsgroup-name
9387 (gnus-group-real-name gnus-newsgroup-name)))
9389 (or gnus-newsgroup-ephemeral-ignored-charsets
9391 (and gnus-newsgroup-name
9392 (or (gnus-group-find-parameter gnus-newsgroup-name
9393 'ignored-charsets t)
9394 (let ((alist gnus-group-ignored-charsets-alist)
9395 elem (charsets nil))
9396 (while (setq elem (pop alist))
9398 (string-match (car elem) name))
9400 charsets (cdr elem))))
9402 gnus-newsgroup-ignored-charsets)))
9403 (setq gnus-newsgroup-charset
9404 (or gnus-newsgroup-ephemeral-charset
9405 (and gnus-newsgroup-name
9406 (or (gnus-group-find-parameter gnus-newsgroup-name
9408 (let ((alist gnus-group-charset-alist)
9410 (while (setq elem (pop alist))
9412 (string-match (car elem) name))
9414 charset (cadr elem))))
9416 gnus-default-charset))
9417 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
9418 ignored-charsets))))
9424 (defun gnus-summary-display-buttonized (&optional show-all-parts)
9425 "Display the current article buffer fully MIME-buttonized.
9426 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
9427 treated as multipart/mixed."
9430 (let ((gnus-unbuttonized-mime-types nil)
9431 (gnus-mime-display-multipart-as-mixed show-all-parts))
9432 (gnus-summary-show-article)))
9434 (defun gnus-summary-repair-multipart (article)
9435 "Add a Content-Type header to a multipart article without one."
9436 (interactive (list (gnus-summary-article-number)))
9437 (gnus-with-article article
9438 (message-narrow-to-head)
9439 (goto-char (point-max))
9441 (when (search-forward "\n--" nil t)
9442 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
9443 (message-narrow-to-head)
9444 (message-remove-header "Mime-Version")
9445 (message-remove-header "Content-Type")
9446 (goto-char (point-max))
9447 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
9449 (insert "Mime-Version: 1.0\n")
9451 (let (gnus-mark-article-hook)
9452 (gnus-summary-select-article t t nil article)))
9454 (defun gnus-summary-toggle-display-buttonized ()
9455 "Toggle the buttonizing of the article buffer."
9458 (if (setq gnus-inhibit-mime-unbuttonizing
9459 (not gnus-inhibit-mime-unbuttonizing))
9460 (let ((gnus-unbuttonized-mime-types nil))
9461 (gnus-summary-show-article))
9462 (gnus-summary-show-article)))
9468 (defmacro gnus-with-article (article &rest forms)
9469 "Select ARTICLE and perform FORMS in the original article buffer.
9470 Then replace the article with the result."
9472 ;; We don't want the article to be marked as read.
9473 (let (gnus-mark-article-hook)
9474 (gnus-summary-select-article t t nil ,article))
9475 (set-buffer gnus-original-article-buffer)
9477 (if (not (gnus-check-backend-function
9478 'request-replace-article (car gnus-article-current)))
9479 (gnus-message 5 "Read-only group; not replacing")
9480 (unless (gnus-request-replace-article
9481 ,article (car gnus-article-current)
9483 (error "Couldn't replace article")))
9484 ;; The cache and backlog have to be flushed somewhat.
9485 (when gnus-keep-backlog
9486 (gnus-backlog-remove-article
9487 (car gnus-article-current) (cdr gnus-article-current)))
9488 (when gnus-use-cache
9489 (gnus-cache-update-article
9490 (car gnus-article-current) (cdr gnus-article-current)))))
9492 (put 'gnus-with-article 'lisp-indent-function 1)
9493 (put 'gnus-with-article 'edebug-form-spec '(form body))
9496 ;;; Generic summary marking commands
9499 (defvar gnus-summary-marking-alist
9500 '((read gnus-del-mark "d")
9501 (unread gnus-unread-mark "u")
9502 (ticked gnus-ticked-mark "!")
9503 (dormant gnus-dormant-mark "?")
9504 (expirable gnus-expirable-mark "e"))
9505 "An alist of names/marks/keystrokes.")
9507 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
9508 (defvar gnus-summary-mark-map)
9510 (defun gnus-summary-make-all-marking-commands ()
9511 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
9512 (dolist (elem gnus-summary-marking-alist)
9513 (apply 'gnus-summary-make-marking-command elem)))
9515 (defun gnus-summary-make-marking-command (name mark keystroke)
9516 (let ((map (make-sparse-keymap)))
9517 (define-key gnus-summary-generic-mark-map keystroke map)
9518 (dolist (lway `((next "next" next nil "n")
9519 (next-unread "next unread" next t "N")
9520 (prev "previous" prev nil "p")
9521 (prev-unread "previous unread" prev t "P")
9522 (nomove "" nil nil ,keystroke)))
9523 (let ((func (gnus-summary-make-marking-command-1
9524 mark (car lway) lway name)))
9525 (setq func (eval func))
9526 (define-key map (nth 4 lway) func)))))
9528 (defun gnus-summary-make-marking-command-1 (mark way lway name)
9530 (format "gnus-summary-put-mark-as-%s%s"
9531 name (if (eq way 'nomove)
9533 (concat "-" (symbol-name way)))))
9536 "Mark the current article as %s%s.
9537 If N, the prefix, then repeat N times.
9538 If N is negative, move in reverse order.
9539 The difference between N and the actual number of articles marked is
9543 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
9545 (defun gnus-summary-generic-mark (n mark move unread)
9546 "Mark N articles with MARK."
9547 (unless (eq major-mode 'gnus-summary-mode)
9548 (error "This command can only be used in the summary buffer"))
9549 (gnus-summary-show-thread)
9553 ((eq move 'prev) -1)
9559 nummove (* -1 nummove))))
9561 (gnus-summary-mark-article nil mark)
9562 (zerop (gnus-summary-next-subject nummove unread t)))
9565 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9566 (gnus-summary-recenter)
9567 (gnus-summary-position-point)
9568 (gnus-set-mode-line 'summary)
9571 (gnus-summary-make-all-marking-commands)
9577 (run-hooks 'gnus-sum-load-hook)
9579 ;;; gnus-sum.el ends here