1 ;;; gnus-sum.el --- summary mode commands for Semi-gnus
2 ;; Copyright (C) 1996,97,98,99 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
5 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Katsumi Yamaoka <yamaoka@jpl.org>
7 ;; Keywords: mail, news, MIME
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
30 (eval-when-compile (require 'cl))
46 (autoload 'gnus-cache-articles-in-group "gnus-cache"))
48 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
49 (autoload 'gnus-set-summary-default-charset "gnus-i18n" nil t)
51 (defcustom gnus-kill-summary-on-exit t
52 "*If non-nil, kill the summary buffer when you exit from it.
53 If nil, the summary will become a \"*Dead Summary*\" buffer, and
54 it will be killed sometime later."
55 :group 'gnus-summary-exit
58 (defcustom gnus-fetch-old-headers nil
59 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
60 If an unread article in the group refers to an older, already read (or
61 just marked as read) article, the old article will not normally be
62 displayed in the Summary buffer. If this variable is non-nil, Gnus
63 will attempt to grab the headers to the old articles, and thereby
64 build complete threads. If it has the value `some', only enough
65 headers to connect otherwise loose threads will be displayed. This
66 variable can also be a number. In that case, no more than that number
67 of old headers will be fetched. If it has the value `invisible', all
68 old headers will be fetched, but none will be displayed.
70 The server has to support NOV for any of this to work."
72 :type '(choice (const :tag "off" nil)
75 (sexp :menu-tag "other" t)))
77 (defcustom gnus-refer-thread-limit 200
78 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
79 If t, fetch all the available old headers."
82 (sexp :menu-tag "other" t)))
84 (defcustom gnus-summary-make-false-root 'adopt
85 "*nil means that Gnus won't gather loose threads.
86 If the root of a thread has expired or been read in a previous
87 session, the information necessary to build a complete thread has been
88 lost. Instead of having many small sub-threads from this original thread
89 scattered all over the summary buffer, Gnus can gather them.
91 If non-nil, Gnus will try to gather all loose sub-threads from an
92 original thread into one large thread.
94 If this variable is non-nil, it should be one of `none', `adopt',
97 If this variable is `none', Gnus will not make a false root, but just
98 present the sub-threads after another.
99 If this variable is `dummy', Gnus will create a dummy root that will
100 have all the sub-threads as children.
101 If this variable is `adopt', Gnus will make one of the \"children\"
102 the parent and mark all the step-children as such.
103 If this variable is `empty', the \"children\" are printed with empty
104 subject fields. (Or rather, they will be printed with a string
105 given by the `gnus-summary-same-subject' variable.)"
107 :type '(choice (const :tag "off" nil)
113 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
114 "*A regexp to match subjects to be excluded from loose thread gathering.
115 As loose thread gathering is done on subjects only, that means that
116 there can be many false gatherings performed. By rooting out certain
117 common subjects, gathering might become saner."
121 (defcustom gnus-summary-gather-subject-limit nil
122 "*Maximum length of subject comparisons when gathering loose threads.
123 Use nil to compare full subjects. Setting this variable to a low
124 number will help gather threads that have been corrupted by
125 newsreaders chopping off subject lines, but it might also mean that
126 unrelated articles that have subject that happen to begin with the
127 same few characters will be incorrectly gathered.
129 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
132 :type '(choice (const :tag "off" nil)
134 (sexp :menu-tag "on" t)))
136 (defcustom gnus-simplify-subject-functions nil
137 "List of functions taking a string argument that simplify subjects.
138 The functions are applied recursively.
140 Useful functions to put in this list include: `gnus-simplify-subject-re',
141 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
143 :type '(repeat function))
145 (defcustom gnus-simplify-ignored-prefixes nil
146 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
148 :type '(choice (const :tag "off" nil)
151 (defcustom gnus-build-sparse-threads nil
152 "*If non-nil, fill in the gaps in threads.
153 If `some', only fill in the gaps that are needed to tie loose threads
154 together. If `more', fill in all leaf nodes that Gnus can find. If
155 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
157 :type '(choice (const :tag "off" nil)
160 (sexp :menu-tag "all" t)))
162 (defcustom gnus-summary-thread-gathering-function
163 'gnus-gather-threads-by-subject
164 "*Function used for gathering loose threads.
165 There are two pre-defined functions: `gnus-gather-threads-by-subject',
166 which only takes Subjects into consideration; and
167 `gnus-gather-threads-by-references', which compared the References
168 headers of the articles to find matches."
170 :type '(radio (function-item gnus-gather-threads-by-subject)
171 (function-item gnus-gather-threads-by-references)
172 (function :tag "other")))
174 (defcustom gnus-summary-same-subject ""
175 "*String indicating that the current article has the same subject as the previous.
176 This variable will only be used if the value of
177 `gnus-summary-make-false-root' is `empty'."
178 :group 'gnus-summary-format
181 (defcustom gnus-summary-goto-unread t
182 "*If t, marking commands will go to the next unread article.
183 If `never', commands that usually go to the next unread article, will
184 go to the next article, whether it is read or not.
185 If nil, only the marking commands will go to the next (un)read article."
186 :group 'gnus-summary-marks
187 :link '(custom-manual "(gnus)Setting Marks")
188 :type '(choice (const :tag "off" nil)
190 (sexp :menu-tag "on" t)))
192 (defcustom gnus-summary-default-score 0
193 "*Default article score level.
194 All scores generated by the score files will be added to this score.
195 If this variable is nil, scoring will be disabled."
196 :group 'gnus-score-default
197 :type '(choice (const :tag "disable")
200 (defcustom gnus-summary-zcore-fuzz 0
201 "*Fuzziness factor for the zcore in the summary buffer.
202 Articles with scores closer than this to `gnus-summary-default-score'
204 :group 'gnus-summary-format
207 (defcustom gnus-simplify-subject-fuzzy-regexp nil
208 "*Strings to be removed when doing fuzzy matches.
209 This can either be a regular expression or list of regular expressions
210 that will be removed from subject strings if fuzzy subject
211 simplification is selected."
213 :type '(repeat regexp))
215 (defcustom gnus-show-threads t
216 "*If non-nil, display threads in summary mode."
220 (defcustom gnus-thread-hide-subtree nil
221 "*If non-nil, hide all threads initially.
222 If threads are hidden, you have to run the command
223 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
224 to expose hidden threads."
228 (defcustom gnus-thread-hide-killed t
229 "*If non-nil, hide killed threads automatically."
233 (defcustom gnus-thread-ignore-subject t
234 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
235 If nil, articles that have different subjects from their parents will
236 start separate threads."
240 (defcustom gnus-thread-operation-ignore-subject t
241 "*If non-nil, subjects will be ignored when doing thread commands.
242 This affects commands like `gnus-summary-kill-thread' and
243 `gnus-summary-lower-thread'.
245 If this variable is nil, articles in the same thread with different
246 subjects will not be included in the operation in question. If this
247 variable is `fuzzy', only articles that have subjects that are fuzzily
248 equal will be included."
250 :type '(choice (const :tag "off" nil)
254 (defcustom gnus-thread-indent-level 4
255 "*Number that says how much each sub-thread should be indented."
259 (defcustom gnus-auto-extend-newsgroup t
260 "*If non-nil, extend newsgroup forward and backward when requested."
261 :group 'gnus-summary-choose
264 (defcustom gnus-auto-select-first t
265 "*If nil, don't select the first unread article when entering a group.
266 If this variable is `best', select the highest-scored unread article
267 in the group. If t, select the first unread article.
269 This variable can also be a function to place point on a likely
270 subject line. Useful values include `gnus-summary-first-unread-subject',
271 `gnus-summary-first-unread-article' and
272 `gnus-summary-best-unread-article'.
274 If you want to prevent automatic selection of the first unread article
275 in some newsgroups, set the variable to nil in
276 `gnus-select-group-hook'."
277 :group 'gnus-group-select
278 :type '(choice (const :tag "none" nil)
280 (sexp :menu-tag "first" t)
281 (function-item gnus-summary-first-unread-subject)
282 (function-item gnus-summary-first-unread-article)
283 (function-item gnus-summary-best-unread-article)))
285 (defcustom gnus-dont-select-after-jump-to-other-group nil
286 "If non-nil, don't select the first unread article after entering the
287 other group by the command `gnus-summary-jump-to-other-group'. If nil,
288 it is depend on the value of `gnus-auto-select-first' whether to select
290 :group 'gnus-group-select
293 (defcustom gnus-auto-select-next t
294 "*If non-nil, offer to go to the next group from the end of the previous.
295 If the value is t and the next newsgroup is empty, Gnus will exit
296 summary mode and go back to group mode. If the value is neither nil
297 nor t, Gnus will select the following unread newsgroup. In
298 particular, if the value is the symbol `quietly', the next unread
299 newsgroup will be selected without any confirmation, and if it is
300 `almost-quietly', the next group will be selected without any
301 confirmation if you are located on the last article in the group.
302 Finally, if this variable is `slightly-quietly', the `Z n' command
303 will go to the next group without confirmation."
304 :group 'gnus-summary-maneuvering
305 :type '(choice (const :tag "off" nil)
307 (const almost-quietly)
308 (const slightly-quietly)
309 (sexp :menu-tag "on" t)))
311 (defcustom gnus-auto-select-same nil
312 "*If non-nil, select the next article with the same subject.
313 If there are no more articles with the same subject, go to
314 the first unread article."
315 :group 'gnus-summary-maneuvering
318 (defcustom gnus-summary-check-current nil
319 "*If non-nil, consider the current article when moving.
320 The \"unread\" movement commands will stay on the same line if the
321 current article is unread."
322 :group 'gnus-summary-maneuvering
325 (defcustom gnus-auto-center-summary t
326 "*If non-nil, always center the current summary buffer.
327 In particular, if `vertical' do only vertical recentering. If non-nil
328 and non-`vertical', do both horizontal and vertical recentering."
329 :group 'gnus-summary-maneuvering
330 :type '(choice (const :tag "none" nil)
332 (integer :tag "height")
333 (sexp :menu-tag "both" t)))
335 (defcustom gnus-show-all-headers nil
336 "*If non-nil, don't hide any headers."
337 :group 'gnus-article-hiding
338 :group 'gnus-article-headers
341 (defcustom gnus-summary-ignore-duplicates nil
342 "*If non-nil, ignore articles with identical Message-ID headers."
346 (defcustom gnus-single-article-buffer t
347 "*If non-nil, display all articles in the same buffer.
348 If nil, each group will get its own article buffer."
349 :group 'gnus-article-various
352 (defcustom gnus-break-pages t
353 "*If non-nil, do page breaking on articles.
354 The page delimiter is specified by the `gnus-page-delimiter'
356 :group 'gnus-article-various
359 (defcustom gnus-show-mime t
360 "*If non-nil, do mime processing of articles.
361 The articles will simply be fed to the function given by
362 `gnus-article-display-method-for-mime'."
363 :group 'gnus-article-mime
366 (defcustom gnus-move-split-methods nil
367 "*Variable used to suggest where articles are to be moved to.
368 It uses the same syntax as the `gnus-split-methods' variable."
369 :group 'gnus-summary-mail
370 :type '(repeat (choice (list :value (fun) function)
371 (cons :value ("" "") regexp (repeat string))
374 (defcustom gnus-unread-mark ? ;Whitespace
375 "*Mark used for unread articles."
376 :group 'gnus-summary-marks
379 (defcustom gnus-ticked-mark ?!
380 "*Mark used for ticked articles."
381 :group 'gnus-summary-marks
384 (defcustom gnus-dormant-mark ??
385 "*Mark used for dormant articles."
386 :group 'gnus-summary-marks
389 (defcustom gnus-del-mark ?r
390 "*Mark used for del'd articles."
391 :group 'gnus-summary-marks
394 (defcustom gnus-read-mark ?R
395 "*Mark used for read articles."
396 :group 'gnus-summary-marks
399 (defcustom gnus-expirable-mark ?E
400 "*Mark used for expirable articles."
401 :group 'gnus-summary-marks
404 (defcustom gnus-killed-mark ?K
405 "*Mark used for killed articles."
406 :group 'gnus-summary-marks
409 (defcustom gnus-souped-mark ?F
410 "*Mark used for killed articles."
411 :group 'gnus-summary-marks
414 (defcustom gnus-kill-file-mark ?X
415 "*Mark used for articles killed by kill files."
416 :group 'gnus-summary-marks
419 (defcustom gnus-low-score-mark ?Y
420 "*Mark used for articles with a low score."
421 :group 'gnus-summary-marks
424 (defcustom gnus-catchup-mark ?C
425 "*Mark used for articles that are caught up."
426 :group 'gnus-summary-marks
429 (defcustom gnus-replied-mark ?A
430 "*Mark used for articles that have been replied to."
431 :group 'gnus-summary-marks
434 (defcustom gnus-cached-mark ?*
435 "*Mark used for articles that are in the cache."
436 :group 'gnus-summary-marks
439 (defcustom gnus-saved-mark ?S
440 "*Mark used for articles that have been saved to."
441 :group 'gnus-summary-marks
444 (defcustom gnus-ancient-mark ?O
445 "*Mark used for ancient articles."
446 :group 'gnus-summary-marks
449 (defcustom gnus-sparse-mark ?Q
450 "*Mark used for sparsely reffed articles."
451 :group 'gnus-summary-marks
454 (defcustom gnus-canceled-mark ?G
455 "*Mark used for canceled articles."
456 :group 'gnus-summary-marks
459 (defcustom gnus-duplicate-mark ?M
460 "*Mark used for duplicate articles."
461 :group 'gnus-summary-marks
464 (defcustom gnus-undownloaded-mark ?@
465 "*Mark used for articles that weren't downloaded."
466 :group 'gnus-summary-marks
469 (defcustom gnus-downloadable-mark ?%
470 "*Mark used for articles that are to be downloaded."
471 :group 'gnus-summary-marks
474 (defcustom gnus-unsendable-mark ?=
475 "*Mark used for articles that won't be sent."
476 :group 'gnus-summary-marks
479 (defcustom gnus-score-over-mark ?+
480 "*Score mark used for articles with high scores."
481 :group 'gnus-summary-marks
484 (defcustom gnus-score-below-mark ?-
485 "*Score mark used for articles with low scores."
486 :group 'gnus-summary-marks
489 (defcustom gnus-empty-thread-mark ? ;Whitespace
490 "*There is no thread under the article."
491 :group 'gnus-summary-marks
494 (defcustom gnus-not-empty-thread-mark ?=
495 "*There is a thread under the article."
496 :group 'gnus-summary-marks
499 (defcustom gnus-view-pseudo-asynchronously nil
500 "*If non-nil, Gnus will view pseudo-articles asynchronously."
501 :group 'gnus-extract-view
504 (defcustom gnus-auto-expirable-marks
505 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
506 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
507 gnus-souped-mark gnus-duplicate-mark)
508 "*The list of marks converted into expiration if a group is auto-expirable."
510 :type '(repeat character))
512 (defcustom gnus-inhibit-user-auto-expire t
513 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
517 (defcustom gnus-view-pseudos nil
518 "*If `automatic', pseudo-articles will be viewed automatically.
519 If `not-confirm', pseudos will be viewed automatically, and the user
520 will not be asked to confirm the command."
521 :group 'gnus-extract-view
522 :type '(choice (const :tag "off" nil)
524 (const not-confirm)))
526 (defcustom gnus-view-pseudos-separately t
527 "*If non-nil, one pseudo-article will be created for each file to be viewed.
528 If nil, all files that use the same viewing command will be given as a
529 list of parameters to that command."
530 :group 'gnus-extract-view
533 (defcustom gnus-insert-pseudo-articles t
534 "*If non-nil, insert pseudo-articles when decoding articles."
535 :group 'gnus-extract-view
538 (defcustom gnus-summary-dummy-line-format
540 "*The format specification for the dummy roots in the summary buffer.
541 It works along the same lines as a normal formatting string,
542 with some simple extensions.
545 :group 'gnus-threading
548 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
549 "*The format specification for the summary mode line.
550 It works along the same lines as a normal formatting string,
551 with some simple extensions:
554 %p Unprefixed group name
555 %A Current article number
556 %z Current article score
558 %U Number of unread articles in the group
559 %e Number of unselected articles in the group
560 %Z A string with unread/unselected article counts
561 %g Shortish group name
562 %S Subject of the current article
564 %s Current score file name
565 %d Number of dormant articles
566 %r Number of articles that have been marked as read in this session
567 %E Number of articles expunged by the score files"
568 :group 'gnus-summary-format
571 (defcustom gnus-summary-mark-below 0
572 "*Mark all articles with a score below this variable as read.
573 This variable is local to each summary buffer and usually set by the
575 :group 'gnus-score-default
578 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
579 "*List of functions used for sorting articles in the summary buffer.
580 This variable is only used when not using a threaded display."
581 :group 'gnus-summary-sort
582 :type '(repeat (choice (function-item gnus-article-sort-by-number)
583 (function-item gnus-article-sort-by-author)
584 (function-item gnus-article-sort-by-subject)
585 (function-item gnus-article-sort-by-date)
586 (function-item gnus-article-sort-by-score)
587 (function :tag "other"))))
589 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
590 "*List of functions used for sorting threads in the summary buffer.
591 By default, threads are sorted by article number.
593 Each function takes two threads and return non-nil if the first thread
594 should be sorted before the other. If you use more than one function,
595 the primary sort function should be the last. You should probably
596 always include `gnus-thread-sort-by-number' in the list of sorting
597 functions -- preferably first.
599 Ready-made functions include `gnus-thread-sort-by-number',
600 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
601 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
602 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
603 :group 'gnus-summary-sort
604 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
605 (function-item gnus-thread-sort-by-author)
606 (function-item gnus-thread-sort-by-subject)
607 (function-item gnus-thread-sort-by-date)
608 (function-item gnus-thread-sort-by-score)
609 (function-item gnus-thread-sort-by-total-score)
610 (function :tag "other"))))
612 (defcustom gnus-thread-score-function '+
613 "*Function used for calculating the total score of a thread.
615 The function is called with the scores of the article and each
616 subthread and should then return the score of the thread.
618 Some functions you can use are `+', `max', or `min'."
619 :group 'gnus-summary-sort
622 (defcustom gnus-summary-expunge-below nil
623 "All articles that have a score less than this variable will be expunged.
624 This variable is local to the summary buffers."
625 :group 'gnus-score-default
626 :type '(choice (const :tag "off" nil)
629 (defcustom gnus-thread-expunge-below nil
630 "All threads that have a total score less than this variable will be expunged.
631 See `gnus-thread-score-function' for en explanation of what a
634 This variable is local to the summary buffers."
635 :group 'gnus-threading
636 :group 'gnus-score-default
637 :type '(choice (const :tag "off" nil)
640 (defcustom gnus-summary-mode-hook nil
641 "*A hook for Gnus summary mode.
642 This hook is run before any variables are set in the summary buffer."
643 :group 'gnus-summary-various
646 (defcustom gnus-summary-menu-hook nil
647 "*Hook run after the creation of the summary mode menu."
648 :group 'gnus-summary-visual
651 (defcustom gnus-summary-exit-hook nil
652 "*A hook called on exit from the summary buffer.
653 It will be called with point in the group buffer."
654 :group 'gnus-summary-exit
657 (defcustom gnus-summary-prepare-hook nil
658 "*A hook called after the summary buffer has been generated.
659 If you want to modify the summary buffer, you can use this hook."
660 :group 'gnus-summary-various
663 (defcustom gnus-summary-prepared-hook nil
664 "*A hook called as the last thing after the summary buffer has been generated."
665 :group 'gnus-summary-various
668 (defcustom gnus-summary-generate-hook nil
669 "*A hook run just before generating the summary buffer.
670 This hook is commonly used to customize threading variables and the
672 :group 'gnus-summary-various
675 (defcustom gnus-select-group-hook nil
676 "*A hook called when a newsgroup is selected.
678 If you'd like to simplify subjects like the
679 `gnus-summary-next-same-subject' command does, you can use the
682 (setq gnus-select-group-hook
685 (mapcar (lambda (header)
686 (mail-header-set-subject
688 (gnus-simplify-subject
689 (mail-header-subject header) 're-only)))
690 gnus-newsgroup-headers))))"
691 :group 'gnus-group-select
694 (defcustom gnus-select-article-hook nil
695 "*A hook called when an article is selected."
696 :group 'gnus-summary-choose
699 (defcustom gnus-visual-mark-article-hook
700 (list 'gnus-highlight-selected-summary)
701 "*Hook run after selecting an article in the summary buffer.
702 It is meant to be used for highlighting the article in some way. It
703 is not run if `gnus-visual' is nil."
704 :group 'gnus-summary-visual
707 (defcustom gnus-parse-headers-hook '(gnus-set-summary-default-charset)
708 "*A hook called before parsing the headers."
712 (defcustom gnus-exit-group-hook nil
713 "*A hook called when exiting (not quitting) summary mode."
717 (defcustom gnus-summary-update-hook
718 (list 'gnus-summary-highlight-line)
719 "*A hook called when a summary line is changed.
720 The hook will not be called if `gnus-visual' is nil.
722 The default function `gnus-summary-highlight-line' will
723 highlight the line according to the `gnus-summary-highlight'
725 :group 'gnus-summary-visual
728 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
729 "*A hook called when an article is selected for the first time.
730 The hook is intended to mark an article as read (or unread)
731 automatically when it is selected."
732 :group 'gnus-summary-choose
735 (defcustom gnus-group-no-more-groups-hook nil
736 "*A hook run when returning to group mode having no more (unread) groups."
737 :group 'gnus-group-select
740 (defcustom gnus-ps-print-hook nil
741 "*A hook run before ps-printing something from Gnus."
745 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
746 "Face used for highlighting the current article in the summary buffer."
747 :group 'gnus-summary-visual
750 (defcustom gnus-summary-highlight
751 '(((= mark gnus-canceled-mark)
752 . gnus-summary-cancelled-face)
753 ((and (> score default)
754 (or (= mark gnus-dormant-mark)
755 (= mark gnus-ticked-mark)))
756 . gnus-summary-high-ticked-face)
757 ((and (< score default)
758 (or (= mark gnus-dormant-mark)
759 (= mark gnus-ticked-mark)))
760 . gnus-summary-low-ticked-face)
761 ((or (= mark gnus-dormant-mark)
762 (= mark gnus-ticked-mark))
763 . gnus-summary-normal-ticked-face)
764 ((and (> score default) (= mark gnus-ancient-mark))
765 . gnus-summary-high-ancient-face)
766 ((and (< score default) (= mark gnus-ancient-mark))
767 . gnus-summary-low-ancient-face)
768 ((= mark gnus-ancient-mark)
769 . gnus-summary-normal-ancient-face)
770 ((and (> score default) (= mark gnus-unread-mark))
771 . gnus-summary-high-unread-face)
772 ((and (< score default) (= mark gnus-unread-mark))
773 . gnus-summary-low-unread-face)
774 ((and (memq article gnus-newsgroup-incorporated)
775 (= mark gnus-unread-mark))
776 . gnus-summary-incorporated-face)
777 ((= mark gnus-unread-mark)
778 . gnus-summary-normal-unread-face)
779 ((and (> score default) (memq mark (list gnus-downloadable-mark
780 gnus-undownloaded-mark)))
781 . gnus-summary-high-unread-face)
782 ((and (< score default) (memq mark (list gnus-downloadable-mark
783 gnus-undownloaded-mark)))
784 . gnus-summary-low-unread-face)
785 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
786 . gnus-summary-normal-unread-face)
788 . gnus-summary-high-read-face)
790 . gnus-summary-low-read-face)
792 . gnus-summary-normal-read-face))
793 "*Controls the highlighting of summary buffer lines.
795 A list of (FORM . FACE) pairs. When deciding how a a particular
796 summary line should be displayed, each form is evaluated. The content
797 of the face field after the first true form is used. You can change
798 how those summary lines are displayed, by editing the face field.
800 You can use the following variables in the FORM field.
802 score: The articles score
803 default: The default article score.
804 below: The score below which articles are automatically marked as read.
805 mark: The articles mark."
806 :group 'gnus-summary-visual
807 :type '(repeat (cons (sexp :tag "Form" nil)
810 (defcustom gnus-alter-header-function nil
811 "Function called to allow alteration of article header structures.
812 The function is called with one parameter, the article header vector,
813 which it may alter in any way.")
815 (defvar gnus-decode-encoded-word-function
816 (mime-find-field-decoder 'From 'nov)
817 "Variable that says which function should be used to decode a string with encoded words.")
819 (defcustom gnus-extra-headers nil
820 "*Extra headers to parse."
822 :type '(repeat symbol))
824 (defcustom gnus-ignored-from-addresses
825 (and user-mail-address (regexp-quote user-mail-address))
826 "*Regexp of From headers that may be suppressed in favor of To headers."
830 (defcustom gnus-group-charset-alist
831 '(("^hk\\>\\|^tw\\>\\|\\<big5\\>" cn-big5)
832 ("^cn\\>\\|\\<chinese\\>" cn-gb-2312)
833 ("^fj\\>\\|^japan\\>" iso-2022-jp-2)
834 ("^relcom\\>" koi8-r)
835 ("^\\(cz\\|hun\\|pl\\|sk\\|hr\\)\\>" iso-8859-2)
836 ("^israel\\>" iso-8859-1)
838 ("^\\(comp\\|rec\\|alt\\|sci\\|soc\\|news\\|gnu\\|bofh\\)\\>" iso-8859-1)
840 "Alist of regexps (to match group names) and default charsets to be used when reading."
841 :type '(repeat (list (regexp :tag "Group")
842 (symbol :tag "Charset")))
843 :group 'gnus-charset)
845 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit)
846 "List of charsets that should be ignored.
847 When these charsets are used in the \"charset\" parameter, the
848 default charset will be used instead."
849 :type '(repeat symbol)
850 :group 'gnus-charset)
852 (defcustom gnus-group-ignored-charsets-alist
853 '(("alt\\.chinese\\.text" iso-8859-1))
854 "Alist of regexps (to match group names) and charsets that should be ignored.
855 When these charsets are used in the \"charset\" parameter, the
856 default charset will be used instead."
857 :type '(repeat (cons (regexp :tag "Group")
859 :group 'gnus-charset)
861 (defcustom gnus-group-highlight-words-alist nil
862 "Alist of group regexps and highlight regexps.
863 This variable uses the same syntax as `gnus-emphasis-alist'."
864 :type '(repeat (cons (regexp :tag "Group")
865 (repeat (list (regexp :tag "Highlight regexp")
866 (number :tag "Group for entire word" 0)
867 (number :tag "Group for displayed part" 0)
869 gnus-emphasis-highlight-words)))))
870 :group 'gnus-summary-visual)
872 (defcustom gnus-use-wheel nil
873 "Use Intelli-mouse on summary movement"
875 :group 'gnus-summary-maneuvering)
877 (defcustom gnus-wheel-scroll-amount '(5 . 1)
878 "Amount to scroll messages by spinning the mouse wheel.
879 This is actually a cons cell, where the first item is the amount to scroll
880 on a normal wheel event, and the second is the amount to scroll when the
881 wheel is moved with the shift key depressed."
882 :type '(cons (integer :tag "Shift") integer)
883 :group 'gnus-summary-maneuvering)
885 (defcustom gnus-wheel-edge-resistance 2
886 "How hard it should be to change the current article
887 by moving the mouse over the edge of the article window."
889 :group 'gnus-summary-maneuvering)
891 ;;; Internal variables
893 (defvar gnus-scores-exclude-files nil)
894 (defvar gnus-page-broken nil)
895 (defvar gnus-inhibit-mime-unbuttonizing nil)
897 (defvar gnus-original-article nil)
898 (defvar gnus-article-internal-prepare-hook nil)
899 (defvar gnus-newsgroup-process-stack nil)
901 (defvar gnus-thread-indent-array nil)
902 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
904 ;; Avoid highlighting in kill files.
905 (defvar gnus-summary-inhibit-highlight nil)
906 (defvar gnus-newsgroup-selected-overlay nil)
907 (defvar gnus-inhibit-limiting nil)
908 (defvar gnus-newsgroup-adaptive-score-file nil)
909 (defvar gnus-current-score-file nil)
910 (defvar gnus-current-move-group nil)
911 (defvar gnus-current-copy-group nil)
912 (defvar gnus-current-crosspost-group nil)
914 (defvar gnus-newsgroup-dependencies nil)
915 (defvar gnus-newsgroup-adaptive nil)
916 (defvar gnus-summary-display-article-function nil)
917 (defvar gnus-summary-highlight-line-function nil
918 "Function called after highlighting a summary line.")
920 (defvar gnus-summary-line-format-alist
921 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
922 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
923 (?s gnus-tmp-subject-or-nil ?s)
924 (?n gnus-tmp-name ?s)
925 (?A (std11-address-string
926 (car (mime-read-field 'From gnus-tmp-header))) ?s)
927 (?a (or (std11-full-name-string
928 (car (mime-read-field 'From gnus-tmp-header)))
930 (?F gnus-tmp-from ?s)
931 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
932 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
933 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
934 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
935 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
936 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
937 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
938 (?L gnus-tmp-lines ?d)
939 (?I gnus-tmp-indentation ?s)
940 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
941 (?R gnus-tmp-replied ?c)
942 (?\[ gnus-tmp-opening-bracket ?c)
943 (?\] gnus-tmp-closing-bracket ?c)
944 (?\> (make-string gnus-tmp-level ? ) ?s)
945 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
946 (?i gnus-tmp-score ?d)
947 (?z gnus-tmp-score-char ?c)
948 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
949 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
950 (?U gnus-tmp-unread ?c)
951 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header) ?s)
952 (?t (gnus-summary-number-of-articles-in-thread
953 (and (boundp 'thread) (car thread)) gnus-tmp-level)
955 (?e (gnus-summary-number-of-articles-in-thread
956 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
958 (?u gnus-tmp-user-defined ?s)
959 (?P (gnus-pick-line-number) ?d))
960 "An alist of format specifications that can appear in summary lines,
961 and what variables they correspond with, along with the type of the
962 variable (string, integer, character, etc).")
964 (defvar gnus-summary-dummy-line-format-alist
965 `((?S gnus-tmp-subject ?s)
966 (?N gnus-tmp-number ?d)
967 (?u gnus-tmp-user-defined ?s)))
969 (defvar gnus-summary-mode-line-format-alist
970 `((?G gnus-tmp-group-name ?s)
971 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
972 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
973 (?A gnus-tmp-article-number ?d)
974 (?Z gnus-tmp-unread-and-unselected ?s)
976 (?U gnus-tmp-unread-and-unticked ?d)
977 (?S gnus-tmp-subject ?s)
978 (?e gnus-tmp-unselected ?d)
979 (?u gnus-tmp-user-defined ?s)
980 (?d (length gnus-newsgroup-dormant) ?d)
981 (?t (length gnus-newsgroup-marked) ?d)
982 (?r (length gnus-newsgroup-reads) ?d)
983 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
984 (?E gnus-newsgroup-expunged-tally ?d)
985 (?s (gnus-current-score-file-nondirectory) ?s)))
987 (defvar gnus-last-search-regexp nil
988 "Default regexp for article search command.")
990 (defvar gnus-last-shell-command nil
991 "Default shell command on article.")
993 (defvar gnus-newsgroup-begin nil)
994 (defvar gnus-newsgroup-end nil)
995 (defvar gnus-newsgroup-last-rmail nil)
996 (defvar gnus-newsgroup-last-mail nil)
997 (defvar gnus-newsgroup-last-folder nil)
998 (defvar gnus-newsgroup-last-file nil)
999 (defvar gnus-newsgroup-auto-expire nil)
1000 (defvar gnus-newsgroup-active nil)
1002 (defvar gnus-newsgroup-data nil)
1003 (defvar gnus-newsgroup-data-reverse nil)
1004 (defvar gnus-newsgroup-limit nil)
1005 (defvar gnus-newsgroup-limits nil)
1007 (defvar gnus-newsgroup-unreads nil
1008 "List of unread articles in the current newsgroup.")
1010 (defvar gnus-newsgroup-unselected nil
1011 "List of unselected unread articles in the current newsgroup.")
1013 (defvar gnus-newsgroup-reads nil
1014 "Alist of read articles and article marks in the current newsgroup.")
1016 (defvar gnus-newsgroup-expunged-tally nil)
1018 (defvar gnus-newsgroup-marked nil
1019 "List of ticked articles in the current newsgroup (a subset of unread art).")
1021 (defvar gnus-newsgroup-killed nil
1022 "List of ranges of articles that have been through the scoring process.")
1024 (defvar gnus-newsgroup-cached nil
1025 "List of articles that come from the article cache.")
1027 (defvar gnus-newsgroup-saved nil
1028 "List of articles that have been saved.")
1030 (defvar gnus-newsgroup-kill-headers nil)
1032 (defvar gnus-newsgroup-replied nil
1033 "List of articles that have been replied to in the current newsgroup.")
1035 (defvar gnus-newsgroup-expirable nil
1036 "List of articles in the current newsgroup that can be expired.")
1038 (defvar gnus-newsgroup-processable nil
1039 "List of articles in the current newsgroup that can be processed.")
1041 (defvar gnus-newsgroup-downloadable nil
1042 "List of articles in the current newsgroup that can be processed.")
1044 (defvar gnus-newsgroup-undownloaded nil
1045 "List of articles in the current newsgroup that haven't been downloaded..")
1047 (defvar gnus-newsgroup-unsendable nil
1048 "List of articles in the current newsgroup that won't be sent.")
1050 (defvar gnus-newsgroup-bookmarks nil
1051 "List of articles in the current newsgroup that have bookmarks.")
1053 (defvar gnus-newsgroup-dormant nil
1054 "List of dormant articles in the current newsgroup.")
1056 (defvar gnus-newsgroup-scored nil
1057 "List of scored articles in the current newsgroup.")
1059 (defvar gnus-newsgroup-incorporated nil
1060 "List of incorporated articles in the current newsgroup.")
1062 (defvar gnus-newsgroup-headers nil
1063 "List of article headers in the current newsgroup.")
1065 (defvar gnus-newsgroup-threads nil)
1067 (defvar gnus-newsgroup-prepared nil
1068 "Whether the current group has been prepared properly.")
1070 (defvar gnus-newsgroup-ancient nil
1071 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1073 (defvar gnus-newsgroup-sparse nil)
1075 (defvar gnus-current-article nil)
1076 (defvar gnus-article-current nil)
1077 (defvar gnus-current-headers nil)
1078 (defvar gnus-have-all-headers nil)
1079 (defvar gnus-last-article nil)
1080 (defvar gnus-newsgroup-history nil)
1081 (defvar gnus-newsgroup-charset nil)
1082 (defvar gnus-newsgroup-ephemeral-charset nil)
1083 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1085 (defconst gnus-summary-local-variables
1086 '(gnus-newsgroup-name
1087 gnus-newsgroup-begin gnus-newsgroup-end
1088 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1089 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1090 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1091 gnus-newsgroup-unselected gnus-newsgroup-marked
1092 gnus-newsgroup-reads gnus-newsgroup-saved
1093 gnus-newsgroup-replied gnus-newsgroup-expirable
1094 gnus-newsgroup-processable gnus-newsgroup-killed
1095 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1096 gnus-newsgroup-unsendable
1097 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1098 gnus-newsgroup-headers gnus-newsgroup-threads
1099 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1100 gnus-current-article gnus-current-headers gnus-have-all-headers
1101 gnus-last-article gnus-article-internal-prepare-hook
1102 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1103 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1104 gnus-thread-expunge-below
1105 gnus-score-alist gnus-current-score-file
1106 (gnus-summary-expunge-below . global)
1107 (gnus-summary-mark-below . global)
1108 gnus-newsgroup-active gnus-scores-exclude-files
1109 gnus-newsgroup-history gnus-newsgroup-ancient
1110 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1111 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1112 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1113 (gnus-newsgroup-expunged-tally . 0)
1114 gnus-cache-removable-articles gnus-newsgroup-cached
1115 gnus-newsgroup-data gnus-newsgroup-data-reverse
1116 gnus-newsgroup-limit gnus-newsgroup-limits
1117 gnus-newsgroup-charset
1118 gnus-newsgroup-incorporated)
1119 "Variables that are buffer-local to the summary buffers.")
1121 ;; Byte-compiler warning.
1122 (defvar gnus-article-mode-map)
1124 ;; Subject simplification.
1126 (defun gnus-simplify-whitespace (str)
1127 "Remove excessive whitespace."
1130 (while (string-match "[ \t][ \t]+" mystr)
1131 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1133 (substring mystr (match-end 0)))))
1135 (when (string-match "^[ \t]+" mystr)
1136 (setq mystr (substring mystr (match-end 0))))
1138 (when (string-match "[ \t]+$" mystr)
1139 (setq mystr (substring mystr 0 (match-beginning 0))))
1142 (defsubst gnus-simplify-subject-re (subject)
1143 "Remove \"Re:\" from subject lines."
1144 (if (string-match "^[Rr][Ee]: *" subject)
1145 (substring subject (match-end 0))
1148 (defun gnus-simplify-subject (subject &optional re-only)
1149 "Remove `Re:' and words in parentheses.
1150 If RE-ONLY is non-nil, strip leading `Re:'s only."
1151 (let ((case-fold-search t)) ;Ignore case.
1152 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1153 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1154 (setq subject (substring subject (match-end 0))))
1155 ;; Remove uninteresting prefixes.
1156 (when (and (not re-only)
1157 gnus-simplify-ignored-prefixes
1158 (string-match gnus-simplify-ignored-prefixes subject))
1159 (setq subject (substring subject (match-end 0))))
1160 ;; Remove words in parentheses from end.
1162 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1163 (setq subject (substring subject 0 (match-beginning 0)))))
1164 ;; Return subject string.
1167 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1169 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1170 (goto-char (point-min))
1171 (while (re-search-forward regexp nil t)
1172 (replace-match (or newtext ""))))
1174 (defun gnus-simplify-buffer-fuzzy ()
1175 "Simplify string in the buffer fuzzily.
1176 The string in the accessible portion of the current buffer is simplified.
1177 It is assumed to be a single-line subject.
1178 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1179 matter is removed. Additional things can be deleted by setting
1180 gnus-simplify-subject-fuzzy-regexp."
1181 (let ((case-fold-search t)
1183 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1185 (while (not (eq modified-tick (buffer-modified-tick)))
1186 (setq modified-tick (buffer-modified-tick))
1188 ((listp gnus-simplify-subject-fuzzy-regexp)
1189 (mapcar 'gnus-simplify-buffer-fuzzy-step
1190 gnus-simplify-subject-fuzzy-regexp))
1191 (gnus-simplify-subject-fuzzy-regexp
1192 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1193 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1194 (gnus-simplify-buffer-fuzzy-step
1195 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1196 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1198 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1199 (gnus-simplify-buffer-fuzzy-step " +" " ")
1200 (gnus-simplify-buffer-fuzzy-step " $")
1201 (gnus-simplify-buffer-fuzzy-step "^ +")))
1203 (defun gnus-simplify-subject-fuzzy (subject)
1204 "Simplify a subject string fuzzily.
1205 See `gnus-simplify-buffer-fuzzy' for details."
1207 (gnus-set-work-buffer)
1208 (let ((case-fold-search t))
1209 ;; Remove uninteresting prefixes.
1210 (when (and gnus-simplify-ignored-prefixes
1211 (string-match gnus-simplify-ignored-prefixes subject))
1212 (setq subject (substring subject (match-end 0))))
1214 (inline (gnus-simplify-buffer-fuzzy))
1217 (defsubst gnus-simplify-subject-fully (subject)
1218 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1220 (gnus-simplify-subject-functions
1221 (gnus-map-function gnus-simplify-subject-functions subject))
1222 ((null gnus-summary-gather-subject-limit)
1223 (gnus-simplify-subject-re subject))
1224 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1225 (gnus-simplify-subject-fuzzy subject))
1226 ((numberp gnus-summary-gather-subject-limit)
1227 (gnus-limit-string (gnus-simplify-subject-re subject)
1228 gnus-summary-gather-subject-limit))
1232 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1233 "Check whether two subjects are equal.
1234 If optional argument simple-first is t, first argument is already
1237 ((null simple-first)
1238 (equal (gnus-simplify-subject-fully s1)
1239 (gnus-simplify-subject-fully s2)))
1242 (gnus-simplify-subject-fully s2)))))
1244 (defun gnus-summary-bubble-group ()
1245 "Increase the score of the current group.
1246 This is a handy function to add to `gnus-summary-exit-hook' to
1247 increase the score of each group you read."
1248 (gnus-group-add-score gnus-newsgroup-name))
1252 ;;; Gnus summary mode
1255 (put 'gnus-summary-mode 'mode-class 'special)
1258 ;; Non-orthogonal keys
1260 (gnus-define-keys gnus-summary-mode-map
1261 " " gnus-summary-next-page
1262 "\177" gnus-summary-prev-page
1263 [delete] gnus-summary-prev-page
1264 [backspace] gnus-summary-prev-page
1265 "\r" gnus-summary-scroll-up
1266 "\M-\r" gnus-summary-scroll-down
1267 "n" gnus-summary-next-unread-article
1268 "p" gnus-summary-prev-unread-article
1269 "N" gnus-summary-next-article
1270 "P" gnus-summary-prev-article
1271 "\M-\C-n" gnus-summary-next-same-subject
1272 "\M-\C-p" gnus-summary-prev-same-subject
1273 "\M-n" gnus-summary-next-unread-subject
1274 "\M-p" gnus-summary-prev-unread-subject
1275 "." gnus-summary-first-unread-article
1276 "," gnus-summary-best-unread-article
1277 "\M-s" gnus-summary-search-article-forward
1278 "\M-r" gnus-summary-search-article-backward
1279 "<" gnus-summary-beginning-of-article
1280 ">" gnus-summary-end-of-article
1281 "j" gnus-summary-goto-article
1282 "^" gnus-summary-refer-parent-article
1283 "\M-^" gnus-summary-refer-article
1284 "u" gnus-summary-tick-article-forward
1285 "!" gnus-summary-tick-article-forward
1286 "U" gnus-summary-tick-article-backward
1287 "d" gnus-summary-mark-as-read-forward
1288 "D" gnus-summary-mark-as-read-backward
1289 "E" gnus-summary-mark-as-expirable
1290 "\M-u" gnus-summary-clear-mark-forward
1291 "\M-U" gnus-summary-clear-mark-backward
1292 "k" gnus-summary-kill-same-subject-and-select
1293 "\C-k" gnus-summary-kill-same-subject
1294 "\M-\C-k" gnus-summary-kill-thread
1295 "\M-\C-l" gnus-summary-lower-thread
1296 "e" gnus-summary-edit-article
1297 "#" gnus-summary-mark-as-processable
1298 "\M-#" gnus-summary-unmark-as-processable
1299 "\M-\C-t" gnus-summary-toggle-threads
1300 "\M-\C-s" gnus-summary-show-thread
1301 "\M-\C-h" gnus-summary-hide-thread
1302 "\M-\C-f" gnus-summary-next-thread
1303 "\M-\C-b" gnus-summary-prev-thread
1304 "\M-\C-u" gnus-summary-up-thread
1305 "\M-\C-d" gnus-summary-down-thread
1306 "&" gnus-summary-execute-command
1307 "c" gnus-summary-catchup-and-exit
1308 "\C-w" gnus-summary-mark-region-as-read
1309 "\C-t" gnus-summary-toggle-truncation
1310 "?" gnus-summary-mark-as-dormant
1311 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1312 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1313 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1314 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1315 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1316 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1317 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1318 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1319 "=" gnus-summary-expand-window
1320 "\C-x\C-s" gnus-summary-reselect-current-group
1321 "\M-g" gnus-summary-rescan-group
1322 "w" gnus-summary-stop-page-breaking
1323 "\C-c\C-r" gnus-summary-caesar-message
1324 "\M-t" gnus-summary-toggle-mime
1325 "f" gnus-summary-followup
1326 "F" gnus-summary-followup-with-original
1327 "C" gnus-summary-cancel-article
1328 "r" gnus-summary-reply
1329 "R" gnus-summary-reply-with-original
1330 "\C-c\C-f" gnus-summary-mail-forward
1331 "o" gnus-summary-save-article
1332 "\C-o" gnus-summary-save-article-mail
1333 "|" gnus-summary-pipe-output
1334 "\M-k" gnus-summary-edit-local-kill
1335 "\M-K" gnus-summary-edit-global-kill
1337 "\C-c\C-d" gnus-summary-describe-group
1338 "q" gnus-summary-exit
1339 "Q" gnus-summary-exit-no-update
1340 "\C-c\C-i" gnus-info-find-node
1341 gnus-mouse-2 gnus-mouse-pick-article
1342 "m" gnus-summary-mail-other-window
1343 "a" gnus-summary-post-news
1344 "x" gnus-summary-limit-to-unread
1345 "s" gnus-summary-isearch-article
1346 "t" gnus-article-toggle-headers
1347 "g" gnus-summary-show-article
1348 "l" gnus-summary-goto-last-article
1349 "v" gnus-summary-preview-mime-message
1350 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1351 "\C-d" gnus-summary-enter-digest-group
1352 "\M-\C-d" gnus-summary-read-document
1353 "\M-\C-e" gnus-summary-edit-parameters
1354 "\M-\C-g" gnus-summary-customize-parameters
1356 "*" gnus-cache-enter-article
1357 "\M-*" gnus-cache-remove-article
1358 "\M-&" gnus-summary-universal-argument
1359 "\C-l" gnus-recenter
1360 "I" gnus-summary-increase-score
1361 "L" gnus-summary-lower-score
1362 "\M-i" gnus-symbolic-argument
1363 "h" gnus-summary-select-article-buffer
1365 "V" gnus-summary-score-map
1366 "X" gnus-uu-extract-map
1367 "S" gnus-summary-send-map)
1369 ;; Sort of orthogonal keymap
1370 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1371 "t" gnus-summary-tick-article-forward
1372 "!" gnus-summary-tick-article-forward
1373 "d" gnus-summary-mark-as-read-forward
1374 "r" gnus-summary-mark-as-read-forward
1375 "c" gnus-summary-clear-mark-forward
1376 " " gnus-summary-clear-mark-forward
1377 "e" gnus-summary-mark-as-expirable
1378 "x" gnus-summary-mark-as-expirable
1379 "?" gnus-summary-mark-as-dormant
1380 "b" gnus-summary-set-bookmark
1381 "B" gnus-summary-remove-bookmark
1382 "#" gnus-summary-mark-as-processable
1383 "\M-#" gnus-summary-unmark-as-processable
1384 "S" gnus-summary-limit-include-expunged
1385 "C" gnus-summary-catchup
1386 "H" gnus-summary-catchup-to-here
1387 "\C-c" gnus-summary-catchup-all
1388 "k" gnus-summary-kill-same-subject-and-select
1389 "K" gnus-summary-kill-same-subject
1390 "P" gnus-uu-mark-map)
1392 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1393 "c" gnus-summary-clear-above
1394 "u" gnus-summary-tick-above
1395 "m" gnus-summary-mark-above
1396 "k" gnus-summary-kill-below)
1398 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1399 "/" gnus-summary-limit-to-subject
1400 "n" gnus-summary-limit-to-articles
1401 "w" gnus-summary-pop-limit
1402 "s" gnus-summary-limit-to-subject
1403 "a" gnus-summary-limit-to-author
1404 "u" gnus-summary-limit-to-unread
1405 "m" gnus-summary-limit-to-marks
1406 "M" gnus-summary-limit-exclude-marks
1407 "v" gnus-summary-limit-to-score
1408 "*" gnus-summary-limit-include-cached
1409 "D" gnus-summary-limit-include-dormant
1410 "T" gnus-summary-limit-include-thread
1411 "d" gnus-summary-limit-exclude-dormant
1412 "t" gnus-summary-limit-to-age
1413 "x" gnus-summary-limit-to-extra
1414 "E" gnus-summary-limit-include-expunged
1415 "c" gnus-summary-limit-exclude-childless-dormant
1416 "C" gnus-summary-limit-mark-excluded-as-read)
1418 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1419 "n" gnus-summary-next-unread-article
1420 "p" gnus-summary-prev-unread-article
1421 "N" gnus-summary-next-article
1422 "P" gnus-summary-prev-article
1423 "\C-n" gnus-summary-next-same-subject
1424 "\C-p" gnus-summary-prev-same-subject
1425 "\M-n" gnus-summary-next-unread-subject
1426 "\M-p" gnus-summary-prev-unread-subject
1427 "f" gnus-summary-first-unread-article
1428 "b" gnus-summary-best-unread-article
1429 "j" gnus-summary-goto-article
1430 "g" gnus-summary-goto-subject
1431 "l" gnus-summary-goto-last-article
1432 "o" gnus-summary-pop-article)
1434 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1435 "k" gnus-summary-kill-thread
1436 "l" gnus-summary-lower-thread
1437 "i" gnus-summary-raise-thread
1438 "T" gnus-summary-toggle-threads
1439 "t" gnus-summary-rethread-current
1440 "^" gnus-summary-reparent-thread
1441 "s" gnus-summary-show-thread
1442 "S" gnus-summary-show-all-threads
1443 "h" gnus-summary-hide-thread
1444 "H" gnus-summary-hide-all-threads
1445 "n" gnus-summary-next-thread
1446 "p" gnus-summary-prev-thread
1447 "u" gnus-summary-up-thread
1448 "o" gnus-summary-top-thread
1449 "d" gnus-summary-down-thread
1450 "#" gnus-uu-mark-thread
1451 "\M-#" gnus-uu-unmark-thread)
1453 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1454 "g" gnus-summary-prepare
1455 "c" gnus-summary-insert-cached-articles)
1457 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1458 "c" gnus-summary-catchup-and-exit
1459 "C" gnus-summary-catchup-all-and-exit
1460 "E" gnus-summary-exit-no-update
1461 "J" gnus-summary-jump-to-other-group
1462 "Q" gnus-summary-exit
1463 "Z" gnus-summary-exit
1464 "n" gnus-summary-catchup-and-goto-next-group
1465 "R" gnus-summary-reselect-current-group
1466 "G" gnus-summary-rescan-group
1467 "N" gnus-summary-next-group
1468 "s" gnus-summary-save-newsrc
1469 "P" gnus-summary-prev-group)
1471 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1472 " " gnus-summary-next-page
1473 "n" gnus-summary-next-page
1474 "\177" gnus-summary-prev-page
1475 [delete] gnus-summary-prev-page
1476 "p" gnus-summary-prev-page
1477 "\r" gnus-summary-scroll-up
1478 "\M-\r" gnus-summary-scroll-down
1479 "<" gnus-summary-beginning-of-article
1480 ">" gnus-summary-end-of-article
1481 "b" gnus-summary-beginning-of-article
1482 "e" gnus-summary-end-of-article
1483 "^" gnus-summary-refer-parent-article
1484 "r" gnus-summary-refer-parent-article
1485 "D" gnus-summary-enter-digest-group
1486 "R" gnus-summary-refer-references
1487 "T" gnus-summary-refer-thread
1488 "g" gnus-summary-show-article
1489 "s" gnus-summary-isearch-article
1490 "P" gnus-summary-print-article
1491 "t" gnus-article-babel)
1493 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1494 "b" gnus-article-add-buttons
1495 "B" gnus-article-add-buttons-to-head
1496 "o" gnus-article-treat-overstrike
1497 "e" gnus-article-emphasize
1498 "w" gnus-article-fill-cited-article
1499 "Q" gnus-article-fill-long-lines
1500 "C" gnus-article-capitalize-sentences
1501 "c" gnus-article-remove-cr
1502 "f" gnus-article-display-x-face
1503 "l" gnus-summary-stop-page-breaking
1504 "r" gnus-summary-caesar-message
1505 "t" gnus-article-toggle-headers
1506 "v" gnus-summary-verbose-headers
1507 "m" gnus-summary-toggle-mime
1508 "H" gnus-article-strip-headers-in-body
1509 "d" gnus-article-treat-dumbquotes)
1511 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1512 "a" gnus-article-hide
1513 "h" gnus-article-toggle-headers
1514 "b" gnus-article-hide-boring-headers
1515 "s" gnus-article-hide-signature
1516 "c" gnus-article-hide-citation
1517 "C" gnus-article-hide-citation-in-followups
1518 "p" gnus-article-hide-pgp
1519 "B" gnus-article-strip-banner
1520 "P" gnus-article-hide-pem
1521 "\C-c" gnus-article-hide-citation-maybe)
1523 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1524 "a" gnus-article-highlight
1525 "h" gnus-article-highlight-headers
1526 "c" gnus-article-highlight-citation
1527 "s" gnus-article-highlight-signature)
1529 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1530 "z" gnus-article-date-ut
1531 "u" gnus-article-date-ut
1532 "l" gnus-article-date-local
1533 "e" gnus-article-date-lapsed
1534 "o" gnus-article-date-original
1535 "i" gnus-article-date-iso8601
1536 "s" gnus-article-date-user)
1538 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1539 "t" gnus-article-remove-trailing-blank-lines
1540 "l" gnus-article-strip-leading-blank-lines
1541 "m" gnus-article-strip-multiple-blank-lines
1542 "a" gnus-article-strip-blank-lines
1543 "A" gnus-article-strip-all-blank-lines
1544 "s" gnus-article-strip-leading-space
1545 "e" gnus-article-strip-trailing-space)
1547 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1549 "f" gnus-summary-fetch-faq
1550 "d" gnus-summary-describe-group
1551 "h" gnus-summary-describe-briefly
1552 "i" gnus-info-find-node)
1554 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1555 "e" gnus-summary-expire-articles
1556 "\M-\C-e" gnus-summary-expire-articles-now
1557 "\177" gnus-summary-delete-article
1558 [delete] gnus-summary-delete-article
1559 [backspace] gnus-summary-delete-article
1560 "m" gnus-summary-move-article
1561 "r" gnus-summary-respool-article
1562 "w" gnus-summary-edit-article
1563 "c" gnus-summary-copy-article
1564 "B" gnus-summary-crosspost-article
1565 "q" gnus-summary-respool-query
1566 "t" gnus-summary-respool-trace
1567 "i" gnus-summary-import-article
1568 "p" gnus-summary-article-posted-p)
1570 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1571 "o" gnus-summary-save-article
1572 "m" gnus-summary-save-article-mail
1573 "F" gnus-summary-write-article-file
1574 "r" gnus-summary-save-article-rmail
1575 "f" gnus-summary-save-article-file
1576 "b" gnus-summary-save-article-body-file
1577 "h" gnus-summary-save-article-folder
1578 "v" gnus-summary-save-article-vm
1579 "p" gnus-summary-pipe-output
1580 "s" gnus-soup-add-article)
1582 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1583 "b" gnus-summary-display-buttonized
1584 "m" gnus-summary-repair-multipart
1585 "v" gnus-article-view-part
1586 "o" gnus-article-save-part
1587 "c" gnus-article-copy-part
1588 "e" gnus-article-externalize-part
1589 "i" gnus-article-inline-part
1590 "|" gnus-article-pipe-part)
1593 (defun gnus-summary-make-menu-bar ()
1594 (gnus-turn-off-edit-menu 'summary)
1596 (unless (boundp 'gnus-summary-misc-menu)
1599 gnus-summary-kill-menu gnus-summary-mode-map ""
1604 ["Enter score..." gnus-summary-score-entry t]
1605 ["Customize" gnus-score-customize t])
1606 (gnus-make-score-map 'increase)
1607 (gnus-make-score-map 'lower)
1609 ["Kill below" gnus-summary-kill-below t]
1610 ["Mark above" gnus-summary-mark-above t]
1611 ["Tick above" gnus-summary-tick-above t]
1612 ["Clear above" gnus-summary-clear-above t])
1613 ["Current score" gnus-summary-current-score t]
1614 ["Set score" gnus-summary-set-score t]
1615 ["Switch current score file..." gnus-score-change-score-file t]
1616 ["Set mark below..." gnus-score-set-mark-below t]
1617 ["Set expunge below..." gnus-score-set-expunge-below t]
1618 ["Edit current score file" gnus-score-edit-current-scores t]
1619 ["Edit score file" gnus-score-edit-file t]
1620 ["Trace score" gnus-score-find-trace t]
1621 ["Find words" gnus-score-find-favourite-words t]
1622 ["Rescore buffer" gnus-summary-rescore t]
1623 ["Increase score..." gnus-summary-increase-score t]
1624 ["Lower score..." gnus-summary-lower-score t]))))
1626 ;; Define both the Article menu in the summary buffer and the equivalent
1627 ;; Commands menu in the article buffer here for consistency.
1630 ["All" gnus-article-hide t]
1631 ["Headers" gnus-article-toggle-headers t]
1632 ["Signature" gnus-article-hide-signature t]
1633 ["Citation" gnus-article-hide-citation t]
1634 ["PGP" gnus-article-hide-pgp t]
1635 ["Banner" gnus-article-strip-banner t]
1636 ["Boring headers" gnus-article-hide-boring-headers t])
1638 ["All" gnus-article-highlight t]
1639 ["Headers" gnus-article-highlight-headers t]
1640 ["Signature" gnus-article-highlight-signature t]
1641 ["Citation" gnus-article-highlight-citation t])
1643 ["Local" gnus-article-date-local t]
1644 ["ISO8601" gnus-article-date-iso8601 t]
1645 ["UT" gnus-article-date-ut t]
1646 ["Original" gnus-article-date-original t]
1647 ["Lapsed" gnus-article-date-lapsed t]
1648 ["User-defined" gnus-article-date-user t])
1651 ["Leading" gnus-article-strip-leading-blank-lines t]
1652 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1653 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1654 ["All of the above" gnus-article-strip-blank-lines t]
1655 ["All" gnus-article-strip-all-blank-lines t]
1656 ["Leading space" gnus-article-strip-leading-space t]
1657 ["Trailing space" gnus-article-strip-trailing-space t])
1658 ["Overstrike" gnus-article-treat-overstrike t]
1659 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1660 ["Emphasis" gnus-article-emphasize t]
1661 ["Word wrap" gnus-article-fill-cited-article t]
1662 ["Fill long lines" gnus-article-fill-long-lines t]
1663 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1664 ["CR" gnus-article-remove-cr t]
1665 ["Show X-Face" gnus-article-display-x-face t]
1666 ["Rot 13" gnus-summary-caesar-message t]
1667 ["Unix pipe" gnus-summary-pipe-message t]
1668 ["Add buttons" gnus-article-add-buttons t]
1669 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1670 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1671 ["Toggle MIME" gnus-summary-toggle-mime t]
1672 ["Verbose header" gnus-summary-verbose-headers t]
1673 ["Toggle header" gnus-summary-toggle-header t])
1675 ["Save in default format" gnus-summary-save-article t]
1676 ["Save in file" gnus-summary-save-article-file t]
1677 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1678 ["Save in MH folder" gnus-summary-save-article-folder t]
1679 ["Save in VM folder" gnus-summary-save-article-vm t]
1680 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1681 ["Save body in file" gnus-summary-save-article-body-file t]
1682 ["Pipe through a filter" gnus-summary-pipe-output t]
1683 ["Add to SOUP packet" gnus-soup-add-article t]
1684 ["Print" gnus-summary-print-article t])
1686 ["Respool article..." gnus-summary-respool-article t]
1687 ["Move article..." gnus-summary-move-article
1688 (gnus-check-backend-function
1689 'request-move-article gnus-newsgroup-name)]
1690 ["Copy article..." gnus-summary-copy-article t]
1691 ["Crosspost article..." gnus-summary-crosspost-article
1692 (gnus-check-backend-function
1693 'request-replace-article gnus-newsgroup-name)]
1694 ["Import file..." gnus-summary-import-article t]
1695 ["Check if posted" gnus-summary-article-posted-p t]
1696 ["Edit article" gnus-summary-edit-article
1697 (not (gnus-group-read-only-p))]
1698 ["Delete article" gnus-summary-delete-article
1699 (gnus-check-backend-function
1700 'request-expire-articles gnus-newsgroup-name)]
1701 ["Query respool" gnus-summary-respool-query t]
1702 ["Trace respool" gnus-summary-respool-trace t]
1703 ["Delete expirable articles" gnus-summary-expire-articles-now
1704 (gnus-check-backend-function
1705 'request-expire-articles gnus-newsgroup-name)])
1707 ["Uudecode" gnus-uu-decode-uu t]
1708 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1709 ["Unshar" gnus-uu-decode-unshar t]
1710 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1711 ["Save" gnus-uu-decode-save t]
1712 ["Binhex" gnus-uu-decode-binhex t]
1713 ["Postscript" gnus-uu-decode-postscript t])
1715 ["Enter article" gnus-cache-enter-article t]
1716 ["Remove article" gnus-cache-remove-article t])
1717 ["Translate" gnus-article-babel t]
1718 ["Select article buffer" gnus-summary-select-article-buffer t]
1719 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1720 ["Isearch article..." gnus-summary-isearch-article t]
1721 ["Beginning of the article" gnus-summary-beginning-of-article t]
1722 ["End of the article" gnus-summary-end-of-article t]
1723 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1724 ["Fetch referenced articles" gnus-summary-refer-references t]
1725 ["Fetch current thread" gnus-summary-refer-thread t]
1726 ["Fetch article with id..." gnus-summary-refer-article t]
1727 ["Redisplay" gnus-summary-show-article t])))
1729 gnus-summary-article-menu gnus-summary-mode-map ""
1730 (cons "Article" innards))
1733 gnus-article-commands-menu gnus-article-mode-map ""
1734 (cons "Commands" innards)))
1737 gnus-summary-thread-menu gnus-summary-mode-map ""
1739 ["Toggle threading" gnus-summary-toggle-threads t]
1740 ["Hide threads" gnus-summary-hide-all-threads t]
1741 ["Show threads" gnus-summary-show-all-threads t]
1742 ["Hide thread" gnus-summary-hide-thread t]
1743 ["Show thread" gnus-summary-show-thread t]
1744 ["Go to next thread" gnus-summary-next-thread t]
1745 ["Go to previous thread" gnus-summary-prev-thread t]
1746 ["Go down thread" gnus-summary-down-thread t]
1747 ["Go up thread" gnus-summary-up-thread t]
1748 ["Top of thread" gnus-summary-top-thread t]
1749 ["Mark thread as read" gnus-summary-kill-thread t]
1750 ["Lower thread score" gnus-summary-lower-thread t]
1751 ["Raise thread score" gnus-summary-raise-thread t]
1752 ["Rethread current" gnus-summary-rethread-current t]
1756 gnus-summary-post-menu gnus-summary-mode-map ""
1758 ["Post an article" gnus-summary-post-news t]
1759 ["Followup" gnus-summary-followup t]
1760 ["Followup and yank" gnus-summary-followup-with-original t]
1761 ["Supersede article" gnus-summary-supersede-article t]
1762 ["Cancel article" gnus-summary-cancel-article t]
1763 ["Reply" gnus-summary-reply t]
1764 ["Reply and yank" gnus-summary-reply-with-original t]
1765 ["Wide reply" gnus-summary-wide-reply t]
1766 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1767 ["Mail forward" gnus-summary-mail-forward t]
1768 ["Post forward" gnus-summary-post-forward t]
1769 ["Digest and mail" gnus-summary-mail-digest t]
1770 ["Digest and post" gnus-summary-post-digest t]
1771 ["Resend message" gnus-summary-resend-message t]
1772 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1773 ["Send a mail" gnus-summary-mail-other-window t]
1774 ["Uuencode and post" gnus-uu-post-news t]
1775 ["Followup via news" gnus-summary-followup-to-mail t]
1776 ["Followup via news and yank"
1777 gnus-summary-followup-to-mail-with-original t]
1779 ;;["Send" gnus-summary-send-draft t]
1780 ;;["Send bounced" gnus-resend-bounced-mail t])
1784 gnus-summary-misc-menu gnus-summary-mode-map ""
1787 ["Mark as read" gnus-summary-mark-as-read-forward t]
1788 ["Mark same subject and select"
1789 gnus-summary-kill-same-subject-and-select t]
1790 ["Mark same subject" gnus-summary-kill-same-subject t]
1791 ["Catchup" gnus-summary-catchup t]
1792 ["Catchup all" gnus-summary-catchup-all t]
1793 ["Catchup to here" gnus-summary-catchup-to-here t]
1794 ["Catchup region" gnus-summary-mark-region-as-read t]
1795 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1797 ["Tick" gnus-summary-tick-article-forward t]
1798 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1799 ["Remove marks" gnus-summary-clear-mark-forward t]
1800 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1801 ["Set bookmark" gnus-summary-set-bookmark t]
1802 ["Remove bookmark" gnus-summary-remove-bookmark t])
1804 ["Marks..." gnus-summary-limit-to-marks t]
1805 ["Subject..." gnus-summary-limit-to-subject t]
1806 ["Author..." gnus-summary-limit-to-author t]
1807 ["Age..." gnus-summary-limit-to-age t]
1808 ["Extra..." gnus-summary-limit-to-extra t]
1809 ["Score" gnus-summary-limit-to-score t]
1810 ["Unread" gnus-summary-limit-to-unread t]
1811 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1812 ["Articles" gnus-summary-limit-to-articles t]
1813 ["Pop limit" gnus-summary-pop-limit t]
1814 ["Show dormant" gnus-summary-limit-include-dormant t]
1815 ["Hide childless dormant"
1816 gnus-summary-limit-exclude-childless-dormant t]
1817 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1818 ["Hide marked" gnus-summary-limit-exclude-marks t]
1819 ["Show expunged" gnus-summary-show-all-expunged t])
1821 ["Set mark" gnus-summary-mark-as-processable t]
1822 ["Remove mark" gnus-summary-unmark-as-processable t]
1823 ["Remove all marks" gnus-summary-unmark-all-processable t]
1824 ["Mark above" gnus-uu-mark-over t]
1825 ["Mark series" gnus-uu-mark-series t]
1826 ["Mark region" gnus-uu-mark-region t]
1827 ["Unmark region" gnus-uu-unmark-region t]
1828 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1829 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1830 ["Mark all" gnus-uu-mark-all t]
1831 ["Mark buffer" gnus-uu-mark-buffer t]
1832 ["Mark sparse" gnus-uu-mark-sparse t]
1833 ["Mark thread" gnus-uu-mark-thread t]
1834 ["Unmark thread" gnus-uu-unmark-thread t]
1835 ("Process Mark Sets"
1836 ["Kill" gnus-summary-kill-process-mark t]
1837 ["Yank" gnus-summary-yank-process-mark
1838 gnus-newsgroup-process-stack]
1839 ["Save" gnus-summary-save-process-mark t]))
1841 ["Page forward" gnus-summary-next-page t]
1842 ["Page backward" gnus-summary-prev-page t]
1843 ["Line forward" gnus-summary-scroll-up t])
1845 ["Next unread article" gnus-summary-next-unread-article t]
1846 ["Previous unread article" gnus-summary-prev-unread-article t]
1847 ["Next article" gnus-summary-next-article t]
1848 ["Previous article" gnus-summary-prev-article t]
1849 ["Next unread subject" gnus-summary-next-unread-subject t]
1850 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1851 ["Next article same subject" gnus-summary-next-same-subject t]
1852 ["Previous article same subject" gnus-summary-prev-same-subject t]
1853 ["First unread article" gnus-summary-first-unread-article t]
1854 ["Best unread article" gnus-summary-best-unread-article t]
1855 ["Go to subject number..." gnus-summary-goto-subject t]
1856 ["Go to article number..." gnus-summary-goto-article t]
1857 ["Go to the last article" gnus-summary-goto-last-article t]
1858 ["Pop article off history" gnus-summary-pop-article t])
1860 ["Sort by number" gnus-summary-sort-by-number t]
1861 ["Sort by author" gnus-summary-sort-by-author t]
1862 ["Sort by subject" gnus-summary-sort-by-subject t]
1863 ["Sort by date" gnus-summary-sort-by-date t]
1864 ["Sort by score" gnus-summary-sort-by-score t]
1865 ["Sort by lines" gnus-summary-sort-by-lines t]
1866 ["Sort by characters" gnus-summary-sort-by-chars t])
1868 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1869 ["Describe group" gnus-summary-describe-group t]
1870 ["Read manual" gnus-info-find-node t])
1872 ["Pick and read" gnus-pick-mode t]
1873 ["Binary" gnus-binary-mode t])
1875 ["Regenerate" gnus-summary-prepare t]
1876 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1877 ["Toggle threading" gnus-summary-toggle-threads t])
1878 ["Filter articles..." gnus-summary-execute-command t]
1879 ["Run command on subjects..." gnus-summary-universal-argument t]
1880 ["Search articles forward..." gnus-summary-search-article-forward t]
1881 ["Search articles backward..." gnus-summary-search-article-backward t]
1882 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1883 ["Expand window" gnus-summary-expand-window t]
1884 ["Expire expirable articles" gnus-summary-expire-articles
1885 (gnus-check-backend-function
1886 'request-expire-articles gnus-newsgroup-name)]
1887 ["Edit local kill file" gnus-summary-edit-local-kill t]
1888 ["Edit main kill file" gnus-summary-edit-global-kill t]
1889 ["Edit group parameters" gnus-summary-edit-parameters t]
1890 ["Customize group parameters" gnus-summary-customize-parameters t]
1891 ["Send a bug report" gnus-bug t]
1893 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1894 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
1895 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1896 ["Exit group" gnus-summary-exit t]
1897 ["Exit group without updating" gnus-summary-exit-no-update t]
1898 ["Exit and goto next group" gnus-summary-next-group t]
1899 ["Exit and goto prev group" gnus-summary-prev-group t]
1900 ["Reselect group" gnus-summary-reselect-current-group t]
1901 ["Rescan group" gnus-summary-rescan-group t]
1902 ["Update dribble" gnus-summary-save-newsrc t])))
1904 (gnus-run-hooks 'gnus-summary-menu-hook)))
1906 (defun gnus-score-set-default (var value)
1907 "A version of set that updates the GNU Emacs menu-bar."
1909 ;; It is the message that forces the active status to be updated.
1912 (defun gnus-make-score-map (type)
1913 "Make a summary score map of type TYPE."
1916 (let ((headers '(("author" "from" string)
1917 ("subject" "subject" string)
1918 ("article body" "body" string)
1919 ("article head" "head" string)
1920 ("xref" "xref" string)
1921 ("extra header" "extra" string)
1922 ("lines" "lines" number)
1923 ("followups to author" "followup" string)))
1924 (types '((number ("less than" <)
1927 (string ("substring" s)
1931 (perms '(("temporary" (current-time-string))
1939 (if (eq type 'lower)
1944 (setq header (car headers))
1950 (let ((ts (cdr (assoc (nth 2 header) types)))
1966 'gnus-summary-score-entry
1968 (if (or (string= (nth 1 header)
1970 (string= (nth 1 header)
1973 (list 'gnus-summary-header
1975 (list 'quote (nth 1 (car ts)))
1976 (list 'gnus-score-default nil)
1982 (list (nreverse outp))))
1985 (list (nreverse outt))))
1987 (setq headers (cdr headers)))
1988 (list (nreverse outh))))))))
1992 (defun gnus-summary-mode (&optional group)
1993 "Major mode for reading articles.
1995 All normal editing commands are switched off.
1996 \\<gnus-summary-mode-map>
1997 Each line in this buffer represents one article. To read an
1998 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
1999 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2002 You can also post articles and send mail from this buffer. To
2003 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2004 of an article, type `\\[gnus-summary-reply]'.
2006 There are approx. one gazillion commands you can execute in this
2007 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2009 The following commands are available:
2011 \\{gnus-summary-mode-map}"
2013 (when (gnus-visual-p 'summary-menu 'menu)
2014 (gnus-summary-make-menu-bar))
2015 (kill-all-local-variables)
2016 (gnus-summary-make-local-variables)
2017 (gnus-make-thread-indent-array)
2018 (gnus-simplify-mode-line)
2019 (setq major-mode 'gnus-summary-mode)
2020 (setq mode-name "Summary")
2021 (make-local-variable 'minor-mode-alist)
2022 (use-local-map gnus-summary-mode-map)
2023 (buffer-disable-undo)
2024 (setq buffer-read-only t) ;Disable modification
2025 (setq truncate-lines t)
2026 (setq selective-display t)
2027 (setq selective-display-ellipses t) ;Display `...'
2028 (gnus-summary-set-display-table)
2029 (gnus-set-default-directory)
2030 (setq gnus-newsgroup-name group)
2031 (unless (gnus-news-group-p group)
2032 (setq gnus-newsgroup-incorporated
2033 (nnmail-new-mail-numbers (gnus-group-real-name group))))
2034 (make-local-variable 'gnus-summary-line-format)
2035 (make-local-variable 'gnus-summary-line-format-spec)
2036 (make-local-variable 'gnus-summary-dummy-line-format)
2037 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2038 (make-local-variable 'gnus-summary-mark-positions)
2039 (make-local-hook 'pre-command-hook)
2040 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2041 (gnus-run-hooks 'gnus-summary-mode-hook)
2042 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2043 (gnus-update-summary-mark-positions))
2045 (defun gnus-summary-make-local-variables ()
2046 "Make all the local summary buffer variables."
2048 (dolist (local gnus-summary-local-variables)
2051 (if (eq (cdr local) 'global)
2052 ;; Copy the global value of the variable.
2053 (setq global (symbol-value (car local)))
2054 ;; Use the value from the list.
2055 (setq global (eval (cdr local))))
2056 (set (make-local-variable (car local)) global))
2057 ;; Simple nil-valued local variable.
2058 (set (make-local-variable local) nil)))))
2060 (defun gnus-summary-clear-local-variables ()
2061 (let ((locals gnus-summary-local-variables))
2063 (if (consp (car locals))
2064 (and (vectorp (caar locals))
2065 (set (caar locals) nil))
2066 (and (vectorp (car locals))
2067 (set (car locals) nil)))
2068 (setq locals (cdr locals)))))
2070 ;; Summary data functions.
2072 (defmacro gnus-data-number (data)
2075 (defmacro gnus-data-set-number (data number)
2076 `(setcar ,data ,number))
2078 (defmacro gnus-data-mark (data)
2081 (defmacro gnus-data-set-mark (data mark)
2082 `(setcar (nthcdr 1 ,data) ,mark))
2084 (defmacro gnus-data-pos (data)
2087 (defmacro gnus-data-set-pos (data pos)
2088 `(setcar (nthcdr 2 ,data) ,pos))
2090 (defmacro gnus-data-header (data)
2093 (defmacro gnus-data-set-header (data header)
2094 `(setf (nth 3 ,data) ,header))
2096 (defmacro gnus-data-level (data)
2099 (defmacro gnus-data-unread-p (data)
2100 `(= (nth 1 ,data) gnus-unread-mark))
2102 (defmacro gnus-data-read-p (data)
2103 `(/= (nth 1 ,data) gnus-unread-mark))
2105 (defmacro gnus-data-pseudo-p (data)
2106 `(consp (nth 3 ,data)))
2108 (defmacro gnus-data-find (number)
2109 `(assq ,number gnus-newsgroup-data))
2111 (defmacro gnus-data-find-list (number &optional data)
2112 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2113 (memq (assq ,number bdata)
2116 (defmacro gnus-data-make (number mark pos header level)
2117 `(list ,number ,mark ,pos ,header ,level))
2119 (defun gnus-data-enter (after-article number mark pos header level offset)
2120 (let ((data (gnus-data-find-list after-article)))
2122 (error "No such article: %d" after-article))
2123 (setcdr data (cons (gnus-data-make number mark pos header level)
2125 (setq gnus-newsgroup-data-reverse nil)
2126 (gnus-data-update-list (cddr data) offset)))
2128 (defun gnus-data-enter-list (after-article list &optional offset)
2130 (let ((data (and after-article (gnus-data-find-list after-article)))
2134 (let ((odata gnus-newsgroup-data))
2135 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2137 (gnus-data-update-list odata offset)))
2138 ;; Find the last element in the list to be spliced into the main
2141 (setq list (cdr list)))
2144 (setcdr list gnus-newsgroup-data)
2145 (setq gnus-newsgroup-data ilist)
2147 (gnus-data-update-list (cdr list) offset)))
2148 (setcdr list (cdr data))
2151 (gnus-data-update-list (cdr list) offset))))
2152 (setq gnus-newsgroup-data-reverse nil))))
2154 (defun gnus-data-remove (article &optional offset)
2155 (let ((data gnus-newsgroup-data))
2156 (if (= (gnus-data-number (car data)) article)
2158 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2159 gnus-newsgroup-data-reverse nil)
2161 (gnus-data-update-list gnus-newsgroup-data offset)))
2163 (when (= (gnus-data-number (cadr data)) article)
2164 (setcdr data (cddr data))
2166 (gnus-data-update-list (cdr data) offset))
2168 gnus-newsgroup-data-reverse nil))
2169 (setq data (cdr data))))))
2171 (defmacro gnus-data-list (backward)
2173 (or gnus-newsgroup-data-reverse
2174 (setq gnus-newsgroup-data-reverse
2175 (reverse gnus-newsgroup-data)))
2176 gnus-newsgroup-data))
2178 (defun gnus-data-update-list (data offset)
2179 "Add OFFSET to the POS of all data entries in DATA."
2180 (setq gnus-newsgroup-data-reverse nil)
2182 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2183 (setq data (cdr data))))
2185 (defun gnus-summary-article-pseudo-p (article)
2186 "Say whether this article is a pseudo article or not."
2187 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2189 (defmacro gnus-summary-article-sparse-p (article)
2190 "Say whether this article is a sparse article or not."
2191 `(memq ,article gnus-newsgroup-sparse))
2193 (defmacro gnus-summary-article-ancient-p (article)
2194 "Say whether this article is a sparse article or not."
2195 `(memq ,article gnus-newsgroup-ancient))
2197 (defun gnus-article-parent-p (number)
2198 "Say whether this article is a parent or not."
2199 (let ((data (gnus-data-find-list number)))
2200 (and (cdr data) ; There has to be an article after...
2201 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2202 (gnus-data-level (nth 1 data))))))
2204 (defun gnus-article-children (number)
2205 "Return a list of all children to NUMBER."
2206 (let* ((data (gnus-data-find-list number))
2207 (level (gnus-data-level (car data)))
2209 (setq data (cdr data))
2211 (= (gnus-data-level (car data)) (1+ level)))
2212 (push (gnus-data-number (car data)) children)
2213 (setq data (cdr data)))
2216 (defmacro gnus-summary-skip-intangible ()
2217 "If the current article is intangible, then jump to a different article."
2218 '(let ((to (get-text-property (point) 'gnus-intangible)))
2219 (and to (gnus-summary-goto-subject to))))
2221 (defmacro gnus-summary-article-intangible-p ()
2222 "Say whether this article is intangible or not."
2223 '(get-text-property (point) 'gnus-intangible))
2225 (defun gnus-article-read-p (article)
2226 "Say whether ARTICLE is read or not."
2227 (not (or (memq article gnus-newsgroup-marked)
2228 (memq article gnus-newsgroup-unreads)
2229 (memq article gnus-newsgroup-unselected)
2230 (memq article gnus-newsgroup-dormant))))
2232 ;; Some summary mode macros.
2234 (defmacro gnus-summary-article-number ()
2235 "The article number of the article on the current line.
2236 If there isn's an article number here, then we return the current
2239 (gnus-summary-skip-intangible)
2240 (or (get-text-property (point) 'gnus-number)
2241 (gnus-summary-last-subject))))
2243 (defmacro gnus-summary-article-header (&optional number)
2244 "Return the header of article NUMBER."
2245 `(gnus-data-header (gnus-data-find
2246 ,(or number '(gnus-summary-article-number)))))
2248 (defmacro gnus-summary-thread-level (&optional number)
2249 "Return the level of thread that starts with article NUMBER."
2250 `(if (and (eq gnus-summary-make-false-root 'dummy)
2251 (get-text-property (point) 'gnus-intangible))
2253 (gnus-data-level (gnus-data-find
2254 ,(or number '(gnus-summary-article-number))))))
2256 (defmacro gnus-summary-article-mark (&optional number)
2257 "Return the mark of article NUMBER."
2258 `(gnus-data-mark (gnus-data-find
2259 ,(or number '(gnus-summary-article-number)))))
2261 (defmacro gnus-summary-article-pos (&optional number)
2262 "Return the position of the line of article NUMBER."
2263 `(gnus-data-pos (gnus-data-find
2264 ,(or number '(gnus-summary-article-number)))))
2266 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2267 (defmacro gnus-summary-article-subject (&optional number)
2268 "Return current subject string or nil if nothing."
2271 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2272 '(gnus-data-header (assq (gnus-summary-article-number)
2273 gnus-newsgroup-data)))))
2276 (mail-header-subject headers))))
2278 (defmacro gnus-summary-article-score (&optional number)
2279 "Return current article score."
2280 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2281 gnus-newsgroup-scored))
2282 gnus-summary-default-score 0))
2284 (defun gnus-summary-article-children (&optional number)
2285 "Return a list of article numbers that are children of article NUMBER."
2286 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2287 (level (gnus-data-level (car data)))
2289 (while (and (setq data (cdr data))
2290 (> (setq l (gnus-data-level (car data))) level))
2291 (and (= (1+ level) l)
2292 (push (gnus-data-number (car data))
2294 (nreverse children)))
2296 (defun gnus-summary-article-parent (&optional number)
2297 "Return the article number of the parent of article NUMBER."
2298 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2299 (gnus-data-list t)))
2300 (level (gnus-data-level (car data))))
2302 () ; This is a root.
2303 ;; We search until we find an article with a level less than
2304 ;; this one. That function has to be the parent.
2305 (while (and (setq data (cdr data))
2306 (not (< (gnus-data-level (car data)) level))))
2307 (and data (gnus-data-number (car data))))))
2309 (defun gnus-unread-mark-p (mark)
2310 "Say whether MARK is the unread mark."
2311 (= mark gnus-unread-mark))
2313 (defun gnus-read-mark-p (mark)
2314 "Say whether MARK is one of the marks that mark as read.
2315 This is all marks except unread, ticked, dormant, and expirable."
2316 (not (or (= mark gnus-unread-mark)
2317 (= mark gnus-ticked-mark)
2318 (= mark gnus-dormant-mark)
2319 (= mark gnus-expirable-mark))))
2321 (defmacro gnus-article-mark (number)
2322 "Return the MARK of article NUMBER.
2323 This macro should only be used when computing the mark the \"first\"
2324 time; i.e., when generating the summary lines. After that,
2325 `gnus-summary-article-mark' should be used to examine the
2328 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2329 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2330 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2331 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2332 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2333 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2334 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2335 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2336 gnus-ancient-mark))))
2338 ;; Saving hidden threads.
2340 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2341 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2343 (defmacro gnus-save-hidden-threads (&rest forms)
2344 "Save hidden threads, eval FORMS, and restore the hidden threads."
2345 (let ((config (make-symbol "config")))
2346 `(let ((,config (gnus-hidden-threads-configuration)))
2350 (gnus-restore-hidden-threads-configuration ,config)))))
2352 (defun gnus-data-compute-positions ()
2353 "Compute the positions of all articles."
2354 (setq gnus-newsgroup-data-reverse nil)
2355 (let ((data gnus-newsgroup-data))
2357 (gnus-save-hidden-threads
2358 (gnus-summary-show-all-threads)
2359 (goto-char (point-min))
2361 (while (get-text-property (point) 'gnus-intangible)
2363 (gnus-data-set-pos (car data) (+ (point) 3))
2364 (setq data (cdr data))
2365 (forward-line 1))))))
2367 (defun gnus-hidden-threads-configuration ()
2368 "Return the current hidden threads configuration."
2371 (goto-char (point-min))
2372 (while (search-forward "\r" nil t)
2373 (push (1- (point)) config))
2376 (defun gnus-restore-hidden-threads-configuration (config)
2377 "Restore hidden threads configuration from CONFIG."
2378 (let (point buffer-read-only)
2379 (while (setq point (pop config))
2380 (when (and (< point (point-max))
2382 (eq (char-after) ?\n))
2383 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2385 ;; Various summary mode internalish functions.
2387 (defun gnus-mouse-pick-article (e)
2390 (gnus-summary-next-page nil t))
2392 (defun gnus-summary-set-display-table ()
2393 ;; Change the display table. Odd characters have a tendency to mess
2394 ;; up nicely formatted displays - we make all possible glyphs
2395 ;; display only a single character.
2397 ;; We start from the standard display table, if any.
2398 (let ((table (or (copy-sequence standard-display-table)
2399 (make-display-table)))
2401 ;; Nix out all the control chars...
2402 (while (>= (setq i (1- i)) 0)
2403 (aset table i [??]))
2404 ;; ... but not newline and cr, of course. (cr is necessary for the
2405 ;; selective display).
2406 (aset table ?\n nil)
2407 (aset table ?\r nil)
2408 ;; We keep TAB as well.
2409 (aset table ?\t nil)
2410 ;; We nix out any glyphs over 126 that are not set already.
2412 (while (>= (setq i (1- i)) 127)
2413 ;; Only modify if the entry is nil.
2414 (unless (aref table i)
2415 (aset table i [??]))))
2416 (setq buffer-display-table table)))
2418 (defun gnus-summary-setup-buffer (group)
2419 "Initialize summary buffer."
2420 (let ((buffer (concat "*Summary " group "*")))
2421 (if (get-buffer buffer)
2424 (setq gnus-summary-buffer (current-buffer))
2425 (not gnus-newsgroup-prepared))
2426 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2427 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2428 (gnus-summary-mode group)
2430 (gnus-carpal-setup-buffer 'summary))
2431 (unless gnus-single-article-buffer
2432 (make-local-variable 'gnus-article-buffer)
2433 (make-local-variable 'gnus-article-current)
2434 (make-local-variable 'gnus-original-article-buffer))
2435 (setq gnus-newsgroup-name group)
2438 (defun gnus-set-global-variables ()
2439 ;; Set the global equivalents of the summary buffer-local variables
2440 ;; to the latest values they had. These reflect the summary buffer
2441 ;; that was in action when the last article was fetched.
2442 (when (eq major-mode 'gnus-summary-mode)
2443 (setq gnus-summary-buffer (current-buffer))
2444 (let ((name gnus-newsgroup-name)
2445 (marked gnus-newsgroup-marked)
2446 (unread gnus-newsgroup-unreads)
2447 (headers gnus-current-headers)
2448 (data gnus-newsgroup-data)
2449 (summary gnus-summary-buffer)
2450 (article-buffer gnus-article-buffer)
2451 (original gnus-original-article-buffer)
2452 (gac gnus-article-current)
2453 (reffed gnus-reffed-article-number)
2454 (score-file gnus-current-score-file)
2455 (default-charset gnus-newsgroup-charset))
2457 (set-buffer gnus-group-buffer)
2458 (setq gnus-newsgroup-name name
2459 gnus-newsgroup-marked marked
2460 gnus-newsgroup-unreads unread
2461 gnus-current-headers headers
2462 gnus-newsgroup-data data
2463 gnus-article-current gac
2464 gnus-summary-buffer summary
2465 gnus-article-buffer article-buffer
2466 gnus-original-article-buffer original
2467 gnus-reffed-article-number reffed
2468 gnus-current-score-file score-file
2469 gnus-newsgroup-charset default-charset)
2470 ;; The article buffer also has local variables.
2471 (when (gnus-buffer-live-p gnus-article-buffer)
2472 (set-buffer gnus-article-buffer)
2473 (setq gnus-summary-buffer summary))))))
2475 (defun gnus-summary-article-unread-p (article)
2476 "Say whether ARTICLE is unread or not."
2477 (memq article gnus-newsgroup-unreads))
2479 (defun gnus-summary-first-article-p (&optional article)
2480 "Return whether ARTICLE is the first article in the buffer."
2481 (if (not (setq article (or article (gnus-summary-article-number))))
2483 (eq article (caar gnus-newsgroup-data))))
2485 (defun gnus-summary-last-article-p (&optional article)
2486 "Return whether ARTICLE is the last article in the buffer."
2487 (if (not (setq article (or article (gnus-summary-article-number))))
2488 ;; All non-existent numbers are the last article. :-)
2490 (not (cdr (gnus-data-find-list article)))))
2492 (defun gnus-make-thread-indent-array ()
2494 (unless (and gnus-thread-indent-array
2495 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2496 (setq gnus-thread-indent-array (make-vector 201 "")
2497 gnus-thread-indent-array-level gnus-thread-indent-level)
2499 (aset gnus-thread-indent-array n
2500 (make-string (* n gnus-thread-indent-level) ? ))
2503 (defun gnus-update-summary-mark-positions ()
2504 "Compute where the summary marks are to go."
2506 (when (gnus-buffer-exists-p gnus-summary-buffer)
2507 (set-buffer gnus-summary-buffer))
2508 (let ((gnus-replied-mark 129)
2509 (gnus-score-below-mark 130)
2510 (gnus-score-over-mark 130)
2511 (gnus-download-mark 131)
2512 (spec gnus-summary-line-format-spec)
2515 (gnus-set-work-buffer)
2516 (let ((gnus-summary-line-format-spec spec)
2517 (gnus-newsgroup-downloadable '((0 . t))))
2518 (gnus-summary-insert-line
2519 (make-full-mail-header 0 "" "" "" "" "" 0 0 "" nil)
2520 0 nil 128 t nil "" nil 1)
2521 (goto-char (point-min))
2522 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2524 (goto-char (point-min))
2525 (push (cons 'replied (and (search-forward "\201" nil t)
2528 (goto-char (point-min))
2529 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2531 (goto-char (point-min))
2532 (push (cons 'download
2533 (and (search-forward "\203" nil t) (- (point) 2)))
2535 (setq gnus-summary-mark-positions pos))))
2537 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2538 "Insert a dummy root in the summary buffer."
2540 (gnus-add-text-properties
2541 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2542 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2544 (defun gnus-summary-from-or-to-or-newsgroups (header)
2545 (let ((to (cdr (assq 'To (mail-header-extra header))))
2546 (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header))))
2547 (default-mime-charset (with-current-buffer gnus-summary-buffer
2548 default-mime-charset)))
2551 gnus-ignored-from-addresses
2552 (string-match gnus-ignored-from-addresses
2553 (mail-header-from header)))
2555 (or (car (funcall gnus-extract-address-components
2557 gnus-decode-encoded-word-function to)))
2558 (funcall gnus-decode-encoded-word-function to))))
2560 gnus-ignored-from-addresses
2561 (string-match gnus-ignored-from-addresses
2562 (mail-header-from header)))
2563 (concat "=> " newsgroups))
2565 (or (car (funcall gnus-extract-address-components
2566 (mail-header-from header)))
2567 (mail-header-from header))))))
2569 (defun gnus-summary-insert-line (gnus-tmp-header
2570 gnus-tmp-level gnus-tmp-current
2571 gnus-tmp-unread gnus-tmp-replied
2572 gnus-tmp-expirable gnus-tmp-subject-or-nil
2573 &optional gnus-tmp-dummy gnus-tmp-score
2575 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2576 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2577 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2578 (gnus-tmp-score-char
2579 (if (or (null gnus-summary-default-score)
2580 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2581 gnus-summary-zcore-fuzz))
2583 (if (< gnus-tmp-score gnus-summary-default-score)
2584 gnus-score-below-mark gnus-score-over-mark)))
2586 (cond (gnus-tmp-process gnus-process-mark)
2587 ((memq gnus-tmp-current gnus-newsgroup-cached)
2589 (gnus-tmp-replied gnus-replied-mark)
2590 ((memq gnus-tmp-current gnus-newsgroup-saved)
2592 (t gnus-unread-mark)))
2593 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2596 ((string-match "<[^>]+> *$" gnus-tmp-from)
2597 (let ((beg (match-beginning 0)))
2598 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2599 (substring gnus-tmp-from (1+ (match-beginning 0))
2600 (1- (match-end 0))))
2601 (substring gnus-tmp-from 0 beg))))
2602 ((string-match "(.+)" gnus-tmp-from)
2603 (substring gnus-tmp-from
2604 (1+ (match-beginning 0)) (1- (match-end 0))))
2606 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2607 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2608 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2609 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2610 (buffer-read-only nil))
2611 (when (string= gnus-tmp-name "")
2612 (setq gnus-tmp-name gnus-tmp-from))
2613 (unless (numberp gnus-tmp-lines)
2614 (setq gnus-tmp-lines 0))
2615 (gnus-put-text-property-excluding-characters-with-faces
2617 (progn (eval gnus-summary-line-format-spec) (point))
2618 'gnus-number gnus-tmp-number)
2619 (when (gnus-visual-p 'summary-highlight 'highlight)
2621 (gnus-run-hooks 'gnus-summary-update-hook)
2624 (defun gnus-summary-update-line (&optional dont-update)
2625 ;; Update summary line after change.
2626 (when (and gnus-summary-default-score
2627 (not gnus-summary-inhibit-highlight))
2628 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2629 (article (gnus-summary-article-number))
2630 (score (gnus-summary-article-score article)))
2632 (if (and gnus-summary-mark-below
2633 (< (gnus-summary-article-score)
2634 gnus-summary-mark-below))
2635 ;; This article has a low score, so we mark it as read.
2636 (when (memq article gnus-newsgroup-unreads)
2637 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2638 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2639 ;; This article was previously marked as read on account
2640 ;; of a low score, but now it has risen, so we mark it as
2642 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2643 (gnus-summary-update-mark
2644 (if (or (null gnus-summary-default-score)
2645 (<= (abs (- score gnus-summary-default-score))
2646 gnus-summary-zcore-fuzz))
2648 (if (< score gnus-summary-default-score)
2649 gnus-score-below-mark gnus-score-over-mark))
2651 ;; Do visual highlighting.
2652 (when (gnus-visual-p 'summary-highlight 'highlight)
2653 (gnus-run-hooks 'gnus-summary-update-hook)))))
2655 (defvar gnus-tmp-new-adopts nil)
2657 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2658 "Return the number of articles in THREAD.
2659 This may be 0 in some cases -- if none of the articles in
2660 the thread are to be displayed."
2662 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2664 ((not (listp thread))
2666 ((and (consp thread) (cdr thread))
2669 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2672 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2675 (when (and level (zerop level) gnus-tmp-new-adopts)
2678 'gnus-summary-number-of-articles-in-thread
2679 gnus-tmp-new-adopts))))
2681 (if (> number 1) gnus-not-empty-thread-mark
2682 gnus-empty-thread-mark)
2685 (defun gnus-summary-set-local-parameters (group)
2686 "Go through the local params of GROUP and set all variable specs in that list."
2687 (let ((params (gnus-group-find-parameter group))
2690 (setq elem (car params)
2691 params (cdr params))
2692 (and (consp elem) ; Has to be a cons.
2693 (consp (cdr elem)) ; The cdr has to be a list.
2694 (symbolp (car elem)) ; Has to be a symbol in there.
2695 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2696 (ignore-errors ; So we set it.
2697 (make-local-variable (car elem))
2698 (set (car elem) (eval (nth 1 elem))))))))
2700 (defun gnus-summary-read-group (group &optional show-all no-article
2701 kill-buffer no-display backward
2703 "Start reading news in newsgroup GROUP.
2704 If SHOW-ALL is non-nil, already read articles are also listed.
2705 If NO-ARTICLE is non-nil, no article is selected initially.
2706 If NO-DISPLAY, don't generate a summary buffer."
2710 (let ((gnus-auto-select-next nil))
2711 (or (gnus-summary-read-group-1
2712 group show-all no-article
2713 kill-buffer no-display
2716 select-articles nil)))))
2717 (eq gnus-auto-select-next 'quietly))
2718 (set-buffer gnus-group-buffer)
2719 ;; The entry function called above goes to the next
2720 ;; group automatically, so we go two groups back
2721 ;; if we are searching for the previous group.
2723 (gnus-group-prev-unread-group 2))
2724 (if (not (equal group (gnus-group-group-name)))
2725 (setq group (gnus-group-group-name))
2729 (defun gnus-summary-jump-to-other-group (group &optional show-all)
2730 "Directly jump to the other GROUP from summary buffer.
2731 If SHOW-ALL is non-nil, already read articles are also listed."
2733 (if (eq gnus-summary-buffer (current-buffer))
2734 (list (completing-read
2735 "Group: " gnus-active-hashtb nil t
2736 (when (and gnus-newsgroup-name
2737 (string-match "[.:][^.:]+$" gnus-newsgroup-name))
2738 (substring gnus-newsgroup-name 0 (1+ (match-beginning 0))))
2739 'gnus-group-history)
2741 (error "%s must be invoked from a gnus summary buffer." this-command)))
2742 (unless (or (zerop (length group))
2743 (and gnus-newsgroup-name
2744 (string-equal gnus-newsgroup-name group)))
2746 (gnus-summary-read-group group show-all
2747 gnus-dont-select-after-jump-to-other-group)))
2749 (defun gnus-summary-read-group-1 (group show-all no-article
2750 kill-buffer no-display
2751 &optional select-articles)
2752 ;; Killed foreign groups can't be entered.
2753 (when (and (not (gnus-group-native-p group))
2754 (not (gnus-gethash group gnus-newsrc-hashtb)))
2755 (error "Dead non-native groups can't be entered"))
2756 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2757 (let* ((new-group (gnus-summary-setup-buffer group))
2758 (quit-config (gnus-group-quit-config group))
2759 (did-select (and new-group (gnus-select-newsgroup
2760 group show-all select-articles))))
2762 ;; This summary buffer exists already, so we just select it.
2764 (gnus-set-global-variables)
2766 (gnus-kill-or-deaden-summary kill-buffer))
2767 (gnus-configure-windows 'summary 'force)
2768 (gnus-set-mode-line 'summary)
2769 (gnus-summary-position-point)
2772 ;; We couldn't select this group.
2774 (when (and (eq major-mode 'gnus-summary-mode)
2775 (not (equal (current-buffer) kill-buffer)))
2776 (kill-buffer (current-buffer))
2777 (if (not quit-config)
2779 ;; Update the info -- marks might need to be removed,
2781 (gnus-summary-update-info)
2782 (set-buffer gnus-group-buffer)
2783 (gnus-group-jump-to-group group)
2784 (gnus-group-next-unread-group 1))
2785 (gnus-handle-ephemeral-exit quit-config)))
2786 (gnus-message 3 "Can't select group")
2788 ;; The user did a `C-g' while prompting for number of articles,
2789 ;; so we exit this group.
2790 ((eq did-select 'quit)
2791 (and (eq major-mode 'gnus-summary-mode)
2792 (not (equal (current-buffer) kill-buffer))
2793 (kill-buffer (current-buffer)))
2795 (gnus-kill-or-deaden-summary kill-buffer))
2796 (if (not quit-config)
2798 (set-buffer gnus-group-buffer)
2799 (gnus-group-jump-to-group group)
2800 (gnus-group-next-unread-group 1)
2801 (gnus-configure-windows 'group 'force))
2802 (gnus-handle-ephemeral-exit quit-config))
2803 ;; Finally signal the quit.
2805 ;; The group was successfully selected.
2807 (gnus-set-global-variables)
2808 ;; Save the active value in effect when the group was entered.
2809 (setq gnus-newsgroup-active
2811 (gnus-active gnus-newsgroup-name)))
2812 ;; You can change the summary buffer in some way with this hook.
2813 (gnus-run-hooks 'gnus-select-group-hook)
2814 ;; Set any local variables in the group parameters.
2815 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2816 (gnus-update-format-specifications
2817 nil 'summary 'summary-mode 'summary-dummy)
2818 (gnus-update-summary-mark-positions)
2819 ;; Do score processing.
2820 (when gnus-use-scoring
2821 (gnus-possibly-score-headers))
2822 ;; Check whether to fill in the gaps in the threads.
2823 (when gnus-build-sparse-threads
2824 (gnus-build-sparse-threads))
2825 ;; Find the initial limit.
2826 (if gnus-show-threads
2828 (let ((gnus-newsgroup-dormant nil))
2829 (gnus-summary-initial-limit show-all))
2830 (gnus-summary-initial-limit show-all))
2831 (setq gnus-newsgroup-limit
2833 (lambda (header) (mail-header-number header))
2834 gnus-newsgroup-headers)))
2835 ;; Generate the summary buffer.
2837 (gnus-summary-prepare))
2838 (when gnus-use-trees
2839 (gnus-tree-open group)
2840 (setq gnus-summary-highlight-line-function
2841 'gnus-tree-highlight-article))
2842 ;; If the summary buffer is empty, but there are some low-scored
2843 ;; articles or some excluded dormants, we include these in the
2845 (when (and (zerop (buffer-size))
2847 (cond (gnus-newsgroup-dormant
2848 (gnus-summary-limit-include-dormant))
2849 ((and gnus-newsgroup-scored show-all)
2850 (gnus-summary-limit-include-expunged t))))
2851 ;; Function `gnus-apply-kill-file' must be called in this hook.
2852 (gnus-run-hooks 'gnus-apply-kill-hook)
2853 (if (and (zerop (buffer-size))
2856 ;; This newsgroup is empty.
2857 (gnus-summary-catchup-and-exit nil t)
2858 (gnus-message 6 "No unread news")
2860 (gnus-kill-or-deaden-summary kill-buffer))
2861 ;; Return nil from this function.
2863 ;; Hide conversation thread subtrees. We cannot do this in
2864 ;; gnus-summary-prepare-hook since kill processing may not
2865 ;; work with hidden articles.
2866 (and gnus-show-threads
2867 gnus-thread-hide-subtree
2868 (gnus-summary-hide-all-threads))
2870 (gnus-kill-or-deaden-summary kill-buffer))
2871 ;; Show first unread article if requested.
2872 (if (and (not no-article)
2874 gnus-newsgroup-unreads
2875 gnus-auto-select-first)
2877 (gnus-configure-windows 'summary)
2879 ((eq gnus-auto-select-first 'best)
2880 (gnus-summary-best-unread-article))
2881 ((eq gnus-auto-select-first t)
2882 (gnus-summary-first-unread-article))
2883 ((gnus-functionp gnus-auto-select-first)
2884 (funcall gnus-auto-select-first))))
2885 ;; Don't select any articles, just move point to the first
2886 ;; article in the group.
2887 (goto-char (point-min))
2888 (gnus-summary-position-point)
2889 (gnus-configure-windows 'summary 'force)
2890 (gnus-set-mode-line 'summary))
2891 (when (get-buffer-window gnus-group-buffer t)
2892 ;; Gotta use windows, because recenter does weird stuff if
2893 ;; the current buffer ain't the displayed window.
2894 (let ((owin (selected-window)))
2895 (select-window (get-buffer-window gnus-group-buffer t))
2896 (when (gnus-group-goto-group group)
2898 (select-window owin)))
2899 ;; Mark this buffer as "prepared".
2900 (setq gnus-newsgroup-prepared t)
2901 (gnus-run-hooks 'gnus-summary-prepared-hook)
2904 (defun gnus-summary-prepare ()
2905 "Generate the summary buffer."
2907 (let ((buffer-read-only nil))
2909 (setq gnus-newsgroup-data nil
2910 gnus-newsgroup-data-reverse nil)
2911 (gnus-run-hooks 'gnus-summary-generate-hook)
2912 ;; Generate the buffer, either with threads or without.
2913 (when gnus-newsgroup-headers
2914 (gnus-summary-prepare-threads
2915 (if gnus-show-threads
2916 (gnus-sort-gathered-threads
2917 (funcall gnus-summary-thread-gathering-function
2919 (gnus-cut-threads (gnus-make-threads)))))
2920 ;; Unthreaded display.
2921 (gnus-sort-articles gnus-newsgroup-headers))))
2922 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2923 ;; Call hooks for modifying summary buffer.
2924 (goto-char (point-min))
2925 (gnus-run-hooks 'gnus-summary-prepare-hook)))
2927 (defsubst gnus-general-simplify-subject (subject)
2928 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2931 ;; Truncate the subject.
2932 (gnus-simplify-subject-functions
2933 (gnus-map-function gnus-simplify-subject-functions subject))
2934 ((numberp gnus-summary-gather-subject-limit)
2935 (setq subject (gnus-simplify-subject-re subject))
2936 (if (> (length subject) gnus-summary-gather-subject-limit)
2937 (substring subject 0 gnus-summary-gather-subject-limit)
2939 ;; Fuzzily simplify it.
2940 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2941 (gnus-simplify-subject-fuzzy subject))
2942 ;; Just remove the leading "Re:".
2944 (gnus-simplify-subject-re subject))))
2946 (if (and gnus-summary-gather-exclude-subject
2947 (string-match gnus-summary-gather-exclude-subject subject))
2948 nil ; This article shouldn't be gathered
2951 (defun gnus-summary-simplify-subject-query ()
2952 "Query where the respool algorithm would put this article."
2954 (gnus-summary-select-article)
2955 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2957 (defun gnus-gather-threads-by-subject (threads)
2958 "Gather threads by looking at Subject headers."
2959 (if (not gnus-summary-make-false-root)
2961 (let ((hashtb (gnus-make-hashtable 1024))
2964 subject hthread whole-subject)
2966 (setq subject (gnus-general-simplify-subject
2967 (setq whole-subject (mail-header-subject
2970 (if (setq hthread (gnus-gethash subject hashtb))
2972 ;; We enter a dummy root into the thread, if we
2973 ;; haven't done that already.
2974 (unless (stringp (caar hthread))
2975 (setcar hthread (list whole-subject (car hthread))))
2976 ;; We add this new gathered thread to this gathered
2978 (setcdr (car hthread)
2979 (nconc (cdar hthread) (list (car threads))))
2980 ;; Remove it from the list of threads.
2981 (setcdr prev (cdr threads))
2982 (setq threads prev))
2983 ;; Enter this thread into the hash table.
2984 (gnus-sethash subject threads hashtb)))
2986 (setq threads (cdr threads)))
2989 (defun gnus-gather-threads-by-references (threads)
2990 "Gather threads by looking at References headers."
2991 (let ((idhashtb (gnus-make-hashtable 1024))
2992 (thhashtb (gnus-make-hashtable 1024))
2995 ids references id gthread gid entered ref)
2997 (when (setq references (mail-header-references (caar threads)))
2998 (setq id (mail-header-id (caar threads))
2999 ids (gnus-split-references references)
3001 (while (setq ref (pop ids))
3002 (setq ids (delete ref ids))
3003 (if (not (setq gid (gnus-gethash ref idhashtb)))
3005 (gnus-sethash ref id idhashtb)
3006 (gnus-sethash id threads thhashtb))
3007 (setq gthread (gnus-gethash gid thhashtb))
3009 ;; We enter a dummy root into the thread, if we
3010 ;; haven't done that already.
3011 (unless (stringp (caar gthread))
3012 (setcar gthread (list (mail-header-subject (caar gthread))
3014 ;; We add this new gathered thread to this gathered
3016 (setcdr (car gthread)
3017 (nconc (cdar gthread) (list (car threads)))))
3018 ;; Add it into the thread hash table.
3019 (gnus-sethash id gthread thhashtb)
3021 ;; Remove it from the list of threads.
3022 (setcdr prev (cdr threads))
3023 (setq threads prev))))
3025 (setq threads (cdr threads)))
3028 (defun gnus-sort-gathered-threads (threads)
3029 "Sort subtreads inside each gathered thread by article number."
3030 (let ((result threads))
3032 (when (stringp (caar threads))
3033 (setcdr (car threads)
3034 (sort (cdar threads) 'gnus-thread-sort-by-number)))
3035 (setq threads (cdr threads)))
3038 (defun gnus-thread-loop-p (root thread)
3039 "Say whether ROOT is in THREAD."
3040 (let ((stack (list thread))
3043 (while (setq thread (pop stack))
3044 (setq th (cdr thread))
3046 (not (eq (caar th) root)))
3049 ;; We have found a loop.
3051 (setcdr thread (delq (car th) (cdr thread)))
3052 (if (boundp (setq ref-dep (intern "none"
3053 gnus-newsgroup-dependencies)))
3054 (setcdr (symbol-value ref-dep)
3055 (nconc (cdr (symbol-value ref-dep))
3057 (set ref-dep (list nil (car th))))
3060 ;; Push all the subthreads onto the stack.
3061 (push (cdr thread) stack)))
3064 (defun gnus-make-threads ()
3065 "Go through the dependency hashtb and find the roots. Return all threads."
3067 (while (catch 'infloop
3070 ;; Deal with self-referencing References loops.
3071 (when (and (car (symbol-value refs))
3078 (car (symbol-value refs)) thread))
3079 (cdr (symbol-value refs)))))))
3082 (unless (car (symbol-value refs))
3083 ;; These threads do not refer back to any other articles,
3084 ;; so they're roots.
3085 (setq threads (append (cdr (symbol-value refs)) threads))))
3086 gnus-newsgroup-dependencies)))
3089 ;; Build the thread tree.
3090 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3091 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3093 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3094 if it was already present.
3096 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3097 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3098 Message-IDs will be renamed be renamed to a unique Message-ID before
3101 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3102 (let* ((id (mail-header-id header))
3103 (id-dep (and id (intern id dependencies)))
3104 ref ref-dep ref-header)
3105 ;; Enter this `header' in the `dependencies' table.
3109 ;; The first two cases do the normal part: enter a new `header'
3110 ;; in the `dependencies' table.
3111 ((not (boundp id-dep))
3112 (set id-dep (list header)))
3113 ((null (car (symbol-value id-dep)))
3114 (setcar (symbol-value id-dep) header))
3116 ;; From here the `header' was already present in the
3117 ;; `dependencies' table.
3119 ;; Overrides an existing entry;
3120 ;; just set the header part of the entry.
3121 (setcar (symbol-value id-dep) header))
3123 ;; Renames the existing `header' to a unique Message-ID.
3124 ((not gnus-summary-ignore-duplicates)
3125 ;; An article with this Message-ID has already been seen.
3126 ;; We rename the Message-ID.
3127 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3129 (mail-header-set-id header id))
3131 ;; The last case ignores an existing entry, except it adds any
3132 ;; additional Xrefs (in case the two articles came from different
3134 ;; Also sets `header' to `nil' meaning that the `dependencies'
3135 ;; table was *not* modified.
3137 (mail-header-set-xref
3138 (car (symbol-value id-dep))
3139 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3141 (or (mail-header-xref header) "")))
3145 ;; First check if that we are not creating a References loop.
3146 (setq ref (gnus-parent-id (mail-header-references header)))
3148 (setq ref-dep (intern-soft ref dependencies))
3150 (setq ref-header (car (symbol-value ref-dep))))
3151 (if (string= id ref)
3152 ;; Yuk! This is a reference loop. Make the article be a
3155 (mail-header-set-references (car (symbol-value id-dep)) "none")
3157 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3158 (setq ref (gnus-parent-id (mail-header-references header)))
3159 (setq ref-dep (intern (or ref "none") dependencies))
3160 (if (boundp ref-dep)
3161 (setcdr (symbol-value ref-dep)
3162 (nconc (cdr (symbol-value ref-dep))
3163 (list (symbol-value id-dep))))
3164 (set ref-dep (list nil (symbol-value id-dep)))))
3167 (defun gnus-build-sparse-threads ()
3168 (let ((headers gnus-newsgroup-headers)
3169 (gnus-summary-ignore-duplicates t)
3170 header references generation relations
3171 subject child end new-child date)
3172 ;; First we create an alist of generations/relations, where
3173 ;; generations is how much we trust the relation, and the relation
3175 (gnus-message 7 "Making sparse threads...")
3177 (nnheader-set-temp-buffer " *gnus sparse threads*")
3178 (while (setq header (pop headers))
3179 (when (and (setq references (mail-header-references header))
3180 (not (string= references "")))
3182 (setq child (mail-header-id header)
3183 subject (mail-header-subject header)
3184 date (mail-header-date header)
3186 (while (search-backward ">" nil t)
3187 (setq end (1+ (point)))
3188 (when (search-backward "<" nil t)
3189 (setq new-child (buffer-substring (point) end))
3190 (push (list (incf generation)
3191 child (setq child new-child)
3195 (push (list (1+ generation) child nil subject) relations))
3197 (kill-buffer (current-buffer)))
3198 ;; Sort over trustworthiness.
3201 (when (gnus-dependencies-add-header
3202 (make-full-mail-header
3203 gnus-reffed-article-number
3204 (nth 3 relation) "" (or (nth 4 relation) "")
3206 (or (nth 2 relation) "") 0 0 "")
3207 gnus-newsgroup-dependencies nil)
3208 (push gnus-reffed-article-number gnus-newsgroup-limit)
3209 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3210 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3211 gnus-newsgroup-reads)
3212 (decf gnus-reffed-article-number)))
3213 (sort relations 'car-less-than-car))
3214 (gnus-message 7 "Making sparse threads...done")))
3216 (defun gnus-build-old-threads ()
3217 ;; Look at all the articles that refer back to old articles, and
3218 ;; fetch the headers for the articles that aren't there. This will
3219 ;; build complete threads - if the roots haven't been expired by the
3224 (when (not (car (symbol-value refs)))
3225 (setq heads (cdr (symbol-value refs)))
3227 (if (memq (mail-header-number (caar heads))
3228 gnus-newsgroup-dormant)
3229 (setq heads (cdr heads))
3230 (setq id (symbol-name refs))
3231 (while (and (setq id (gnus-build-get-header id))
3232 (not (car (gnus-id-to-thread id)))))
3233 (setq heads nil)))))
3234 gnus-newsgroup-dependencies)))
3236 ;; This function has to be called with point after the article number
3237 ;; on the beginning of the line.
3238 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3239 (let ((eol (gnus-point-at-eol))
3240 (buffer (current-buffer))
3243 ;; overview: [num subject from date id refs chars lines misc]
3248 (make-full-mail-header
3250 (nnheader-nov-field) ; subject
3251 (nnheader-nov-field) ; from
3252 (nnheader-nov-field) ; date
3253 (nnheader-nov-read-message-id) ; id
3254 (nnheader-nov-field) ; refs
3255 (nnheader-nov-read-integer) ; chars
3256 (nnheader-nov-read-integer) ; lines
3258 (nnheader-nov-field)) ; misc
3259 (nnheader-nov-parse-extra))) ; extra
3261 (when gnus-alter-header-function
3262 (funcall gnus-alter-header-function header))
3263 (gnus-dependencies-add-header header dependencies force-new)))
3265 (defun gnus-build-get-header (id)
3266 ;; Look through the buffer of NOV lines and find the header to
3267 ;; ID. Enter this line into the dependencies hash table, and return
3268 ;; the id of the parent article (if any).
3269 (let ((deps gnus-newsgroup-dependencies)
3273 (set-buffer nntp-server-buffer)
3274 (let ((case-fold-search nil))
3275 (goto-char (point-min))
3276 (while (and (not found)
3277 (search-forward id nil t))
3279 (setq found (looking-at
3280 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3281 (regexp-quote id))))
3282 (or found (beginning-of-line 2)))
3286 (setq header (gnus-nov-parse-line
3287 (read (current-buffer)) deps))
3288 (gnus-parent-id (mail-header-references header))))))
3290 (let ((number (mail-header-number header)))
3291 (push number gnus-newsgroup-limit)
3292 (push header gnus-newsgroup-headers)
3293 (if (memq number gnus-newsgroup-unselected)
3295 (push number gnus-newsgroup-unreads)
3296 (setq gnus-newsgroup-unselected
3297 (delq number gnus-newsgroup-unselected)))
3298 (push number gnus-newsgroup-ancient)))))))
3300 (defun gnus-build-all-threads ()
3301 "Read all the headers."
3302 (let ((gnus-summary-ignore-duplicates t)
3303 (dependencies gnus-newsgroup-dependencies)
3306 (set-buffer nntp-server-buffer)
3307 (let ((case-fold-search nil))
3308 (goto-char (point-min))
3311 (setq article (read (current-buffer))
3312 header (gnus-nov-parse-line
3313 article dependencies)))
3316 (set-buffer gnus-summary-buffer)
3317 (push header gnus-newsgroup-headers)
3318 (if (memq (setq article (mail-header-number header))
3319 gnus-newsgroup-unselected)
3321 (push article gnus-newsgroup-unreads)
3322 (setq gnus-newsgroup-unselected
3323 (delq article gnus-newsgroup-unselected)))
3324 (push article gnus-newsgroup-ancient)))
3325 (forward-line 1)))))))
3327 (defun gnus-summary-update-article-line (article header)
3328 "Update the line for ARTICLE using HEADERS."
3329 (let* ((id (mail-header-id header))
3330 (thread (gnus-id-to-thread id)))
3332 (error "Article in no thread"))
3333 ;; Update the thread.
3334 (setcar thread header)
3335 (gnus-summary-goto-subject article)
3336 (let* ((datal (gnus-data-find-list article))
3338 (length (when (cdr datal)
3339 (- (gnus-data-pos data)
3340 (gnus-data-pos (cadr datal)))))
3341 (buffer-read-only nil)
3342 (level (gnus-summary-thread-level)))
3344 (gnus-summary-insert-line
3345 header level nil (gnus-article-mark article)
3346 (memq article gnus-newsgroup-replied)
3347 (memq article gnus-newsgroup-expirable)
3348 ;; Only insert the Subject string when it's different
3349 ;; from the previous Subject string.
3350 (if (gnus-subject-equal
3352 (mail-header-subject
3355 (gnus-data-find-list
3357 (gnus-data-list t)))))
3358 ;; Error on the side of excessive subjects.
3360 (mail-header-subject header))
3362 (mail-header-subject header))
3363 nil (cdr (assq article gnus-newsgroup-scored))
3364 (memq article gnus-newsgroup-processable))
3366 (gnus-data-update-list
3367 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3369 (defun gnus-summary-update-article (article &optional iheader)
3370 "Update ARTICLE in the summary buffer."
3371 (set-buffer gnus-summary-buffer)
3372 (let* ((header (gnus-summary-article-header article))
3373 (id (mail-header-id header))
3374 (data (gnus-data-find article))
3375 (thread (gnus-id-to-thread id))
3376 (references (mail-header-references header))
3380 (when (and references
3381 (not (equal "" references)))
3384 (buffer-read-only nil)
3390 (delq thread parent)))
3391 (if (gnus-summary-insert-subject id header)
3392 ;; Set the (possibly) new article number in the data structure.
3393 (gnus-data-set-number data (gnus-id-to-article id))
3397 (defun gnus-rebuild-thread (id &optional line)
3398 "Rebuild the thread containing ID.
3399 If LINE, insert the rebuilt thread starting on line LINE."
3400 (let ((buffer-read-only nil)
3401 old-pos current thread data)
3402 (if (not gnus-show-threads)
3403 (setq thread (list (car (gnus-id-to-thread id))))
3404 ;; Get the thread this article is part of.
3405 (setq thread (gnus-remove-thread id)))
3406 (setq old-pos (gnus-point-at-bol))
3407 (setq current (save-excursion
3408 (and (zerop (forward-line -1))
3409 (gnus-summary-article-number))))
3410 ;; If this is a gathered thread, we have to go some re-gathering.
3411 (when (stringp (car thread))
3412 (let ((subject (car thread))
3414 (setq thread (cdr thread))
3416 (unless (memq (setq thr (gnus-id-to-thread
3418 (mail-header-id (caar thread)))))
3421 (setq thread (cdr thread)))
3422 ;; We now have all (unique) roots.
3423 (if (= (length roots) 1)
3424 ;; All the loose roots are now one solid root.
3425 (setq thread (car roots))
3426 (setq thread (cons subject (gnus-sort-threads roots))))))
3428 ;; We then insert this thread into the summary buffer.
3430 (goto-char (point-min))
3431 (forward-line (1- line)))
3432 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3433 (if gnus-show-threads
3434 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3435 (gnus-summary-prepare-unthreaded thread))
3436 (setq data (nreverse gnus-newsgroup-data))
3437 (setq threads gnus-newsgroup-threads))
3438 ;; We splice the new data into the data structure.
3439 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3440 ;;!!! then we want to insert at the beginning of the buffer.
3441 ;;!!! That happens to be true with Gnus now, but that may
3442 ;;!!! change in the future. Perhaps.
3443 (gnus-data-enter-list
3444 (if line nil current) data (- (point) old-pos))
3445 (setq gnus-newsgroup-threads
3446 (nconc threads gnus-newsgroup-threads))
3447 (gnus-data-compute-positions))))
3449 (defun gnus-number-to-header (number)
3450 "Return the header for article NUMBER."
3451 (let ((headers gnus-newsgroup-headers))
3453 (not (= number (mail-header-number (car headers)))))
3458 (defun gnus-parent-headers (in-headers &optional generation)
3459 "Return the headers of the GENERATIONeth parent of HEADERS."
3461 (setq generation 1))
3463 (headers in-headers)
3466 (not (zerop generation))
3467 (setq references (mail-header-references headers)))
3468 (setq headers (if (and references
3469 (setq parent (gnus-parent-id references)))
3470 (car (gnus-id-to-thread parent))
3473 (and (not (eq headers in-headers))
3476 (defun gnus-id-to-thread (id)
3477 "Return the (sub-)thread where ID appears."
3478 (gnus-gethash id gnus-newsgroup-dependencies))
3480 (defun gnus-id-to-article (id)
3481 "Return the article number of ID."
3482 (let ((thread (gnus-id-to-thread id)))
3485 (mail-header-number (car thread)))))
3487 (defun gnus-id-to-header (id)
3488 "Return the article headers of ID."
3489 (car (gnus-id-to-thread id)))
3491 (defun gnus-article-displayed-root-p (article)
3492 "Say whether ARTICLE is a root(ish) article."
3493 (let ((level (gnus-summary-thread-level article))
3494 (refs (mail-header-references (gnus-summary-article-header article)))
3500 ((null (gnus-parent-id refs)) t)
3502 (null (setq particle (gnus-id-to-article
3503 (gnus-parent-id refs))))
3504 (null (gnus-summary-thread-level particle)))))))
3506 (defun gnus-root-id (id)
3507 "Return the id of the root of the thread where ID appears."
3509 (while (and id (setq prev (car (gnus-id-to-thread id))))
3511 id (gnus-parent-id (mail-header-references prev))))
3514 (defun gnus-articles-in-thread (thread)
3515 "Return the list of articles in THREAD."
3516 (cons (mail-header-number (car thread))
3517 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3519 (defun gnus-remove-thread (id &optional dont-remove)
3520 "Remove the thread that has ID in it."
3521 (let (headers thread last-id)
3522 ;; First go up in this thread until we find the root.
3523 (setq last-id (gnus-root-id id)
3524 headers (message-flatten-list (gnus-id-to-thread last-id)))
3525 ;; We have now found the real root of this thread. It might have
3526 ;; been gathered into some loose thread, so we have to search
3527 ;; through the threads to find the thread we wanted.
3528 (let ((threads gnus-newsgroup-threads)
3531 (setq sub (car threads))
3532 (if (stringp (car sub))
3533 ;; This is a gathered thread, so we look at the roots
3534 ;; below it to find whether this article is in this
3537 (setq sub (cdr sub))
3539 (when (member (caar sub) headers)
3540 (setq thread (car threads)
3543 (setq sub (cdr sub))))
3544 ;; It's an ordinary thread, so we check it.
3545 (when (eq (car sub) (car headers))
3548 (setq threads (cdr threads)))
3549 ;; If this article is in no thread, then it's a root.
3552 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3553 (setq thread (gnus-id-to-thread last-id)))
3556 thread ; We return this thread.
3558 (if (stringp (car thread))
3560 ;; If we use dummy roots, then we have to remove the
3561 ;; dummy root as well.
3562 (when (eq gnus-summary-make-false-root 'dummy)
3563 ;; We go to the dummy root by going to
3564 ;; the first sub-"thread", and then one line up.
3565 (gnus-summary-goto-article
3566 (mail-header-number (caadr thread)))
3569 (gnus-data-compute-positions))
3570 (setq thread (cdr thread))
3572 (gnus-remove-thread-1 (car thread))
3573 (setq thread (cdr thread))))
3574 (gnus-summary-show-all-threads)
3575 (gnus-remove-thread-1 thread))))))))
3577 (defun gnus-remove-thread-1 (thread)
3578 "Remove the thread THREAD recursively."
3579 (let ((number (mail-header-number (pop thread)))
3581 (setq thread (reverse thread))
3583 (gnus-remove-thread-1 (pop thread)))
3584 (when (setq d (gnus-data-find number))
3585 (goto-char (gnus-data-pos d))
3588 (- (gnus-point-at-bol)
3590 (1+ (gnus-point-at-eol))
3591 (gnus-delete-line)))))))
3593 (defun gnus-sort-threads (threads)
3595 (if (not gnus-thread-sort-functions)
3597 (gnus-message 8 "Sorting threads...")
3599 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3600 (gnus-message 8 "Sorting threads...done"))))
3602 (defun gnus-sort-articles (articles)
3604 (when gnus-article-sort-functions
3605 (gnus-message 7 "Sorting articles...")
3607 (setq gnus-newsgroup-headers
3608 (sort articles (gnus-make-sort-function
3609 gnus-article-sort-functions)))
3610 (gnus-message 7 "Sorting articles...done"))))
3612 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3613 (defmacro gnus-thread-header (thread)
3614 ;; Return header of first article in THREAD.
3615 ;; Note that THREAD must never, ever be anything else than a variable -
3616 ;; using some other form will lead to serious barfage.
3617 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3618 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3619 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
3622 (defsubst gnus-article-sort-by-number (h1 h2)
3623 "Sort articles by article number."
3624 (< (mail-header-number h1)
3625 (mail-header-number h2)))
3627 (defun gnus-thread-sort-by-number (h1 h2)
3628 "Sort threads by root article number."
3629 (gnus-article-sort-by-number
3630 (gnus-thread-header h1) (gnus-thread-header h2)))
3632 (defsubst gnus-article-sort-by-lines (h1 h2)
3633 "Sort articles by article Lines header."
3634 (< (mail-header-lines h1)
3635 (mail-header-lines h2)))
3637 (defun gnus-thread-sort-by-lines (h1 h2)
3638 "Sort threads by root article Lines header."
3639 (gnus-article-sort-by-lines
3640 (gnus-thread-header h1) (gnus-thread-header h2)))
3642 (defsubst gnus-article-sort-by-chars (h1 h2)
3643 "Sort articles by octet length."
3644 (< (mail-header-chars h1)
3645 (mail-header-chars h2)))
3647 (defun gnus-thread-sort-by-chars (h1 h2)
3648 "Sort threads by root article octet length."
3649 (gnus-article-sort-by-chars
3650 (gnus-thread-header h1) (gnus-thread-header h2)))
3652 (defsubst gnus-article-sort-by-author (h1 h2)
3653 "Sort articles by root author."
3655 (let ((addr (car (mime-read-field 'From h1))))
3656 (or (std11-full-name-string addr)
3657 (std11-address-string addr)
3659 (let ((addr (car (mime-read-field 'From h2))))
3660 (or (std11-full-name-string addr)
3661 (std11-address-string addr)
3665 (defun gnus-thread-sort-by-author (h1 h2)
3666 "Sort threads by root author."
3667 (gnus-article-sort-by-author
3668 (gnus-thread-header h1) (gnus-thread-header h2)))
3670 (defsubst gnus-article-sort-by-subject (h1 h2)
3671 "Sort articles by root subject."
3673 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3674 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3676 (defun gnus-thread-sort-by-subject (h1 h2)
3677 "Sort threads by root subject."
3678 (gnus-article-sort-by-subject
3679 (gnus-thread-header h1) (gnus-thread-header h2)))
3681 (defsubst gnus-article-sort-by-date (h1 h2)
3682 "Sort articles by root article date."
3684 (gnus-date-get-time (mail-header-date h1))
3685 (gnus-date-get-time (mail-header-date h2))))
3687 (defun gnus-thread-sort-by-date (h1 h2)
3688 "Sort threads by root article date."
3689 (gnus-article-sort-by-date
3690 (gnus-thread-header h1) (gnus-thread-header h2)))
3692 (defsubst gnus-article-sort-by-score (h1 h2)
3693 "Sort articles by root article score.
3694 Unscored articles will be counted as having a score of zero."
3695 (> (or (cdr (assq (mail-header-number h1)
3696 gnus-newsgroup-scored))
3697 gnus-summary-default-score 0)
3698 (or (cdr (assq (mail-header-number h2)
3699 gnus-newsgroup-scored))
3700 gnus-summary-default-score 0)))
3702 (defun gnus-thread-sort-by-score (h1 h2)
3703 "Sort threads by root article score."
3704 (gnus-article-sort-by-score
3705 (gnus-thread-header h1) (gnus-thread-header h2)))
3707 (defun gnus-thread-sort-by-total-score (h1 h2)
3708 "Sort threads by the sum of all scores in the thread.
3709 Unscored articles will be counted as having a score of zero."
3710 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3712 (defun gnus-thread-total-score (thread)
3713 ;; This function find the total score of THREAD.
3714 (cond ((null thread)
3717 (if (stringp (car thread))
3718 (apply gnus-thread-score-function 0
3719 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3720 (gnus-thread-total-score-1 thread)))
3722 (gnus-thread-total-score-1 (list thread)))))
3724 (defun gnus-thread-total-score-1 (root)
3725 ;; This function find the total score of the thread below ROOT.
3726 (setq root (car root))
3727 (apply gnus-thread-score-function
3729 (mapcar 'gnus-thread-total-score
3730 (cdr (gnus-id-to-thread (mail-header-id root))))
3731 (when (> (mail-header-number root) 0)
3732 (list (or (cdr (assq (mail-header-number root)
3733 gnus-newsgroup-scored))
3734 gnus-summary-default-score 0))))
3735 (list gnus-summary-default-score)
3738 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3739 (defvar gnus-tmp-prev-subject nil)
3740 (defvar gnus-tmp-false-parent nil)
3741 (defvar gnus-tmp-root-expunged nil)
3742 (defvar gnus-tmp-dummy-line nil)
3744 (defvar gnus-tmp-header)
3745 (defun gnus-extra-header (type &optional header)
3746 "Return the extra header of TYPE."
3747 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
3750 (defun gnus-summary-prepare-threads (threads)
3751 "Prepare summary buffer from THREADS and indentation LEVEL.
3752 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3753 or a straight list of headers."
3754 (gnus-message 7 "Generating summary...")
3756 (setq gnus-newsgroup-threads threads)
3759 (let ((gnus-tmp-level 0)
3760 (default-score (or gnus-summary-default-score 0))
3761 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3762 thread number subject stack state gnus-tmp-gathered beg-match
3763 new-roots gnus-tmp-new-adopts thread-end
3764 gnus-tmp-header gnus-tmp-unread
3765 gnus-tmp-replied gnus-tmp-subject-or-nil
3766 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3767 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3768 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3770 (setq gnus-tmp-prev-subject nil)
3772 (if (vectorp (car threads))
3773 ;; If this is a straight (sic) list of headers, then a
3774 ;; threaded summary display isn't required, so we just create
3775 ;; an unthreaded one.
3776 (gnus-summary-prepare-unthreaded threads)
3778 ;; Do the threaded display.
3780 (while (or threads stack gnus-tmp-new-adopts new-roots)
3782 (if (and (= gnus-tmp-level 0)
3785 (not gnus-tmp-false-parent)
3786 (or gnus-tmp-new-adopts new-roots))
3787 (if gnus-tmp-new-adopts
3788 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3789 thread (list (car gnus-tmp-new-adopts))
3790 gnus-tmp-header (caar thread)
3791 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3793 (setq thread (list (car new-roots))
3794 gnus-tmp-header (caar thread)
3795 new-roots (cdr new-roots))))
3798 ;; If there are some threads, we do them before the
3799 ;; threads on the stack.
3800 (setq thread threads
3801 gnus-tmp-header (caar thread))
3802 ;; There were no current threads, so we pop something off
3804 (setq state (car stack)
3805 gnus-tmp-level (car state)
3808 gnus-tmp-header (caar thread))))
3810 (setq gnus-tmp-false-parent nil)
3811 (setq gnus-tmp-root-expunged nil)
3812 (setq thread-end nil)
3814 (if (stringp gnus-tmp-header)
3815 ;; The header is a dummy root.
3817 ((eq gnus-summary-make-false-root 'adopt)
3818 ;; We let the first article adopt the rest.
3819 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3821 (setq gnus-tmp-gathered
3823 (lambda (h) (mail-header-number (car h)))
3826 (setq thread (cons (list (caar thread)
3829 (setq gnus-tmp-level -1
3830 gnus-tmp-false-parent t))
3831 ((eq gnus-summary-make-false-root 'empty)
3832 ;; We print adopted articles with empty subject fields.
3833 (setq gnus-tmp-gathered
3835 (lambda (h) (mail-header-number (car h)))
3838 (setq gnus-tmp-level -1))
3839 ((eq gnus-summary-make-false-root 'dummy)
3840 ;; We remember that we probably want to output a dummy
3842 (setq gnus-tmp-dummy-line gnus-tmp-header)
3843 (setq gnus-tmp-prev-subject gnus-tmp-header))
3845 ;; We do not make a root for the gathered
3846 ;; sub-threads at all.
3847 (setq gnus-tmp-level -1)))
3849 (setq number (mail-header-number gnus-tmp-header)
3850 subject (mail-header-subject gnus-tmp-header))
3853 ;; If the thread has changed subject, we might want to make
3854 ;; this subthread into a root.
3855 ((and (null gnus-thread-ignore-subject)
3856 (not (zerop gnus-tmp-level))
3857 gnus-tmp-prev-subject
3859 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3860 (setq new-roots (nconc new-roots (list (car thread)))
3862 gnus-tmp-header nil))
3863 ;; If the article lies outside the current limit,
3864 ;; then we do not display it.
3865 ((not (memq number gnus-newsgroup-limit))
3866 (setq gnus-tmp-gathered
3868 (lambda (h) (mail-header-number (car h)))
3871 (setq gnus-tmp-new-adopts (if (cdar thread)
3872 (append gnus-tmp-new-adopts
3874 gnus-tmp-new-adopts)
3876 gnus-tmp-header nil)
3877 (when (zerop gnus-tmp-level)
3878 (setq gnus-tmp-root-expunged t)))
3879 ;; Perhaps this article is to be marked as read?
3880 ((and gnus-summary-mark-below
3881 (< (or (cdr (assq number gnus-newsgroup-scored))
3883 gnus-summary-mark-below)
3884 ;; Don't touch sparse articles.
3885 (not (gnus-summary-article-sparse-p number))
3886 (not (gnus-summary-article-ancient-p number)))
3887 (setq gnus-newsgroup-unreads
3888 (delq number gnus-newsgroup-unreads))
3889 (if gnus-newsgroup-auto-expire
3890 (push number gnus-newsgroup-expirable)
3891 (push (cons number gnus-low-score-mark)
3892 gnus-newsgroup-reads))))
3894 (when gnus-tmp-header
3895 ;; We may have an old dummy line to output before this
3897 (when (and gnus-tmp-dummy-line
3900 (mail-header-subject gnus-tmp-header)))
3901 (gnus-summary-insert-dummy-line
3902 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3903 (setq gnus-tmp-dummy-line nil))
3905 ;; Compute the mark.
3906 (setq gnus-tmp-unread (gnus-article-mark number))
3908 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3909 gnus-tmp-header gnus-tmp-level)
3910 gnus-newsgroup-data)
3912 ;; Actually insert the line.
3914 gnus-tmp-subject-or-nil
3916 ((and gnus-thread-ignore-subject
3917 gnus-tmp-prev-subject
3918 (not (inline (gnus-subject-equal
3919 gnus-tmp-prev-subject subject))))
3921 ((zerop gnus-tmp-level)
3922 (if (and (eq gnus-summary-make-false-root 'empty)
3923 (memq number gnus-tmp-gathered)
3924 gnus-tmp-prev-subject
3925 (inline (gnus-subject-equal
3926 gnus-tmp-prev-subject subject)))
3927 gnus-summary-same-subject
3929 (t gnus-summary-same-subject)))
3930 (if (and (eq gnus-summary-make-false-root 'adopt)
3931 (= gnus-tmp-level 1)
3932 (memq number gnus-tmp-gathered))
3933 (setq gnus-tmp-opening-bracket ?\<
3934 gnus-tmp-closing-bracket ?\>)
3935 (setq gnus-tmp-opening-bracket ?\[
3936 gnus-tmp-closing-bracket ?\]))
3938 gnus-tmp-indentation
3939 (aref gnus-thread-indent-array gnus-tmp-level)
3940 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3941 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3942 gnus-summary-default-score 0)
3944 (if (or (null gnus-summary-default-score)
3945 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3946 gnus-summary-zcore-fuzz))
3948 (if (< gnus-tmp-score gnus-summary-default-score)
3949 gnus-score-below-mark gnus-score-over-mark))
3951 (cond ((memq number gnus-newsgroup-processable)
3953 ((memq number gnus-newsgroup-cached)
3955 ((memq number gnus-newsgroup-replied)
3957 ((memq number gnus-newsgroup-saved)
3959 (t gnus-unread-mark))
3960 gnus-tmp-from (mail-header-from gnus-tmp-header)
3963 ((string-match "<[^>]+> *$" gnus-tmp-from)
3964 (setq beg-match (match-beginning 0))
3965 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3966 (substring gnus-tmp-from (1+ (match-beginning 0))
3967 (1- (match-end 0))))
3968 (substring gnus-tmp-from 0 beg-match)))
3969 ((string-match "(.+)" gnus-tmp-from)
3970 (substring gnus-tmp-from
3971 (1+ (match-beginning 0)) (1- (match-end 0))))
3973 (when (string= gnus-tmp-name "")
3974 (setq gnus-tmp-name gnus-tmp-from))
3975 (unless (numberp gnus-tmp-lines)
3976 (setq gnus-tmp-lines 0))
3977 (gnus-put-text-property
3979 (progn (eval gnus-summary-line-format-spec) (point))
3980 'gnus-number number)
3983 (gnus-run-hooks 'gnus-summary-update-hook)
3986 (setq gnus-tmp-prev-subject subject)))
3988 (when (nth 1 thread)
3989 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3990 (incf gnus-tmp-level)
3991 (setq threads (if thread-end nil (cdar thread)))
3993 (setq gnus-tmp-level 0)))))
3994 (gnus-message 7 "Generating summary...done"))
3996 (defun gnus-summary-prepare-unthreaded (headers)
3997 "Generate an unthreaded summary buffer based on HEADERS."
3998 (let (header number mark)
4003 ;; We may have to root out some bad articles...
4004 (when (memq (setq number (mail-header-number
4005 (setq header (pop headers))))
4006 gnus-newsgroup-limit)
4007 ;; Mark article as read when it has a low score.
4008 (when (and gnus-summary-mark-below
4009 (< (or (cdr (assq number gnus-newsgroup-scored))
4010 gnus-summary-default-score 0)
4011 gnus-summary-mark-below)
4012 (not (gnus-summary-article-ancient-p number)))
4013 (setq gnus-newsgroup-unreads
4014 (delq number gnus-newsgroup-unreads))
4015 (if gnus-newsgroup-auto-expire
4016 (push number gnus-newsgroup-expirable)
4017 (push (cons number gnus-low-score-mark)
4018 gnus-newsgroup-reads)))
4020 (setq mark (gnus-article-mark number))
4021 (push (gnus-data-make number mark (1+ (point)) header 0)
4022 gnus-newsgroup-data)
4023 (gnus-summary-insert-line
4025 mark (memq number gnus-newsgroup-replied)
4026 (memq number gnus-newsgroup-expirable)
4027 (mail-header-subject header) nil
4028 (cdr (assq number gnus-newsgroup-scored))
4029 (memq number gnus-newsgroup-processable))))))
4031 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4032 "Select newsgroup GROUP.
4033 If READ-ALL is non-nil, all articles in the group are selected.
4034 If SELECT-ARTICLES, only select those articles from GROUP."
4035 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4036 ;;!!! Dirty hack; should be removed.
4037 (gnus-summary-ignore-duplicates
4038 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4040 gnus-summary-ignore-duplicates))
4041 (info (nth 2 entry))
4042 articles fetched-articles cached)
4044 (unless (gnus-check-server
4045 (setq gnus-current-select-method
4046 (gnus-find-method-for-group group)))
4047 (error "Couldn't open server"))
4049 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4050 (gnus-activate-group group) ; Or we can activate it...
4051 (progn ; Or we bug out.
4052 (when (equal major-mode 'gnus-summary-mode)
4053 (kill-buffer (current-buffer)))
4054 (error "Couldn't request group %s: %s"
4055 group (gnus-status-message group))))
4057 (unless (gnus-request-group group t)
4058 (when (equal major-mode 'gnus-summary-mode)
4059 (kill-buffer (current-buffer)))
4060 (error "Couldn't request group %s: %s"
4061 group (gnus-status-message group)))
4063 (setq gnus-newsgroup-name group)
4064 (setq gnus-newsgroup-unselected nil)
4065 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4066 (gnus-summary-setup-default-charset)
4068 ;; Adjust and set lists of article marks.
4070 (gnus-adjust-marked-articles info))
4072 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4074 (if (gnus-virtual-group-p group)
4075 gnus-newsgroup-cached
4076 (gnus-cache-articles-in-group group)))
4078 (setq gnus-newsgroup-unreads
4079 (gnus-set-difference
4080 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4081 gnus-newsgroup-dormant))
4083 (setq gnus-newsgroup-processable nil)
4085 (gnus-update-read-articles group gnus-newsgroup-unreads)
4087 (if (setq articles select-articles)
4088 (setq gnus-newsgroup-unselected
4089 (gnus-sorted-intersection
4090 gnus-newsgroup-unreads
4091 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4092 (setq articles (gnus-articles-to-read group read-all)))
4096 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4098 ((eq articles 0) nil)
4100 ;; Init the dependencies hash table.
4101 (setq gnus-newsgroup-dependencies
4102 (gnus-make-hashtable (length articles)))
4103 (gnus-set-global-variables)
4104 ;; Retrieve the headers and read them in.
4105 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
4106 (setq gnus-newsgroup-headers
4107 (gnus-retrieve-parsed-headers
4108 articles gnus-newsgroup-name
4109 ;; We might want to fetch old headers, but
4110 ;; not if there is only 1 article.
4111 (and (or (and (not (eq gnus-fetch-old-headers 'some))
4112 (not (numberp gnus-fetch-old-headers)))
4113 (> (length articles) 1))
4114 gnus-fetch-old-headers)))
4115 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
4117 ;; Suppress duplicates?
4118 (when gnus-suppress-duplicates
4119 (gnus-dup-suppress-articles))
4121 ;; Set the initial limit.
4122 (setq gnus-newsgroup-limit (copy-sequence articles))
4123 ;; Remove canceled articles from the list of unread articles.
4124 (setq gnus-newsgroup-unreads
4125 (gnus-set-sorted-intersection
4126 gnus-newsgroup-unreads
4127 (setq fetched-articles
4128 (mapcar (lambda (headers) (mail-header-number headers))
4129 gnus-newsgroup-headers))))
4130 ;; Removed marked articles that do not exist.
4131 (gnus-update-missing-marks
4132 (gnus-sorted-complement fetched-articles articles))
4134 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4136 (setq gnus-newsgroup-cached cached))
4138 ;; We might want to build some more threads first.
4139 (when (and gnus-fetch-old-headers
4140 (eq gnus-headers-retrieved-by 'nov))
4141 (if (eq gnus-fetch-old-headers 'invisible)
4142 (gnus-build-all-threads)
4143 (gnus-build-old-threads)))
4144 ;; Let the Gnus agent mark articles as read.
4146 (gnus-agent-get-undownloaded-list))
4147 ;; Check whether auto-expire is to be done in this group.
4148 (setq gnus-newsgroup-auto-expire
4149 (gnus-group-auto-expirable-p group))
4150 ;; Set up the article buffer now, if necessary.
4151 (unless gnus-single-article-buffer
4152 (gnus-article-setup-buffer))
4153 ;; First and last article in this newsgroup.
4154 (when gnus-newsgroup-headers
4155 (setq gnus-newsgroup-begin
4156 (mail-header-number (car gnus-newsgroup-headers))
4159 (gnus-last-element gnus-newsgroup-headers))))
4160 ;; GROUP is successfully selected.
4161 (or gnus-newsgroup-headers t)))))
4163 (defun gnus-articles-to-read (group &optional read-all)
4164 ;; Find out what articles the user wants to read.
4166 ;; Select all articles if `read-all' is non-nil, or if there
4167 ;; are no unread articles.
4169 (and (zerop (length gnus-newsgroup-marked))
4170 (zerop (length gnus-newsgroup-unreads)))
4171 (eq (gnus-group-find-parameter group 'display)
4173 (gnus-uncompress-range (gnus-active group))
4174 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4175 (copy-sequence gnus-newsgroup-unreads))
4177 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4178 (scored (length scored-list))
4179 (number (length articles))
4180 (marked (+ (length gnus-newsgroup-marked)
4181 (length gnus-newsgroup-dormant)))
4189 ((and (or (<= scored marked) (= scored number))
4190 (natnump gnus-large-newsgroup)
4191 (> number gnus-large-newsgroup))
4192 (let ((input (read-from-minibuffer
4194 "How many articles from %s (max %d): "
4195 (gnus-limit-string gnus-newsgroup-name 35)
4197 (static-if (< emacs-major-version 20)
4198 (number-to-string gnus-large-newsgroup)
4200 (number-to-string gnus-large-newsgroup)
4202 (if (string-match "^[ \t]*$" input)
4205 ((and (> scored marked) (< scored number)
4206 (> (- scored number) 20))
4209 (format "%s %s (%d scored, %d total): "
4210 "How many articles from"
4211 group scored number))))
4212 (if (string-match "^[ \t]*$" input)
4216 (setq select (if (stringp select) (string-to-number select) select))
4217 (if (or (null select) (zerop select))
4219 (if (and (not (zerop scored)) (<= (abs select) scored))
4221 (setq articles (sort scored-list '<))
4222 (setq number (length articles)))
4223 (setq articles (copy-sequence articles)))
4225 (when (< (abs select) number)
4227 ;; Select the N oldest articles.
4228 (setcdr (nthcdr (1- (abs select)) articles) nil)
4229 ;; Select the N most recent articles.
4230 (setq articles (nthcdr (- number select) articles))))
4231 (setq gnus-newsgroup-unselected
4232 (gnus-sorted-intersection
4233 gnus-newsgroup-unreads
4234 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4237 (defun gnus-killed-articles (killed articles)
4240 (when (inline (gnus-member-of-range (car articles) killed))
4241 (push (car articles) out))
4242 (setq articles (cdr articles)))
4245 (defun gnus-uncompress-marks (marks)
4246 "Uncompress the mark ranges in MARKS."
4247 (let ((uncompressed '(score bookmark))
4250 (if (memq (caar marks) uncompressed)
4251 (push (car marks) out)
4252 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4253 (setq marks (cdr marks)))
4256 (defun gnus-adjust-marked-articles (info)
4257 "Set all article lists and remove all marks that are no longer valid."
4258 (let* ((marked-lists (gnus-info-marks info))
4259 (active (gnus-active (gnus-info-group info)))
4262 (types gnus-article-mark-lists)
4263 (uncompressed '(score bookmark killed))
4264 marks var articles article mark)
4267 (setq marks (pop marked-lists))
4268 (set (setq var (intern (format "gnus-newsgroup-%s"
4269 (car (rassq (setq mark (car marks))
4271 (if (memq (car marks) uncompressed) (cdr marks)
4272 (gnus-uncompress-range (cdr marks))))
4274 (setq articles (symbol-value var))
4276 ;; All articles have to be subsets of the active articles.
4278 ;; Adjust "simple" lists.
4279 ((memq mark '(tick dormant expire reply save))
4281 (when (or (< (setq article (pop articles)) min) (> article max))
4282 (set var (delq article (symbol-value var))))))
4284 ((memq mark uncompressed)
4285 (when (not (listp (cdr (symbol-value var))))
4286 (set var (list (symbol-value var))))
4287 (when (not (listp (cdr articles)))
4288 (setq articles (list articles)))
4290 (when (or (not (consp (setq article (pop articles))))
4291 (< (car article) min)
4292 (> (car article) max))
4293 (set var (delq article (symbol-value var))))))))))
4295 (defun gnus-update-missing-marks (missing)
4296 "Go through the list of MISSING articles and remove them from the mark lists."
4298 (let ((types gnus-article-mark-lists)
4300 ;; Go through all types.
4302 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4303 (when (symbol-value var)
4304 ;; This list has articles. So we delete all missing articles
4308 (set var (delq (pop m) (symbol-value var)))))))))
4310 (defun gnus-update-marks ()
4311 "Enter the various lists of marked articles into the newsgroup info list."
4312 (let ((types gnus-article-mark-lists)
4313 (info (gnus-get-info gnus-newsgroup-name))
4314 (uncompressed '(score bookmark killed))
4315 type list newmarked symbol delta-marks)
4317 ;; Add all marks lists to the list of marks lists.
4318 (while (setq type (pop types))
4319 (setq list (symbol-value
4321 (intern (format "gnus-newsgroup-%s"
4325 ;; Get rid of the entries of the articles that have the
4327 (when (and (eq (cdr type) 'score)
4331 (prev (cons nil list))
4334 (if (or (not (consp (car arts)))
4335 (= (cdar arts) gnus-summary-default-score))
4336 (setcdr prev (cdr arts))
4338 (setq arts (cdr arts)))
4339 (setq list (cdr all)))))
4341 (or (memq (cdr type) uncompressed)
4342 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
4344 (when (gnus-check-backend-function 'request-set-mark
4345 gnus-newsgroup-name)
4346 ;; uncompressed:s are not proper flags (they are cons cells)
4347 ;; cache is a internal gnus flag
4348 (unless (memq (cdr type) (cons 'cache uncompressed))
4349 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4350 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
4351 (add (gnus-remove-from-range (gnus-copy-sequence list) old)))
4353 (push (list add 'add (list (cdr type))) delta-marks))
4355 (push (list del 'del (list (cdr type))) delta-marks)))))
4358 (push (cons (cdr type) list) newmarked)))
4361 (unless (gnus-check-group gnus-newsgroup-name)
4362 (error "Can't open server for %s" gnus-newsgroup-name))
4363 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4365 ;; Enter these new marks into the info of the group.
4367 (setcar (nthcdr 3 info) newmarked)
4368 ;; Add the marks lists to the end of the info.
4370 (setcdr (nthcdr 2 info) (list newmarked))))
4372 ;; Cut off the end of the info if there's nothing else there.
4376 (when (nthcdr (decf i) info)
4377 (setcdr (nthcdr i info) nil)))))))
4379 (defun gnus-set-mode-line (where)
4380 "This function sets the mode line of the article or summary buffers.
4381 If WHERE is `summary', the summary mode line format will be used."
4382 ;; Is this mode line one we keep updated?
4383 (when (and (memq where gnus-updated-mode-lines)
4385 (intern (format "gnus-%s-mode-line-format-spec" where))))
4388 ;; We evaluate this in the summary buffer since these
4389 ;; variables are buffer-local to that buffer.
4390 (set-buffer gnus-summary-buffer)
4391 ;; We bind all these variables that are used in the `eval' form
4393 (let* ((mformat (symbol-value
4395 (format "gnus-%s-mode-line-format-spec" where))))
4396 (gnus-tmp-group-name gnus-newsgroup-name)
4397 (gnus-tmp-article-number (or gnus-current-article 0))
4398 (gnus-tmp-unread gnus-newsgroup-unreads)
4399 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4400 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4401 (gnus-tmp-unread-and-unselected
4402 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4403 (zerop gnus-tmp-unselected))
4405 ((zerop gnus-tmp-unselected)
4406 (format "{%d more}" gnus-tmp-unread-and-unticked))
4407 (t (format "{%d(+%d) more}"
4408 gnus-tmp-unread-and-unticked
4409 gnus-tmp-unselected))))
4411 (if (and gnus-current-headers
4412 (vectorp gnus-current-headers))
4413 (gnus-mode-string-quote
4414 (mail-header-subject gnus-current-headers))
4416 bufname-length max-len
4417 gnus-tmp-header);; passed as argument to any user-format-funcs
4418 (setq mode-string (eval mformat))
4419 (setq bufname-length (if (string-match "%b" mode-string)
4422 (if (eq where 'summary)
4424 (get-buffer gnus-article-buffer))))
4427 (setq max-len (max 4 (if gnus-mode-non-string-length
4429 gnus-mode-non-string-length
4431 (length mode-string))))
4432 ;; We might have to chop a bit of the string off...
4433 (when (> (length mode-string) max-len)
4435 (concat (gnus-truncate-string mode-string (- max-len 3))
4437 ;; Pad the mode string a bit.
4438 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4439 ;; Update the mode line.
4440 (setq mode-line-buffer-identification
4441 (gnus-mode-line-buffer-identification (list mode-string)))
4442 (set-buffer-modified-p t))))
4444 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4445 "Go through the HEADERS list and add all Xrefs to a hash table.
4446 The resulting hash table is returned, or nil if no Xrefs were found."
4447 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4448 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4449 (xref-hashtb (gnus-make-hashtable))
4450 start group entry number xrefs header)
4452 (setq header (pop headers))
4453 (when (and (setq xrefs (mail-header-xref header))
4454 (not (memq (setq number (mail-header-number header))
4457 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4458 (setq start (match-end 0))
4459 (setq group (if prefix
4460 (concat prefix (substring xrefs (match-beginning 1)
4462 (substring xrefs (match-beginning 1) (match-end 1))))
4464 (string-to-int (substring xrefs (match-beginning 2)
4466 (if (setq entry (gnus-gethash group xref-hashtb))
4467 (setcdr entry (cons number (cdr entry)))
4468 (gnus-sethash group (cons number nil) xref-hashtb)))))
4469 (and start xref-hashtb)))
4471 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4472 "Look through all the headers and mark the Xrefs as read."
4473 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4474 name entry info xref-hashtb idlist method nth4)
4476 (set-buffer gnus-group-buffer)
4477 (when (setq xref-hashtb
4478 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4481 (unless (string= from-newsgroup (setq name (symbol-name group)))
4482 (setq idlist (symbol-value group))
4483 ;; Dead groups are not updated.
4485 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4487 (when (stringp (setq nth4 (gnus-info-method info)))
4488 (setq nth4 (gnus-server-to-method nth4))))
4489 ;; Only do the xrefs if the group has the same
4490 ;; select method as the group we have just read.
4491 (or (gnus-methods-equal-p
4492 nth4 (gnus-find-method-for-group from-newsgroup))
4494 (equal nth4 (setq method (gnus-find-method-for-group
4496 (and (equal (car nth4) (car method))
4497 (equal (nth 1 nth4) (nth 1 method))))
4498 gnus-use-cross-reference
4499 (or (not (eq gnus-use-cross-reference t))
4501 ;; Only do cross-references on subscribed
4502 ;; groups, if that is what is wanted.
4503 (<= (gnus-info-level info) gnus-level-subscribed))
4504 (gnus-group-make-articles-read name idlist))))
4507 (defun gnus-compute-read-articles (group articles)
4508 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4509 (info (nth 2 entry))
4510 (active (gnus-active group))
4513 ;; First peel off all invalid article numbers.
4515 (let ((ids articles)
4517 (while (setq id (pop ids))
4518 (when (and first (> id (cdr active)))
4519 ;; We'll end up in this situation in one particular
4520 ;; obscure situation. If you re-scan a group and get
4521 ;; a new article that is cross-posted to a different
4522 ;; group that has not been re-scanned, you might get
4523 ;; crossposted article that has a higher number than
4524 ;; Gnus believes possible. So we re-activate this
4525 ;; group as well. This might mean doing the
4526 ;; crossposting thingy will *increase* the number
4527 ;; of articles in some groups. Tsk, tsk.
4528 (setq active (or (gnus-activate-group group) active)))
4529 (when (or (> id (cdr active))
4530 (< id (car active)))
4531 (setq articles (delq id articles))))))
4532 ;; If the read list is nil, we init it.
4534 (null (gnus-info-read info))
4536 (setq ninfo (cons 1 (1- (car active))))
4537 (setq ninfo (gnus-info-read info)))
4538 ;; Then we add the read articles to the range.
4540 ninfo (setq articles (sort articles '<))))))
4542 (defun gnus-group-make-articles-read (group articles)
4543 "Update the info of GROUP to say that ARTICLES are read."
4545 (entry (gnus-gethash group gnus-newsrc-hashtb))
4546 (info (nth 2 entry))
4547 (active (gnus-active group))
4550 (setq range (gnus-compute-read-articles group articles))
4552 (set-buffer gnus-group-buffer)
4555 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4556 (gnus-info-set-read ',info ',(gnus-info-read info))
4557 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4558 (gnus-group-update-group ,group t))))
4559 ;; Add the read articles to the range.
4560 (gnus-info-set-read info range)
4561 ;; Then we have to re-compute how many unread
4562 ;; articles there are in this group.
4566 (setq num (- (1+ (cdr active)) (car active))))
4567 ((not (listp (cdr range)))
4568 (setq num (- (cdr active) (- (1+ (cdr range))
4572 (if (numberp (car range))
4574 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4575 (setq range (cdr range)))
4576 (setq num (- (cdr active) num))))
4577 ;; Update the number of unread articles.
4579 ;; Update the group buffer.
4580 (gnus-group-update-group group t)))))
4582 (defvar gnus-newsgroup-none-id 0)
4584 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4585 (let ((cur nntp-server-buffer)
4588 (save-excursion (set-buffer gnus-summary-buffer)
4589 gnus-newsgroup-dependencies)))
4591 (mail-parse-charset gnus-newsgroup-charset)
4592 (mail-parse-ignored-charsets
4593 (save-excursion (condition-case nil
4594 (set-buffer gnus-summary-buffer)
4596 gnus-newsgroup-ignored-charsets)))
4598 (set-buffer nntp-server-buffer)
4599 ;; Translate all TAB characters into SPACE characters.
4600 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4601 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4602 (gnus-run-hooks 'gnus-parse-headers-hook)
4603 (let ((case-fold-search t)
4604 in-reply-to header p lines chars ctype)
4605 (goto-char (point-min))
4606 ;; Search to the beginning of the next header. Error messages
4607 ;; do not begin with 2 or 3.
4608 (while (re-search-forward "^[23][0-9]+ " nil t)
4611 ;; This implementation of this function, with nine
4612 ;; search-forwards instead of the one re-search-forward and
4613 ;; a case (which basically was the old function) is actually
4614 ;; about twice as fast, even though it looks messier. You
4615 ;; can't have everything, I guess. Speed and elegance
4616 ;; doesn't always go hand in hand.
4619 (make-full-mail-header
4625 (narrow-to-region (point)
4626 (or (and (search-forward "\n.\n" nil t)
4632 (if (search-forward "\nsubject: " nil t)
4633 (buffer-substring (match-end 0) (std11-field-end))
4638 (if (search-forward "\nfrom: " nil t)
4639 (buffer-substring (match-end 0) (std11-field-end))
4644 (if (search-forward "\ndate: " nil t)
4645 (buffer-substring (match-end 0) (std11-field-end))
4650 (setq id (if (re-search-forward
4651 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4652 ;; We do it this way to make sure the Message-ID
4653 ;; is (somewhat) syntactically valid.
4654 (buffer-substring (match-beginning 1)
4656 ;; If there was no message-id, we just fake one
4657 ;; to make subsequent routines simpler.
4658 (nnheader-generate-fake-message-id))))
4662 (if (search-forward "\nreferences: " nil t)
4666 (buffer-substring (match-end 0) (std11-field-end))
4671 (search-backward ">" end t)
4674 (search-backward "<" end t)
4676 ;; Get the references from the in-reply-to header if there
4677 ;; were no references and the in-reply-to header looks
4679 (if (and (search-forward "\nin-reply-to: " nil t)
4681 (buffer-substring (match-end 0)
4683 (string-match "<[^>]+>" in-reply-to))
4685 (setq ref (substring in-reply-to (match-beginning 0)
4687 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4688 (setq ref2 (substring in-reply-to (match-beginning 0)
4690 (when (> (length ref2) (length ref))
4697 (if (search-forward "\nchars: " nil t)
4698 (if (numberp (setq chars (ignore-errors (read cur))))
4704 (if (search-forward "\nlines: " nil t)
4705 (if (numberp (setq lines (ignore-errors (read cur))))
4711 (and (search-forward "\nxref: " nil t)
4712 (buffer-substring (match-end 0) (std11-field-end))))
4714 (when gnus-extra-headers
4715 (let ((extra gnus-extra-headers)
4719 (when (search-forward
4720 (concat "\n" (symbol-name (car extra)) ": ") nil t)
4721 (push (cons (car extra)
4722 (buffer-substring (match-end 0)
4728 (if (and (search-forward "\ncontent-type: " nil t)
4730 (buffer-substring (match-end 0) (std11-field-end))))
4731 (mime-entity-set-content-type-internal
4732 header (mime-parse-Content-Type ctype)))
4733 (when (equal id ref)
4736 (when gnus-alter-header-function
4737 (funcall gnus-alter-header-function header)
4738 (setq id (mail-header-id header)
4739 ref (gnus-parent-id (mail-header-references header))))
4742 (gnus-dependencies-add-header
4743 header dependencies force-new))
4744 (push header headers))
4745 (goto-char (point-max))
4747 (nreverse headers)))))
4749 ;; Goes through the xover lines and returns a list of vectors
4750 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4751 force-new dependencies
4752 group also-fetch-heads)
4753 "Parse the news overview data in the server buffer, and return a
4754 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4755 ;; Get the Xref when the users reads the articles since most/some
4756 ;; NNTP servers do not include Xrefs when using XOVER.
4757 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4758 (let ((mail-parse-charset gnus-newsgroup-charset)
4759 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
4760 (cur nntp-server-buffer)
4761 (dependencies (or dependencies gnus-newsgroup-dependencies))
4762 number headers header)
4764 (set-buffer nntp-server-buffer)
4765 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4766 ;; Allow the user to mangle the headers before parsing them.
4767 (gnus-run-hooks 'gnus-parse-headers-hook)
4768 (goto-char (point-min))
4771 (while (and sequence (not (eobp)))
4772 (setq number (read cur))
4773 (while (and sequence
4774 (< (car sequence) number))
4775 (setq sequence (cdr sequence)))
4777 (eq number (car sequence))
4779 (setq sequence (cdr sequence))
4780 (setq header (inline
4781 (gnus-nov-parse-line
4782 number dependencies force-new))))
4783 (push header headers))
4786 (gnus-error 4 "Strange nov line (%d)"
4787 (count-lines (point-min) (point)))))
4789 ;; A common bug in inn is that if you have posted an article and
4790 ;; then retrieves the active file, it will answer correctly --
4791 ;; the new article is included. However, a NOV entry for the
4792 ;; article may not have been generated yet, so this may fail.
4793 ;; We work around this problem by retrieving the last few
4794 ;; headers using HEAD.
4795 (if (or (not also-fetch-heads)
4797 ;; We (probably) got all the headers.
4799 (let ((gnus-nov-is-evil t))
4802 (gnus-retrieve-parsed-headers sequence group)
4805 (defun gnus-article-get-xrefs ()
4806 "Fill in the Xref value in `gnus-current-headers', if necessary.
4807 This is meant to be called in `gnus-article-internal-prepare-hook'."
4808 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4809 gnus-current-headers)))
4810 (or (not gnus-use-cross-reference)
4812 (and (mail-header-xref headers)
4813 (not (string= (mail-header-xref headers) "")))
4814 (let ((case-fold-search t)
4817 (nnheader-narrow-to-headers)
4818 (goto-char (point-min))
4819 (when (or (and (eq (downcase (char-after)) ?x)
4820 (looking-at "Xref:"))
4821 (search-forward "\nXref:" nil t))
4822 (goto-char (1+ (match-end 0)))
4823 (setq xref (buffer-substring (point)
4824 (progn (end-of-line) (point))))
4825 (mail-header-set-xref headers xref)))))))
4827 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4828 "Find article ID and insert the summary line for that article.
4829 OLD-HEADER can either be a header or a line number to insert
4830 the subject line on."
4831 (let* ((line (and (numberp old-header) old-header))
4832 (old-header (and (vectorp old-header) old-header))
4833 (header (cond ((and old-header use-old-header)
4836 (gnus-number-to-header id))
4837 (gnus-number-to-header id))
4839 (gnus-read-header id))))
4840 (number (and (numberp id) id))
4843 ;; Rebuild the thread that this article is part of and go to the
4844 ;; article we have fetched.
4845 (when (and (not gnus-show-threads)
4848 (setq d (gnus-data-find (mail-header-number old-header))))
4849 (goto-char (gnus-data-pos d))
4852 (- (gnus-point-at-bol)
4854 (1+ (gnus-point-at-eol))
4855 (gnus-delete-line))))))
4857 (mail-header-set-number header (mail-header-number old-header)))
4858 (setq gnus-newsgroup-sparse
4859 (delq (setq number (mail-header-number header))
4860 gnus-newsgroup-sparse))
4861 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4862 (push number gnus-newsgroup-limit)
4863 (gnus-rebuild-thread (mail-header-id header) line)
4864 (gnus-summary-goto-subject number nil t))
4865 (when (and (numberp number)
4867 ;; We have to update the boundaries even if we can't fetch the
4868 ;; article if ID is a number -- so that the next `P' or `N'
4869 ;; command will fetch the previous (or next) article even
4870 ;; if the one we tried to fetch this time has been canceled.
4871 (when (> number gnus-newsgroup-end)
4872 (setq gnus-newsgroup-end number))
4873 (when (< number gnus-newsgroup-begin)
4874 (setq gnus-newsgroup-begin number))
4875 (setq gnus-newsgroup-unselected
4876 (delq number gnus-newsgroup-unselected)))
4877 ;; Report back a success?
4878 (and header (mail-header-number header))))
4880 ;;; Process/prefix in the summary buffer
4882 (defun gnus-summary-work-articles (n)
4883 "Return a list of articles to be worked upon.
4884 The prefix argument, the list of process marked articles, and the
4885 current article will be taken into consideration."
4887 (set-buffer gnus-summary-buffer)
4890 ;; A numerical prefix has been given.
4891 (setq n (prefix-numeric-value n))
4892 (let ((backward (< n 0))
4893 (n (abs (prefix-numeric-value n)))
4898 (push (setq article (gnus-summary-article-number))
4901 (gnus-summary-find-prev nil article)
4902 (gnus-summary-find-next nil article)))
4904 (nreverse articles)))
4905 ((and (gnus-region-active-p) (mark))
4906 (message "region active")
4907 ;; Work on the region between point and mark.
4908 (let ((max (max (point) (mark)))
4911 (goto-char (min (point) (mark)))
4914 (push (setq article (gnus-summary-article-number)) articles)
4915 (gnus-summary-find-next nil article)
4917 (nreverse articles))))
4918 (gnus-newsgroup-processable
4919 ;; There are process-marked articles present.
4920 ;; Save current state.
4921 (gnus-summary-save-process-mark)
4923 (reverse gnus-newsgroup-processable))
4925 ;; Just return the current article.
4926 (list (gnus-summary-article-number))))))
4928 (defmacro gnus-summary-iterate (arg &rest forms)
4929 "Iterate over the process/prefixed articles and do FORMS.
4930 ARG is the interactive prefix given to the command. FORMS will be
4931 executed with point over the summary line of the articles."
4932 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
4933 `(let ((,articles (gnus-summary-work-articles ,arg)))
4935 (gnus-summary-goto-subject (car ,articles))
4939 (put 'gnus-summary-iterate 'lisp-indent-function 1)
4940 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
4942 (defun gnus-summary-save-process-mark ()
4943 "Push the current set of process marked articles on the stack."
4945 (push (copy-sequence gnus-newsgroup-processable)
4946 gnus-newsgroup-process-stack))
4948 (defun gnus-summary-kill-process-mark ()
4949 "Push the current set of process marked articles on the stack and unmark."
4951 (gnus-summary-save-process-mark)
4952 (gnus-summary-unmark-all-processable))
4954 (defun gnus-summary-yank-process-mark ()
4955 "Pop the last process mark state off the stack and restore it."
4957 (unless gnus-newsgroup-process-stack
4958 (error "Empty mark stack"))
4959 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4961 (defun gnus-summary-process-mark-set (set)
4962 "Make SET into the current process marked articles."
4963 (gnus-summary-unmark-all-processable)
4965 (gnus-summary-set-process-mark (pop set))))
4967 ;;; Searching and stuff
4969 (defun gnus-summary-search-group (&optional backward use-level)
4970 "Search for next unread newsgroup.
4971 If optional argument BACKWARD is non-nil, search backward instead."
4973 (set-buffer gnus-group-buffer)
4974 (when (gnus-group-search-forward
4975 backward nil (if use-level (gnus-group-group-level) nil))
4976 (gnus-group-group-name))))
4978 (defun gnus-summary-best-group (&optional exclude-group)
4979 "Find the name of the best unread group.
4980 If EXCLUDE-GROUP, do not go to this group."
4982 (set-buffer gnus-group-buffer)
4984 (gnus-group-best-unread-group exclude-group))))
4986 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
4987 (if backward (gnus-summary-find-prev)
4988 (let* ((dummy (gnus-summary-article-intangible-p))
4989 (article (or article (gnus-summary-article-number)))
4990 (arts (gnus-data-find-list article))
4992 (when (and (not dummy)
4993 (or (not gnus-summary-check-current)
4995 (not (gnus-data-unread-p (car arts)))))
4996 (setq arts (cdr arts)))
5001 (when (or (and undownloaded
5002 (eq gnus-undownloaded-mark
5003 (gnus-data-mark (car arts))))
5004 (gnus-data-unread-p (car arts)))
5005 (setq result (car arts)
5007 (setq arts (cdr arts)))
5010 (goto-char (gnus-data-pos result))
5011 (gnus-data-number result)))))
5013 (defun gnus-summary-find-prev (&optional unread article)
5014 (let* ((eobp (eobp))
5015 (article (or article (gnus-summary-article-number)))
5016 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5018 (when (and (not eobp)
5019 (or (not gnus-summary-check-current)
5021 (not (gnus-data-unread-p (car arts)))))
5022 (setq arts (cdr arts)))
5027 (when (gnus-data-unread-p (car arts))
5028 (setq result (car arts)
5030 (setq arts (cdr arts)))
5033 (goto-char (gnus-data-pos result))
5034 (gnus-data-number result))))
5036 (defun gnus-summary-find-subject (subject &optional unread backward article)
5037 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5038 (article (or article (gnus-summary-article-number)))
5039 (articles (gnus-data-list backward))
5040 (arts (gnus-data-find-list article articles))
5042 (when (or (not gnus-summary-check-current)
5044 (not (gnus-data-unread-p (car arts))))
5045 (setq arts (cdr arts)))
5047 (and (or (not unread)
5048 (gnus-data-unread-p (car arts)))
5049 (vectorp (gnus-data-header (car arts)))
5051 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5052 (setq result (car arts)
5054 (setq arts (cdr arts)))
5056 (goto-char (gnus-data-pos result))
5057 (gnus-data-number result))))
5059 (defun gnus-summary-search-forward (&optional unread subject backward)
5060 "Search forward for an article.
5061 If UNREAD, look for unread articles. If SUBJECT, look for
5062 articles with that subject. If BACKWARD, search backward instead."
5063 (cond (subject (gnus-summary-find-subject subject unread backward))
5064 (backward (gnus-summary-find-prev unread))
5065 (t (gnus-summary-find-next unread))))
5067 (defun gnus-recenter (&optional n)
5068 "Center point in window and redisplay frame.
5069 Also do horizontal recentering."
5071 (when (and gnus-auto-center-summary
5072 (not (eq gnus-auto-center-summary 'vertical)))
5073 (gnus-horizontal-recenter))
5076 (defun gnus-summary-recenter ()
5077 "Center point in the summary window.
5078 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5079 displayed, no centering will be performed."
5080 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5081 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5082 (let* ((top (cond ((< (window-height) 4) 0)
5083 ((< (window-height) 7) 1)
5084 (t (if (numberp gnus-auto-center-summary)
5085 gnus-auto-center-summary
5087 (height (1- (window-height)))
5088 (bottom (save-excursion (goto-char (point-max))
5089 (forward-line (- height))
5091 (window (get-buffer-window (current-buffer))))
5092 ;; The user has to want it.
5093 (when gnus-auto-center-summary
5094 (when (get-buffer-window gnus-article-buffer)
5095 ;; Only do recentering when the article buffer is displayed,
5096 ;; Set the window start to either `bottom', which is the biggest
5097 ;; possible valid number, or the second line from the top,
5098 ;; whichever is the least.
5100 window (min bottom (save-excursion
5101 (forward-line (- top)) (point)))))
5102 ;; Do horizontal recentering while we're at it.
5103 (when (and (get-buffer-window (current-buffer) t)
5104 (not (eq gnus-auto-center-summary 'vertical)))
5105 (let ((selected (selected-window)))
5106 (select-window (get-buffer-window (current-buffer) t))
5107 (gnus-summary-position-point)
5108 (gnus-horizontal-recenter)
5109 (select-window selected))))))
5111 (defun gnus-summary-jump-to-group (newsgroup)
5112 "Move point to NEWSGROUP in group mode buffer."
5113 ;; Keep update point of group mode buffer if visible.
5114 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5115 (save-window-excursion
5116 ;; Take care of tree window mode.
5117 (when (get-buffer-window gnus-group-buffer)
5118 (pop-to-buffer gnus-group-buffer))
5119 (gnus-group-jump-to-group newsgroup))
5121 ;; Take care of tree window mode.
5122 (if (get-buffer-window gnus-group-buffer)
5123 (pop-to-buffer gnus-group-buffer)
5124 (set-buffer gnus-group-buffer))
5125 (gnus-group-jump-to-group newsgroup))))
5127 ;; This function returns a list of article numbers based on the
5128 ;; difference between the ranges of read articles in this group and
5129 ;; the range of active articles.
5130 (defun gnus-list-of-unread-articles (group)
5131 (let* ((read (gnus-info-read (gnus-get-info group)))
5132 (active (or (gnus-active group) (gnus-activate-group group)))
5135 ;; If none are read, then all are unread.
5137 (setq first (car active))
5138 ;; If the range of read articles is a single range, then the
5139 ;; first unread article is the article after the last read
5140 ;; article. Sounds logical, doesn't it?
5141 (if (not (listp (cdr read)))
5142 (setq first (max (car active) (1+ (cdr read))))
5143 ;; `read' is a list of ranges.
5144 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5147 (setq first (car active)))
5150 (while (< first nlast)
5152 (setq first (1+ first))))
5153 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5154 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5155 (setq read (cdr read)))))
5156 ;; And add the last unread articles.
5157 (while (<= first last)
5159 (setq first (1+ first)))
5160 ;; Return the list of unread articles.
5161 (delq 0 (nreverse unread))))
5163 (defun gnus-list-of-read-articles (group)
5164 "Return a list of unread, unticked and non-dormant articles."
5165 (let* ((info (gnus-get-info group))
5166 (marked (gnus-info-marks info))
5167 (active (gnus-active group)))
5169 (gnus-set-difference
5170 (gnus-sorted-complement
5171 (gnus-uncompress-range active)
5172 (gnus-list-of-unread-articles group))
5174 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5175 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5177 ;; Various summary commands
5179 (defun gnus-summary-select-article-buffer ()
5180 "Reconfigure windows to show article buffer."
5182 (if (not (gnus-buffer-live-p gnus-article-buffer))
5183 (error "There is no article buffer for this summary buffer")
5184 (gnus-configure-windows 'article)
5185 (select-window (get-buffer-window gnus-article-buffer))))
5187 (defun gnus-summary-universal-argument (arg)
5188 "Perform any operation on all articles that are process/prefixed."
5190 (let ((articles (gnus-summary-work-articles arg))
5197 (substitute-command-keys
5198 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
5201 (gnus-error 1 "Undefined key")
5204 (gnus-summary-goto-subject (setq article (pop articles)))
5205 (let (gnus-newsgroup-processable)
5206 (command-execute func))
5207 (gnus-summary-remove-process-mark article)))))
5208 (gnus-summary-position-point))
5210 (defun gnus-summary-toggle-truncation (&optional arg)
5211 "Toggle truncation of summary lines.
5212 With arg, turn line truncation on iff arg is positive."
5214 (setq truncate-lines
5215 (if (null arg) (not truncate-lines)
5216 (> (prefix-numeric-value arg) 0)))
5219 (defun gnus-summary-reselect-current-group (&optional all rescan)
5220 "Rescan the current newsgroup, exit and then reselect it.
5221 The prefix argument ALL means to select all articles."
5223 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5224 (error "Ephemeral groups can't be reselected"))
5225 (let ((current-subject (gnus-summary-article-number))
5226 (group gnus-newsgroup-name))
5228 (set-buffer gnus-group-buffer)
5229 ;; We have to adjust the point of group mode buffer because
5230 ;; point was moved to the next unread newsgroup by exiting.
5231 (gnus-summary-jump-to-group group)
5234 (gnus-group-get-new-news-this-group 1))))
5235 (setq gnus-newsgroup-begin nil)
5237 (gnus-group-read-group all t group)
5238 (gnus-summary-goto-subject current-subject nil t)))
5240 (defun gnus-summary-rescan-group (&optional all)
5241 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5243 (gnus-summary-reselect-current-group all t))
5245 (defun gnus-summary-update-info (&optional non-destructive)
5247 (let ((group gnus-newsgroup-name))
5249 (when gnus-newsgroup-kill-headers
5250 (setq gnus-newsgroup-killed
5251 (gnus-compress-sequence
5253 (gnus-set-sorted-intersection
5254 (gnus-uncompress-range gnus-newsgroup-killed)
5255 (setq gnus-newsgroup-unselected
5256 (sort gnus-newsgroup-unselected '<)))
5257 (setq gnus-newsgroup-unreads
5258 (sort gnus-newsgroup-unreads '<)))
5260 (unless (listp (cdr gnus-newsgroup-killed))
5261 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5262 (let ((headers gnus-newsgroup-headers))
5263 ;; Set the new ranges of read articles.
5265 (set-buffer gnus-group-buffer)
5266 (gnus-undo-force-boundary))
5267 (gnus-update-read-articles
5268 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5269 ;; Set the current article marks.
5270 (let ((gnus-newsgroup-scored
5271 (if (and (not gnus-save-score)
5272 (not non-destructive))
5274 gnus-newsgroup-scored)))
5276 (gnus-update-marks)))
5277 ;; Do the cross-ref thing.
5278 (when gnus-use-cross-reference
5279 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5280 ;; Do not switch windows but change the buffer to work.
5281 (set-buffer gnus-group-buffer)
5282 (unless (gnus-ephemeral-group-p group)
5283 (gnus-group-update-group group)))))))
5285 (defun gnus-summary-save-newsrc (&optional force)
5286 "Save the current number of read/marked articles in the dribble buffer.
5287 The dribble buffer will then be saved.
5288 If FORCE (the prefix), also save the .newsrc file(s)."
5290 (gnus-summary-update-info t)
5292 (gnus-save-newsrc-file)
5293 (gnus-dribble-save)))
5295 (defun gnus-summary-exit (&optional temporary)
5296 "Exit reading current newsgroup, and then return to group selection mode.
5297 gnus-exit-group-hook is called with no arguments if that value is non-nil."
5299 (gnus-set-global-variables)
5300 (gnus-kill-save-kill-buffer)
5301 (gnus-async-halt-prefetch)
5302 (let* ((group gnus-newsgroup-name)
5303 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5306 (buf (current-buffer)))
5308 ;; Do adaptive scoring, and possibly save score files.
5309 (when gnus-newsgroup-adaptive
5310 (gnus-score-adaptive))
5311 (when gnus-use-scoring
5313 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5314 ;; If we have several article buffers, we kill them at exit.
5315 (unless gnus-single-article-buffer
5316 (gnus-kill-buffer gnus-original-article-buffer)
5317 (setq gnus-article-current nil))
5318 (when gnus-use-cache
5319 (gnus-cache-possibly-remove-articles)
5320 (gnus-cache-save-buffers))
5321 (gnus-async-prefetch-remove-group group)
5322 (when gnus-suppress-duplicates
5323 (gnus-dup-enter-articles))
5324 (when gnus-use-trees
5325 (gnus-tree-close group))
5326 ;; Remove entries for this group.
5327 (nnmail-purge-split-history (gnus-group-real-name group))
5328 ;; Make all changes in this group permanent.
5330 (gnus-run-hooks 'gnus-exit-group-hook)
5331 (gnus-summary-update-info))
5332 (gnus-close-group group)
5333 ;; Make sure where we were, and go to next newsgroup.
5334 (set-buffer gnus-group-buffer)
5336 (gnus-group-jump-to-group group))
5337 (gnus-run-hooks 'gnus-summary-exit-hook)
5338 (unless (or quit-config
5339 ;; If this group has disappeared from the summary
5340 ;; buffer, don't skip forwards.
5341 (not (string= group (gnus-group-group-name))))
5342 (gnus-group-next-unread-group 1))
5343 (setq group-point (point))
5346 ;; If we have several article buffers, we kill them at exit.
5347 (unless gnus-single-article-buffer
5348 (gnus-kill-buffer gnus-article-buffer)
5349 (gnus-kill-buffer gnus-original-article-buffer)
5350 (setq gnus-article-current nil))
5352 (if (not gnus-kill-summary-on-exit)
5353 (gnus-deaden-summary)
5354 ;; We set all buffer-local variables to nil. It is unclear why
5355 ;; this is needed, but if we don't, buffer-local variables are
5356 ;; not garbage-collected, it seems. This would the lead to en
5357 ;; ever-growing Emacs.
5358 (gnus-summary-clear-local-variables)
5359 (when (get-buffer gnus-article-buffer)
5360 (bury-buffer gnus-article-buffer))
5361 ;; We clear the global counterparts of the buffer-local
5362 ;; variables as well, just to be on the safe side.
5363 (set-buffer gnus-group-buffer)
5364 (gnus-summary-clear-local-variables)
5365 ;; Return to group mode buffer.
5366 (when (eq mode 'gnus-summary-mode)
5367 (gnus-kill-buffer buf)))
5368 (setq gnus-current-select-method gnus-select-method)
5369 (pop-to-buffer gnus-group-buffer)
5370 (if (not quit-config)
5372 (goto-char group-point)
5373 (gnus-configure-windows 'group 'force))
5374 (gnus-handle-ephemeral-exit quit-config))
5375 ;; Clear the current group name.
5377 (setq gnus-newsgroup-name nil)))))
5379 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5380 (defun gnus-summary-exit-no-update (&optional no-questions)
5381 "Quit reading current newsgroup without updating read article info."
5383 (let* ((group gnus-newsgroup-name)
5384 (quit-config (gnus-group-quit-config group)))
5385 (when (or no-questions
5387 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5388 (gnus-async-halt-prefetch)
5390 (delq 'gnus-summary-expire-articles
5391 (copy-list gnus-summary-prepare-exit-hook)))
5392 ;; If we have several article buffers, we kill them at exit.
5393 (unless gnus-single-article-buffer
5394 (gnus-kill-buffer gnus-article-buffer)
5395 (gnus-kill-buffer gnus-original-article-buffer)
5396 (setq gnus-article-current nil))
5397 (if (not gnus-kill-summary-on-exit)
5398 (gnus-deaden-summary)
5399 (gnus-close-group group)
5400 (gnus-summary-clear-local-variables)
5401 (set-buffer gnus-group-buffer)
5402 (gnus-summary-clear-local-variables)
5403 (when (get-buffer gnus-summary-buffer)
5404 (kill-buffer gnus-summary-buffer)))
5405 (unless gnus-single-article-buffer
5406 (setq gnus-article-current nil))
5407 (when gnus-use-trees
5408 (gnus-tree-close group))
5409 (gnus-async-prefetch-remove-group group)
5410 (when (get-buffer gnus-article-buffer)
5411 (bury-buffer gnus-article-buffer))
5412 ;; Return to the group buffer.
5413 (gnus-configure-windows 'group 'force)
5414 ;; Clear the current group name.
5415 (setq gnus-newsgroup-name nil)
5416 (when (equal (gnus-group-group-name) group)
5417 (gnus-group-next-unread-group 1))
5419 (gnus-handle-ephemeral-exit quit-config)))))
5421 (defun gnus-handle-ephemeral-exit (quit-config)
5422 "Handle movement when leaving an ephemeral group.
5423 The state which existed when entering the ephemeral is reset."
5424 (if (not (buffer-name (car quit-config)))
5425 (gnus-configure-windows 'group 'force)
5426 (set-buffer (car quit-config))
5427 (cond ((eq major-mode 'gnus-summary-mode)
5428 (gnus-set-global-variables))
5429 ((eq major-mode 'gnus-article-mode)
5431 ;; The `gnus-summary-buffer' variable may point
5432 ;; to the old summary buffer when using a single
5434 (unless (gnus-buffer-live-p gnus-summary-buffer)
5435 (set-buffer gnus-group-buffer))
5436 (set-buffer gnus-summary-buffer)
5437 (gnus-set-global-variables))))
5438 (if (or (eq (cdr quit-config) 'article)
5439 (eq (cdr quit-config) 'pick))
5441 ;; The current article may be from the ephemeral group
5442 ;; thus it is best that we reload this article
5443 (gnus-summary-show-article)
5444 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5445 (gnus-configure-windows 'pick 'force)
5446 (gnus-configure-windows (cdr quit-config) 'force)))
5447 (gnus-configure-windows (cdr quit-config) 'force))
5448 (when (eq major-mode 'gnus-summary-mode)
5449 (gnus-summary-next-subject 1 nil t)
5450 (gnus-summary-recenter)
5451 (gnus-summary-position-point))))
5453 (defun gnus-summary-preview-mime-message ()
5454 "MIME decode and play this message."
5456 (let ((gnus-break-pages nil)
5458 (gnus-summary-select-article gnus-show-all-headers t))
5459 (select-window (get-buffer-window gnus-article-buffer)))
5463 (defvar gnus-dead-summary-mode-map nil)
5465 (unless gnus-dead-summary-mode-map
5466 (setq gnus-dead-summary-mode-map (make-keymap))
5467 (suppress-keymap gnus-dead-summary-mode-map)
5468 (substitute-key-definition
5469 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5470 (let ((keys '("\C-d" "\r" "\177" [delete])))
5472 (define-key gnus-dead-summary-mode-map
5473 (pop keys) 'gnus-summary-wake-up-the-dead))))
5475 (defvar gnus-dead-summary-mode nil
5476 "Minor mode for Gnus summary buffers.")
5478 (defun gnus-dead-summary-mode (&optional arg)
5479 "Minor mode for Gnus summary buffers."
5481 (when (eq major-mode 'gnus-summary-mode)
5482 (make-local-variable 'gnus-dead-summary-mode)
5483 (setq gnus-dead-summary-mode
5484 (if (null arg) (not gnus-dead-summary-mode)
5485 (> (prefix-numeric-value arg) 0)))
5486 (when gnus-dead-summary-mode
5487 (gnus-add-minor-mode
5488 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5490 (defun gnus-deaden-summary ()
5491 "Make the current summary buffer into a dead summary buffer."
5492 ;; Kill any previous dead summary buffer.
5493 (when (and gnus-dead-summary
5494 (buffer-name gnus-dead-summary))
5496 (set-buffer gnus-dead-summary)
5497 (when gnus-dead-summary-mode
5498 (kill-buffer (current-buffer)))))
5499 ;; Make this the current dead summary.
5500 (setq gnus-dead-summary (current-buffer))
5501 (gnus-dead-summary-mode 1)
5502 (let ((name (buffer-name)))
5503 (when (string-match "Summary" name)
5505 (concat (substring name 0 (match-beginning 0)) "Dead "
5506 (substring name (match-beginning 0)))
5509 (defun gnus-kill-or-deaden-summary (buffer)
5510 "Kill or deaden the summary BUFFER."
5512 (when (and (buffer-name buffer)
5513 (not gnus-single-article-buffer))
5516 (gnus-kill-buffer gnus-article-buffer)
5517 (gnus-kill-buffer gnus-original-article-buffer)))
5518 (cond (gnus-kill-summary-on-exit
5519 (when (and gnus-use-trees
5520 (gnus-buffer-exists-p buffer))
5523 (gnus-tree-close gnus-newsgroup-name)))
5524 (gnus-kill-buffer buffer))
5525 ((gnus-buffer-exists-p buffer)
5528 (gnus-deaden-summary))))))
5530 (defun gnus-summary-wake-up-the-dead (&rest args)
5531 "Wake up the dead summary buffer."
5533 (gnus-dead-summary-mode -1)
5534 (let ((name (buffer-name)))
5535 (when (string-match "Dead " name)
5537 (concat (substring name 0 (match-beginning 0))
5538 (substring name (match-end 0)))
5540 (gnus-message 3 "This dead summary is now alive again"))
5542 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5543 (defun gnus-summary-fetch-faq (&optional faq-dir)
5544 "Fetch the FAQ for the current group.
5545 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5549 (when current-prefix-arg
5551 "Faq dir: " (and (listp gnus-group-faq-directory)
5552 (mapcar (lambda (file) (list file))
5553 gnus-group-faq-directory))))))
5554 (let (gnus-faq-buffer)
5555 (when (setq gnus-faq-buffer
5556 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5557 (gnus-configure-windows 'summary-faq))))
5559 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5560 (defun gnus-summary-describe-group (&optional force)
5561 "Describe the current newsgroup."
5563 (gnus-group-describe-group force gnus-newsgroup-name))
5565 (defun gnus-summary-describe-briefly ()
5566 "Describe summary mode commands briefly."
5568 (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")))
5570 ;; Walking around group mode buffer from summary mode.
5572 (defun gnus-summary-next-group (&optional no-article target-group backward)
5573 "Exit current newsgroup and then select next unread newsgroup.
5574 If prefix argument NO-ARTICLE is non-nil, no article is selected
5575 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5576 previous group instead."
5578 ;; Stop pre-fetching.
5579 (gnus-async-halt-prefetch)
5580 (let ((current-group gnus-newsgroup-name)
5581 (current-buffer (current-buffer))
5583 ;; First we semi-exit this group to update Xrefs and all variables.
5584 ;; We can't do a real exit, because the window conf must remain
5585 ;; the same in case the user is prompted for info, and we don't
5586 ;; want the window conf to change before that...
5587 (gnus-summary-exit t)
5588 (while (not entered)
5589 ;; Then we find what group we are supposed to enter.
5590 (set-buffer gnus-group-buffer)
5591 (gnus-group-jump-to-group current-group)
5594 (if (eq gnus-keep-same-level 'best)
5595 (gnus-summary-best-group gnus-newsgroup-name)
5596 (gnus-summary-search-group backward gnus-keep-same-level))))
5597 (if (not target-group)
5598 ;; There are no further groups, so we return to the group
5601 (gnus-message 5 "Returning to the group buffer")
5603 (when (gnus-buffer-live-p current-buffer)
5604 (set-buffer current-buffer)
5605 (gnus-summary-exit))
5606 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5607 ;; We try to enter the target group.
5608 (gnus-group-jump-to-group target-group)
5609 (let ((unreads (gnus-group-group-unread)))
5610 (if (and (or (eq t unreads)
5611 (and unreads (not (zerop unreads))))
5612 (gnus-summary-read-group
5613 target-group nil no-article
5614 (and (buffer-name current-buffer) current-buffer)
5617 (setq current-group target-group
5618 target-group nil)))))))
5620 (defun gnus-summary-prev-group (&optional no-article)
5621 "Exit current newsgroup and then select previous unread newsgroup.
5622 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5624 (gnus-summary-next-group no-article nil t))
5626 ;; Walking around summary lines.
5628 (defun gnus-summary-first-subject (&optional unread undownloaded)
5629 "Go to the first unread subject.
5630 If UNREAD is non-nil, go to the first unread article.
5631 Returns the article selected or nil if there are no unread articles."
5636 ((null gnus-newsgroup-data)
5637 (gnus-message 3 "No articles in the group")
5639 ;; Pick the first article.
5641 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5642 (gnus-data-number (car gnus-newsgroup-data)))
5643 ;; No unread articles.
5644 ((null gnus-newsgroup-unreads)
5645 (gnus-message 3 "No more unread articles")
5647 ;; Find the first unread article.
5649 (let ((data gnus-newsgroup-data))
5651 (and (not (and undownloaded
5652 (eq gnus-undownloaded-mark
5653 (gnus-data-mark (car data)))))
5654 (not (gnus-data-unread-p (car data)))))
5655 (setq data (cdr data)))
5657 (goto-char (gnus-data-pos (car data)))
5658 (gnus-data-number (car data))))))
5659 (gnus-summary-position-point)))
5661 (defun gnus-summary-next-subject (n &optional unread dont-display)
5662 "Go to next N'th summary line.
5663 If N is negative, go to the previous N'th subject line.
5664 If UNREAD is non-nil, only unread articles are selected.
5665 The difference between N and the actual number of steps taken is
5668 (let ((backward (< n 0))
5672 (gnus-summary-find-prev unread)
5673 (gnus-summary-find-next unread)))
5674 (gnus-summary-show-thread)
5677 (gnus-message 7 "No more%s articles"
5678 (if unread " unread" "")))
5679 (unless dont-display
5680 (gnus-summary-recenter)
5681 (gnus-summary-position-point))
5684 (defun gnus-summary-next-unread-subject (n)
5685 "Go to next N'th unread summary line."
5687 (gnus-summary-next-subject n t))
5689 (defun gnus-summary-prev-subject (n &optional unread)
5690 "Go to previous N'th summary line.
5691 If optional argument UNREAD is non-nil, only unread article is selected."
5693 (gnus-summary-next-subject (- n) unread))
5695 (defun gnus-summary-prev-unread-subject (n)
5696 "Go to previous N'th unread summary line."
5698 (gnus-summary-next-subject (- n) t))
5700 (defun gnus-summary-goto-subject (article &optional force silent)
5701 "Go the subject line of ARTICLE.
5702 If FORCE, also allow jumping to articles not currently shown."
5703 (interactive "nArticle number: ")
5705 (data (gnus-data-find article)))
5706 ;; We read in the article if we have to.
5709 (gnus-summary-insert-subject
5711 (if (or (numberp force) (vectorp force)) force)
5713 (setq data (gnus-data-find article)))
5718 (gnus-message 3 "Can't find article %d" article))
5720 (goto-char (gnus-data-pos data))
5721 (gnus-summary-position-point)
5724 ;; Walking around summary lines with displaying articles.
5726 (defun gnus-summary-expand-window (&optional arg)
5727 "Make the summary buffer take up the entire Emacs frame.
5728 Given a prefix, will force an `article' buffer configuration."
5731 (gnus-configure-windows 'article 'force)
5732 (gnus-configure-windows 'summary 'force)))
5734 (defun gnus-summary-display-article (article &optional all-header)
5735 "Display ARTICLE in article buffer."
5736 (gnus-set-global-variables)
5740 (if gnus-summary-display-article-function
5741 (funcall gnus-summary-display-article-function article all-header)
5742 (gnus-article-prepare article all-header))
5743 (gnus-run-hooks 'gnus-select-article-hook)
5744 (when (and gnus-current-article
5745 (not (zerop gnus-current-article)))
5746 (gnus-summary-goto-subject gnus-current-article))
5747 (gnus-summary-recenter)
5748 (when (and gnus-use-trees gnus-show-threads)
5749 (gnus-possibly-generate-tree article)
5750 (gnus-highlight-selected-tree article))
5751 ;; Successfully display article.
5752 (gnus-article-set-window-start
5753 (cdr (assq article gnus-newsgroup-bookmarks))))))
5755 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5756 "Select the current article.
5757 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5758 non-nil, the article will be re-fetched even if it already present in
5759 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5761 ;; Make sure we are in the summary buffer to work around bbdb bug.
5762 (unless (eq major-mode 'gnus-summary-mode)
5763 (set-buffer gnus-summary-buffer))
5764 (let ((article (or article (gnus-summary-article-number)))
5765 (all-headers (not (not all-headers))) ;Must be T or NIL.
5766 gnus-summary-display-article-function
5769 (gnus-summary-article-pseudo-p article)
5770 (error "This is a pseudo-article"))
5773 (set-buffer gnus-summary-buffer)
5774 (if (or (and gnus-single-article-buffer
5775 (or (null gnus-current-article)
5776 (null gnus-article-current)
5777 (null (get-buffer gnus-article-buffer))
5778 (not (eq article (cdr gnus-article-current)))
5779 (not (equal (car gnus-article-current)
5780 gnus-newsgroup-name))))
5781 (and (not gnus-single-article-buffer)
5782 (or (null gnus-current-article)
5783 (not (eq gnus-current-article article))))
5785 ;; The requested article is different from the current article.
5787 (gnus-summary-display-article article all-headers)
5789 (when (or all-headers gnus-show-all-headers)
5790 (gnus-article-show-all-headers)))
5791 (when (or all-headers gnus-show-all-headers)
5792 (gnus-article-show-all-headers))
5795 (gnus-article-set-window-start
5796 (cdr (assq article gnus-newsgroup-bookmarks)))))))
5798 (defun gnus-summary-set-current-mark (&optional current-mark)
5799 "Obsolete function."
5802 (defun gnus-summary-next-article (&optional unread subject backward push)
5803 "Select the next article.
5804 If UNREAD, only unread articles are selected.
5805 If SUBJECT, only articles with SUBJECT are selected.
5806 If BACKWARD, the previous article is selected instead of the next."
5809 ;; Is there such an article?
5810 ((and (gnus-summary-search-forward unread subject backward)
5811 (or (gnus-summary-display-article (gnus-summary-article-number))
5812 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5813 (gnus-summary-position-point))
5814 ;; If not, we try the first unread, if that is wanted.
5816 gnus-auto-select-same
5817 (gnus-summary-first-unread-article))
5818 (gnus-summary-position-point)
5819 (gnus-message 6 "Wrapped"))
5820 ;; Try to get next/previous article not displayed in this group.
5821 ((and gnus-auto-extend-newsgroup
5822 (not unread) (not subject))
5823 (gnus-summary-goto-article
5824 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5825 nil (count-lines (point-min) (point))))
5826 ;; Go to next/previous group.
5828 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5829 (gnus-summary-jump-to-group gnus-newsgroup-name))
5830 (let ((cmd last-command-char)
5833 (set-buffer gnus-group-buffer)
5836 (if (eq gnus-keep-same-level 'best)
5837 (gnus-summary-best-group gnus-newsgroup-name)
5838 (gnus-summary-search-group backward gnus-keep-same-level))))
5839 ;; For some reason, the group window gets selected. We change
5841 (select-window (get-buffer-window (current-buffer)))
5842 ;; Select next unread newsgroup automagically.
5844 ((or (not gnus-auto-select-next)
5846 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5847 ((or (eq gnus-auto-select-next 'quietly)
5848 (and (eq gnus-auto-select-next 'slightly-quietly)
5850 (and (eq gnus-auto-select-next 'almost-quietly)
5851 (gnus-summary-last-article-p)))
5853 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5855 (gnus-message 7 "No more%s articles (%s)..."
5856 (if unread " unread" "")
5857 (if group (concat "selecting " group)
5859 (gnus-summary-next-group nil group backward)))
5861 (when (gnus-key-press-event-p last-input-event)
5862 (gnus-summary-walk-group-buffer
5863 gnus-newsgroup-name cmd unread backward point))))))))
5865 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5866 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5867 (?\C-p (gnus-group-prev-unread-group 1))))
5868 (cursor-in-echo-area t)
5869 keve key group ended)
5871 (set-buffer gnus-group-buffer)
5874 (if (eq gnus-keep-same-level 'best)
5875 (gnus-summary-best-group gnus-newsgroup-name)
5876 (gnus-summary-search-group backward gnus-keep-same-level))))
5879 5 "No more%s articles%s" (if unread " unread" "")
5881 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5882 (format " (Type %s for %s [%s])"
5883 (single-key-description cmd) group
5884 (car (gnus-gethash group gnus-newsrc-hashtb)))
5885 (format " (Type %s to exit %s)"
5886 (single-key-description cmd)
5887 gnus-newsgroup-name)))
5888 ;; Confirm auto selection.
5889 (setq key (car (setq keve (gnus-read-event-char))))
5892 ((assq key keystrokes)
5893 (let ((obuf (current-buffer)))
5894 (switch-to-buffer gnus-group-buffer)
5896 (gnus-group-jump-to-group group))
5897 (eval (cadr (assq key keystrokes)))
5898 (setq group (gnus-group-group-name))
5899 (switch-to-buffer obuf))
5903 (gnus-ephemeral-group-p gnus-newsgroup-name))
5905 (gnus-summary-next-group nil group backward)))
5907 (push (cdr keve) unread-command-events))))))
5909 (defun gnus-summary-next-unread-article ()
5910 "Select unread article after current one."
5912 (gnus-summary-next-article
5913 (or (not (eq gnus-summary-goto-unread 'never))
5914 (gnus-summary-last-article-p (gnus-summary-article-number)))
5915 (and gnus-auto-select-same
5916 (gnus-summary-article-subject))))
5918 (defun gnus-summary-prev-article (&optional unread subject)
5919 "Select the article after the current one.
5920 If UNREAD is non-nil, only unread articles are selected."
5922 (gnus-summary-next-article unread subject t))
5924 (defun gnus-summary-prev-unread-article ()
5925 "Select unread article before current one."
5927 (gnus-summary-prev-article
5928 (or (not (eq gnus-summary-goto-unread 'never))
5929 (gnus-summary-first-article-p (gnus-summary-article-number)))
5930 (and gnus-auto-select-same
5931 (gnus-summary-article-subject))))
5933 (defun gnus-summary-next-page (&optional lines circular)
5934 "Show next page of the selected article.
5935 If at the end of the current article, select the next article.
5936 LINES says how many lines should be scrolled up.
5938 If CIRCULAR is non-nil, go to the start of the article instead of
5939 selecting the next article when reaching the end of the current
5942 (setq gnus-summary-buffer (current-buffer))
5943 (gnus-set-global-variables)
5944 (let ((article (gnus-summary-article-number))
5945 (article-window (get-buffer-window gnus-article-buffer t))
5947 ;; If the buffer is empty, we have no article.
5949 (error "No article to select"))
5950 (gnus-configure-windows 'article)
5951 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
5952 (if (and (eq gnus-summary-goto-unread 'never)
5953 (not (gnus-summary-last-article-p article)))
5954 (gnus-summary-next-article)
5955 (gnus-summary-next-unread-article))
5956 (if (or (null gnus-current-article)
5957 (null gnus-article-current)
5958 (/= article (cdr gnus-article-current))
5959 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5960 ;; Selected subject is different from current article's.
5961 (gnus-summary-display-article article)
5962 (when article-window
5963 (gnus-eval-in-buffer-window gnus-article-buffer
5964 (setq endp (gnus-article-next-page lines)))
5967 (gnus-summary-beginning-of-article))
5969 (gnus-message 3 "End of message"))
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 (gnus-summary-recenter)
5976 (gnus-summary-position-point)))
5978 (defun gnus-summary-prev-page (&optional lines move)
5979 "Show previous page of selected article.
5980 Argument LINES specifies lines to be scrolled down.
5981 If MOVE, move to the previous unread article if point is at
5982 the beginning of the buffer."
5984 (let ((article (gnus-summary-article-number))
5985 (article-window (get-buffer-window gnus-article-buffer t))
5987 (gnus-configure-windows 'article)
5988 (if (or (null gnus-current-article)
5989 (null gnus-article-current)
5990 (/= article (cdr gnus-article-current))
5991 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5992 ;; Selected subject is different from current article's.
5993 (gnus-summary-display-article article)
5994 (gnus-summary-recenter)
5995 (when article-window
5996 (gnus-eval-in-buffer-window gnus-article-buffer
5997 (setq endp (gnus-article-prev-page lines)))
5998 (when (and move endp)
6000 (gnus-message 3 "Beginning of message"))
6002 (if (and (eq gnus-summary-goto-unread 'never)
6003 (not (gnus-summary-first-article-p article)))
6004 (gnus-summary-prev-article)
6005 (gnus-summary-prev-unread-article))))))))
6006 (gnus-summary-position-point))
6008 (defun gnus-summary-prev-page-or-article (&optional lines)
6009 "Show previous page of selected article.
6010 Argument LINES specifies lines to be scrolled down.
6011 If at the beginning of the article, go to the next article."
6013 (gnus-summary-prev-page lines t))
6015 (defun gnus-summary-scroll-up (lines)
6016 "Scroll up (or down) one line current article.
6017 Argument LINES specifies lines to be scrolled up (or down if negative)."
6019 (gnus-configure-windows 'article)
6020 (gnus-summary-show-thread)
6021 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6022 (gnus-eval-in-buffer-window gnus-article-buffer
6024 (when (gnus-article-next-page lines)
6025 (gnus-message 3 "End of message")))
6027 (gnus-article-prev-page (- lines))))))
6028 (gnus-summary-recenter)
6029 (gnus-summary-position-point))
6031 (defun gnus-summary-scroll-down (lines)
6032 "Scroll down (or up) one line current article.
6033 Argument LINES specifies lines to be scrolled down (or up if negative)."
6035 (gnus-summary-scroll-up (- lines)))
6037 (defun gnus-summary-next-same-subject ()
6038 "Select next article which has the same subject as current one."
6040 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6042 (defun gnus-summary-prev-same-subject ()
6043 "Select previous article which has the same subject as current one."
6045 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6047 (defun gnus-summary-next-unread-same-subject ()
6048 "Select next unread article which has the same subject as current one."
6050 (gnus-summary-next-article t (gnus-summary-article-subject)))
6052 (defun gnus-summary-prev-unread-same-subject ()
6053 "Select previous unread article which has the same subject as current one."
6055 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6057 (defun gnus-summary-first-unread-article ()
6058 "Select the first unread article.
6059 Return nil if there are no unread articles."
6062 (when (gnus-summary-first-subject t)
6063 (gnus-summary-show-thread)
6064 (gnus-summary-first-subject t)
6065 (gnus-summary-display-article (gnus-summary-article-number)))
6066 (gnus-summary-position-point)))
6068 (defun gnus-summary-first-unread-subject ()
6069 "Place the point on the subject line of the first unread article.
6070 Return nil if there are no unread articles."
6073 (when (gnus-summary-first-subject t)
6074 (gnus-summary-show-thread)
6075 (gnus-summary-first-subject t))
6076 (gnus-summary-position-point)))
6078 (defun gnus-summary-first-article ()
6079 "Select the first article.
6080 Return nil if there are no articles."
6083 (when (gnus-summary-first-subject)
6084 (gnus-summary-show-thread)
6085 (gnus-summary-first-subject)
6086 (gnus-summary-display-article (gnus-summary-article-number)))
6087 (gnus-summary-position-point)))
6089 (defun gnus-summary-best-unread-article ()
6090 "Select the unread article with the highest score."
6092 (let ((best -1000000)
6093 (data gnus-newsgroup-data)
6096 (and (gnus-data-unread-p (car data))
6098 (gnus-summary-article-score (gnus-data-number (car data))))
6101 article (gnus-data-number (car data))))
6102 (setq data (cdr data)))
6105 (gnus-summary-goto-article article)
6106 (error "No unread articles"))
6107 (gnus-summary-position-point))))
6109 (defun gnus-summary-last-subject ()
6110 "Go to the last displayed subject line in the group."
6111 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6113 (gnus-summary-goto-subject article))))
6115 (defun gnus-summary-goto-article (article &optional all-headers force)
6116 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6117 If ALL-HEADERS is non-nil, no header lines are hidden.
6118 If FORCE, go to the article even if it isn't displayed. If FORCE
6119 is a number, it is the line the article is to be displayed on."
6123 "Article number or Message-ID: "
6124 (mapcar (lambda (number) (list (int-to-string number)))
6125 gnus-newsgroup-limit))
6129 (if (and (stringp article)
6130 (string-match "@" article))
6131 (gnus-summary-refer-article article)
6132 (when (stringp article)
6133 (setq article (string-to-number article)))
6134 (if (gnus-summary-goto-subject article force)
6135 (gnus-summary-display-article article all-headers)
6136 (gnus-message 4 "Couldn't go to article %s" article) nil))
6137 (gnus-summary-position-point)))
6139 (defun gnus-summary-goto-last-article ()
6140 "Go to the previously read article."
6143 (when gnus-last-article
6144 (gnus-summary-goto-article gnus-last-article nil t))
6145 (gnus-summary-position-point)))
6147 (defun gnus-summary-pop-article (number)
6148 "Pop one article off the history and go to the previous.
6149 NUMBER articles will be popped off."
6152 (setq gnus-newsgroup-history
6153 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6155 (gnus-summary-goto-article (car to) nil t)
6156 (error "Article history empty")))
6157 (gnus-summary-position-point))
6159 ;; Summary commands and functions for limiting the summary buffer.
6161 (defun gnus-summary-limit-to-articles (n)
6162 "Limit the summary buffer to the next N articles.
6163 If not given a prefix, use the process marked articles instead."
6166 (let ((articles (gnus-summary-work-articles n)))
6167 (setq gnus-newsgroup-processable nil)
6168 (gnus-summary-limit articles))
6169 (gnus-summary-position-point)))
6171 (defun gnus-summary-pop-limit (&optional total)
6172 "Restore the previous limit.
6173 If given a prefix, remove all limits."
6176 (setq gnus-newsgroup-limits
6177 (list (mapcar (lambda (h) (mail-header-number h))
6178 gnus-newsgroup-headers))))
6179 (unless gnus-newsgroup-limits
6180 (error "No limit to pop"))
6182 (gnus-summary-limit nil 'pop)
6183 (gnus-summary-position-point)))
6185 (defun gnus-summary-limit-to-subject (subject &optional header)
6186 "Limit the summary buffer to articles that have subjects that match a regexp."
6187 (interactive "sLimit to subject (regexp): ")
6189 (setq header "subject"))
6190 (when (not (equal "" subject))
6192 (let ((articles (gnus-summary-find-matching
6193 (or header "subject") subject 'all)))
6195 (error "Found no matches for \"%s\"" subject))
6196 (gnus-summary-limit articles))
6197 (gnus-summary-position-point))))
6199 (defun gnus-summary-limit-to-author (from)
6200 "Limit the summary buffer to articles that have authors that match a regexp."
6201 (interactive "sLimit to author (regexp): ")
6202 (gnus-summary-limit-to-subject from "from"))
6204 (defun gnus-summary-limit-to-age (age &optional younger-p)
6205 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6206 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6207 articles that are younger than AGE days."
6208 (interactive "nLimit to articles older than (in days): \nP")
6210 (let ((data gnus-newsgroup-data)
6211 (cutoff (days-to-time age))
6212 articles d date is-younger)
6213 (while (setq d (pop data))
6214 (when (and (vectorp (gnus-data-header d))
6215 (setq date (mail-header-date (gnus-data-header d))))
6216 (setq is-younger (time-less-p
6217 (time-since (date-to-time date))
6222 (push (gnus-data-number d) articles))))
6223 (gnus-summary-limit (nreverse articles)))
6224 (gnus-summary-position-point)))
6226 (defun gnus-summary-limit-to-extra (header regexp)
6227 "Limit the summary buffer to articles that match an 'extra' header."
6231 (gnus-completing-read
6232 (symbol-name (car gnus-extra-headers))
6233 "Limit extra header:"
6235 (cons (symbol-name x) x))
6240 (read-string (format "Limit to header %s (regexp): " header)))))
6241 (when (not (equal "" regexp))
6243 (let ((articles (gnus-summary-find-matching
6244 (cons 'extra header) regexp 'all)))
6246 (error "Found no matches for \"%s\"" regexp))
6247 (gnus-summary-limit articles))
6248 (gnus-summary-position-point))))
6250 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6252 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6254 (defun gnus-summary-limit-to-unread (&optional all)
6255 "Limit the summary buffer to articles that are not marked as read.
6256 If ALL is non-nil, limit strictly to unread articles."
6259 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6260 (gnus-summary-limit-to-marks
6261 ;; Concat all the marks that say that an article is read and have
6263 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6264 gnus-killed-mark gnus-kill-file-mark
6265 gnus-low-score-mark gnus-expirable-mark
6266 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6267 gnus-duplicate-mark gnus-souped-mark)
6270 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6271 (make-obsolete 'gnus-summary-delete-marked-with
6272 'gnus-summary-limit-exlude-marks)
6274 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6275 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6276 If REVERSE, limit the summary buffer to articles that are marked
6277 with MARKS. MARKS can either be a string of marks or a list of marks.
6278 Returns how many articles were removed."
6279 (interactive "sMarks: ")
6280 (gnus-summary-limit-to-marks marks t))
6282 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6283 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6284 If REVERSE (the prefix), limit the summary buffer to articles that are
6285 not marked with MARKS. MARKS can either be a string of marks or a
6287 Returns how many articles were removed."
6288 (interactive "sMarks: \nP")
6290 (let ((data gnus-newsgroup-data)
6291 (marks (if (listp marks) marks
6292 (append marks nil))) ; Transform to list.
6295 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6296 (memq (gnus-data-mark (car data)) marks))
6297 (push (gnus-data-number (car data)) articles))
6298 (setq data (cdr data)))
6299 (gnus-summary-limit articles))
6300 (gnus-summary-position-point)))
6302 (defun gnus-summary-limit-to-score (&optional score)
6303 "Limit to articles with score at or above SCORE."
6305 (setq score (if score
6306 (prefix-numeric-value score)
6307 (or gnus-summary-default-score 0)))
6308 (let ((data gnus-newsgroup-data)
6311 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6313 (push (gnus-data-number (car data)) articles))
6314 (setq data (cdr data)))
6316 (gnus-summary-limit articles)
6317 (gnus-summary-position-point))))
6319 (defun gnus-summary-limit-include-thread (id)
6320 "Display all the hidden articles that in the current thread."
6321 (interactive (list (mail-header-id (gnus-summary-article-header))))
6322 (let ((articles (gnus-articles-in-thread
6323 (gnus-id-to-thread (gnus-root-id id)))))
6325 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6326 (gnus-summary-position-point))))
6328 (defun gnus-summary-limit-include-dormant ()
6329 "Display all the hidden articles that are marked as dormant.
6330 Note that this command only works on a subset of the articles currently
6331 fetched for this group."
6333 (unless gnus-newsgroup-dormant
6334 (error "There are no dormant articles in this group"))
6336 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6337 (gnus-summary-position-point)))
6339 (defun gnus-summary-limit-exclude-dormant ()
6340 "Hide all dormant articles."
6343 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6344 (gnus-summary-position-point)))
6346 (defun gnus-summary-limit-exclude-childless-dormant ()
6347 "Hide all dormant articles that have no children."
6349 (let ((data (gnus-data-list t))
6350 articles d children)
6351 ;; Find all articles that are either not dormant or have
6353 (while (setq d (pop data))
6354 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6356 (gnus-article-children (gnus-data-number d)))
6359 (when (memq (car children) articles)
6364 (push (gnus-data-number d) articles)))
6367 (gnus-summary-limit articles)
6368 (gnus-summary-position-point))))
6370 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6371 "Mark all unread excluded articles as read.
6372 If ALL, mark even excluded ticked and dormants as read."
6374 (let ((articles (gnus-sorted-complement
6376 (mapcar (lambda (h) (mail-header-number h))
6377 gnus-newsgroup-headers)
6379 (sort gnus-newsgroup-limit '<)))
6381 (setq gnus-newsgroup-unreads
6382 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6384 (setq gnus-newsgroup-dormant nil
6385 gnus-newsgroup-marked nil
6386 gnus-newsgroup-reads
6388 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6389 gnus-newsgroup-reads))
6390 (while (setq article (pop articles))
6391 (unless (or (memq article gnus-newsgroup-dormant)
6392 (memq article gnus-newsgroup-marked))
6393 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6395 (defun gnus-summary-limit (articles &optional pop)
6397 ;; We pop the previous limit off the stack and use that.
6398 (setq articles (car gnus-newsgroup-limits)
6399 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6400 ;; We use the new limit, so we push the old limit on the stack.
6401 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6403 (setq gnus-newsgroup-limit articles)
6404 (let ((total (length gnus-newsgroup-data))
6405 (data (gnus-data-find-list (gnus-summary-article-number)))
6406 (gnus-summary-mark-below nil) ; Inhibit this.
6408 ;; This will do all the work of generating the new summary buffer
6409 ;; according to the new limit.
6410 (gnus-summary-prepare)
6411 ;; Hide any threads, possibly.
6412 (and gnus-show-threads
6413 gnus-thread-hide-subtree
6414 (gnus-summary-hide-all-threads))
6415 ;; Try to return to the article you were at, or one in the
6418 ;; We try to find some article after the current one.
6420 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6423 (setq data (cdr data))))
6425 ;; If there is no data, that means that we were after the last
6426 ;; article. The same goes when we can't find any articles
6427 ;; after the current one.
6428 (goto-char (point-max))
6429 (gnus-summary-find-prev))
6430 (gnus-set-mode-line 'summary)
6431 ;; We return how many articles were removed from the summary
6432 ;; buffer as a result of the new limit.
6433 (- total (length gnus-newsgroup-data))))
6435 (defsubst gnus-invisible-cut-children (threads)
6438 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6443 (defsubst gnus-cut-thread (thread)
6444 "Go forwards in the thread until we find an article that we want to display."
6445 (when (or (eq gnus-fetch-old-headers 'some)
6446 (eq gnus-fetch-old-headers 'invisible)
6447 (eq gnus-build-sparse-threads 'some)
6448 (eq gnus-build-sparse-threads 'more))
6449 ;; Deal with old-fetched headers and sparse threads.
6453 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6454 (gnus-summary-article-ancient-p
6455 (mail-header-number (car thread))))
6456 (if (or (<= (length (cdr thread)) 1)
6457 (eq gnus-fetch-old-headers 'invisible))
6458 (setq gnus-newsgroup-limit
6459 (delq (mail-header-number (car thread))
6460 gnus-newsgroup-limit)
6461 thread (cadr thread))
6462 (when (gnus-invisible-cut-children (cdr thread))
6463 (let ((th (cdr thread)))
6465 (if (memq (mail-header-number (caar th))
6466 gnus-newsgroup-limit)
6467 (setq thread (car th)
6469 (setq th (cdr th))))))))))
6472 (defun gnus-cut-threads (threads)
6473 "Cut off all uninteresting articles from the beginning of threads."
6474 (when (or (eq gnus-fetch-old-headers 'some)
6475 (eq gnus-fetch-old-headers 'invisible)
6476 (eq gnus-build-sparse-threads 'some)
6477 (eq gnus-build-sparse-threads 'more))
6480 (setcar th (gnus-cut-thread (car th)))
6481 (setq th (cdr th)))))
6482 ;; Remove nixed out threads.
6485 (defun gnus-summary-initial-limit (&optional show-if-empty)
6486 "Figure out what the initial limit is supposed to be on group entry.
6487 This entails weeding out unwanted dormants, low-scored articles,
6488 fetch-old-headers verbiage, and so on."
6489 ;; Most groups have nothing to remove.
6490 (if (or gnus-inhibit-limiting
6491 (and (null gnus-newsgroup-dormant)
6492 (not (eq gnus-fetch-old-headers 'some))
6493 (not (eq gnus-fetch-old-headers 'invisible))
6494 (null gnus-summary-expunge-below)
6495 (not (eq gnus-build-sparse-threads 'some))
6496 (not (eq gnus-build-sparse-threads 'more))
6497 (null gnus-thread-expunge-below)
6498 (not gnus-use-nocem)))
6500 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6501 (setq gnus-newsgroup-limit nil)
6504 (unless (car (symbol-value node))
6505 ;; These threads have no parents -- they are roots.
6506 (let ((nodes (cdr (symbol-value node)))
6509 (if (and gnus-thread-expunge-below
6510 (< (gnus-thread-total-score (car nodes))
6511 gnus-thread-expunge-below))
6512 (gnus-expunge-thread (pop nodes))
6513 (setq thread (pop nodes))
6514 (gnus-summary-limit-children thread))))))
6515 gnus-newsgroup-dependencies)
6516 ;; If this limitation resulted in an empty group, we might
6517 ;; pop the previous limit and use it instead.
6518 (when (and (not gnus-newsgroup-limit)
6520 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6521 gnus-newsgroup-limit))
6523 (defun gnus-summary-limit-children (thread)
6524 "Return 1 if this subthread is visible and 0 if it is not."
6525 ;; First we get the number of visible children to this thread. This
6526 ;; is done by recursing down the thread using this function, so this
6527 ;; will really go down to a leaf article first, before slowly
6528 ;; working its way up towards the root.
6532 (apply '+ (mapcar 'gnus-summary-limit-children
6535 (number (mail-header-number (car thread)))
6538 (not (memq number gnus-newsgroup-marked))
6540 ;; If this article is dormant and has absolutely no visible
6541 ;; children, then this article isn't visible.
6542 (and (memq number gnus-newsgroup-dormant)
6544 ;; If this is "fetch-old-headered" and there is no
6545 ;; visible children, then we don't want this article.
6546 (and (eq gnus-fetch-old-headers 'some)
6547 (gnus-summary-article-ancient-p number)
6549 ;; If this is "fetch-old-headered" and `invisible', then
6550 ;; we don't want this article.
6551 (and (eq gnus-fetch-old-headers 'invisible)
6552 (gnus-summary-article-ancient-p number))
6553 ;; If this is a sparsely inserted article with no children,
6554 ;; we don't want it.
6555 (and (eq gnus-build-sparse-threads 'some)
6556 (gnus-summary-article-sparse-p number)
6558 ;; If we use expunging, and this article is really
6559 ;; low-scored, then we don't want this article.
6560 (when (and gnus-summary-expunge-below
6562 (or (cdr (assq number gnus-newsgroup-scored))
6563 gnus-summary-default-score))
6564 gnus-summary-expunge-below))
6565 ;; We increase the expunge-tally here, but that has
6566 ;; nothing to do with the limits, really.
6567 (incf gnus-newsgroup-expunged-tally)
6568 ;; We also mark as read here, if that's wanted.
6569 (when (and gnus-summary-mark-below
6570 (< score gnus-summary-mark-below))
6571 (setq gnus-newsgroup-unreads
6572 (delq number gnus-newsgroup-unreads))
6573 (if gnus-newsgroup-auto-expire
6574 (push number gnus-newsgroup-expirable)
6575 (push (cons number gnus-low-score-mark)
6576 gnus-newsgroup-reads)))
6578 ;; Check NoCeM things.
6579 (if (and gnus-use-nocem
6580 (gnus-nocem-unwanted-article-p
6581 (mail-header-id (car thread))))
6583 (setq gnus-newsgroup-unreads
6584 (delq number gnus-newsgroup-unreads))
6586 ;; Nope, invisible article.
6588 ;; Ok, this article is to be visible, so we add it to the limit
6590 (push number gnus-newsgroup-limit)
6593 (defun gnus-expunge-thread (thread)
6594 "Mark all articles in THREAD as read."
6595 (let* ((number (mail-header-number (car thread))))
6596 (incf gnus-newsgroup-expunged-tally)
6597 ;; We also mark as read here, if that's wanted.
6598 (setq gnus-newsgroup-unreads
6599 (delq number gnus-newsgroup-unreads))
6600 (if gnus-newsgroup-auto-expire
6601 (push number gnus-newsgroup-expirable)
6602 (push (cons number gnus-low-score-mark)
6603 gnus-newsgroup-reads)))
6604 ;; Go recursively through all subthreads.
6605 (mapcar 'gnus-expunge-thread (cdr thread)))
6607 ;; Summary article oriented commands
6609 (defun gnus-summary-refer-parent-article (n)
6610 "Refer parent article N times.
6611 If N is negative, go to ancestor -N instead.
6612 The difference between N and the number of articles fetched is returned."
6616 (when (not (natnump n))
6621 (setq header (gnus-summary-article-header))
6622 (if (and (eq (mail-header-number header)
6623 (cdr gnus-article-current))
6624 (equal gnus-newsgroup-name
6625 (car gnus-article-current)))
6626 ;; If we try to find the parent of the currently
6627 ;; displayed article, then we take a look at the actual
6628 ;; References header, since this is slightly more
6629 ;; reliable than the References field we got from the
6632 (set-buffer gnus-original-article-buffer)
6633 (nnheader-narrow-to-headers)
6634 (unless (setq ref (message-fetch-field "references"))
6635 (setq ref (message-fetch-field "in-reply-to")))
6638 ;; It's not the current article, so we take a bet on
6639 ;; the value we got from the server.
6640 (mail-header-references header)))
6642 (not (equal ref "")))
6643 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6644 (gnus-message 1 "Couldn't find parent"))
6645 (gnus-message 1 "No references in article %d"
6646 (gnus-summary-article-number))
6649 (gnus-summary-position-point)
6652 (defun gnus-summary-refer-references ()
6653 "Fetch all articles mentioned in the References header.
6654 Return the number of articles fetched."
6656 (let ((ref (mail-header-references (gnus-summary-article-header)))
6657 (current (gnus-summary-article-number))
6661 (error "No References in the current article")
6662 ;; For each Message-ID in the References header...
6663 (while (string-match "<[^>]*>" ref)
6665 ;; ... fetch that article.
6666 (gnus-summary-refer-article
6667 (prog1 (match-string 0 ref)
6668 (setq ref (substring ref (match-end 0))))))
6669 (gnus-summary-goto-subject current)
6670 (gnus-summary-position-point)
6673 (defun gnus-summary-refer-thread (&optional limit)
6674 "Fetch all articles in the current thread.
6675 If LIMIT (the numerical prefix), fetch that many old headers instead
6676 of what's specified by the `gnus-refer-thread-limit' variable."
6678 (let ((id (mail-header-id (gnus-summary-article-header)))
6679 (limit (if limit (prefix-numeric-value limit)
6680 gnus-refer-thread-limit)))
6681 ;; We want to fetch LIMIT *old* headers, but we also have to
6682 ;; re-fetch all the headers in the current buffer, because many of
6683 ;; them may be undisplayed. So we adjust LIMIT.
6684 (when (numberp limit)
6685 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6686 (unless (eq gnus-fetch-old-headers 'invisible)
6687 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6688 ;; Retrieve the headers and read them in.
6689 (if (eq (gnus-retrieve-headers
6690 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6692 (gnus-build-all-threads)
6693 (error "Can't fetch thread from backends that don't support NOV"))
6694 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6695 (gnus-summary-limit-include-thread id)))
6697 (defun gnus-summary-refer-article (message-id &optional arg)
6698 "Fetch an article specified by MESSAGE-ID.
6699 If ARG (the prefix), fetch the article using `gnus-refer-article-method'
6700 or `gnus-select-method', no matter what backend the article comes from."
6701 (interactive "sMessage-ID: \nP")
6702 (when (and (stringp message-id)
6703 (not (zerop (length message-id))))
6704 ;; Construct the correct Message-ID if necessary.
6705 ;; Suggested by tale@pawl.rpi.edu.
6706 (unless (string-match "^<" message-id)
6707 (setq message-id (concat "<" message-id)))
6708 (unless (string-match ">$" message-id)
6709 (setq message-id (concat message-id ">")))
6710 (let* ((header (gnus-id-to-header message-id))
6712 (gnus-summary-article-sparse-p
6713 (mail-header-number header))
6714 (memq (mail-header-number header)
6715 gnus-newsgroup-limit))))
6717 ;; If the article is present in the buffer we just go to it.
6719 (or (not (gnus-summary-article-sparse-p
6720 (mail-header-number header)))
6723 (gnus-summary-goto-article
6724 (mail-header-number header) nil t)
6726 (gnus-summary-update-article (mail-header-number header)))))
6728 ;; We fetch the article
6729 (let ((gnus-override-method
6730 (cond ((gnus-news-group-p gnus-newsgroup-name)
6731 gnus-refer-article-method)
6733 (or gnus-refer-article-method gnus-select-method))
6736 ;; Start the special refer-article method, if necessary.
6737 (when (and gnus-refer-article-method
6738 (gnus-news-group-p gnus-newsgroup-name))
6739 (gnus-check-server gnus-refer-article-method))
6740 ;; Fetch the header, and display the article.
6741 (if (setq number (gnus-summary-insert-subject message-id))
6742 (gnus-summary-select-article nil nil nil number)
6743 (gnus-message 3 "Couldn't fetch article %s" message-id))))))))
6745 (defun gnus-summary-edit-parameters ()
6746 "Edit the group parameters of the current group."
6748 (gnus-group-edit-group gnus-newsgroup-name 'params))
6750 (defun gnus-summary-customize-parameters ()
6751 "Customize the group parameters of the current group."
6753 (gnus-group-customize gnus-newsgroup-name))
6755 (defun gnus-summary-enter-digest-group (&optional force)
6756 "Enter an nndoc group based on the current article.
6757 If FORCE, force a digest interpretation. If not, try
6758 to guess what the document format is."
6760 (let ((conf gnus-current-window-configuration))
6762 (gnus-summary-select-article))
6763 (setq gnus-current-window-configuration conf)
6764 (let* ((name (format "%s-%d"
6765 (gnus-group-prefixed-name
6766 gnus-newsgroup-name (list 'nndoc ""))
6768 (set-buffer gnus-summary-buffer)
6769 gnus-current-article)))
6770 (ogroup gnus-newsgroup-name)
6771 (params (append (gnus-info-params (gnus-get-info ogroup))
6772 (list (cons 'to-group ogroup))
6773 (list (cons 'save-article-group ogroup))))
6774 (case-fold-search t)
6775 (buf (current-buffer))
6778 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6779 (insert-buffer-substring gnus-original-article-buffer)
6780 ;; Remove lines that may lead nndoc to misinterpret the
6783 (goto-char (point-min))
6784 (or (search-forward "\n\n" nil t) (point)))
6785 (goto-char (point-min))
6786 (delete-matching-lines "^Path:\\|^From ")
6789 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
6790 (gnus-newsgroup-ephemeral-ignored-charsets
6791 gnus-newsgroup-ignored-charsets))
6792 (gnus-group-read-ephemeral-group
6793 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6795 ,(if force 'digest 'guess))) t))
6796 ;; Make all postings to this group go to the parent group.
6797 (nconc (gnus-info-params (gnus-get-info name))
6799 ;; Couldn't select this doc group.
6800 (switch-to-buffer buf)
6801 (gnus-set-global-variables)
6802 (gnus-configure-windows 'summary)
6803 (gnus-message 3 "Article couldn't be entered?"))
6804 (kill-buffer dig)))))
6806 (defun gnus-summary-read-document (n)
6807 "Open a new group based on the current article(s).
6808 This will allow you to read digests and other similar
6809 documents as newsgroups.
6810 Obeys the standard process/prefix convention."
6812 (let* ((articles (gnus-summary-work-articles n))
6813 (ogroup gnus-newsgroup-name)
6814 (params (append (gnus-info-params (gnus-get-info ogroup))
6815 (list (cons 'to-group ogroup))))
6816 article group egroup groups vgroup)
6817 (while (setq article (pop articles))
6818 (setq group (format "%s-%d" gnus-newsgroup-name article))
6819 (gnus-summary-remove-process-mark article)
6820 (when (gnus-summary-display-article article)
6823 (insert-buffer-substring gnus-original-article-buffer)
6824 ;; Remove some headers that may lead nndoc to make
6826 (message-narrow-to-head)
6827 (goto-char (point-min))
6828 (delete-matching-lines "^\\(Path\\):\\|^From ")
6831 (gnus-group-read-ephemeral-group
6832 group `(nndoc ,group (nndoc-address ,(current-buffer))
6833 (nndoc-article-type guess))
6836 ;; Make all postings to this group go to the parent group.
6837 (nconc (gnus-info-params (gnus-get-info egroup))
6839 (push egroup groups))
6840 ;; Couldn't select this doc group.
6841 (gnus-error 3 "Article couldn't be entered"))))))
6842 ;; Now we have selected all the documents.
6845 (error "None of the articles could be interpreted as documents"))
6846 ((gnus-group-read-ephemeral-group
6847 (setq vgroup (format
6848 "nnvirtual:%s-%s" gnus-newsgroup-name
6849 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6850 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6852 (cons (current-buffer) 'summary)))
6854 (error "Couldn't select virtual nndoc group")))))
6856 (defun gnus-summary-isearch-article (&optional regexp-p)
6857 "Do incremental search forward on the current article.
6858 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6860 (let (gnus-treat-hide-headers
6861 gnus-treat-hide-boring-headers
6862 gnus-treat-display-xface
6863 gnus-treat-display-smileys
6864 gnus-treat-display-picons
6865 gnus-treat-play-sounds)
6866 (gnus-summary-select-article nil t))
6867 (gnus-configure-windows 'article)
6868 (gnus-eval-in-buffer-window gnus-article-buffer
6869 (set (make-local-variable 'isearch-lazy-highlight) t)
6872 (goto-char (point-min))
6873 (isearch-forward regexp-p))))
6875 (defun gnus-summary-search-article-forward (regexp &optional backward)
6876 "Search for an article containing REGEXP forward.
6877 If BACKWARD, search backward instead."
6880 (format "Search article %s (regexp%s): "
6881 (if current-prefix-arg "backward" "forward")
6882 (if gnus-last-search-regexp
6883 (concat ", default " gnus-last-search-regexp)
6885 current-prefix-arg))
6886 (if (string-equal regexp "")
6887 (setq regexp (or gnus-last-search-regexp ""))
6888 (setq gnus-last-search-regexp regexp))
6889 (if (gnus-summary-search-article regexp backward)
6890 (gnus-summary-show-thread)
6891 (error "Search failed: \"%s\"" regexp)))
6893 (defun gnus-summary-search-article-backward (regexp)
6894 "Search for an article containing REGEXP backward."
6897 (format "Search article backward (regexp%s): "
6898 (if gnus-last-search-regexp
6899 (concat ", default " gnus-last-search-regexp)
6901 (gnus-summary-search-article-forward regexp 'backward))
6903 (defvar gnus-summary-search-article-matched-text)
6905 (defmacro gnus-summary-search-article-highlight-matched-text ()
6906 "Highlight matched text in the function `gnus-summary-search-article'."
6907 '(let ((start (match-beginning 0))
6909 (old (if (boundp 'gnus-summary-search-article-matched-text)
6910 gnus-summary-search-article-matched-text))
6911 (inhibit-read-only t)
6914 (let ((old-start (car old))
6915 (old-end (cadr old))
6916 (old-text (caddr old)))
6917 (when (string-equal (buffer-substring old-start old-end) old-text)
6918 (goto-char old-start)
6919 (delete-region old-start old-end)
6922 (set (make-local-variable 'gnus-summary-search-article-matched-text)
6923 (list start end (buffer-substring start end)))
6924 (put-text-property start end 'face
6925 (or (find-face 'isearch) 'secondary-selection))))
6928 (defun gnus-summary-search-article (regexp &optional backward)
6929 "Search for an article containing REGEXP.
6930 Optional argument BACKWARD means do search for backward.
6931 `gnus-select-article-hook' is not called during the search."
6932 ;; We have to require this here to make sure that the following
6933 ;; dynamic binding isn't shadowed by autoloading.
6934 (require 'gnus-async)
6936 (let ((gnus-select-article-hook nil) ;Disable hook.
6937 (gnus-article-display-hook nil)
6938 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6939 (gnus-use-article-prefetch nil)
6940 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
6941 (gnus-use-trees nil) ;Inhibit updating tree buffer.
6942 (sum (current-buffer))
6945 (gnus-save-hidden-threads
6946 (let (gnus-treat-hide-headers
6947 gnus-treat-hide-boring-headers
6948 gnus-treat-display-xface
6949 gnus-treat-display-smileys
6950 gnus-treat-display-picons
6951 gnus-treat-play-sounds)
6952 (gnus-summary-select-article nil t))
6953 (set-buffer gnus-article-buffer)
6957 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
6959 (re-search-backward regexp nil t)
6960 (re-search-forward regexp nil t))
6961 ;; We found the regexp.
6963 (gnus-summary-search-article-highlight-matched-text)
6967 (get-buffer-window (current-buffer))
6971 (setq point (point)))
6972 ;; We didn't find it, so we go to the next article.
6975 (while (eq found 'not)
6976 (if (not (if backward (gnus-summary-find-prev)
6977 (gnus-summary-find-next)))
6978 ;; No more articles.
6980 ;; Select the next article and adjust point.
6981 (unless (gnus-summary-article-sparse-p
6982 (gnus-summary-article-number))
6984 (let (gnus-treat-hide-headers
6985 gnus-treat-hide-boring-headers
6986 gnus-treat-display-xface
6987 gnus-treat-display-smileys
6988 gnus-treat-display-picons
6989 gnus-treat-play-sounds)
6990 (gnus-summary-select-article nil t))
6991 (set-buffer gnus-article-buffer)
6993 (goto-char (if backward (point-max) (point-min))))))))
6994 (gnus-message 7 ""))
6995 ;; Return whether we found the regexp.
6996 (when (eq found 'found)
6998 (gnus-summary-show-thread)
6999 (gnus-summary-goto-subject gnus-current-article)
7000 (gnus-summary-position-point)
7003 (defun gnus-summary-find-matching (header regexp &optional backward unread
7005 "Return a list of all articles that match REGEXP on HEADER.
7006 The search stars on the current article and goes forwards unless
7007 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
7008 If UNREAD is non-nil, only unread articles will
7009 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
7010 in the comparisons."
7011 (let ((data (if (eq backward 'all) gnus-newsgroup-data
7012 (gnus-data-find-list
7013 (gnus-summary-article-number) (gnus-data-list backward))))
7014 (case-fold-search (not not-case-fold))
7017 (if (eq (car header) 'extra)
7020 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
7022 (error "%s is an invalid header" header))
7023 (unless (fboundp (intern (concat "mail-header-" header)))
7024 (error "%s is not a valid header" header))
7025 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
7028 (and (or (not unread) ; We want all articles...
7029 (gnus-data-unread-p d)) ; Or just unreads.
7030 (vectorp (gnus-data-header d)) ; It's not a pseudo.
7031 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
7032 (push (gnus-data-number d) articles)) ; Success!
7033 (setq data (cdr data)))
7034 (nreverse articles)))
7036 (defun gnus-summary-execute-command (header regexp command &optional backward)
7037 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7038 If HEADER is an empty string (or nil), the match is done on the entire
7039 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7041 (list (let ((completion-ignore-case t))
7044 (mapcar (lambda (string) (list string))
7045 '("Number" "Subject" "From" "Lines" "Date"
7046 "Message-ID" "Xref" "References" "Body"))
7047 nil 'require-match))
7048 (read-string "Regexp: ")
7049 (read-key-sequence "Command: ")
7050 current-prefix-arg))
7051 (when (equal header "Body")
7053 ;; Hidden thread subtrees must be searched as well.
7054 (gnus-summary-show-all-threads)
7055 ;; We don't want to change current point nor window configuration.
7057 (save-window-excursion
7058 (gnus-message 6 "Executing %s..." (key-description command))
7059 ;; We'd like to execute COMMAND interactively so as to give arguments.
7060 (gnus-execute header regexp
7061 `(call-interactively ',(key-binding command))
7063 (gnus-message 6 "Executing %s...done" (key-description command)))))
7065 (defun gnus-summary-beginning-of-article ()
7066 "Scroll the article back to the beginning."
7068 (gnus-summary-select-article)
7069 (gnus-configure-windows 'article)
7070 (gnus-eval-in-buffer-window gnus-article-buffer
7072 (goto-char (point-min))
7073 (when gnus-page-broken
7074 (gnus-narrow-to-page))))
7076 (defun gnus-summary-end-of-article ()
7077 "Scroll to the end of the article."
7079 (gnus-summary-select-article)
7080 (gnus-configure-windows 'article)
7081 (gnus-eval-in-buffer-window gnus-article-buffer
7083 (goto-char (point-max))
7085 (when gnus-page-broken
7086 (gnus-narrow-to-page))))
7088 (defun gnus-summary-print-article (&optional filename n)
7089 "Generate and print a PostScript image of the N next (mail) articles.
7091 If N is negative, print the N previous articles. If N is nil and articles
7092 have been marked with the process mark, print these instead.
7094 If the optional first argument FILENAME is nil, send the image to the
7095 printer. If FILENAME is a string, save the PostScript image in a file with
7096 that name. If FILENAME is a number, prompt the user for the name of the file
7098 (interactive (list (ps-print-preprint current-prefix-arg)
7099 current-prefix-arg))
7100 (dolist (article (gnus-summary-work-articles n))
7101 (gnus-summary-select-article nil nil 'pseudo article)
7102 (gnus-eval-in-buffer-window gnus-article-buffer
7103 (let ((buffer (generate-new-buffer " *print*")))
7106 (copy-to-buffer buffer (point-min) (point-max))
7108 (gnus-article-delete-invisible-text)
7109 (let ((ps-left-header
7112 (mail-header-subject gnus-current-headers) ")")
7114 (mail-header-from gnus-current-headers) ")")))
7117 "/pagenumberstring load"
7119 (mail-header-date gnus-current-headers) ")"))))
7120 (gnus-run-hooks 'gnus-ps-print-hook)
7122 (ps-print-buffer-with-faces filename))))
7123 (kill-buffer buffer))))))
7125 (defun gnus-summary-show-article (&optional arg)
7126 "Force re-fetching of the current article.
7127 If ARG (the prefix) is non-nil, show the raw article without any
7128 article massaging functions being run."
7131 ;; Select the article the normal way.
7132 (gnus-summary-select-article nil 'force)
7133 ;; We have to require this here to make sure that the following
7134 ;; dynamic binding isn't shadowed by autoloading.
7135 (require 'gnus-async)
7137 ;; Bind the article treatment functions to nil.
7138 (let ((gnus-have-all-headers t)
7139 gnus-article-display-hook
7140 gnus-article-prepare-hook
7141 gnus-article-decode-hook
7145 (gnus-summary-select-article nil 'force)))
7146 (gnus-summary-goto-subject gnus-current-article)
7147 (gnus-summary-position-point))
7149 (defun gnus-summary-verbose-headers (&optional arg)
7150 "Toggle permanent full header display.
7151 If ARG is a positive number, turn header display on.
7152 If ARG is a negative number, turn header display off."
7154 (setq gnus-show-all-headers
7155 (cond ((or (not (numberp arg))
7157 (not gnus-show-all-headers))
7160 (gnus-summary-show-article))
7162 (defun gnus-summary-toggle-header (&optional arg)
7163 "Show the headers if they are hidden, or hide them if they are shown.
7164 If ARG is a positive number, show the entire header.
7165 If ARG is a negative number, hide the unwanted header lines."
7168 (set-buffer gnus-article-buffer)
7170 (let* ((buffer-read-only nil)
7171 (inhibit-point-motion-hooks t)
7174 (article-narrow-to-head)
7175 (setq hidden (gnus-article-hidden-text-p 'headers)))
7176 (goto-char (point-min))
7177 (when (search-forward "\n\n" nil t)
7178 (delete-region (point-min) (1- (point))))
7179 (goto-char (point-min))
7181 (set-buffer gnus-original-article-buffer)
7182 (goto-char (point-min))
7183 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
7184 (insert-buffer-substring gnus-original-article-buffer 1 e)
7186 (narrow-to-region (point-min) (point))
7187 (article-decode-encoded-words)
7189 (and (numberp arg) (< arg 0)))
7190 (let ((gnus-treat-hide-headers nil)
7191 (gnus-treat-hide-boring-headers nil))
7192 (gnus-treat-article 'head))
7193 (gnus-treat-article 'head)))))))
7195 (defun gnus-summary-show-all-headers ()
7196 "Make all header lines visible."
7198 (gnus-article-show-all-headers))
7200 (defun gnus-summary-toggle-mime (&optional arg)
7201 "Toggle MIME processing.
7202 If ARG is a positive number, turn MIME processing on."
7204 (setq gnus-show-mime
7206 (not gnus-show-mime)
7207 (> (prefix-numeric-value arg) 0)))
7208 (gnus-summary-select-article t 'force))
7210 (defun gnus-summary-caesar-message (&optional arg)
7211 "Caesar rotate the current article by 13.
7212 The numerical prefix specifies how many places to rotate each letter
7215 (gnus-summary-select-article)
7216 (let ((mail-header-separator ""))
7217 (gnus-eval-in-buffer-window gnus-article-buffer
7220 (let ((start (window-start))
7222 (message-caesar-buffer-body arg)
7223 (set-window-start (get-buffer-window (current-buffer)) start))))))
7225 (defun gnus-summary-stop-page-breaking ()
7226 "Stop page breaking in the current article."
7228 (gnus-summary-select-article)
7229 (gnus-eval-in-buffer-window gnus-article-buffer
7231 (when (gnus-visual-p 'page-marker)
7232 (let ((buffer-read-only nil))
7233 (gnus-remove-text-with-property 'gnus-prev)
7234 (gnus-remove-text-with-property 'gnus-next))
7235 (setq gnus-page-broken nil))))
7237 (defun gnus-summary-move-article (&optional n to-newsgroup
7238 select-method action)
7239 "Move the current article to a different newsgroup.
7240 If N is a positive number, move the N next articles.
7241 If N is a negative number, move the N previous articles.
7242 If N is nil and any articles have been marked with the process mark,
7243 move those articles instead.
7244 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7245 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7246 re-spool using this method.
7248 For this function to work, both the current newsgroup and the
7249 newsgroup that you want to move to have to support the `request-move'
7250 and `request-accept' functions."
7253 (setq action 'move))
7254 ;; Disable marking as read.
7255 (let (gnus-mark-article-hook)
7256 (save-window-excursion
7257 (gnus-summary-select-article)))
7258 ;; Check whether the source group supports the required functions.
7259 (cond ((and (eq action 'move)
7260 (not (gnus-check-backend-function
7261 'request-move-article gnus-newsgroup-name)))
7262 (error "The current group does not support article moving"))
7263 ((and (eq action 'crosspost)
7264 (not (gnus-check-backend-function
7265 'request-replace-article gnus-newsgroup-name)))
7266 (error "The current group does not support article editing")))
7267 (let ((articles (gnus-summary-work-articles n))
7268 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
7269 (names '((move "Move" "Moving")
7270 (copy "Copy" "Copying")
7271 (crosspost "Crosspost" "Crossposting")))
7272 (copy-buf (save-excursion
7273 (nnheader-set-temp-buffer " *copy article*")))
7274 (default-marks gnus-article-mark-lists)
7275 (no-expire-marks (delete '(expirable . expire)
7276 (copy-sequence gnus-article-mark-lists)))
7277 art-group to-method new-xref article to-groups)
7278 (unless (assq action names)
7279 (error "Unknown action %s" action))
7280 ;; Read the newsgroup name.
7281 (when (and (not to-newsgroup)
7282 (not select-method))
7284 (gnus-read-move-group-name
7285 (cadr (assq action names))
7286 (symbol-value (intern (format "gnus-current-%s-group" action)))
7288 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
7289 (setq to-method (or select-method
7290 (gnus-group-name-to-method to-newsgroup)))
7291 ;; Check the method we are to move this article to...
7292 (unless (gnus-check-backend-function
7293 'request-accept-article (car to-method))
7294 (error "%s does not support article copying" (car to-method)))
7295 (unless (gnus-check-server to-method)
7296 (error "Can't open server %s" (car to-method)))
7297 (gnus-message 6 "%s to %s: %s..."
7298 (caddr (assq action names))
7299 (or (car select-method) to-newsgroup) articles)
7301 (setq article (pop articles))
7305 ;; Move the article.
7307 ;; Remove this article from future suppression.
7308 (gnus-dup-unsuppress-article article)
7309 (gnus-request-move-article
7310 article ; Article to move
7311 gnus-newsgroup-name ; From newsgroup
7312 (nth 1 (gnus-find-method-for-group
7313 gnus-newsgroup-name)) ; Server
7314 (list 'gnus-request-accept-article
7315 to-newsgroup (list 'quote select-method)
7316 (not articles) t) ; Accept form
7317 (not articles))) ; Only save nov last time
7318 ;; Copy the article.
7321 (set-buffer copy-buf)
7322 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
7323 (gnus-request-accept-article
7324 to-newsgroup select-method (not articles) t))))
7325 ;; Crosspost the article.
7326 ((eq action 'crosspost)
7327 (let ((xref (message-tokenize-header
7328 (mail-header-xref (gnus-summary-article-header article))
7330 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
7333 (setq xref (list (system-name))))
7336 (mapconcat 'identity
7337 (delete "Xref:" (delete new-xref xref))
7341 (set-buffer copy-buf)
7342 ;; First put the article in the destination group.
7343 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7344 (when (consp (setq art-group
7345 (gnus-request-accept-article
7346 to-newsgroup select-method (not articles))))
7347 (setq new-xref (concat new-xref " " (car art-group)
7348 ":" (cdr art-group)))
7349 ;; Now we have the new Xrefs header, so we insert
7350 ;; it and replace the new article.
7351 (nnheader-replace-header "Xref" new-xref)
7352 (gnus-request-replace-article
7353 (cdr art-group) to-newsgroup (current-buffer))
7357 (gnus-message 1 "Couldn't %s article %s"
7358 (cadr (assq action names)) article))
7359 ((and (eq art-group 'junk)
7361 (gnus-summary-mark-article article gnus-canceled-mark)
7362 (gnus-message 4 "Deleted article %s" article))
7364 (let* ((pto-group (gnus-group-prefixed-name
7365 (car art-group) to-method))
7367 (gnus-gethash pto-group gnus-newsrc-hashtb))
7368 (info (nth 2 entry))
7369 (to-group (gnus-info-group info))
7371 ;; Update the group that has been moved to.
7373 (memq action '(move copy)))
7374 (unless (member to-group to-groups)
7375 (push to-group to-groups))
7377 (unless (memq article gnus-newsgroup-unreads)
7378 (push 'read to-marks)
7380 info (gnus-add-to-range (gnus-info-read info)
7381 (list (cdr art-group)))))
7383 ;; Copy any marks over to the new group.
7384 (let ((marks (if (gnus-group-auto-expirable-p to-group)
7387 (to-article (cdr art-group)))
7389 ;; See whether the article is to be put in the cache.
7390 (when gnus-use-cache
7391 (gnus-cache-possibly-enter-article
7393 (let ((header (copy-sequence
7394 (gnus-summary-article-header article))))
7395 (mail-header-set-number header to-article)
7397 (memq article gnus-newsgroup-marked)
7398 (memq article gnus-newsgroup-dormant)
7399 (memq article gnus-newsgroup-unreads)))
7401 (when (and (equal to-group gnus-newsgroup-name)
7402 (not (memq article gnus-newsgroup-unreads)))
7403 ;; Mark this article as read in this group.
7404 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7405 (setcdr (gnus-active to-group) to-article)
7406 (setcdr gnus-newsgroup-active to-article))
7409 (when (memq article (symbol-value
7410 (intern (format "gnus-newsgroup-%s"
7412 (push (cdar marks) to-marks)
7413 ;; If the other group is the same as this group,
7414 ;; then we have to add the mark to the list.
7415 (when (equal to-group gnus-newsgroup-name)
7416 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7419 (intern (format "gnus-newsgroup-%s"
7421 ;; Copy the marks to other group.
7422 (gnus-add-marked-articles
7423 to-group (cdar marks) (list to-article) info))
7424 (setq marks (cdr marks)))
7426 (gnus-request-set-mark to-group (list (list (list to-article)
7431 (concat "(gnus-group-set-info '"
7432 (gnus-prin1-to-string (gnus-get-info to-group))
7435 ;; Update the Xref header in this article to point to
7436 ;; the new crossposted article we have just created.
7437 (when (eq action 'crosspost)
7439 (set-buffer copy-buf)
7440 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7441 (nnheader-replace-header "Xref" new-xref)
7442 (gnus-request-replace-article
7443 article gnus-newsgroup-name (current-buffer)))))
7445 ;;;!!!Why is this necessary?
7446 (set-buffer gnus-summary-buffer)
7448 (gnus-summary-goto-subject article)
7449 (when (eq action 'move)
7450 (gnus-summary-mark-article article gnus-canceled-mark))))
7451 (gnus-summary-remove-process-mark article))
7452 ;; Re-activate all groups that have been moved to.
7455 (set-buffer gnus-group-buffer)
7456 (when (gnus-group-goto-group (car to-groups) t)
7457 (gnus-group-get-new-news-this-group 1 t))
7460 (gnus-kill-buffer copy-buf)
7461 (gnus-summary-position-point)
7462 (gnus-set-mode-line 'summary)))
7464 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7465 "Move the current article to a different newsgroup.
7466 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7467 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7468 re-spool using this method."
7470 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7472 (defun gnus-summary-crosspost-article (&optional n)
7473 "Crosspost the current article to some other group."
7475 (gnus-summary-move-article n nil nil 'crosspost))
7477 (defcustom gnus-summary-respool-default-method nil
7478 "Default method for respooling an article.
7479 If nil, use to the current newsgroup method."
7480 :type '(choice (gnus-select-method :value (nnml ""))
7482 :group 'gnus-summary-mail)
7484 (defun gnus-summary-respool-article (&optional n method)
7485 "Respool the current article.
7486 The article will be squeezed through the mail spooling process again,
7487 which means that it will be put in some mail newsgroup or other
7488 depending on `nnmail-split-methods'.
7489 If N is a positive number, respool the N next articles.
7490 If N is a negative number, respool the N previous articles.
7491 If N is nil and any articles have been marked with the process mark,
7492 respool those articles instead.
7494 Respooling can be done both from mail groups and \"real\" newsgroups.
7495 In the former case, the articles in question will be moved from the
7496 current group into whatever groups they are destined to. In the
7497 latter case, they will be copied into the relevant groups."
7499 (list current-prefix-arg
7500 (let* ((methods (gnus-methods-using 'respool))
7502 (symbol-name (or gnus-summary-respool-default-method
7503 (car (gnus-find-method-for-group
7504 gnus-newsgroup-name)))))
7506 (gnus-completing-read
7507 methname "What backend do you want to use when respooling?"
7508 methods nil t nil 'gnus-mail-method-history))
7511 ((zerop (length (setq ms (gnus-servers-using-backend
7513 (list (intern method) ""))
7517 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7518 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7521 (error "No method given for respooling"))
7522 (if (assoc (symbol-name
7523 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7524 (gnus-methods-using 'respool))
7525 (gnus-summary-move-article n nil method)
7526 (gnus-summary-copy-article n nil method)))
7528 (defun gnus-summary-import-article (file)
7529 "Import an arbitrary file into a mail newsgroup."
7530 (interactive "fImport file: ")
7531 (let ((group gnus-newsgroup-name)
7532 (now (current-time))
7534 (unless (gnus-check-backend-function 'request-accept-article group)
7535 (error "%s does not support article importing" group))
7536 (or (file-readable-p file)
7537 (not (file-regular-p file))
7538 (error "Can't read %s" file))
7540 (set-buffer (gnus-get-buffer-create " *import file*"))
7542 (nnheader-insert-file-contents file)
7543 (goto-char (point-min))
7544 (unless (nnheader-article-p)
7545 ;; This doesn't look like an article, so we fudge some headers.
7546 (setq atts (file-attributes file)
7547 lines (count-lines (point-min) (point-max)))
7548 (insert "From: " (read-string "From: ") "\n"
7549 "Subject: " (read-string "Subject: ") "\n"
7550 "Date: " (message-make-date (nth 5 atts))
7552 "Message-ID: " (message-make-message-id) "\n"
7553 "Lines: " (int-to-string lines) "\n"
7554 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7555 (gnus-request-accept-article group nil t)
7556 (kill-buffer (current-buffer)))))
7558 (defun gnus-summary-article-posted-p ()
7559 "Say whether the current (mail) article is available from `gnus-select-method' as well.
7560 This will be the case if the article has both been mailed and posted."
7562 (let ((id (mail-header-references (gnus-summary-article-header)))
7563 (gnus-override-method
7564 (or gnus-refer-article-method gnus-select-method)))
7565 (if (gnus-request-head id "")
7566 (gnus-message 2 "The current message was found on %s"
7567 gnus-override-method)
7568 (gnus-message 2 "The current message couldn't be found on %s"
7569 gnus-override-method)
7572 (defun gnus-summary-expire-articles (&optional now)
7573 "Expire all articles that are marked as expirable in the current group."
7575 (when (gnus-check-backend-function
7576 'request-expire-articles gnus-newsgroup-name)
7577 ;; This backend supports expiry.
7578 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7579 (expirable (if total
7581 ;; We need to update the info for
7582 ;; this group for `gnus-list-of-read-articles'
7583 ;; to give us the right answer.
7584 (gnus-run-hooks 'gnus-exit-group-hook)
7585 (gnus-summary-update-info)
7586 (gnus-list-of-read-articles gnus-newsgroup-name))
7587 (setq gnus-newsgroup-expirable
7588 (sort gnus-newsgroup-expirable '<))))
7589 (expiry-wait (if now 'immediate
7590 (gnus-group-find-parameter
7591 gnus-newsgroup-name 'expiry-wait)))
7594 ;; There are expirable articles in this group, so we run them
7595 ;; through the expiry process.
7596 (gnus-message 6 "Expiring articles...")
7597 (unless (gnus-check-group gnus-newsgroup-name)
7598 (error "Can't open server for %s" gnus-newsgroup-name))
7599 ;; The list of articles that weren't expired is returned.
7602 (let ((nnmail-expiry-wait-function nil)
7603 (nnmail-expiry-wait expiry-wait))
7604 (setq es (gnus-request-expire-articles
7605 expirable gnus-newsgroup-name)))
7606 (setq es (gnus-request-expire-articles
7607 expirable gnus-newsgroup-name))))
7609 (setq gnus-newsgroup-expirable es))
7610 ;; We go through the old list of expirable, and mark all
7611 ;; really expired articles as nonexistent.
7612 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7613 (let ((gnus-use-cache nil))
7615 (unless (memq (car expirable) es)
7616 (when (gnus-data-find (car expirable))
7617 (gnus-summary-mark-article
7618 (car expirable) gnus-canceled-mark)))
7619 (setq expirable (cdr expirable)))))
7620 (gnus-message 6 "Expiring articles...done")))))
7622 (defun gnus-summary-expire-articles-now ()
7623 "Expunge all expirable articles in the current group.
7624 This means that *all* articles that are marked as expirable will be
7625 deleted forever, right now."
7627 (or gnus-expert-user
7629 "Are you really, really, really sure you want to delete all these messages? ")
7631 (gnus-summary-expire-articles t))
7633 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7634 (defun gnus-summary-delete-article (&optional n)
7635 "Delete the N next (mail) articles.
7636 This command actually deletes articles. This is not a marking
7637 command. The article will disappear forever from your life, never to
7639 If N is negative, delete backwards.
7640 If N is nil and articles have been marked with the process mark,
7641 delete these instead."
7643 (unless (gnus-check-backend-function 'request-expire-articles
7644 gnus-newsgroup-name)
7645 (error "The current newsgroup does not support article deletion"))
7646 ;; Compute the list of articles to delete.
7647 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
7649 (if (and gnus-novice-user
7650 (not (gnus-yes-or-no-p
7651 (format "Do you really want to delete %s forever? "
7652 (if (> (length articles) 1)
7653 (format "these %s articles" (length articles))
7656 ;; Delete the articles.
7657 (setq not-deleted (gnus-request-expire-articles
7658 articles gnus-newsgroup-name 'force))
7660 (gnus-summary-remove-process-mark (car articles))
7661 ;; The backend might not have been able to delete the article
7663 (unless (memq (car articles) not-deleted)
7664 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7665 (setq articles (cdr articles)))
7667 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7668 (gnus-summary-position-point)
7669 (gnus-set-mode-line 'summary)
7672 (defun gnus-summary-edit-article (&optional force)
7673 "Edit the current article.
7674 This will have permanent effect only in mail groups.
7675 If FORCE is non-nil, allow editing of articles even in read-only
7679 (set-buffer gnus-summary-buffer)
7680 (let ((mail-parse-charset gnus-newsgroup-charset)
7681 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
7682 (gnus-set-global-variables)
7683 (when (and (not force)
7684 (gnus-group-read-only-p))
7685 (error "The current newsgroup does not support article editing"))
7686 (gnus-summary-show-article t)
7687 (gnus-article-edit-article
7689 `(lambda (no-highlight)
7690 (let ((mail-parse-charset ',gnus-newsgroup-charset)
7691 (mail-parse-ignored-charsets
7692 ',gnus-newsgroup-ignored-charsets))
7693 (gnus-summary-edit-article-done
7694 ,(or (mail-header-references gnus-current-headers) "")
7695 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
7697 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7699 (defun gnus-summary-edit-article-done (&optional references read-only buffer
7701 "Make edits to the current article permanent."
7703 ;; Replace the article.
7704 (let ((buf (current-buffer)))
7706 (insert-buffer-substring buf)
7707 (if (and (not read-only)
7708 (not (gnus-request-replace-article
7709 (cdr gnus-article-current) (car gnus-article-current)
7710 (current-buffer) t)))
7711 (error "Couldn't replace article")
7712 ;; Update the summary buffer.
7714 (equal (message-tokenize-header references " ")
7715 (message-tokenize-header
7716 (or (message-fetch-field "references") "") " ")))
7717 ;; We only have to update this line.
7720 (message-narrow-to-head)
7721 (let ((head (buffer-string))
7724 (insert (format "211 %d Article retrieved.\n"
7725 (cdr gnus-article-current)))
7728 (let ((nntp-server-buffer (current-buffer)))
7729 (setq header (car (gnus-get-newsgroup-headers
7731 (set-buffer gnus-summary-buffer)
7732 gnus-newsgroup-dependencies)
7735 (set-buffer gnus-summary-buffer)
7736 (gnus-data-set-header
7737 (gnus-data-find (cdr gnus-article-current))
7739 (gnus-summary-update-article-line
7740 (cdr gnus-article-current) header))))))
7742 (set-buffer (or buffer gnus-summary-buffer))
7743 (gnus-summary-update-article (cdr gnus-article-current)))
7744 ;; Prettify the article buffer again.
7745 (unless no-highlight
7747 (set-buffer gnus-article-buffer)
7748 ;;;!!! Fix this -- article should be rehighlighted.
7749 ;;;(gnus-run-hooks 'gnus-article-display-hook)
7750 (set-buffer gnus-original-article-buffer)
7751 (gnus-request-article
7752 (cdr gnus-article-current)
7753 (car gnus-article-current) (current-buffer))))
7754 ;; Prettify the summary buffer line.
7755 (when (gnus-visual-p 'summary-highlight 'highlight)
7756 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
7758 (defun gnus-summary-edit-wash (key)
7759 "Perform editing command KEY in the article buffer."
7763 (message "%s" (concat (this-command-keys) "- "))
7766 (gnus-summary-edit-article)
7767 (execute-kbd-macro (concat (this-command-keys) key))
7768 (gnus-article-edit-done))
7772 (defun gnus-summary-respool-query (&optional silent trace)
7773 "Query where the respool algorithm would put this article."
7775 (let (gnus-mark-article-hook)
7776 (gnus-summary-select-article)
7778 (set-buffer gnus-original-article-buffer)
7780 (message-narrow-to-head)
7781 (let ((groups (nnmail-article-group 'identity trace)))
7784 (message "This message would go to %s"
7785 (mapconcat 'car groups ", "))
7786 (message "This message would go to no groups"))
7789 (defun gnus-summary-respool-trace ()
7790 "Trace where the respool algorithm would put this article.
7791 Display a buffer showing all fancy splitting patterns which matched."
7793 (gnus-summary-respool-query nil t))
7795 ;; Summary marking commands.
7797 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
7798 "Mark articles which has the same subject as read, and then select the next.
7799 If UNMARK is positive, remove any kind of mark.
7800 If UNMARK is negative, tick articles."
7803 (setq unmark (prefix-numeric-value unmark)))
7805 (gnus-summary-mark-same-subject
7806 (gnus-summary-article-subject) unmark)))
7807 ;; Select next unread article. If auto-select-same mode, should
7808 ;; select the first unread article.
7809 (gnus-summary-next-article t (and gnus-auto-select-same
7810 (gnus-summary-article-subject)))
7811 (gnus-message 7 "%d article%s marked as %s"
7812 count (if (= count 1) " is" "s are")
7813 (if unmark "unread" "read"))))
7815 (defun gnus-summary-kill-same-subject (&optional unmark)
7816 "Mark articles which has the same subject as read.
7817 If UNMARK is positive, remove any kind of mark.
7818 If UNMARK is negative, tick articles."
7821 (setq unmark (prefix-numeric-value unmark)))
7823 (gnus-summary-mark-same-subject
7824 (gnus-summary-article-subject) unmark)))
7825 ;; If marked as read, go to next unread subject.
7827 ;; Go to next unread subject.
7828 (gnus-summary-next-subject 1 t))
7829 (gnus-message 7 "%d articles are marked as %s"
7830 count (if unmark "unread" "read"))))
7832 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7833 "Mark articles with same SUBJECT as read, and return marked number.
7834 If optional argument UNMARK is positive, remove any kinds of marks.
7835 If optional argument UNMARK is negative, mark articles as unread instead."
7839 ((null unmark) ; Mark as read.
7842 (gnus-summary-mark-article-as-read gnus-killed-mark)
7843 (gnus-summary-show-thread) t)
7844 (gnus-summary-find-subject subject))
7845 (setq count (1+ count))))
7846 ((> unmark 0) ; Tick.
7849 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
7850 (gnus-summary-show-thread) t)
7851 (gnus-summary-find-subject subject))
7852 (setq count (1+ count))))
7853 (t ; Mark as unread.
7856 (gnus-summary-mark-article-as-unread gnus-unread-mark)
7857 (gnus-summary-show-thread) t)
7858 (gnus-summary-find-subject subject))
7859 (setq count (1+ count)))))
7860 (gnus-set-mode-line 'summary)
7861 ;; Return the number of marked articles.
7864 (defun gnus-summary-mark-as-processable (n &optional unmark)
7865 "Set the process mark on the next N articles.
7866 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7867 the process mark instead. The difference between N and the actual
7868 number of articles marked is returned."
7870 (let ((backward (< n 0))
7875 (gnus-summary-remove-process-mark
7876 (gnus-summary-article-number))
7877 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7878 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7881 (gnus-message 7 "No more articles"))
7882 (gnus-summary-recenter)
7883 (gnus-summary-position-point)
7886 (defun gnus-summary-unmark-as-processable (n)
7887 "Remove the process mark from the next N articles.
7888 If N is negative, unmark backward instead. The difference between N and
7889 the actual number of articles unmarked is returned."
7891 (gnus-summary-mark-as-processable n t))
7893 (defun gnus-summary-unmark-all-processable ()
7894 "Remove the process mark from all articles."
7897 (while gnus-newsgroup-processable
7898 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7899 (gnus-summary-position-point))
7901 (defun gnus-summary-mark-as-expirable (n)
7902 "Mark N articles forward as expirable.
7903 If N is negative, mark backward instead. The difference between N and
7904 the actual number of articles marked is returned."
7906 (gnus-summary-mark-forward n gnus-expirable-mark))
7908 (defun gnus-summary-mark-article-as-replied (article)
7909 "Mark ARTICLE replied and update the summary line."
7910 (push article gnus-newsgroup-replied)
7911 (let ((buffer-read-only nil))
7912 (when (gnus-summary-goto-subject article nil t)
7913 (gnus-summary-update-secondary-mark article))))
7915 (defun gnus-summary-set-bookmark (article)
7916 "Set a bookmark in current article."
7917 (interactive (list (gnus-summary-article-number)))
7918 (when (or (not (get-buffer gnus-article-buffer))
7919 (not gnus-current-article)
7920 (not gnus-article-current)
7921 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7922 (error "No current article selected"))
7923 ;; Remove old bookmark, if one exists.
7924 (let ((old (assq article gnus-newsgroup-bookmarks)))
7926 (setq gnus-newsgroup-bookmarks
7927 (delq old gnus-newsgroup-bookmarks))))
7928 ;; Set the new bookmark, which is on the form
7929 ;; (article-number . line-number-in-body).
7933 (set-buffer gnus-article-buffer)
7937 (goto-char (point-min))
7938 (search-forward "\n\n" nil t)
7941 gnus-newsgroup-bookmarks)
7942 (gnus-message 6 "A bookmark has been added to the current article."))
7944 (defun gnus-summary-remove-bookmark (article)
7945 "Remove the bookmark from the current article."
7946 (interactive (list (gnus-summary-article-number)))
7947 ;; Remove old bookmark, if one exists.
7948 (let ((old (assq article gnus-newsgroup-bookmarks)))
7951 (setq gnus-newsgroup-bookmarks
7952 (delq old gnus-newsgroup-bookmarks))
7953 (gnus-message 6 "Removed bookmark."))
7954 (gnus-message 6 "No bookmark in current article."))))
7956 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7957 (defun gnus-summary-mark-as-dormant (n)
7958 "Mark N articles forward as dormant.
7959 If N is negative, mark backward instead. The difference between N and
7960 the actual number of articles marked is returned."
7962 (gnus-summary-mark-forward n gnus-dormant-mark))
7964 (defun gnus-summary-set-process-mark (article)
7965 "Set the process mark on ARTICLE and update the summary line."
7966 (setq gnus-newsgroup-processable
7968 (delq article gnus-newsgroup-processable)))
7969 (when (gnus-summary-goto-subject article)
7970 (gnus-summary-show-thread)
7971 (gnus-summary-goto-subject article)
7972 (gnus-summary-update-secondary-mark article)))
7974 (defun gnus-summary-remove-process-mark (article)
7975 "Remove the process mark from ARTICLE and update the summary line."
7976 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7977 (when (gnus-summary-goto-subject article)
7978 (gnus-summary-show-thread)
7979 (gnus-summary-goto-subject article)
7980 (gnus-summary-update-secondary-mark article)))
7982 (defun gnus-summary-set-saved-mark (article)
7983 "Set the process mark on ARTICLE and update the summary line."
7984 (push article gnus-newsgroup-saved)
7985 (when (gnus-summary-goto-subject article)
7986 (gnus-summary-update-secondary-mark article)))
7988 (defun gnus-summary-mark-forward (n &optional mark no-expire)
7989 "Mark N articles as read forwards.
7990 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
7991 The difference between N and the actual number of articles marked is
7994 (gnus-summary-show-thread)
7995 (let ((backward (< n 0))
7996 (gnus-summary-goto-unread
7997 (and gnus-summary-goto-unread
7998 (not (eq gnus-summary-goto-unread 'never))
7999 (not (memq mark (list gnus-unread-mark
8000 gnus-ticked-mark gnus-dormant-mark)))))
8002 (mark (or mark gnus-del-mark)))
8004 (gnus-summary-mark-article nil mark no-expire)
8005 (zerop (gnus-summary-next-subject
8007 (and gnus-summary-goto-unread
8008 (not (eq gnus-summary-goto-unread 'never)))
8012 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
8013 (gnus-summary-recenter)
8014 (gnus-summary-position-point)
8015 (gnus-set-mode-line 'summary)
8018 (defun gnus-summary-mark-article-as-read (mark)
8019 "Mark the current article quickly as read with MARK."
8020 (let ((article (gnus-summary-article-number)))
8021 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8022 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8023 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8024 (push (cons article mark) gnus-newsgroup-reads)
8025 ;; Possibly remove from cache, if that is used.
8026 (when gnus-use-cache
8027 (gnus-cache-enter-remove-article article))
8028 ;; Allow the backend to change the mark.
8029 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8030 ;; Check for auto-expiry.
8031 (when (and gnus-newsgroup-auto-expire
8032 (memq mark gnus-auto-expirable-marks))
8033 (setq mark gnus-expirable-mark)
8034 ;; Let the backend know about the mark change.
8035 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8036 (push article gnus-newsgroup-expirable))
8037 ;; Set the mark in the buffer.
8038 (gnus-summary-update-mark mark 'unread)
8041 (defun gnus-summary-mark-article-as-unread (mark)
8042 "Mark the current article quickly as unread with MARK."
8043 (let* ((article (gnus-summary-article-number))
8044 (old-mark (gnus-summary-article-mark article)))
8045 ;; Allow the backend to change the mark.
8046 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8047 (if (eq mark old-mark)
8051 (gnus-error 1 "Can't mark negative article numbers")
8053 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8054 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8055 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
8056 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
8057 (cond ((= mark gnus-ticked-mark)
8058 (push article gnus-newsgroup-marked))
8059 ((= mark gnus-dormant-mark)
8060 (push article gnus-newsgroup-dormant))
8062 (push article gnus-newsgroup-unreads)))
8063 (gnus-pull article gnus-newsgroup-reads)
8065 ;; See whether the article is to be put in the cache.
8067 (vectorp (gnus-summary-article-header article))
8069 (gnus-cache-possibly-enter-article
8070 gnus-newsgroup-name article
8071 (gnus-summary-article-header article)
8072 (= mark gnus-ticked-mark)
8073 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8076 (gnus-summary-update-mark mark 'unread)
8079 (defun gnus-summary-mark-article (&optional article mark no-expire)
8080 "Mark ARTICLE with MARK. MARK can be any character.
8081 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
8082 `??' (dormant) and `?E' (expirable).
8083 If MARK is nil, then the default character `?r' is used.
8084 If ARTICLE is nil, then the article on the current line will be
8086 ;; The mark might be a string.
8087 (when (stringp mark)
8088 (setq mark (aref mark 0)))
8089 ;; If no mark is given, then we check auto-expiring.
8091 (setq mark gnus-del-mark))
8092 (when (and (not no-expire)
8093 gnus-newsgroup-auto-expire
8094 (memq mark gnus-auto-expirable-marks))
8095 (setq mark gnus-expirable-mark))
8096 (let ((article (or article (gnus-summary-article-number)))
8097 (old-mark (gnus-summary-article-mark article)))
8098 ;; Allow the backend to change the mark.
8099 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8100 (if (eq mark old-mark)
8103 (error "No article on current line"))
8104 (if (not (if (or (= mark gnus-unread-mark)
8105 (= mark gnus-ticked-mark)
8106 (= mark gnus-dormant-mark))
8107 (gnus-mark-article-as-unread article mark)
8108 (gnus-mark-article-as-read article mark)))
8110 ;; See whether the article is to be put in the cache.
8112 (not (= mark gnus-canceled-mark))
8113 (vectorp (gnus-summary-article-header article))
8115 (gnus-cache-possibly-enter-article
8116 gnus-newsgroup-name article
8117 (gnus-summary-article-header article)
8118 (= mark gnus-ticked-mark)
8119 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8121 (when (gnus-summary-goto-subject article nil t)
8122 (let ((buffer-read-only nil))
8123 (gnus-summary-show-thread)
8125 (gnus-summary-update-mark mark 'unread)
8128 (defun gnus-summary-update-secondary-mark (article)
8129 "Update the secondary (read, process, cache) mark."
8130 (gnus-summary-update-mark
8131 (cond ((memq article gnus-newsgroup-processable)
8133 ((memq article gnus-newsgroup-cached)
8135 ((memq article gnus-newsgroup-replied)
8137 ((memq article gnus-newsgroup-saved)
8139 (t gnus-unread-mark))
8141 (when (gnus-visual-p 'summary-highlight 'highlight)
8142 (gnus-run-hooks 'gnus-summary-update-hook))
8145 (defun gnus-summary-update-mark (mark type)
8146 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
8147 (buffer-read-only nil))
8148 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
8150 (when (looking-at "\r")
8152 (when (<= (+ forward (point)) (point-max))
8153 ;; Go to the right position on the line.
8154 (goto-char (+ forward (point)))
8155 ;; Replace the old mark with the new mark.
8156 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
8157 ;; Optionally update the marks by some user rule.
8158 (when (eq type 'unread)
8160 (gnus-data-find (gnus-summary-article-number)) mark)
8161 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
8163 (defun gnus-mark-article-as-read (article &optional mark)
8164 "Enter ARTICLE in the pertinent lists and remove it from others."
8165 ;; Make the article expirable.
8166 (let ((mark (or mark gnus-del-mark)))
8167 (if (= mark gnus-expirable-mark)
8168 (push article gnus-newsgroup-expirable)
8169 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
8170 ;; Remove from unread and marked lists.
8171 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8172 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8173 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8174 (push (cons article mark) gnus-newsgroup-reads)
8175 ;; Possibly remove from cache, if that is used.
8176 (when gnus-use-cache
8177 (gnus-cache-enter-remove-article article))
8180 (defun gnus-mark-article-as-unread (article &optional mark)
8181 "Enter ARTICLE in the pertinent lists and remove it from others."
8182 (let ((mark (or mark gnus-ticked-mark)))
8185 (gnus-error 1 "Can't mark negative article numbers")
8187 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
8188 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
8189 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
8190 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8192 ;; Unsuppress duplicates?
8193 (when gnus-suppress-duplicates
8194 (gnus-dup-unsuppress-article article))
8196 (cond ((= mark gnus-ticked-mark)
8197 (push article gnus-newsgroup-marked))
8198 ((= mark gnus-dormant-mark)
8199 (push article gnus-newsgroup-dormant))
8201 (push article gnus-newsgroup-unreads)))
8202 (gnus-pull article gnus-newsgroup-reads)
8205 (defalias 'gnus-summary-mark-as-unread-forward
8206 'gnus-summary-tick-article-forward)
8207 (make-obsolete 'gnus-summary-mark-as-unread-forward
8208 'gnus-summary-tick-article-forward)
8209 (defun gnus-summary-tick-article-forward (n)
8210 "Tick N articles forwards.
8211 If N is negative, tick backwards instead.
8212 The difference between N and the number of articles ticked is returned."
8214 (gnus-summary-mark-forward n gnus-ticked-mark))
8216 (defalias 'gnus-summary-mark-as-unread-backward
8217 'gnus-summary-tick-article-backward)
8218 (make-obsolete 'gnus-summary-mark-as-unread-backward
8219 'gnus-summary-tick-article-backward)
8220 (defun gnus-summary-tick-article-backward (n)
8221 "Tick N articles backwards.
8222 The difference between N and the number of articles ticked is returned."
8224 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
8226 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8227 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8228 (defun gnus-summary-tick-article (&optional article clear-mark)
8229 "Mark current article as unread.
8230 Optional 1st argument ARTICLE specifies article number to be marked as unread.
8231 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
8233 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
8236 (defun gnus-summary-mark-as-read-forward (n)
8237 "Mark N articles as read forwards.
8238 If N is negative, mark backwards instead.
8239 The difference between N and the actual number of articles marked is
8242 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
8244 (defun gnus-summary-mark-as-read-backward (n)
8245 "Mark the N articles as read backwards.
8246 The difference between N and the actual number of articles marked is
8249 (gnus-summary-mark-forward
8250 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
8252 (defun gnus-summary-mark-as-read (&optional article mark)
8253 "Mark current article as read.
8254 ARTICLE specifies the article to be marked as read.
8255 MARK specifies a string to be inserted at the beginning of the line."
8256 (gnus-summary-mark-article article mark))
8258 (defun gnus-summary-clear-mark-forward (n)
8259 "Clear marks from N articles forward.
8260 If N is negative, clear backward instead.
8261 The difference between N and the number of marks cleared is returned."
8263 (gnus-summary-mark-forward n gnus-unread-mark))
8265 (defun gnus-summary-clear-mark-backward (n)
8266 "Clear marks from N articles backward.
8267 The difference between N and the number of marks cleared is returned."
8269 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8271 (defun gnus-summary-mark-unread-as-read ()
8272 "Intended to be used by `gnus-summary-mark-article-hook'."
8273 (when (memq gnus-current-article gnus-newsgroup-unreads)
8274 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
8276 (defun gnus-summary-mark-read-and-unread-as-read ()
8277 "Intended to be used by `gnus-summary-mark-article-hook'."
8278 (let ((mark (gnus-summary-article-mark)))
8279 (when (or (gnus-unread-mark-p mark)
8280 (gnus-read-mark-p mark))
8281 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
8283 (defun gnus-summary-mark-region-as-read (point mark all)
8284 "Mark all unread articles between point and mark as read.
8285 If given a prefix, mark all articles between point and mark as read,
8286 even ticked and dormant ones."
8287 (interactive "r\nP")
8296 (memq (setq article (gnus-summary-article-number))
8297 gnus-newsgroup-unreads))
8298 (gnus-summary-mark-article article gnus-del-mark))
8300 (gnus-summary-find-next))))))
8302 (defun gnus-summary-mark-below (score mark)
8303 "Mark articles with score less than SCORE with MARK."
8304 (interactive "P\ncMark: ")
8305 (setq score (if score
8306 (prefix-numeric-value score)
8307 (or gnus-summary-default-score 0)))
8309 (set-buffer gnus-summary-buffer)
8310 (goto-char (point-min))
8313 (and (< (gnus-summary-article-score) score)
8314 (gnus-summary-mark-article nil mark))
8315 (gnus-summary-find-next)))))
8317 (defun gnus-summary-kill-below (&optional score)
8318 "Mark articles with score below SCORE as read."
8320 (gnus-summary-mark-below score gnus-killed-mark))
8322 (defun gnus-summary-clear-above (&optional score)
8323 "Clear all marks from articles with score above SCORE."
8325 (gnus-summary-mark-above score gnus-unread-mark))
8327 (defun gnus-summary-tick-above (&optional score)
8328 "Tick all articles with score above SCORE."
8330 (gnus-summary-mark-above score gnus-ticked-mark))
8332 (defun gnus-summary-mark-above (score mark)
8333 "Mark articles with score over SCORE with MARK."
8334 (interactive "P\ncMark: ")
8335 (setq score (if score
8336 (prefix-numeric-value score)
8337 (or gnus-summary-default-score 0)))
8339 (set-buffer gnus-summary-buffer)
8340 (goto-char (point-min))
8342 (when (> (gnus-summary-article-score) score)
8343 (gnus-summary-mark-article nil mark))
8345 (gnus-summary-find-next)))))
8347 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8348 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
8349 (defun gnus-summary-limit-include-expunged (&optional no-error)
8350 "Display all the hidden articles that were expunged for low scores."
8352 (let ((buffer-read-only nil))
8353 (let ((scored gnus-newsgroup-scored)
8356 (unless (gnus-summary-goto-subject (caar scored))
8357 (and (setq h (gnus-summary-article-header (caar scored)))
8358 (< (cdar scored) gnus-summary-expunge-below)
8360 (setq scored (cdr scored)))
8362 (when (not no-error)
8363 (error "No expunged articles hidden"))
8364 (goto-char (point-min))
8365 (gnus-summary-prepare-unthreaded (nreverse headers))
8366 (goto-char (point-min))
8367 (gnus-summary-position-point)
8370 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
8371 "Mark all unread articles in this newsgroup as read.
8372 If prefix argument ALL is non-nil, ticked and dormant articles will
8373 also be marked as read.
8374 If QUIETLY is non-nil, no questions will be asked.
8375 If TO-HERE is non-nil, it should be a point in the buffer. All
8376 articles before this point will be marked as read.
8377 Note that this function will only catch up the unread article
8378 in the current summary buffer limitation.
8379 The number of articles marked as read is returned."
8384 (not gnus-interactive-catchup) ;Without confirmation?
8388 "Mark absolutely all articles as read? "
8389 "Mark all unread articles as read? ")))
8391 (not gnus-newsgroup-adaptive)
8392 (not gnus-newsgroup-auto-expire)
8393 (not gnus-suppress-duplicates)
8394 (or (not gnus-use-cache)
8395 (eq gnus-use-cache 'passive)))
8398 (setq gnus-newsgroup-marked nil
8399 gnus-newsgroup-dormant nil))
8400 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8401 ;; We actually mark all articles as canceled, which we
8402 ;; have to do when using auto-expiry or adaptive scoring.
8403 (gnus-summary-show-all-threads)
8404 (when (gnus-summary-first-subject (not all) t)
8406 (if to-here (< (point) to-here) t)
8407 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8408 (gnus-summary-find-next (not all) nil nil t))))
8409 (gnus-set-mode-line 'summary))
8411 (gnus-summary-position-point)))
8413 (defun gnus-summary-catchup-to-here (&optional all)
8414 "Mark all unticked articles before the current one as read.
8415 If ALL is non-nil, also mark ticked and dormant articles as read."
8418 (gnus-save-hidden-threads
8419 (let ((beg (point)))
8420 ;; We check that there are unread articles.
8421 (when (or all (gnus-summary-find-prev))
8422 (gnus-summary-catchup all t beg)))))
8423 (gnus-summary-position-point))
8425 (defun gnus-summary-catchup-all (&optional quietly)
8426 "Mark all articles in this newsgroup as read."
8428 (gnus-summary-catchup t quietly))
8430 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8431 "Mark all unread articles in this group as read, then exit.
8432 If prefix argument ALL is non-nil, all articles are marked as read."
8434 (when (gnus-summary-catchup all quietly nil 'fast)
8435 ;; Select next newsgroup or exit.
8436 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
8437 (eq gnus-auto-select-next 'quietly))
8438 (gnus-summary-next-group nil)
8439 (gnus-summary-exit))))
8441 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8442 "Mark all articles in this newsgroup as read, and then exit."
8444 (gnus-summary-catchup-and-exit t quietly))
8446 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
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-article t nil nil t))
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 'gnus-summary-save-in-rmail))
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 to-newsgroup nil nil
9006 (gnus-group-name-to-method
9008 (error "Couldn't create group %s" to-newsgroup)))
9009 (error "No such group: %s" to-newsgroup)))
9012 (defun gnus-summary-save-parts (type dir n reverse)
9013 "Save parts matching TYPE to DIR.
9014 If REVERSE, save parts that do not match TYPE."
9016 (list (read-string "Save parts of type: " "image/.*")
9017 (read-file-name "Save to directory: " t nil t)
9018 current-prefix-arg))
9019 (gnus-summary-iterate n
9020 (let ((gnus-display-mime-function nil)
9021 (gnus-inhibit-treatment t))
9022 (gnus-summary-select-article))
9024 (set-buffer gnus-article-buffer)
9025 (let ((handles (or (mm-dissect-buffer) (mm-uu-dissect))))
9027 (gnus-summary-save-parts-1 type dir handles reverse)
9028 (mm-destroy-parts handles))))))
9030 (defun gnus-summary-save-parts-1 (type dir handle reverse)
9031 (if (stringp (car handle))
9032 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
9035 (not (string-match type (mm-handle-media-type handle)))
9036 (string-match type (mm-handle-media-type handle)))
9037 (let ((file (expand-file-name
9038 (file-name-nondirectory
9040 (mail-content-type-get
9041 (mm-handle-disposition handle) 'filename)
9042 (concat gnus-newsgroup-name "." gnus-current-article)))
9044 (unless (file-exists-p file)
9045 (mm-save-part-to-file handle file))))))
9047 ;; Summary extract commands
9049 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
9050 (let ((buffer-read-only nil)
9051 (article (gnus-summary-article-number))
9053 (unless (gnus-summary-goto-subject article)
9054 (error "No such article: %d" article))
9055 (gnus-summary-position-point)
9056 ;; If all commands are to be bunched up on one line, we collect
9058 (unless gnus-view-pseudos-separately
9059 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
9062 (setq action (cdr (assq 'action (car ps))))
9063 (setq files (list (cdr (assq 'name (car ps)))))
9064 (while (and ps (cdr ps)
9065 (string= (or action "1")
9066 (or (cdr (assq 'action (cadr ps))) "2")))
9067 (push (cdr (assq 'name (cadr ps))) files)
9068 (setcdr ps (cddr ps)))
9070 (when (not (string-match "%s" action))
9073 (when (assq 'execute (car ps))
9074 (setcdr (assq 'execute (car ps))
9075 (funcall (if (string-match "%s" action)
9082 (gnus-quote-arg-for-sh-or-csh f)))
9084 (setq ps (cdr ps)))))
9085 (if (and gnus-view-pseudos (not not-view))
9087 (when (assq 'execute (car pslist))
9088 (gnus-execute-command (cdr (assq 'execute (car pslist)))
9089 (eq gnus-view-pseudos 'not-confirm)))
9090 (setq pslist (cdr pslist)))
9093 (setq after-article (or (cdr (assq 'article (car pslist)))
9094 (gnus-summary-article-number)))
9095 (gnus-summary-goto-subject after-article)
9098 (insert " " (file-name-nondirectory
9099 (cdr (assq 'name (car pslist))))
9100 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
9102 (forward-line -1) ; back to `b'
9103 (gnus-add-text-properties
9104 b (1- e) (list 'gnus-number gnus-reffed-article-number
9105 gnus-mouse-face-prop gnus-mouse-face))
9107 after-article gnus-reffed-article-number
9108 gnus-unread-mark b (car pslist) 0 (- e b))
9109 (push gnus-reffed-article-number gnus-newsgroup-unreads)
9110 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
9111 (setq pslist (cdr pslist)))))))
9113 (defun gnus-pseudos< (p1 p2)
9114 (let ((c1 (cdr (assq 'action p1)))
9115 (c2 (cdr (assq 'action p2))))
9116 (and c1 c2 (string< c1 c2))))
9118 (defun gnus-request-pseudo-article (props)
9119 (cond ((assq 'execute props)
9120 (gnus-execute-command (cdr (assq 'execute props)))))
9121 (let ((gnus-current-article (gnus-summary-article-number)))
9122 (gnus-run-hooks 'gnus-mark-article-hook)))
9124 (defun gnus-execute-command (command &optional automatic)
9126 (gnus-article-setup-buffer)
9127 (set-buffer gnus-article-buffer)
9128 (setq buffer-read-only nil)
9129 (let ((command (if automatic command
9130 (read-string "Command: " (cons command 0)))))
9132 (insert "$ " command "\n\n")
9133 (if gnus-view-pseudo-asynchronously
9134 (start-process "gnus-execute" (current-buffer) shell-file-name
9135 shell-command-switch command)
9136 (call-process shell-file-name nil t nil
9137 shell-command-switch command)))))
9139 ;; Summary kill commands.
9141 (defun gnus-summary-edit-global-kill (article)
9142 "Edit the \"global\" kill file."
9143 (interactive (list (gnus-summary-article-number)))
9144 (gnus-group-edit-global-kill article))
9146 (defun gnus-summary-edit-local-kill ()
9147 "Edit a local kill file applied to the current newsgroup."
9149 (setq gnus-current-headers (gnus-summary-article-header))
9150 (gnus-group-edit-local-kill
9151 (gnus-summary-article-number) gnus-newsgroup-name))
9155 (defun gnus-read-header (id &optional header)
9156 "Read the headers of article ID and enter them into the Gnus system."
9157 (let ((group gnus-newsgroup-name)
9158 (gnus-override-method
9159 (and (gnus-news-group-p gnus-newsgroup-name)
9160 gnus-refer-article-method))
9162 ;; First we check to see whether the header in question is already
9165 ;; This is a Message-ID.
9166 (setq header (or header (gnus-id-to-header id)))
9167 ;; This is an article number.
9168 (setq header (or header (gnus-summary-article-header id))))
9170 (not (gnus-summary-article-sparse-p (mail-header-number header))))
9171 ;; We have found the header.
9173 ;; If this is a sparse article, we have to nix out its
9174 ;; previous entry in the thread hashtb.
9176 (gnus-summary-article-sparse-p (mail-header-number header)))
9177 (let* ((parent (gnus-parent-id (mail-header-references header)))
9178 (thread (and parent (gnus-id-to-thread parent))))
9180 (delq (assq header thread) thread))))
9181 ;; We have to really fetch the header to this article.
9183 (set-buffer nntp-server-buffer)
9184 (when (setq where (gnus-request-head id group))
9185 (nnheader-fold-continuation-lines)
9186 (goto-char (point-max))
9188 (goto-char (point-min))
9192 ((cdr where) (cdr where))
9193 (header (mail-header-number header))
9194 (t gnus-reffed-article-number))
9196 (insert " Article retrieved.\n"))
9198 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
9199 () ; Malformed head.
9200 (unless (gnus-summary-article-sparse-p (mail-header-number header))
9201 (when (and (stringp id)
9202 (not (string= (gnus-group-real-name group)
9204 ;; If we fetched by Message-ID and the article came
9205 ;; from a different group, we fudge some bogus article
9206 ;; numbers for this article.
9207 (mail-header-set-number header gnus-reffed-article-number))
9209 (set-buffer gnus-summary-buffer)
9210 (decf gnus-reffed-article-number)
9211 (gnus-remove-header (mail-header-number header))
9212 (push header gnus-newsgroup-headers)
9213 (setq gnus-current-headers header)
9214 (push (mail-header-number header) gnus-newsgroup-limit)))
9217 (defun gnus-remove-header (number)
9218 "Remove header NUMBER from `gnus-newsgroup-headers'."
9219 (if (and gnus-newsgroup-headers
9220 (= number (mail-header-number (car gnus-newsgroup-headers))))
9221 (pop gnus-newsgroup-headers)
9222 (let ((headers gnus-newsgroup-headers))
9223 (while (and (cdr headers)
9224 (not (= number (mail-header-number (cadr headers)))))
9227 (setcdr headers (cddr headers))))))
9230 ;;; summary highlights
9233 (defun gnus-highlight-selected-summary ()
9234 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
9235 ;; Highlight selected article in summary buffer
9236 (when gnus-summary-selected-face
9238 (let* ((beg (progn (beginning-of-line) (point)))
9239 (end (progn (end-of-line) (point)))
9240 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
9241 (from (if (get-text-property beg gnus-mouse-face-prop)
9243 (or (next-single-property-change
9244 beg gnus-mouse-face-prop nil end)
9249 (or (next-single-property-change
9250 from gnus-mouse-face-prop nil end)
9252 ;; If no mouse-face prop on line we will have to = from = end,
9253 ;; so we highlight the entire line instead.
9254 (when (= (+ to 2) from)
9257 (if gnus-newsgroup-selected-overlay
9258 ;; Move old overlay.
9260 gnus-newsgroup-selected-overlay from to (current-buffer))
9261 ;; Create new overlay.
9263 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
9264 'face gnus-summary-selected-face))))))
9266 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
9267 (defun gnus-summary-highlight-line ()
9268 "Highlight current line according to `gnus-summary-highlight'."
9269 (let* ((list gnus-summary-highlight)
9271 (end (progn (end-of-line) (point)))
9272 ;; now find out where the line starts and leave point there.
9273 (beg (progn (beginning-of-line) (point)))
9274 (article (gnus-summary-article-number))
9275 (score (or (cdr (assq (or article gnus-current-article)
9276 gnus-newsgroup-scored))
9277 gnus-summary-default-score 0))
9278 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
9279 (inhibit-read-only t))
9280 ;; Eval the cars of the lists until we find a match.
9281 (let ((default gnus-summary-default-score))
9283 (not (eval (caar list))))
9284 (setq list (cdr list))))
9285 (let ((face (cdar list)))
9286 (unless (eq face (get-text-property beg 'face))
9287 (gnus-put-text-property-excluding-characters-with-faces
9289 (setq face (if (boundp face) (symbol-value face) face)))
9290 (when gnus-summary-highlight-line-function
9291 (funcall gnus-summary-highlight-line-function article face))))
9294 (defun gnus-update-read-articles (group unread &optional compute)
9295 "Update the list of read articles in GROUP."
9296 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
9297 (entry (gnus-gethash group gnus-newsrc-hashtb))
9298 (info (nth 2 entry))
9300 (unread (sort (copy-sequence unread) '<))
9302 (if (or (not info) (not active))
9303 ;; There is no info on this group if it was, in fact,
9304 ;; killed. Gnus stores no information on killed groups, so
9305 ;; there's nothing to be done.
9306 ;; One could store the information somewhere temporarily,
9307 ;; perhaps... Hmmm...
9309 ;; Remove any negative articles numbers.
9310 (while (and unread (< (car unread) 0))
9311 (setq unread (cdr unread)))
9312 ;; Remove any expired article numbers
9313 (while (and unread (< (car unread) (car active)))
9314 (setq unread (cdr unread)))
9315 ;; Compute the ranges of read articles by looking at the list of
9318 (when (/= (car unread) prev)
9319 (push (if (= prev (1- (car unread))) prev
9320 (cons prev (1- (car unread))))
9322 (setq prev (1+ (car unread)))
9323 (setq unread (cdr unread)))
9324 (when (<= prev (cdr active))
9325 (push (cons prev (cdr active)) read))
9326 (setq read (if (> (length read) 1) (nreverse read) read))
9330 (set-buffer gnus-group-buffer)
9333 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
9334 (gnus-info-set-read ',info ',(gnus-info-read info))
9335 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
9336 (gnus-group-update-group ,group t))))
9337 ;; Propagate the read marks to the backend.
9338 (if (gnus-check-backend-function 'request-set-mark group)
9339 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
9340 (add (gnus-remove-from-range read (gnus-info-read info))))
9342 (unless (gnus-check-group group)
9343 (error "Can't open server for %s" group))
9344 (gnus-request-set-mark
9345 group (delq nil (list (if add (list add 'add '(read)))
9346 (if del (list del 'del '(read)))))))))
9347 ;; Enter this list into the group info.
9348 (gnus-info-set-read info read)
9349 ;; Set the number of unread articles in gnus-newsrc-hashtb.
9350 (gnus-get-unread-articles-in-group info (gnus-active group))
9353 (defun gnus-offer-save-summaries ()
9354 "Offer to save all active summary buffers."
9356 (let ((buflist (buffer-list))
9358 ;; Go through all buffers and find all summaries.
9360 (and (setq bufname (buffer-name (car buflist)))
9361 (string-match "Summary" bufname)
9363 (set-buffer bufname)
9364 ;; We check that this is, indeed, a summary buffer.
9365 (and (eq major-mode 'gnus-summary-mode)
9366 ;; Also make sure this isn't bogus.
9367 gnus-newsgroup-prepared
9368 ;; Also make sure that this isn't a dead summary buffer.
9369 (not gnus-dead-summary-mode)))
9370 (push bufname buffers))
9371 (setq buflist (cdr buflist)))
9372 ;; Go through all these summary buffers and offer to save them.
9375 "Update summary buffer %s? "
9377 (switch-to-buffer buf)
9378 (gnus-summary-exit))
9382 ;;; @ for mime-partial
9385 (defun gnus-request-partial-message ()
9387 (let ((number (gnus-summary-article-number))
9388 (group gnus-newsgroup-name)
9389 (mother gnus-article-buffer))
9390 (set-buffer (get-buffer-create " *Partial Article*"))
9392 (setq mime-preview-buffer mother)
9393 (gnus-request-article-this-buffer number group)
9397 (autoload 'mime-combine-message/partial-pieces-automatically
9399 "Internal method to combine message/partial messages automatically.")
9402 'action '((type . message)(subtype . partial)
9403 (major-mode . gnus-original-article-mode)
9404 (method . mime-combine-message/partial-pieces-automatically)
9405 (summary-buffer-exp . gnus-summary-buffer)
9406 (request-partial-message-method . gnus-request-partial-message)
9410 ;;; @ for message/rfc822
9413 (defun gnus-mime-extract-message/rfc822 (entity situation)
9414 (let (group article num cwin swin cur)
9415 (with-current-buffer (mime-entity-buffer entity)
9417 (narrow-to-region (mime-entity-body-start entity)
9418 (mime-entity-body-end entity))
9419 (setq group (or (cdr (assq 'group situation))
9420 (completing-read "Group: "
9423 (gnus-read-active-file-p)
9424 gnus-newsgroup-name))
9425 article (gnus-request-accept-article group)
9428 (when (and (consp article)
9429 (numberp (setq article (cdr article))))
9430 (setq num (1+ (or (cdr (assq 'number situation)) 0))
9431 cwin (get-buffer-window (current-buffer) t)
9433 (save-window-excursion
9434 (if (setq swin (get-buffer-window gnus-summary-buffer t))
9435 (select-window swin)
9436 (set-buffer gnus-summary-buffer)
9438 (setq cur gnus-current-article)
9440 (let (gnus-show-threads)
9441 (gnus-summary-goto-subject article t)
9443 (gnus-summary-clear-mark-forward 1)
9444 (gnus-summary-goto-subject cur)
9446 (when (and cwin (window-frame cwin))
9447 (select-frame (window-frame cwin))
9449 (when (boundp 'mime-acting-situation-to-override)
9450 (set-alist 'mime-acting-situation-to-override
9453 (set-alist 'mime-acting-situation-to-override
9456 (save-current-buffer
9457 (set-buffer gnus-group-buffer)
9458 (gnus-activate-group ,group)
9460 (gnus-summary-goto-article ,cur
9461 gnus-show-all-headers)
9463 (set-alist 'mime-acting-situation-to-override
9469 'action '((type . message)(subtype . rfc822)
9470 (major-mode . gnus-original-article-mode)
9471 (method . gnus-mime-extract-message/rfc822)
9476 'action '((type . message)(subtype . news)
9477 (major-mode . gnus-original-article-mode)
9478 (method . gnus-mime-extract-message/rfc822)
9482 (defun gnus-mime-extract-multipart (entity situation)
9483 (let ((children (mime-entity-children entity))
9484 mime-acting-situation-to-override
9487 (mime-play-entity (car children)
9488 (cons (assq 'mode situation)
9489 mime-acting-situation-to-override))
9490 (setq children (cdr children)))
9491 (if (setq f (cdr (assq 'after-method
9492 mime-acting-situation-to-override)))
9497 'action '((type . multipart)
9498 (method . gnus-mime-extract-multipart)
9507 (defun gnus-summary-setup-default-charset ()
9508 "Setup newsgroup default charset."
9509 (if (equal gnus-newsgroup-name "nndraft:drafts")
9510 (setq gnus-newsgroup-charset nil)
9511 (let* ((name (and gnus-newsgroup-name
9512 (gnus-group-real-name gnus-newsgroup-name)))
9514 (or gnus-newsgroup-ephemeral-ignored-charsets
9516 (and gnus-newsgroup-name
9517 (or (gnus-group-find-parameter gnus-newsgroup-name
9518 'ignored-charsets t)
9519 (let ((alist gnus-group-ignored-charsets-alist)
9520 elem (charsets nil))
9521 (while (setq elem (pop alist))
9523 (string-match (car elem) name))
9525 charsets (cdr elem))))
9527 gnus-newsgroup-ignored-charsets)))
9528 (setq gnus-newsgroup-charset
9529 (or gnus-newsgroup-ephemeral-charset
9530 (and gnus-newsgroup-name
9531 (or (gnus-group-find-parameter gnus-newsgroup-name
9533 (let ((alist gnus-group-charset-alist)
9535 (while (setq elem (pop alist))
9537 (string-match (car elem) name))
9539 charset (cadr elem))))
9541 gnus-default-charset))
9542 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
9543 ignored-charsets))))
9549 (defun gnus-summary-display-buttonized (&optional show-all-parts)
9550 "Display the current article buffer fully MIME-buttonized.
9551 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
9552 treated as multipart/mixed."
9555 (let ((gnus-unbuttonized-mime-types nil)
9556 (gnus-mime-display-multipart-as-mixed show-all-parts))
9557 (gnus-summary-show-article)))
9559 (defun gnus-summary-repair-multipart (article)
9560 "Add a Content-Type header to a multipart article without one."
9561 (interactive (list (gnus-summary-article-number)))
9562 (gnus-with-article article
9563 (message-narrow-to-head)
9564 (goto-char (point-max))
9566 (when (search-forward "\n--" nil t)
9567 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
9568 (message-narrow-to-head)
9569 (message-remove-header "Mime-Version")
9570 (message-remove-header "Content-Type")
9571 (goto-char (point-max))
9572 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
9574 (insert "Mime-Version: 1.0\n")
9576 (let (gnus-mark-article-hook)
9577 (gnus-summary-select-article t t nil article)))
9579 (defun gnus-summary-toggle-display-buttonized ()
9580 "Toggle the buttonizing of the article buffer."
9583 (if (setq gnus-inhibit-mime-unbuttonizing
9584 (not gnus-inhibit-mime-unbuttonizing))
9585 (let ((gnus-unbuttonized-mime-types nil))
9586 (gnus-summary-show-article))
9587 (gnus-summary-show-article)))
9590 ;;; Intelli-mouse commmands
9593 (defun gnus-wheel-summary-scroll (event)
9595 (let ((amount (if (memq 'shift (event-modifiers event))
9596 (car gnus-wheel-scroll-amount)
9597 (cdr gnus-wheel-scroll-amount)))
9598 (direction (- (* (static-if (featurep 'xemacs)
9599 (event-button event)
9600 (cond ((eq 'mouse-4 (event-basic-type event))
9602 ((eq 'mouse-5 (event-basic-type event))
9606 (gnus-summary-scroll-up (* amount direction))
9607 (when (gnus-eval-in-buffer-window gnus-article-buffer
9610 (and (if (< 0 direction)
9611 (gnus-article-next-page 0)
9612 (gnus-article-prev-page 0)
9614 (if (setq edge (get-text-property
9615 (point-min) 'gnus-wheel-edge))
9616 (setq edge (* edge direction))
9619 (let ((buffer-read-only nil)
9620 (inhibit-read-only t))
9621 (put-text-property (point-min) (point-max)
9622 'gnus-wheel-edge direction)
9624 (or (> edge gnus-wheel-edge-resistance)
9625 (let ((buffer-read-only nil)
9626 (inhibit-read-only t))
9627 (put-text-property (point-min) (point-max)
9629 (* (1+ edge) direction))
9631 (eq last-command 'gnus-wheel-summary-scroll))
9633 (gnus-summary-next-article nil nil (minusp direction)))
9636 (defun gnus-wheel-install ()
9637 "Enable mouse wheel support on summary window."
9638 (when gnus-use-wheel
9640 '([(mouse-4)] [(shift mouse-4)] [(mouse-5)] [(shift mouse-5)])))
9642 (define-key gnus-summary-mode-map key
9643 'gnus-wheel-summary-scroll)))))
9645 (add-hook 'gnus-summary-mode-hook 'gnus-wheel-install)
9651 (defmacro gnus-with-article (article &rest forms)
9652 "Select ARTICLE and perform FORMS in the original article buffer.
9653 Then replace the article with the result."
9655 ;; We don't want the article to be marked as read.
9656 (let (gnus-mark-article-hook)
9657 (gnus-summary-select-article t t nil ,article))
9658 (set-buffer gnus-original-article-buffer)
9660 (if (not (gnus-check-backend-function
9661 'request-replace-article (car gnus-article-current)))
9662 (gnus-message 5 "Read-only group; not replacing")
9663 (unless (gnus-request-replace-article
9664 ,article (car gnus-article-current)
9666 (error "Couldn't replace article")))
9667 ;; The cache and backlog have to be flushed somewhat.
9668 (when gnus-keep-backlog
9669 (gnus-backlog-remove-article
9670 (car gnus-article-current) (cdr gnus-article-current)))
9671 (when gnus-use-cache
9672 (gnus-cache-update-article
9673 (car gnus-article-current) (cdr gnus-article-current)))))
9675 (put 'gnus-with-article 'lisp-indent-function 1)
9676 (put 'gnus-with-article 'edebug-form-spec '(form body))
9679 ;;; Generic summary marking commands
9682 (defvar gnus-summary-marking-alist
9683 '((read gnus-del-mark "d")
9684 (unread gnus-unread-mark "u")
9685 (ticked gnus-ticked-mark "!")
9686 (dormant gnus-dormant-mark "?")
9687 (expirable gnus-expirable-mark "e"))
9688 "An alist of names/marks/keystrokes.")
9690 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
9691 (defvar gnus-summary-mark-map)
9693 (defun gnus-summary-make-all-marking-commands ()
9694 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
9695 (dolist (elem gnus-summary-marking-alist)
9696 (apply 'gnus-summary-make-marking-command elem)))
9698 (defun gnus-summary-make-marking-command (name mark keystroke)
9699 (let ((map (make-sparse-keymap)))
9700 (define-key gnus-summary-generic-mark-map keystroke map)
9701 (dolist (lway `((next "next" next nil "n")
9702 (next-unread "next unread" next t "N")
9703 (prev "previous" prev nil "p")
9704 (prev-unread "previous unread" prev t "P")
9705 (nomove "" nil nil ,keystroke)))
9706 (let ((func (gnus-summary-make-marking-command-1
9707 mark (car lway) lway name)))
9708 (setq func (eval func))
9709 (define-key map (nth 4 lway) func)))))
9711 (defun gnus-summary-make-marking-command-1 (mark way lway name)
9713 (format "gnus-summary-put-mark-as-%s%s"
9714 name (if (eq way 'nomove)
9716 (concat "-" (symbol-name way)))))
9719 "Mark the current article as %s%s.
9720 If N, the prefix, then repeat N times.
9721 If N is negative, move in reverse order.
9722 The difference between N and the actual number of articles marked is
9726 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
9728 (defun gnus-summary-generic-mark (n mark move unread)
9729 "Mark N articles with MARK."
9730 (unless (eq major-mode 'gnus-summary-mode)
9731 (error "This command can only be used in the summary buffer"))
9732 (gnus-summary-show-thread)
9736 ((eq move 'prev) -1)
9742 nummove (* -1 nummove))))
9744 (gnus-summary-mark-article nil mark)
9745 (zerop (gnus-summary-next-subject nummove unread t)))
9748 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9749 (gnus-summary-recenter)
9750 (gnus-summary-position-point)
9751 (gnus-set-mode-line 'summary)
9754 (gnus-summary-make-all-marking-commands)
9760 (run-hooks 'gnus-sum-load-hook)
9762 ;;; gnus-sum.el ends here