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))
43 ;; Avoid byte-compile warnings.
44 (defvar gnus-article-decoded-p)
45 (defvar gnus-decode-encoded-word-function)
49 (autoload 'gnus-cache-articles-in-group "gnus-cache"))
51 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
52 (autoload 'gnus-set-summary-default-charset "gnus-i18n" nil t)
54 (defcustom gnus-kill-summary-on-exit t
55 "*If non-nil, kill the summary buffer when you exit from it.
56 If nil, the summary will become a \"*Dead Summary*\" buffer, and
57 it will be killed sometime later."
58 :group 'gnus-summary-exit
61 (defcustom gnus-fetch-old-headers nil
62 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
63 If an unread article in the group refers to an older, already read (or
64 just marked as read) article, the old article will not normally be
65 displayed in the Summary buffer. If this variable is non-nil, Gnus
66 will attempt to grab the headers to the old articles, and thereby
67 build complete threads. If it has the value `some', only enough
68 headers to connect otherwise loose threads will be displayed. This
69 variable can also be a number. In that case, no more than that number
70 of old headers will be fetched. If it has the value `invisible', all
71 old headers will be fetched, but none will be displayed.
73 The server has to support NOV for any of this to work."
75 :type '(choice (const :tag "off" nil)
78 (sexp :menu-tag "other" t)))
80 (defcustom gnus-refer-thread-limit 200
81 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
82 If t, fetch all the available old headers."
85 (sexp :menu-tag "other" t)))
87 (defcustom gnus-summary-make-false-root 'adopt
88 "*nil means that Gnus won't gather loose threads.
89 If the root of a thread has expired or been read in a previous
90 session, the information necessary to build a complete thread has been
91 lost. Instead of having many small sub-threads from this original thread
92 scattered all over the summary buffer, Gnus can gather them.
94 If non-nil, Gnus will try to gather all loose sub-threads from an
95 original thread into one large thread.
97 If this variable is non-nil, it should be one of `none', `adopt',
100 If this variable is `none', Gnus will not make a false root, but just
101 present the sub-threads after another.
102 If this variable is `dummy', Gnus will create a dummy root that will
103 have all the sub-threads as children.
104 If this variable is `adopt', Gnus will make one of the \"children\"
105 the parent and mark all the step-children as such.
106 If this variable is `empty', the \"children\" are printed with empty
107 subject fields. (Or rather, they will be printed with a string
108 given by the `gnus-summary-same-subject' variable.)"
110 :type '(choice (const :tag "off" nil)
116 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
117 "*A regexp to match subjects to be excluded from loose thread gathering.
118 As loose thread gathering is done on subjects only, that means that
119 there can be many false gatherings performed. By rooting out certain
120 common subjects, gathering might become saner."
124 (defcustom gnus-summary-gather-subject-limit nil
125 "*Maximum length of subject comparisons when gathering loose threads.
126 Use nil to compare full subjects. Setting this variable to a low
127 number will help gather threads that have been corrupted by
128 newsreaders chopping off subject lines, but it might also mean that
129 unrelated articles that have subject that happen to begin with the
130 same few characters will be incorrectly gathered.
132 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
135 :type '(choice (const :tag "off" nil)
137 (sexp :menu-tag "on" t)))
139 (defcustom gnus-simplify-subject-functions nil
140 "List of functions taking a string argument that simplify subjects.
141 The functions are applied recursively.
143 Useful functions to put in this list include: `gnus-simplify-subject-re',
144 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
146 :type '(repeat function))
148 (defcustom gnus-simplify-ignored-prefixes nil
149 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
151 :type '(choice (const :tag "off" nil)
154 (defcustom gnus-build-sparse-threads nil
155 "*If non-nil, fill in the gaps in threads.
156 If `some', only fill in the gaps that are needed to tie loose threads
157 together. If `more', fill in all leaf nodes that Gnus can find. If
158 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
160 :type '(choice (const :tag "off" nil)
163 (sexp :menu-tag "all" t)))
165 (defcustom gnus-summary-thread-gathering-function
166 'gnus-gather-threads-by-subject
167 "*Function used for gathering loose threads.
168 There are two pre-defined functions: `gnus-gather-threads-by-subject',
169 which only takes Subjects into consideration; and
170 `gnus-gather-threads-by-references', which compared the References
171 headers of the articles to find matches."
173 :type '(radio (function-item gnus-gather-threads-by-subject)
174 (function-item gnus-gather-threads-by-references)
175 (function :tag "other")))
177 (defcustom gnus-summary-same-subject ""
178 "*String indicating that the current article has the same subject as the previous.
179 This variable will only be used if the value of
180 `gnus-summary-make-false-root' is `empty'."
181 :group 'gnus-summary-format
184 (defcustom gnus-summary-goto-unread t
185 "*If t, marking commands will go to the next unread article.
186 If `never', commands that usually go to the next unread article, will
187 go to the next article, whether it is read or not.
188 If nil, only the marking commands will go to the next (un)read article."
189 :group 'gnus-summary-marks
190 :link '(custom-manual "(gnus)Setting Marks")
191 :type '(choice (const :tag "off" nil)
193 (sexp :menu-tag "on" t)))
195 (defcustom gnus-summary-default-score 0
196 "*Default article score level.
197 All scores generated by the score files will be added to this score.
198 If this variable is nil, scoring will be disabled."
199 :group 'gnus-score-default
200 :type '(choice (const :tag "disable")
203 (defcustom gnus-summary-zcore-fuzz 0
204 "*Fuzziness factor for the zcore in the summary buffer.
205 Articles with scores closer than this to `gnus-summary-default-score'
207 :group 'gnus-summary-format
210 (defcustom gnus-simplify-subject-fuzzy-regexp nil
211 "*Strings to be removed when doing fuzzy matches.
212 This can either be a regular expression or list of regular expressions
213 that will be removed from subject strings if fuzzy subject
214 simplification is selected."
216 :type '(repeat regexp))
218 (defcustom gnus-show-threads t
219 "*If non-nil, display threads in summary mode."
223 (defcustom gnus-thread-hide-subtree nil
224 "*If non-nil, hide all threads initially.
225 If threads are hidden, you have to run the command
226 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
227 to expose hidden threads."
231 (defcustom gnus-thread-hide-killed t
232 "*If non-nil, hide killed threads automatically."
236 (defcustom gnus-thread-ignore-subject t
237 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
238 If nil, articles that have different subjects from their parents will
239 start separate threads."
243 (defcustom gnus-thread-operation-ignore-subject t
244 "*If non-nil, subjects will be ignored when doing thread commands.
245 This affects commands like `gnus-summary-kill-thread' and
246 `gnus-summary-lower-thread'.
248 If this variable is nil, articles in the same thread with different
249 subjects will not be included in the operation in question. If this
250 variable is `fuzzy', only articles that have subjects that are fuzzily
251 equal will be included."
253 :type '(choice (const :tag "off" nil)
257 (defcustom gnus-thread-indent-level 4
258 "*Number that says how much each sub-thread should be indented."
262 (defcustom gnus-auto-extend-newsgroup t
263 "*If non-nil, extend newsgroup forward and backward when requested."
264 :group 'gnus-summary-choose
267 (defcustom gnus-auto-select-first t
268 "*If nil, don't select the first unread article when entering a group.
269 If this variable is `best', select the highest-scored unread article
270 in the group. If t, select the first unread article.
272 This variable can also be a function to place point on a likely
273 subject line. Useful values include `gnus-summary-first-unread-subject',
274 `gnus-summary-first-unread-article' and
275 `gnus-summary-best-unread-article'.
277 If you want to prevent automatic selection of the first unread article
278 in some newsgroups, set the variable to nil in
279 `gnus-select-group-hook'."
280 :group 'gnus-group-select
281 :type '(choice (const :tag "none" nil)
283 (sexp :menu-tag "first" t)
284 (function-item gnus-summary-first-unread-subject)
285 (function-item gnus-summary-first-unread-article)
286 (function-item gnus-summary-best-unread-article)))
288 (defcustom gnus-auto-select-next t
289 "*If non-nil, offer to go to the next group from the end of the previous.
290 If the value is t and the next newsgroup is empty, Gnus will exit
291 summary mode and go back to group mode. If the value is neither nil
292 nor t, Gnus will select the following unread newsgroup. In
293 particular, if the value is the symbol `quietly', the next unread
294 newsgroup will be selected without any confirmation, and if it is
295 `almost-quietly', the next group will be selected without any
296 confirmation if you are located on the last article in the group.
297 Finally, if this variable is `slightly-quietly', the `Z n' command
298 will go to the next group without confirmation."
299 :group 'gnus-summary-maneuvering
300 :type '(choice (const :tag "off" nil)
302 (const almost-quietly)
303 (const slightly-quietly)
304 (sexp :menu-tag "on" t)))
306 (defcustom gnus-auto-select-same nil
307 "*If non-nil, select the next article with the same subject.
308 If there are no more articles with the same subject, go to
309 the first unread article."
310 :group 'gnus-summary-maneuvering
313 (defcustom gnus-summary-check-current nil
314 "*If non-nil, consider the current article when moving.
315 The \"unread\" movement commands will stay on the same line if the
316 current article is unread."
317 :group 'gnus-summary-maneuvering
320 (defcustom gnus-auto-center-summary t
321 "*If non-nil, always center the current summary buffer.
322 In particular, if `vertical' do only vertical recentering. If non-nil
323 and non-`vertical', do both horizontal and vertical recentering."
324 :group 'gnus-summary-maneuvering
325 :type '(choice (const :tag "none" nil)
327 (integer :tag "height")
328 (sexp :menu-tag "both" t)))
330 (defcustom gnus-show-all-headers nil
331 "*If non-nil, don't hide any headers."
332 :group 'gnus-article-hiding
333 :group 'gnus-article-headers
336 (defcustom gnus-summary-ignore-duplicates nil
337 "*If non-nil, ignore articles with identical Message-ID headers."
341 (defcustom gnus-single-article-buffer t
342 "*If non-nil, display all articles in the same buffer.
343 If nil, each group will get its own article buffer."
344 :group 'gnus-article-various
347 (defcustom gnus-break-pages t
348 "*If non-nil, do page breaking on articles.
349 The page delimiter is specified by the `gnus-page-delimiter'
351 :group 'gnus-article-various
354 (defcustom gnus-show-mime t
355 "*If non-nil, do mime processing of articles.
356 The articles will simply be fed to the function given by
357 `gnus-article-display-method-for-mime'."
358 :group 'gnus-article-mime
361 (defcustom gnus-move-split-methods nil
362 "*Variable used to suggest where articles are to be moved to.
363 It uses the same syntax as the `gnus-split-methods' variable."
364 :group 'gnus-summary-mail
365 :type '(repeat (choice (list :value (fun) function)
366 (cons :value ("" "") regexp (repeat string))
369 (defcustom gnus-unread-mark ? ;Whitespace
370 "*Mark used for unread articles."
371 :group 'gnus-summary-marks
374 (defcustom gnus-ticked-mark ?!
375 "*Mark used for ticked articles."
376 :group 'gnus-summary-marks
379 (defcustom gnus-dormant-mark ??
380 "*Mark used for dormant articles."
381 :group 'gnus-summary-marks
384 (defcustom gnus-del-mark ?r
385 "*Mark used for del'd articles."
386 :group 'gnus-summary-marks
389 (defcustom gnus-read-mark ?R
390 "*Mark used for read articles."
391 :group 'gnus-summary-marks
394 (defcustom gnus-expirable-mark ?E
395 "*Mark used for expirable articles."
396 :group 'gnus-summary-marks
399 (defcustom gnus-killed-mark ?K
400 "*Mark used for killed articles."
401 :group 'gnus-summary-marks
404 (defcustom gnus-souped-mark ?F
405 "*Mark used for killed articles."
406 :group 'gnus-summary-marks
409 (defcustom gnus-kill-file-mark ?X
410 "*Mark used for articles killed by kill files."
411 :group 'gnus-summary-marks
414 (defcustom gnus-low-score-mark ?Y
415 "*Mark used for articles with a low score."
416 :group 'gnus-summary-marks
419 (defcustom gnus-catchup-mark ?C
420 "*Mark used for articles that are caught up."
421 :group 'gnus-summary-marks
424 (defcustom gnus-replied-mark ?A
425 "*Mark used for articles that have been replied to."
426 :group 'gnus-summary-marks
429 (defcustom gnus-cached-mark ?*
430 "*Mark used for articles that are in the cache."
431 :group 'gnus-summary-marks
434 (defcustom gnus-saved-mark ?S
435 "*Mark used for articles that have been saved to."
436 :group 'gnus-summary-marks
439 (defcustom gnus-ancient-mark ?O
440 "*Mark used for ancient articles."
441 :group 'gnus-summary-marks
444 (defcustom gnus-sparse-mark ?Q
445 "*Mark used for sparsely reffed articles."
446 :group 'gnus-summary-marks
449 (defcustom gnus-canceled-mark ?G
450 "*Mark used for canceled articles."
451 :group 'gnus-summary-marks
454 (defcustom gnus-duplicate-mark ?M
455 "*Mark used for duplicate articles."
456 :group 'gnus-summary-marks
459 (defcustom gnus-undownloaded-mark ?@
460 "*Mark used for articles that weren't downloaded."
461 :group 'gnus-summary-marks
464 (defcustom gnus-downloadable-mark ?%
465 "*Mark used for articles that are to be downloaded."
466 :group 'gnus-summary-marks
469 (defcustom gnus-unsendable-mark ?=
470 "*Mark used for articles that won't be sent."
471 :group 'gnus-summary-marks
474 (defcustom gnus-score-over-mark ?+
475 "*Score mark used for articles with high scores."
476 :group 'gnus-summary-marks
479 (defcustom gnus-score-below-mark ?-
480 "*Score mark used for articles with low scores."
481 :group 'gnus-summary-marks
484 (defcustom gnus-empty-thread-mark ? ;Whitespace
485 "*There is no thread under the article."
486 :group 'gnus-summary-marks
489 (defcustom gnus-not-empty-thread-mark ?=
490 "*There is a thread under the article."
491 :group 'gnus-summary-marks
494 (defcustom gnus-view-pseudo-asynchronously nil
495 "*If non-nil, Gnus will view pseudo-articles asynchronously."
496 :group 'gnus-extract-view
499 (defcustom gnus-auto-expirable-marks
500 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
501 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
502 gnus-souped-mark gnus-duplicate-mark)
503 "*The list of marks converted into expiration if a group is auto-expirable."
505 :type '(repeat character))
507 (defcustom gnus-inhibit-user-auto-expire t
508 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
512 (defcustom gnus-view-pseudos nil
513 "*If `automatic', pseudo-articles will be viewed automatically.
514 If `not-confirm', pseudos will be viewed automatically, and the user
515 will not be asked to confirm the command."
516 :group 'gnus-extract-view
517 :type '(choice (const :tag "off" nil)
519 (const not-confirm)))
521 (defcustom gnus-view-pseudos-separately t
522 "*If non-nil, one pseudo-article will be created for each file to be viewed.
523 If nil, all files that use the same viewing command will be given as a
524 list of parameters to that command."
525 :group 'gnus-extract-view
528 (defcustom gnus-insert-pseudo-articles t
529 "*If non-nil, insert pseudo-articles when decoding articles."
530 :group 'gnus-extract-view
533 (defcustom gnus-summary-dummy-line-format
535 "*The format specification for the dummy roots in the summary buffer.
536 It works along the same lines as a normal formatting string,
537 with some simple extensions.
540 :group 'gnus-threading
543 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
544 "*The format specification for the summary mode line.
545 It works along the same lines as a normal formatting string,
546 with some simple extensions:
549 %p Unprefixed group name
550 %A Current article number
551 %z Current article score
553 %U Number of unread articles in the group
554 %e Number of unselected articles in the group
555 %Z A string with unread/unselected article counts
556 %g Shortish group name
557 %S Subject of the current article
559 %s Current score file name
560 %d Number of dormant articles
561 %r Number of articles that have been marked as read in this session
562 %E Number of articles expunged by the score files"
563 :group 'gnus-summary-format
566 (defcustom gnus-summary-mark-below 0
567 "*Mark all articles with a score below this variable as read.
568 This variable is local to each summary buffer and usually set by the
570 :group 'gnus-score-default
573 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
574 "*List of functions used for sorting articles in the summary buffer.
575 This variable is only used when not using a threaded display."
576 :group 'gnus-summary-sort
577 :type '(repeat (choice (function-item gnus-article-sort-by-number)
578 (function-item gnus-article-sort-by-author)
579 (function-item gnus-article-sort-by-subject)
580 (function-item gnus-article-sort-by-date)
581 (function-item gnus-article-sort-by-score)
582 (function :tag "other"))))
584 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
585 "*List of functions used for sorting threads in the summary buffer.
586 By default, threads are sorted by article number.
588 Each function takes two threads and return non-nil if the first thread
589 should be sorted before the other. If you use more than one function,
590 the primary sort function should be the last. You should probably
591 always include `gnus-thread-sort-by-number' in the list of sorting
592 functions -- preferably first.
594 Ready-made functions include `gnus-thread-sort-by-number',
595 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
596 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
597 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
598 :group 'gnus-summary-sort
599 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
600 (function-item gnus-thread-sort-by-author)
601 (function-item gnus-thread-sort-by-subject)
602 (function-item gnus-thread-sort-by-date)
603 (function-item gnus-thread-sort-by-score)
604 (function-item gnus-thread-sort-by-total-score)
605 (function :tag "other"))))
607 (defcustom gnus-thread-score-function '+
608 "*Function used for calculating the total score of a thread.
610 The function is called with the scores of the article and each
611 subthread and should then return the score of the thread.
613 Some functions you can use are `+', `max', or `min'."
614 :group 'gnus-summary-sort
617 (defcustom gnus-summary-expunge-below nil
618 "All articles that have a score less than this variable will be expunged.
619 This variable is local to the summary buffers."
620 :group 'gnus-score-default
621 :type '(choice (const :tag "off" nil)
624 (defcustom gnus-thread-expunge-below nil
625 "All threads that have a total score less than this variable will be expunged.
626 See `gnus-thread-score-function' for en explanation of what a
629 This variable is local to the summary buffers."
630 :group 'gnus-threading
631 :group 'gnus-score-default
632 :type '(choice (const :tag "off" nil)
635 (defcustom gnus-summary-mode-hook nil
636 "*A hook for Gnus summary mode.
637 This hook is run before any variables are set in the summary buffer."
638 :group 'gnus-summary-various
641 (defcustom gnus-summary-menu-hook nil
642 "*Hook run after the creation of the summary mode menu."
643 :group 'gnus-summary-visual
646 (defcustom gnus-summary-exit-hook nil
647 "*A hook called on exit from the summary buffer.
648 It will be called with point in the group buffer."
649 :group 'gnus-summary-exit
652 (defcustom gnus-summary-prepare-hook nil
653 "*A hook called after the summary buffer has been generated.
654 If you want to modify the summary buffer, you can use this hook."
655 :group 'gnus-summary-various
658 (defcustom gnus-summary-prepared-hook nil
659 "*A hook called as the last thing after the summary buffer has been generated."
660 :group 'gnus-summary-various
663 (defcustom gnus-summary-generate-hook nil
664 "*A hook run just before generating the summary buffer.
665 This hook is commonly used to customize threading variables and the
667 :group 'gnus-summary-various
670 (defcustom gnus-select-group-hook nil
671 "*A hook called when a newsgroup is selected.
673 If you'd like to simplify subjects like the
674 `gnus-summary-next-same-subject' command does, you can use the
677 (setq gnus-select-group-hook
680 (mapcar (lambda (header)
681 (mail-header-set-subject
683 (gnus-simplify-subject
684 (mail-header-subject header) 're-only)))
685 gnus-newsgroup-headers))))"
686 :group 'gnus-group-select
689 (defcustom gnus-select-article-hook nil
690 "*A hook called when an article is selected."
691 :group 'gnus-summary-choose
694 (defcustom gnus-visual-mark-article-hook
695 (list 'gnus-highlight-selected-summary)
696 "*Hook run after selecting an article in the summary buffer.
697 It is meant to be used for highlighting the article in some way. It
698 is not run if `gnus-visual' is nil."
699 :group 'gnus-summary-visual
702 (defcustom gnus-parse-headers-hook '(gnus-set-summary-default-charset)
703 "*A hook called before parsing the headers."
707 (defcustom gnus-exit-group-hook nil
708 "*A hook called when exiting (not quitting) summary mode."
712 (defcustom gnus-summary-update-hook
713 (list 'gnus-summary-highlight-line)
714 "*A hook called when a summary line is changed.
715 The hook will not be called if `gnus-visual' is nil.
717 The default function `gnus-summary-highlight-line' will
718 highlight the line according to the `gnus-summary-highlight'
720 :group 'gnus-summary-visual
723 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
724 "*A hook called when an article is selected for the first time.
725 The hook is intended to mark an article as read (or unread)
726 automatically when it is selected."
727 :group 'gnus-summary-choose
730 (defcustom gnus-group-no-more-groups-hook nil
731 "*A hook run when returning to group mode having no more (unread) groups."
732 :group 'gnus-group-select
735 (defcustom gnus-ps-print-hook nil
736 "*A hook run before ps-printing something from Gnus."
740 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
741 "Face used for highlighting the current article in the summary buffer."
742 :group 'gnus-summary-visual
745 (defcustom gnus-summary-highlight
746 '(((= mark gnus-canceled-mark)
747 . gnus-summary-cancelled-face)
748 ((and (> score default)
749 (or (= mark gnus-dormant-mark)
750 (= mark gnus-ticked-mark)))
751 . gnus-summary-high-ticked-face)
752 ((and (< score default)
753 (or (= mark gnus-dormant-mark)
754 (= mark gnus-ticked-mark)))
755 . gnus-summary-low-ticked-face)
756 ((or (= mark gnus-dormant-mark)
757 (= mark gnus-ticked-mark))
758 . gnus-summary-normal-ticked-face)
759 ((and (> score default) (= mark gnus-ancient-mark))
760 . gnus-summary-high-ancient-face)
761 ((and (< score default) (= mark gnus-ancient-mark))
762 . gnus-summary-low-ancient-face)
763 ((= mark gnus-ancient-mark)
764 . gnus-summary-normal-ancient-face)
765 ((and (> score default) (= mark gnus-unread-mark))
766 . gnus-summary-high-unread-face)
767 ((and (< score default) (= mark gnus-unread-mark))
768 . gnus-summary-low-unread-face)
769 ((= mark gnus-unread-mark)
770 . gnus-summary-normal-unread-face)
771 ((and (> score default) (memq mark (list gnus-downloadable-mark
772 gnus-undownloaded-mark)))
773 . gnus-summary-high-unread-face)
774 ((and (< score default) (memq mark (list gnus-downloadable-mark
775 gnus-undownloaded-mark)))
776 . gnus-summary-low-unread-face)
777 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
778 . gnus-summary-normal-unread-face)
780 . gnus-summary-high-read-face)
782 . gnus-summary-low-read-face)
784 . gnus-summary-normal-read-face))
785 "*Controls the highlighting of summary buffer lines.
787 A list of (FORM . FACE) pairs. When deciding how a a particular
788 summary line should be displayed, each form is evaluated. The content
789 of the face field after the first true form is used. You can change
790 how those summary lines are displayed, by editing the face field.
792 You can use the following variables in the FORM field.
794 score: The articles score
795 default: The default article score.
796 below: The score below which articles are automatically marked as read.
797 mark: The articles mark."
798 :group 'gnus-summary-visual
799 :type '(repeat (cons (sexp :tag "Form" nil)
802 (defcustom gnus-alter-header-function nil
803 "Function called to allow alteration of article header structures.
804 The function is called with one parameter, the article header vector,
805 which it may alter in any way.")
807 (defcustom gnus-extra-headers nil
808 "*Extra headers to parse."
810 :type '(repeat symbol))
812 (defcustom gnus-ignored-from-addresses
813 (and user-mail-address (regexp-quote user-mail-address))
814 "*Regexp of From headers that may be suppressed in favor of To headers."
818 (defcustom gnus-group-charset-alist
819 '(("^hk\\>\\|^tw\\>\\|\\<big5\\>" cn-big5)
820 ("^cn\\>\\|\\<chinese\\>" cn-gb-2312)
821 ("^fj\\>\\|^japan\\>" iso-2022-jp-2)
822 ("^relcom\\>" koi8-r)
823 ("^\\(cz\\|hun\\|pl\\|sk\\|hr\\)\\>" iso-8859-2)
824 ("^israel\\>" iso-8859-1)
826 ("^\\(comp\\|rec\\|alt\\|sci\\|soc\\|news\\|gnu\\|bofh\\)\\>" iso-8859-1)
828 "Alist of regexps (to match group names) and default charsets to be used when reading."
829 :type '(repeat (list (regexp :tag "Group")
830 (symbol :tag "Charset")))
831 :group 'gnus-charset)
833 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit)
834 "List of charsets that should be ignored.
835 When these charsets are used in the \"charset\" parameter, the
836 default charset will be used instead."
837 :type '(repeat symbol)
838 :group 'gnus-charset)
840 ;;; Internal variables
842 (defvar gnus-scores-exclude-files nil)
843 (defvar gnus-page-broken nil)
844 (defvar gnus-inhibit-mime-unbuttonizing nil)
846 (defvar gnus-original-article nil)
847 (defvar gnus-article-internal-prepare-hook nil)
848 (defvar gnus-newsgroup-process-stack nil)
850 (defvar gnus-thread-indent-array nil)
851 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
853 ;; Avoid highlighting in kill files.
854 (defvar gnus-summary-inhibit-highlight nil)
855 (defvar gnus-newsgroup-selected-overlay nil)
856 (defvar gnus-inhibit-limiting nil)
857 (defvar gnus-newsgroup-adaptive-score-file nil)
858 (defvar gnus-current-score-file nil)
859 (defvar gnus-current-move-group nil)
860 (defvar gnus-current-copy-group nil)
861 (defvar gnus-current-crosspost-group nil)
863 (defvar gnus-newsgroup-dependencies nil)
864 (defvar gnus-newsgroup-adaptive nil)
865 (defvar gnus-summary-display-article-function nil)
866 (defvar gnus-summary-highlight-line-function nil
867 "Function called after highlighting a summary line.")
869 (defvar gnus-summary-line-format-alist
870 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
871 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
872 (?s gnus-tmp-subject-or-nil ?s)
873 (?n gnus-tmp-name ?s)
874 (?A (std11-address-string
875 (car (mime-read-field 'From gnus-tmp-header))) ?s)
876 (?a (or (std11-full-name-string
877 (car (mime-read-field 'From gnus-tmp-header)))
879 (?F gnus-tmp-from ?s)
880 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
881 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
882 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
883 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
884 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
885 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
886 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
887 (?L gnus-tmp-lines ?d)
888 (?I gnus-tmp-indentation ?s)
889 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
890 (?R gnus-tmp-replied ?c)
891 (?\[ gnus-tmp-opening-bracket ?c)
892 (?\] gnus-tmp-closing-bracket ?c)
893 (?\> (make-string gnus-tmp-level ? ) ?s)
894 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
895 (?i gnus-tmp-score ?d)
896 (?z gnus-tmp-score-char ?c)
897 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
898 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
899 (?U gnus-tmp-unread ?c)
900 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header) ?s)
901 (?t (gnus-summary-number-of-articles-in-thread
902 (and (boundp 'thread) (car thread)) gnus-tmp-level)
904 (?e (gnus-summary-number-of-articles-in-thread
905 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
907 (?u gnus-tmp-user-defined ?s)
908 (?P (gnus-pick-line-number) ?d))
909 "An alist of format specifications that can appear in summary lines,
910 and what variables they correspond with, along with the type of the
911 variable (string, integer, character, etc).")
913 (defvar gnus-summary-dummy-line-format-alist
914 `((?S gnus-tmp-subject ?s)
915 (?N gnus-tmp-number ?d)
916 (?u gnus-tmp-user-defined ?s)))
918 (defvar gnus-summary-mode-line-format-alist
919 `((?G gnus-tmp-group-name ?s)
920 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
921 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
922 (?A gnus-tmp-article-number ?d)
923 (?Z gnus-tmp-unread-and-unselected ?s)
925 (?U gnus-tmp-unread-and-unticked ?d)
926 (?S gnus-tmp-subject ?s)
927 (?e gnus-tmp-unselected ?d)
928 (?u gnus-tmp-user-defined ?s)
929 (?d (length gnus-newsgroup-dormant) ?d)
930 (?t (length gnus-newsgroup-marked) ?d)
931 (?r (length gnus-newsgroup-reads) ?d)
932 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
933 (?E gnus-newsgroup-expunged-tally ?d)
934 (?s (gnus-current-score-file-nondirectory) ?s)))
936 (defvar gnus-last-search-regexp nil
937 "Default regexp for article search command.")
939 (defvar gnus-last-shell-command nil
940 "Default shell command on article.")
942 (defvar gnus-newsgroup-begin nil)
943 (defvar gnus-newsgroup-end nil)
944 (defvar gnus-newsgroup-last-rmail nil)
945 (defvar gnus-newsgroup-last-mail nil)
946 (defvar gnus-newsgroup-last-folder nil)
947 (defvar gnus-newsgroup-last-file nil)
948 (defvar gnus-newsgroup-auto-expire nil)
949 (defvar gnus-newsgroup-active nil)
951 (defvar gnus-newsgroup-data nil)
952 (defvar gnus-newsgroup-data-reverse nil)
953 (defvar gnus-newsgroup-limit nil)
954 (defvar gnus-newsgroup-limits nil)
956 (defvar gnus-newsgroup-unreads nil
957 "List of unread articles in the current newsgroup.")
959 (defvar gnus-newsgroup-unselected nil
960 "List of unselected unread articles in the current newsgroup.")
962 (defvar gnus-newsgroup-reads nil
963 "Alist of read articles and article marks in the current newsgroup.")
965 (defvar gnus-newsgroup-expunged-tally nil)
967 (defvar gnus-newsgroup-marked nil
968 "List of ticked articles in the current newsgroup (a subset of unread art).")
970 (defvar gnus-newsgroup-killed nil
971 "List of ranges of articles that have been through the scoring process.")
973 (defvar gnus-newsgroup-cached nil
974 "List of articles that come from the article cache.")
976 (defvar gnus-newsgroup-saved nil
977 "List of articles that have been saved.")
979 (defvar gnus-newsgroup-kill-headers nil)
981 (defvar gnus-newsgroup-replied nil
982 "List of articles that have been replied to in the current newsgroup.")
984 (defvar gnus-newsgroup-expirable nil
985 "List of articles in the current newsgroup that can be expired.")
987 (defvar gnus-newsgroup-processable nil
988 "List of articles in the current newsgroup that can be processed.")
990 (defvar gnus-newsgroup-downloadable nil
991 "List of articles in the current newsgroup that can be processed.")
993 (defvar gnus-newsgroup-undownloaded nil
994 "List of articles in the current newsgroup that haven't been downloaded..")
996 (defvar gnus-newsgroup-unsendable nil
997 "List of articles in the current newsgroup that won't be sent.")
999 (defvar gnus-newsgroup-bookmarks nil
1000 "List of articles in the current newsgroup that have bookmarks.")
1002 (defvar gnus-newsgroup-dormant nil
1003 "List of dormant articles in the current newsgroup.")
1005 (defvar gnus-newsgroup-scored nil
1006 "List of scored articles in the current newsgroup.")
1008 (defvar gnus-newsgroup-headers nil
1009 "List of article headers in the current newsgroup.")
1011 (defvar gnus-newsgroup-threads nil)
1013 (defvar gnus-newsgroup-prepared nil
1014 "Whether the current group has been prepared properly.")
1016 (defvar gnus-newsgroup-ancient nil
1017 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1019 (defvar gnus-newsgroup-sparse nil)
1021 (defvar gnus-current-article nil)
1022 (defvar gnus-article-current nil)
1023 (defvar gnus-current-headers nil)
1024 (defvar gnus-have-all-headers nil)
1025 (defvar gnus-last-article nil)
1026 (defvar gnus-newsgroup-history nil)
1027 (defvar gnus-newsgroup-charset nil)
1029 (defconst gnus-summary-local-variables
1030 '(gnus-newsgroup-name
1031 gnus-newsgroup-begin gnus-newsgroup-end
1032 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1033 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1034 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1035 gnus-newsgroup-unselected gnus-newsgroup-marked
1036 gnus-newsgroup-reads gnus-newsgroup-saved
1037 gnus-newsgroup-replied gnus-newsgroup-expirable
1038 gnus-newsgroup-processable gnus-newsgroup-killed
1039 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1040 gnus-newsgroup-unsendable
1041 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1042 gnus-newsgroup-headers gnus-newsgroup-threads
1043 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1044 gnus-current-article gnus-current-headers gnus-have-all-headers
1045 gnus-last-article gnus-article-internal-prepare-hook
1046 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1047 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1048 gnus-thread-expunge-below
1049 gnus-score-alist gnus-current-score-file
1050 (gnus-summary-expunge-below . global)
1051 (gnus-summary-mark-below . global)
1052 gnus-newsgroup-active gnus-scores-exclude-files
1053 gnus-newsgroup-history gnus-newsgroup-ancient
1054 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1055 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1056 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1057 (gnus-newsgroup-expunged-tally . 0)
1058 gnus-cache-removable-articles gnus-newsgroup-cached
1059 gnus-newsgroup-data gnus-newsgroup-data-reverse
1060 gnus-newsgroup-limit gnus-newsgroup-limits
1061 gnus-newsgroup-charset)
1062 "Variables that are buffer-local to the summary buffers.")
1064 ;; Byte-compiler warning.
1065 (defvar gnus-article-mode-map)
1067 ;; Subject simplification.
1069 (defun gnus-simplify-whitespace (str)
1070 "Remove excessive whitespace."
1073 (while (string-match "[ \t][ \t]+" mystr)
1074 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1076 (substring mystr (match-end 0)))))
1078 (when (string-match "^[ \t]+" mystr)
1079 (setq mystr (substring mystr (match-end 0))))
1081 (when (string-match "[ \t]+$" mystr)
1082 (setq mystr (substring mystr 0 (match-beginning 0))))
1085 (defsubst gnus-simplify-subject-re (subject)
1086 "Remove \"Re:\" from subject lines."
1087 (if (string-match "^[Rr][Ee]: *" subject)
1088 (substring subject (match-end 0))
1091 (defun gnus-simplify-subject (subject &optional re-only)
1092 "Remove `Re:' and words in parentheses.
1093 If RE-ONLY is non-nil, strip leading `Re:'s only."
1094 (let ((case-fold-search t)) ;Ignore case.
1095 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1096 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1097 (setq subject (substring subject (match-end 0))))
1098 ;; Remove uninteresting prefixes.
1099 (when (and (not re-only)
1100 gnus-simplify-ignored-prefixes
1101 (string-match gnus-simplify-ignored-prefixes subject))
1102 (setq subject (substring subject (match-end 0))))
1103 ;; Remove words in parentheses from end.
1105 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1106 (setq subject (substring subject 0 (match-beginning 0)))))
1107 ;; Return subject string.
1110 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1112 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1113 (goto-char (point-min))
1114 (while (re-search-forward regexp nil t)
1115 (replace-match (or newtext ""))))
1117 (defun gnus-simplify-buffer-fuzzy ()
1118 "Simplify string in the buffer fuzzily.
1119 The string in the accessible portion of the current buffer is simplified.
1120 It is assumed to be a single-line subject.
1121 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1122 matter is removed. Additional things can be deleted by setting
1123 gnus-simplify-subject-fuzzy-regexp."
1124 (let ((case-fold-search t)
1126 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1128 (while (not (eq modified-tick (buffer-modified-tick)))
1129 (setq modified-tick (buffer-modified-tick))
1131 ((listp gnus-simplify-subject-fuzzy-regexp)
1132 (mapcar 'gnus-simplify-buffer-fuzzy-step
1133 gnus-simplify-subject-fuzzy-regexp))
1134 (gnus-simplify-subject-fuzzy-regexp
1135 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1136 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1137 (gnus-simplify-buffer-fuzzy-step
1138 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1139 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1141 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1142 (gnus-simplify-buffer-fuzzy-step " +" " ")
1143 (gnus-simplify-buffer-fuzzy-step " $")
1144 (gnus-simplify-buffer-fuzzy-step "^ +")))
1146 (defun gnus-simplify-subject-fuzzy (subject)
1147 "Simplify a subject string fuzzily.
1148 See `gnus-simplify-buffer-fuzzy' for details."
1150 (gnus-set-work-buffer)
1151 (let ((case-fold-search t))
1152 ;; Remove uninteresting prefixes.
1153 (when (and gnus-simplify-ignored-prefixes
1154 (string-match gnus-simplify-ignored-prefixes subject))
1155 (setq subject (substring subject (match-end 0))))
1157 (inline (gnus-simplify-buffer-fuzzy))
1160 (defsubst gnus-simplify-subject-fully (subject)
1161 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1163 (gnus-simplify-subject-functions
1164 (gnus-map-function gnus-simplify-subject-functions subject))
1165 ((null gnus-summary-gather-subject-limit)
1166 (gnus-simplify-subject-re subject))
1167 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1168 (gnus-simplify-subject-fuzzy subject))
1169 ((numberp gnus-summary-gather-subject-limit)
1170 (gnus-limit-string (gnus-simplify-subject-re subject)
1171 gnus-summary-gather-subject-limit))
1175 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1176 "Check whether two subjects are equal.
1177 If optional argument simple-first is t, first argument is already
1180 ((null simple-first)
1181 (equal (gnus-simplify-subject-fully s1)
1182 (gnus-simplify-subject-fully s2)))
1185 (gnus-simplify-subject-fully s2)))))
1187 (defun gnus-summary-bubble-group ()
1188 "Increase the score of the current group.
1189 This is a handy function to add to `gnus-summary-exit-hook' to
1190 increase the score of each group you read."
1191 (gnus-group-add-score gnus-newsgroup-name))
1195 ;;; Gnus summary mode
1198 (put 'gnus-summary-mode 'mode-class 'special)
1201 ;; Non-orthogonal keys
1203 (gnus-define-keys gnus-summary-mode-map
1204 " " gnus-summary-next-page
1205 "\177" gnus-summary-prev-page
1206 [delete] gnus-summary-prev-page
1207 [backspace] gnus-summary-prev-page
1208 "\r" gnus-summary-scroll-up
1209 "\M-\r" gnus-summary-scroll-down
1210 "n" gnus-summary-next-unread-article
1211 "p" gnus-summary-prev-unread-article
1212 "N" gnus-summary-next-article
1213 "P" gnus-summary-prev-article
1214 "\M-\C-n" gnus-summary-next-same-subject
1215 "\M-\C-p" gnus-summary-prev-same-subject
1216 "\M-n" gnus-summary-next-unread-subject
1217 "\M-p" gnus-summary-prev-unread-subject
1218 "." gnus-summary-first-unread-article
1219 "," gnus-summary-best-unread-article
1220 "\M-s" gnus-summary-search-article-forward
1221 "\M-r" gnus-summary-search-article-backward
1222 "<" gnus-summary-beginning-of-article
1223 ">" gnus-summary-end-of-article
1224 "j" gnus-summary-goto-article
1225 "^" gnus-summary-refer-parent-article
1226 "\M-^" gnus-summary-refer-article
1227 "u" gnus-summary-tick-article-forward
1228 "!" gnus-summary-tick-article-forward
1229 "U" gnus-summary-tick-article-backward
1230 "d" gnus-summary-mark-as-read-forward
1231 "D" gnus-summary-mark-as-read-backward
1232 "E" gnus-summary-mark-as-expirable
1233 "\M-u" gnus-summary-clear-mark-forward
1234 "\M-U" gnus-summary-clear-mark-backward
1235 "k" gnus-summary-kill-same-subject-and-select
1236 "\C-k" gnus-summary-kill-same-subject
1237 "\M-\C-k" gnus-summary-kill-thread
1238 "\M-\C-l" gnus-summary-lower-thread
1239 "e" gnus-summary-edit-article
1240 "#" gnus-summary-mark-as-processable
1241 "\M-#" gnus-summary-unmark-as-processable
1242 "\M-\C-t" gnus-summary-toggle-threads
1243 "\M-\C-s" gnus-summary-show-thread
1244 "\M-\C-h" gnus-summary-hide-thread
1245 "\M-\C-f" gnus-summary-next-thread
1246 "\M-\C-b" gnus-summary-prev-thread
1247 "\M-\C-u" gnus-summary-up-thread
1248 "\M-\C-d" gnus-summary-down-thread
1249 "&" gnus-summary-execute-command
1250 "c" gnus-summary-catchup-and-exit
1251 "\C-w" gnus-summary-mark-region-as-read
1252 "\C-t" gnus-summary-toggle-truncation
1253 "?" gnus-summary-mark-as-dormant
1254 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1255 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1256 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1257 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1258 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1259 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1260 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1261 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1262 "=" gnus-summary-expand-window
1263 "\C-x\C-s" gnus-summary-reselect-current-group
1264 "\M-g" gnus-summary-rescan-group
1265 "w" gnus-summary-stop-page-breaking
1266 "\C-c\C-r" gnus-summary-caesar-message
1267 "\M-t" gnus-summary-toggle-mime
1268 "f" gnus-summary-followup
1269 "F" gnus-summary-followup-with-original
1270 "C" gnus-summary-cancel-article
1271 "r" gnus-summary-reply
1272 "R" gnus-summary-reply-with-original
1273 "\C-c\C-f" gnus-summary-mail-forward
1274 "o" gnus-summary-save-article
1275 "\C-o" gnus-summary-save-article-mail
1276 "|" gnus-summary-pipe-output
1277 "\M-k" gnus-summary-edit-local-kill
1278 "\M-K" gnus-summary-edit-global-kill
1280 "\C-c\C-d" gnus-summary-describe-group
1281 "q" gnus-summary-exit
1282 "Q" gnus-summary-exit-no-update
1283 "\C-c\C-i" gnus-info-find-node
1284 gnus-mouse-2 gnus-mouse-pick-article
1285 "m" gnus-summary-mail-other-window
1286 "a" gnus-summary-post-news
1287 "x" gnus-summary-limit-to-unread
1288 "s" gnus-summary-isearch-article
1289 "t" gnus-article-hide-headers
1290 "g" gnus-summary-show-article
1291 "l" gnus-summary-goto-last-article
1292 "v" gnus-summary-preview-mime-message
1293 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1294 "\C-d" gnus-summary-enter-digest-group
1295 "\M-\C-d" gnus-summary-read-document
1296 "\M-\C-e" gnus-summary-edit-parameters
1297 "\M-\C-g" gnus-summary-customize-parameters
1299 "*" gnus-cache-enter-article
1300 "\M-*" gnus-cache-remove-article
1301 "\M-&" gnus-summary-universal-argument
1302 "\C-l" gnus-recenter
1303 "I" gnus-summary-increase-score
1304 "L" gnus-summary-lower-score
1305 "\M-i" gnus-symbolic-argument
1306 "h" gnus-summary-select-article-buffer
1308 "V" gnus-summary-score-map
1309 "X" gnus-uu-extract-map
1310 "S" gnus-summary-send-map)
1312 ;; Sort of orthogonal keymap
1313 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1314 "t" gnus-summary-tick-article-forward
1315 "!" gnus-summary-tick-article-forward
1316 "d" gnus-summary-mark-as-read-forward
1317 "r" gnus-summary-mark-as-read-forward
1318 "c" gnus-summary-clear-mark-forward
1319 " " gnus-summary-clear-mark-forward
1320 "e" gnus-summary-mark-as-expirable
1321 "x" gnus-summary-mark-as-expirable
1322 "?" gnus-summary-mark-as-dormant
1323 "b" gnus-summary-set-bookmark
1324 "B" gnus-summary-remove-bookmark
1325 "#" gnus-summary-mark-as-processable
1326 "\M-#" gnus-summary-unmark-as-processable
1327 "S" gnus-summary-limit-include-expunged
1328 "C" gnus-summary-catchup
1329 "H" gnus-summary-catchup-to-here
1330 "\C-c" gnus-summary-catchup-all
1331 "k" gnus-summary-kill-same-subject-and-select
1332 "K" gnus-summary-kill-same-subject
1333 "P" gnus-uu-mark-map)
1335 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1336 "c" gnus-summary-clear-above
1337 "u" gnus-summary-tick-above
1338 "m" gnus-summary-mark-above
1339 "k" gnus-summary-kill-below)
1341 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1342 "/" gnus-summary-limit-to-subject
1343 "n" gnus-summary-limit-to-articles
1344 "w" gnus-summary-pop-limit
1345 "s" gnus-summary-limit-to-subject
1346 "a" gnus-summary-limit-to-author
1347 "u" gnus-summary-limit-to-unread
1348 "m" gnus-summary-limit-to-marks
1349 "M" gnus-summary-limit-exclude-marks
1350 "v" gnus-summary-limit-to-score
1351 "*" gnus-summary-limit-include-cached
1352 "D" gnus-summary-limit-include-dormant
1353 "T" gnus-summary-limit-include-thread
1354 "d" gnus-summary-limit-exclude-dormant
1355 "t" gnus-summary-limit-to-age
1356 "E" gnus-summary-limit-include-expunged
1357 "c" gnus-summary-limit-exclude-childless-dormant
1358 "C" gnus-summary-limit-mark-excluded-as-read)
1360 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1361 "n" gnus-summary-next-unread-article
1362 "p" gnus-summary-prev-unread-article
1363 "N" gnus-summary-next-article
1364 "P" gnus-summary-prev-article
1365 "\C-n" gnus-summary-next-same-subject
1366 "\C-p" gnus-summary-prev-same-subject
1367 "\M-n" gnus-summary-next-unread-subject
1368 "\M-p" gnus-summary-prev-unread-subject
1369 "f" gnus-summary-first-unread-article
1370 "b" gnus-summary-best-unread-article
1371 "j" gnus-summary-goto-article
1372 "g" gnus-summary-goto-subject
1373 "l" gnus-summary-goto-last-article
1374 "o" gnus-summary-pop-article)
1376 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1377 "k" gnus-summary-kill-thread
1378 "l" gnus-summary-lower-thread
1379 "i" gnus-summary-raise-thread
1380 "T" gnus-summary-toggle-threads
1381 "t" gnus-summary-rethread-current
1382 "^" gnus-summary-reparent-thread
1383 "s" gnus-summary-show-thread
1384 "S" gnus-summary-show-all-threads
1385 "h" gnus-summary-hide-thread
1386 "H" gnus-summary-hide-all-threads
1387 "n" gnus-summary-next-thread
1388 "p" gnus-summary-prev-thread
1389 "u" gnus-summary-up-thread
1390 "o" gnus-summary-top-thread
1391 "d" gnus-summary-down-thread
1392 "#" gnus-uu-mark-thread
1393 "\M-#" gnus-uu-unmark-thread)
1395 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1396 "g" gnus-summary-prepare
1397 "c" gnus-summary-insert-cached-articles)
1399 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1400 "c" gnus-summary-catchup-and-exit
1401 "C" gnus-summary-catchup-all-and-exit
1402 "E" gnus-summary-exit-no-update
1403 "Q" gnus-summary-exit
1404 "Z" gnus-summary-exit
1405 "n" gnus-summary-catchup-and-goto-next-group
1406 "R" gnus-summary-reselect-current-group
1407 "G" gnus-summary-rescan-group
1408 "N" gnus-summary-next-group
1409 "s" gnus-summary-save-newsrc
1410 "P" gnus-summary-prev-group)
1412 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1413 " " gnus-summary-next-page
1414 "n" gnus-summary-next-page
1415 "\177" gnus-summary-prev-page
1416 [delete] gnus-summary-prev-page
1417 "p" gnus-summary-prev-page
1418 "\r" gnus-summary-scroll-up
1419 "\M-\r" gnus-summary-scroll-down
1420 "<" gnus-summary-beginning-of-article
1421 ">" gnus-summary-end-of-article
1422 "b" gnus-summary-beginning-of-article
1423 "e" gnus-summary-end-of-article
1424 "^" gnus-summary-refer-parent-article
1425 "r" gnus-summary-refer-parent-article
1426 "D" gnus-summary-enter-digest-group
1427 "R" gnus-summary-refer-references
1428 "T" gnus-summary-refer-thread
1429 "g" gnus-summary-show-article
1430 "s" gnus-summary-isearch-article
1431 "P" gnus-summary-print-article)
1433 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1434 "b" gnus-article-add-buttons
1435 "B" gnus-article-add-buttons-to-head
1436 "o" gnus-article-treat-overstrike
1437 "e" gnus-article-emphasize
1438 "w" gnus-article-fill-cited-article
1439 "Q" gnus-article-fill-long-lines
1440 "C" gnus-article-capitalize-sentences
1441 "c" gnus-article-remove-cr
1442 "f" gnus-article-display-x-face
1443 "l" gnus-summary-stop-page-breaking
1444 "r" gnus-summary-caesar-message
1445 "t" gnus-article-hide-headers
1446 "v" gnus-summary-verbose-headers
1447 "m" gnus-summary-toggle-mime
1448 "h" gnus-article-treat-html
1449 "H" gnus-article-strip-headers-in-body
1450 "d" gnus-article-treat-dumbquotes)
1452 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1453 "a" gnus-article-hide
1454 "h" gnus-article-hide-headers
1455 "b" gnus-article-hide-boring-headers
1456 "s" gnus-article-hide-signature
1457 "c" gnus-article-hide-citation
1458 "C" gnus-article-hide-citation-in-followups
1459 "p" gnus-article-hide-pgp
1460 "B" gnus-article-strip-banner
1461 "P" gnus-article-hide-pem
1462 "\C-c" gnus-article-hide-citation-maybe)
1464 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1465 "a" gnus-article-highlight
1466 "h" gnus-article-highlight-headers
1467 "c" gnus-article-highlight-citation
1468 "s" gnus-article-highlight-signature)
1470 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1471 "z" gnus-article-date-ut
1472 "u" gnus-article-date-ut
1473 "l" gnus-article-date-local
1474 "e" gnus-article-date-lapsed
1475 "o" gnus-article-date-original
1476 "i" gnus-article-date-iso8601
1477 "s" gnus-article-date-user)
1479 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1480 "t" gnus-article-remove-trailing-blank-lines
1481 "l" gnus-article-strip-leading-blank-lines
1482 "m" gnus-article-strip-multiple-blank-lines
1483 "a" gnus-article-strip-blank-lines
1484 "A" gnus-article-strip-all-blank-lines
1485 "s" gnus-article-strip-leading-space
1486 "e" gnus-article-strip-trailing-space)
1488 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1490 "f" gnus-summary-fetch-faq
1491 "d" gnus-summary-describe-group
1492 "h" gnus-summary-describe-briefly
1493 "i" gnus-info-find-node)
1495 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1496 "e" gnus-summary-expire-articles
1497 "\M-\C-e" gnus-summary-expire-articles-now
1498 "\177" gnus-summary-delete-article
1499 [delete] gnus-summary-delete-article
1500 "m" gnus-summary-move-article
1501 "r" gnus-summary-respool-article
1502 "w" gnus-summary-edit-article
1503 "c" gnus-summary-copy-article
1504 "B" gnus-summary-crosspost-article
1505 "q" gnus-summary-respool-query
1506 "t" gnus-summary-respool-trace
1507 "i" gnus-summary-import-article
1508 "p" gnus-summary-article-posted-p)
1510 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1511 "o" gnus-summary-save-article
1512 "m" gnus-summary-save-article-mail
1513 "F" gnus-summary-write-article-file
1514 "r" gnus-summary-save-article-rmail
1515 "f" gnus-summary-save-article-file
1516 "b" gnus-summary-save-article-body-file
1517 "h" gnus-summary-save-article-folder
1518 "v" gnus-summary-save-article-vm
1519 "p" gnus-summary-pipe-output
1520 "s" gnus-soup-add-article)
1522 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1523 "b" gnus-summary-display-buttonized
1524 "m" gnus-summary-repair-multipart
1525 "v" gnus-article-view-part
1526 "o" gnus-article-save-part
1527 "c" gnus-article-copy-part
1528 "e" gnus-article-externalize-part
1529 "i" gnus-article-inline-part
1530 "|" gnus-article-pipe-part)
1533 (defun gnus-summary-make-menu-bar ()
1534 (gnus-turn-off-edit-menu 'summary)
1536 (unless (boundp 'gnus-summary-misc-menu)
1539 gnus-summary-kill-menu gnus-summary-mode-map ""
1544 ["Enter score..." gnus-summary-score-entry t]
1545 ["Customize" gnus-score-customize t])
1546 (gnus-make-score-map 'increase)
1547 (gnus-make-score-map 'lower)
1549 ["Kill below" gnus-summary-kill-below t]
1550 ["Mark above" gnus-summary-mark-above t]
1551 ["Tick above" gnus-summary-tick-above t]
1552 ["Clear above" gnus-summary-clear-above t])
1553 ["Current score" gnus-summary-current-score t]
1554 ["Set score" gnus-summary-set-score t]
1555 ["Switch current score file..." gnus-score-change-score-file t]
1556 ["Set mark below..." gnus-score-set-mark-below t]
1557 ["Set expunge below..." gnus-score-set-expunge-below t]
1558 ["Edit current score file" gnus-score-edit-current-scores t]
1559 ["Edit score file" gnus-score-edit-file t]
1560 ["Trace score" gnus-score-find-trace t]
1561 ["Find words" gnus-score-find-favourite-words t]
1562 ["Rescore buffer" gnus-summary-rescore t]
1563 ["Increase score..." gnus-summary-increase-score t]
1564 ["Lower score..." gnus-summary-lower-score t]))))
1566 ;; Define both the Article menu in the summary buffer and the equivalent
1567 ;; Commands menu in the article buffer here for consistency.
1570 ["All" gnus-article-hide t]
1571 ["Headers" gnus-article-hide-headers t]
1572 ["Signature" gnus-article-hide-signature t]
1573 ["Citation" gnus-article-hide-citation t]
1574 ["PGP" gnus-article-hide-pgp t]
1575 ["Banner" gnus-article-strip-banner t]
1576 ["Boring headers" gnus-article-hide-boring-headers t])
1578 ["All" gnus-article-highlight t]
1579 ["Headers" gnus-article-highlight-headers t]
1580 ["Signature" gnus-article-highlight-signature t]
1581 ["Citation" gnus-article-highlight-citation t])
1583 ["Local" gnus-article-date-local t]
1584 ["ISO8601" gnus-article-date-iso8601 t]
1585 ["UT" gnus-article-date-ut t]
1586 ["Original" gnus-article-date-original t]
1587 ["Lapsed" gnus-article-date-lapsed t]
1588 ["User-defined" gnus-article-date-user t])
1591 ["Leading" gnus-article-strip-leading-blank-lines t]
1592 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1593 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1594 ["All of the above" gnus-article-strip-blank-lines t]
1595 ["All" gnus-article-strip-all-blank-lines t]
1596 ["Leading space" gnus-article-strip-leading-space t]
1597 ["Trailing space" gnus-article-strip-trailing-space t])
1598 ["Overstrike" gnus-article-treat-overstrike t]
1599 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1600 ["Emphasis" gnus-article-emphasize t]
1601 ["Word wrap" gnus-article-fill-cited-article t]
1602 ["Fill long lines" gnus-article-fill-long-lines t]
1603 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1604 ["CR" gnus-article-remove-cr t]
1605 ["Show X-Face" gnus-article-display-x-face t]
1606 ["UnHTMLize" gnus-article-treat-html t]
1607 ["Rot 13" gnus-summary-caesar-message t]
1608 ["Unix pipe" gnus-summary-pipe-message t]
1609 ["Add buttons" gnus-article-add-buttons t]
1610 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1611 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1612 ["Toggle MIME" gnus-summary-toggle-mime t]
1613 ["Verbose header" gnus-summary-verbose-headers t]
1614 ["Toggle header" gnus-summary-toggle-header t])
1616 ["Save in default format" gnus-summary-save-article t]
1617 ["Save in file" gnus-summary-save-article-file t]
1618 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1619 ["Save in MH folder" gnus-summary-save-article-folder t]
1620 ["Save in VM folder" gnus-summary-save-article-vm t]
1621 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1622 ["Save body in file" gnus-summary-save-article-body-file t]
1623 ["Pipe through a filter" gnus-summary-pipe-output t]
1624 ["Add to SOUP packet" gnus-soup-add-article t]
1625 ["Print" gnus-summary-print-article t])
1627 ["Respool article..." gnus-summary-respool-article t]
1628 ["Move article..." gnus-summary-move-article
1629 (gnus-check-backend-function
1630 'request-move-article gnus-newsgroup-name)]
1631 ["Copy article..." gnus-summary-copy-article t]
1632 ["Crosspost article..." gnus-summary-crosspost-article
1633 (gnus-check-backend-function
1634 'request-replace-article gnus-newsgroup-name)]
1635 ["Import file..." gnus-summary-import-article t]
1636 ["Check if posted" gnus-summary-article-posted-p t]
1637 ["Edit article" gnus-summary-edit-article
1638 (not (gnus-group-read-only-p))]
1639 ["Delete article" gnus-summary-delete-article
1640 (gnus-check-backend-function
1641 'request-expire-articles gnus-newsgroup-name)]
1642 ["Query respool" gnus-summary-respool-query t]
1643 ["Trace respool" gnus-summary-respool-trace t]
1644 ["Delete expirable articles" gnus-summary-expire-articles-now
1645 (gnus-check-backend-function
1646 'request-expire-articles gnus-newsgroup-name)])
1648 ["Uudecode" gnus-uu-decode-uu t]
1649 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1650 ["Unshar" gnus-uu-decode-unshar t]
1651 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1652 ["Save" gnus-uu-decode-save t]
1653 ["Binhex" gnus-uu-decode-binhex t]
1654 ["Postscript" gnus-uu-decode-postscript t])
1656 ["Enter article" gnus-cache-enter-article t]
1657 ["Remove article" gnus-cache-remove-article t])
1658 ["Select article buffer" gnus-summary-select-article-buffer t]
1659 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1660 ["Isearch article..." gnus-summary-isearch-article t]
1661 ["Beginning of the article" gnus-summary-beginning-of-article t]
1662 ["End of the article" gnus-summary-end-of-article t]
1663 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1664 ["Fetch referenced articles" gnus-summary-refer-references t]
1665 ["Fetch current thread" gnus-summary-refer-thread t]
1666 ["Fetch article with id..." gnus-summary-refer-article t]
1667 ["Redisplay" gnus-summary-show-article t])))
1669 gnus-summary-article-menu gnus-summary-mode-map ""
1670 (cons "Article" innards))
1673 gnus-article-commands-menu gnus-article-mode-map ""
1674 (cons "Commands" innards)))
1677 gnus-summary-thread-menu gnus-summary-mode-map ""
1679 ["Toggle threading" gnus-summary-toggle-threads t]
1680 ["Hide threads" gnus-summary-hide-all-threads t]
1681 ["Show threads" gnus-summary-show-all-threads t]
1682 ["Hide thread" gnus-summary-hide-thread t]
1683 ["Show thread" gnus-summary-show-thread t]
1684 ["Go to next thread" gnus-summary-next-thread t]
1685 ["Go to previous thread" gnus-summary-prev-thread t]
1686 ["Go down thread" gnus-summary-down-thread t]
1687 ["Go up thread" gnus-summary-up-thread t]
1688 ["Top of thread" gnus-summary-top-thread t]
1689 ["Mark thread as read" gnus-summary-kill-thread t]
1690 ["Lower thread score" gnus-summary-lower-thread t]
1691 ["Raise thread score" gnus-summary-raise-thread t]
1692 ["Rethread current" gnus-summary-rethread-current t]
1696 gnus-summary-post-menu gnus-summary-mode-map ""
1698 ["Post an article" gnus-summary-post-news t]
1699 ["Followup" gnus-summary-followup t]
1700 ["Followup and yank" gnus-summary-followup-with-original t]
1701 ["Supersede article" gnus-summary-supersede-article t]
1702 ["Cancel article" gnus-summary-cancel-article t]
1703 ["Reply" gnus-summary-reply t]
1704 ["Reply and yank" gnus-summary-reply-with-original t]
1705 ["Wide reply" gnus-summary-wide-reply t]
1706 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1707 ["Mail forward" gnus-summary-mail-forward t]
1708 ["Post forward" gnus-summary-post-forward t]
1709 ["Digest and mail" gnus-summary-mail-digest t]
1710 ["Digest and post" gnus-summary-post-digest t]
1711 ["Resend message" gnus-summary-resend-message t]
1712 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1713 ["Send a mail" gnus-summary-mail-other-window t]
1714 ["Uuencode and post" gnus-uu-post-news t]
1715 ["Followup via news" gnus-summary-followup-to-mail t]
1716 ["Followup via news and yank"
1717 gnus-summary-followup-to-mail-with-original t]
1719 ;;["Send" gnus-summary-send-draft t]
1720 ;;["Send bounced" gnus-resend-bounced-mail t])
1724 gnus-summary-misc-menu gnus-summary-mode-map ""
1727 ["Mark as read" gnus-summary-mark-as-read-forward t]
1728 ["Mark same subject and select"
1729 gnus-summary-kill-same-subject-and-select t]
1730 ["Mark same subject" gnus-summary-kill-same-subject t]
1731 ["Catchup" gnus-summary-catchup t]
1732 ["Catchup all" gnus-summary-catchup-all t]
1733 ["Catchup to here" gnus-summary-catchup-to-here t]
1734 ["Catchup region" gnus-summary-mark-region-as-read t]
1735 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1737 ["Tick" gnus-summary-tick-article-forward t]
1738 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1739 ["Remove marks" gnus-summary-clear-mark-forward t]
1740 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1741 ["Set bookmark" gnus-summary-set-bookmark t]
1742 ["Remove bookmark" gnus-summary-remove-bookmark t])
1744 ["Marks..." gnus-summary-limit-to-marks t]
1745 ["Subject..." gnus-summary-limit-to-subject t]
1746 ["Author..." gnus-summary-limit-to-author t]
1747 ["Age..." gnus-summary-limit-to-age t]
1748 ["Score" gnus-summary-limit-to-score t]
1749 ["Unread" gnus-summary-limit-to-unread t]
1750 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1751 ["Articles" gnus-summary-limit-to-articles t]
1752 ["Pop limit" gnus-summary-pop-limit t]
1753 ["Show dormant" gnus-summary-limit-include-dormant t]
1754 ["Hide childless dormant"
1755 gnus-summary-limit-exclude-childless-dormant t]
1756 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1757 ["Hide marked" gnus-summary-limit-exclude-marks t]
1758 ["Show expunged" gnus-summary-show-all-expunged t])
1760 ["Set mark" gnus-summary-mark-as-processable t]
1761 ["Remove mark" gnus-summary-unmark-as-processable t]
1762 ["Remove all marks" gnus-summary-unmark-all-processable t]
1763 ["Mark above" gnus-uu-mark-over t]
1764 ["Mark series" gnus-uu-mark-series t]
1765 ["Mark region" gnus-uu-mark-region t]
1766 ["Unmark region" gnus-uu-unmark-region t]
1767 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1768 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1769 ["Mark all" gnus-uu-mark-all t]
1770 ["Mark buffer" gnus-uu-mark-buffer t]
1771 ["Mark sparse" gnus-uu-mark-sparse t]
1772 ["Mark thread" gnus-uu-mark-thread t]
1773 ["Unmark thread" gnus-uu-unmark-thread t]
1774 ("Process Mark Sets"
1775 ["Kill" gnus-summary-kill-process-mark t]
1776 ["Yank" gnus-summary-yank-process-mark
1777 gnus-newsgroup-process-stack]
1778 ["Save" gnus-summary-save-process-mark t]))
1780 ["Page forward" gnus-summary-next-page t]
1781 ["Page backward" gnus-summary-prev-page t]
1782 ["Line forward" gnus-summary-scroll-up t])
1784 ["Next unread article" gnus-summary-next-unread-article t]
1785 ["Previous unread article" gnus-summary-prev-unread-article t]
1786 ["Next article" gnus-summary-next-article t]
1787 ["Previous article" gnus-summary-prev-article t]
1788 ["Next unread subject" gnus-summary-next-unread-subject t]
1789 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1790 ["Next article same subject" gnus-summary-next-same-subject t]
1791 ["Previous article same subject" gnus-summary-prev-same-subject t]
1792 ["First unread article" gnus-summary-first-unread-article t]
1793 ["Best unread article" gnus-summary-best-unread-article t]
1794 ["Go to subject number..." gnus-summary-goto-subject t]
1795 ["Go to article number..." gnus-summary-goto-article t]
1796 ["Go to the last article" gnus-summary-goto-last-article t]
1797 ["Pop article off history" gnus-summary-pop-article t])
1799 ["Sort by number" gnus-summary-sort-by-number t]
1800 ["Sort by author" gnus-summary-sort-by-author t]
1801 ["Sort by subject" gnus-summary-sort-by-subject t]
1802 ["Sort by date" gnus-summary-sort-by-date t]
1803 ["Sort by score" gnus-summary-sort-by-score t]
1804 ["Sort by lines" gnus-summary-sort-by-lines t]
1805 ["Sort by characters" gnus-summary-sort-by-chars t])
1807 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1808 ["Describe group" gnus-summary-describe-group t]
1809 ["Read manual" gnus-info-find-node t])
1811 ["Pick and read" gnus-pick-mode t]
1812 ["Binary" gnus-binary-mode t])
1814 ["Regenerate" gnus-summary-prepare t]
1815 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1816 ["Toggle threading" gnus-summary-toggle-threads t])
1817 ["Filter articles..." gnus-summary-execute-command t]
1818 ["Run command on subjects..." gnus-summary-universal-argument t]
1819 ["Search articles forward..." gnus-summary-search-article-forward t]
1820 ["Search articles backward..." gnus-summary-search-article-backward t]
1821 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1822 ["Expand window" gnus-summary-expand-window t]
1823 ["Expire expirable articles" gnus-summary-expire-articles
1824 (gnus-check-backend-function
1825 'request-expire-articles gnus-newsgroup-name)]
1826 ["Edit local kill file" gnus-summary-edit-local-kill t]
1827 ["Edit main kill file" gnus-summary-edit-global-kill t]
1828 ["Edit group parameters" gnus-summary-edit-parameters t]
1829 ["Customize group parameters" gnus-summary-customize-parameters t]
1830 ["Send a bug report" gnus-bug t]
1832 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1833 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
1834 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1835 ["Exit group" gnus-summary-exit t]
1836 ["Exit group without updating" gnus-summary-exit-no-update t]
1837 ["Exit and goto next group" gnus-summary-next-group t]
1838 ["Exit and goto prev group" gnus-summary-prev-group t]
1839 ["Reselect group" gnus-summary-reselect-current-group t]
1840 ["Rescan group" gnus-summary-rescan-group t]
1841 ["Update dribble" gnus-summary-save-newsrc t])))
1843 (gnus-run-hooks 'gnus-summary-menu-hook)))
1845 (defun gnus-score-set-default (var value)
1846 "A version of set that updates the GNU Emacs menu-bar."
1848 ;; It is the message that forces the active status to be updated.
1851 (defun gnus-make-score-map (type)
1852 "Make a summary score map of type TYPE."
1855 (let ((headers '(("author" "from" string)
1856 ("subject" "subject" string)
1857 ("article body" "body" string)
1858 ("article head" "head" string)
1859 ("xref" "xref" string)
1860 ("extra header" "extra" string)
1861 ("lines" "lines" number)
1862 ("followups to author" "followup" string)))
1863 (types '((number ("less than" <)
1866 (string ("substring" s)
1870 (perms '(("temporary" (current-time-string))
1878 (if (eq type 'lower)
1883 (setq header (car headers))
1889 (let ((ts (cdr (assoc (nth 2 header) types)))
1905 'gnus-summary-score-entry
1907 (if (or (string= (nth 1 header)
1909 (string= (nth 1 header)
1912 (list 'gnus-summary-header
1914 (list 'quote (nth 1 (car ts)))
1915 (list 'gnus-score-default nil)
1921 (list (nreverse outp))))
1924 (list (nreverse outt))))
1926 (setq headers (cdr headers)))
1927 (list (nreverse outh))))))))
1931 (defun gnus-summary-mode (&optional group)
1932 "Major mode for reading articles.
1934 All normal editing commands are switched off.
1935 \\<gnus-summary-mode-map>
1936 Each line in this buffer represents one article. To read an
1937 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
1938 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
1941 You can also post articles and send mail from this buffer. To
1942 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
1943 of an article, type `\\[gnus-summary-reply]'.
1945 There are approx. one gazillion commands you can execute in this
1946 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
1948 The following commands are available:
1950 \\{gnus-summary-mode-map}"
1952 (when (gnus-visual-p 'summary-menu 'menu)
1953 (gnus-summary-make-menu-bar))
1954 (kill-all-local-variables)
1955 (gnus-summary-make-local-variables)
1956 (gnus-make-thread-indent-array)
1957 (gnus-simplify-mode-line)
1958 (setq major-mode 'gnus-summary-mode)
1959 (setq mode-name "Summary")
1960 (make-local-variable 'minor-mode-alist)
1961 (use-local-map gnus-summary-mode-map)
1962 (buffer-disable-undo)
1963 (setq buffer-read-only t) ;Disable modification
1964 (setq truncate-lines t)
1965 (setq selective-display t)
1966 (setq selective-display-ellipses t) ;Display `...'
1967 (gnus-summary-set-display-table)
1968 (gnus-set-default-directory)
1969 (setq gnus-newsgroup-name group)
1970 (make-local-variable 'gnus-summary-line-format)
1971 (make-local-variable 'gnus-summary-line-format-spec)
1972 (make-local-variable 'gnus-summary-dummy-line-format)
1973 (make-local-variable 'gnus-summary-dummy-line-format-spec)
1974 (make-local-variable 'gnus-summary-mark-positions)
1975 (make-local-hook 'pre-command-hook)
1976 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
1977 (gnus-run-hooks 'gnus-summary-mode-hook)
1978 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
1979 (gnus-update-summary-mark-positions))
1981 (defun gnus-summary-make-local-variables ()
1982 "Make all the local summary buffer variables."
1984 (dolist (local gnus-summary-local-variables)
1987 (if (eq (cdr local) 'global)
1988 ;; Copy the global value of the variable.
1989 (setq global (symbol-value (car local)))
1990 ;; Use the value from the list.
1991 (setq global (eval (cdr local))))
1992 (set (make-local-variable (car local)) global))
1993 ;; Simple nil-valued local variable.
1994 (set (make-local-variable local) nil)))))
1996 (defun gnus-summary-clear-local-variables ()
1997 (let ((locals gnus-summary-local-variables))
1999 (if (consp (car locals))
2000 (and (vectorp (caar locals))
2001 (set (caar locals) nil))
2002 (and (vectorp (car locals))
2003 (set (car locals) nil)))
2004 (setq locals (cdr locals)))))
2006 ;; Summary data functions.
2008 (defmacro gnus-data-number (data)
2011 (defmacro gnus-data-set-number (data number)
2012 `(setcar ,data ,number))
2014 (defmacro gnus-data-mark (data)
2017 (defmacro gnus-data-set-mark (data mark)
2018 `(setcar (nthcdr 1 ,data) ,mark))
2020 (defmacro gnus-data-pos (data)
2023 (defmacro gnus-data-set-pos (data pos)
2024 `(setcar (nthcdr 2 ,data) ,pos))
2026 (defmacro gnus-data-header (data)
2029 (defmacro gnus-data-set-header (data header)
2030 `(setf (nth 3 ,data) ,header))
2032 (defmacro gnus-data-level (data)
2035 (defmacro gnus-data-unread-p (data)
2036 `(= (nth 1 ,data) gnus-unread-mark))
2038 (defmacro gnus-data-read-p (data)
2039 `(/= (nth 1 ,data) gnus-unread-mark))
2041 (defmacro gnus-data-pseudo-p (data)
2042 `(consp (nth 3 ,data)))
2044 (defmacro gnus-data-find (number)
2045 `(assq ,number gnus-newsgroup-data))
2047 (defmacro gnus-data-find-list (number &optional data)
2048 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2049 (memq (assq ,number bdata)
2052 (defmacro gnus-data-make (number mark pos header level)
2053 `(list ,number ,mark ,pos ,header ,level))
2055 (defun gnus-data-enter (after-article number mark pos header level offset)
2056 (let ((data (gnus-data-find-list after-article)))
2058 (error "No such article: %d" after-article))
2059 (setcdr data (cons (gnus-data-make number mark pos header level)
2061 (setq gnus-newsgroup-data-reverse nil)
2062 (gnus-data-update-list (cddr data) offset)))
2064 (defun gnus-data-enter-list (after-article list &optional offset)
2066 (let ((data (and after-article (gnus-data-find-list after-article)))
2070 (let ((odata gnus-newsgroup-data))
2071 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2073 (gnus-data-update-list odata offset)))
2074 ;; Find the last element in the list to be spliced into the main
2077 (setq list (cdr list)))
2080 (setcdr list gnus-newsgroup-data)
2081 (setq gnus-newsgroup-data ilist)
2083 (gnus-data-update-list (cdr list) offset)))
2084 (setcdr list (cdr data))
2087 (gnus-data-update-list (cdr list) offset))))
2088 (setq gnus-newsgroup-data-reverse nil))))
2090 (defun gnus-data-remove (article &optional offset)
2091 (let ((data gnus-newsgroup-data))
2092 (if (= (gnus-data-number (car data)) article)
2094 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2095 gnus-newsgroup-data-reverse nil)
2097 (gnus-data-update-list gnus-newsgroup-data offset)))
2099 (when (= (gnus-data-number (cadr data)) article)
2100 (setcdr data (cddr data))
2102 (gnus-data-update-list (cdr data) offset))
2104 gnus-newsgroup-data-reverse nil))
2105 (setq data (cdr data))))))
2107 (defmacro gnus-data-list (backward)
2109 (or gnus-newsgroup-data-reverse
2110 (setq gnus-newsgroup-data-reverse
2111 (reverse gnus-newsgroup-data)))
2112 gnus-newsgroup-data))
2114 (defun gnus-data-update-list (data offset)
2115 "Add OFFSET to the POS of all data entries in DATA."
2116 (setq gnus-newsgroup-data-reverse nil)
2118 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2119 (setq data (cdr data))))
2121 (defun gnus-summary-article-pseudo-p (article)
2122 "Say whether this article is a pseudo article or not."
2123 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2125 (defmacro gnus-summary-article-sparse-p (article)
2126 "Say whether this article is a sparse article or not."
2127 `(memq ,article gnus-newsgroup-sparse))
2129 (defmacro gnus-summary-article-ancient-p (article)
2130 "Say whether this article is a sparse article or not."
2131 `(memq ,article gnus-newsgroup-ancient))
2133 (defun gnus-article-parent-p (number)
2134 "Say whether this article is a parent or not."
2135 (let ((data (gnus-data-find-list number)))
2136 (and (cdr data) ; There has to be an article after...
2137 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2138 (gnus-data-level (nth 1 data))))))
2140 (defun gnus-article-children (number)
2141 "Return a list of all children to NUMBER."
2142 (let* ((data (gnus-data-find-list number))
2143 (level (gnus-data-level (car data)))
2145 (setq data (cdr data))
2147 (= (gnus-data-level (car data)) (1+ level)))
2148 (push (gnus-data-number (car data)) children)
2149 (setq data (cdr data)))
2152 (defmacro gnus-summary-skip-intangible ()
2153 "If the current article is intangible, then jump to a different article."
2154 '(let ((to (get-text-property (point) 'gnus-intangible)))
2155 (and to (gnus-summary-goto-subject to))))
2157 (defmacro gnus-summary-article-intangible-p ()
2158 "Say whether this article is intangible or not."
2159 '(get-text-property (point) 'gnus-intangible))
2161 (defun gnus-article-read-p (article)
2162 "Say whether ARTICLE is read or not."
2163 (not (or (memq article gnus-newsgroup-marked)
2164 (memq article gnus-newsgroup-unreads)
2165 (memq article gnus-newsgroup-unselected)
2166 (memq article gnus-newsgroup-dormant))))
2168 ;; Some summary mode macros.
2170 (defmacro gnus-summary-article-number ()
2171 "The article number of the article on the current line.
2172 If there isn's an article number here, then we return the current
2175 (gnus-summary-skip-intangible)
2176 (or (get-text-property (point) 'gnus-number)
2177 (gnus-summary-last-subject))))
2179 (defmacro gnus-summary-article-header (&optional number)
2180 "Return the header of article NUMBER."
2181 `(gnus-data-header (gnus-data-find
2182 ,(or number '(gnus-summary-article-number)))))
2184 (defmacro gnus-summary-thread-level (&optional number)
2185 "Return the level of thread that starts with article NUMBER."
2186 `(if (and (eq gnus-summary-make-false-root 'dummy)
2187 (get-text-property (point) 'gnus-intangible))
2189 (gnus-data-level (gnus-data-find
2190 ,(or number '(gnus-summary-article-number))))))
2192 (defmacro gnus-summary-article-mark (&optional number)
2193 "Return the mark of article NUMBER."
2194 `(gnus-data-mark (gnus-data-find
2195 ,(or number '(gnus-summary-article-number)))))
2197 (defmacro gnus-summary-article-pos (&optional number)
2198 "Return the position of the line of article NUMBER."
2199 `(gnus-data-pos (gnus-data-find
2200 ,(or number '(gnus-summary-article-number)))))
2202 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2203 (defmacro gnus-summary-article-subject (&optional number)
2204 "Return current subject string or nil if nothing."
2207 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2208 '(gnus-data-header (assq (gnus-summary-article-number)
2209 gnus-newsgroup-data)))))
2212 (mail-header-subject headers))))
2214 (defmacro gnus-summary-article-score (&optional number)
2215 "Return current article score."
2216 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2217 gnus-newsgroup-scored))
2218 gnus-summary-default-score 0))
2220 (defun gnus-summary-article-children (&optional number)
2221 "Return a list of article numbers that are children of article NUMBER."
2222 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2223 (level (gnus-data-level (car data)))
2225 (while (and (setq data (cdr data))
2226 (> (setq l (gnus-data-level (car data))) level))
2227 (and (= (1+ level) l)
2228 (push (gnus-data-number (car data))
2230 (nreverse children)))
2232 (defun gnus-summary-article-parent (&optional number)
2233 "Return the article number of the parent of article NUMBER."
2234 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2235 (gnus-data-list t)))
2236 (level (gnus-data-level (car data))))
2238 () ; This is a root.
2239 ;; We search until we find an article with a level less than
2240 ;; this one. That function has to be the parent.
2241 (while (and (setq data (cdr data))
2242 (not (< (gnus-data-level (car data)) level))))
2243 (and data (gnus-data-number (car data))))))
2245 (defun gnus-unread-mark-p (mark)
2246 "Say whether MARK is the unread mark."
2247 (= mark gnus-unread-mark))
2249 (defun gnus-read-mark-p (mark)
2250 "Say whether MARK is one of the marks that mark as read.
2251 This is all marks except unread, ticked, dormant, and expirable."
2252 (not (or (= mark gnus-unread-mark)
2253 (= mark gnus-ticked-mark)
2254 (= mark gnus-dormant-mark)
2255 (= mark gnus-expirable-mark))))
2257 (defmacro gnus-article-mark (number)
2258 "Return the MARK of article NUMBER.
2259 This macro should only be used when computing the mark the \"first\"
2260 time; i.e., when generating the summary lines. After that,
2261 `gnus-summary-article-mark' should be used to examine the
2264 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2265 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2266 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2267 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2268 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2269 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2270 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2271 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2272 gnus-ancient-mark))))
2274 ;; Saving hidden threads.
2276 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2277 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2279 (defmacro gnus-save-hidden-threads (&rest forms)
2280 "Save hidden threads, eval FORMS, and restore the hidden threads."
2281 (let ((config (make-symbol "config")))
2282 `(let ((,config (gnus-hidden-threads-configuration)))
2286 (gnus-restore-hidden-threads-configuration ,config)))))
2288 (defun gnus-data-compute-positions ()
2289 "Compute the positions of all articles."
2290 (setq gnus-newsgroup-data-reverse nil)
2291 (let ((data gnus-newsgroup-data))
2293 (gnus-save-hidden-threads
2294 (gnus-summary-show-all-threads)
2295 (goto-char (point-min))
2297 (while (get-text-property (point) 'gnus-intangible)
2299 (gnus-data-set-pos (car data) (+ (point) 3))
2300 (setq data (cdr data))
2301 (forward-line 1))))))
2303 (defun gnus-hidden-threads-configuration ()
2304 "Return the current hidden threads configuration."
2307 (goto-char (point-min))
2308 (while (search-forward "\r" nil t)
2309 (push (1- (point)) config))
2312 (defun gnus-restore-hidden-threads-configuration (config)
2313 "Restore hidden threads configuration from CONFIG."
2314 (let (point buffer-read-only)
2315 (while (setq point (pop config))
2316 (when (and (< point (point-max))
2318 (eq (char-after) ?\n))
2319 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2321 ;; Various summary mode internalish functions.
2323 (defun gnus-mouse-pick-article (e)
2326 (gnus-summary-next-page nil t))
2328 (defun gnus-summary-set-display-table ()
2329 ;; Change the display table. Odd characters have a tendency to mess
2330 ;; up nicely formatted displays - we make all possible glyphs
2331 ;; display only a single character.
2333 ;; We start from the standard display table, if any.
2334 (let ((table (or (copy-sequence standard-display-table)
2335 (make-display-table)))
2337 ;; Nix out all the control chars...
2338 (while (>= (setq i (1- i)) 0)
2339 (aset table i [??]))
2340 ;; ... but not newline and cr, of course. (cr is necessary for the
2341 ;; selective display).
2342 (aset table ?\n nil)
2343 (aset table ?\r nil)
2344 ;; We keep TAB as well.
2345 (aset table ?\t nil)
2346 ;; We nix out any glyphs over 126 that are not set already.
2348 (while (>= (setq i (1- i)) 127)
2349 ;; Only modify if the entry is nil.
2350 (unless (aref table i)
2351 (aset table i [??]))))
2352 (setq buffer-display-table table)))
2354 (defun gnus-summary-setup-buffer (group)
2355 "Initialize summary buffer."
2356 (let ((buffer (concat "*Summary " group "*")))
2357 (if (get-buffer buffer)
2360 (setq gnus-summary-buffer (current-buffer))
2361 (not gnus-newsgroup-prepared))
2362 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2363 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2364 (gnus-summary-mode group)
2366 (gnus-carpal-setup-buffer 'summary))
2367 (unless gnus-single-article-buffer
2368 (make-local-variable 'gnus-article-buffer)
2369 (make-local-variable 'gnus-article-current)
2370 (make-local-variable 'gnus-original-article-buffer))
2371 (setq gnus-newsgroup-name group)
2374 (defun gnus-set-global-variables ()
2375 ;; Set the global equivalents of the summary buffer-local variables
2376 ;; to the latest values they had. These reflect the summary buffer
2377 ;; that was in action when the last article was fetched.
2378 (when (eq major-mode 'gnus-summary-mode)
2379 (setq gnus-summary-buffer (current-buffer))
2380 (let ((name gnus-newsgroup-name)
2381 (marked gnus-newsgroup-marked)
2382 (unread gnus-newsgroup-unreads)
2383 (headers gnus-current-headers)
2384 (data gnus-newsgroup-data)
2385 (summary gnus-summary-buffer)
2386 (article-buffer gnus-article-buffer)
2387 (original gnus-original-article-buffer)
2388 (gac gnus-article-current)
2389 (reffed gnus-reffed-article-number)
2390 (score-file gnus-current-score-file)
2391 (default-charset gnus-newsgroup-charset))
2393 (set-buffer gnus-group-buffer)
2394 (setq gnus-newsgroup-name name
2395 gnus-newsgroup-marked marked
2396 gnus-newsgroup-unreads unread
2397 gnus-current-headers headers
2398 gnus-newsgroup-data data
2399 gnus-article-current gac
2400 gnus-summary-buffer summary
2401 gnus-article-buffer article-buffer
2402 gnus-original-article-buffer original
2403 gnus-reffed-article-number reffed
2404 gnus-current-score-file score-file
2405 gnus-newsgroup-charset default-charset)
2406 ;; The article buffer also has local variables.
2407 (when (gnus-buffer-live-p gnus-article-buffer)
2408 (set-buffer gnus-article-buffer)
2409 (setq gnus-summary-buffer summary))))))
2411 (defun gnus-summary-article-unread-p (article)
2412 "Say whether ARTICLE is unread or not."
2413 (memq article gnus-newsgroup-unreads))
2415 (defun gnus-summary-first-article-p (&optional article)
2416 "Return whether ARTICLE is the first article in the buffer."
2417 (if (not (setq article (or article (gnus-summary-article-number))))
2419 (eq article (caar gnus-newsgroup-data))))
2421 (defun gnus-summary-last-article-p (&optional article)
2422 "Return whether ARTICLE is the last article in the buffer."
2423 (if (not (setq article (or article (gnus-summary-article-number))))
2424 ;; All non-existent numbers are the last article. :-)
2426 (not (cdr (gnus-data-find-list article)))))
2428 (defun gnus-make-thread-indent-array ()
2430 (unless (and gnus-thread-indent-array
2431 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2432 (setq gnus-thread-indent-array (make-vector 201 "")
2433 gnus-thread-indent-array-level gnus-thread-indent-level)
2435 (aset gnus-thread-indent-array n
2436 (make-string (* n gnus-thread-indent-level) ? ))
2439 (defun gnus-update-summary-mark-positions ()
2440 "Compute where the summary marks are to go."
2442 (when (gnus-buffer-exists-p gnus-summary-buffer)
2443 (set-buffer gnus-summary-buffer))
2444 (let ((gnus-replied-mark 129)
2445 (gnus-score-below-mark 130)
2446 (gnus-score-over-mark 130)
2447 (gnus-download-mark 131)
2448 (spec gnus-summary-line-format-spec)
2451 (gnus-set-work-buffer)
2452 (let ((gnus-summary-line-format-spec spec)
2453 (gnus-newsgroup-downloadable '((0 . t))))
2454 (gnus-summary-insert-line
2455 (make-full-mail-header 0 "" "" "" "" "" 0 0 "" nil)
2456 0 nil 128 t nil "" nil 1)
2457 (goto-char (point-min))
2458 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2460 (goto-char (point-min))
2461 (push (cons 'replied (and (search-forward "\201" nil t)
2464 (goto-char (point-min))
2465 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2467 (goto-char (point-min))
2468 (push (cons 'download
2469 (and (search-forward "\203" nil t) (- (point) 2)))
2471 (setq gnus-summary-mark-positions pos))))
2473 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2474 "Insert a dummy root in the summary buffer."
2476 (gnus-add-text-properties
2477 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2478 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2480 (defun gnus-summary-from-or-to-or-newsgroups (header)
2481 (let ((to (cdr (assq 'To (mail-header-extra header))))
2482 (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header))))
2483 (mail-parse-charset gnus-newsgroup-charset))
2486 gnus-ignored-from-addresses
2487 (string-match gnus-ignored-from-addresses
2488 (mail-header-from header)))
2490 (or (car (funcall gnus-extract-address-components
2492 gnus-decode-encoded-word-function to)))
2493 (funcall gnus-decode-encoded-word-function to))))
2495 gnus-ignored-from-addresses
2496 (string-match gnus-ignored-from-addresses
2497 (mail-header-from header)))
2498 (concat "=> " newsgroups))
2500 (or (car (funcall gnus-extract-address-components
2501 (mail-header-from header)))
2502 (mail-header-from header))))))
2504 (defun gnus-summary-insert-line (gnus-tmp-header
2505 gnus-tmp-level gnus-tmp-current
2506 gnus-tmp-unread gnus-tmp-replied
2507 gnus-tmp-expirable gnus-tmp-subject-or-nil
2508 &optional gnus-tmp-dummy gnus-tmp-score
2510 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2511 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2512 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2513 (gnus-tmp-score-char
2514 (if (or (null gnus-summary-default-score)
2515 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2516 gnus-summary-zcore-fuzz))
2518 (if (< gnus-tmp-score gnus-summary-default-score)
2519 gnus-score-below-mark gnus-score-over-mark)))
2521 (cond (gnus-tmp-process gnus-process-mark)
2522 ((memq gnus-tmp-current gnus-newsgroup-cached)
2524 (gnus-tmp-replied gnus-replied-mark)
2525 ((memq gnus-tmp-current gnus-newsgroup-saved)
2527 (t gnus-unread-mark)))
2528 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2531 ((string-match "<[^>]+> *$" gnus-tmp-from)
2532 (let ((beg (match-beginning 0)))
2533 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2534 (substring gnus-tmp-from (1+ (match-beginning 0))
2535 (1- (match-end 0))))
2536 (substring gnus-tmp-from 0 beg))))
2537 ((string-match "(.+)" gnus-tmp-from)
2538 (substring gnus-tmp-from
2539 (1+ (match-beginning 0)) (1- (match-end 0))))
2541 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2542 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2543 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2544 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2545 (buffer-read-only nil))
2546 (when (string= gnus-tmp-name "")
2547 (setq gnus-tmp-name gnus-tmp-from))
2548 (unless (numberp gnus-tmp-lines)
2549 (setq gnus-tmp-lines 0))
2550 (gnus-put-text-property-excluding-characters-with-faces
2552 (progn (eval gnus-summary-line-format-spec) (point))
2553 'gnus-number gnus-tmp-number)
2554 (when (gnus-visual-p 'summary-highlight 'highlight)
2556 (gnus-run-hooks 'gnus-summary-update-hook)
2559 (defun gnus-summary-update-line (&optional dont-update)
2560 ;; Update summary line after change.
2561 (when (and gnus-summary-default-score
2562 (not gnus-summary-inhibit-highlight))
2563 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2564 (article (gnus-summary-article-number))
2565 (score (gnus-summary-article-score article)))
2567 (if (and gnus-summary-mark-below
2568 (< (gnus-summary-article-score)
2569 gnus-summary-mark-below))
2570 ;; This article has a low score, so we mark it as read.
2571 (when (memq article gnus-newsgroup-unreads)
2572 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2573 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2574 ;; This article was previously marked as read on account
2575 ;; of a low score, but now it has risen, so we mark it as
2577 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2578 (gnus-summary-update-mark
2579 (if (or (null gnus-summary-default-score)
2580 (<= (abs (- score gnus-summary-default-score))
2581 gnus-summary-zcore-fuzz))
2583 (if (< score gnus-summary-default-score)
2584 gnus-score-below-mark gnus-score-over-mark))
2586 ;; Do visual highlighting.
2587 (when (gnus-visual-p 'summary-highlight 'highlight)
2588 (gnus-run-hooks 'gnus-summary-update-hook)))))
2590 (defvar gnus-tmp-new-adopts nil)
2592 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2593 "Return the number of articles in THREAD.
2594 This may be 0 in some cases -- if none of the articles in
2595 the thread are to be displayed."
2597 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2599 ((not (listp thread))
2601 ((and (consp thread) (cdr thread))
2604 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2607 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2610 (when (and level (zerop level) gnus-tmp-new-adopts)
2613 'gnus-summary-number-of-articles-in-thread
2614 gnus-tmp-new-adopts))))
2616 (if (> number 1) gnus-not-empty-thread-mark
2617 gnus-empty-thread-mark)
2620 (defun gnus-summary-set-local-parameters (group)
2621 "Go through the local params of GROUP and set all variable specs in that list."
2622 (let ((params (gnus-group-find-parameter group))
2625 (setq elem (car params)
2626 params (cdr params))
2627 (and (consp elem) ; Has to be a cons.
2628 (consp (cdr elem)) ; The cdr has to be a list.
2629 (symbolp (car elem)) ; Has to be a symbol in there.
2630 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2631 (ignore-errors ; So we set it.
2632 (make-local-variable (car elem))
2633 (set (car elem) (eval (nth 1 elem))))))))
2635 (defun gnus-summary-read-group (group &optional show-all no-article
2636 kill-buffer no-display backward
2638 "Start reading news in newsgroup GROUP.
2639 If SHOW-ALL is non-nil, already read articles are also listed.
2640 If NO-ARTICLE is non-nil, no article is selected initially.
2641 If NO-DISPLAY, don't generate a summary buffer."
2645 (let ((gnus-auto-select-next nil))
2646 (or (gnus-summary-read-group-1
2647 group show-all no-article
2648 kill-buffer no-display
2651 select-articles nil)))))
2652 (eq gnus-auto-select-next 'quietly))
2653 (set-buffer gnus-group-buffer)
2654 ;; The entry function called above goes to the next
2655 ;; group automatically, so we go two groups back
2656 ;; if we are searching for the previous group.
2658 (gnus-group-prev-unread-group 2))
2659 (if (not (equal group (gnus-group-group-name)))
2660 (setq group (gnus-group-group-name))
2664 (defun gnus-summary-read-group-1 (group show-all no-article
2665 kill-buffer no-display
2666 &optional select-articles)
2667 ;; Killed foreign groups can't be entered.
2668 (when (and (not (gnus-group-native-p group))
2669 (not (gnus-gethash group gnus-newsrc-hashtb)))
2670 (error "Dead non-native groups can't be entered"))
2671 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2672 (let* ((new-group (gnus-summary-setup-buffer group))
2673 (quit-config (gnus-group-quit-config group))
2674 (did-select (and new-group (gnus-select-newsgroup
2675 group show-all select-articles))))
2677 ;; This summary buffer exists already, so we just select it.
2679 (gnus-set-global-variables)
2681 (gnus-kill-or-deaden-summary kill-buffer))
2682 (gnus-configure-windows 'summary 'force)
2683 (gnus-set-mode-line 'summary)
2684 (gnus-summary-position-point)
2687 ;; We couldn't select this group.
2689 (when (and (eq major-mode 'gnus-summary-mode)
2690 (not (equal (current-buffer) kill-buffer)))
2691 (kill-buffer (current-buffer))
2692 (if (not quit-config)
2694 ;; Update the info -- marks might need to be removed,
2696 (gnus-summary-update-info)
2697 (set-buffer gnus-group-buffer)
2698 (gnus-group-jump-to-group group)
2699 (gnus-group-next-unread-group 1))
2700 (gnus-handle-ephemeral-exit quit-config)))
2701 (gnus-message 3 "Can't select group")
2703 ;; The user did a `C-g' while prompting for number of articles,
2704 ;; so we exit this group.
2705 ((eq did-select 'quit)
2706 (and (eq major-mode 'gnus-summary-mode)
2707 (not (equal (current-buffer) kill-buffer))
2708 (kill-buffer (current-buffer)))
2710 (gnus-kill-or-deaden-summary kill-buffer))
2711 (if (not quit-config)
2713 (set-buffer gnus-group-buffer)
2714 (gnus-group-jump-to-group group)
2715 (gnus-group-next-unread-group 1)
2716 (gnus-configure-windows 'group 'force))
2717 (gnus-handle-ephemeral-exit quit-config))
2718 ;; Finally signal the quit.
2720 ;; The group was successfully selected.
2722 (gnus-set-global-variables)
2723 ;; Save the active value in effect when the group was entered.
2724 (setq gnus-newsgroup-active
2726 (gnus-active gnus-newsgroup-name)))
2727 ;; You can change the summary buffer in some way with this hook.
2728 (gnus-run-hooks 'gnus-select-group-hook)
2729 ;; Set any local variables in the group parameters.
2730 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2731 (gnus-update-format-specifications
2732 nil 'summary 'summary-mode 'summary-dummy)
2733 ;; Do score processing.
2734 (when gnus-use-scoring
2735 (gnus-possibly-score-headers))
2736 ;; Check whether to fill in the gaps in the threads.
2737 (when gnus-build-sparse-threads
2738 (gnus-build-sparse-threads))
2739 ;; Find the initial limit.
2740 (if gnus-show-threads
2742 (let ((gnus-newsgroup-dormant nil))
2743 (gnus-summary-initial-limit show-all))
2744 (gnus-summary-initial-limit show-all))
2745 (setq gnus-newsgroup-limit
2747 (lambda (header) (mail-header-number header))
2748 gnus-newsgroup-headers)))
2749 ;; Generate the summary buffer.
2751 (gnus-summary-prepare))
2752 (when gnus-use-trees
2753 (gnus-tree-open group)
2754 (setq gnus-summary-highlight-line-function
2755 'gnus-tree-highlight-article))
2756 ;; If the summary buffer is empty, but there are some low-scored
2757 ;; articles or some excluded dormants, we include these in the
2759 (when (and (zerop (buffer-size))
2761 (cond (gnus-newsgroup-dormant
2762 (gnus-summary-limit-include-dormant))
2763 ((and gnus-newsgroup-scored show-all)
2764 (gnus-summary-limit-include-expunged t))))
2765 ;; Function `gnus-apply-kill-file' must be called in this hook.
2766 (gnus-run-hooks 'gnus-apply-kill-hook)
2767 (if (and (zerop (buffer-size))
2770 ;; This newsgroup is empty.
2771 (gnus-summary-catchup-and-exit nil t)
2772 (gnus-message 6 "No unread news")
2774 (gnus-kill-or-deaden-summary kill-buffer))
2775 ;; Return nil from this function.
2777 ;; Hide conversation thread subtrees. We cannot do this in
2778 ;; gnus-summary-prepare-hook since kill processing may not
2779 ;; work with hidden articles.
2780 (and gnus-show-threads
2781 gnus-thread-hide-subtree
2782 (gnus-summary-hide-all-threads))
2784 (gnus-kill-or-deaden-summary kill-buffer))
2785 ;; Show first unread article if requested.
2786 (if (and (not no-article)
2788 gnus-newsgroup-unreads
2789 gnus-auto-select-first)
2791 (gnus-configure-windows 'summary)
2793 ((eq gnus-auto-select-first 'best)
2794 (gnus-summary-best-unread-article))
2795 ((eq gnus-auto-select-first t)
2796 (gnus-summary-first-unread-article))
2797 ((gnus-functionp gnus-auto-select-first)
2798 (funcall gnus-auto-select-first))))
2799 ;; Don't select any articles, just move point to the first
2800 ;; article in the group.
2801 (goto-char (point-min))
2802 (gnus-summary-position-point)
2803 (gnus-configure-windows 'summary 'force)
2804 (gnus-set-mode-line 'summary))
2805 (when (get-buffer-window gnus-group-buffer t)
2806 ;; Gotta use windows, because recenter does weird stuff if
2807 ;; the current buffer ain't the displayed window.
2808 (let ((owin (selected-window)))
2809 (select-window (get-buffer-window gnus-group-buffer t))
2810 (when (gnus-group-goto-group group)
2812 (select-window owin)))
2813 ;; Mark this buffer as "prepared".
2814 (setq gnus-newsgroup-prepared t)
2815 (gnus-run-hooks 'gnus-summary-prepared-hook)
2818 (defun gnus-summary-prepare ()
2819 "Generate the summary buffer."
2821 (let ((buffer-read-only nil))
2823 (setq gnus-newsgroup-data nil
2824 gnus-newsgroup-data-reverse nil)
2825 (gnus-run-hooks 'gnus-summary-generate-hook)
2826 ;; Generate the buffer, either with threads or without.
2827 (when gnus-newsgroup-headers
2828 (gnus-summary-prepare-threads
2829 (if gnus-show-threads
2830 (gnus-sort-gathered-threads
2831 (funcall gnus-summary-thread-gathering-function
2833 (gnus-cut-threads (gnus-make-threads)))))
2834 ;; Unthreaded display.
2835 (gnus-sort-articles gnus-newsgroup-headers))))
2836 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2837 ;; Call hooks for modifying summary buffer.
2838 (goto-char (point-min))
2839 (gnus-run-hooks 'gnus-summary-prepare-hook)))
2841 (defsubst gnus-general-simplify-subject (subject)
2842 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2845 ;; Truncate the subject.
2846 (gnus-simplify-subject-functions
2847 (gnus-map-function gnus-simplify-subject-functions subject))
2848 ((numberp gnus-summary-gather-subject-limit)
2849 (setq subject (gnus-simplify-subject-re subject))
2850 (if (> (length subject) gnus-summary-gather-subject-limit)
2851 (substring subject 0 gnus-summary-gather-subject-limit)
2853 ;; Fuzzily simplify it.
2854 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2855 (gnus-simplify-subject-fuzzy subject))
2856 ;; Just remove the leading "Re:".
2858 (gnus-simplify-subject-re subject))))
2860 (if (and gnus-summary-gather-exclude-subject
2861 (string-match gnus-summary-gather-exclude-subject subject))
2862 nil ; This article shouldn't be gathered
2865 (defun gnus-summary-simplify-subject-query ()
2866 "Query where the respool algorithm would put this article."
2868 (gnus-summary-select-article)
2869 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2871 (defun gnus-gather-threads-by-subject (threads)
2872 "Gather threads by looking at Subject headers."
2873 (if (not gnus-summary-make-false-root)
2875 (let ((hashtb (gnus-make-hashtable 1024))
2878 subject hthread whole-subject)
2880 (setq subject (gnus-general-simplify-subject
2881 (setq whole-subject (mail-header-subject
2884 (if (setq hthread (gnus-gethash subject hashtb))
2886 ;; We enter a dummy root into the thread, if we
2887 ;; haven't done that already.
2888 (unless (stringp (caar hthread))
2889 (setcar hthread (list whole-subject (car hthread))))
2890 ;; We add this new gathered thread to this gathered
2892 (setcdr (car hthread)
2893 (nconc (cdar hthread) (list (car threads))))
2894 ;; Remove it from the list of threads.
2895 (setcdr prev (cdr threads))
2896 (setq threads prev))
2897 ;; Enter this thread into the hash table.
2898 (gnus-sethash subject threads hashtb)))
2900 (setq threads (cdr threads)))
2903 (defun gnus-gather-threads-by-references (threads)
2904 "Gather threads by looking at References headers."
2905 (let ((idhashtb (gnus-make-hashtable 1024))
2906 (thhashtb (gnus-make-hashtable 1024))
2909 ids references id gthread gid entered ref)
2911 (when (setq references (mail-header-references (caar threads)))
2912 (setq id (mail-header-id (caar threads))
2913 ids (gnus-split-references references)
2915 (while (setq ref (pop ids))
2916 (setq ids (delete ref ids))
2917 (if (not (setq gid (gnus-gethash ref idhashtb)))
2919 (gnus-sethash ref id idhashtb)
2920 (gnus-sethash id threads thhashtb))
2921 (setq gthread (gnus-gethash gid thhashtb))
2923 ;; We enter a dummy root into the thread, if we
2924 ;; haven't done that already.
2925 (unless (stringp (caar gthread))
2926 (setcar gthread (list (mail-header-subject (caar gthread))
2928 ;; We add this new gathered thread to this gathered
2930 (setcdr (car gthread)
2931 (nconc (cdar gthread) (list (car threads)))))
2932 ;; Add it into the thread hash table.
2933 (gnus-sethash id gthread thhashtb)
2935 ;; Remove it from the list of threads.
2936 (setcdr prev (cdr threads))
2937 (setq threads prev))))
2939 (setq threads (cdr threads)))
2942 (defun gnus-sort-gathered-threads (threads)
2943 "Sort subtreads inside each gathered thread by article number."
2944 (let ((result threads))
2946 (when (stringp (caar threads))
2947 (setcdr (car threads)
2948 (sort (cdar threads) 'gnus-thread-sort-by-number)))
2949 (setq threads (cdr threads)))
2952 (defun gnus-thread-loop-p (root thread)
2953 "Say whether ROOT is in THREAD."
2954 (let ((stack (list thread))
2957 (while (setq thread (pop stack))
2958 (setq th (cdr thread))
2960 (not (eq (caar th) root)))
2963 ;; We have found a loop.
2965 (setcdr thread (delq (car th) (cdr thread)))
2966 (if (boundp (setq ref-dep (intern "none"
2967 gnus-newsgroup-dependencies)))
2968 (setcdr (symbol-value ref-dep)
2969 (nconc (cdr (symbol-value ref-dep))
2971 (set ref-dep (list nil (car th))))
2974 ;; Push all the subthreads onto the stack.
2975 (push (cdr thread) stack)))
2978 (defun gnus-make-threads ()
2979 "Go through the dependency hashtb and find the roots. Return all threads."
2981 (while (catch 'infloop
2984 ;; Deal with self-referencing References loops.
2985 (when (and (car (symbol-value refs))
2992 (car (symbol-value refs)) thread))
2993 (cdr (symbol-value refs)))))))
2996 (unless (car (symbol-value refs))
2997 ;; These threads do not refer back to any other articles,
2998 ;; so they're roots.
2999 (setq threads (append (cdr (symbol-value refs)) threads))))
3000 gnus-newsgroup-dependencies)))
3003 ;; Build the thread tree.
3004 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3005 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3007 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3008 if it was already present.
3010 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3011 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3012 Message-IDs will be renamed be renamed to a unique Message-ID before
3015 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3016 (let* ((id (mail-header-id header))
3017 (id-dep (and id (intern id dependencies)))
3018 ref ref-dep ref-header)
3019 ;; Enter this `header' in the `dependencies' table.
3023 ;; The first two cases do the normal part: enter a new `header'
3024 ;; in the `dependencies' table.
3025 ((not (boundp id-dep))
3026 (set id-dep (list header)))
3027 ((null (car (symbol-value id-dep)))
3028 (setcar (symbol-value id-dep) header))
3030 ;; From here the `header' was already present in the
3031 ;; `dependencies' table.
3033 ;; Overrides an existing entry;
3034 ;; just set the header part of the entry.
3035 (setcar (symbol-value id-dep) header))
3037 ;; Renames the existing `header' to a unique Message-ID.
3038 ((not gnus-summary-ignore-duplicates)
3039 ;; An article with this Message-ID has already been seen.
3040 ;; We rename the Message-ID.
3041 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3043 (mail-header-set-id header id))
3045 ;; The last case ignores an existing entry, except it adds any
3046 ;; additional Xrefs (in case the two articles came from different
3048 ;; Also sets `header' to `nil' meaning that the `dependencies'
3049 ;; table was *not* modified.
3051 (mail-header-set-xref
3052 (car (symbol-value id-dep))
3053 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3055 (or (mail-header-xref header) "")))
3059 ;; First check if that we are not creating a References loop.
3060 (setq ref (gnus-parent-id (mail-header-references header)))
3062 (setq ref-dep (intern-soft ref dependencies))
3064 (setq ref-header (car (symbol-value ref-dep))))
3065 (if (string= id ref)
3066 ;; Yuk! This is a reference loop. Make the article be a
3069 (mail-header-set-references (car (symbol-value id-dep)) "none")
3071 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3072 (setq ref (gnus-parent-id (mail-header-references header)))
3073 (setq ref-dep (intern (or ref "none") dependencies))
3074 (if (boundp ref-dep)
3075 (setcdr (symbol-value ref-dep)
3076 (nconc (cdr (symbol-value ref-dep))
3077 (list (symbol-value id-dep))))
3078 (set ref-dep (list nil (symbol-value id-dep)))))
3081 (defun gnus-build-sparse-threads ()
3082 (let ((headers gnus-newsgroup-headers)
3083 (gnus-summary-ignore-duplicates t)
3084 header references generation relations
3085 subject child end new-child date)
3086 ;; First we create an alist of generations/relations, where
3087 ;; generations is how much we trust the relation, and the relation
3089 (gnus-message 7 "Making sparse threads...")
3091 (nnheader-set-temp-buffer " *gnus sparse threads*")
3092 (while (setq header (pop headers))
3093 (when (and (setq references (mail-header-references header))
3094 (not (string= references "")))
3096 (setq child (mail-header-id header)
3097 subject (mail-header-subject header)
3098 date (mail-header-date header)
3100 (while (search-backward ">" nil t)
3101 (setq end (1+ (point)))
3102 (when (search-backward "<" nil t)
3103 (setq new-child (buffer-substring (point) end))
3104 (push (list (incf generation)
3105 child (setq child new-child)
3109 (push (list (1+ generation) child nil subject) relations))
3111 (kill-buffer (current-buffer)))
3112 ;; Sort over trustworthiness.
3115 (when (gnus-dependencies-add-header
3116 (make-full-mail-header
3117 gnus-reffed-article-number
3118 (nth 3 relation) "" (or (nth 4 relation) "")
3120 (or (nth 2 relation) "") 0 0 "")
3121 gnus-newsgroup-dependencies nil)
3122 (push gnus-reffed-article-number gnus-newsgroup-limit)
3123 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3124 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3125 gnus-newsgroup-reads)
3126 (decf gnus-reffed-article-number)))
3127 (sort relations 'car-less-than-car))
3128 (gnus-message 7 "Making sparse threads...done")))
3130 (defun gnus-build-old-threads ()
3131 ;; Look at all the articles that refer back to old articles, and
3132 ;; fetch the headers for the articles that aren't there. This will
3133 ;; build complete threads - if the roots haven't been expired by the
3138 (when (not (car (symbol-value refs)))
3139 (setq heads (cdr (symbol-value refs)))
3141 (if (memq (mail-header-number (caar heads))
3142 gnus-newsgroup-dormant)
3143 (setq heads (cdr heads))
3144 (setq id (symbol-name refs))
3145 (while (and (setq id (gnus-build-get-header id))
3146 (not (car (gnus-id-to-thread id)))))
3147 (setq heads nil)))))
3148 gnus-newsgroup-dependencies)))
3150 ;; This function has to be called with point after the article number
3151 ;; on the beginning of the line.
3152 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3153 (let ((eol (gnus-point-at-eol))
3154 (buffer (current-buffer))
3157 ;; overview: [num subject from date id refs chars lines misc]
3162 (make-full-mail-header
3164 (nnheader-nov-field) ; subject
3165 (nnheader-nov-field) ; from
3166 (nnheader-nov-field) ; date
3167 (nnheader-nov-read-message-id) ; id
3168 (nnheader-nov-field) ; refs
3169 (nnheader-nov-read-integer) ; chars
3170 (nnheader-nov-read-integer) ; lines
3172 (nnheader-nov-field)) ; misc
3173 (nnheader-nov-parse-extra))) ; extra
3175 (when gnus-alter-header-function
3176 (funcall gnus-alter-header-function header))
3177 (gnus-dependencies-add-header header dependencies force-new)))
3179 (defun gnus-build-get-header (id)
3180 ;; Look through the buffer of NOV lines and find the header to
3181 ;; ID. Enter this line into the dependencies hash table, and return
3182 ;; the id of the parent article (if any).
3183 (let ((deps gnus-newsgroup-dependencies)
3187 (set-buffer nntp-server-buffer)
3188 (let ((case-fold-search nil))
3189 (goto-char (point-min))
3190 (while (and (not found)
3191 (search-forward id nil t))
3193 (setq found (looking-at
3194 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3195 (regexp-quote id))))
3196 (or found (beginning-of-line 2)))
3200 (setq header (gnus-nov-parse-line
3201 (read (current-buffer)) deps))
3202 (gnus-parent-id (mail-header-references header))))))
3204 (let ((number (mail-header-number header)))
3205 (push number gnus-newsgroup-limit)
3206 (push header gnus-newsgroup-headers)
3207 (if (memq number gnus-newsgroup-unselected)
3209 (push number gnus-newsgroup-unreads)
3210 (setq gnus-newsgroup-unselected
3211 (delq number gnus-newsgroup-unselected)))
3212 (push number gnus-newsgroup-ancient)))))))
3214 (defun gnus-build-all-threads ()
3215 "Read all the headers."
3216 (let ((gnus-summary-ignore-duplicates t)
3217 (dependencies gnus-newsgroup-dependencies)
3220 (set-buffer nntp-server-buffer)
3221 (let ((case-fold-search nil))
3222 (goto-char (point-min))
3225 (setq article (read (current-buffer))
3226 header (gnus-nov-parse-line
3227 article dependencies)))
3230 (set-buffer gnus-summary-buffer)
3231 (push header gnus-newsgroup-headers)
3232 (if (memq (setq article (mail-header-number header))
3233 gnus-newsgroup-unselected)
3235 (push article gnus-newsgroup-unreads)
3236 (setq gnus-newsgroup-unselected
3237 (delq article gnus-newsgroup-unselected)))
3238 (push article gnus-newsgroup-ancient)))
3239 (forward-line 1)))))))
3241 (defun gnus-summary-update-article-line (article header)
3242 "Update the line for ARTICLE using HEADERS."
3243 (let* ((id (mail-header-id header))
3244 (thread (gnus-id-to-thread id)))
3246 (error "Article in no thread"))
3247 ;; Update the thread.
3248 (setcar thread header)
3249 (gnus-summary-goto-subject article)
3250 (let* ((datal (gnus-data-find-list article))
3252 (length (when (cdr datal)
3253 (- (gnus-data-pos data)
3254 (gnus-data-pos (cadr datal)))))
3255 (buffer-read-only nil)
3256 (level (gnus-summary-thread-level)))
3258 (gnus-summary-insert-line
3259 header level nil (gnus-article-mark article)
3260 (memq article gnus-newsgroup-replied)
3261 (memq article gnus-newsgroup-expirable)
3262 ;; Only insert the Subject string when it's different
3263 ;; from the previous Subject string.
3264 (if (gnus-subject-equal
3266 (mail-header-subject
3269 (gnus-data-find-list
3271 (gnus-data-list t)))))
3272 ;; Error on the side of excessive subjects.
3274 (mail-header-subject header))
3276 (mail-header-subject header))
3277 nil (cdr (assq article gnus-newsgroup-scored))
3278 (memq article gnus-newsgroup-processable))
3280 (gnus-data-update-list
3281 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3283 (defun gnus-summary-update-article (article &optional iheader)
3284 "Update ARTICLE in the summary buffer."
3285 (set-buffer gnus-summary-buffer)
3286 (let* ((header (gnus-summary-article-header article))
3287 (id (mail-header-id header))
3288 (data (gnus-data-find article))
3289 (thread (gnus-id-to-thread id))
3290 (references (mail-header-references header))
3294 (when (and references
3295 (not (equal "" references)))
3298 (buffer-read-only nil)
3304 (delq thread parent)))
3305 (if (gnus-summary-insert-subject id header)
3306 ;; Set the (possibly) new article number in the data structure.
3307 (gnus-data-set-number data (gnus-id-to-article id))
3311 (defun gnus-rebuild-thread (id &optional line)
3312 "Rebuild the thread containing ID.
3313 If LINE, insert the rebuilt thread starting on line LINE."
3314 (let ((buffer-read-only nil)
3315 old-pos current thread data)
3316 (if (not gnus-show-threads)
3317 (setq thread (list (car (gnus-id-to-thread id))))
3318 ;; Get the thread this article is part of.
3319 (setq thread (gnus-remove-thread id)))
3320 (setq old-pos (gnus-point-at-bol))
3321 (setq current (save-excursion
3322 (and (zerop (forward-line -1))
3323 (gnus-summary-article-number))))
3324 ;; If this is a gathered thread, we have to go some re-gathering.
3325 (when (stringp (car thread))
3326 (let ((subject (car thread))
3328 (setq thread (cdr thread))
3330 (unless (memq (setq thr (gnus-id-to-thread
3332 (mail-header-id (caar thread)))))
3335 (setq thread (cdr thread)))
3336 ;; We now have all (unique) roots.
3337 (if (= (length roots) 1)
3338 ;; All the loose roots are now one solid root.
3339 (setq thread (car roots))
3340 (setq thread (cons subject (gnus-sort-threads roots))))))
3342 ;; We then insert this thread into the summary buffer.
3344 (goto-char (point-min))
3345 (forward-line (1- line)))
3346 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3347 (if gnus-show-threads
3348 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3349 (gnus-summary-prepare-unthreaded thread))
3350 (setq data (nreverse gnus-newsgroup-data))
3351 (setq threads gnus-newsgroup-threads))
3352 ;; We splice the new data into the data structure.
3353 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3354 ;;!!! then we want to insert at the beginning of the buffer.
3355 ;;!!! That happens to be true with Gnus now, but that may
3356 ;;!!! change in the future. Perhaps.
3357 (gnus-data-enter-list
3358 (if line nil current) data (- (point) old-pos))
3359 (setq gnus-newsgroup-threads
3360 (nconc threads gnus-newsgroup-threads))
3361 (gnus-data-compute-positions))))
3363 (defun gnus-number-to-header (number)
3364 "Return the header for article NUMBER."
3365 (let ((headers gnus-newsgroup-headers))
3367 (not (= number (mail-header-number (car headers)))))
3372 (defun gnus-parent-headers (in-headers &optional generation)
3373 "Return the headers of the GENERATIONeth parent of HEADERS."
3375 (setq generation 1))
3377 (headers in-headers)
3380 (not (zerop generation))
3381 (setq references (mail-header-references headers)))
3382 (setq headers (if (and references
3383 (setq parent (gnus-parent-id references)))
3384 (car (gnus-id-to-thread parent))
3387 (and (not (eq headers in-headers))
3390 (defun gnus-id-to-thread (id)
3391 "Return the (sub-)thread where ID appears."
3392 (gnus-gethash id gnus-newsgroup-dependencies))
3394 (defun gnus-id-to-article (id)
3395 "Return the article number of ID."
3396 (let ((thread (gnus-id-to-thread id)))
3399 (mail-header-number (car thread)))))
3401 (defun gnus-id-to-header (id)
3402 "Return the article headers of ID."
3403 (car (gnus-id-to-thread id)))
3405 (defun gnus-article-displayed-root-p (article)
3406 "Say whether ARTICLE is a root(ish) article."
3407 (let ((level (gnus-summary-thread-level article))
3408 (refs (mail-header-references (gnus-summary-article-header article)))
3414 ((null (gnus-parent-id refs)) t)
3416 (null (setq particle (gnus-id-to-article
3417 (gnus-parent-id refs))))
3418 (null (gnus-summary-thread-level particle)))))))
3420 (defun gnus-root-id (id)
3421 "Return the id of the root of the thread where ID appears."
3423 (while (and id (setq prev (car (gnus-id-to-thread id))))
3425 id (gnus-parent-id (mail-header-references prev))))
3428 (defun gnus-articles-in-thread (thread)
3429 "Return the list of articles in THREAD."
3430 (cons (mail-header-number (car thread))
3431 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3433 (defun gnus-remove-thread (id &optional dont-remove)
3434 "Remove the thread that has ID in it."
3435 (let (headers thread last-id)
3436 ;; First go up in this thread until we find the root.
3437 (setq last-id (gnus-root-id id)
3438 headers (message-flatten-list (gnus-id-to-thread last-id)))
3439 ;; We have now found the real root of this thread. It might have
3440 ;; been gathered into some loose thread, so we have to search
3441 ;; through the threads to find the thread we wanted.
3442 (let ((threads gnus-newsgroup-threads)
3445 (setq sub (car threads))
3446 (if (stringp (car sub))
3447 ;; This is a gathered thread, so we look at the roots
3448 ;; below it to find whether this article is in this
3451 (setq sub (cdr sub))
3453 (when (member (caar sub) headers)
3454 (setq thread (car threads)
3457 (setq sub (cdr sub))))
3458 ;; It's an ordinary thread, so we check it.
3459 (when (eq (car sub) (car headers))
3462 (setq threads (cdr threads)))
3463 ;; If this article is in no thread, then it's a root.
3466 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3467 (setq thread (gnus-id-to-thread last-id)))
3470 thread ; We return this thread.
3472 (if (stringp (car thread))
3474 ;; If we use dummy roots, then we have to remove the
3475 ;; dummy root as well.
3476 (when (eq gnus-summary-make-false-root 'dummy)
3477 ;; We go to the dummy root by going to
3478 ;; the first sub-"thread", and then one line up.
3479 (gnus-summary-goto-article
3480 (mail-header-number (caadr thread)))
3483 (gnus-data-compute-positions))
3484 (setq thread (cdr thread))
3486 (gnus-remove-thread-1 (car thread))
3487 (setq thread (cdr thread))))
3488 (gnus-summary-show-all-threads)
3489 (gnus-remove-thread-1 thread))))))))
3491 (defun gnus-remove-thread-1 (thread)
3492 "Remove the thread THREAD recursively."
3493 (let ((number (mail-header-number (pop thread)))
3495 (setq thread (reverse thread))
3497 (gnus-remove-thread-1 (pop thread)))
3498 (when (setq d (gnus-data-find number))
3499 (goto-char (gnus-data-pos d))
3502 (- (gnus-point-at-bol)
3504 (1+ (gnus-point-at-eol))
3505 (gnus-delete-line)))))))
3507 (defun gnus-sort-threads (threads)
3509 (if (not gnus-thread-sort-functions)
3511 (gnus-message 8 "Sorting threads...")
3513 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3514 (gnus-message 8 "Sorting threads...done"))))
3516 (defun gnus-sort-articles (articles)
3518 (when gnus-article-sort-functions
3519 (gnus-message 7 "Sorting articles...")
3521 (setq gnus-newsgroup-headers
3522 (sort articles (gnus-make-sort-function
3523 gnus-article-sort-functions)))
3524 (gnus-message 7 "Sorting articles...done"))))
3526 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3527 (defmacro gnus-thread-header (thread)
3528 ;; Return header of first article in THREAD.
3529 ;; Note that THREAD must never, ever be anything else than a variable -
3530 ;; using some other form will lead to serious barfage.
3531 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3532 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3533 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
3536 (defsubst gnus-article-sort-by-number (h1 h2)
3537 "Sort articles by article number."
3538 (< (mail-header-number h1)
3539 (mail-header-number h2)))
3541 (defun gnus-thread-sort-by-number (h1 h2)
3542 "Sort threads by root article number."
3543 (gnus-article-sort-by-number
3544 (gnus-thread-header h1) (gnus-thread-header h2)))
3546 (defsubst gnus-article-sort-by-lines (h1 h2)
3547 "Sort articles by article Lines header."
3548 (< (mail-header-lines h1)
3549 (mail-header-lines h2)))
3551 (defun gnus-thread-sort-by-lines (h1 h2)
3552 "Sort threads by root article Lines header."
3553 (gnus-article-sort-by-lines
3554 (gnus-thread-header h1) (gnus-thread-header h2)))
3556 (defsubst gnus-article-sort-by-chars (h1 h2)
3557 "Sort articles by octet length."
3558 (< (mail-header-chars h1)
3559 (mail-header-chars h2)))
3561 (defun gnus-thread-sort-by-chars (h1 h2)
3562 "Sort threads by root article octet length."
3563 (gnus-article-sort-by-chars
3564 (gnus-thread-header h1) (gnus-thread-header h2)))
3566 (defsubst gnus-article-sort-by-author (h1 h2)
3567 "Sort articles by root author."
3569 (let ((addr (mime-read-field 'From h1)))
3570 (or (std11-full-name-string addr)
3571 (std11-address-string addr)
3573 (let ((addr (mime-read-field 'From h2)))
3574 (or (std11-full-name-string addr)
3575 (std11-address-string addr)
3579 (defun gnus-thread-sort-by-author (h1 h2)
3580 "Sort threads by root author."
3581 (gnus-article-sort-by-author
3582 (gnus-thread-header h1) (gnus-thread-header h2)))
3584 (defsubst gnus-article-sort-by-subject (h1 h2)
3585 "Sort articles by root subject."
3587 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3588 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3590 (defun gnus-thread-sort-by-subject (h1 h2)
3591 "Sort threads by root subject."
3592 (gnus-article-sort-by-subject
3593 (gnus-thread-header h1) (gnus-thread-header h2)))
3595 (defsubst gnus-article-sort-by-date (h1 h2)
3596 "Sort articles by root article date."
3598 (gnus-date-get-time (mail-header-date h1))
3599 (gnus-date-get-time (mail-header-date h2))))
3601 (defun gnus-thread-sort-by-date (h1 h2)
3602 "Sort threads by root article date."
3603 (gnus-article-sort-by-date
3604 (gnus-thread-header h1) (gnus-thread-header h2)))
3606 (defsubst gnus-article-sort-by-score (h1 h2)
3607 "Sort articles by root article score.
3608 Unscored articles will be counted as having a score of zero."
3609 (> (or (cdr (assq (mail-header-number h1)
3610 gnus-newsgroup-scored))
3611 gnus-summary-default-score 0)
3612 (or (cdr (assq (mail-header-number h2)
3613 gnus-newsgroup-scored))
3614 gnus-summary-default-score 0)))
3616 (defun gnus-thread-sort-by-score (h1 h2)
3617 "Sort threads by root article score."
3618 (gnus-article-sort-by-score
3619 (gnus-thread-header h1) (gnus-thread-header h2)))
3621 (defun gnus-thread-sort-by-total-score (h1 h2)
3622 "Sort threads by the sum of all scores in the thread.
3623 Unscored articles will be counted as having a score of zero."
3624 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3626 (defun gnus-thread-total-score (thread)
3627 ;; This function find the total score of THREAD.
3628 (cond ((null thread)
3631 (if (stringp (car thread))
3632 (apply gnus-thread-score-function 0
3633 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3634 (gnus-thread-total-score-1 thread)))
3636 (gnus-thread-total-score-1 (list thread)))))
3638 (defun gnus-thread-total-score-1 (root)
3639 ;; This function find the total score of the thread below ROOT.
3640 (setq root (car root))
3641 (apply gnus-thread-score-function
3643 (mapcar 'gnus-thread-total-score
3644 (cdr (gnus-id-to-thread (mail-header-id root))))
3645 (when (> (mail-header-number root) 0)
3646 (list (or (cdr (assq (mail-header-number root)
3647 gnus-newsgroup-scored))
3648 gnus-summary-default-score 0))))
3649 (list gnus-summary-default-score)
3652 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3653 (defvar gnus-tmp-prev-subject nil)
3654 (defvar gnus-tmp-false-parent nil)
3655 (defvar gnus-tmp-root-expunged nil)
3656 (defvar gnus-tmp-dummy-line nil)
3658 (defvar gnus-tmp-header)
3659 (defun gnus-extra-header (type &optional header)
3660 "Return the extra header of TYPE."
3661 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
3664 (defun gnus-summary-prepare-threads (threads)
3665 "Prepare summary buffer from THREADS and indentation LEVEL.
3666 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3667 or a straight list of headers."
3668 (gnus-message 7 "Generating summary...")
3670 (setq gnus-newsgroup-threads threads)
3673 (let ((gnus-tmp-level 0)
3674 (default-score (or gnus-summary-default-score 0))
3675 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3676 thread number subject stack state gnus-tmp-gathered beg-match
3677 new-roots gnus-tmp-new-adopts thread-end
3678 gnus-tmp-header gnus-tmp-unread
3679 gnus-tmp-replied gnus-tmp-subject-or-nil
3680 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3681 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3682 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3684 (setq gnus-tmp-prev-subject nil)
3686 (if (vectorp (car threads))
3687 ;; If this is a straight (sic) list of headers, then a
3688 ;; threaded summary display isn't required, so we just create
3689 ;; an unthreaded one.
3690 (gnus-summary-prepare-unthreaded threads)
3692 ;; Do the threaded display.
3694 (while (or threads stack gnus-tmp-new-adopts new-roots)
3696 (if (and (= gnus-tmp-level 0)
3699 (not gnus-tmp-false-parent)
3700 (or gnus-tmp-new-adopts new-roots))
3701 (if gnus-tmp-new-adopts
3702 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3703 thread (list (car gnus-tmp-new-adopts))
3704 gnus-tmp-header (caar thread)
3705 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3707 (setq thread (list (car new-roots))
3708 gnus-tmp-header (caar thread)
3709 new-roots (cdr new-roots))))
3712 ;; If there are some threads, we do them before the
3713 ;; threads on the stack.
3714 (setq thread threads
3715 gnus-tmp-header (caar thread))
3716 ;; There were no current threads, so we pop something off
3718 (setq state (car stack)
3719 gnus-tmp-level (car state)
3722 gnus-tmp-header (caar thread))))
3724 (setq gnus-tmp-false-parent nil)
3725 (setq gnus-tmp-root-expunged nil)
3726 (setq thread-end nil)
3728 (if (stringp gnus-tmp-header)
3729 ;; The header is a dummy root.
3731 ((eq gnus-summary-make-false-root 'adopt)
3732 ;; We let the first article adopt the rest.
3733 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3735 (setq gnus-tmp-gathered
3737 (lambda (h) (mail-header-number (car h)))
3740 (setq thread (cons (list (caar thread)
3743 (setq gnus-tmp-level -1
3744 gnus-tmp-false-parent t))
3745 ((eq gnus-summary-make-false-root 'empty)
3746 ;; We print adopted articles with empty subject fields.
3747 (setq gnus-tmp-gathered
3749 (lambda (h) (mail-header-number (car h)))
3752 (setq gnus-tmp-level -1))
3753 ((eq gnus-summary-make-false-root 'dummy)
3754 ;; We remember that we probably want to output a dummy
3756 (setq gnus-tmp-dummy-line gnus-tmp-header)
3757 (setq gnus-tmp-prev-subject gnus-tmp-header))
3759 ;; We do not make a root for the gathered
3760 ;; sub-threads at all.
3761 (setq gnus-tmp-level -1)))
3763 (setq number (mail-header-number gnus-tmp-header)
3764 subject (mail-header-subject gnus-tmp-header))
3767 ;; If the thread has changed subject, we might want to make
3768 ;; this subthread into a root.
3769 ((and (null gnus-thread-ignore-subject)
3770 (not (zerop gnus-tmp-level))
3771 gnus-tmp-prev-subject
3773 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3774 (setq new-roots (nconc new-roots (list (car thread)))
3776 gnus-tmp-header nil))
3777 ;; If the article lies outside the current limit,
3778 ;; then we do not display it.
3779 ((not (memq number gnus-newsgroup-limit))
3780 (setq gnus-tmp-gathered
3782 (lambda (h) (mail-header-number (car h)))
3785 (setq gnus-tmp-new-adopts (if (cdar thread)
3786 (append gnus-tmp-new-adopts
3788 gnus-tmp-new-adopts)
3790 gnus-tmp-header nil)
3791 (when (zerop gnus-tmp-level)
3792 (setq gnus-tmp-root-expunged t)))
3793 ;; Perhaps this article is to be marked as read?
3794 ((and gnus-summary-mark-below
3795 (< (or (cdr (assq number gnus-newsgroup-scored))
3797 gnus-summary-mark-below)
3798 ;; Don't touch sparse articles.
3799 (not (gnus-summary-article-sparse-p number))
3800 (not (gnus-summary-article-ancient-p number)))
3801 (setq gnus-newsgroup-unreads
3802 (delq number gnus-newsgroup-unreads))
3803 (if gnus-newsgroup-auto-expire
3804 (push number gnus-newsgroup-expirable)
3805 (push (cons number gnus-low-score-mark)
3806 gnus-newsgroup-reads))))
3808 (when gnus-tmp-header
3809 ;; We may have an old dummy line to output before this
3811 (when (and gnus-tmp-dummy-line
3814 (mail-header-subject gnus-tmp-header)))
3815 (gnus-summary-insert-dummy-line
3816 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3817 (setq gnus-tmp-dummy-line nil))
3819 ;; Compute the mark.
3820 (setq gnus-tmp-unread (gnus-article-mark number))
3822 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3823 gnus-tmp-header gnus-tmp-level)
3824 gnus-newsgroup-data)
3826 ;; Actually insert the line.
3828 gnus-tmp-subject-or-nil
3830 ((and gnus-thread-ignore-subject
3831 gnus-tmp-prev-subject
3832 (not (inline (gnus-subject-equal
3833 gnus-tmp-prev-subject subject))))
3835 ((zerop gnus-tmp-level)
3836 (if (and (eq gnus-summary-make-false-root 'empty)
3837 (memq number gnus-tmp-gathered)
3838 gnus-tmp-prev-subject
3839 (inline (gnus-subject-equal
3840 gnus-tmp-prev-subject subject)))
3841 gnus-summary-same-subject
3843 (t gnus-summary-same-subject)))
3844 (if (and (eq gnus-summary-make-false-root 'adopt)
3845 (= gnus-tmp-level 1)
3846 (memq number gnus-tmp-gathered))
3847 (setq gnus-tmp-opening-bracket ?\<
3848 gnus-tmp-closing-bracket ?\>)
3849 (setq gnus-tmp-opening-bracket ?\[
3850 gnus-tmp-closing-bracket ?\]))
3852 gnus-tmp-indentation
3853 (aref gnus-thread-indent-array gnus-tmp-level)
3854 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3855 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3856 gnus-summary-default-score 0)
3858 (if (or (null gnus-summary-default-score)
3859 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3860 gnus-summary-zcore-fuzz))
3862 (if (< gnus-tmp-score gnus-summary-default-score)
3863 gnus-score-below-mark gnus-score-over-mark))
3865 (cond ((memq number gnus-newsgroup-processable)
3867 ((memq number gnus-newsgroup-cached)
3869 ((memq number gnus-newsgroup-replied)
3871 ((memq number gnus-newsgroup-saved)
3873 (t gnus-unread-mark))
3874 gnus-tmp-from (mail-header-from gnus-tmp-header)
3877 ((string-match "<[^>]+> *$" gnus-tmp-from)
3878 (setq beg-match (match-beginning 0))
3879 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3880 (substring gnus-tmp-from (1+ (match-beginning 0))
3881 (1- (match-end 0))))
3882 (substring gnus-tmp-from 0 beg-match)))
3883 ((string-match "(.+)" gnus-tmp-from)
3884 (substring gnus-tmp-from
3885 (1+ (match-beginning 0)) (1- (match-end 0))))
3887 (when (string= gnus-tmp-name "")
3888 (setq gnus-tmp-name gnus-tmp-from))
3889 (unless (numberp gnus-tmp-lines)
3890 (setq gnus-tmp-lines 0))
3891 (gnus-put-text-property
3893 (progn (eval gnus-summary-line-format-spec) (point))
3894 'gnus-number number)
3897 (gnus-run-hooks 'gnus-summary-update-hook)
3900 (setq gnus-tmp-prev-subject subject)))
3902 (when (nth 1 thread)
3903 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3904 (incf gnus-tmp-level)
3905 (setq threads (if thread-end nil (cdar thread)))
3907 (setq gnus-tmp-level 0)))))
3908 (gnus-message 7 "Generating summary...done"))
3910 (defun gnus-summary-prepare-unthreaded (headers)
3911 "Generate an unthreaded summary buffer based on HEADERS."
3912 (let (header number mark)
3917 ;; We may have to root out some bad articles...
3918 (when (memq (setq number (mail-header-number
3919 (setq header (pop headers))))
3920 gnus-newsgroup-limit)
3921 ;; Mark article as read when it has a low score.
3922 (when (and gnus-summary-mark-below
3923 (< (or (cdr (assq number gnus-newsgroup-scored))
3924 gnus-summary-default-score 0)
3925 gnus-summary-mark-below)
3926 (not (gnus-summary-article-ancient-p number)))
3927 (setq gnus-newsgroup-unreads
3928 (delq number gnus-newsgroup-unreads))
3929 (if gnus-newsgroup-auto-expire
3930 (push number gnus-newsgroup-expirable)
3931 (push (cons number gnus-low-score-mark)
3932 gnus-newsgroup-reads)))
3934 (setq mark (gnus-article-mark number))
3935 (push (gnus-data-make number mark (1+ (point)) header 0)
3936 gnus-newsgroup-data)
3937 (gnus-summary-insert-line
3939 mark (memq number gnus-newsgroup-replied)
3940 (memq number gnus-newsgroup-expirable)
3941 (mail-header-subject header) nil
3942 (cdr (assq number gnus-newsgroup-scored))
3943 (memq number gnus-newsgroup-processable))))))
3945 (defun gnus-select-newsgroup (group &optional read-all select-articles)
3946 "Select newsgroup GROUP.
3947 If READ-ALL is non-nil, all articles in the group are selected.
3948 If SELECT-ARTICLES, only select those articles from GROUP."
3949 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3950 ;;!!! Dirty hack; should be removed.
3951 (gnus-summary-ignore-duplicates
3952 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
3954 gnus-summary-ignore-duplicates))
3955 (info (nth 2 entry))
3956 articles fetched-articles cached)
3958 (unless (gnus-check-server
3959 (setq gnus-current-select-method
3960 (gnus-find-method-for-group group)))
3961 (error "Couldn't open server"))
3963 (or (and entry (not (eq (car entry) t))) ; Either it's active...
3964 (gnus-activate-group group) ; Or we can activate it...
3965 (progn ; Or we bug out.
3966 (when (equal major-mode 'gnus-summary-mode)
3967 (kill-buffer (current-buffer)))
3968 (error "Couldn't request group %s: %s"
3969 group (gnus-status-message group))))
3971 (unless (gnus-request-group group t)
3972 (when (equal major-mode 'gnus-summary-mode)
3973 (kill-buffer (current-buffer)))
3974 (error "Couldn't request group %s: %s"
3975 group (gnus-status-message group)))
3977 (setq gnus-newsgroup-name group)
3978 (setq gnus-newsgroup-unselected nil)
3979 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
3980 (gnus-summary-setup-default-charset)
3982 ;; Adjust and set lists of article marks.
3984 (gnus-adjust-marked-articles info))
3986 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3988 (if (gnus-virtual-group-p group)
3989 gnus-newsgroup-cached
3990 (gnus-cache-articles-in-group group)))
3992 (setq gnus-newsgroup-unreads
3993 (gnus-set-difference
3994 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
3995 gnus-newsgroup-dormant))
3997 (setq gnus-newsgroup-processable nil)
3999 (gnus-update-read-articles group gnus-newsgroup-unreads)
4001 (if (setq articles select-articles)
4002 (setq gnus-newsgroup-unselected
4003 (gnus-sorted-intersection
4004 gnus-newsgroup-unreads
4005 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4006 (setq articles (gnus-articles-to-read group read-all)))
4010 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4012 ((eq articles 0) nil)
4014 ;; Init the dependencies hash table.
4015 (setq gnus-newsgroup-dependencies
4016 (gnus-make-hashtable (length articles)))
4017 (gnus-set-global-variables)
4018 ;; Retrieve the headers and read them in.
4019 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
4020 (setq gnus-newsgroup-headers
4021 (gnus-retrieve-parsed-headers
4022 articles gnus-newsgroup-name
4023 ;; We might want to fetch old headers, but
4024 ;; not if there is only 1 article.
4025 (and (or (and (not (eq gnus-fetch-old-headers 'some))
4026 (not (numberp gnus-fetch-old-headers)))
4027 (> (length articles) 1))
4028 gnus-fetch-old-headers)))
4029 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
4031 ;; Suppress duplicates?
4032 (when gnus-suppress-duplicates
4033 (gnus-dup-suppress-articles))
4035 ;; Set the initial limit.
4036 (setq gnus-newsgroup-limit (copy-sequence articles))
4037 ;; Remove canceled articles from the list of unread articles.
4038 (setq gnus-newsgroup-unreads
4039 (gnus-set-sorted-intersection
4040 gnus-newsgroup-unreads
4041 (setq fetched-articles
4042 (mapcar (lambda (headers) (mail-header-number headers))
4043 gnus-newsgroup-headers))))
4044 ;; Removed marked articles that do not exist.
4045 (gnus-update-missing-marks
4046 (gnus-sorted-complement fetched-articles articles))
4048 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4050 (setq gnus-newsgroup-cached cached))
4052 ;; We might want to build some more threads first.
4053 (when (and gnus-fetch-old-headers
4054 (eq gnus-headers-retrieved-by 'nov))
4055 (if (eq gnus-fetch-old-headers 'invisible)
4056 (gnus-build-all-threads)
4057 (gnus-build-old-threads)))
4058 ;; Let the Gnus agent mark articles as read.
4060 (gnus-agent-get-undownloaded-list))
4061 ;; Check whether auto-expire is to be done in this group.
4062 (setq gnus-newsgroup-auto-expire
4063 (gnus-group-auto-expirable-p group))
4064 ;; Set up the article buffer now, if necessary.
4065 (unless gnus-single-article-buffer
4066 (gnus-article-setup-buffer))
4067 ;; First and last article in this newsgroup.
4068 (when gnus-newsgroup-headers
4069 (setq gnus-newsgroup-begin
4070 (mail-header-number (car gnus-newsgroup-headers))
4073 (gnus-last-element gnus-newsgroup-headers))))
4074 ;; GROUP is successfully selected.
4075 (or gnus-newsgroup-headers t)))))
4077 (defun gnus-articles-to-read (group &optional read-all)
4078 ;; Find out what articles the user wants to read.
4080 ;; Select all articles if `read-all' is non-nil, or if there
4081 ;; are no unread articles.
4083 (and (zerop (length gnus-newsgroup-marked))
4084 (zerop (length gnus-newsgroup-unreads)))
4085 (eq (gnus-group-find-parameter group 'display)
4087 (gnus-uncompress-range (gnus-active group))
4088 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4089 (copy-sequence gnus-newsgroup-unreads))
4091 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4092 (scored (length scored-list))
4093 (number (length articles))
4094 (marked (+ (length gnus-newsgroup-marked)
4095 (length gnus-newsgroup-dormant)))
4103 ((and (or (<= scored marked) (= scored number))
4104 (natnump gnus-large-newsgroup)
4105 (> number gnus-large-newsgroup))
4106 (let* ((minibuffer-setup-hook (append
4107 minibuffer-setup-hook
4108 '(beginning-of-line)))
4111 "How many articles from %s (max %d): "
4112 (gnus-limit-string gnus-newsgroup-name 35)
4114 (number-to-string gnus-large-newsgroup))))
4115 (if (string-match "^[ \t]*$" input)
4118 ((and (> scored marked) (< scored number)
4119 (> (- scored number) 20))
4122 (format "%s %s (%d scored, %d total): "
4123 "How many articles from"
4124 group scored number))))
4125 (if (string-match "^[ \t]*$" input)
4129 (setq select (if (stringp select) (string-to-number select) select))
4130 (if (or (null select) (zerop select))
4132 (if (and (not (zerop scored)) (<= (abs select) scored))
4134 (setq articles (sort scored-list '<))
4135 (setq number (length articles)))
4136 (setq articles (copy-sequence articles)))
4138 (when (< (abs select) number)
4140 ;; Select the N oldest articles.
4141 (setcdr (nthcdr (1- (abs select)) articles) nil)
4142 ;; Select the N most recent articles.
4143 (setq articles (nthcdr (- number select) articles))))
4144 (setq gnus-newsgroup-unselected
4145 (gnus-sorted-intersection
4146 gnus-newsgroup-unreads
4147 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4150 (defun gnus-killed-articles (killed articles)
4153 (when (inline (gnus-member-of-range (car articles) killed))
4154 (push (car articles) out))
4155 (setq articles (cdr articles)))
4158 (defun gnus-uncompress-marks (marks)
4159 "Uncompress the mark ranges in MARKS."
4160 (let ((uncompressed '(score bookmark))
4163 (if (memq (caar marks) uncompressed)
4164 (push (car marks) out)
4165 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4166 (setq marks (cdr marks)))
4169 (defun gnus-adjust-marked-articles (info)
4170 "Set all article lists and remove all marks that are no longer valid."
4171 (let* ((marked-lists (gnus-info-marks info))
4172 (active (gnus-active (gnus-info-group info)))
4175 (types gnus-article-mark-lists)
4176 (uncompressed '(score bookmark killed))
4177 marks var articles article mark)
4180 (setq marks (pop marked-lists))
4181 (set (setq var (intern (format "gnus-newsgroup-%s"
4182 (car (rassq (setq mark (car marks))
4184 (if (memq (car marks) uncompressed) (cdr marks)
4185 (gnus-uncompress-range (cdr marks))))
4187 (setq articles (symbol-value var))
4189 ;; All articles have to be subsets of the active articles.
4191 ;; Adjust "simple" lists.
4192 ((memq mark '(tick dormant expire reply save))
4194 (when (or (< (setq article (pop articles)) min) (> article max))
4195 (set var (delq article (symbol-value var))))))
4197 ((memq mark uncompressed)
4198 (when (not (listp (cdr (symbol-value var))))
4199 (set var (list (symbol-value var))))
4200 (when (not (listp (cdr articles)))
4201 (setq articles (list articles)))
4203 (when (or (not (consp (setq article (pop articles))))
4204 (< (car article) min)
4205 (> (car article) max))
4206 (set var (delq article (symbol-value var))))))))))
4208 (defun gnus-update-missing-marks (missing)
4209 "Go through the list of MISSING articles and remove them from the mark lists."
4211 (let ((types gnus-article-mark-lists)
4213 ;; Go through all types.
4215 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4216 (when (symbol-value var)
4217 ;; This list has articles. So we delete all missing articles
4221 (set var (delq (pop m) (symbol-value var)))))))))
4223 (defun gnus-update-marks ()
4224 "Enter the various lists of marked articles into the newsgroup info list."
4225 (let ((types gnus-article-mark-lists)
4226 (info (gnus-get-info gnus-newsgroup-name))
4227 (uncompressed '(score bookmark killed))
4228 type list newmarked symbol delta-marks)
4230 ;; Add all marks lists to the list of marks lists.
4231 (while (setq type (pop types))
4232 (setq list (symbol-value
4234 (intern (format "gnus-newsgroup-%s"
4238 ;; Get rid of the entries of the articles that have the
4240 (when (and (eq (cdr type) 'score)
4244 (prev (cons nil list))
4247 (if (or (not (consp (car arts)))
4248 (= (cdar arts) gnus-summary-default-score))
4249 (setcdr prev (cdr arts))
4251 (setq arts (cdr arts)))
4252 (setq list (cdr all)))))
4254 (when (gnus-check-backend-function 'request-set-mark
4255 gnus-newsgroup-name)
4256 ;; uncompressed:s are not proper flags (they are cons cells)
4257 ;; cache is a internal gnus flag
4258 (unless (memq (cdr type) (cons 'cache uncompressed))
4259 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4260 (list (gnus-compress-sequence (sort list '<)))
4261 (del (gnus-remove-from-range old list))
4262 (add (gnus-remove-from-range list old)))
4264 (push (list add 'add (list (cdr type))) delta-marks))
4266 (push (list del 'del (list (cdr type))) delta-marks)))))
4269 (push (cons (cdr type)
4270 (if (memq (cdr type) uncompressed) list
4271 (gnus-compress-sequence
4272 (set symbol (sort list '<)) t)))
4277 (unless (gnus-check-group gnus-newsgroup-name)
4278 (error "Can't open server for %s" gnus-newsgroup-name))
4279 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4281 ;; Enter these new marks into the info of the group.
4283 (setcar (nthcdr 3 info) newmarked)
4284 ;; Add the marks lists to the end of the info.
4286 (setcdr (nthcdr 2 info) (list newmarked))))
4288 ;; Cut off the end of the info if there's nothing else there.
4292 (when (nthcdr (decf i) info)
4293 (setcdr (nthcdr i info) nil)))))))
4295 (defun gnus-set-mode-line (where)
4296 "This function sets the mode line of the article or summary buffers.
4297 If WHERE is `summary', the summary mode line format will be used."
4298 ;; Is this mode line one we keep updated?
4299 (when (and (memq where gnus-updated-mode-lines)
4301 (intern (format "gnus-%s-mode-line-format-spec" where))))
4304 ;; We evaluate this in the summary buffer since these
4305 ;; variables are buffer-local to that buffer.
4306 (set-buffer gnus-summary-buffer)
4307 ;; We bind all these variables that are used in the `eval' form
4309 (let* ((mformat (symbol-value
4311 (format "gnus-%s-mode-line-format-spec" where))))
4312 (gnus-tmp-group-name gnus-newsgroup-name)
4313 (gnus-tmp-article-number (or gnus-current-article 0))
4314 (gnus-tmp-unread gnus-newsgroup-unreads)
4315 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4316 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4317 (gnus-tmp-unread-and-unselected
4318 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4319 (zerop gnus-tmp-unselected))
4321 ((zerop gnus-tmp-unselected)
4322 (format "{%d more}" gnus-tmp-unread-and-unticked))
4323 (t (format "{%d(+%d) more}"
4324 gnus-tmp-unread-and-unticked
4325 gnus-tmp-unselected))))
4327 (if (and gnus-current-headers
4328 (vectorp gnus-current-headers))
4329 (gnus-mode-string-quote
4330 (mail-header-subject gnus-current-headers))
4332 bufname-length max-len
4333 gnus-tmp-header);; passed as argument to any user-format-funcs
4334 (setq mode-string (eval mformat))
4335 (setq bufname-length (if (string-match "%b" mode-string)
4338 (if (eq where 'summary)
4340 (get-buffer gnus-article-buffer))))
4343 (setq max-len (max 4 (if gnus-mode-non-string-length
4345 gnus-mode-non-string-length
4347 (length mode-string))))
4348 ;; We might have to chop a bit of the string off...
4349 (when (> (length mode-string) max-len)
4351 (concat (gnus-truncate-string mode-string (- max-len 3))
4353 ;; Pad the mode string a bit.
4354 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4355 ;; Update the mode line.
4356 (setq mode-line-buffer-identification
4357 (gnus-mode-line-buffer-identification (list mode-string)))
4358 (set-buffer-modified-p t))))
4360 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4361 "Go through the HEADERS list and add all Xrefs to a hash table.
4362 The resulting hash table is returned, or nil if no Xrefs were found."
4363 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4364 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4365 (xref-hashtb (gnus-make-hashtable))
4366 start group entry number xrefs header)
4368 (setq header (pop headers))
4369 (when (and (setq xrefs (mail-header-xref header))
4370 (not (memq (setq number (mail-header-number header))
4373 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4374 (setq start (match-end 0))
4375 (setq group (if prefix
4376 (concat prefix (substring xrefs (match-beginning 1)
4378 (substring xrefs (match-beginning 1) (match-end 1))))
4380 (string-to-int (substring xrefs (match-beginning 2)
4382 (if (setq entry (gnus-gethash group xref-hashtb))
4383 (setcdr entry (cons number (cdr entry)))
4384 (gnus-sethash group (cons number nil) xref-hashtb)))))
4385 (and start xref-hashtb)))
4387 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4388 "Look through all the headers and mark the Xrefs as read."
4389 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4390 name entry info xref-hashtb idlist method nth4)
4392 (set-buffer gnus-group-buffer)
4393 (when (setq xref-hashtb
4394 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4397 (unless (string= from-newsgroup (setq name (symbol-name group)))
4398 (setq idlist (symbol-value group))
4399 ;; Dead groups are not updated.
4401 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4403 (when (stringp (setq nth4 (gnus-info-method info)))
4404 (setq nth4 (gnus-server-to-method nth4))))
4405 ;; Only do the xrefs if the group has the same
4406 ;; select method as the group we have just read.
4407 (or (gnus-methods-equal-p
4408 nth4 (gnus-find-method-for-group from-newsgroup))
4410 (equal nth4 (setq method (gnus-find-method-for-group
4412 (and (equal (car nth4) (car method))
4413 (equal (nth 1 nth4) (nth 1 method))))
4414 gnus-use-cross-reference
4415 (or (not (eq gnus-use-cross-reference t))
4417 ;; Only do cross-references on subscribed
4418 ;; groups, if that is what is wanted.
4419 (<= (gnus-info-level info) gnus-level-subscribed))
4420 (gnus-group-make-articles-read name idlist))))
4423 (defun gnus-compute-read-articles (group articles)
4424 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4425 (info (nth 2 entry))
4426 (active (gnus-active group))
4429 ;; First peel off all invalid article numbers.
4431 (let ((ids articles)
4433 (while (setq id (pop ids))
4434 (when (and first (> id (cdr active)))
4435 ;; We'll end up in this situation in one particular
4436 ;; obscure situation. If you re-scan a group and get
4437 ;; a new article that is cross-posted to a different
4438 ;; group that has not been re-scanned, you might get
4439 ;; crossposted article that has a higher number than
4440 ;; Gnus believes possible. So we re-activate this
4441 ;; group as well. This might mean doing the
4442 ;; crossposting thingy will *increase* the number
4443 ;; of articles in some groups. Tsk, tsk.
4444 (setq active (or (gnus-activate-group group) active)))
4445 (when (or (> id (cdr active))
4446 (< id (car active)))
4447 (setq articles (delq id articles))))))
4448 ;; If the read list is nil, we init it.
4450 (null (gnus-info-read info))
4452 (setq ninfo (cons 1 (1- (car active))))
4453 (setq ninfo (gnus-info-read info)))
4454 ;; Then we add the read articles to the range.
4456 ninfo (setq articles (sort articles '<))))))
4458 (defun gnus-group-make-articles-read (group articles)
4459 "Update the info of GROUP to say that ARTICLES are read."
4461 (entry (gnus-gethash group gnus-newsrc-hashtb))
4462 (info (nth 2 entry))
4463 (active (gnus-active group))
4466 (setq range (gnus-compute-read-articles group articles))
4468 (set-buffer gnus-group-buffer)
4471 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4472 (gnus-info-set-read ',info ',(gnus-info-read info))
4473 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4474 (gnus-group-update-group ,group t))))
4475 ;; Add the read articles to the range.
4476 (gnus-info-set-read info range)
4477 ;; Then we have to re-compute how many unread
4478 ;; articles there are in this group.
4482 (setq num (- (1+ (cdr active)) (car active))))
4483 ((not (listp (cdr range)))
4484 (setq num (- (cdr active) (- (1+ (cdr range))
4488 (if (numberp (car range))
4490 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4491 (setq range (cdr range)))
4492 (setq num (- (cdr active) num))))
4493 ;; Update the number of unread articles.
4495 ;; Update the group buffer.
4496 (gnus-group-update-group group t)))))
4498 (defvar gnus-newsgroup-none-id 0)
4500 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4501 (let ((cur nntp-server-buffer)
4504 (save-excursion (set-buffer gnus-summary-buffer)
4505 gnus-newsgroup-dependencies)))
4507 (mail-parse-charset gnus-newsgroup-charset))
4509 (set-buffer nntp-server-buffer)
4510 ;; Translate all TAB characters into SPACE characters.
4511 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4512 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4513 (gnus-run-hooks 'gnus-parse-headers-hook)
4514 (let ((case-fold-search t)
4515 in-reply-to header p lines chars ctype)
4516 (goto-char (point-min))
4517 ;; Search to the beginning of the next header. Error messages
4518 ;; do not begin with 2 or 3.
4519 (while (re-search-forward "^[23][0-9]+ " nil t)
4522 ;; This implementation of this function, with nine
4523 ;; search-forwards instead of the one re-search-forward and
4524 ;; a case (which basically was the old function) is actually
4525 ;; about twice as fast, even though it looks messier. You
4526 ;; can't have everything, I guess. Speed and elegance
4527 ;; doesn't always go hand in hand.
4530 (make-full-mail-header
4536 (narrow-to-region (point)
4537 (or (and (search-forward "\n.\n" nil t)
4543 (if (search-forward "\nsubject: " nil t)
4544 (buffer-substring (match-end 0) (std11-field-end))
4549 (if (search-forward "\nfrom: " nil t)
4550 (buffer-substring (match-end 0) (std11-field-end))
4555 (if (search-forward "\ndate: " nil t)
4556 (buffer-substring (match-end 0) (std11-field-end))
4561 (setq id (if (re-search-forward
4562 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4563 ;; We do it this way to make sure the Message-ID
4564 ;; is (somewhat) syntactically valid.
4565 (buffer-substring (match-beginning 1)
4567 ;; If there was no message-id, we just fake one
4568 ;; to make subsequent routines simpler.
4569 (nnheader-generate-fake-message-id))))
4573 (if (search-forward "\nreferences: " nil t)
4577 (buffer-substring (match-end 0) (std11-field-end))
4582 (search-backward ">" end t)
4585 (search-backward "<" end t)
4587 ;; Get the references from the in-reply-to header if there
4588 ;; were no references and the in-reply-to header looks
4590 (if (and (search-forward "\nin-reply-to: " nil t)
4592 (buffer-substring (match-end 0)
4594 (string-match "<[^>]+>" in-reply-to))
4596 (setq ref (substring in-reply-to (match-beginning 0)
4598 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4599 (setq ref2 (substring in-reply-to (match-beginning 0)
4601 (when (> (length ref2) (length ref))
4608 (if (search-forward "\nchars: " nil t)
4609 (if (numberp (setq chars (ignore-errors (read cur))))
4615 (if (search-forward "\nlines: " nil t)
4616 (if (numberp (setq lines (ignore-errors (read cur))))
4622 (and (search-forward "\nxref: " nil t)
4623 (buffer-substring (match-end 0) (std11-field-end))))
4625 (when gnus-extra-headers
4626 (let ((extra gnus-extra-headers)
4630 (when (search-forward
4631 (concat "\n" (symbol-name (car extra)) ": ") nil t)
4632 (push (cons (car extra)
4633 (buffer-substring (match-end 0)
4639 (if (and (search-forward "\ncontent-type: " nil t)
4641 (buffer-substring (match-end 0) (std11-field-end))))
4642 (mime-entity-set-content-type-internal
4643 header (mime-parse-Content-Type ctype)))
4644 (when (equal id ref)
4647 (when gnus-alter-header-function
4648 (funcall gnus-alter-header-function header)
4649 (setq id (mail-header-id header)
4650 ref (gnus-parent-id (mail-header-references header))))
4653 (gnus-dependencies-add-header
4654 header dependencies force-new))
4655 (push header headers))
4656 (goto-char (point-max))
4658 (nreverse headers)))))
4660 ;; Goes through the xover lines and returns a list of vectors
4661 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4662 force-new dependencies
4663 group also-fetch-heads)
4664 "Parse the news overview data in the server buffer, and return a
4665 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4666 ;; Get the Xref when the users reads the articles since most/some
4667 ;; NNTP servers do not include Xrefs when using XOVER.
4668 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4669 (let ((mail-parse-charset gnus-newsgroup-charset)
4670 (cur nntp-server-buffer)
4671 (dependencies (or dependencies gnus-newsgroup-dependencies))
4672 number headers header)
4674 (set-buffer nntp-server-buffer)
4675 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4676 ;; Allow the user to mangle the headers before parsing them.
4677 (gnus-run-hooks 'gnus-parse-headers-hook)
4678 (goto-char (point-min))
4681 (while (and sequence (not (eobp)))
4682 (setq number (read cur))
4683 (while (and sequence
4684 (< (car sequence) number))
4685 (setq sequence (cdr sequence)))
4687 (eq number (car sequence))
4689 (setq sequence (cdr sequence))
4690 (setq header (inline
4691 (gnus-nov-parse-line
4692 number dependencies force-new))))
4693 (push header headers))
4696 (gnus-error 4 "Strange nov line (%d)"
4697 (count-lines (point-min) (point)))))
4699 ;; A common bug in inn is that if you have posted an article and
4700 ;; then retrieves the active file, it will answer correctly --
4701 ;; the new article is included. However, a NOV entry for the
4702 ;; article may not have been generated yet, so this may fail.
4703 ;; We work around this problem by retrieving the last few
4704 ;; headers using HEAD.
4705 (if (or (not also-fetch-heads)
4707 ;; We (probably) got all the headers.
4709 (let ((gnus-nov-is-evil t))
4712 (gnus-retrieve-parsed-headers sequence group)
4715 (defun gnus-article-get-xrefs ()
4716 "Fill in the Xref value in `gnus-current-headers', if necessary.
4717 This is meant to be called in `gnus-article-internal-prepare-hook'."
4718 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4719 gnus-current-headers)))
4720 (or (not gnus-use-cross-reference)
4722 (and (mail-header-xref headers)
4723 (not (string= (mail-header-xref headers) "")))
4724 (let ((case-fold-search t)
4727 (nnheader-narrow-to-headers)
4728 (goto-char (point-min))
4729 (when (or (and (eq (downcase (char-after)) ?x)
4730 (looking-at "Xref:"))
4731 (search-forward "\nXref:" nil t))
4732 (goto-char (1+ (match-end 0)))
4733 (setq xref (buffer-substring (point)
4734 (progn (end-of-line) (point))))
4735 (mail-header-set-xref headers xref)))))))
4737 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4738 "Find article ID and insert the summary line for that article.
4739 OLD-HEADER can either be a header or a line number to insert
4740 the subject line on."
4741 (let* ((line (and (numberp old-header) old-header))
4742 (old-header (and (vectorp old-header) old-header))
4743 (header (cond ((and old-header use-old-header)
4746 (gnus-number-to-header id))
4747 (gnus-number-to-header id))
4749 (gnus-read-header id))))
4750 (number (and (numberp id) id))
4753 ;; Rebuild the thread that this article is part of and go to the
4754 ;; article we have fetched.
4755 (when (and (not gnus-show-threads)
4758 (setq d (gnus-data-find (mail-header-number old-header))))
4759 (goto-char (gnus-data-pos d))
4762 (- (gnus-point-at-bol)
4764 (1+ (gnus-point-at-eol))
4765 (gnus-delete-line))))))
4767 (mail-header-set-number header (mail-header-number old-header)))
4768 (setq gnus-newsgroup-sparse
4769 (delq (setq number (mail-header-number header))
4770 gnus-newsgroup-sparse))
4771 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4772 (push number gnus-newsgroup-limit)
4773 (gnus-rebuild-thread (mail-header-id header) line)
4774 (gnus-summary-goto-subject number nil t))
4775 (when (and (numberp number)
4777 ;; We have to update the boundaries even if we can't fetch the
4778 ;; article if ID is a number -- so that the next `P' or `N'
4779 ;; command will fetch the previous (or next) article even
4780 ;; if the one we tried to fetch this time has been canceled.
4781 (when (> number gnus-newsgroup-end)
4782 (setq gnus-newsgroup-end number))
4783 (when (< number gnus-newsgroup-begin)
4784 (setq gnus-newsgroup-begin number))
4785 (setq gnus-newsgroup-unselected
4786 (delq number gnus-newsgroup-unselected)))
4787 ;; Report back a success?
4788 (and header (mail-header-number header))))
4790 ;;; Process/prefix in the summary buffer
4792 (defun gnus-summary-work-articles (n)
4793 "Return a list of articles to be worked upon.
4794 The prefix argument, the list of process marked articles, and the
4795 current article will be taken into consideration."
4797 (set-buffer gnus-summary-buffer)
4800 ;; A numerical prefix has been given.
4801 (setq n (prefix-numeric-value n))
4802 (let ((backward (< n 0))
4803 (n (abs (prefix-numeric-value n)))
4808 (push (setq article (gnus-summary-article-number))
4811 (gnus-summary-find-prev nil article)
4812 (gnus-summary-find-next nil article)))
4814 (nreverse articles)))
4815 ((and (gnus-region-active-p) (mark))
4816 (message "region active")
4817 ;; Work on the region between point and mark.
4818 (let ((max (max (point) (mark)))
4821 (goto-char (min (point) (mark)))
4824 (push (setq article (gnus-summary-article-number)) articles)
4825 (gnus-summary-find-next nil article)
4827 (nreverse articles))))
4828 (gnus-newsgroup-processable
4829 ;; There are process-marked articles present.
4830 ;; Save current state.
4831 (gnus-summary-save-process-mark)
4833 (reverse gnus-newsgroup-processable))
4835 ;; Just return the current article.
4836 (list (gnus-summary-article-number))))))
4838 (defmacro gnus-summary-iterate (arg &rest forms)
4839 "Iterate over the process/prefixed articles and do FORMS.
4840 ARG is the interactive prefix given to the command. FORMS will be
4841 executed with point over the summary line of the articles."
4842 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
4843 `(let ((,articles (gnus-summary-work-articles ,arg)))
4845 (gnus-summary-goto-subject (car ,articles))
4848 (put 'gnus-summary-iterate 'lisp-indent-function 1)
4849 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
4851 (defun gnus-summary-save-process-mark ()
4852 "Push the current set of process marked articles on the stack."
4854 (push (copy-sequence gnus-newsgroup-processable)
4855 gnus-newsgroup-process-stack))
4857 (defun gnus-summary-kill-process-mark ()
4858 "Push the current set of process marked articles on the stack and unmark."
4860 (gnus-summary-save-process-mark)
4861 (gnus-summary-unmark-all-processable))
4863 (defun gnus-summary-yank-process-mark ()
4864 "Pop the last process mark state off the stack and restore it."
4866 (unless gnus-newsgroup-process-stack
4867 (error "Empty mark stack"))
4868 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4870 (defun gnus-summary-process-mark-set (set)
4871 "Make SET into the current process marked articles."
4872 (gnus-summary-unmark-all-processable)
4874 (gnus-summary-set-process-mark (pop set))))
4876 ;;; Searching and stuff
4878 (defun gnus-summary-search-group (&optional backward use-level)
4879 "Search for next unread newsgroup.
4880 If optional argument BACKWARD is non-nil, search backward instead."
4882 (set-buffer gnus-group-buffer)
4883 (when (gnus-group-search-forward
4884 backward nil (if use-level (gnus-group-group-level) nil))
4885 (gnus-group-group-name))))
4887 (defun gnus-summary-best-group (&optional exclude-group)
4888 "Find the name of the best unread group.
4889 If EXCLUDE-GROUP, do not go to this group."
4891 (set-buffer gnus-group-buffer)
4893 (gnus-group-best-unread-group exclude-group))))
4895 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
4896 (if backward (gnus-summary-find-prev)
4897 (let* ((dummy (gnus-summary-article-intangible-p))
4898 (article (or article (gnus-summary-article-number)))
4899 (arts (gnus-data-find-list article))
4901 (when (and (not dummy)
4902 (or (not gnus-summary-check-current)
4904 (not (gnus-data-unread-p (car arts)))))
4905 (setq arts (cdr arts)))
4910 (when (or (and undownloaded
4911 (eq gnus-undownloaded-mark
4912 (gnus-data-mark (car arts))))
4913 (gnus-data-unread-p (car arts)))
4914 (setq result (car arts)
4916 (setq arts (cdr arts)))
4919 (goto-char (gnus-data-pos result))
4920 (gnus-data-number result)))))
4922 (defun gnus-summary-find-prev (&optional unread article)
4923 (let* ((eobp (eobp))
4924 (article (or article (gnus-summary-article-number)))
4925 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
4927 (when (and (not eobp)
4928 (or (not gnus-summary-check-current)
4930 (not (gnus-data-unread-p (car arts)))))
4931 (setq arts (cdr arts)))
4936 (when (gnus-data-unread-p (car arts))
4937 (setq result (car arts)
4939 (setq arts (cdr arts)))
4942 (goto-char (gnus-data-pos result))
4943 (gnus-data-number result))))
4945 (defun gnus-summary-find-subject (subject &optional unread backward article)
4946 (let* ((simp-subject (gnus-simplify-subject-fully subject))
4947 (article (or article (gnus-summary-article-number)))
4948 (articles (gnus-data-list backward))
4949 (arts (gnus-data-find-list article articles))
4951 (when (or (not gnus-summary-check-current)
4953 (not (gnus-data-unread-p (car arts))))
4954 (setq arts (cdr arts)))
4956 (and (or (not unread)
4957 (gnus-data-unread-p (car arts)))
4958 (vectorp (gnus-data-header (car arts)))
4960 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
4961 (setq result (car arts)
4963 (setq arts (cdr arts)))
4965 (goto-char (gnus-data-pos result))
4966 (gnus-data-number result))))
4968 (defun gnus-summary-search-forward (&optional unread subject backward)
4969 "Search forward for an article.
4970 If UNREAD, look for unread articles. If SUBJECT, look for
4971 articles with that subject. If BACKWARD, search backward instead."
4972 (cond (subject (gnus-summary-find-subject subject unread backward))
4973 (backward (gnus-summary-find-prev unread))
4974 (t (gnus-summary-find-next unread))))
4976 (defun gnus-recenter (&optional n)
4977 "Center point in window and redisplay frame.
4978 Also do horizontal recentering."
4980 (when (and gnus-auto-center-summary
4981 (not (eq gnus-auto-center-summary 'vertical)))
4982 (gnus-horizontal-recenter))
4985 (defun gnus-summary-recenter ()
4986 "Center point in the summary window.
4987 If `gnus-auto-center-summary' is nil, or the article buffer isn't
4988 displayed, no centering will be performed."
4989 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
4990 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
4991 (let* ((top (cond ((< (window-height) 4) 0)
4992 ((< (window-height) 7) 1)
4993 (t (if (numberp gnus-auto-center-summary)
4994 gnus-auto-center-summary
4996 (height (1- (window-height)))
4997 (bottom (save-excursion (goto-char (point-max))
4998 (forward-line (- height))
5000 (window (get-buffer-window (current-buffer))))
5001 ;; The user has to want it.
5002 (when gnus-auto-center-summary
5003 (when (get-buffer-window gnus-article-buffer)
5004 ;; Only do recentering when the article buffer is displayed,
5005 ;; Set the window start to either `bottom', which is the biggest
5006 ;; possible valid number, or the second line from the top,
5007 ;; whichever is the least.
5009 window (min bottom (save-excursion
5010 (forward-line (- top)) (point)))))
5011 ;; Do horizontal recentering while we're at it.
5012 (when (and (get-buffer-window (current-buffer) t)
5013 (not (eq gnus-auto-center-summary 'vertical)))
5014 (let ((selected (selected-window)))
5015 (select-window (get-buffer-window (current-buffer) t))
5016 (gnus-summary-position-point)
5017 (gnus-horizontal-recenter)
5018 (select-window selected))))))
5020 (defun gnus-summary-jump-to-group (newsgroup)
5021 "Move point to NEWSGROUP in group mode buffer."
5022 ;; Keep update point of group mode buffer if visible.
5023 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5024 (save-window-excursion
5025 ;; Take care of tree window mode.
5026 (when (get-buffer-window gnus-group-buffer)
5027 (pop-to-buffer gnus-group-buffer))
5028 (gnus-group-jump-to-group newsgroup))
5030 ;; Take care of tree window mode.
5031 (if (get-buffer-window gnus-group-buffer)
5032 (pop-to-buffer gnus-group-buffer)
5033 (set-buffer gnus-group-buffer))
5034 (gnus-group-jump-to-group newsgroup))))
5036 ;; This function returns a list of article numbers based on the
5037 ;; difference between the ranges of read articles in this group and
5038 ;; the range of active articles.
5039 (defun gnus-list-of-unread-articles (group)
5040 (let* ((read (gnus-info-read (gnus-get-info group)))
5041 (active (or (gnus-active group) (gnus-activate-group group)))
5044 ;; If none are read, then all are unread.
5046 (setq first (car active))
5047 ;; If the range of read articles is a single range, then the
5048 ;; first unread article is the article after the last read
5049 ;; article. Sounds logical, doesn't it?
5050 (if (not (listp (cdr read)))
5051 (setq first (max (car active) (1+ (cdr read))))
5052 ;; `read' is a list of ranges.
5053 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5056 (setq first (car active)))
5059 (while (< first nlast)
5061 (setq first (1+ first))))
5062 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5063 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5064 (setq read (cdr read)))))
5065 ;; And add the last unread articles.
5066 (while (<= first last)
5068 (setq first (1+ first)))
5069 ;; Return the list of unread articles.
5070 (delq 0 (nreverse unread))))
5072 (defun gnus-list-of-read-articles (group)
5073 "Return a list of unread, unticked and non-dormant articles."
5074 (let* ((info (gnus-get-info group))
5075 (marked (gnus-info-marks info))
5076 (active (gnus-active group)))
5078 (gnus-set-difference
5079 (gnus-sorted-complement
5080 (gnus-uncompress-range active)
5081 (gnus-list-of-unread-articles group))
5083 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5084 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5086 ;; Various summary commands
5088 (defun gnus-summary-select-article-buffer ()
5089 "Reconfigure windows to show article buffer."
5091 (if (not (gnus-buffer-live-p gnus-article-buffer))
5092 (error "There is no article buffer for this summary buffer")
5093 (gnus-configure-windows 'article)
5094 (select-window (get-buffer-window gnus-article-buffer))))
5096 (defun gnus-summary-universal-argument (arg)
5097 "Perform any operation on all articles that are process/prefixed."
5099 (let ((articles (gnus-summary-work-articles arg))
5106 (substitute-command-keys
5107 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
5110 (gnus-error 1 "Undefined key")
5113 (gnus-summary-goto-subject (setq article (pop articles)))
5114 (let (gnus-newsgroup-processable)
5115 (command-execute func))
5116 (gnus-summary-remove-process-mark article)))))
5117 (gnus-summary-position-point))
5119 (defun gnus-summary-toggle-truncation (&optional arg)
5120 "Toggle truncation of summary lines.
5121 With arg, turn line truncation on iff arg is positive."
5123 (setq truncate-lines
5124 (if (null arg) (not truncate-lines)
5125 (> (prefix-numeric-value arg) 0)))
5128 (defun gnus-summary-reselect-current-group (&optional all rescan)
5129 "Exit and then reselect the current newsgroup.
5130 The prefix argument ALL means to select all articles."
5132 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5133 (error "Ephemeral groups can't be reselected"))
5134 (let ((current-subject (gnus-summary-article-number))
5135 (group gnus-newsgroup-name))
5136 (setq gnus-newsgroup-begin nil)
5138 ;; We have to adjust the point of group mode buffer because
5139 ;; point was moved to the next unread newsgroup by exiting.
5140 (gnus-summary-jump-to-group group)
5143 (gnus-group-get-new-news-this-group 1)))
5144 (gnus-group-read-group all t)
5145 (gnus-summary-goto-subject current-subject nil t)))
5147 (defun gnus-summary-rescan-group (&optional all)
5148 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5150 (gnus-summary-reselect-current-group all t))
5152 (defun gnus-summary-update-info (&optional non-destructive)
5154 (let ((group gnus-newsgroup-name))
5156 (when gnus-newsgroup-kill-headers
5157 (setq gnus-newsgroup-killed
5158 (gnus-compress-sequence
5160 (gnus-set-sorted-intersection
5161 (gnus-uncompress-range gnus-newsgroup-killed)
5162 (setq gnus-newsgroup-unselected
5163 (sort gnus-newsgroup-unselected '<)))
5164 (setq gnus-newsgroup-unreads
5165 (sort gnus-newsgroup-unreads '<)))
5167 (unless (listp (cdr gnus-newsgroup-killed))
5168 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5169 (let ((headers gnus-newsgroup-headers))
5170 ;; Set the new ranges of read articles.
5172 (set-buffer gnus-group-buffer)
5173 (gnus-undo-force-boundary))
5174 (gnus-update-read-articles
5175 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5176 ;; Set the current article marks.
5177 (let ((gnus-newsgroup-scored
5178 (if (and (not gnus-save-score)
5179 (not non-destructive))
5181 gnus-newsgroup-scored)))
5183 (gnus-update-marks)))
5184 ;; Do the cross-ref thing.
5185 (when gnus-use-cross-reference
5186 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5187 ;; Do not switch windows but change the buffer to work.
5188 (set-buffer gnus-group-buffer)
5189 (unless (gnus-ephemeral-group-p group)
5190 (gnus-group-update-group group)))))))
5192 (defun gnus-summary-save-newsrc (&optional force)
5193 "Save the current number of read/marked articles in the dribble buffer.
5194 The dribble buffer will then be saved.
5195 If FORCE (the prefix), also save the .newsrc file(s)."
5197 (gnus-summary-update-info t)
5199 (gnus-save-newsrc-file)
5200 (gnus-dribble-save)))
5202 (defun gnus-summary-exit (&optional temporary)
5203 "Exit reading current newsgroup, and then return to group selection mode.
5204 gnus-exit-group-hook is called with no arguments if that value is non-nil."
5206 (gnus-set-global-variables)
5207 (gnus-kill-save-kill-buffer)
5208 (gnus-async-halt-prefetch)
5209 (let* ((group gnus-newsgroup-name)
5210 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5213 (buf (current-buffer)))
5215 ;; Do adaptive scoring, and possibly save score files.
5216 (when gnus-newsgroup-adaptive
5217 (gnus-score-adaptive))
5218 (when gnus-use-scoring
5220 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5221 ;; If we have several article buffers, we kill them at exit.
5222 (unless gnus-single-article-buffer
5223 (gnus-kill-buffer gnus-original-article-buffer)
5224 (setq gnus-article-current nil))
5225 (when gnus-use-cache
5226 (gnus-cache-possibly-remove-articles)
5227 (gnus-cache-save-buffers))
5228 (gnus-async-prefetch-remove-group group)
5229 (when gnus-suppress-duplicates
5230 (gnus-dup-enter-articles))
5231 (when gnus-use-trees
5232 (gnus-tree-close group))
5233 ;; Remove entries for this group.
5234 (nnmail-purge-split-history (gnus-group-real-name group))
5235 ;; Make all changes in this group permanent.
5237 (gnus-run-hooks 'gnus-exit-group-hook)
5238 (gnus-summary-update-info))
5239 (gnus-close-group group)
5240 ;; Make sure where we were, and go to next newsgroup.
5241 (set-buffer gnus-group-buffer)
5243 (gnus-group-jump-to-group group))
5244 (gnus-run-hooks 'gnus-summary-exit-hook)
5245 (unless (or quit-config
5246 ;; If this group has disappeared from the summary
5247 ;; buffer, don't skip forwards.
5248 (not (string= group (gnus-group-group-name))))
5249 (gnus-group-next-unread-group 1))
5250 (setq group-point (point))
5253 ;; If we have several article buffers, we kill them at exit.
5254 (unless gnus-single-article-buffer
5255 (gnus-kill-buffer gnus-article-buffer)
5256 (gnus-kill-buffer gnus-original-article-buffer)
5257 (setq gnus-article-current nil))
5259 (if (not gnus-kill-summary-on-exit)
5260 (gnus-deaden-summary)
5261 ;; We set all buffer-local variables to nil. It is unclear why
5262 ;; this is needed, but if we don't, buffer-local variables are
5263 ;; not garbage-collected, it seems. This would the lead to en
5264 ;; ever-growing Emacs.
5265 (gnus-summary-clear-local-variables)
5266 (when (get-buffer gnus-article-buffer)
5267 (bury-buffer gnus-article-buffer))
5268 ;; We clear the global counterparts of the buffer-local
5269 ;; variables as well, just to be on the safe side.
5270 (set-buffer gnus-group-buffer)
5271 (gnus-summary-clear-local-variables)
5272 ;; Return to group mode buffer.
5273 (when (eq mode 'gnus-summary-mode)
5274 (gnus-kill-buffer buf)))
5275 (setq gnus-current-select-method gnus-select-method)
5276 (pop-to-buffer gnus-group-buffer)
5277 (if (not quit-config)
5279 (goto-char group-point)
5280 (gnus-configure-windows 'group 'force))
5281 (gnus-handle-ephemeral-exit quit-config))
5282 ;; Clear the current group name.
5284 (setq gnus-newsgroup-name nil)))))
5286 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5287 (defun gnus-summary-exit-no-update (&optional no-questions)
5288 "Quit reading current newsgroup without updating read article info."
5290 (let* ((group gnus-newsgroup-name)
5291 (quit-config (gnus-group-quit-config group)))
5292 (when (or no-questions
5294 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5295 (gnus-async-halt-prefetch)
5297 (delq 'gnus-summary-expire-articles
5298 (copy-list gnus-summary-prepare-exit-hook)))
5299 ;; If we have several article buffers, we kill them at exit.
5300 (unless gnus-single-article-buffer
5301 (gnus-kill-buffer gnus-article-buffer)
5302 (gnus-kill-buffer gnus-original-article-buffer)
5303 (setq gnus-article-current nil))
5304 (if (not gnus-kill-summary-on-exit)
5305 (gnus-deaden-summary)
5306 (gnus-close-group group)
5307 (gnus-summary-clear-local-variables)
5308 (set-buffer gnus-group-buffer)
5309 (gnus-summary-clear-local-variables)
5310 (when (get-buffer gnus-summary-buffer)
5311 (kill-buffer gnus-summary-buffer)))
5312 (unless gnus-single-article-buffer
5313 (setq gnus-article-current nil))
5314 (when gnus-use-trees
5315 (gnus-tree-close group))
5316 (gnus-async-prefetch-remove-group group)
5317 (when (get-buffer gnus-article-buffer)
5318 (bury-buffer gnus-article-buffer))
5319 ;; Return to the group buffer.
5320 (gnus-configure-windows 'group 'force)
5321 ;; Clear the current group name.
5322 (setq gnus-newsgroup-name nil)
5323 (when (equal (gnus-group-group-name) group)
5324 (gnus-group-next-unread-group 1))
5326 (gnus-handle-ephemeral-exit quit-config)))))
5328 (defun gnus-handle-ephemeral-exit (quit-config)
5329 "Handle movement when leaving an ephemeral group.
5330 The state which existed when entering the ephemeral is reset."
5331 (if (not (buffer-name (car quit-config)))
5332 (gnus-configure-windows 'group 'force)
5333 (set-buffer (car quit-config))
5334 (cond ((eq major-mode 'gnus-summary-mode)
5335 (gnus-set-global-variables))
5336 ((eq major-mode 'gnus-article-mode)
5338 ;; The `gnus-summary-buffer' variable may point
5339 ;; to the old summary buffer when using a single
5341 (unless (gnus-buffer-live-p gnus-summary-buffer)
5342 (set-buffer gnus-group-buffer))
5343 (set-buffer gnus-summary-buffer)
5344 (gnus-set-global-variables))))
5345 (if (or (eq (cdr quit-config) 'article)
5346 (eq (cdr quit-config) 'pick))
5348 ;; The current article may be from the ephemeral group
5349 ;; thus it is best that we reload this article
5350 (gnus-summary-show-article)
5351 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5352 (gnus-configure-windows 'pick 'force)
5353 (gnus-configure-windows (cdr quit-config) 'force)))
5354 (gnus-configure-windows (cdr quit-config) 'force))
5355 (when (eq major-mode 'gnus-summary-mode)
5356 (gnus-summary-next-subject 1 nil t)
5357 (gnus-summary-recenter)
5358 (gnus-summary-position-point))))
5360 (defun gnus-summary-preview-mime-message ()
5361 "MIME decode and play this message."
5363 (let ((gnus-break-pages nil)
5365 (gnus-summary-select-article gnus-show-all-headers t))
5366 (select-window (get-buffer-window gnus-article-buffer)))
5370 (defvar gnus-dead-summary-mode-map nil)
5372 (unless gnus-dead-summary-mode-map
5373 (setq gnus-dead-summary-mode-map (make-keymap))
5374 (suppress-keymap gnus-dead-summary-mode-map)
5375 (substitute-key-definition
5376 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5377 (let ((keys '("\C-d" "\r" "\177" [delete])))
5379 (define-key gnus-dead-summary-mode-map
5380 (pop keys) 'gnus-summary-wake-up-the-dead))))
5382 (defvar gnus-dead-summary-mode nil
5383 "Minor mode for Gnus summary buffers.")
5385 (defun gnus-dead-summary-mode (&optional arg)
5386 "Minor mode for Gnus summary buffers."
5388 (when (eq major-mode 'gnus-summary-mode)
5389 (make-local-variable 'gnus-dead-summary-mode)
5390 (setq gnus-dead-summary-mode
5391 (if (null arg) (not gnus-dead-summary-mode)
5392 (> (prefix-numeric-value arg) 0)))
5393 (when gnus-dead-summary-mode
5394 (gnus-add-minor-mode
5395 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5397 (defun gnus-deaden-summary ()
5398 "Make the current summary buffer into a dead summary buffer."
5399 ;; Kill any previous dead summary buffer.
5400 (when (and gnus-dead-summary
5401 (buffer-name gnus-dead-summary))
5403 (set-buffer gnus-dead-summary)
5404 (when gnus-dead-summary-mode
5405 (kill-buffer (current-buffer)))))
5406 ;; Make this the current dead summary.
5407 (setq gnus-dead-summary (current-buffer))
5408 (gnus-dead-summary-mode 1)
5409 (let ((name (buffer-name)))
5410 (when (string-match "Summary" name)
5412 (concat (substring name 0 (match-beginning 0)) "Dead "
5413 (substring name (match-beginning 0)))
5416 (defun gnus-kill-or-deaden-summary (buffer)
5417 "Kill or deaden the summary BUFFER."
5419 (when (and (buffer-name buffer)
5420 (not gnus-single-article-buffer))
5423 (gnus-kill-buffer gnus-article-buffer)
5424 (gnus-kill-buffer gnus-original-article-buffer)))
5425 (cond (gnus-kill-summary-on-exit
5426 (when (and gnus-use-trees
5427 (gnus-buffer-exists-p buffer))
5430 (gnus-tree-close gnus-newsgroup-name)))
5431 (gnus-kill-buffer buffer))
5432 ((gnus-buffer-exists-p buffer)
5435 (gnus-deaden-summary))))))
5437 (defun gnus-summary-wake-up-the-dead (&rest args)
5438 "Wake up the dead summary buffer."
5440 (gnus-dead-summary-mode -1)
5441 (let ((name (buffer-name)))
5442 (when (string-match "Dead " name)
5444 (concat (substring name 0 (match-beginning 0))
5445 (substring name (match-end 0)))
5447 (gnus-message 3 "This dead summary is now alive again"))
5449 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5450 (defun gnus-summary-fetch-faq (&optional faq-dir)
5451 "Fetch the FAQ for the current group.
5452 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5456 (when current-prefix-arg
5458 "Faq dir: " (and (listp gnus-group-faq-directory)
5459 (mapcar (lambda (file) (list file))
5460 gnus-group-faq-directory))))))
5461 (let (gnus-faq-buffer)
5462 (when (setq gnus-faq-buffer
5463 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5464 (gnus-configure-windows 'summary-faq))))
5466 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5467 (defun gnus-summary-describe-group (&optional force)
5468 "Describe the current newsgroup."
5470 (gnus-group-describe-group force gnus-newsgroup-name))
5472 (defun gnus-summary-describe-briefly ()
5473 "Describe summary mode commands briefly."
5475 (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")))
5477 ;; Walking around group mode buffer from summary mode.
5479 (defun gnus-summary-next-group (&optional no-article target-group backward)
5480 "Exit current newsgroup and then select next unread newsgroup.
5481 If prefix argument NO-ARTICLE is non-nil, no article is selected
5482 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5483 previous group instead."
5485 ;; Stop pre-fetching.
5486 (gnus-async-halt-prefetch)
5487 (let ((current-group gnus-newsgroup-name)
5488 (current-buffer (current-buffer))
5490 ;; First we semi-exit this group to update Xrefs and all variables.
5491 ;; We can't do a real exit, because the window conf must remain
5492 ;; the same in case the user is prompted for info, and we don't
5493 ;; want the window conf to change before that...
5494 (gnus-summary-exit t)
5495 (while (not entered)
5496 ;; Then we find what group we are supposed to enter.
5497 (set-buffer gnus-group-buffer)
5498 (gnus-group-jump-to-group current-group)
5501 (if (eq gnus-keep-same-level 'best)
5502 (gnus-summary-best-group gnus-newsgroup-name)
5503 (gnus-summary-search-group backward gnus-keep-same-level))))
5504 (if (not target-group)
5505 ;; There are no further groups, so we return to the group
5508 (gnus-message 5 "Returning to the group buffer")
5510 (when (gnus-buffer-live-p current-buffer)
5511 (set-buffer current-buffer)
5512 (gnus-summary-exit))
5513 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5514 ;; We try to enter the target group.
5515 (gnus-group-jump-to-group target-group)
5516 (let ((unreads (gnus-group-group-unread)))
5517 (if (and (or (eq t unreads)
5518 (and unreads (not (zerop unreads))))
5519 (gnus-summary-read-group
5520 target-group nil no-article
5521 (and (buffer-name current-buffer) current-buffer)
5524 (setq current-group target-group
5525 target-group nil)))))))
5527 (defun gnus-summary-prev-group (&optional no-article)
5528 "Exit current newsgroup and then select previous unread newsgroup.
5529 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5531 (gnus-summary-next-group no-article nil t))
5533 ;; Walking around summary lines.
5535 (defun gnus-summary-first-subject (&optional unread undownloaded)
5536 "Go to the first unread subject.
5537 If UNREAD is non-nil, go to the first unread article.
5538 Returns the article selected or nil if there are no unread articles."
5543 ((null gnus-newsgroup-data)
5544 (gnus-message 3 "No articles in the group")
5546 ;; Pick the first article.
5548 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5549 (gnus-data-number (car gnus-newsgroup-data)))
5550 ;; No unread articles.
5551 ((null gnus-newsgroup-unreads)
5552 (gnus-message 3 "No more unread articles")
5554 ;; Find the first unread article.
5556 (let ((data gnus-newsgroup-data))
5558 (and (not (and undownloaded
5559 (eq gnus-undownloaded-mark
5560 (gnus-data-mark (car data)))))
5561 (not (gnus-data-unread-p (car data)))))
5562 (setq data (cdr data)))
5564 (goto-char (gnus-data-pos (car data)))
5565 (gnus-data-number (car data))))))
5566 (gnus-summary-position-point)))
5568 (defun gnus-summary-next-subject (n &optional unread dont-display)
5569 "Go to next N'th summary line.
5570 If N is negative, go to the previous N'th subject line.
5571 If UNREAD is non-nil, only unread articles are selected.
5572 The difference between N and the actual number of steps taken is
5575 (let ((backward (< n 0))
5579 (gnus-summary-find-prev unread)
5580 (gnus-summary-find-next unread)))
5581 (gnus-summary-show-thread)
5584 (gnus-message 7 "No more%s articles"
5585 (if unread " unread" "")))
5586 (unless dont-display
5587 (gnus-summary-recenter)
5588 (gnus-summary-position-point))
5591 (defun gnus-summary-next-unread-subject (n)
5592 "Go to next N'th unread summary line."
5594 (gnus-summary-next-subject n t))
5596 (defun gnus-summary-prev-subject (n &optional unread)
5597 "Go to previous N'th summary line.
5598 If optional argument UNREAD is non-nil, only unread article is selected."
5600 (gnus-summary-next-subject (- n) unread))
5602 (defun gnus-summary-prev-unread-subject (n)
5603 "Go to previous N'th unread summary line."
5605 (gnus-summary-next-subject (- n) t))
5607 (defun gnus-summary-goto-subject (article &optional force silent)
5608 "Go the subject line of ARTICLE.
5609 If FORCE, also allow jumping to articles not currently shown."
5610 (interactive "nArticle number: ")
5612 (data (gnus-data-find article)))
5613 ;; We read in the article if we have to.
5616 (gnus-summary-insert-subject
5618 (if (or (numberp force) (vectorp force)) force)
5620 (setq data (gnus-data-find article)))
5625 (gnus-message 3 "Can't find article %d" article))
5627 (goto-char (gnus-data-pos data))
5628 (gnus-summary-position-point)
5631 ;; Walking around summary lines with displaying articles.
5633 (defun gnus-summary-expand-window (&optional arg)
5634 "Make the summary buffer take up the entire Emacs frame.
5635 Given a prefix, will force an `article' buffer configuration."
5638 (gnus-configure-windows 'article 'force)
5639 (gnus-configure-windows 'summary 'force)))
5641 (defun gnus-summary-display-article (article &optional all-header)
5642 "Display ARTICLE in article buffer."
5643 (gnus-set-global-variables)
5647 (if gnus-summary-display-article-function
5648 (funcall gnus-summary-display-article-function article all-header)
5649 (gnus-article-prepare article all-header))
5650 (gnus-run-hooks 'gnus-select-article-hook)
5651 (when (and gnus-current-article
5652 (not (zerop gnus-current-article)))
5653 (gnus-summary-goto-subject gnus-current-article))
5654 (gnus-summary-recenter)
5655 (when (and gnus-use-trees gnus-show-threads)
5656 (gnus-possibly-generate-tree article)
5657 (gnus-highlight-selected-tree article))
5658 ;; Successfully display article.
5659 (gnus-article-set-window-start
5660 (cdr (assq article gnus-newsgroup-bookmarks))))))
5662 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5663 "Select the current article.
5664 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5665 non-nil, the article will be re-fetched even if it already present in
5666 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5668 ;; Make sure we are in the summary buffer to work around bbdb bug.
5669 (unless (eq major-mode 'gnus-summary-mode)
5670 (set-buffer gnus-summary-buffer))
5671 (let ((article (or article (gnus-summary-article-number)))
5672 (all-headers (not (not all-headers))) ;Must be T or NIL.
5673 gnus-summary-display-article-function
5676 (gnus-summary-article-pseudo-p article)
5677 (error "This is a pseudo-article"))
5680 (set-buffer gnus-summary-buffer)
5681 (if (or (and gnus-single-article-buffer
5682 (or (null gnus-current-article)
5683 (null gnus-article-current)
5684 (null (get-buffer gnus-article-buffer))
5685 (not (eq article (cdr gnus-article-current)))
5686 (not (equal (car gnus-article-current)
5687 gnus-newsgroup-name))))
5688 (and (not gnus-single-article-buffer)
5689 (or (null gnus-current-article)
5690 (not (eq gnus-current-article article))))
5692 ;; The requested article is different from the current article.
5694 (gnus-summary-display-article article all-headers)
5696 (when (or all-headers gnus-show-all-headers)
5697 (gnus-article-show-all-headers)))
5698 (when (or all-headers gnus-show-all-headers)
5699 (gnus-article-show-all-headers))
5702 (gnus-article-set-window-start
5703 (cdr (assq article gnus-newsgroup-bookmarks)))))))
5705 (defun gnus-summary-set-current-mark (&optional current-mark)
5706 "Obsolete function."
5709 (defun gnus-summary-next-article (&optional unread subject backward push)
5710 "Select the next article.
5711 If UNREAD, only unread articles are selected.
5712 If SUBJECT, only articles with SUBJECT are selected.
5713 If BACKWARD, the previous article is selected instead of the next."
5716 ;; Is there such an article?
5717 ((and (gnus-summary-search-forward unread subject backward)
5718 (or (gnus-summary-display-article (gnus-summary-article-number))
5719 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5720 (gnus-summary-position-point))
5721 ;; If not, we try the first unread, if that is wanted.
5723 gnus-auto-select-same
5724 (gnus-summary-first-unread-article))
5725 (gnus-summary-position-point)
5726 (gnus-message 6 "Wrapped"))
5727 ;; Try to get next/previous article not displayed in this group.
5728 ((and gnus-auto-extend-newsgroup
5729 (not unread) (not subject))
5730 (gnus-summary-goto-article
5731 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5732 nil (count-lines (point-min) (point))))
5733 ;; Go to next/previous group.
5735 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5736 (gnus-summary-jump-to-group gnus-newsgroup-name))
5737 (let ((cmd last-command-char)
5740 (set-buffer gnus-group-buffer)
5743 (if (eq gnus-keep-same-level 'best)
5744 (gnus-summary-best-group gnus-newsgroup-name)
5745 (gnus-summary-search-group backward gnus-keep-same-level))))
5746 ;; For some reason, the group window gets selected. We change
5748 (select-window (get-buffer-window (current-buffer)))
5749 ;; Select next unread newsgroup automagically.
5751 ((or (not gnus-auto-select-next)
5753 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5754 ((or (eq gnus-auto-select-next 'quietly)
5755 (and (eq gnus-auto-select-next 'slightly-quietly)
5757 (and (eq gnus-auto-select-next 'almost-quietly)
5758 (gnus-summary-last-article-p)))
5760 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5762 (gnus-message 7 "No more%s articles (%s)..."
5763 (if unread " unread" "")
5764 (if group (concat "selecting " group)
5766 (gnus-summary-next-group nil group backward)))
5768 (when (gnus-key-press-event-p last-input-event)
5769 (gnus-summary-walk-group-buffer
5770 gnus-newsgroup-name cmd unread backward point))))))))
5772 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5773 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5774 (?\C-p (gnus-group-prev-unread-group 1))))
5775 (cursor-in-echo-area t)
5776 keve key group ended)
5778 (set-buffer gnus-group-buffer)
5781 (if (eq gnus-keep-same-level 'best)
5782 (gnus-summary-best-group gnus-newsgroup-name)
5783 (gnus-summary-search-group backward gnus-keep-same-level))))
5786 5 "No more%s articles%s" (if unread " unread" "")
5788 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5789 (format " (Type %s for %s [%s])"
5790 (single-key-description cmd) group
5791 (car (gnus-gethash group gnus-newsrc-hashtb)))
5792 (format " (Type %s to exit %s)"
5793 (single-key-description cmd)
5794 gnus-newsgroup-name)))
5795 ;; Confirm auto selection.
5796 (setq key (car (setq keve (gnus-read-event-char))))
5799 ((assq key keystrokes)
5800 (let ((obuf (current-buffer)))
5801 (switch-to-buffer gnus-group-buffer)
5803 (gnus-group-jump-to-group group))
5804 (eval (cadr (assq key keystrokes)))
5805 (setq group (gnus-group-group-name))
5806 (switch-to-buffer obuf))
5810 (gnus-ephemeral-group-p gnus-newsgroup-name))
5812 (gnus-summary-next-group nil group backward)))
5814 (push (cdr keve) unread-command-events))))))
5816 (defun gnus-summary-next-unread-article ()
5817 "Select unread article after current one."
5819 (gnus-summary-next-article
5820 (or (not (eq gnus-summary-goto-unread 'never))
5821 (gnus-summary-last-article-p (gnus-summary-article-number)))
5822 (and gnus-auto-select-same
5823 (gnus-summary-article-subject))))
5825 (defun gnus-summary-prev-article (&optional unread subject)
5826 "Select the article after the current one.
5827 If UNREAD is non-nil, only unread articles are selected."
5829 (gnus-summary-next-article unread subject t))
5831 (defun gnus-summary-prev-unread-article ()
5832 "Select unread article before current one."
5834 (gnus-summary-prev-article
5835 (or (not (eq gnus-summary-goto-unread 'never))
5836 (gnus-summary-first-article-p (gnus-summary-article-number)))
5837 (and gnus-auto-select-same
5838 (gnus-summary-article-subject))))
5840 (defun gnus-summary-next-page (&optional lines circular)
5841 "Show next page of the selected article.
5842 If at the end of the current article, select the next article.
5843 LINES says how many lines should be scrolled up.
5845 If CIRCULAR is non-nil, go to the start of the article instead of
5846 selecting the next article when reaching the end of the current
5849 (setq gnus-summary-buffer (current-buffer))
5850 (gnus-set-global-variables)
5851 (let ((article (gnus-summary-article-number))
5852 (article-window (get-buffer-window gnus-article-buffer t))
5854 ;; If the buffer is empty, we have no article.
5856 (error "No article to select"))
5857 (gnus-configure-windows 'article)
5858 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
5859 (if (and (eq gnus-summary-goto-unread 'never)
5860 (not (gnus-summary-last-article-p article)))
5861 (gnus-summary-next-article)
5862 (gnus-summary-next-unread-article))
5863 (if (or (null gnus-current-article)
5864 (null gnus-article-current)
5865 (/= article (cdr gnus-article-current))
5866 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5867 ;; Selected subject is different from current article's.
5868 (gnus-summary-display-article article)
5869 (when article-window
5870 (gnus-eval-in-buffer-window gnus-article-buffer
5871 (setq endp (gnus-article-next-page lines)))
5874 (gnus-summary-beginning-of-article))
5876 (gnus-message 3 "End of message"))
5878 (if (and (eq gnus-summary-goto-unread 'never)
5879 (not (gnus-summary-last-article-p article)))
5880 (gnus-summary-next-article)
5881 (gnus-summary-next-unread-article))))))))
5882 (gnus-summary-recenter)
5883 (gnus-summary-position-point)))
5885 (defun gnus-summary-prev-page (&optional lines move)
5886 "Show previous page of selected article.
5887 Argument LINES specifies lines to be scrolled down.
5888 If MOVE, move to the previous unread article if point is at
5889 the beginning of the buffer."
5891 (let ((article (gnus-summary-article-number))
5892 (article-window (get-buffer-window gnus-article-buffer t))
5894 (gnus-configure-windows 'article)
5895 (if (or (null gnus-current-article)
5896 (null gnus-article-current)
5897 (/= article (cdr gnus-article-current))
5898 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5899 ;; Selected subject is different from current article's.
5900 (gnus-summary-display-article article)
5901 (gnus-summary-recenter)
5902 (when article-window
5903 (gnus-eval-in-buffer-window gnus-article-buffer
5904 (setq endp (gnus-article-prev-page lines)))
5905 (when (and move endp)
5907 (gnus-message 3 "Beginning of message"))
5909 (if (and (eq gnus-summary-goto-unread 'never)
5910 (not (gnus-summary-first-article-p article)))
5911 (gnus-summary-prev-article)
5912 (gnus-summary-prev-unread-article))))))))
5913 (gnus-summary-position-point))
5915 (defun gnus-summary-prev-page-or-article (&optional lines)
5916 "Show previous page of selected article.
5917 Argument LINES specifies lines to be scrolled down.
5918 If at the beginning of the article, go to the next article."
5920 (gnus-summary-prev-page lines t))
5922 (defun gnus-summary-scroll-up (lines)
5923 "Scroll up (or down) one line current article.
5924 Argument LINES specifies lines to be scrolled up (or down if negative)."
5926 (gnus-configure-windows 'article)
5927 (gnus-summary-show-thread)
5928 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
5929 (gnus-eval-in-buffer-window gnus-article-buffer
5931 (when (gnus-article-next-page lines)
5932 (gnus-message 3 "End of message")))
5934 (gnus-article-prev-page (- lines))))))
5935 (gnus-summary-recenter)
5936 (gnus-summary-position-point))
5938 (defun gnus-summary-scroll-down (lines)
5939 "Scroll down (or up) one line current article.
5940 Argument LINES specifies lines to be scrolled down (or up if negative)."
5942 (gnus-summary-scroll-up (- lines)))
5944 (defun gnus-summary-next-same-subject ()
5945 "Select next article which has the same subject as current one."
5947 (gnus-summary-next-article nil (gnus-summary-article-subject)))
5949 (defun gnus-summary-prev-same-subject ()
5950 "Select previous article which has the same subject as current one."
5952 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
5954 (defun gnus-summary-next-unread-same-subject ()
5955 "Select next unread article which has the same subject as current one."
5957 (gnus-summary-next-article t (gnus-summary-article-subject)))
5959 (defun gnus-summary-prev-unread-same-subject ()
5960 "Select previous unread article which has the same subject as current one."
5962 (gnus-summary-prev-article t (gnus-summary-article-subject)))
5964 (defun gnus-summary-first-unread-article ()
5965 "Select the first unread article.
5966 Return nil if there are no unread articles."
5969 (when (gnus-summary-first-subject t)
5970 (gnus-summary-show-thread)
5971 (gnus-summary-first-subject t)
5972 (gnus-summary-display-article (gnus-summary-article-number)))
5973 (gnus-summary-position-point)))
5975 (defun gnus-summary-first-unread-subject ()
5976 "Place the point on the subject line of the first unread article.
5977 Return nil if there are no unread articles."
5980 (when (gnus-summary-first-subject t)
5981 (gnus-summary-show-thread)
5982 (gnus-summary-first-subject t))
5983 (gnus-summary-position-point)))
5985 (defun gnus-summary-first-article ()
5986 "Select the first article.
5987 Return nil if there are no articles."
5990 (when (gnus-summary-first-subject)
5991 (gnus-summary-show-thread)
5992 (gnus-summary-first-subject)
5993 (gnus-summary-display-article (gnus-summary-article-number)))
5994 (gnus-summary-position-point)))
5996 (defun gnus-summary-best-unread-article ()
5997 "Select the unread article with the highest score."
5999 (let ((best -1000000)
6000 (data gnus-newsgroup-data)
6003 (and (gnus-data-unread-p (car data))
6005 (gnus-summary-article-score (gnus-data-number (car data))))
6008 article (gnus-data-number (car data))))
6009 (setq data (cdr data)))
6012 (gnus-summary-goto-article article)
6013 (error "No unread articles"))
6014 (gnus-summary-position-point))))
6016 (defun gnus-summary-last-subject ()
6017 "Go to the last displayed subject line in the group."
6018 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6020 (gnus-summary-goto-subject article))))
6022 (defun gnus-summary-goto-article (article &optional all-headers force)
6023 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6024 If ALL-HEADERS is non-nil, no header lines are hidden.
6025 If FORCE, go to the article even if it isn't displayed. If FORCE
6026 is a number, it is the line the article is to be displayed on."
6030 "Article number or Message-ID: "
6031 (mapcar (lambda (number) (list (int-to-string number)))
6032 gnus-newsgroup-limit))
6036 (if (and (stringp article)
6037 (string-match "@" article))
6038 (gnus-summary-refer-article article)
6039 (when (stringp article)
6040 (setq article (string-to-number article)))
6041 (if (gnus-summary-goto-subject article force)
6042 (gnus-summary-display-article article all-headers)
6043 (gnus-message 4 "Couldn't go to article %s" article) nil))
6044 (gnus-summary-position-point)))
6046 (defun gnus-summary-goto-last-article ()
6047 "Go to the previously read article."
6050 (when gnus-last-article
6051 (gnus-summary-goto-article gnus-last-article nil t))
6052 (gnus-summary-position-point)))
6054 (defun gnus-summary-pop-article (number)
6055 "Pop one article off the history and go to the previous.
6056 NUMBER articles will be popped off."
6059 (setq gnus-newsgroup-history
6060 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6062 (gnus-summary-goto-article (car to) nil t)
6063 (error "Article history empty")))
6064 (gnus-summary-position-point))
6066 ;; Summary commands and functions for limiting the summary buffer.
6068 (defun gnus-summary-limit-to-articles (n)
6069 "Limit the summary buffer to the next N articles.
6070 If not given a prefix, use the process marked articles instead."
6073 (let ((articles (gnus-summary-work-articles n)))
6074 (setq gnus-newsgroup-processable nil)
6075 (gnus-summary-limit articles))
6076 (gnus-summary-position-point)))
6078 (defun gnus-summary-pop-limit (&optional total)
6079 "Restore the previous limit.
6080 If given a prefix, remove all limits."
6083 (setq gnus-newsgroup-limits
6084 (list (mapcar (lambda (h) (mail-header-number h))
6085 gnus-newsgroup-headers))))
6086 (unless gnus-newsgroup-limits
6087 (error "No limit to pop"))
6089 (gnus-summary-limit nil 'pop)
6090 (gnus-summary-position-point)))
6092 (defun gnus-summary-limit-to-subject (subject &optional header)
6093 "Limit the summary buffer to articles that have subjects that match a regexp."
6094 (interactive "sLimit to subject (regexp): ")
6096 (setq header "subject"))
6097 (when (not (equal "" subject))
6099 (let ((articles (gnus-summary-find-matching
6100 (or header "subject") subject 'all)))
6102 (error "Found no matches for \"%s\"" subject))
6103 (gnus-summary-limit articles))
6104 (gnus-summary-position-point))))
6106 (defun gnus-summary-limit-to-author (from)
6107 "Limit the summary buffer to articles that have authors that match a regexp."
6108 (interactive "sLimit to author (regexp): ")
6109 (gnus-summary-limit-to-subject from "from"))
6111 (defun gnus-summary-limit-to-age (age &optional younger-p)
6112 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6113 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6114 articles that are younger than AGE days."
6115 (interactive "nTime in days: \nP")
6117 (let ((data gnus-newsgroup-data)
6118 (cutoff (days-to-time age))
6119 articles d date is-younger)
6120 (while (setq d (pop data))
6121 (when (and (vectorp (gnus-data-header d))
6122 (setq date (mail-header-date (gnus-data-header d))))
6123 (setq is-younger (time-less-p
6124 (time-since (date-to-time date))
6129 (push (gnus-data-number d) articles))))
6130 (gnus-summary-limit (nreverse articles)))
6131 (gnus-summary-position-point)))
6133 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6135 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6137 (defun gnus-summary-limit-to-unread (&optional all)
6138 "Limit the summary buffer to articles that are not marked as read.
6139 If ALL is non-nil, limit strictly to unread articles."
6142 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6143 (gnus-summary-limit-to-marks
6144 ;; Concat all the marks that say that an article is read and have
6146 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6147 gnus-killed-mark gnus-kill-file-mark
6148 gnus-low-score-mark gnus-expirable-mark
6149 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6150 gnus-duplicate-mark gnus-souped-mark)
6153 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6154 (make-obsolete 'gnus-summary-delete-marked-with
6155 'gnus-summary-limit-exlude-marks)
6157 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6158 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6159 If REVERSE, limit the summary buffer to articles that are marked
6160 with MARKS. MARKS can either be a string of marks or a list of marks.
6161 Returns how many articles were removed."
6162 (interactive "sMarks: ")
6163 (gnus-summary-limit-to-marks marks t))
6165 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6166 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6167 If REVERSE (the prefix), limit the summary buffer to articles that are
6168 not marked with MARKS. MARKS can either be a string of marks or a
6170 Returns how many articles were removed."
6171 (interactive "sMarks: \nP")
6173 (let ((data gnus-newsgroup-data)
6174 (marks (if (listp marks) marks
6175 (append marks nil))) ; Transform to list.
6178 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6179 (memq (gnus-data-mark (car data)) marks))
6180 (push (gnus-data-number (car data)) articles))
6181 (setq data (cdr data)))
6182 (gnus-summary-limit articles))
6183 (gnus-summary-position-point)))
6185 (defun gnus-summary-limit-to-score (&optional score)
6186 "Limit to articles with score at or above SCORE."
6188 (setq score (if score
6189 (prefix-numeric-value score)
6190 (or gnus-summary-default-score 0)))
6191 (let ((data gnus-newsgroup-data)
6194 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6196 (push (gnus-data-number (car data)) articles))
6197 (setq data (cdr data)))
6199 (gnus-summary-limit articles)
6200 (gnus-summary-position-point))))
6202 (defun gnus-summary-limit-include-thread (id)
6203 "Display all the hidden articles that in the current thread."
6204 (interactive (list (mail-header-id (gnus-summary-article-header))))
6205 (let ((articles (gnus-articles-in-thread
6206 (gnus-id-to-thread (gnus-root-id id)))))
6208 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6209 (gnus-summary-position-point))))
6211 (defun gnus-summary-limit-include-dormant ()
6212 "Display all the hidden articles that are marked as dormant.
6213 Note that this command only works on a subset of the articles currently
6214 fetched for this group."
6216 (unless gnus-newsgroup-dormant
6217 (error "There are no dormant articles in this group"))
6219 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6220 (gnus-summary-position-point)))
6222 (defun gnus-summary-limit-exclude-dormant ()
6223 "Hide all dormant articles."
6226 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6227 (gnus-summary-position-point)))
6229 (defun gnus-summary-limit-exclude-childless-dormant ()
6230 "Hide all dormant articles that have no children."
6232 (let ((data (gnus-data-list t))
6233 articles d children)
6234 ;; Find all articles that are either not dormant or have
6236 (while (setq d (pop data))
6237 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6239 (gnus-article-children (gnus-data-number d)))
6242 (when (memq (car children) articles)
6247 (push (gnus-data-number d) articles)))
6250 (gnus-summary-limit articles)
6251 (gnus-summary-position-point))))
6253 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6254 "Mark all unread excluded articles as read.
6255 If ALL, mark even excluded ticked and dormants as read."
6257 (let ((articles (gnus-sorted-complement
6259 (mapcar (lambda (h) (mail-header-number h))
6260 gnus-newsgroup-headers)
6262 (sort gnus-newsgroup-limit '<)))
6264 (setq gnus-newsgroup-unreads
6265 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6267 (setq gnus-newsgroup-dormant nil
6268 gnus-newsgroup-marked nil
6269 gnus-newsgroup-reads
6271 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6272 gnus-newsgroup-reads))
6273 (while (setq article (pop articles))
6274 (unless (or (memq article gnus-newsgroup-dormant)
6275 (memq article gnus-newsgroup-marked))
6276 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6278 (defun gnus-summary-limit (articles &optional pop)
6280 ;; We pop the previous limit off the stack and use that.
6281 (setq articles (car gnus-newsgroup-limits)
6282 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6283 ;; We use the new limit, so we push the old limit on the stack.
6284 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6286 (setq gnus-newsgroup-limit articles)
6287 (let ((total (length gnus-newsgroup-data))
6288 (data (gnus-data-find-list (gnus-summary-article-number)))
6289 (gnus-summary-mark-below nil) ; Inhibit this.
6291 ;; This will do all the work of generating the new summary buffer
6292 ;; according to the new limit.
6293 (gnus-summary-prepare)
6294 ;; Hide any threads, possibly.
6295 (and gnus-show-threads
6296 gnus-thread-hide-subtree
6297 (gnus-summary-hide-all-threads))
6298 ;; Try to return to the article you were at, or one in the
6301 ;; We try to find some article after the current one.
6303 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6306 (setq data (cdr data))))
6308 ;; If there is no data, that means that we were after the last
6309 ;; article. The same goes when we can't find any articles
6310 ;; after the current one.
6311 (goto-char (point-max))
6312 (gnus-summary-find-prev))
6313 (gnus-set-mode-line 'summary)
6314 ;; We return how many articles were removed from the summary
6315 ;; buffer as a result of the new limit.
6316 (- total (length gnus-newsgroup-data))))
6318 (defsubst gnus-invisible-cut-children (threads)
6321 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6326 (defsubst gnus-cut-thread (thread)
6327 "Go forwards in the thread until we find an article that we want to display."
6328 (when (or (eq gnus-fetch-old-headers 'some)
6329 (eq gnus-fetch-old-headers 'invisible)
6330 (eq gnus-build-sparse-threads 'some)
6331 (eq gnus-build-sparse-threads 'more))
6332 ;; Deal with old-fetched headers and sparse threads.
6336 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6337 (gnus-summary-article-ancient-p
6338 (mail-header-number (car thread))))
6339 (if (or (<= (length (cdr thread)) 1)
6340 (eq gnus-fetch-old-headers 'invisible))
6341 (setq gnus-newsgroup-limit
6342 (delq (mail-header-number (car thread))
6343 gnus-newsgroup-limit)
6344 thread (cadr thread))
6345 (when (gnus-invisible-cut-children (cdr thread))
6346 (let ((th (cdr thread)))
6348 (if (memq (mail-header-number (caar th))
6349 gnus-newsgroup-limit)
6350 (setq thread (car th)
6352 (setq th (cdr th))))))))))
6355 (defun gnus-cut-threads (threads)
6356 "Cut off all uninteresting articles from the beginning of threads."
6357 (when (or (eq gnus-fetch-old-headers 'some)
6358 (eq gnus-fetch-old-headers 'invisible)
6359 (eq gnus-build-sparse-threads 'some)
6360 (eq gnus-build-sparse-threads 'more))
6363 (setcar th (gnus-cut-thread (car th)))
6364 (setq th (cdr th)))))
6365 ;; Remove nixed out threads.
6368 (defun gnus-summary-initial-limit (&optional show-if-empty)
6369 "Figure out what the initial limit is supposed to be on group entry.
6370 This entails weeding out unwanted dormants, low-scored articles,
6371 fetch-old-headers verbiage, and so on."
6372 ;; Most groups have nothing to remove.
6373 (if (or gnus-inhibit-limiting
6374 (and (null gnus-newsgroup-dormant)
6375 (not (eq gnus-fetch-old-headers 'some))
6376 (not (eq gnus-fetch-old-headers 'invisible))
6377 (null gnus-summary-expunge-below)
6378 (not (eq gnus-build-sparse-threads 'some))
6379 (not (eq gnus-build-sparse-threads 'more))
6380 (null gnus-thread-expunge-below)
6381 (not gnus-use-nocem)))
6383 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6384 (setq gnus-newsgroup-limit nil)
6387 (unless (car (symbol-value node))
6388 ;; These threads have no parents -- they are roots.
6389 (let ((nodes (cdr (symbol-value node)))
6392 (if (and gnus-thread-expunge-below
6393 (< (gnus-thread-total-score (car nodes))
6394 gnus-thread-expunge-below))
6395 (gnus-expunge-thread (pop nodes))
6396 (setq thread (pop nodes))
6397 (gnus-summary-limit-children thread))))))
6398 gnus-newsgroup-dependencies)
6399 ;; If this limitation resulted in an empty group, we might
6400 ;; pop the previous limit and use it instead.
6401 (when (and (not gnus-newsgroup-limit)
6403 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6404 gnus-newsgroup-limit))
6406 (defun gnus-summary-limit-children (thread)
6407 "Return 1 if this subthread is visible and 0 if it is not."
6408 ;; First we get the number of visible children to this thread. This
6409 ;; is done by recursing down the thread using this function, so this
6410 ;; will really go down to a leaf article first, before slowly
6411 ;; working its way up towards the root.
6415 (apply '+ (mapcar 'gnus-summary-limit-children
6418 (number (mail-header-number (car thread)))
6421 (not (memq number gnus-newsgroup-marked))
6423 ;; If this article is dormant and has absolutely no visible
6424 ;; children, then this article isn't visible.
6425 (and (memq number gnus-newsgroup-dormant)
6427 ;; If this is "fetch-old-headered" and there is no
6428 ;; visible children, then we don't want this article.
6429 (and (eq gnus-fetch-old-headers 'some)
6430 (gnus-summary-article-ancient-p number)
6432 ;; If this is "fetch-old-headered" and `invisible', then
6433 ;; we don't want this article.
6434 (and (eq gnus-fetch-old-headers 'invisible)
6435 (gnus-summary-article-ancient-p number))
6436 ;; If this is a sparsely inserted article with no children,
6437 ;; we don't want it.
6438 (and (eq gnus-build-sparse-threads 'some)
6439 (gnus-summary-article-sparse-p number)
6441 ;; If we use expunging, and this article is really
6442 ;; low-scored, then we don't want this article.
6443 (when (and gnus-summary-expunge-below
6445 (or (cdr (assq number gnus-newsgroup-scored))
6446 gnus-summary-default-score))
6447 gnus-summary-expunge-below))
6448 ;; We increase the expunge-tally here, but that has
6449 ;; nothing to do with the limits, really.
6450 (incf gnus-newsgroup-expunged-tally)
6451 ;; We also mark as read here, if that's wanted.
6452 (when (and gnus-summary-mark-below
6453 (< score gnus-summary-mark-below))
6454 (setq gnus-newsgroup-unreads
6455 (delq number gnus-newsgroup-unreads))
6456 (if gnus-newsgroup-auto-expire
6457 (push number gnus-newsgroup-expirable)
6458 (push (cons number gnus-low-score-mark)
6459 gnus-newsgroup-reads)))
6461 ;; Check NoCeM things.
6462 (if (and gnus-use-nocem
6463 (gnus-nocem-unwanted-article-p
6464 (mail-header-id (car thread))))
6466 (setq gnus-newsgroup-unreads
6467 (delq number gnus-newsgroup-unreads))
6469 ;; Nope, invisible article.
6471 ;; Ok, this article is to be visible, so we add it to the limit
6473 (push number gnus-newsgroup-limit)
6476 (defun gnus-expunge-thread (thread)
6477 "Mark all articles in THREAD as read."
6478 (let* ((number (mail-header-number (car thread))))
6479 (incf gnus-newsgroup-expunged-tally)
6480 ;; We also mark as read here, if that's wanted.
6481 (setq gnus-newsgroup-unreads
6482 (delq number gnus-newsgroup-unreads))
6483 (if gnus-newsgroup-auto-expire
6484 (push number gnus-newsgroup-expirable)
6485 (push (cons number gnus-low-score-mark)
6486 gnus-newsgroup-reads)))
6487 ;; Go recursively through all subthreads.
6488 (mapcar 'gnus-expunge-thread (cdr thread)))
6490 ;; Summary article oriented commands
6492 (defun gnus-summary-refer-parent-article (n)
6493 "Refer parent article N times.
6494 If N is negative, go to ancestor -N instead.
6495 The difference between N and the number of articles fetched is returned."
6499 (when (not (natnump n))
6504 (setq header (gnus-summary-article-header))
6505 (if (and (eq (mail-header-number header)
6506 (cdr gnus-article-current))
6507 (equal gnus-newsgroup-name
6508 (car gnus-article-current)))
6509 ;; If we try to find the parent of the currently
6510 ;; displayed article, then we take a look at the actual
6511 ;; References header, since this is slightly more
6512 ;; reliable than the References field we got from the
6515 (set-buffer gnus-original-article-buffer)
6516 (nnheader-narrow-to-headers)
6517 (unless (setq ref (message-fetch-field "references"))
6518 (setq ref (message-fetch-field "in-reply-to")))
6521 ;; It's not the current article, so we take a bet on
6522 ;; the value we got from the server.
6523 (mail-header-references header)))
6525 (not (equal ref "")))
6526 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6527 (gnus-message 1 "Couldn't find parent"))
6528 (gnus-message 1 "No references in article %d"
6529 (gnus-summary-article-number))
6532 (gnus-summary-position-point)
6535 (defun gnus-summary-refer-references ()
6536 "Fetch all articles mentioned in the References header.
6537 Return the number of articles fetched."
6539 (let ((ref (mail-header-references (gnus-summary-article-header)))
6540 (current (gnus-summary-article-number))
6544 (error "No References in the current article")
6545 ;; For each Message-ID in the References header...
6546 (while (string-match "<[^>]*>" ref)
6548 ;; ... fetch that article.
6549 (gnus-summary-refer-article
6550 (prog1 (match-string 0 ref)
6551 (setq ref (substring ref (match-end 0))))))
6552 (gnus-summary-goto-subject current)
6553 (gnus-summary-position-point)
6556 (defun gnus-summary-refer-thread (&optional limit)
6557 "Fetch all articles in the current thread.
6558 If LIMIT (the numerical prefix), fetch that many old headers instead
6559 of what's specified by the `gnus-refer-thread-limit' variable."
6561 (let ((id (mail-header-id (gnus-summary-article-header)))
6562 (limit (if limit (prefix-numeric-value limit)
6563 gnus-refer-thread-limit)))
6564 ;; We want to fetch LIMIT *old* headers, but we also have to
6565 ;; re-fetch all the headers in the current buffer, because many of
6566 ;; them may be undisplayed. So we adjust LIMIT.
6567 (when (numberp limit)
6568 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6569 (unless (eq gnus-fetch-old-headers 'invisible)
6570 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6571 ;; Retrieve the headers and read them in.
6572 (if (eq (gnus-retrieve-headers
6573 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6575 (gnus-build-all-threads)
6576 (error "Can't fetch thread from backends that don't support NOV"))
6577 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6578 (gnus-summary-limit-include-thread id)))
6580 (defun gnus-summary-refer-article (message-id &optional arg)
6581 "Fetch an article specified by MESSAGE-ID.
6582 If ARG (the prefix), fetch the article using `gnus-refer-article-method'
6583 or `gnus-select-method', no matter what backend the article comes from."
6584 (interactive "sMessage-ID: \nP")
6585 (when (and (stringp message-id)
6586 (not (zerop (length message-id))))
6587 ;; Construct the correct Message-ID if necessary.
6588 ;; Suggested by tale@pawl.rpi.edu.
6589 (unless (string-match "^<" message-id)
6590 (setq message-id (concat "<" message-id)))
6591 (unless (string-match ">$" message-id)
6592 (setq message-id (concat message-id ">")))
6593 (let* ((header (gnus-id-to-header message-id))
6595 (gnus-summary-article-sparse-p
6596 (mail-header-number header))
6597 (memq (mail-header-number header)
6598 gnus-newsgroup-limit))))
6600 ;; If the article is present in the buffer we just go to it.
6602 (or (not (gnus-summary-article-sparse-p
6603 (mail-header-number header)))
6606 (gnus-summary-goto-article
6607 (mail-header-number header) nil t)
6609 (gnus-summary-update-article (mail-header-number header)))))
6611 ;; We fetch the article
6612 (let ((gnus-override-method
6613 (cond ((gnus-news-group-p gnus-newsgroup-name)
6614 gnus-refer-article-method)
6616 (or gnus-refer-article-method gnus-select-method))
6619 ;; Start the special refer-article method, if necessary.
6620 (when (and gnus-refer-article-method
6621 (gnus-news-group-p gnus-newsgroup-name))
6622 (gnus-check-server gnus-refer-article-method))
6623 ;; Fetch the header, and display the article.
6624 (if (setq number (gnus-summary-insert-subject message-id))
6625 (gnus-summary-select-article nil nil nil number)
6626 (gnus-message 3 "Couldn't fetch article %s" message-id))))))))
6628 (defun gnus-summary-edit-parameters ()
6629 "Edit the group parameters of the current group."
6631 (gnus-group-edit-group gnus-newsgroup-name 'params))
6633 (defun gnus-summary-customize-parameters ()
6634 "Customize the group parameters of the current group."
6636 (gnus-group-customize gnus-newsgroup-name))
6638 (defun gnus-summary-enter-digest-group (&optional force)
6639 "Enter an nndoc group based on the current article.
6640 If FORCE, force a digest interpretation. If not, try
6641 to guess what the document format is."
6643 (let ((conf gnus-current-window-configuration))
6645 (gnus-summary-select-article))
6646 (setq gnus-current-window-configuration conf)
6647 (let* ((name (format "%s-%d"
6648 (gnus-group-prefixed-name
6649 gnus-newsgroup-name (list 'nndoc ""))
6651 (set-buffer gnus-summary-buffer)
6652 gnus-current-article)))
6653 (ogroup gnus-newsgroup-name)
6654 (params (append (gnus-info-params (gnus-get-info ogroup))
6655 (list (cons 'to-group ogroup))
6656 (list (cons 'save-article-group ogroup))))
6657 (case-fold-search t)
6658 (buf (current-buffer))
6661 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6662 (insert-buffer-substring gnus-original-article-buffer)
6663 ;; Remove lines that may lead nndoc to misinterpret the
6666 (goto-char (point-min))
6667 (or (search-forward "\n\n" nil t) (point)))
6668 (goto-char (point-min))
6669 (delete-matching-lines "^\\(Path\\):\\|^From ")
6672 (if (gnus-group-read-ephemeral-group
6673 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6675 ,(if force 'digest 'guess))) t)
6676 ;; Make all postings to this group go to the parent group.
6677 (nconc (gnus-info-params (gnus-get-info name))
6679 ;; Couldn't select this doc group.
6680 (switch-to-buffer buf)
6681 (gnus-set-global-variables)
6682 (gnus-configure-windows 'summary)
6683 (gnus-message 3 "Article couldn't be entered?"))
6684 (kill-buffer dig)))))
6686 (defun gnus-summary-read-document (n)
6687 "Open a new group based on the current article(s).
6688 This will allow you to read digests and other similar
6689 documents as newsgroups.
6690 Obeys the standard process/prefix convention."
6692 (let* ((articles (gnus-summary-work-articles n))
6693 (ogroup gnus-newsgroup-name)
6694 (params (append (gnus-info-params (gnus-get-info ogroup))
6695 (list (cons 'to-group ogroup))))
6696 article group egroup groups vgroup)
6697 (while (setq article (pop articles))
6698 (setq group (format "%s-%d" gnus-newsgroup-name article))
6699 (gnus-summary-remove-process-mark article)
6700 (when (gnus-summary-display-article article)
6703 (insert-buffer-substring gnus-original-article-buffer)
6704 ;; Remove some headers that may lead nndoc to make
6706 (message-narrow-to-head)
6707 (goto-char (point-min))
6708 (delete-matching-lines "^\\(Path\\):\\|^From ")
6711 (gnus-group-read-ephemeral-group
6712 group `(nndoc ,group (nndoc-address ,(current-buffer))
6713 (nndoc-article-type guess))
6716 ;; Make all postings to this group go to the parent group.
6717 (nconc (gnus-info-params (gnus-get-info egroup))
6719 (push egroup groups))
6720 ;; Couldn't select this doc group.
6721 (gnus-error 3 "Article couldn't be entered"))))))
6722 ;; Now we have selected all the documents.
6725 (error "None of the articles could be interpreted as documents"))
6726 ((gnus-group-read-ephemeral-group
6727 (setq vgroup (format
6728 "nnvirtual:%s-%s" gnus-newsgroup-name
6729 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6730 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6732 (cons (current-buffer) 'summary)))
6734 (error "Couldn't select virtual nndoc group")))))
6736 (defun gnus-summary-isearch-article (&optional regexp-p)
6737 "Do incremental search forward on the current article.
6738 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6740 (gnus-summary-select-article)
6741 (gnus-configure-windows 'article)
6742 (gnus-eval-in-buffer-window gnus-article-buffer
6745 (isearch-forward regexp-p))))
6747 (defun gnus-summary-search-article-forward (regexp &optional backward)
6748 "Search for an article containing REGEXP forward.
6749 If BACKWARD, search backward instead."
6752 (format "Search article %s (regexp%s): "
6753 (if current-prefix-arg "backward" "forward")
6754 (if gnus-last-search-regexp
6755 (concat ", default " gnus-last-search-regexp)
6757 current-prefix-arg))
6758 (if (string-equal regexp "")
6759 (setq regexp (or gnus-last-search-regexp ""))
6760 (setq gnus-last-search-regexp regexp))
6761 (if (gnus-summary-search-article regexp backward)
6762 (gnus-summary-show-thread)
6763 (error "Search failed: \"%s\"" regexp)))
6765 (defun gnus-summary-search-article-backward (regexp)
6766 "Search for an article containing REGEXP backward."
6769 (format "Search article backward (regexp%s): "
6770 (if gnus-last-search-regexp
6771 (concat ", default " gnus-last-search-regexp)
6773 (gnus-summary-search-article-forward regexp 'backward))
6775 (defun gnus-summary-search-article (regexp &optional backward)
6776 "Search for an article containing REGEXP.
6777 Optional argument BACKWARD means do search for backward.
6778 `gnus-select-article-hook' is not called during the search."
6779 ;; We have to require this here to make sure that the following
6780 ;; dynamic binding isn't shadowed by autoloading.
6781 (require 'gnus-async)
6783 (let ((gnus-select-article-hook nil) ;Disable hook.
6784 (gnus-article-display-hook nil)
6785 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6786 (gnus-use-article-prefetch nil)
6787 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
6788 (gnus-use-trees nil) ;Inhibit updating tree buffer.
6789 (sum (current-buffer))
6792 (gnus-save-hidden-threads
6793 (gnus-summary-select-article)
6794 (set-buffer gnus-article-buffer)
6798 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
6800 (re-search-backward regexp nil t)
6801 (re-search-forward regexp nil t))
6802 ;; We found the regexp.
6807 (get-buffer-window (current-buffer))
6811 (setq point (point)))
6812 ;; We didn't find it, so we go to the next article.
6815 (while (eq found 'not)
6816 (if (not (if backward (gnus-summary-find-prev)
6817 (gnus-summary-find-next)))
6818 ;; No more articles.
6820 ;; Select the next article and adjust point.
6821 (unless (gnus-summary-article-sparse-p
6822 (gnus-summary-article-number))
6824 (gnus-summary-select-article)
6825 (set-buffer gnus-article-buffer)
6827 (goto-char (if backward (point-max) (point-min))))))))
6828 (gnus-message 7 ""))
6829 ;; Return whether we found the regexp.
6830 (when (eq found 'found)
6832 (gnus-summary-show-thread)
6833 (gnus-summary-goto-subject gnus-current-article)
6834 (gnus-summary-position-point)
6837 (defun gnus-summary-find-matching (header regexp &optional backward unread
6839 "Return a list of all articles that match REGEXP on HEADER.
6840 The search stars on the current article and goes forwards unless
6841 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
6842 If UNREAD is non-nil, only unread articles will
6843 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
6844 in the comparisons."
6845 (let ((data (if (eq backward 'all) gnus-newsgroup-data
6846 (gnus-data-find-list
6847 (gnus-summary-article-number) (gnus-data-list backward))))
6848 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
6849 (case-fold-search (not not-case-fold))
6851 (unless (fboundp (intern (concat "mail-header-" header)))
6852 (error "%s is not a valid header" header))
6855 (and (or (not unread) ; We want all articles...
6856 (gnus-data-unread-p d)) ; Or just unreads.
6857 (vectorp (gnus-data-header d)) ; It's not a pseudo.
6858 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
6859 (push (gnus-data-number d) articles)) ; Success!
6860 (setq data (cdr data)))
6861 (nreverse articles)))
6863 (defun gnus-summary-execute-command (header regexp command &optional backward)
6864 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
6865 If HEADER is an empty string (or nil), the match is done on the entire
6866 article. If BACKWARD (the prefix) is non-nil, search backward instead."
6868 (list (let ((completion-ignore-case t))
6871 (mapcar (lambda (string) (list string))
6872 '("Number" "Subject" "From" "Lines" "Date"
6873 "Message-ID" "Xref" "References" "Body"))
6874 nil 'require-match))
6875 (read-string "Regexp: ")
6876 (read-key-sequence "Command: ")
6877 current-prefix-arg))
6878 (when (equal header "Body")
6880 ;; Hidden thread subtrees must be searched as well.
6881 (gnus-summary-show-all-threads)
6882 ;; We don't want to change current point nor window configuration.
6884 (save-window-excursion
6885 (gnus-message 6 "Executing %s..." (key-description command))
6886 ;; We'd like to execute COMMAND interactively so as to give arguments.
6887 (gnus-execute header regexp
6888 `(call-interactively ',(key-binding command))
6890 (gnus-message 6 "Executing %s...done" (key-description command)))))
6892 (defun gnus-summary-beginning-of-article ()
6893 "Scroll the article back to the beginning."
6895 (gnus-summary-select-article)
6896 (gnus-configure-windows 'article)
6897 (gnus-eval-in-buffer-window gnus-article-buffer
6899 (goto-char (point-min))
6900 (when gnus-page-broken
6901 (gnus-narrow-to-page))))
6903 (defun gnus-summary-end-of-article ()
6904 "Scroll to the end of the article."
6906 (gnus-summary-select-article)
6907 (gnus-configure-windows 'article)
6908 (gnus-eval-in-buffer-window gnus-article-buffer
6910 (goto-char (point-max))
6912 (when gnus-page-broken
6913 (gnus-narrow-to-page))))
6915 (defun gnus-summary-print-article (&optional filename n)
6916 "Generate and print a PostScript image of the N next (mail) articles.
6918 If N is negative, print the N previous articles. If N is nil and articles
6919 have been marked with the process mark, print these instead.
6921 If the optional first argument FILENAME is nil, send the image to the
6922 printer. If FILENAME is a string, save the PostScript image in a file with
6923 that name. If FILENAME is a number, prompt the user for the name of the file
6925 (interactive (list (ps-print-preprint current-prefix-arg)
6926 current-prefix-arg))
6927 (dolist (article (gnus-summary-work-articles n))
6928 (gnus-summary-select-article nil nil 'pseudo article)
6929 (gnus-eval-in-buffer-window gnus-article-buffer
6930 (let ((buffer (generate-new-buffer " *print*")))
6933 (copy-to-buffer buffer (point-min) (point-max))
6935 (gnus-article-delete-invisible-text)
6936 (let ((ps-left-header
6939 (mail-header-subject gnus-current-headers) ")")
6941 (mail-header-from gnus-current-headers) ")")))
6944 "/pagenumberstring load"
6946 (mail-header-date gnus-current-headers) ")"))))
6947 (gnus-run-hooks 'gnus-ps-print-hook)
6949 (ps-print-buffer-with-faces filename))))
6950 (kill-buffer buffer))))))
6952 (defun gnus-summary-show-article (&optional arg)
6953 "Force re-fetching of the current article.
6954 If ARG (the prefix) is non-nil, show the raw article without any
6955 article massaging functions being run."
6958 ;; Select the article the normal way.
6959 (gnus-summary-select-article nil 'force)
6960 ;; We have to require this here to make sure that the following
6961 ;; dynamic binding isn't shadowed by autoloading.
6962 (require 'gnus-async)
6964 ;; Bind the article treatment functions to nil.
6965 (let ((gnus-have-all-headers t)
6966 gnus-article-display-hook
6967 gnus-article-prepare-hook
6968 gnus-article-decode-hook
6972 (gnus-summary-select-article nil 'force)))
6973 (gnus-summary-goto-subject gnus-current-article)
6974 (gnus-summary-position-point))
6976 (defun gnus-summary-verbose-headers (&optional arg)
6977 "Toggle permanent full header display.
6978 If ARG is a positive number, turn header display on.
6979 If ARG is a negative number, turn header display off."
6981 (setq gnus-show-all-headers
6982 (cond ((or (not (numberp arg))
6984 (not gnus-show-all-headers))
6987 (gnus-summary-show-article))
6989 (defun gnus-summary-toggle-header (&optional arg)
6990 "Show the headers if they are hidden, or hide them if they are shown.
6991 If ARG is a positive number, show the entire header.
6992 If ARG is a negative number, hide the unwanted header lines."
6995 (set-buffer gnus-article-buffer)
6997 (let* ((buffer-read-only nil)
6998 (inhibit-point-motion-hooks t)
7001 (article-narrow-to-head)
7002 (setq hidden (gnus-article-hidden-text-p 'headers)))
7003 (goto-char (point-min))
7004 (when (search-forward "\n\n" nil t)
7005 (delete-region (point-min) (1- (point))))
7006 (goto-char (point-min))
7008 (set-buffer gnus-original-article-buffer)
7009 (goto-char (point-min))
7010 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
7011 (insert-buffer-substring gnus-original-article-buffer 1 e)
7013 (narrow-to-region (point-min) (point))
7014 (article-decode-encoded-words)
7016 (and (numberp arg) (< arg 0)))
7017 (let ((gnus-treat-hide-headers nil)
7018 (gnus-treat-hide-boring-headers nil))
7019 (gnus-treat-article 'head))
7020 (gnus-treat-article 'head)))))))
7022 (defun gnus-summary-show-all-headers ()
7023 "Make all header lines visible."
7025 (gnus-article-show-all-headers))
7027 (defun gnus-summary-toggle-mime (&optional arg)
7028 "Toggle MIME processing.
7029 If ARG is a positive number, turn MIME processing on."
7031 (setq gnus-show-mime
7033 (not gnus-show-mime)
7034 (> (prefix-numeric-value arg) 0)))
7035 (gnus-summary-select-article t 'force))
7037 (defun gnus-summary-caesar-message (&optional arg)
7038 "Caesar rotate the current article by 13.
7039 The numerical prefix specifies how many places to rotate each letter
7042 (gnus-summary-select-article)
7043 (let ((mail-header-separator ""))
7044 (gnus-eval-in-buffer-window gnus-article-buffer
7047 (let ((start (window-start))
7049 (message-caesar-buffer-body arg)
7050 (set-window-start (get-buffer-window (current-buffer)) start))))))
7052 (defun gnus-summary-stop-page-breaking ()
7053 "Stop page breaking in the current article."
7055 (gnus-summary-select-article)
7056 (gnus-eval-in-buffer-window gnus-article-buffer
7058 (when (gnus-visual-p 'page-marker)
7059 (let ((buffer-read-only nil))
7060 (gnus-remove-text-with-property 'gnus-prev)
7061 (gnus-remove-text-with-property 'gnus-next))
7062 (setq gnus-page-broken nil))))
7064 (defun gnus-summary-move-article (&optional n to-newsgroup
7065 select-method action)
7066 "Move the current article to a different newsgroup.
7067 If N is a positive number, move the N next articles.
7068 If N is a negative number, move the N previous articles.
7069 If N is nil and any articles have been marked with the process mark,
7070 move those articles instead.
7071 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7072 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7073 re-spool using this method.
7075 For this function to work, both the current newsgroup and the
7076 newsgroup that you want to move to have to support the `request-move'
7077 and `request-accept' functions."
7080 (setq action 'move))
7081 ;; Disable marking as read.
7082 (let (gnus-mark-article-hook)
7083 (save-window-excursion
7084 (gnus-summary-select-article)))
7085 ;; Check whether the source group supports the required functions.
7086 (cond ((and (eq action 'move)
7087 (not (gnus-check-backend-function
7088 'request-move-article gnus-newsgroup-name)))
7089 (error "The current group does not support article moving"))
7090 ((and (eq action 'crosspost)
7091 (not (gnus-check-backend-function
7092 'request-replace-article gnus-newsgroup-name)))
7093 (error "The current group does not support article editing")))
7094 (let ((articles (gnus-summary-work-articles n))
7095 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
7096 (names '((move "Move" "Moving")
7097 (copy "Copy" "Copying")
7098 (crosspost "Crosspost" "Crossposting")))
7099 (copy-buf (save-excursion
7100 (nnheader-set-temp-buffer " *copy article*")))
7101 (default-marks gnus-article-mark-lists)
7102 (no-expire-marks (delete '(expirable . expire)
7103 (copy-sequence gnus-article-mark-lists)))
7104 art-group to-method new-xref article to-groups)
7105 (unless (assq action names)
7106 (error "Unknown action %s" action))
7107 ;; Read the newsgroup name.
7108 (when (and (not to-newsgroup)
7109 (not select-method))
7111 (gnus-read-move-group-name
7112 (cadr (assq action names))
7113 (symbol-value (intern (format "gnus-current-%s-group" action)))
7115 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
7116 (setq to-method (or select-method
7117 (gnus-group-name-to-method to-newsgroup)))
7118 ;; Check the method we are to move this article to...
7119 (unless (gnus-check-backend-function
7120 'request-accept-article (car to-method))
7121 (error "%s does not support article copying" (car to-method)))
7122 (unless (gnus-check-server to-method)
7123 (error "Can't open server %s" (car to-method)))
7124 (gnus-message 6 "%s to %s: %s..."
7125 (caddr (assq action names))
7126 (or (car select-method) to-newsgroup) articles)
7128 (setq article (pop articles))
7132 ;; Move the article.
7134 ;; Remove this article from future suppression.
7135 (gnus-dup-unsuppress-article article)
7136 (gnus-request-move-article
7137 article ; Article to move
7138 gnus-newsgroup-name ; From newsgroup
7139 (nth 1 (gnus-find-method-for-group
7140 gnus-newsgroup-name)) ; Server
7141 (list 'gnus-request-accept-article
7142 to-newsgroup (list 'quote select-method)
7143 (not articles) t) ; Accept form
7144 (not articles))) ; Only save nov last time
7145 ;; Copy the article.
7148 (set-buffer copy-buf)
7149 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
7150 (gnus-request-accept-article
7151 to-newsgroup select-method (not articles) t))))
7152 ;; Crosspost the article.
7153 ((eq action 'crosspost)
7154 (let ((xref (message-tokenize-header
7155 (mail-header-xref (gnus-summary-article-header article))
7157 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
7160 (setq xref (list (system-name))))
7163 (mapconcat 'identity
7164 (delete "Xref:" (delete new-xref xref))
7168 (set-buffer copy-buf)
7169 ;; First put the article in the destination group.
7170 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7171 (when (consp (setq art-group
7172 (gnus-request-accept-article
7173 to-newsgroup select-method (not articles))))
7174 (setq new-xref (concat new-xref " " (car art-group)
7175 ":" (cdr art-group)))
7176 ;; Now we have the new Xrefs header, so we insert
7177 ;; it and replace the new article.
7178 (nnheader-replace-header "Xref" new-xref)
7179 (gnus-request-replace-article
7180 (cdr art-group) to-newsgroup (current-buffer))
7184 (gnus-message 1 "Couldn't %s article %s"
7185 (cadr (assq action names)) article))
7186 ((and (eq art-group 'junk)
7188 (gnus-summary-mark-article article gnus-canceled-mark)
7189 (gnus-message 4 "Deleted article %s" article))
7191 (let* ((pto-group (gnus-group-prefixed-name
7192 (car art-group) to-method))
7194 (gnus-gethash pto-group gnus-newsrc-hashtb))
7195 (info (nth 2 entry))
7196 (to-group (gnus-info-group info)))
7197 ;; Update the group that has been moved to.
7199 (memq action '(move copy)))
7200 (unless (member to-group to-groups)
7201 (push to-group to-groups))
7203 (unless (memq article gnus-newsgroup-unreads)
7205 info (gnus-add-to-range (gnus-info-read info)
7206 (list (cdr art-group)))))
7208 ;; Copy any marks over to the new group.
7209 (let ((marks (if (gnus-group-auto-expirable-p to-group)
7212 (to-article (cdr art-group)))
7214 ;; See whether the article is to be put in the cache.
7215 (when gnus-use-cache
7216 (gnus-cache-possibly-enter-article
7218 (let ((header (copy-sequence
7219 (gnus-summary-article-header article))))
7220 (mail-header-set-number header to-article)
7222 (memq article gnus-newsgroup-marked)
7223 (memq article gnus-newsgroup-dormant)
7224 (memq article gnus-newsgroup-unreads)))
7226 (when (and (equal to-group gnus-newsgroup-name)
7227 (not (memq article gnus-newsgroup-unreads)))
7228 ;; Mark this article as read in this group.
7229 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7230 (setcdr (gnus-active to-group) to-article)
7231 (setcdr gnus-newsgroup-active to-article))
7234 (when (memq article (symbol-value
7235 (intern (format "gnus-newsgroup-%s"
7237 ;; If the other group is the same as this group,
7238 ;; then we have to add the mark to the list.
7239 (when (equal to-group gnus-newsgroup-name)
7240 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7243 (intern (format "gnus-newsgroup-%s"
7245 ;; Copy the marks to other group.
7246 (gnus-add-marked-articles
7247 to-group (cdar marks) (list to-article) info))
7248 (setq marks (cdr marks)))
7251 (concat "(gnus-group-set-info '"
7252 (gnus-prin1-to-string (gnus-get-info to-group))
7255 ;; Update the Xref header in this article to point to
7256 ;; the new crossposted article we have just created.
7257 (when (eq action 'crosspost)
7259 (set-buffer copy-buf)
7260 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7261 (nnheader-replace-header "Xref" new-xref)
7262 (gnus-request-replace-article
7263 article gnus-newsgroup-name (current-buffer)))))
7265 ;;;!!!Why is this necessary?
7266 (set-buffer gnus-summary-buffer)
7268 (gnus-summary-goto-subject article)
7269 (when (eq action 'move)
7270 (gnus-summary-mark-article article gnus-canceled-mark))))
7271 (gnus-summary-remove-process-mark article))
7272 ;; Re-activate all groups that have been moved to.
7275 (set-buffer gnus-group-buffer)
7276 (when (gnus-group-goto-group (car to-groups) t)
7277 (gnus-group-get-new-news-this-group 1 t))
7280 (gnus-kill-buffer copy-buf)
7281 (gnus-summary-position-point)
7282 (gnus-set-mode-line 'summary)))
7284 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7285 "Move the current article to a different newsgroup.
7286 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7287 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7288 re-spool using this method."
7290 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7292 (defun gnus-summary-crosspost-article (&optional n)
7293 "Crosspost the current article to some other group."
7295 (gnus-summary-move-article n nil nil 'crosspost))
7297 (defcustom gnus-summary-respool-default-method nil
7298 "Default method for respooling an article.
7299 If nil, use to the current newsgroup method."
7300 :type '(choice (gnus-select-method :value (nnml ""))
7302 :group 'gnus-summary-mail)
7304 (defun gnus-summary-respool-article (&optional n method)
7305 "Respool the current article.
7306 The article will be squeezed through the mail spooling process again,
7307 which means that it will be put in some mail newsgroup or other
7308 depending on `nnmail-split-methods'.
7309 If N is a positive number, respool the N next articles.
7310 If N is a negative number, respool the N previous articles.
7311 If N is nil and any articles have been marked with the process mark,
7312 respool those articles instead.
7314 Respooling can be done both from mail groups and \"real\" newsgroups.
7315 In the former case, the articles in question will be moved from the
7316 current group into whatever groups they are destined to. In the
7317 latter case, they will be copied into the relevant groups."
7319 (list current-prefix-arg
7320 (let* ((methods (gnus-methods-using 'respool))
7322 (symbol-name (or gnus-summary-respool-default-method
7323 (car (gnus-find-method-for-group
7324 gnus-newsgroup-name)))))
7326 (gnus-completing-read
7327 methname "What backend do you want to use when respooling?"
7328 methods nil t nil 'gnus-mail-method-history))
7331 ((zerop (length (setq ms (gnus-servers-using-backend
7333 (list (intern method) ""))
7337 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7338 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7341 (error "No method given for respooling"))
7342 (if (assoc (symbol-name
7343 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7344 (gnus-methods-using 'respool))
7345 (gnus-summary-move-article n nil method)
7346 (gnus-summary-copy-article n nil method)))
7348 (defun gnus-summary-import-article (file)
7349 "Import an arbitrary file into a mail newsgroup."
7350 (interactive "fImport file: ")
7351 (let ((group gnus-newsgroup-name)
7352 (now (current-time))
7354 (unless (gnus-check-backend-function 'request-accept-article group)
7355 (error "%s does not support article importing" group))
7356 (or (file-readable-p file)
7357 (not (file-regular-p file))
7358 (error "Can't read %s" file))
7360 (set-buffer (gnus-get-buffer-create " *import file*"))
7362 (nnheader-insert-file-contents file)
7363 (goto-char (point-min))
7364 (unless (nnheader-article-p)
7365 ;; This doesn't look like an article, so we fudge some headers.
7366 (setq atts (file-attributes file)
7367 lines (count-lines (point-min) (point-max)))
7368 (insert "From: " (read-string "From: ") "\n"
7369 "Subject: " (read-string "Subject: ") "\n"
7370 "Date: " (message-make-date (nth 5 atts))
7372 "Message-ID: " (message-make-message-id) "\n"
7373 "Lines: " (int-to-string lines) "\n"
7374 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7375 (gnus-request-accept-article group nil t)
7376 (kill-buffer (current-buffer)))))
7378 (defun gnus-summary-article-posted-p ()
7379 "Say whether the current (mail) article is available from `gnus-select-method' as well.
7380 This will be the case if the article has both been mailed and posted."
7382 (let ((id (mail-header-references (gnus-summary-article-header)))
7383 (gnus-override-method
7384 (or gnus-refer-article-method gnus-select-method)))
7385 (if (gnus-request-head id "")
7386 (gnus-message 2 "The current message was found on %s"
7387 gnus-override-method)
7388 (gnus-message 2 "The current message couldn't be found on %s"
7389 gnus-override-method)
7392 (defun gnus-summary-expire-articles (&optional now)
7393 "Expire all articles that are marked as expirable in the current group."
7395 (when (gnus-check-backend-function
7396 'request-expire-articles gnus-newsgroup-name)
7397 ;; This backend supports expiry.
7398 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7399 (expirable (if total
7401 ;; We need to update the info for
7402 ;; this group for `gnus-list-of-read-articles'
7403 ;; to give us the right answer.
7404 (gnus-run-hooks 'gnus-exit-group-hook)
7405 (gnus-summary-update-info)
7406 (gnus-list-of-read-articles gnus-newsgroup-name))
7407 (setq gnus-newsgroup-expirable
7408 (sort gnus-newsgroup-expirable '<))))
7409 (expiry-wait (if now 'immediate
7410 (gnus-group-find-parameter
7411 gnus-newsgroup-name 'expiry-wait)))
7414 ;; There are expirable articles in this group, so we run them
7415 ;; through the expiry process.
7416 (gnus-message 6 "Expiring articles...")
7417 (unless (gnus-check-group gnus-newsgroup-name)
7418 (error "Can't open server for %s" gnus-newsgroup-name))
7419 ;; The list of articles that weren't expired is returned.
7422 (let ((nnmail-expiry-wait-function nil)
7423 (nnmail-expiry-wait expiry-wait))
7424 (setq es (gnus-request-expire-articles
7425 expirable gnus-newsgroup-name)))
7426 (setq es (gnus-request-expire-articles
7427 expirable gnus-newsgroup-name))))
7429 (setq gnus-newsgroup-expirable es))
7430 ;; We go through the old list of expirable, and mark all
7431 ;; really expired articles as nonexistent.
7432 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7433 (let ((gnus-use-cache nil))
7435 (unless (memq (car expirable) es)
7436 (when (gnus-data-find (car expirable))
7437 (gnus-summary-mark-article
7438 (car expirable) gnus-canceled-mark)))
7439 (setq expirable (cdr expirable)))))
7440 (gnus-message 6 "Expiring articles...done")))))
7442 (defun gnus-summary-expire-articles-now ()
7443 "Expunge all expirable articles in the current group.
7444 This means that *all* articles that are marked as expirable will be
7445 deleted forever, right now."
7447 (or gnus-expert-user
7449 "Are you really, really, really sure you want to delete all these messages? ")
7451 (gnus-summary-expire-articles t))
7453 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7454 (defun gnus-summary-delete-article (&optional n)
7455 "Delete the N next (mail) articles.
7456 This command actually deletes articles. This is not a marking
7457 command. The article will disappear forever from your life, never to
7459 If N is negative, delete backwards.
7460 If N is nil and articles have been marked with the process mark,
7461 delete these instead."
7463 (unless (gnus-check-backend-function 'request-expire-articles
7464 gnus-newsgroup-name)
7465 (error "The current newsgroup does not support article deletion"))
7466 ;; Compute the list of articles to delete.
7467 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
7469 (if (and gnus-novice-user
7470 (not (gnus-yes-or-no-p
7471 (format "Do you really want to delete %s forever? "
7472 (if (> (length articles) 1)
7473 (format "these %s articles" (length articles))
7476 ;; Delete the articles.
7477 (setq not-deleted (gnus-request-expire-articles
7478 articles gnus-newsgroup-name 'force))
7480 (gnus-summary-remove-process-mark (car articles))
7481 ;; The backend might not have been able to delete the article
7483 (unless (memq (car articles) not-deleted)
7484 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7485 (setq articles (cdr articles)))
7487 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7488 (gnus-summary-position-point)
7489 (gnus-set-mode-line 'summary)
7492 (defun gnus-summary-edit-article (&optional force)
7493 "Edit the current article.
7494 This will have permanent effect only in mail groups.
7495 If FORCE is non-nil, allow editing of articles even in read-only
7498 (let ((mail-parse-charset gnus-newsgroup-charset))
7500 (set-buffer gnus-summary-buffer)
7501 (gnus-set-global-variables)
7502 (when (and (not force)
7503 (gnus-group-read-only-p))
7504 (error "The current newsgroup does not support article editing"))
7505 (gnus-summary-show-article t)
7506 (gnus-article-edit-article
7508 `(lambda (no-highlight)
7509 (let ((mail-parse-charset ',gnus-newsgroup-charset))
7510 (gnus-summary-edit-article-done
7511 ,(or (mail-header-references gnus-current-headers) "")
7512 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
7514 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7516 (defun gnus-summary-edit-article-done (&optional references read-only buffer
7518 "Make edits to the current article permanent."
7520 ;; Replace the article.
7521 (let ((buf (current-buffer)))
7523 (insert-buffer-substring buf)
7524 (if (and (not read-only)
7525 (not (gnus-request-replace-article
7526 (cdr gnus-article-current) (car gnus-article-current)
7527 (current-buffer) t)))
7528 (error "Couldn't replace article")
7529 ;; Update the summary buffer.
7531 (equal (message-tokenize-header references " ")
7532 (message-tokenize-header
7533 (or (message-fetch-field "references") "") " ")))
7534 ;; We only have to update this line.
7537 (message-narrow-to-head)
7538 (let ((head (buffer-string))
7541 (insert (format "211 %d Article retrieved.\n"
7542 (cdr gnus-article-current)))
7545 (let ((nntp-server-buffer (current-buffer)))
7546 (setq header (car (gnus-get-newsgroup-headers
7548 (set-buffer gnus-summary-buffer)
7549 gnus-newsgroup-dependencies)
7552 (set-buffer gnus-summary-buffer)
7553 (gnus-data-set-header
7554 (gnus-data-find (cdr gnus-article-current))
7556 (gnus-summary-update-article-line
7557 (cdr gnus-article-current) header))))))
7559 (set-buffer (or buffer gnus-summary-buffer))
7560 (gnus-summary-update-article (cdr gnus-article-current)))
7561 ;; Prettify the article buffer again.
7562 (unless no-highlight
7564 (set-buffer gnus-article-buffer)
7565 ;;;!!! Fix this -- article should be rehighlighted.
7566 ;;;(gnus-run-hooks 'gnus-article-display-hook)
7567 (set-buffer gnus-original-article-buffer)
7568 (gnus-request-article
7569 (cdr gnus-article-current)
7570 (car gnus-article-current) (current-buffer))))
7571 ;; Prettify the summary buffer line.
7572 (when (gnus-visual-p 'summary-highlight 'highlight)
7573 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
7575 (defun gnus-summary-edit-wash (key)
7576 "Perform editing command KEY in the article buffer."
7580 (message "%s" (concat (this-command-keys) "- "))
7583 (gnus-summary-edit-article)
7584 (execute-kbd-macro (concat (this-command-keys) key))
7585 (gnus-article-edit-done))
7589 (defun gnus-summary-respool-query (&optional silent trace)
7590 "Query where the respool algorithm would put this article."
7592 (let (gnus-mark-article-hook)
7593 (gnus-summary-select-article)
7595 (set-buffer gnus-original-article-buffer)
7597 (message-narrow-to-head)
7598 (let ((groups (nnmail-article-group 'identity trace)))
7601 (message "This message would go to %s"
7602 (mapconcat 'car groups ", "))
7603 (message "This message would go to no groups"))
7606 (defun gnus-summary-respool-trace ()
7607 "Trace where the respool algorithm would put this article.
7608 Display a buffer showing all fancy splitting patterns which matched."
7610 (gnus-summary-respool-query nil t))
7612 ;; Summary marking commands.
7614 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
7615 "Mark articles which has the same subject as read, and then select the next.
7616 If UNMARK is positive, remove any kind of mark.
7617 If UNMARK is negative, tick articles."
7620 (setq unmark (prefix-numeric-value unmark)))
7622 (gnus-summary-mark-same-subject
7623 (gnus-summary-article-subject) unmark)))
7624 ;; Select next unread article. If auto-select-same mode, should
7625 ;; select the first unread article.
7626 (gnus-summary-next-article t (and gnus-auto-select-same
7627 (gnus-summary-article-subject)))
7628 (gnus-message 7 "%d article%s marked as %s"
7629 count (if (= count 1) " is" "s are")
7630 (if unmark "unread" "read"))))
7632 (defun gnus-summary-kill-same-subject (&optional unmark)
7633 "Mark articles which has the same subject as read.
7634 If UNMARK is positive, remove any kind of mark.
7635 If UNMARK is negative, tick articles."
7638 (setq unmark (prefix-numeric-value unmark)))
7640 (gnus-summary-mark-same-subject
7641 (gnus-summary-article-subject) unmark)))
7642 ;; If marked as read, go to next unread subject.
7644 ;; Go to next unread subject.
7645 (gnus-summary-next-subject 1 t))
7646 (gnus-message 7 "%d articles are marked as %s"
7647 count (if unmark "unread" "read"))))
7649 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7650 "Mark articles with same SUBJECT as read, and return marked number.
7651 If optional argument UNMARK is positive, remove any kinds of marks.
7652 If optional argument UNMARK is negative, mark articles as unread instead."
7656 ((null unmark) ; Mark as read.
7659 (gnus-summary-mark-article-as-read gnus-killed-mark)
7660 (gnus-summary-show-thread) t)
7661 (gnus-summary-find-subject subject))
7662 (setq count (1+ count))))
7663 ((> unmark 0) ; Tick.
7666 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
7667 (gnus-summary-show-thread) t)
7668 (gnus-summary-find-subject subject))
7669 (setq count (1+ count))))
7670 (t ; Mark as unread.
7673 (gnus-summary-mark-article-as-unread gnus-unread-mark)
7674 (gnus-summary-show-thread) t)
7675 (gnus-summary-find-subject subject))
7676 (setq count (1+ count)))))
7677 (gnus-set-mode-line 'summary)
7678 ;; Return the number of marked articles.
7681 (defun gnus-summary-mark-as-processable (n &optional unmark)
7682 "Set the process mark on the next N articles.
7683 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7684 the process mark instead. The difference between N and the actual
7685 number of articles marked is returned."
7687 (let ((backward (< n 0))
7692 (gnus-summary-remove-process-mark
7693 (gnus-summary-article-number))
7694 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7695 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7698 (gnus-message 7 "No more articles"))
7699 (gnus-summary-recenter)
7700 (gnus-summary-position-point)
7703 (defun gnus-summary-unmark-as-processable (n)
7704 "Remove the process mark from the next N articles.
7705 If N is negative, unmark backward instead. The difference between N and
7706 the actual number of articles unmarked is returned."
7708 (gnus-summary-mark-as-processable n t))
7710 (defun gnus-summary-unmark-all-processable ()
7711 "Remove the process mark from all articles."
7714 (while gnus-newsgroup-processable
7715 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7716 (gnus-summary-position-point))
7718 (defun gnus-summary-mark-as-expirable (n)
7719 "Mark N articles forward as expirable.
7720 If N is negative, mark backward instead. The difference between N and
7721 the actual number of articles marked is returned."
7723 (gnus-summary-mark-forward n gnus-expirable-mark))
7725 (defun gnus-summary-mark-article-as-replied (article)
7726 "Mark ARTICLE replied and update the summary line."
7727 (push article gnus-newsgroup-replied)
7728 (let ((buffer-read-only nil))
7729 (when (gnus-summary-goto-subject article nil t)
7730 (gnus-summary-update-secondary-mark article))))
7732 (defun gnus-summary-set-bookmark (article)
7733 "Set a bookmark in current article."
7734 (interactive (list (gnus-summary-article-number)))
7735 (when (or (not (get-buffer gnus-article-buffer))
7736 (not gnus-current-article)
7737 (not gnus-article-current)
7738 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7739 (error "No current article selected"))
7740 ;; Remove old bookmark, if one exists.
7741 (let ((old (assq article gnus-newsgroup-bookmarks)))
7743 (setq gnus-newsgroup-bookmarks
7744 (delq old gnus-newsgroup-bookmarks))))
7745 ;; Set the new bookmark, which is on the form
7746 ;; (article-number . line-number-in-body).
7750 (set-buffer gnus-article-buffer)
7754 (goto-char (point-min))
7755 (search-forward "\n\n" nil t)
7758 gnus-newsgroup-bookmarks)
7759 (gnus-message 6 "A bookmark has been added to the current article."))
7761 (defun gnus-summary-remove-bookmark (article)
7762 "Remove the bookmark from the current article."
7763 (interactive (list (gnus-summary-article-number)))
7764 ;; Remove old bookmark, if one exists.
7765 (let ((old (assq article gnus-newsgroup-bookmarks)))
7768 (setq gnus-newsgroup-bookmarks
7769 (delq old gnus-newsgroup-bookmarks))
7770 (gnus-message 6 "Removed bookmark."))
7771 (gnus-message 6 "No bookmark in current article."))))
7773 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7774 (defun gnus-summary-mark-as-dormant (n)
7775 "Mark N articles forward as dormant.
7776 If N is negative, mark backward instead. The difference between N and
7777 the actual number of articles marked is returned."
7779 (gnus-summary-mark-forward n gnus-dormant-mark))
7781 (defun gnus-summary-set-process-mark (article)
7782 "Set the process mark on ARTICLE and update the summary line."
7783 (setq gnus-newsgroup-processable
7785 (delq article gnus-newsgroup-processable)))
7786 (when (gnus-summary-goto-subject article)
7787 (gnus-summary-show-thread)
7788 (gnus-summary-goto-subject article)
7789 (gnus-summary-update-secondary-mark article)))
7791 (defun gnus-summary-remove-process-mark (article)
7792 "Remove the process mark from ARTICLE and update the summary line."
7793 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7794 (when (gnus-summary-goto-subject article)
7795 (gnus-summary-show-thread)
7796 (gnus-summary-goto-subject article)
7797 (gnus-summary-update-secondary-mark article)))
7799 (defun gnus-summary-set-saved-mark (article)
7800 "Set the process mark on ARTICLE and update the summary line."
7801 (push article gnus-newsgroup-saved)
7802 (when (gnus-summary-goto-subject article)
7803 (gnus-summary-update-secondary-mark article)))
7805 (defun gnus-summary-mark-forward (n &optional mark no-expire)
7806 "Mark N articles as read forwards.
7807 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
7808 The difference between N and the actual number of articles marked is
7811 (gnus-summary-show-thread)
7812 (let ((backward (< n 0))
7813 (gnus-summary-goto-unread
7814 (and gnus-summary-goto-unread
7815 (not (eq gnus-summary-goto-unread 'never))
7816 (not (memq mark (list gnus-unread-mark
7817 gnus-ticked-mark gnus-dormant-mark)))))
7819 (mark (or mark gnus-del-mark)))
7821 (gnus-summary-mark-article nil mark no-expire)
7822 (zerop (gnus-summary-next-subject
7824 (and gnus-summary-goto-unread
7825 (not (eq gnus-summary-goto-unread 'never)))
7829 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
7830 (gnus-summary-recenter)
7831 (gnus-summary-position-point)
7832 (gnus-set-mode-line 'summary)
7835 (defun gnus-summary-mark-article-as-read (mark)
7836 "Mark the current article quickly as read with MARK."
7837 (let ((article (gnus-summary-article-number)))
7838 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7839 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7840 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7841 (push (cons article mark) gnus-newsgroup-reads)
7842 ;; Possibly remove from cache, if that is used.
7843 (when gnus-use-cache
7844 (gnus-cache-enter-remove-article article))
7845 ;; Allow the backend to change the mark.
7846 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7847 ;; Check for auto-expiry.
7848 (when (and gnus-newsgroup-auto-expire
7849 (memq mark gnus-auto-expirable-marks))
7850 (setq mark gnus-expirable-mark)
7851 ;; Let the backend know about the mark change.
7852 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7853 (push article gnus-newsgroup-expirable))
7854 ;; Set the mark in the buffer.
7855 (gnus-summary-update-mark mark 'unread)
7858 (defun gnus-summary-mark-article-as-unread (mark)
7859 "Mark the current article quickly as unread with MARK."
7860 (let* ((article (gnus-summary-article-number))
7861 (old-mark (gnus-summary-article-mark article)))
7862 ;; Allow the backend to change the mark.
7863 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7864 (if (eq mark old-mark)
7868 (gnus-error 1 "Can't mark negative article numbers")
7870 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7871 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7872 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
7873 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
7874 (cond ((= mark gnus-ticked-mark)
7875 (push article gnus-newsgroup-marked))
7876 ((= mark gnus-dormant-mark)
7877 (push article gnus-newsgroup-dormant))
7879 (push article gnus-newsgroup-unreads)))
7880 (gnus-pull article gnus-newsgroup-reads)
7882 ;; See whether the article is to be put in the cache.
7884 (vectorp (gnus-summary-article-header article))
7886 (gnus-cache-possibly-enter-article
7887 gnus-newsgroup-name article
7888 (gnus-summary-article-header article)
7889 (= mark gnus-ticked-mark)
7890 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7893 (gnus-summary-update-mark mark 'unread)
7896 (defun gnus-summary-mark-article (&optional article mark no-expire)
7897 "Mark ARTICLE with MARK. MARK can be any character.
7898 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
7899 `??' (dormant) and `?E' (expirable).
7900 If MARK is nil, then the default character `?r' is used.
7901 If ARTICLE is nil, then the article on the current line will be
7903 ;; The mark might be a string.
7904 (when (stringp mark)
7905 (setq mark (aref mark 0)))
7906 ;; If no mark is given, then we check auto-expiring.
7908 (setq mark gnus-del-mark))
7909 (when (and (not no-expire)
7910 gnus-newsgroup-auto-expire
7911 (memq mark gnus-auto-expirable-marks))
7912 (setq mark gnus-expirable-mark))
7913 (let ((article (or article (gnus-summary-article-number)))
7914 (old-mark (gnus-summary-article-mark article)))
7915 ;; Allow the backend to change the mark.
7916 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7917 (if (eq mark old-mark)
7920 (error "No article on current line"))
7921 (if (not (if (or (= mark gnus-unread-mark)
7922 (= mark gnus-ticked-mark)
7923 (= mark gnus-dormant-mark))
7924 (gnus-mark-article-as-unread article mark)
7925 (gnus-mark-article-as-read article mark)))
7927 ;; See whether the article is to be put in the cache.
7929 (not (= mark gnus-canceled-mark))
7930 (vectorp (gnus-summary-article-header article))
7932 (gnus-cache-possibly-enter-article
7933 gnus-newsgroup-name article
7934 (gnus-summary-article-header article)
7935 (= mark gnus-ticked-mark)
7936 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7938 (when (gnus-summary-goto-subject article nil t)
7939 (let ((buffer-read-only nil))
7940 (gnus-summary-show-thread)
7942 (gnus-summary-update-mark mark 'unread)
7945 (defun gnus-summary-update-secondary-mark (article)
7946 "Update the secondary (read, process, cache) mark."
7947 (gnus-summary-update-mark
7948 (cond ((memq article gnus-newsgroup-processable)
7950 ((memq article gnus-newsgroup-cached)
7952 ((memq article gnus-newsgroup-replied)
7954 ((memq article gnus-newsgroup-saved)
7956 (t gnus-unread-mark))
7958 (when (gnus-visual-p 'summary-highlight 'highlight)
7959 (gnus-run-hooks 'gnus-summary-update-hook))
7962 (defun gnus-summary-update-mark (mark type)
7963 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
7964 (buffer-read-only nil))
7965 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
7967 (when (looking-at "\r")
7969 (when (<= (+ forward (point)) (point-max))
7970 ;; Go to the right position on the line.
7971 (goto-char (+ forward (point)))
7972 ;; Replace the old mark with the new mark.
7973 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
7974 ;; Optionally update the marks by some user rule.
7975 (when (eq type 'unread)
7977 (gnus-data-find (gnus-summary-article-number)) mark)
7978 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
7980 (defun gnus-mark-article-as-read (article &optional mark)
7981 "Enter ARTICLE in the pertinent lists and remove it from others."
7982 ;; Make the article expirable.
7983 (let ((mark (or mark gnus-del-mark)))
7984 (if (= mark gnus-expirable-mark)
7985 (push article gnus-newsgroup-expirable)
7986 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
7987 ;; Remove from unread and marked lists.
7988 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7989 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7990 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7991 (push (cons article mark) gnus-newsgroup-reads)
7992 ;; Possibly remove from cache, if that is used.
7993 (when gnus-use-cache
7994 (gnus-cache-enter-remove-article article))
7997 (defun gnus-mark-article-as-unread (article &optional mark)
7998 "Enter ARTICLE in the pertinent lists and remove it from others."
7999 (let ((mark (or mark gnus-ticked-mark)))
8002 (gnus-error 1 "Can't mark negative article numbers")
8004 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
8005 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
8006 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
8007 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8009 ;; Unsuppress duplicates?
8010 (when gnus-suppress-duplicates
8011 (gnus-dup-unsuppress-article article))
8013 (cond ((= mark gnus-ticked-mark)
8014 (push article gnus-newsgroup-marked))
8015 ((= mark gnus-dormant-mark)
8016 (push article gnus-newsgroup-dormant))
8018 (push article gnus-newsgroup-unreads)))
8019 (gnus-pull article gnus-newsgroup-reads)
8022 (defalias 'gnus-summary-mark-as-unread-forward
8023 'gnus-summary-tick-article-forward)
8024 (make-obsolete 'gnus-summary-mark-as-unread-forward
8025 'gnus-summary-tick-article-forward)
8026 (defun gnus-summary-tick-article-forward (n)
8027 "Tick N articles forwards.
8028 If N is negative, tick backwards instead.
8029 The difference between N and the number of articles ticked is returned."
8031 (gnus-summary-mark-forward n gnus-ticked-mark))
8033 (defalias 'gnus-summary-mark-as-unread-backward
8034 'gnus-summary-tick-article-backward)
8035 (make-obsolete 'gnus-summary-mark-as-unread-backward
8036 'gnus-summary-tick-article-backward)
8037 (defun gnus-summary-tick-article-backward (n)
8038 "Tick N articles backwards.
8039 The difference between N and the number of articles ticked is returned."
8041 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
8043 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8044 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8045 (defun gnus-summary-tick-article (&optional article clear-mark)
8046 "Mark current article as unread.
8047 Optional 1st argument ARTICLE specifies article number to be marked as unread.
8048 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
8050 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
8053 (defun gnus-summary-mark-as-read-forward (n)
8054 "Mark N articles as read forwards.
8055 If N is negative, mark backwards instead.
8056 The difference between N and the actual number of articles marked is
8059 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
8061 (defun gnus-summary-mark-as-read-backward (n)
8062 "Mark the N articles as read backwards.
8063 The difference between N and the actual number of articles marked is
8066 (gnus-summary-mark-forward
8067 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
8069 (defun gnus-summary-mark-as-read (&optional article mark)
8070 "Mark current article as read.
8071 ARTICLE specifies the article to be marked as read.
8072 MARK specifies a string to be inserted at the beginning of the line."
8073 (gnus-summary-mark-article article mark))
8075 (defun gnus-summary-clear-mark-forward (n)
8076 "Clear marks from N articles forward.
8077 If N is negative, clear backward instead.
8078 The difference between N and the number of marks cleared is returned."
8080 (gnus-summary-mark-forward n gnus-unread-mark))
8082 (defun gnus-summary-clear-mark-backward (n)
8083 "Clear marks from N articles backward.
8084 The difference between N and the number of marks cleared is returned."
8086 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8088 (defun gnus-summary-mark-unread-as-read ()
8089 "Intended to be used by `gnus-summary-mark-article-hook'."
8090 (when (memq gnus-current-article gnus-newsgroup-unreads)
8091 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
8093 (defun gnus-summary-mark-read-and-unread-as-read ()
8094 "Intended to be used by `gnus-summary-mark-article-hook'."
8095 (let ((mark (gnus-summary-article-mark)))
8096 (when (or (gnus-unread-mark-p mark)
8097 (gnus-read-mark-p mark))
8098 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
8100 (defun gnus-summary-mark-region-as-read (point mark all)
8101 "Mark all unread articles between point and mark as read.
8102 If given a prefix, mark all articles between point and mark as read,
8103 even ticked and dormant ones."
8104 (interactive "r\nP")
8113 (memq (setq article (gnus-summary-article-number))
8114 gnus-newsgroup-unreads))
8115 (gnus-summary-mark-article article gnus-del-mark))
8117 (gnus-summary-find-next))))))
8119 (defun gnus-summary-mark-below (score mark)
8120 "Mark articles with score less than SCORE with MARK."
8121 (interactive "P\ncMark: ")
8122 (setq score (if score
8123 (prefix-numeric-value score)
8124 (or gnus-summary-default-score 0)))
8126 (set-buffer gnus-summary-buffer)
8127 (goto-char (point-min))
8130 (and (< (gnus-summary-article-score) score)
8131 (gnus-summary-mark-article nil mark))
8132 (gnus-summary-find-next)))))
8134 (defun gnus-summary-kill-below (&optional score)
8135 "Mark articles with score below SCORE as read."
8137 (gnus-summary-mark-below score gnus-killed-mark))
8139 (defun gnus-summary-clear-above (&optional score)
8140 "Clear all marks from articles with score above SCORE."
8142 (gnus-summary-mark-above score gnus-unread-mark))
8144 (defun gnus-summary-tick-above (&optional score)
8145 "Tick all articles with score above SCORE."
8147 (gnus-summary-mark-above score gnus-ticked-mark))
8149 (defun gnus-summary-mark-above (score mark)
8150 "Mark articles with score over SCORE with MARK."
8151 (interactive "P\ncMark: ")
8152 (setq score (if score
8153 (prefix-numeric-value score)
8154 (or gnus-summary-default-score 0)))
8156 (set-buffer gnus-summary-buffer)
8157 (goto-char (point-min))
8159 (when (> (gnus-summary-article-score) score)
8160 (gnus-summary-mark-article nil mark))
8162 (gnus-summary-find-next)))))
8164 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8165 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
8166 (defun gnus-summary-limit-include-expunged (&optional no-error)
8167 "Display all the hidden articles that were expunged for low scores."
8169 (let ((buffer-read-only nil))
8170 (let ((scored gnus-newsgroup-scored)
8173 (unless (gnus-summary-goto-subject (caar scored))
8174 (and (setq h (gnus-summary-article-header (caar scored)))
8175 (< (cdar scored) gnus-summary-expunge-below)
8177 (setq scored (cdr scored)))
8179 (when (not no-error)
8180 (error "No expunged articles hidden"))
8181 (goto-char (point-min))
8182 (gnus-summary-prepare-unthreaded (nreverse headers))
8183 (goto-char (point-min))
8184 (gnus-summary-position-point)
8187 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
8188 "Mark all unread articles in this newsgroup as read.
8189 If prefix argument ALL is non-nil, ticked and dormant articles will
8190 also be marked as read.
8191 If QUIETLY is non-nil, no questions will be asked.
8192 If TO-HERE is non-nil, it should be a point in the buffer. All
8193 articles before this point will be marked as read.
8194 Note that this function will only catch up the unread article
8195 in the current summary buffer limitation.
8196 The number of articles marked as read is returned."
8201 (not gnus-interactive-catchup) ;Without confirmation?
8205 "Mark absolutely all articles as read? "
8206 "Mark all unread articles as read? ")))
8208 (not gnus-newsgroup-adaptive)
8209 (not gnus-newsgroup-auto-expire)
8210 (not gnus-suppress-duplicates)
8211 (or (not gnus-use-cache)
8212 (eq gnus-use-cache 'passive)))
8215 (setq gnus-newsgroup-marked nil
8216 gnus-newsgroup-dormant nil))
8217 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8218 ;; We actually mark all articles as canceled, which we
8219 ;; have to do when using auto-expiry or adaptive scoring.
8220 (gnus-summary-show-all-threads)
8221 (when (gnus-summary-first-subject (not all) t)
8223 (if to-here (< (point) to-here) t)
8224 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8225 (gnus-summary-find-next (not all) nil nil t))))
8226 (gnus-set-mode-line 'summary))
8228 (gnus-summary-position-point)))
8230 (defun gnus-summary-catchup-to-here (&optional all)
8231 "Mark all unticked articles before the current one as read.
8232 If ALL is non-nil, also mark ticked and dormant articles as read."
8235 (gnus-save-hidden-threads
8236 (let ((beg (point)))
8237 ;; We check that there are unread articles.
8238 (when (or all (gnus-summary-find-prev))
8239 (gnus-summary-catchup all t beg)))))
8240 (gnus-summary-position-point))
8242 (defun gnus-summary-catchup-all (&optional quietly)
8243 "Mark all articles in this newsgroup as read."
8245 (gnus-summary-catchup t quietly))
8247 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8248 "Mark all articles not marked as unread in this newsgroup as read, then exit.
8249 If prefix argument ALL is non-nil, all articles are marked as read."
8251 (when (gnus-summary-catchup all quietly nil 'fast)
8252 ;; Select next newsgroup or exit.
8253 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
8254 (eq gnus-auto-select-next 'quietly))
8255 (gnus-summary-next-group nil)
8256 (gnus-summary-exit))))
8258 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8259 "Mark all articles in this newsgroup as read, and then exit."
8261 (gnus-summary-catchup-and-exit t quietly))
8263 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
8264 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8265 "Mark all articles in this group as read and select the next group.
8266 If given a prefix, mark all articles, unread as well as ticked, as
8270 (gnus-summary-catchup all))
8271 (gnus-summary-next-article t nil nil t))
8273 ;; Thread-based commands.
8275 (defun gnus-summary-articles-in-thread (&optional article)
8276 "Return a list of all articles in the current thread.
8277 If ARTICLE is non-nil, return all articles in the thread that starts
8279 (let* ((article (or article (gnus-summary-article-number)))
8280 (data (gnus-data-find-list article))
8281 (top-level (gnus-data-level (car data)))
8283 (cond ((null gnus-thread-operation-ignore-subject)
8284 (gnus-simplify-subject-re
8285 (mail-header-subject (gnus-data-header (car data)))))
8286 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8287 (gnus-simplify-subject-fuzzy
8288 (mail-header-subject (gnus-data-header (car data)))))
8290 (end-point (save-excursion
8291 (if (gnus-summary-go-to-next-thread)
8292 (point) (point-max))))
8295 (< (gnus-data-pos (car data)) end-point))
8296 (when (or (not top-subject)
8297 (string= top-subject
8298 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8299 (gnus-simplify-subject-fuzzy
8300 (mail-header-subject
8301 (gnus-data-header (car data))))
8302 (gnus-simplify-subject-re
8303 (mail-header-subject
8304 (gnus-data-header (car data)))))))
8305 (push (gnus-data-number (car data)) articles))
8306 (unless (and (setq data (cdr data))
8307 (> (gnus-data-level (car data)) top-level))
8309 ;; Return the list of articles.
8310 (nreverse articles)))
8312 (defun gnus-summary-rethread-current ()
8313 "Rethread the thread the current article is part of."
8315 (let* ((gnus-show-threads t)
8316 (article (gnus-summary-article-number))
8317 (id (mail-header-id (gnus-summary-article-header)))
8318 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8320 (error "No article on the current line"))
8321 (gnus-rebuild-thread id)
8322 (gnus-summary-goto-subject article)))
8324 (defun gnus-summary-reparent-thread ()
8325 "Make the current article child of the marked (or previous) article.
8327 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8328 is non-nil or the Subject: of both articles are the same."
8330 (unless (not (gnus-group-read-only-p))
8331 (error "The current newsgroup does not support article editing"))
8332 (unless (<= (length gnus-newsgroup-processable) 1)
8333 (error "No more than one article may be marked"))
8334 (save-window-excursion
8335 (let ((gnus-article-buffer " *reparent*")
8336 (current-article (gnus-summary-article-number))
8337 ;; First grab the marked article, otherwise one line up.
8338 (parent-article (if (not (null gnus-newsgroup-processable))
8339 (car gnus-newsgroup-processable)
8341 (if (eq (forward-line -1) 0)
8342 (gnus-summary-article-number)
8343 (error "Beginning of summary buffer"))))))
8344 (unless (not (eq current-article parent-article))
8345 (error "An article may not be self-referential"))
8346 (let ((message-id (mail-header-id
8347 (gnus-summary-article-header parent-article))))
8348 (unless (and message-id (not (equal message-id "")))
8349 (error "No message-id in desired parent"))
8350 (gnus-with-article current-article
8351 (goto-char (point-min))
8352 (if (re-search-forward "^References: " nil t)
8354 (re-search-forward "^[^ \t]" nil t)
8357 (insert " " message-id))
8358 (insert "References: " message-id "\n")))
8359 (set-buffer gnus-summary-buffer)
8360 (gnus-summary-unmark-all-processable)
8361 (gnus-summary-update-article current-article)
8362 (gnus-summary-rethread-current)
8363 (gnus-message 3 "Article %d is now the child of article %d"
8364 current-article parent-article)))))
8366 (defun gnus-summary-toggle-threads (&optional arg)
8367 "Toggle showing conversation threads.
8368 If ARG is positive number, turn showing conversation threads on."
8370 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8371 (setq gnus-show-threads
8372 (if (null arg) (not gnus-show-threads)
8373 (> (prefix-numeric-value arg) 0)))
8374 (gnus-summary-prepare)
8375 (gnus-summary-goto-subject current)
8376 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8377 (gnus-summary-position-point)))
8379 (defun gnus-summary-show-all-threads ()
8383 (let ((buffer-read-only nil))
8384 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8385 (gnus-summary-position-point))
8387 (defun gnus-summary-show-thread ()
8388 "Show thread subtrees.
8389 Returns nil if no thread was there to be shown."
8391 (let ((buffer-read-only nil)
8393 ;; first goto end then to beg, to have point at beg after let
8394 (end (progn (end-of-line) (point)))
8395 (beg (progn (beginning-of-line) (point))))
8397 ;; Any hidden lines here?
8398 (search-forward "\r" end t)
8399 (subst-char-in-region beg end ?\^M ?\n t)
8401 (gnus-summary-position-point))))
8403 (defun gnus-summary-hide-all-threads ()
8404 "Hide all thread subtrees."
8407 (goto-char (point-min))
8408 (gnus-summary-hide-thread)
8409 (while (zerop (gnus-summary-next-thread 1 t))
8410 (gnus-summary-hide-thread)))
8411 (gnus-summary-position-point))
8413 (defun gnus-summary-hide-thread ()
8414 "Hide thread subtrees.
8415 Returns nil if no threads were there to be hidden."
8417 (let ((buffer-read-only nil)
8419 (article (gnus-summary-article-number)))
8421 ;; Go forward until either the buffer ends or the subthread
8423 (when (and (not (eobp))
8424 (or (zerop (gnus-summary-next-thread 1 t))
8425 (goto-char (point-max))))
8427 (if (and (> (point) start)
8428 (search-backward "\n" start t))
8430 (subst-char-in-region start (point) ?\n ?\^M)
8431 (gnus-summary-goto-subject article))
8434 ;;(gnus-summary-position-point)
8437 (defun gnus-summary-go-to-next-thread (&optional previous)
8438 "Go to the same level (or less) next thread.
8439 If PREVIOUS is non-nil, go to previous thread instead.
8440 Return the article number moved to, or nil if moving was impossible."
8441 (let ((level (gnus-summary-thread-level))
8442 (way (if previous -1 1))
8445 (while (and (not (eobp))
8446 (< level (gnus-summary-thread-level)))
8454 (gnus-summary-article-number)
8457 (defun gnus-summary-next-thread (n &optional silent)
8458 "Go to the same level next N'th thread.
8459 If N is negative, search backward instead.
8460 Returns the difference between N and the number of skips actually
8463 If SILENT, don't output messages."
8465 (let ((backward (< n 0))
8468 (gnus-summary-go-to-next-thread backward))
8471 (gnus-summary-position-point))
8472 (when (and (not silent) (/= 0 n))
8473 (gnus-message 7 "No more threads"))
8476 (defun gnus-summary-prev-thread (n)
8477 "Go to the same level previous N'th thread.
8478 Returns the difference between N and the number of skips actually
8481 (gnus-summary-next-thread (- n)))
8483 (defun gnus-summary-go-down-thread ()
8484 "Go down one level in the current thread."
8485 (let ((children (gnus-summary-article-children)))
8487 (gnus-summary-goto-subject (car children)))))
8489 (defun gnus-summary-go-up-thread ()
8490 "Go up one level in the current thread."
8491 (let ((parent (gnus-summary-article-parent)))
8493 (gnus-summary-goto-subject parent))))
8495 (defun gnus-summary-down-thread (n)
8496 "Go down thread N steps.
8497 If N is negative, go up instead.
8498 Returns the difference between N and how many steps down that were
8504 (if up (gnus-summary-go-up-thread)
8505 (gnus-summary-go-down-thread)))
8507 (gnus-summary-position-point)
8509 (gnus-message 7 "Can't go further"))
8512 (defun gnus-summary-up-thread (n)
8513 "Go up thread N steps.
8514 If N is negative, go up instead.
8515 Returns the difference between N and how many steps down that were
8518 (gnus-summary-down-thread (- n)))
8520 (defun gnus-summary-top-thread ()
8521 "Go to the top of the thread."
8523 (while (gnus-summary-go-up-thread))
8524 (gnus-summary-article-number))
8526 (defun gnus-summary-kill-thread (&optional unmark)
8527 "Mark articles under current thread as read.
8528 If the prefix argument is positive, remove any kinds of marks.
8529 If the prefix argument is negative, tick articles instead."
8532 (setq unmark (prefix-numeric-value unmark)))
8533 (let ((articles (gnus-summary-articles-in-thread)))
8535 ;; Expand the thread.
8536 (gnus-summary-show-thread)
8537 ;; Mark all the articles.
8539 (gnus-summary-goto-subject (car articles))
8540 (cond ((null unmark)
8541 (gnus-summary-mark-article-as-read gnus-killed-mark))
8543 (gnus-summary-mark-article-as-unread gnus-unread-mark))
8545 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
8546 (setq articles (cdr articles))))
8547 ;; Hide killed subtrees.
8549 gnus-thread-hide-killed
8550 (gnus-summary-hide-thread))
8551 ;; If marked as read, go to next unread subject.
8553 ;; Go to next unread subject.
8554 (gnus-summary-next-subject 1 t)))
8555 (gnus-set-mode-line 'summary))
8557 ;; Summary sorting commands
8559 (defun gnus-summary-sort-by-number (&optional reverse)
8560 "Sort the summary buffer by article number.
8561 Argument REVERSE means reverse order."
8563 (gnus-summary-sort 'number reverse))
8565 (defun gnus-summary-sort-by-author (&optional reverse)
8566 "Sort the summary buffer by author name alphabetically.
8567 If case-fold-search is non-nil, case of letters is ignored.
8568 Argument REVERSE means reverse order."
8570 (gnus-summary-sort 'author reverse))
8572 (defun gnus-summary-sort-by-subject (&optional reverse)
8573 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8574 If case-fold-search is non-nil, case of letters is ignored.
8575 Argument REVERSE means reverse order."
8577 (gnus-summary-sort 'subject reverse))
8579 (defun gnus-summary-sort-by-date (&optional reverse)
8580 "Sort the summary buffer by date.
8581 Argument REVERSE means reverse order."
8583 (gnus-summary-sort 'date reverse))
8585 (defun gnus-summary-sort-by-score (&optional reverse)
8586 "Sort the summary buffer by score.
8587 Argument REVERSE means reverse order."
8589 (gnus-summary-sort 'score reverse))
8591 (defun gnus-summary-sort-by-lines (&optional reverse)
8592 "Sort the summary buffer by the number of lines.
8593 Argument REVERSE means reverse order."
8595 (gnus-summary-sort 'lines reverse))
8597 (defun gnus-summary-sort-by-chars (&optional reverse)
8598 "Sort the summary buffer by article length.
8599 Argument REVERSE means reverse order."
8601 (gnus-summary-sort 'chars reverse))
8603 (defun gnus-summary-sort (predicate reverse)
8604 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
8605 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
8606 (article (intern (format "gnus-article-sort-by-%s" predicate)))
8607 (gnus-thread-sort-functions
8612 (gnus-article-sort-functions
8618 (gnus-summary-prepare-hook nil))
8619 ;; We do the sorting by regenerating the threads.
8620 (gnus-summary-prepare)
8621 ;; Hide subthreads if needed.
8622 (when (and gnus-show-threads gnus-thread-hide-subtree)
8623 (gnus-summary-hide-all-threads))))
8625 ;; Summary saving commands.
8627 (defun gnus-summary-save-article (&optional n not-saved)
8628 "Save the current article using the default saver function.
8629 If N is a positive number, save the N next articles.
8630 If N is a negative number, save the N previous articles.
8631 If N is nil and any articles have been marked with the process mark,
8632 save those articles instead.
8633 The variable `gnus-default-article-saver' specifies the saver function."
8635 (let* ((articles (gnus-summary-work-articles n))
8636 (save-buffer (save-excursion
8637 (nnheader-set-temp-buffer " *Gnus Save*")))
8638 (num (length articles))
8640 (dolist (article articles)
8641 (setq header (gnus-summary-article-header article))
8642 (if (not (vectorp header))
8643 ;; This is a pseudo-article.
8644 (if (assq 'name header)
8645 (gnus-copy-file (cdr (assq 'name header)))
8646 (gnus-message 1 "Article %d is unsaveable" article))
8647 ;; This is a real article.
8648 (save-window-excursion
8649 (gnus-summary-select-article t nil nil article))
8651 (set-buffer save-buffer)
8653 (insert-buffer-substring gnus-original-article-buffer))
8654 (setq file (gnus-article-save save-buffer file num))
8655 (gnus-summary-remove-process-mark article)
8657 (gnus-summary-set-saved-mark article))))
8658 (gnus-kill-buffer save-buffer)
8659 (gnus-summary-position-point)
8660 (gnus-set-mode-line 'summary)
8663 (defun gnus-summary-pipe-output (&optional arg)
8664 "Pipe the current article to a subprocess.
8665 If N is a positive number, pipe the N next articles.
8666 If N is a negative number, pipe the N previous articles.
8667 If N is nil and any articles have been marked with the process mark,
8668 pipe those articles instead."
8670 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8671 (gnus-summary-save-article arg t))
8672 (gnus-configure-windows 'pipe))
8674 (defun gnus-summary-save-article-mail (&optional arg)
8675 "Append the current article to an mail file.
8676 If N is a positive number, save the N next articles.
8677 If N is a negative number, save the N previous articles.
8678 If N is nil and any articles have been marked with the process mark,
8679 save those articles instead."
8681 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8682 (gnus-summary-save-article arg)))
8684 (defun gnus-summary-save-article-rmail (&optional arg)
8685 "Append the current article to an rmail file.
8686 If N is a positive number, save the N next articles.
8687 If N is a negative number, save the N previous articles.
8688 If N is nil and any articles have been marked with the process mark,
8689 save those articles instead."
8691 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
8692 (gnus-summary-save-article arg)))
8694 (defun gnus-summary-save-article-file (&optional arg)
8695 "Append the current article to a file.
8696 If N is a positive number, save the N next articles.
8697 If N is a negative number, save the N previous articles.
8698 If N is nil and any articles have been marked with the process mark,
8699 save those articles instead."
8701 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8702 (gnus-summary-save-article arg)))
8704 (defun gnus-summary-write-article-file (&optional arg)
8705 "Write the current article to a file, deleting the previous file.
8706 If N is a positive number, save the N next articles.
8707 If N is a negative number, save the N previous articles.
8708 If N is nil and any articles have been marked with the process mark,
8709 save those articles instead."
8711 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
8712 (gnus-summary-save-article arg)))
8714 (defun gnus-summary-save-article-body-file (&optional arg)
8715 "Append the current article body to a file.
8716 If N is a positive number, save the N next articles.
8717 If N is a negative number, save the N previous articles.
8718 If N is nil and any articles have been marked with the process mark,
8719 save those articles instead."
8721 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
8722 (gnus-summary-save-article arg)))
8724 (defun gnus-summary-pipe-message (program)
8725 "Pipe the current article through PROGRAM."
8726 (interactive "sProgram: ")
8727 (gnus-summary-select-article)
8728 (let ((mail-header-separator ""))
8729 (gnus-eval-in-buffer-window gnus-article-buffer
8732 (let ((start (window-start))
8734 (message-pipe-buffer-body program)
8735 (set-window-start (get-buffer-window (current-buffer)) start))))))
8737 (defun gnus-get-split-value (methods)
8738 "Return a value based on the split METHODS."
8739 (let (split-name method result match)
8742 (set-buffer gnus-original-article-buffer)
8744 (nnheader-narrow-to-headers)
8746 (goto-char (point-min))
8747 (setq method (pop methods))
8748 (setq match (car method))
8751 ;; Regular expression.
8753 (re-search-forward match nil t)))
8754 ((gnus-functionp match)
8758 (setq result (funcall match gnus-newsgroup-name))))
8763 (setq result (eval match)))))
8764 (setq split-name (append (cdr method) split-name))
8765 (cond ((stringp result)
8766 (push (expand-file-name
8767 result gnus-article-save-directory)
8770 (setq split-name (append result split-name)))))))))
8771 (nreverse split-name)))
8773 (defun gnus-valid-move-group-p (group)
8776 (symbol-value group)
8779 (car (gnus-find-method-for-group
8780 (symbol-name group))))
8781 gnus-valid-select-methods))))
8783 (defun gnus-read-move-group-name (prompt default articles prefix)
8784 "Read a group name."
8785 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
8786 (minibuffer-confirm-incomplete nil) ; XEmacs
8790 (if (> (length articles) 1)
8791 (format "these %d articles" (length articles))
8796 (gnus-completing-read default prom
8798 'gnus-valid-move-group-p
8800 'gnus-group-history))
8801 ((= 1 (length split-name))
8802 (gnus-completing-read (car split-name) prom
8804 'gnus-valid-move-group-p
8806 'gnus-group-history))
8808 (gnus-completing-read nil prom
8809 (mapcar (lambda (el) (list el))
8810 (nreverse split-name))
8812 'gnus-group-history)))))
8814 (if (or (string= to-newsgroup "")
8815 (string= to-newsgroup prefix))
8816 (setq to-newsgroup default))
8817 (unless to-newsgroup
8818 (error "No group name entered"))
8819 (or (gnus-active to-newsgroup)
8820 (gnus-activate-group to-newsgroup)
8821 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
8823 (or (and (gnus-request-create-group
8824 to-newsgroup (gnus-group-name-to-method to-newsgroup))
8825 (gnus-activate-group to-newsgroup nil nil
8826 (gnus-group-name-to-method
8828 (error "Couldn't create group %s" to-newsgroup)))
8829 (error "No such group: %s" to-newsgroup)))
8832 ;; Summary extract commands
8834 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
8835 (let ((buffer-read-only nil)
8836 (article (gnus-summary-article-number))
8838 (unless (gnus-summary-goto-subject article)
8839 (error "No such article: %d" article))
8840 (gnus-summary-position-point)
8841 ;; If all commands are to be bunched up on one line, we collect
8843 (unless gnus-view-pseudos-separately
8844 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
8847 (setq action (cdr (assq 'action (car ps))))
8848 (setq files (list (cdr (assq 'name (car ps)))))
8849 (while (and ps (cdr ps)
8850 (string= (or action "1")
8851 (or (cdr (assq 'action (cadr ps))) "2")))
8852 (push (cdr (assq 'name (cadr ps))) files)
8853 (setcdr ps (cddr ps)))
8855 (when (not (string-match "%s" action))
8858 (when (assq 'execute (car ps))
8859 (setcdr (assq 'execute (car ps))
8860 (funcall (if (string-match "%s" action)
8867 (gnus-quote-arg-for-sh-or-csh f)))
8869 (setq ps (cdr ps)))))
8870 (if (and gnus-view-pseudos (not not-view))
8872 (when (assq 'execute (car pslist))
8873 (gnus-execute-command (cdr (assq 'execute (car pslist)))
8874 (eq gnus-view-pseudos 'not-confirm)))
8875 (setq pslist (cdr pslist)))
8878 (setq after-article (or (cdr (assq 'article (car pslist)))
8879 (gnus-summary-article-number)))
8880 (gnus-summary-goto-subject after-article)
8883 (insert " " (file-name-nondirectory
8884 (cdr (assq 'name (car pslist))))
8885 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
8887 (forward-line -1) ; back to `b'
8888 (gnus-add-text-properties
8889 b (1- e) (list 'gnus-number gnus-reffed-article-number
8890 gnus-mouse-face-prop gnus-mouse-face))
8892 after-article gnus-reffed-article-number
8893 gnus-unread-mark b (car pslist) 0 (- e b))
8894 (push gnus-reffed-article-number gnus-newsgroup-unreads)
8895 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
8896 (setq pslist (cdr pslist)))))))
8898 (defun gnus-pseudos< (p1 p2)
8899 (let ((c1 (cdr (assq 'action p1)))
8900 (c2 (cdr (assq 'action p2))))
8901 (and c1 c2 (string< c1 c2))))
8903 (defun gnus-request-pseudo-article (props)
8904 (cond ((assq 'execute props)
8905 (gnus-execute-command (cdr (assq 'execute props)))))
8906 (let ((gnus-current-article (gnus-summary-article-number)))
8907 (gnus-run-hooks 'gnus-mark-article-hook)))
8909 (defun gnus-execute-command (command &optional automatic)
8911 (gnus-article-setup-buffer)
8912 (set-buffer gnus-article-buffer)
8913 (setq buffer-read-only nil)
8914 (let ((command (if automatic command
8915 (read-string "Command: " (cons command 0)))))
8917 (insert "$ " command "\n\n")
8918 (if gnus-view-pseudo-asynchronously
8919 (start-process "gnus-execute" (current-buffer) shell-file-name
8920 shell-command-switch command)
8921 (call-process shell-file-name nil t nil
8922 shell-command-switch command)))))
8924 ;; Summary kill commands.
8926 (defun gnus-summary-edit-global-kill (article)
8927 "Edit the \"global\" kill file."
8928 (interactive (list (gnus-summary-article-number)))
8929 (gnus-group-edit-global-kill article))
8931 (defun gnus-summary-edit-local-kill ()
8932 "Edit a local kill file applied to the current newsgroup."
8934 (setq gnus-current-headers (gnus-summary-article-header))
8935 (gnus-group-edit-local-kill
8936 (gnus-summary-article-number) gnus-newsgroup-name))
8940 (defun gnus-read-header (id &optional header)
8941 "Read the headers of article ID and enter them into the Gnus system."
8942 (let ((group gnus-newsgroup-name)
8943 (gnus-override-method
8944 (and (gnus-news-group-p gnus-newsgroup-name)
8945 gnus-refer-article-method))
8947 ;; First we check to see whether the header in question is already
8950 ;; This is a Message-ID.
8951 (setq header (or header (gnus-id-to-header id)))
8952 ;; This is an article number.
8953 (setq header (or header (gnus-summary-article-header id))))
8955 (not (gnus-summary-article-sparse-p (mail-header-number header))))
8956 ;; We have found the header.
8958 ;; If this is a sparse article, we have to nix out its
8959 ;; previous entry in the thread hashtb.
8961 (gnus-summary-article-sparse-p (mail-header-number header)))
8962 (let* ((parent (gnus-parent-id (mail-header-references header)))
8963 (thread (and parent (gnus-id-to-thread parent))))
8965 (delq (assq header thread) thread))))
8966 ;; We have to really fetch the header to this article.
8968 (set-buffer nntp-server-buffer)
8969 (when (setq where (gnus-request-head id group))
8970 (nnheader-fold-continuation-lines)
8971 (goto-char (point-max))
8973 (goto-char (point-min))
8977 ((cdr where) (cdr where))
8978 (header (mail-header-number header))
8979 (t gnus-reffed-article-number))
8981 (insert " Article retrieved.\n"))
8983 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
8984 () ; Malformed head.
8985 (unless (gnus-summary-article-sparse-p (mail-header-number header))
8986 (when (and (stringp id)
8987 (not (string= (gnus-group-real-name group)
8989 ;; If we fetched by Message-ID and the article came
8990 ;; from a different group, we fudge some bogus article
8991 ;; numbers for this article.
8992 (mail-header-set-number header gnus-reffed-article-number))
8994 (set-buffer gnus-summary-buffer)
8995 (decf gnus-reffed-article-number)
8996 (gnus-remove-header (mail-header-number header))
8997 (push header gnus-newsgroup-headers)
8998 (setq gnus-current-headers header)
8999 (push (mail-header-number header) gnus-newsgroup-limit)))
9002 (defun gnus-remove-header (number)
9003 "Remove header NUMBER from `gnus-newsgroup-headers'."
9004 (if (and gnus-newsgroup-headers
9005 (= number (mail-header-number (car gnus-newsgroup-headers))))
9006 (pop gnus-newsgroup-headers)
9007 (let ((headers gnus-newsgroup-headers))
9008 (while (and (cdr headers)
9009 (not (= number (mail-header-number (cadr headers)))))
9012 (setcdr headers (cddr headers))))))
9015 ;;; summary highlights
9018 (defun gnus-highlight-selected-summary ()
9019 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
9020 ;; Highlight selected article in summary buffer
9021 (when gnus-summary-selected-face
9023 (let* ((beg (progn (beginning-of-line) (point)))
9024 (end (progn (end-of-line) (point)))
9025 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
9026 (from (if (get-text-property beg gnus-mouse-face-prop)
9028 (or (next-single-property-change
9029 beg gnus-mouse-face-prop nil end)
9034 (or (next-single-property-change
9035 from gnus-mouse-face-prop nil end)
9037 ;; If no mouse-face prop on line we will have to = from = end,
9038 ;; so we highlight the entire line instead.
9039 (when (= (+ to 2) from)
9042 (if gnus-newsgroup-selected-overlay
9043 ;; Move old overlay.
9045 gnus-newsgroup-selected-overlay from to (current-buffer))
9046 ;; Create new overlay.
9048 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
9049 'face gnus-summary-selected-face))))))
9051 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
9052 (defun gnus-summary-highlight-line ()
9053 "Highlight current line according to `gnus-summary-highlight'."
9054 (let* ((list gnus-summary-highlight)
9056 (end (progn (end-of-line) (point)))
9057 ;; now find out where the line starts and leave point there.
9058 (beg (progn (beginning-of-line) (point)))
9059 (article (gnus-summary-article-number))
9060 (score (or (cdr (assq (or article gnus-current-article)
9061 gnus-newsgroup-scored))
9062 gnus-summary-default-score 0))
9063 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
9064 (inhibit-read-only t))
9065 ;; Eval the cars of the lists until we find a match.
9066 (let ((default gnus-summary-default-score))
9068 (not (eval (caar list))))
9069 (setq list (cdr list))))
9070 (let ((face (cdar list)))
9071 (unless (eq face (get-text-property beg 'face))
9072 (gnus-put-text-property-excluding-characters-with-faces
9074 (setq face (if (boundp face) (symbol-value face) face)))
9075 (when gnus-summary-highlight-line-function
9076 (funcall gnus-summary-highlight-line-function article face))))
9079 (defun gnus-update-read-articles (group unread &optional compute)
9080 "Update the list of read articles in GROUP."
9081 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
9082 (entry (gnus-gethash group gnus-newsrc-hashtb))
9083 (info (nth 2 entry))
9085 (unread (sort (copy-sequence unread) '<))
9087 (if (or (not info) (not active))
9088 ;; There is no info on this group if it was, in fact,
9089 ;; killed. Gnus stores no information on killed groups, so
9090 ;; there's nothing to be done.
9091 ;; One could store the information somewhere temporarily,
9092 ;; perhaps... Hmmm...
9094 ;; Remove any negative articles numbers.
9095 (while (and unread (< (car unread) 0))
9096 (setq unread (cdr unread)))
9097 ;; Remove any expired article numbers
9098 (while (and unread (< (car unread) (car active)))
9099 (setq unread (cdr unread)))
9100 ;; Compute the ranges of read articles by looking at the list of
9103 (when (/= (car unread) prev)
9104 (push (if (= prev (1- (car unread))) prev
9105 (cons prev (1- (car unread))))
9107 (setq prev (1+ (car unread)))
9108 (setq unread (cdr unread)))
9109 (when (<= prev (cdr active))
9110 (push (cons prev (cdr active)) read))
9111 (setq read (if (> (length read) 1) (nreverse read) read))
9115 (set-buffer gnus-group-buffer)
9118 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
9119 (gnus-info-set-read ',info ',(gnus-info-read info))
9120 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
9121 (gnus-group-update-group ,group t))))
9122 ;; Propagate the read marks to the backend.
9123 (if (gnus-check-backend-function 'request-set-mark group)
9124 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
9125 (add (gnus-remove-from-range read (gnus-info-read info))))
9127 (unless (gnus-check-group group)
9128 (error "Can't open server for %s" group))
9129 (gnus-request-set-mark
9130 group (delq nil (list (if add (list add 'add '(read)))
9131 (if del (list del 'del '(read)))))))))
9132 ;; Enter this list into the group info.
9133 (gnus-info-set-read info read)
9134 ;; Set the number of unread articles in gnus-newsrc-hashtb.
9135 (gnus-get-unread-articles-in-group info (gnus-active group))
9138 (defun gnus-offer-save-summaries ()
9139 "Offer to save all active summary buffers."
9141 (let ((buflist (buffer-list))
9143 ;; Go through all buffers and find all summaries.
9145 (and (setq bufname (buffer-name (car buflist)))
9146 (string-match "Summary" bufname)
9148 (set-buffer bufname)
9149 ;; We check that this is, indeed, a summary buffer.
9150 (and (eq major-mode 'gnus-summary-mode)
9151 ;; Also make sure this isn't bogus.
9152 gnus-newsgroup-prepared
9153 ;; Also make sure that this isn't a dead summary buffer.
9154 (not gnus-dead-summary-mode)))
9155 (push bufname buffers))
9156 (setq buflist (cdr buflist)))
9157 ;; Go through all these summary buffers and offer to save them.
9160 "Update summary buffer %s? "
9162 (switch-to-buffer buf)
9163 (gnus-summary-exit))
9167 ;;; @ for mime-partial
9170 (defun gnus-request-partial-message ()
9172 (let ((number (gnus-summary-article-number))
9173 (group gnus-newsgroup-name)
9174 (mother gnus-article-buffer))
9175 (set-buffer (get-buffer-create " *Partial Article*"))
9177 (setq mime-preview-buffer mother)
9178 (gnus-request-article-this-buffer number group)
9182 (autoload 'mime-combine-message/partial-pieces-automatically
9184 "Internal method to combine message/partial messages automatically.")
9187 'action '((type . message)(subtype . partial)
9188 (major-mode . gnus-original-article-mode)
9189 (method . mime-combine-message/partial-pieces-automatically)
9190 (summary-buffer-exp . gnus-summary-buffer)
9191 (request-partial-message-method . gnus-request-partial-message)
9195 ;;; @ for message/rfc822
9198 (defun gnus-mime-extract-message/rfc822 (entity situation)
9199 (let (group article num cwin swin cur)
9200 (with-current-buffer (mime-entity-buffer entity)
9202 (narrow-to-region (mime-entity-body-start entity)
9203 (mime-entity-body-end entity))
9204 (setq group (or (cdr (assq 'group situation))
9205 (completing-read "Group: "
9208 (gnus-read-active-file-p)
9209 gnus-newsgroup-name))
9210 article (gnus-request-accept-article group)
9213 (when (and (consp article)
9214 (numberp (setq article (cdr article))))
9215 (setq num (1+ (or (cdr (assq 'number situation)) 0))
9216 cwin (get-buffer-window (current-buffer) t)
9218 (save-window-excursion
9219 (if (setq swin (get-buffer-window gnus-summary-buffer t))
9220 (select-window swin)
9221 (set-buffer gnus-summary-buffer)
9223 (setq cur gnus-current-article)
9225 (let (gnus-show-threads)
9226 (gnus-summary-goto-subject article t)
9228 (gnus-summary-clear-mark-forward 1)
9229 (gnus-summary-goto-subject cur)
9231 (when (and cwin (window-frame cwin))
9232 (select-frame (window-frame cwin))
9234 (when (boundp 'mime-acting-situation-to-override)
9235 (set-alist 'mime-acting-situation-to-override
9238 (set-alist 'mime-acting-situation-to-override
9241 (save-current-buffer
9242 (set-buffer gnus-group-buffer)
9243 (gnus-activate-group ,group)
9245 (gnus-summary-goto-article ,cur
9246 gnus-show-all-headers)
9248 (set-alist 'mime-acting-situation-to-override
9254 'action '((type . message)(subtype . rfc822)
9255 (major-mode . gnus-original-article-mode)
9256 (method . gnus-mime-extract-message/rfc822)
9261 'action '((type . message)(subtype . news)
9262 (major-mode . gnus-original-article-mode)
9263 (method . gnus-mime-extract-message/rfc822)
9267 (defun gnus-mime-extract-multipart (entity situation)
9268 (let ((children (mime-entity-children entity))
9269 mime-acting-situation-to-override
9272 (mime-play-entity (car children)
9273 (cons (assq 'mode situation)
9274 mime-acting-situation-to-override))
9275 (setq children (cdr children)))
9276 (if (setq f (cdr (assq 'after-method
9277 mime-acting-situation-to-override)))
9282 'action '((type . multipart)
9283 (method . gnus-mime-extract-multipart)
9292 (defun gnus-summary-setup-default-charset ()
9293 "Setup newsgroup default charset."
9294 (let ((name (and gnus-newsgroup-name
9295 (gnus-group-real-name gnus-newsgroup-name))))
9296 (setq gnus-newsgroup-charset
9297 (or (and gnus-newsgroup-name
9298 (or (gnus-group-find-parameter gnus-newsgroup-name
9300 (let ((alist gnus-group-charset-alist)
9302 (while (setq elem (pop alist))
9304 (string-match (car elem) name))
9306 charset (cadr elem))))
9308 gnus-default-charset))))
9314 (defun gnus-summary-display-buttonized (&optional show-all-parts)
9315 "Display the current article buffer fully MIME-buttonized.
9316 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
9317 treated as multipart/mixed."
9320 (let ((gnus-unbuttonized-mime-types nil)
9321 (gnus-mime-display-multipart-as-mixed show-all-parts))
9322 (gnus-summary-show-article)))
9324 (defun gnus-summary-repair-multipart (article)
9325 "Add a Content-Type header to a multipart article without one."
9326 (interactive (list (gnus-summary-article-number)))
9327 (gnus-with-article article
9328 (message-narrow-to-head)
9329 (goto-char (point-max))
9331 (when (search-forward "\n--" nil t)
9332 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
9333 (message-narrow-to-head)
9334 (message-remove-header "Mime-Version")
9335 (message-remove-header "Content-Type")
9336 (goto-char (point-max))
9337 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
9339 (insert "Mime-Version: 1.0\n")
9341 (let (gnus-mark-article-hook)
9342 (gnus-summary-select-article t t nil article)))
9344 (defun gnus-summary-toggle-display-buttonized ()
9345 "Toggle the buttonizing of the article buffer."
9348 (if (setq gnus-inhibit-mime-unbuttonizing
9349 (not gnus-inhibit-mime-unbuttonizing))
9350 (let ((gnus-unbuttonized-mime-types nil))
9351 (gnus-summary-show-article))
9352 (gnus-summary-show-article)))
9358 (defmacro gnus-with-article (article &rest forms)
9359 "Select ARTICLE and perform FORMS in the original article buffer.
9360 Then replace the article with the result."
9362 ;; We don't want the article to be marked as read.
9363 (let (gnus-mark-article-hook)
9364 (gnus-summary-select-article t t nil ,article))
9365 (set-buffer gnus-original-article-buffer)
9367 (if (not (gnus-check-backend-function
9368 'request-replace-article (car gnus-article-current)))
9369 (gnus-message 5 "Read-only group; not replacing")
9370 (unless (gnus-request-replace-article
9371 ,article (car gnus-article-current)
9373 (error "Couldn't replace article")))
9374 ;; The cache and backlog have to be flushed somewhat.
9375 (when gnus-keep-backlog
9376 (gnus-backlog-remove-article
9377 (car gnus-article-current) (cdr gnus-article-current)))
9378 (when gnus-use-cache
9379 (gnus-cache-update-article
9380 (car gnus-article-current) (cdr gnus-article-current)))))
9382 (put 'gnus-with-article 'lisp-indent-function 1)
9383 (put 'gnus-with-article 'edebug-form-spec '(form body))
9386 ;;; Generic summary marking commands
9389 (defvar gnus-summary-marking-alist
9390 '((read gnus-del-mark "d")
9391 (unread gnus-unread-mark "u")
9392 (ticked gnus-ticked-mark "!")
9393 (dormant gnus-dormant-mark "?")
9394 (expirable gnus-expirable-mark "e"))
9395 "An alist of names/marks/keystrokes.")
9397 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
9398 (defvar gnus-summary-mark-map)
9400 (defun gnus-summary-make-all-marking-commands ()
9401 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
9402 (dolist (elem gnus-summary-marking-alist)
9403 (apply 'gnus-summary-make-marking-command elem)))
9405 (defun gnus-summary-make-marking-command (name mark keystroke)
9406 (let ((map (make-sparse-keymap)))
9407 (define-key gnus-summary-generic-mark-map keystroke map)
9408 (dolist (lway `((next "next" next nil "n")
9409 (next-unread "next unread" next t "N")
9410 (prev "previous" prev nil "p")
9411 (prev-unread "previous unread" prev t "P")
9412 (nomove "" nil nil ,keystroke)))
9413 (let ((func (gnus-summary-make-marking-command-1
9414 mark (car lway) lway name)))
9415 (setq func (eval func))
9416 (define-key map (nth 4 lway) func)))))
9418 (defun gnus-summary-make-marking-command-1 (mark way lway name)
9420 (format "gnus-summary-put-mark-as-%s%s"
9421 name (if (eq way 'nomove)
9423 (concat "-" (symbol-name way)))))
9426 "Mark the current article as %s%s.
9427 If N, the prefix, then repeat N times.
9428 If N is negative, move in reverse order.
9429 The difference between N and the actual number of articles marked is
9433 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
9435 (defun gnus-summary-generic-mark (n mark move unread)
9436 "Mark N articles with MARK."
9437 (unless (eq major-mode 'gnus-summary-mode)
9438 (error "This command can only be used in the summary buffer"))
9439 (gnus-summary-show-thread)
9443 ((eq move 'prev) -1)
9449 nummove (* -1 nummove))))
9451 (gnus-summary-mark-article nil mark)
9452 (zerop (gnus-summary-next-subject nummove unread t)))
9455 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9456 (gnus-summary-recenter)
9457 (gnus-summary-position-point)
9458 (gnus-set-mode-line 'summary)
9461 (gnus-summary-make-all-marking-commands)
9467 (run-hooks 'gnus-sum-load-hook)
9469 ;;; gnus-sum.el ends here