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 (defcustom gnus-group-highlight-words-alist nil
841 "Alist of group regexps and highlight regexps.
842 This variable uses the same syntax as `gnus-emphasis-alist'."
843 :type '(repeat (cons (regexp :tag "Group")
844 (repeat (list (regexp :tag "Highlight regexp")
845 (number :tag "Group for entire word" 0)
846 (number :tag "Group for displayed part" 0)
848 gnus-emphasis-highlight-words)))))
849 :group 'gnus-summary-visual)
851 ;;; Internal variables
853 (defvar gnus-scores-exclude-files nil)
854 (defvar gnus-page-broken nil)
855 (defvar gnus-inhibit-mime-unbuttonizing nil)
857 (defvar gnus-original-article nil)
858 (defvar gnus-article-internal-prepare-hook nil)
859 (defvar gnus-newsgroup-process-stack nil)
861 (defvar gnus-thread-indent-array nil)
862 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
864 ;; Avoid highlighting in kill files.
865 (defvar gnus-summary-inhibit-highlight nil)
866 (defvar gnus-newsgroup-selected-overlay nil)
867 (defvar gnus-inhibit-limiting nil)
868 (defvar gnus-newsgroup-adaptive-score-file nil)
869 (defvar gnus-current-score-file nil)
870 (defvar gnus-current-move-group nil)
871 (defvar gnus-current-copy-group nil)
872 (defvar gnus-current-crosspost-group nil)
874 (defvar gnus-newsgroup-dependencies nil)
875 (defvar gnus-newsgroup-adaptive nil)
876 (defvar gnus-summary-display-article-function nil)
877 (defvar gnus-summary-highlight-line-function nil
878 "Function called after highlighting a summary line.")
880 (defvar gnus-summary-line-format-alist
881 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
882 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
883 (?s gnus-tmp-subject-or-nil ?s)
884 (?n gnus-tmp-name ?s)
885 (?A (std11-address-string
886 (car (mime-read-field 'From gnus-tmp-header))) ?s)
887 (?a (or (std11-full-name-string
888 (car (mime-read-field 'From gnus-tmp-header)))
890 (?F gnus-tmp-from ?s)
891 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
892 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
893 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
894 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
895 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
896 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
897 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
898 (?L gnus-tmp-lines ?d)
899 (?I gnus-tmp-indentation ?s)
900 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
901 (?R gnus-tmp-replied ?c)
902 (?\[ gnus-tmp-opening-bracket ?c)
903 (?\] gnus-tmp-closing-bracket ?c)
904 (?\> (make-string gnus-tmp-level ? ) ?s)
905 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
906 (?i gnus-tmp-score ?d)
907 (?z gnus-tmp-score-char ?c)
908 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
909 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
910 (?U gnus-tmp-unread ?c)
911 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header) ?s)
912 (?t (gnus-summary-number-of-articles-in-thread
913 (and (boundp 'thread) (car thread)) gnus-tmp-level)
915 (?e (gnus-summary-number-of-articles-in-thread
916 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
918 (?u gnus-tmp-user-defined ?s)
919 (?P (gnus-pick-line-number) ?d))
920 "An alist of format specifications that can appear in summary lines,
921 and what variables they correspond with, along with the type of the
922 variable (string, integer, character, etc).")
924 (defvar gnus-summary-dummy-line-format-alist
925 `((?S gnus-tmp-subject ?s)
926 (?N gnus-tmp-number ?d)
927 (?u gnus-tmp-user-defined ?s)))
929 (defvar gnus-summary-mode-line-format-alist
930 `((?G gnus-tmp-group-name ?s)
931 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
932 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
933 (?A gnus-tmp-article-number ?d)
934 (?Z gnus-tmp-unread-and-unselected ?s)
936 (?U gnus-tmp-unread-and-unticked ?d)
937 (?S gnus-tmp-subject ?s)
938 (?e gnus-tmp-unselected ?d)
939 (?u gnus-tmp-user-defined ?s)
940 (?d (length gnus-newsgroup-dormant) ?d)
941 (?t (length gnus-newsgroup-marked) ?d)
942 (?r (length gnus-newsgroup-reads) ?d)
943 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
944 (?E gnus-newsgroup-expunged-tally ?d)
945 (?s (gnus-current-score-file-nondirectory) ?s)))
947 (defvar gnus-last-search-regexp nil
948 "Default regexp for article search command.")
950 (defvar gnus-last-shell-command nil
951 "Default shell command on article.")
953 (defvar gnus-newsgroup-begin nil)
954 (defvar gnus-newsgroup-end nil)
955 (defvar gnus-newsgroup-last-rmail nil)
956 (defvar gnus-newsgroup-last-mail nil)
957 (defvar gnus-newsgroup-last-folder nil)
958 (defvar gnus-newsgroup-last-file nil)
959 (defvar gnus-newsgroup-auto-expire nil)
960 (defvar gnus-newsgroup-active nil)
962 (defvar gnus-newsgroup-data nil)
963 (defvar gnus-newsgroup-data-reverse nil)
964 (defvar gnus-newsgroup-limit nil)
965 (defvar gnus-newsgroup-limits nil)
967 (defvar gnus-newsgroup-unreads nil
968 "List of unread articles in the current newsgroup.")
970 (defvar gnus-newsgroup-unselected nil
971 "List of unselected unread articles in the current newsgroup.")
973 (defvar gnus-newsgroup-reads nil
974 "Alist of read articles and article marks in the current newsgroup.")
976 (defvar gnus-newsgroup-expunged-tally nil)
978 (defvar gnus-newsgroup-marked nil
979 "List of ticked articles in the current newsgroup (a subset of unread art).")
981 (defvar gnus-newsgroup-killed nil
982 "List of ranges of articles that have been through the scoring process.")
984 (defvar gnus-newsgroup-cached nil
985 "List of articles that come from the article cache.")
987 (defvar gnus-newsgroup-saved nil
988 "List of articles that have been saved.")
990 (defvar gnus-newsgroup-kill-headers nil)
992 (defvar gnus-newsgroup-replied nil
993 "List of articles that have been replied to in the current newsgroup.")
995 (defvar gnus-newsgroup-expirable nil
996 "List of articles in the current newsgroup that can be expired.")
998 (defvar gnus-newsgroup-processable nil
999 "List of articles in the current newsgroup that can be processed.")
1001 (defvar gnus-newsgroup-downloadable nil
1002 "List of articles in the current newsgroup that can be processed.")
1004 (defvar gnus-newsgroup-undownloaded nil
1005 "List of articles in the current newsgroup that haven't been downloaded..")
1007 (defvar gnus-newsgroup-unsendable nil
1008 "List of articles in the current newsgroup that won't be sent.")
1010 (defvar gnus-newsgroup-bookmarks nil
1011 "List of articles in the current newsgroup that have bookmarks.")
1013 (defvar gnus-newsgroup-dormant nil
1014 "List of dormant articles in the current newsgroup.")
1016 (defvar gnus-newsgroup-scored nil
1017 "List of scored articles in the current newsgroup.")
1019 (defvar gnus-newsgroup-headers nil
1020 "List of article headers in the current newsgroup.")
1022 (defvar gnus-newsgroup-threads nil)
1024 (defvar gnus-newsgroup-prepared nil
1025 "Whether the current group has been prepared properly.")
1027 (defvar gnus-newsgroup-ancient nil
1028 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1030 (defvar gnus-newsgroup-sparse nil)
1032 (defvar gnus-current-article nil)
1033 (defvar gnus-article-current nil)
1034 (defvar gnus-current-headers nil)
1035 (defvar gnus-have-all-headers nil)
1036 (defvar gnus-last-article nil)
1037 (defvar gnus-newsgroup-history nil)
1038 (defvar gnus-newsgroup-charset nil)
1040 (defconst gnus-summary-local-variables
1041 '(gnus-newsgroup-name
1042 gnus-newsgroup-begin gnus-newsgroup-end
1043 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1044 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1045 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1046 gnus-newsgroup-unselected gnus-newsgroup-marked
1047 gnus-newsgroup-reads gnus-newsgroup-saved
1048 gnus-newsgroup-replied gnus-newsgroup-expirable
1049 gnus-newsgroup-processable gnus-newsgroup-killed
1050 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1051 gnus-newsgroup-unsendable
1052 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1053 gnus-newsgroup-headers gnus-newsgroup-threads
1054 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1055 gnus-current-article gnus-current-headers gnus-have-all-headers
1056 gnus-last-article gnus-article-internal-prepare-hook
1057 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1058 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1059 gnus-thread-expunge-below
1060 gnus-score-alist gnus-current-score-file
1061 (gnus-summary-expunge-below . global)
1062 (gnus-summary-mark-below . global)
1063 gnus-newsgroup-active gnus-scores-exclude-files
1064 gnus-newsgroup-history gnus-newsgroup-ancient
1065 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1066 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1067 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1068 (gnus-newsgroup-expunged-tally . 0)
1069 gnus-cache-removable-articles gnus-newsgroup-cached
1070 gnus-newsgroup-data gnus-newsgroup-data-reverse
1071 gnus-newsgroup-limit gnus-newsgroup-limits
1072 gnus-newsgroup-charset)
1073 "Variables that are buffer-local to the summary buffers.")
1075 ;; Byte-compiler warning.
1076 (defvar gnus-article-mode-map)
1078 ;; Subject simplification.
1080 (defun gnus-simplify-whitespace (str)
1081 "Remove excessive whitespace."
1084 (while (string-match "[ \t][ \t]+" mystr)
1085 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1087 (substring mystr (match-end 0)))))
1089 (when (string-match "^[ \t]+" mystr)
1090 (setq mystr (substring mystr (match-end 0))))
1092 (when (string-match "[ \t]+$" mystr)
1093 (setq mystr (substring mystr 0 (match-beginning 0))))
1096 (defsubst gnus-simplify-subject-re (subject)
1097 "Remove \"Re:\" from subject lines."
1098 (if (string-match "^[Rr][Ee]: *" subject)
1099 (substring subject (match-end 0))
1102 (defun gnus-simplify-subject (subject &optional re-only)
1103 "Remove `Re:' and words in parentheses.
1104 If RE-ONLY is non-nil, strip leading `Re:'s only."
1105 (let ((case-fold-search t)) ;Ignore case.
1106 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1107 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1108 (setq subject (substring subject (match-end 0))))
1109 ;; Remove uninteresting prefixes.
1110 (when (and (not re-only)
1111 gnus-simplify-ignored-prefixes
1112 (string-match gnus-simplify-ignored-prefixes subject))
1113 (setq subject (substring subject (match-end 0))))
1114 ;; Remove words in parentheses from end.
1116 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1117 (setq subject (substring subject 0 (match-beginning 0)))))
1118 ;; Return subject string.
1121 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1123 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1124 (goto-char (point-min))
1125 (while (re-search-forward regexp nil t)
1126 (replace-match (or newtext ""))))
1128 (defun gnus-simplify-buffer-fuzzy ()
1129 "Simplify string in the buffer fuzzily.
1130 The string in the accessible portion of the current buffer is simplified.
1131 It is assumed to be a single-line subject.
1132 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1133 matter is removed. Additional things can be deleted by setting
1134 gnus-simplify-subject-fuzzy-regexp."
1135 (let ((case-fold-search t)
1137 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1139 (while (not (eq modified-tick (buffer-modified-tick)))
1140 (setq modified-tick (buffer-modified-tick))
1142 ((listp gnus-simplify-subject-fuzzy-regexp)
1143 (mapcar 'gnus-simplify-buffer-fuzzy-step
1144 gnus-simplify-subject-fuzzy-regexp))
1145 (gnus-simplify-subject-fuzzy-regexp
1146 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1147 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1148 (gnus-simplify-buffer-fuzzy-step
1149 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1150 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1152 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1153 (gnus-simplify-buffer-fuzzy-step " +" " ")
1154 (gnus-simplify-buffer-fuzzy-step " $")
1155 (gnus-simplify-buffer-fuzzy-step "^ +")))
1157 (defun gnus-simplify-subject-fuzzy (subject)
1158 "Simplify a subject string fuzzily.
1159 See `gnus-simplify-buffer-fuzzy' for details."
1161 (gnus-set-work-buffer)
1162 (let ((case-fold-search t))
1163 ;; Remove uninteresting prefixes.
1164 (when (and gnus-simplify-ignored-prefixes
1165 (string-match gnus-simplify-ignored-prefixes subject))
1166 (setq subject (substring subject (match-end 0))))
1168 (inline (gnus-simplify-buffer-fuzzy))
1171 (defsubst gnus-simplify-subject-fully (subject)
1172 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1174 (gnus-simplify-subject-functions
1175 (gnus-map-function gnus-simplify-subject-functions subject))
1176 ((null gnus-summary-gather-subject-limit)
1177 (gnus-simplify-subject-re subject))
1178 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1179 (gnus-simplify-subject-fuzzy subject))
1180 ((numberp gnus-summary-gather-subject-limit)
1181 (gnus-limit-string (gnus-simplify-subject-re subject)
1182 gnus-summary-gather-subject-limit))
1186 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1187 "Check whether two subjects are equal.
1188 If optional argument simple-first is t, first argument is already
1191 ((null simple-first)
1192 (equal (gnus-simplify-subject-fully s1)
1193 (gnus-simplify-subject-fully s2)))
1196 (gnus-simplify-subject-fully s2)))))
1198 (defun gnus-summary-bubble-group ()
1199 "Increase the score of the current group.
1200 This is a handy function to add to `gnus-summary-exit-hook' to
1201 increase the score of each group you read."
1202 (gnus-group-add-score gnus-newsgroup-name))
1206 ;;; Gnus summary mode
1209 (put 'gnus-summary-mode 'mode-class 'special)
1212 ;; Non-orthogonal keys
1214 (gnus-define-keys gnus-summary-mode-map
1215 " " gnus-summary-next-page
1216 "\177" gnus-summary-prev-page
1217 [delete] gnus-summary-prev-page
1218 [backspace] gnus-summary-prev-page
1219 "\r" gnus-summary-scroll-up
1220 "\M-\r" gnus-summary-scroll-down
1221 "n" gnus-summary-next-unread-article
1222 "p" gnus-summary-prev-unread-article
1223 "N" gnus-summary-next-article
1224 "P" gnus-summary-prev-article
1225 "\M-\C-n" gnus-summary-next-same-subject
1226 "\M-\C-p" gnus-summary-prev-same-subject
1227 "\M-n" gnus-summary-next-unread-subject
1228 "\M-p" gnus-summary-prev-unread-subject
1229 "." gnus-summary-first-unread-article
1230 "," gnus-summary-best-unread-article
1231 "\M-s" gnus-summary-search-article-forward
1232 "\M-r" gnus-summary-search-article-backward
1233 "<" gnus-summary-beginning-of-article
1234 ">" gnus-summary-end-of-article
1235 "j" gnus-summary-goto-article
1236 "^" gnus-summary-refer-parent-article
1237 "\M-^" gnus-summary-refer-article
1238 "u" gnus-summary-tick-article-forward
1239 "!" gnus-summary-tick-article-forward
1240 "U" gnus-summary-tick-article-backward
1241 "d" gnus-summary-mark-as-read-forward
1242 "D" gnus-summary-mark-as-read-backward
1243 "E" gnus-summary-mark-as-expirable
1244 "\M-u" gnus-summary-clear-mark-forward
1245 "\M-U" gnus-summary-clear-mark-backward
1246 "k" gnus-summary-kill-same-subject-and-select
1247 "\C-k" gnus-summary-kill-same-subject
1248 "\M-\C-k" gnus-summary-kill-thread
1249 "\M-\C-l" gnus-summary-lower-thread
1250 "e" gnus-summary-edit-article
1251 "#" gnus-summary-mark-as-processable
1252 "\M-#" gnus-summary-unmark-as-processable
1253 "\M-\C-t" gnus-summary-toggle-threads
1254 "\M-\C-s" gnus-summary-show-thread
1255 "\M-\C-h" gnus-summary-hide-thread
1256 "\M-\C-f" gnus-summary-next-thread
1257 "\M-\C-b" gnus-summary-prev-thread
1258 "\M-\C-u" gnus-summary-up-thread
1259 "\M-\C-d" gnus-summary-down-thread
1260 "&" gnus-summary-execute-command
1261 "c" gnus-summary-catchup-and-exit
1262 "\C-w" gnus-summary-mark-region-as-read
1263 "\C-t" gnus-summary-toggle-truncation
1264 "?" gnus-summary-mark-as-dormant
1265 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1266 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1267 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1268 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1269 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1270 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1271 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1272 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1273 "=" gnus-summary-expand-window
1274 "\C-x\C-s" gnus-summary-reselect-current-group
1275 "\M-g" gnus-summary-rescan-group
1276 "w" gnus-summary-stop-page-breaking
1277 "\C-c\C-r" gnus-summary-caesar-message
1278 "\M-t" gnus-summary-toggle-mime
1279 "f" gnus-summary-followup
1280 "F" gnus-summary-followup-with-original
1281 "C" gnus-summary-cancel-article
1282 "r" gnus-summary-reply
1283 "R" gnus-summary-reply-with-original
1284 "\C-c\C-f" gnus-summary-mail-forward
1285 "o" gnus-summary-save-article
1286 "\C-o" gnus-summary-save-article-mail
1287 "|" gnus-summary-pipe-output
1288 "\M-k" gnus-summary-edit-local-kill
1289 "\M-K" gnus-summary-edit-global-kill
1291 "\C-c\C-d" gnus-summary-describe-group
1292 "q" gnus-summary-exit
1293 "Q" gnus-summary-exit-no-update
1294 "\C-c\C-i" gnus-info-find-node
1295 gnus-mouse-2 gnus-mouse-pick-article
1296 "m" gnus-summary-mail-other-window
1297 "a" gnus-summary-post-news
1298 "x" gnus-summary-limit-to-unread
1299 "s" gnus-summary-isearch-article
1300 "t" gnus-article-toggle-headers
1301 "g" gnus-summary-show-article
1302 "l" gnus-summary-goto-last-article
1303 "v" gnus-summary-preview-mime-message
1304 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1305 "\C-d" gnus-summary-enter-digest-group
1306 "\M-\C-d" gnus-summary-read-document
1307 "\M-\C-e" gnus-summary-edit-parameters
1308 "\M-\C-g" gnus-summary-customize-parameters
1310 "*" gnus-cache-enter-article
1311 "\M-*" gnus-cache-remove-article
1312 "\M-&" gnus-summary-universal-argument
1313 "\C-l" gnus-recenter
1314 "I" gnus-summary-increase-score
1315 "L" gnus-summary-lower-score
1316 "\M-i" gnus-symbolic-argument
1317 "h" gnus-summary-select-article-buffer
1319 "V" gnus-summary-score-map
1320 "X" gnus-uu-extract-map
1321 "S" gnus-summary-send-map)
1323 ;; Sort of orthogonal keymap
1324 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1325 "t" gnus-summary-tick-article-forward
1326 "!" gnus-summary-tick-article-forward
1327 "d" gnus-summary-mark-as-read-forward
1328 "r" gnus-summary-mark-as-read-forward
1329 "c" gnus-summary-clear-mark-forward
1330 " " gnus-summary-clear-mark-forward
1331 "e" gnus-summary-mark-as-expirable
1332 "x" gnus-summary-mark-as-expirable
1333 "?" gnus-summary-mark-as-dormant
1334 "b" gnus-summary-set-bookmark
1335 "B" gnus-summary-remove-bookmark
1336 "#" gnus-summary-mark-as-processable
1337 "\M-#" gnus-summary-unmark-as-processable
1338 "S" gnus-summary-limit-include-expunged
1339 "C" gnus-summary-catchup
1340 "H" gnus-summary-catchup-to-here
1341 "\C-c" gnus-summary-catchup-all
1342 "k" gnus-summary-kill-same-subject-and-select
1343 "K" gnus-summary-kill-same-subject
1344 "P" gnus-uu-mark-map)
1346 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1347 "c" gnus-summary-clear-above
1348 "u" gnus-summary-tick-above
1349 "m" gnus-summary-mark-above
1350 "k" gnus-summary-kill-below)
1352 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1353 "/" gnus-summary-limit-to-subject
1354 "n" gnus-summary-limit-to-articles
1355 "w" gnus-summary-pop-limit
1356 "s" gnus-summary-limit-to-subject
1357 "a" gnus-summary-limit-to-author
1358 "u" gnus-summary-limit-to-unread
1359 "m" gnus-summary-limit-to-marks
1360 "M" gnus-summary-limit-exclude-marks
1361 "v" gnus-summary-limit-to-score
1362 "*" gnus-summary-limit-include-cached
1363 "D" gnus-summary-limit-include-dormant
1364 "T" gnus-summary-limit-include-thread
1365 "d" gnus-summary-limit-exclude-dormant
1366 "t" gnus-summary-limit-to-age
1367 "x" gnus-summary-limit-to-extra
1368 "E" gnus-summary-limit-include-expunged
1369 "c" gnus-summary-limit-exclude-childless-dormant
1370 "C" gnus-summary-limit-mark-excluded-as-read)
1372 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1373 "n" gnus-summary-next-unread-article
1374 "p" gnus-summary-prev-unread-article
1375 "N" gnus-summary-next-article
1376 "P" gnus-summary-prev-article
1377 "\C-n" gnus-summary-next-same-subject
1378 "\C-p" gnus-summary-prev-same-subject
1379 "\M-n" gnus-summary-next-unread-subject
1380 "\M-p" gnus-summary-prev-unread-subject
1381 "f" gnus-summary-first-unread-article
1382 "b" gnus-summary-best-unread-article
1383 "j" gnus-summary-goto-article
1384 "g" gnus-summary-goto-subject
1385 "l" gnus-summary-goto-last-article
1386 "o" gnus-summary-pop-article)
1388 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1389 "k" gnus-summary-kill-thread
1390 "l" gnus-summary-lower-thread
1391 "i" gnus-summary-raise-thread
1392 "T" gnus-summary-toggle-threads
1393 "t" gnus-summary-rethread-current
1394 "^" gnus-summary-reparent-thread
1395 "s" gnus-summary-show-thread
1396 "S" gnus-summary-show-all-threads
1397 "h" gnus-summary-hide-thread
1398 "H" gnus-summary-hide-all-threads
1399 "n" gnus-summary-next-thread
1400 "p" gnus-summary-prev-thread
1401 "u" gnus-summary-up-thread
1402 "o" gnus-summary-top-thread
1403 "d" gnus-summary-down-thread
1404 "#" gnus-uu-mark-thread
1405 "\M-#" gnus-uu-unmark-thread)
1407 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1408 "g" gnus-summary-prepare
1409 "c" gnus-summary-insert-cached-articles)
1411 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1412 "c" gnus-summary-catchup-and-exit
1413 "C" gnus-summary-catchup-all-and-exit
1414 "E" gnus-summary-exit-no-update
1415 "Q" gnus-summary-exit
1416 "Z" gnus-summary-exit
1417 "n" gnus-summary-catchup-and-goto-next-group
1418 "R" gnus-summary-reselect-current-group
1419 "G" gnus-summary-rescan-group
1420 "N" gnus-summary-next-group
1421 "s" gnus-summary-save-newsrc
1422 "P" gnus-summary-prev-group)
1424 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1425 " " gnus-summary-next-page
1426 "n" gnus-summary-next-page
1427 "\177" gnus-summary-prev-page
1428 [delete] gnus-summary-prev-page
1429 "p" gnus-summary-prev-page
1430 "\r" gnus-summary-scroll-up
1431 "\M-\r" gnus-summary-scroll-down
1432 "<" gnus-summary-beginning-of-article
1433 ">" gnus-summary-end-of-article
1434 "b" gnus-summary-beginning-of-article
1435 "e" gnus-summary-end-of-article
1436 "^" gnus-summary-refer-parent-article
1437 "r" gnus-summary-refer-parent-article
1438 "D" gnus-summary-enter-digest-group
1439 "R" gnus-summary-refer-references
1440 "T" gnus-summary-refer-thread
1441 "g" gnus-summary-show-article
1442 "s" gnus-summary-isearch-article
1443 "P" gnus-summary-print-article
1444 "t" gnus-article-babel)
1446 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1447 "b" gnus-article-add-buttons
1448 "B" gnus-article-add-buttons-to-head
1449 "o" gnus-article-treat-overstrike
1450 "e" gnus-article-emphasize
1451 "w" gnus-article-fill-cited-article
1452 "Q" gnus-article-fill-long-lines
1453 "C" gnus-article-capitalize-sentences
1454 "c" gnus-article-remove-cr
1455 "f" gnus-article-display-x-face
1456 "l" gnus-summary-stop-page-breaking
1457 "r" gnus-summary-caesar-message
1458 "t" gnus-article-toggle-headers
1459 "v" gnus-summary-verbose-headers
1460 "m" gnus-summary-toggle-mime
1461 "h" gnus-article-treat-html
1462 "H" gnus-article-strip-headers-in-body
1463 "d" gnus-article-treat-dumbquotes)
1465 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1466 "a" gnus-article-hide
1467 "h" gnus-article-toggle-headers
1468 "b" gnus-article-hide-boring-headers
1469 "s" gnus-article-hide-signature
1470 "c" gnus-article-hide-citation
1471 "C" gnus-article-hide-citation-in-followups
1472 "p" gnus-article-hide-pgp
1473 "B" gnus-article-strip-banner
1474 "P" gnus-article-hide-pem
1475 "\C-c" gnus-article-hide-citation-maybe)
1477 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1478 "a" gnus-article-highlight
1479 "h" gnus-article-highlight-headers
1480 "c" gnus-article-highlight-citation
1481 "s" gnus-article-highlight-signature)
1483 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1484 "z" gnus-article-date-ut
1485 "u" gnus-article-date-ut
1486 "l" gnus-article-date-local
1487 "e" gnus-article-date-lapsed
1488 "o" gnus-article-date-original
1489 "i" gnus-article-date-iso8601
1490 "s" gnus-article-date-user)
1492 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1493 "t" gnus-article-remove-trailing-blank-lines
1494 "l" gnus-article-strip-leading-blank-lines
1495 "m" gnus-article-strip-multiple-blank-lines
1496 "a" gnus-article-strip-blank-lines
1497 "A" gnus-article-strip-all-blank-lines
1498 "s" gnus-article-strip-leading-space
1499 "e" gnus-article-strip-trailing-space)
1501 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1503 "f" gnus-summary-fetch-faq
1504 "d" gnus-summary-describe-group
1505 "h" gnus-summary-describe-briefly
1506 "i" gnus-info-find-node)
1508 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1509 "e" gnus-summary-expire-articles
1510 "\M-\C-e" gnus-summary-expire-articles-now
1511 "\177" gnus-summary-delete-article
1512 [delete] gnus-summary-delete-article
1513 "m" gnus-summary-move-article
1514 "r" gnus-summary-respool-article
1515 "w" gnus-summary-edit-article
1516 "c" gnus-summary-copy-article
1517 "B" gnus-summary-crosspost-article
1518 "q" gnus-summary-respool-query
1519 "t" gnus-summary-respool-trace
1520 "i" gnus-summary-import-article
1521 "p" gnus-summary-article-posted-p)
1523 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1524 "o" gnus-summary-save-article
1525 "m" gnus-summary-save-article-mail
1526 "F" gnus-summary-write-article-file
1527 "r" gnus-summary-save-article-rmail
1528 "f" gnus-summary-save-article-file
1529 "b" gnus-summary-save-article-body-file
1530 "h" gnus-summary-save-article-folder
1531 "v" gnus-summary-save-article-vm
1532 "p" gnus-summary-pipe-output
1533 "s" gnus-soup-add-article)
1535 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1536 "b" gnus-summary-display-buttonized
1537 "m" gnus-summary-repair-multipart
1538 "v" gnus-article-view-part
1539 "o" gnus-article-save-part
1540 "c" gnus-article-copy-part
1541 "e" gnus-article-externalize-part
1542 "i" gnus-article-inline-part
1543 "|" gnus-article-pipe-part)
1546 (defun gnus-summary-make-menu-bar ()
1547 (gnus-turn-off-edit-menu 'summary)
1549 (unless (boundp 'gnus-summary-misc-menu)
1552 gnus-summary-kill-menu gnus-summary-mode-map ""
1557 ["Enter score..." gnus-summary-score-entry t]
1558 ["Customize" gnus-score-customize t])
1559 (gnus-make-score-map 'increase)
1560 (gnus-make-score-map 'lower)
1562 ["Kill below" gnus-summary-kill-below t]
1563 ["Mark above" gnus-summary-mark-above t]
1564 ["Tick above" gnus-summary-tick-above t]
1565 ["Clear above" gnus-summary-clear-above t])
1566 ["Current score" gnus-summary-current-score t]
1567 ["Set score" gnus-summary-set-score t]
1568 ["Switch current score file..." gnus-score-change-score-file t]
1569 ["Set mark below..." gnus-score-set-mark-below t]
1570 ["Set expunge below..." gnus-score-set-expunge-below t]
1571 ["Edit current score file" gnus-score-edit-current-scores t]
1572 ["Edit score file" gnus-score-edit-file t]
1573 ["Trace score" gnus-score-find-trace t]
1574 ["Find words" gnus-score-find-favourite-words t]
1575 ["Rescore buffer" gnus-summary-rescore t]
1576 ["Increase score..." gnus-summary-increase-score t]
1577 ["Lower score..." gnus-summary-lower-score t]))))
1579 ;; Define both the Article menu in the summary buffer and the equivalent
1580 ;; Commands menu in the article buffer here for consistency.
1583 ["All" gnus-article-hide t]
1584 ["Headers" gnus-article-toggle-headers t]
1585 ["Signature" gnus-article-hide-signature t]
1586 ["Citation" gnus-article-hide-citation t]
1587 ["PGP" gnus-article-hide-pgp t]
1588 ["Banner" gnus-article-strip-banner t]
1589 ["Boring headers" gnus-article-hide-boring-headers t])
1591 ["All" gnus-article-highlight t]
1592 ["Headers" gnus-article-highlight-headers t]
1593 ["Signature" gnus-article-highlight-signature t]
1594 ["Citation" gnus-article-highlight-citation t])
1596 ["Local" gnus-article-date-local t]
1597 ["ISO8601" gnus-article-date-iso8601 t]
1598 ["UT" gnus-article-date-ut t]
1599 ["Original" gnus-article-date-original t]
1600 ["Lapsed" gnus-article-date-lapsed t]
1601 ["User-defined" gnus-article-date-user t])
1604 ["Leading" gnus-article-strip-leading-blank-lines t]
1605 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1606 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1607 ["All of the above" gnus-article-strip-blank-lines t]
1608 ["All" gnus-article-strip-all-blank-lines t]
1609 ["Leading space" gnus-article-strip-leading-space t]
1610 ["Trailing space" gnus-article-strip-trailing-space t])
1611 ["Overstrike" gnus-article-treat-overstrike t]
1612 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1613 ["Emphasis" gnus-article-emphasize t]
1614 ["Word wrap" gnus-article-fill-cited-article t]
1615 ["Fill long lines" gnus-article-fill-long-lines t]
1616 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1617 ["CR" gnus-article-remove-cr t]
1618 ["Show X-Face" gnus-article-display-x-face t]
1619 ["UnHTMLize" gnus-article-treat-html t]
1620 ["Rot 13" gnus-summary-caesar-message t]
1621 ["Unix pipe" gnus-summary-pipe-message t]
1622 ["Add buttons" gnus-article-add-buttons t]
1623 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1624 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1625 ["Toggle MIME" gnus-summary-toggle-mime t]
1626 ["Verbose header" gnus-summary-verbose-headers t]
1627 ["Toggle header" gnus-summary-toggle-header t])
1629 ["Save in default format" gnus-summary-save-article t]
1630 ["Save in file" gnus-summary-save-article-file t]
1631 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1632 ["Save in MH folder" gnus-summary-save-article-folder t]
1633 ["Save in VM folder" gnus-summary-save-article-vm t]
1634 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1635 ["Save body in file" gnus-summary-save-article-body-file t]
1636 ["Pipe through a filter" gnus-summary-pipe-output t]
1637 ["Add to SOUP packet" gnus-soup-add-article t]
1638 ["Print" gnus-summary-print-article t])
1640 ["Respool article..." gnus-summary-respool-article t]
1641 ["Move article..." gnus-summary-move-article
1642 (gnus-check-backend-function
1643 'request-move-article gnus-newsgroup-name)]
1644 ["Copy article..." gnus-summary-copy-article t]
1645 ["Crosspost article..." gnus-summary-crosspost-article
1646 (gnus-check-backend-function
1647 'request-replace-article gnus-newsgroup-name)]
1648 ["Import file..." gnus-summary-import-article t]
1649 ["Check if posted" gnus-summary-article-posted-p t]
1650 ["Edit article" gnus-summary-edit-article
1651 (not (gnus-group-read-only-p))]
1652 ["Delete article" gnus-summary-delete-article
1653 (gnus-check-backend-function
1654 'request-expire-articles gnus-newsgroup-name)]
1655 ["Query respool" gnus-summary-respool-query t]
1656 ["Trace respool" gnus-summary-respool-trace t]
1657 ["Delete expirable articles" gnus-summary-expire-articles-now
1658 (gnus-check-backend-function
1659 'request-expire-articles gnus-newsgroup-name)])
1661 ["Uudecode" gnus-uu-decode-uu t]
1662 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1663 ["Unshar" gnus-uu-decode-unshar t]
1664 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1665 ["Save" gnus-uu-decode-save t]
1666 ["Binhex" gnus-uu-decode-binhex t]
1667 ["Postscript" gnus-uu-decode-postscript t])
1669 ["Enter article" gnus-cache-enter-article t]
1670 ["Remove article" gnus-cache-remove-article t])
1671 ["Translate" gnus-article-babel t]
1672 ["Select article buffer" gnus-summary-select-article-buffer t]
1673 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1674 ["Isearch article..." gnus-summary-isearch-article t]
1675 ["Beginning of the article" gnus-summary-beginning-of-article t]
1676 ["End of the article" gnus-summary-end-of-article t]
1677 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1678 ["Fetch referenced articles" gnus-summary-refer-references t]
1679 ["Fetch current thread" gnus-summary-refer-thread t]
1680 ["Fetch article with id..." gnus-summary-refer-article t]
1681 ["Redisplay" gnus-summary-show-article t])))
1683 gnus-summary-article-menu gnus-summary-mode-map ""
1684 (cons "Article" innards))
1687 gnus-article-commands-menu gnus-article-mode-map ""
1688 (cons "Commands" innards)))
1691 gnus-summary-thread-menu gnus-summary-mode-map ""
1693 ["Toggle threading" gnus-summary-toggle-threads t]
1694 ["Hide threads" gnus-summary-hide-all-threads t]
1695 ["Show threads" gnus-summary-show-all-threads t]
1696 ["Hide thread" gnus-summary-hide-thread t]
1697 ["Show thread" gnus-summary-show-thread t]
1698 ["Go to next thread" gnus-summary-next-thread t]
1699 ["Go to previous thread" gnus-summary-prev-thread t]
1700 ["Go down thread" gnus-summary-down-thread t]
1701 ["Go up thread" gnus-summary-up-thread t]
1702 ["Top of thread" gnus-summary-top-thread t]
1703 ["Mark thread as read" gnus-summary-kill-thread t]
1704 ["Lower thread score" gnus-summary-lower-thread t]
1705 ["Raise thread score" gnus-summary-raise-thread t]
1706 ["Rethread current" gnus-summary-rethread-current t]
1710 gnus-summary-post-menu gnus-summary-mode-map ""
1712 ["Post an article" gnus-summary-post-news t]
1713 ["Followup" gnus-summary-followup t]
1714 ["Followup and yank" gnus-summary-followup-with-original t]
1715 ["Supersede article" gnus-summary-supersede-article t]
1716 ["Cancel article" gnus-summary-cancel-article t]
1717 ["Reply" gnus-summary-reply t]
1718 ["Reply and yank" gnus-summary-reply-with-original t]
1719 ["Wide reply" gnus-summary-wide-reply t]
1720 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1721 ["Mail forward" gnus-summary-mail-forward t]
1722 ["Post forward" gnus-summary-post-forward t]
1723 ["Digest and mail" gnus-summary-mail-digest t]
1724 ["Digest and post" gnus-summary-post-digest t]
1725 ["Resend message" gnus-summary-resend-message t]
1726 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1727 ["Send a mail" gnus-summary-mail-other-window t]
1728 ["Uuencode and post" gnus-uu-post-news t]
1729 ["Followup via news" gnus-summary-followup-to-mail t]
1730 ["Followup via news and yank"
1731 gnus-summary-followup-to-mail-with-original t]
1733 ;;["Send" gnus-summary-send-draft t]
1734 ;;["Send bounced" gnus-resend-bounced-mail t])
1738 gnus-summary-misc-menu gnus-summary-mode-map ""
1741 ["Mark as read" gnus-summary-mark-as-read-forward t]
1742 ["Mark same subject and select"
1743 gnus-summary-kill-same-subject-and-select t]
1744 ["Mark same subject" gnus-summary-kill-same-subject t]
1745 ["Catchup" gnus-summary-catchup t]
1746 ["Catchup all" gnus-summary-catchup-all t]
1747 ["Catchup to here" gnus-summary-catchup-to-here t]
1748 ["Catchup region" gnus-summary-mark-region-as-read t]
1749 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1751 ["Tick" gnus-summary-tick-article-forward t]
1752 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1753 ["Remove marks" gnus-summary-clear-mark-forward t]
1754 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1755 ["Set bookmark" gnus-summary-set-bookmark t]
1756 ["Remove bookmark" gnus-summary-remove-bookmark t])
1758 ["Marks..." gnus-summary-limit-to-marks t]
1759 ["Subject..." gnus-summary-limit-to-subject t]
1760 ["Author..." gnus-summary-limit-to-author t]
1761 ["Age..." gnus-summary-limit-to-age t]
1762 ["Extra..." gnus-summary-limit-to-extra t]
1763 ["Score" gnus-summary-limit-to-score t]
1764 ["Unread" gnus-summary-limit-to-unread t]
1765 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1766 ["Articles" gnus-summary-limit-to-articles t]
1767 ["Pop limit" gnus-summary-pop-limit t]
1768 ["Show dormant" gnus-summary-limit-include-dormant t]
1769 ["Hide childless dormant"
1770 gnus-summary-limit-exclude-childless-dormant t]
1771 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1772 ["Hide marked" gnus-summary-limit-exclude-marks t]
1773 ["Show expunged" gnus-summary-show-all-expunged t])
1775 ["Set mark" gnus-summary-mark-as-processable t]
1776 ["Remove mark" gnus-summary-unmark-as-processable t]
1777 ["Remove all marks" gnus-summary-unmark-all-processable t]
1778 ["Mark above" gnus-uu-mark-over t]
1779 ["Mark series" gnus-uu-mark-series t]
1780 ["Mark region" gnus-uu-mark-region t]
1781 ["Unmark region" gnus-uu-unmark-region t]
1782 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1783 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1784 ["Mark all" gnus-uu-mark-all t]
1785 ["Mark buffer" gnus-uu-mark-buffer t]
1786 ["Mark sparse" gnus-uu-mark-sparse t]
1787 ["Mark thread" gnus-uu-mark-thread t]
1788 ["Unmark thread" gnus-uu-unmark-thread t]
1789 ("Process Mark Sets"
1790 ["Kill" gnus-summary-kill-process-mark t]
1791 ["Yank" gnus-summary-yank-process-mark
1792 gnus-newsgroup-process-stack]
1793 ["Save" gnus-summary-save-process-mark t]))
1795 ["Page forward" gnus-summary-next-page t]
1796 ["Page backward" gnus-summary-prev-page t]
1797 ["Line forward" gnus-summary-scroll-up t])
1799 ["Next unread article" gnus-summary-next-unread-article t]
1800 ["Previous unread article" gnus-summary-prev-unread-article t]
1801 ["Next article" gnus-summary-next-article t]
1802 ["Previous article" gnus-summary-prev-article t]
1803 ["Next unread subject" gnus-summary-next-unread-subject t]
1804 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1805 ["Next article same subject" gnus-summary-next-same-subject t]
1806 ["Previous article same subject" gnus-summary-prev-same-subject t]
1807 ["First unread article" gnus-summary-first-unread-article t]
1808 ["Best unread article" gnus-summary-best-unread-article t]
1809 ["Go to subject number..." gnus-summary-goto-subject t]
1810 ["Go to article number..." gnus-summary-goto-article t]
1811 ["Go to the last article" gnus-summary-goto-last-article t]
1812 ["Pop article off history" gnus-summary-pop-article t])
1814 ["Sort by number" gnus-summary-sort-by-number t]
1815 ["Sort by author" gnus-summary-sort-by-author t]
1816 ["Sort by subject" gnus-summary-sort-by-subject t]
1817 ["Sort by date" gnus-summary-sort-by-date t]
1818 ["Sort by score" gnus-summary-sort-by-score t]
1819 ["Sort by lines" gnus-summary-sort-by-lines t]
1820 ["Sort by characters" gnus-summary-sort-by-chars t])
1822 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1823 ["Describe group" gnus-summary-describe-group t]
1824 ["Read manual" gnus-info-find-node t])
1826 ["Pick and read" gnus-pick-mode t]
1827 ["Binary" gnus-binary-mode t])
1829 ["Regenerate" gnus-summary-prepare t]
1830 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1831 ["Toggle threading" gnus-summary-toggle-threads t])
1832 ["Filter articles..." gnus-summary-execute-command t]
1833 ["Run command on subjects..." gnus-summary-universal-argument t]
1834 ["Search articles forward..." gnus-summary-search-article-forward t]
1835 ["Search articles backward..." gnus-summary-search-article-backward t]
1836 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1837 ["Expand window" gnus-summary-expand-window t]
1838 ["Expire expirable articles" gnus-summary-expire-articles
1839 (gnus-check-backend-function
1840 'request-expire-articles gnus-newsgroup-name)]
1841 ["Edit local kill file" gnus-summary-edit-local-kill t]
1842 ["Edit main kill file" gnus-summary-edit-global-kill t]
1843 ["Edit group parameters" gnus-summary-edit-parameters t]
1844 ["Customize group parameters" gnus-summary-customize-parameters t]
1845 ["Send a bug report" gnus-bug t]
1847 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1848 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
1849 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1850 ["Exit group" gnus-summary-exit t]
1851 ["Exit group without updating" gnus-summary-exit-no-update t]
1852 ["Exit and goto next group" gnus-summary-next-group t]
1853 ["Exit and goto prev group" gnus-summary-prev-group t]
1854 ["Reselect group" gnus-summary-reselect-current-group t]
1855 ["Rescan group" gnus-summary-rescan-group t]
1856 ["Update dribble" gnus-summary-save-newsrc t])))
1858 (gnus-run-hooks 'gnus-summary-menu-hook)))
1860 (defun gnus-score-set-default (var value)
1861 "A version of set that updates the GNU Emacs menu-bar."
1863 ;; It is the message that forces the active status to be updated.
1866 (defun gnus-make-score-map (type)
1867 "Make a summary score map of type TYPE."
1870 (let ((headers '(("author" "from" string)
1871 ("subject" "subject" string)
1872 ("article body" "body" string)
1873 ("article head" "head" string)
1874 ("xref" "xref" string)
1875 ("extra header" "extra" string)
1876 ("lines" "lines" number)
1877 ("followups to author" "followup" string)))
1878 (types '((number ("less than" <)
1881 (string ("substring" s)
1885 (perms '(("temporary" (current-time-string))
1893 (if (eq type 'lower)
1898 (setq header (car headers))
1904 (let ((ts (cdr (assoc (nth 2 header) types)))
1920 'gnus-summary-score-entry
1922 (if (or (string= (nth 1 header)
1924 (string= (nth 1 header)
1927 (list 'gnus-summary-header
1929 (list 'quote (nth 1 (car ts)))
1930 (list 'gnus-score-default nil)
1936 (list (nreverse outp))))
1939 (list (nreverse outt))))
1941 (setq headers (cdr headers)))
1942 (list (nreverse outh))))))))
1946 (defun gnus-summary-mode (&optional group)
1947 "Major mode for reading articles.
1949 All normal editing commands are switched off.
1950 \\<gnus-summary-mode-map>
1951 Each line in this buffer represents one article. To read an
1952 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
1953 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
1956 You can also post articles and send mail from this buffer. To
1957 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
1958 of an article, type `\\[gnus-summary-reply]'.
1960 There are approx. one gazillion commands you can execute in this
1961 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
1963 The following commands are available:
1965 \\{gnus-summary-mode-map}"
1967 (when (gnus-visual-p 'summary-menu 'menu)
1968 (gnus-summary-make-menu-bar))
1969 (kill-all-local-variables)
1970 (gnus-summary-make-local-variables)
1971 (gnus-make-thread-indent-array)
1972 (gnus-simplify-mode-line)
1973 (setq major-mode 'gnus-summary-mode)
1974 (setq mode-name "Summary")
1975 (make-local-variable 'minor-mode-alist)
1976 (use-local-map gnus-summary-mode-map)
1977 (buffer-disable-undo)
1978 (setq buffer-read-only t) ;Disable modification
1979 (setq truncate-lines t)
1980 (setq selective-display t)
1981 (setq selective-display-ellipses t) ;Display `...'
1982 (gnus-summary-set-display-table)
1983 (gnus-set-default-directory)
1984 (setq gnus-newsgroup-name group)
1985 (make-local-variable 'gnus-summary-line-format)
1986 (make-local-variable 'gnus-summary-line-format-spec)
1987 (make-local-variable 'gnus-summary-dummy-line-format)
1988 (make-local-variable 'gnus-summary-dummy-line-format-spec)
1989 (make-local-variable 'gnus-summary-mark-positions)
1990 (make-local-hook 'pre-command-hook)
1991 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
1992 (gnus-run-hooks 'gnus-summary-mode-hook)
1993 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
1994 (gnus-update-summary-mark-positions))
1996 (defun gnus-summary-make-local-variables ()
1997 "Make all the local summary buffer variables."
1999 (dolist (local gnus-summary-local-variables)
2002 (if (eq (cdr local) 'global)
2003 ;; Copy the global value of the variable.
2004 (setq global (symbol-value (car local)))
2005 ;; Use the value from the list.
2006 (setq global (eval (cdr local))))
2007 (set (make-local-variable (car local)) global))
2008 ;; Simple nil-valued local variable.
2009 (set (make-local-variable local) nil)))))
2011 (defun gnus-summary-clear-local-variables ()
2012 (let ((locals gnus-summary-local-variables))
2014 (if (consp (car locals))
2015 (and (vectorp (caar locals))
2016 (set (caar locals) nil))
2017 (and (vectorp (car locals))
2018 (set (car locals) nil)))
2019 (setq locals (cdr locals)))))
2021 ;; Summary data functions.
2023 (defmacro gnus-data-number (data)
2026 (defmacro gnus-data-set-number (data number)
2027 `(setcar ,data ,number))
2029 (defmacro gnus-data-mark (data)
2032 (defmacro gnus-data-set-mark (data mark)
2033 `(setcar (nthcdr 1 ,data) ,mark))
2035 (defmacro gnus-data-pos (data)
2038 (defmacro gnus-data-set-pos (data pos)
2039 `(setcar (nthcdr 2 ,data) ,pos))
2041 (defmacro gnus-data-header (data)
2044 (defmacro gnus-data-set-header (data header)
2045 `(setf (nth 3 ,data) ,header))
2047 (defmacro gnus-data-level (data)
2050 (defmacro gnus-data-unread-p (data)
2051 `(= (nth 1 ,data) gnus-unread-mark))
2053 (defmacro gnus-data-read-p (data)
2054 `(/= (nth 1 ,data) gnus-unread-mark))
2056 (defmacro gnus-data-pseudo-p (data)
2057 `(consp (nth 3 ,data)))
2059 (defmacro gnus-data-find (number)
2060 `(assq ,number gnus-newsgroup-data))
2062 (defmacro gnus-data-find-list (number &optional data)
2063 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2064 (memq (assq ,number bdata)
2067 (defmacro gnus-data-make (number mark pos header level)
2068 `(list ,number ,mark ,pos ,header ,level))
2070 (defun gnus-data-enter (after-article number mark pos header level offset)
2071 (let ((data (gnus-data-find-list after-article)))
2073 (error "No such article: %d" after-article))
2074 (setcdr data (cons (gnus-data-make number mark pos header level)
2076 (setq gnus-newsgroup-data-reverse nil)
2077 (gnus-data-update-list (cddr data) offset)))
2079 (defun gnus-data-enter-list (after-article list &optional offset)
2081 (let ((data (and after-article (gnus-data-find-list after-article)))
2085 (let ((odata gnus-newsgroup-data))
2086 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2088 (gnus-data-update-list odata offset)))
2089 ;; Find the last element in the list to be spliced into the main
2092 (setq list (cdr list)))
2095 (setcdr list gnus-newsgroup-data)
2096 (setq gnus-newsgroup-data ilist)
2098 (gnus-data-update-list (cdr list) offset)))
2099 (setcdr list (cdr data))
2102 (gnus-data-update-list (cdr list) offset))))
2103 (setq gnus-newsgroup-data-reverse nil))))
2105 (defun gnus-data-remove (article &optional offset)
2106 (let ((data gnus-newsgroup-data))
2107 (if (= (gnus-data-number (car data)) article)
2109 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2110 gnus-newsgroup-data-reverse nil)
2112 (gnus-data-update-list gnus-newsgroup-data offset)))
2114 (when (= (gnus-data-number (cadr data)) article)
2115 (setcdr data (cddr data))
2117 (gnus-data-update-list (cdr data) offset))
2119 gnus-newsgroup-data-reverse nil))
2120 (setq data (cdr data))))))
2122 (defmacro gnus-data-list (backward)
2124 (or gnus-newsgroup-data-reverse
2125 (setq gnus-newsgroup-data-reverse
2126 (reverse gnus-newsgroup-data)))
2127 gnus-newsgroup-data))
2129 (defun gnus-data-update-list (data offset)
2130 "Add OFFSET to the POS of all data entries in DATA."
2131 (setq gnus-newsgroup-data-reverse nil)
2133 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2134 (setq data (cdr data))))
2136 (defun gnus-summary-article-pseudo-p (article)
2137 "Say whether this article is a pseudo article or not."
2138 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2140 (defmacro gnus-summary-article-sparse-p (article)
2141 "Say whether this article is a sparse article or not."
2142 `(memq ,article gnus-newsgroup-sparse))
2144 (defmacro gnus-summary-article-ancient-p (article)
2145 "Say whether this article is a sparse article or not."
2146 `(memq ,article gnus-newsgroup-ancient))
2148 (defun gnus-article-parent-p (number)
2149 "Say whether this article is a parent or not."
2150 (let ((data (gnus-data-find-list number)))
2151 (and (cdr data) ; There has to be an article after...
2152 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2153 (gnus-data-level (nth 1 data))))))
2155 (defun gnus-article-children (number)
2156 "Return a list of all children to NUMBER."
2157 (let* ((data (gnus-data-find-list number))
2158 (level (gnus-data-level (car data)))
2160 (setq data (cdr data))
2162 (= (gnus-data-level (car data)) (1+ level)))
2163 (push (gnus-data-number (car data)) children)
2164 (setq data (cdr data)))
2167 (defmacro gnus-summary-skip-intangible ()
2168 "If the current article is intangible, then jump to a different article."
2169 '(let ((to (get-text-property (point) 'gnus-intangible)))
2170 (and to (gnus-summary-goto-subject to))))
2172 (defmacro gnus-summary-article-intangible-p ()
2173 "Say whether this article is intangible or not."
2174 '(get-text-property (point) 'gnus-intangible))
2176 (defun gnus-article-read-p (article)
2177 "Say whether ARTICLE is read or not."
2178 (not (or (memq article gnus-newsgroup-marked)
2179 (memq article gnus-newsgroup-unreads)
2180 (memq article gnus-newsgroup-unselected)
2181 (memq article gnus-newsgroup-dormant))))
2183 ;; Some summary mode macros.
2185 (defmacro gnus-summary-article-number ()
2186 "The article number of the article on the current line.
2187 If there isn's an article number here, then we return the current
2190 (gnus-summary-skip-intangible)
2191 (or (get-text-property (point) 'gnus-number)
2192 (gnus-summary-last-subject))))
2194 (defmacro gnus-summary-article-header (&optional number)
2195 "Return the header of article NUMBER."
2196 `(gnus-data-header (gnus-data-find
2197 ,(or number '(gnus-summary-article-number)))))
2199 (defmacro gnus-summary-thread-level (&optional number)
2200 "Return the level of thread that starts with article NUMBER."
2201 `(if (and (eq gnus-summary-make-false-root 'dummy)
2202 (get-text-property (point) 'gnus-intangible))
2204 (gnus-data-level (gnus-data-find
2205 ,(or number '(gnus-summary-article-number))))))
2207 (defmacro gnus-summary-article-mark (&optional number)
2208 "Return the mark of article NUMBER."
2209 `(gnus-data-mark (gnus-data-find
2210 ,(or number '(gnus-summary-article-number)))))
2212 (defmacro gnus-summary-article-pos (&optional number)
2213 "Return the position of the line of article NUMBER."
2214 `(gnus-data-pos (gnus-data-find
2215 ,(or number '(gnus-summary-article-number)))))
2217 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2218 (defmacro gnus-summary-article-subject (&optional number)
2219 "Return current subject string or nil if nothing."
2222 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2223 '(gnus-data-header (assq (gnus-summary-article-number)
2224 gnus-newsgroup-data)))))
2227 (mail-header-subject headers))))
2229 (defmacro gnus-summary-article-score (&optional number)
2230 "Return current article score."
2231 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2232 gnus-newsgroup-scored))
2233 gnus-summary-default-score 0))
2235 (defun gnus-summary-article-children (&optional number)
2236 "Return a list of article numbers that are children of article NUMBER."
2237 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2238 (level (gnus-data-level (car data)))
2240 (while (and (setq data (cdr data))
2241 (> (setq l (gnus-data-level (car data))) level))
2242 (and (= (1+ level) l)
2243 (push (gnus-data-number (car data))
2245 (nreverse children)))
2247 (defun gnus-summary-article-parent (&optional number)
2248 "Return the article number of the parent of article NUMBER."
2249 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2250 (gnus-data-list t)))
2251 (level (gnus-data-level (car data))))
2253 () ; This is a root.
2254 ;; We search until we find an article with a level less than
2255 ;; this one. That function has to be the parent.
2256 (while (and (setq data (cdr data))
2257 (not (< (gnus-data-level (car data)) level))))
2258 (and data (gnus-data-number (car data))))))
2260 (defun gnus-unread-mark-p (mark)
2261 "Say whether MARK is the unread mark."
2262 (= mark gnus-unread-mark))
2264 (defun gnus-read-mark-p (mark)
2265 "Say whether MARK is one of the marks that mark as read.
2266 This is all marks except unread, ticked, dormant, and expirable."
2267 (not (or (= mark gnus-unread-mark)
2268 (= mark gnus-ticked-mark)
2269 (= mark gnus-dormant-mark)
2270 (= mark gnus-expirable-mark))))
2272 (defmacro gnus-article-mark (number)
2273 "Return the MARK of article NUMBER.
2274 This macro should only be used when computing the mark the \"first\"
2275 time; i.e., when generating the summary lines. After that,
2276 `gnus-summary-article-mark' should be used to examine the
2279 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2280 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2281 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2282 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2283 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2284 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2285 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2286 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2287 gnus-ancient-mark))))
2289 ;; Saving hidden threads.
2291 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2292 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2294 (defmacro gnus-save-hidden-threads (&rest forms)
2295 "Save hidden threads, eval FORMS, and restore the hidden threads."
2296 (let ((config (make-symbol "config")))
2297 `(let ((,config (gnus-hidden-threads-configuration)))
2301 (gnus-restore-hidden-threads-configuration ,config)))))
2303 (defun gnus-data-compute-positions ()
2304 "Compute the positions of all articles."
2305 (setq gnus-newsgroup-data-reverse nil)
2306 (let ((data gnus-newsgroup-data))
2308 (gnus-save-hidden-threads
2309 (gnus-summary-show-all-threads)
2310 (goto-char (point-min))
2312 (while (get-text-property (point) 'gnus-intangible)
2314 (gnus-data-set-pos (car data) (+ (point) 3))
2315 (setq data (cdr data))
2316 (forward-line 1))))))
2318 (defun gnus-hidden-threads-configuration ()
2319 "Return the current hidden threads configuration."
2322 (goto-char (point-min))
2323 (while (search-forward "\r" nil t)
2324 (push (1- (point)) config))
2327 (defun gnus-restore-hidden-threads-configuration (config)
2328 "Restore hidden threads configuration from CONFIG."
2329 (let (point buffer-read-only)
2330 (while (setq point (pop config))
2331 (when (and (< point (point-max))
2333 (eq (char-after) ?\n))
2334 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2336 ;; Various summary mode internalish functions.
2338 (defun gnus-mouse-pick-article (e)
2341 (gnus-summary-next-page nil t))
2343 (defun gnus-summary-set-display-table ()
2344 ;; Change the display table. Odd characters have a tendency to mess
2345 ;; up nicely formatted displays - we make all possible glyphs
2346 ;; display only a single character.
2348 ;; We start from the standard display table, if any.
2349 (let ((table (or (copy-sequence standard-display-table)
2350 (make-display-table)))
2352 ;; Nix out all the control chars...
2353 (while (>= (setq i (1- i)) 0)
2354 (aset table i [??]))
2355 ;; ... but not newline and cr, of course. (cr is necessary for the
2356 ;; selective display).
2357 (aset table ?\n nil)
2358 (aset table ?\r nil)
2359 ;; We keep TAB as well.
2360 (aset table ?\t nil)
2361 ;; We nix out any glyphs over 126 that are not set already.
2363 (while (>= (setq i (1- i)) 127)
2364 ;; Only modify if the entry is nil.
2365 (unless (aref table i)
2366 (aset table i [??]))))
2367 (setq buffer-display-table table)))
2369 (defun gnus-summary-setup-buffer (group)
2370 "Initialize summary buffer."
2371 (let ((buffer (concat "*Summary " group "*")))
2372 (if (get-buffer buffer)
2375 (setq gnus-summary-buffer (current-buffer))
2376 (not gnus-newsgroup-prepared))
2377 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2378 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2379 (gnus-summary-mode group)
2381 (gnus-carpal-setup-buffer 'summary))
2382 (unless gnus-single-article-buffer
2383 (make-local-variable 'gnus-article-buffer)
2384 (make-local-variable 'gnus-article-current)
2385 (make-local-variable 'gnus-original-article-buffer))
2386 (setq gnus-newsgroup-name group)
2389 (defun gnus-set-global-variables ()
2390 ;; Set the global equivalents of the summary buffer-local variables
2391 ;; to the latest values they had. These reflect the summary buffer
2392 ;; that was in action when the last article was fetched.
2393 (when (eq major-mode 'gnus-summary-mode)
2394 (setq gnus-summary-buffer (current-buffer))
2395 (let ((name gnus-newsgroup-name)
2396 (marked gnus-newsgroup-marked)
2397 (unread gnus-newsgroup-unreads)
2398 (headers gnus-current-headers)
2399 (data gnus-newsgroup-data)
2400 (summary gnus-summary-buffer)
2401 (article-buffer gnus-article-buffer)
2402 (original gnus-original-article-buffer)
2403 (gac gnus-article-current)
2404 (reffed gnus-reffed-article-number)
2405 (score-file gnus-current-score-file)
2406 (default-charset gnus-newsgroup-charset))
2408 (set-buffer gnus-group-buffer)
2409 (setq gnus-newsgroup-name name
2410 gnus-newsgroup-marked marked
2411 gnus-newsgroup-unreads unread
2412 gnus-current-headers headers
2413 gnus-newsgroup-data data
2414 gnus-article-current gac
2415 gnus-summary-buffer summary
2416 gnus-article-buffer article-buffer
2417 gnus-original-article-buffer original
2418 gnus-reffed-article-number reffed
2419 gnus-current-score-file score-file
2420 gnus-newsgroup-charset default-charset)
2421 ;; The article buffer also has local variables.
2422 (when (gnus-buffer-live-p gnus-article-buffer)
2423 (set-buffer gnus-article-buffer)
2424 (setq gnus-summary-buffer summary))))))
2426 (defun gnus-summary-article-unread-p (article)
2427 "Say whether ARTICLE is unread or not."
2428 (memq article gnus-newsgroup-unreads))
2430 (defun gnus-summary-first-article-p (&optional article)
2431 "Return whether ARTICLE is the first article in the buffer."
2432 (if (not (setq article (or article (gnus-summary-article-number))))
2434 (eq article (caar gnus-newsgroup-data))))
2436 (defun gnus-summary-last-article-p (&optional article)
2437 "Return whether ARTICLE is the last article in the buffer."
2438 (if (not (setq article (or article (gnus-summary-article-number))))
2439 ;; All non-existent numbers are the last article. :-)
2441 (not (cdr (gnus-data-find-list article)))))
2443 (defun gnus-make-thread-indent-array ()
2445 (unless (and gnus-thread-indent-array
2446 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2447 (setq gnus-thread-indent-array (make-vector 201 "")
2448 gnus-thread-indent-array-level gnus-thread-indent-level)
2450 (aset gnus-thread-indent-array n
2451 (make-string (* n gnus-thread-indent-level) ? ))
2454 (defun gnus-update-summary-mark-positions ()
2455 "Compute where the summary marks are to go."
2457 (when (gnus-buffer-exists-p gnus-summary-buffer)
2458 (set-buffer gnus-summary-buffer))
2459 (let ((gnus-replied-mark 129)
2460 (gnus-score-below-mark 130)
2461 (gnus-score-over-mark 130)
2462 (gnus-download-mark 131)
2463 (spec gnus-summary-line-format-spec)
2466 (gnus-set-work-buffer)
2467 (let ((gnus-summary-line-format-spec spec)
2468 (gnus-newsgroup-downloadable '((0 . t))))
2469 (gnus-summary-insert-line
2470 (make-full-mail-header 0 "" "" "" "" "" 0 0 "" nil)
2471 0 nil 128 t nil "" nil 1)
2472 (goto-char (point-min))
2473 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2475 (goto-char (point-min))
2476 (push (cons 'replied (and (search-forward "\201" nil t)
2479 (goto-char (point-min))
2480 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2482 (goto-char (point-min))
2483 (push (cons 'download
2484 (and (search-forward "\203" nil t) (- (point) 2)))
2486 (setq gnus-summary-mark-positions pos))))
2488 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2489 "Insert a dummy root in the summary buffer."
2491 (gnus-add-text-properties
2492 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2493 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2495 (defun gnus-summary-from-or-to-or-newsgroups (header)
2496 (let ((to (cdr (assq 'To (mail-header-extra header))))
2497 (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header))))
2498 (mail-parse-charset gnus-newsgroup-charset))
2501 gnus-ignored-from-addresses
2502 (string-match gnus-ignored-from-addresses
2503 (mail-header-from header)))
2505 (or (car (funcall gnus-extract-address-components
2507 gnus-decode-encoded-word-function to)))
2508 (funcall gnus-decode-encoded-word-function to))))
2510 gnus-ignored-from-addresses
2511 (string-match gnus-ignored-from-addresses
2512 (mail-header-from header)))
2513 (concat "=> " newsgroups))
2515 (or (car (funcall gnus-extract-address-components
2516 (mail-header-from header)))
2517 (mail-header-from header))))))
2519 (defun gnus-summary-insert-line (gnus-tmp-header
2520 gnus-tmp-level gnus-tmp-current
2521 gnus-tmp-unread gnus-tmp-replied
2522 gnus-tmp-expirable gnus-tmp-subject-or-nil
2523 &optional gnus-tmp-dummy gnus-tmp-score
2525 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2526 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2527 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2528 (gnus-tmp-score-char
2529 (if (or (null gnus-summary-default-score)
2530 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2531 gnus-summary-zcore-fuzz))
2533 (if (< gnus-tmp-score gnus-summary-default-score)
2534 gnus-score-below-mark gnus-score-over-mark)))
2536 (cond (gnus-tmp-process gnus-process-mark)
2537 ((memq gnus-tmp-current gnus-newsgroup-cached)
2539 (gnus-tmp-replied gnus-replied-mark)
2540 ((memq gnus-tmp-current gnus-newsgroup-saved)
2542 (t gnus-unread-mark)))
2543 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2546 ((string-match "<[^>]+> *$" gnus-tmp-from)
2547 (let ((beg (match-beginning 0)))
2548 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2549 (substring gnus-tmp-from (1+ (match-beginning 0))
2550 (1- (match-end 0))))
2551 (substring gnus-tmp-from 0 beg))))
2552 ((string-match "(.+)" gnus-tmp-from)
2553 (substring gnus-tmp-from
2554 (1+ (match-beginning 0)) (1- (match-end 0))))
2556 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2557 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2558 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2559 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2560 (buffer-read-only nil))
2561 (when (string= gnus-tmp-name "")
2562 (setq gnus-tmp-name gnus-tmp-from))
2563 (unless (numberp gnus-tmp-lines)
2564 (setq gnus-tmp-lines 0))
2565 (gnus-put-text-property-excluding-characters-with-faces
2567 (progn (eval gnus-summary-line-format-spec) (point))
2568 'gnus-number gnus-tmp-number)
2569 (when (gnus-visual-p 'summary-highlight 'highlight)
2571 (gnus-run-hooks 'gnus-summary-update-hook)
2574 (defun gnus-summary-update-line (&optional dont-update)
2575 ;; Update summary line after change.
2576 (when (and gnus-summary-default-score
2577 (not gnus-summary-inhibit-highlight))
2578 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2579 (article (gnus-summary-article-number))
2580 (score (gnus-summary-article-score article)))
2582 (if (and gnus-summary-mark-below
2583 (< (gnus-summary-article-score)
2584 gnus-summary-mark-below))
2585 ;; This article has a low score, so we mark it as read.
2586 (when (memq article gnus-newsgroup-unreads)
2587 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2588 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2589 ;; This article was previously marked as read on account
2590 ;; of a low score, but now it has risen, so we mark it as
2592 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2593 (gnus-summary-update-mark
2594 (if (or (null gnus-summary-default-score)
2595 (<= (abs (- score gnus-summary-default-score))
2596 gnus-summary-zcore-fuzz))
2598 (if (< score gnus-summary-default-score)
2599 gnus-score-below-mark gnus-score-over-mark))
2601 ;; Do visual highlighting.
2602 (when (gnus-visual-p 'summary-highlight 'highlight)
2603 (gnus-run-hooks 'gnus-summary-update-hook)))))
2605 (defvar gnus-tmp-new-adopts nil)
2607 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2608 "Return the number of articles in THREAD.
2609 This may be 0 in some cases -- if none of the articles in
2610 the thread are to be displayed."
2612 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2614 ((not (listp thread))
2616 ((and (consp thread) (cdr thread))
2619 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2622 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2625 (when (and level (zerop level) gnus-tmp-new-adopts)
2628 'gnus-summary-number-of-articles-in-thread
2629 gnus-tmp-new-adopts))))
2631 (if (> number 1) gnus-not-empty-thread-mark
2632 gnus-empty-thread-mark)
2635 (defun gnus-summary-set-local-parameters (group)
2636 "Go through the local params of GROUP and set all variable specs in that list."
2637 (let ((params (gnus-group-find-parameter group))
2640 (setq elem (car params)
2641 params (cdr params))
2642 (and (consp elem) ; Has to be a cons.
2643 (consp (cdr elem)) ; The cdr has to be a list.
2644 (symbolp (car elem)) ; Has to be a symbol in there.
2645 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2646 (ignore-errors ; So we set it.
2647 (make-local-variable (car elem))
2648 (set (car elem) (eval (nth 1 elem))))))))
2650 (defun gnus-summary-read-group (group &optional show-all no-article
2651 kill-buffer no-display backward
2653 "Start reading news in newsgroup GROUP.
2654 If SHOW-ALL is non-nil, already read articles are also listed.
2655 If NO-ARTICLE is non-nil, no article is selected initially.
2656 If NO-DISPLAY, don't generate a summary buffer."
2660 (let ((gnus-auto-select-next nil))
2661 (or (gnus-summary-read-group-1
2662 group show-all no-article
2663 kill-buffer no-display
2666 select-articles nil)))))
2667 (eq gnus-auto-select-next 'quietly))
2668 (set-buffer gnus-group-buffer)
2669 ;; The entry function called above goes to the next
2670 ;; group automatically, so we go two groups back
2671 ;; if we are searching for the previous group.
2673 (gnus-group-prev-unread-group 2))
2674 (if (not (equal group (gnus-group-group-name)))
2675 (setq group (gnus-group-group-name))
2679 (defun gnus-summary-read-group-1 (group show-all no-article
2680 kill-buffer no-display
2681 &optional select-articles)
2682 ;; Killed foreign groups can't be entered.
2683 (when (and (not (gnus-group-native-p group))
2684 (not (gnus-gethash group gnus-newsrc-hashtb)))
2685 (error "Dead non-native groups can't be entered"))
2686 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2687 (let* ((new-group (gnus-summary-setup-buffer group))
2688 (quit-config (gnus-group-quit-config group))
2689 (did-select (and new-group (gnus-select-newsgroup
2690 group show-all select-articles))))
2692 ;; This summary buffer exists already, so we just select it.
2694 (gnus-set-global-variables)
2696 (gnus-kill-or-deaden-summary kill-buffer))
2697 (gnus-configure-windows 'summary 'force)
2698 (gnus-set-mode-line 'summary)
2699 (gnus-summary-position-point)
2702 ;; We couldn't select this group.
2704 (when (and (eq major-mode 'gnus-summary-mode)
2705 (not (equal (current-buffer) kill-buffer)))
2706 (kill-buffer (current-buffer))
2707 (if (not quit-config)
2709 ;; Update the info -- marks might need to be removed,
2711 (gnus-summary-update-info)
2712 (set-buffer gnus-group-buffer)
2713 (gnus-group-jump-to-group group)
2714 (gnus-group-next-unread-group 1))
2715 (gnus-handle-ephemeral-exit quit-config)))
2716 (gnus-message 3 "Can't select group")
2718 ;; The user did a `C-g' while prompting for number of articles,
2719 ;; so we exit this group.
2720 ((eq did-select 'quit)
2721 (and (eq major-mode 'gnus-summary-mode)
2722 (not (equal (current-buffer) kill-buffer))
2723 (kill-buffer (current-buffer)))
2725 (gnus-kill-or-deaden-summary kill-buffer))
2726 (if (not quit-config)
2728 (set-buffer gnus-group-buffer)
2729 (gnus-group-jump-to-group group)
2730 (gnus-group-next-unread-group 1)
2731 (gnus-configure-windows 'group 'force))
2732 (gnus-handle-ephemeral-exit quit-config))
2733 ;; Finally signal the quit.
2735 ;; The group was successfully selected.
2737 (gnus-set-global-variables)
2738 ;; Save the active value in effect when the group was entered.
2739 (setq gnus-newsgroup-active
2741 (gnus-active gnus-newsgroup-name)))
2742 ;; You can change the summary buffer in some way with this hook.
2743 (gnus-run-hooks 'gnus-select-group-hook)
2744 ;; Set any local variables in the group parameters.
2745 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2746 (gnus-update-format-specifications
2747 nil 'summary 'summary-mode 'summary-dummy)
2748 ;; Do score processing.
2749 (when gnus-use-scoring
2750 (gnus-possibly-score-headers))
2751 ;; Check whether to fill in the gaps in the threads.
2752 (when gnus-build-sparse-threads
2753 (gnus-build-sparse-threads))
2754 ;; Find the initial limit.
2755 (if gnus-show-threads
2757 (let ((gnus-newsgroup-dormant nil))
2758 (gnus-summary-initial-limit show-all))
2759 (gnus-summary-initial-limit show-all))
2760 (setq gnus-newsgroup-limit
2762 (lambda (header) (mail-header-number header))
2763 gnus-newsgroup-headers)))
2764 ;; Generate the summary buffer.
2766 (gnus-summary-prepare))
2767 (when gnus-use-trees
2768 (gnus-tree-open group)
2769 (setq gnus-summary-highlight-line-function
2770 'gnus-tree-highlight-article))
2771 ;; If the summary buffer is empty, but there are some low-scored
2772 ;; articles or some excluded dormants, we include these in the
2774 (when (and (zerop (buffer-size))
2776 (cond (gnus-newsgroup-dormant
2777 (gnus-summary-limit-include-dormant))
2778 ((and gnus-newsgroup-scored show-all)
2779 (gnus-summary-limit-include-expunged t))))
2780 ;; Function `gnus-apply-kill-file' must be called in this hook.
2781 (gnus-run-hooks 'gnus-apply-kill-hook)
2782 (if (and (zerop (buffer-size))
2785 ;; This newsgroup is empty.
2786 (gnus-summary-catchup-and-exit nil t)
2787 (gnus-message 6 "No unread news")
2789 (gnus-kill-or-deaden-summary kill-buffer))
2790 ;; Return nil from this function.
2792 ;; Hide conversation thread subtrees. We cannot do this in
2793 ;; gnus-summary-prepare-hook since kill processing may not
2794 ;; work with hidden articles.
2795 (and gnus-show-threads
2796 gnus-thread-hide-subtree
2797 (gnus-summary-hide-all-threads))
2799 (gnus-kill-or-deaden-summary kill-buffer))
2800 ;; Show first unread article if requested.
2801 (if (and (not no-article)
2803 gnus-newsgroup-unreads
2804 gnus-auto-select-first)
2806 (gnus-configure-windows 'summary)
2808 ((eq gnus-auto-select-first 'best)
2809 (gnus-summary-best-unread-article))
2810 ((eq gnus-auto-select-first t)
2811 (gnus-summary-first-unread-article))
2812 ((gnus-functionp gnus-auto-select-first)
2813 (funcall gnus-auto-select-first))))
2814 ;; Don't select any articles, just move point to the first
2815 ;; article in the group.
2816 (goto-char (point-min))
2817 (gnus-summary-position-point)
2818 (gnus-configure-windows 'summary 'force)
2819 (gnus-set-mode-line 'summary))
2820 (when (get-buffer-window gnus-group-buffer t)
2821 ;; Gotta use windows, because recenter does weird stuff if
2822 ;; the current buffer ain't the displayed window.
2823 (let ((owin (selected-window)))
2824 (select-window (get-buffer-window gnus-group-buffer t))
2825 (when (gnus-group-goto-group group)
2827 (select-window owin)))
2828 ;; Mark this buffer as "prepared".
2829 (setq gnus-newsgroup-prepared t)
2830 (gnus-run-hooks 'gnus-summary-prepared-hook)
2833 (defun gnus-summary-prepare ()
2834 "Generate the summary buffer."
2836 (let ((buffer-read-only nil))
2838 (setq gnus-newsgroup-data nil
2839 gnus-newsgroup-data-reverse nil)
2840 (gnus-run-hooks 'gnus-summary-generate-hook)
2841 ;; Generate the buffer, either with threads or without.
2842 (when gnus-newsgroup-headers
2843 (gnus-summary-prepare-threads
2844 (if gnus-show-threads
2845 (gnus-sort-gathered-threads
2846 (funcall gnus-summary-thread-gathering-function
2848 (gnus-cut-threads (gnus-make-threads)))))
2849 ;; Unthreaded display.
2850 (gnus-sort-articles gnus-newsgroup-headers))))
2851 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2852 ;; Call hooks for modifying summary buffer.
2853 (goto-char (point-min))
2854 (gnus-run-hooks 'gnus-summary-prepare-hook)))
2856 (defsubst gnus-general-simplify-subject (subject)
2857 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2860 ;; Truncate the subject.
2861 (gnus-simplify-subject-functions
2862 (gnus-map-function gnus-simplify-subject-functions subject))
2863 ((numberp gnus-summary-gather-subject-limit)
2864 (setq subject (gnus-simplify-subject-re subject))
2865 (if (> (length subject) gnus-summary-gather-subject-limit)
2866 (substring subject 0 gnus-summary-gather-subject-limit)
2868 ;; Fuzzily simplify it.
2869 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2870 (gnus-simplify-subject-fuzzy subject))
2871 ;; Just remove the leading "Re:".
2873 (gnus-simplify-subject-re subject))))
2875 (if (and gnus-summary-gather-exclude-subject
2876 (string-match gnus-summary-gather-exclude-subject subject))
2877 nil ; This article shouldn't be gathered
2880 (defun gnus-summary-simplify-subject-query ()
2881 "Query where the respool algorithm would put this article."
2883 (gnus-summary-select-article)
2884 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2886 (defun gnus-gather-threads-by-subject (threads)
2887 "Gather threads by looking at Subject headers."
2888 (if (not gnus-summary-make-false-root)
2890 (let ((hashtb (gnus-make-hashtable 1024))
2893 subject hthread whole-subject)
2895 (setq subject (gnus-general-simplify-subject
2896 (setq whole-subject (mail-header-subject
2899 (if (setq hthread (gnus-gethash subject hashtb))
2901 ;; We enter a dummy root into the thread, if we
2902 ;; haven't done that already.
2903 (unless (stringp (caar hthread))
2904 (setcar hthread (list whole-subject (car hthread))))
2905 ;; We add this new gathered thread to this gathered
2907 (setcdr (car hthread)
2908 (nconc (cdar hthread) (list (car threads))))
2909 ;; Remove it from the list of threads.
2910 (setcdr prev (cdr threads))
2911 (setq threads prev))
2912 ;; Enter this thread into the hash table.
2913 (gnus-sethash subject threads hashtb)))
2915 (setq threads (cdr threads)))
2918 (defun gnus-gather-threads-by-references (threads)
2919 "Gather threads by looking at References headers."
2920 (let ((idhashtb (gnus-make-hashtable 1024))
2921 (thhashtb (gnus-make-hashtable 1024))
2924 ids references id gthread gid entered ref)
2926 (when (setq references (mail-header-references (caar threads)))
2927 (setq id (mail-header-id (caar threads))
2928 ids (gnus-split-references references)
2930 (while (setq ref (pop ids))
2931 (setq ids (delete ref ids))
2932 (if (not (setq gid (gnus-gethash ref idhashtb)))
2934 (gnus-sethash ref id idhashtb)
2935 (gnus-sethash id threads thhashtb))
2936 (setq gthread (gnus-gethash gid thhashtb))
2938 ;; We enter a dummy root into the thread, if we
2939 ;; haven't done that already.
2940 (unless (stringp (caar gthread))
2941 (setcar gthread (list (mail-header-subject (caar gthread))
2943 ;; We add this new gathered thread to this gathered
2945 (setcdr (car gthread)
2946 (nconc (cdar gthread) (list (car threads)))))
2947 ;; Add it into the thread hash table.
2948 (gnus-sethash id gthread thhashtb)
2950 ;; Remove it from the list of threads.
2951 (setcdr prev (cdr threads))
2952 (setq threads prev))))
2954 (setq threads (cdr threads)))
2957 (defun gnus-sort-gathered-threads (threads)
2958 "Sort subtreads inside each gathered thread by article number."
2959 (let ((result threads))
2961 (when (stringp (caar threads))
2962 (setcdr (car threads)
2963 (sort (cdar threads) 'gnus-thread-sort-by-number)))
2964 (setq threads (cdr threads)))
2967 (defun gnus-thread-loop-p (root thread)
2968 "Say whether ROOT is in THREAD."
2969 (let ((stack (list thread))
2972 (while (setq thread (pop stack))
2973 (setq th (cdr thread))
2975 (not (eq (caar th) root)))
2978 ;; We have found a loop.
2980 (setcdr thread (delq (car th) (cdr thread)))
2981 (if (boundp (setq ref-dep (intern "none"
2982 gnus-newsgroup-dependencies)))
2983 (setcdr (symbol-value ref-dep)
2984 (nconc (cdr (symbol-value ref-dep))
2986 (set ref-dep (list nil (car th))))
2989 ;; Push all the subthreads onto the stack.
2990 (push (cdr thread) stack)))
2993 (defun gnus-make-threads ()
2994 "Go through the dependency hashtb and find the roots. Return all threads."
2996 (while (catch 'infloop
2999 ;; Deal with self-referencing References loops.
3000 (when (and (car (symbol-value refs))
3007 (car (symbol-value refs)) thread))
3008 (cdr (symbol-value refs)))))))
3011 (unless (car (symbol-value refs))
3012 ;; These threads do not refer back to any other articles,
3013 ;; so they're roots.
3014 (setq threads (append (cdr (symbol-value refs)) threads))))
3015 gnus-newsgroup-dependencies)))
3018 ;; Build the thread tree.
3019 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3020 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3022 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3023 if it was already present.
3025 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3026 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3027 Message-IDs will be renamed be renamed to a unique Message-ID before
3030 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3031 (let* ((id (mail-header-id header))
3032 (id-dep (and id (intern id dependencies)))
3033 ref ref-dep ref-header)
3034 ;; Enter this `header' in the `dependencies' table.
3038 ;; The first two cases do the normal part: enter a new `header'
3039 ;; in the `dependencies' table.
3040 ((not (boundp id-dep))
3041 (set id-dep (list header)))
3042 ((null (car (symbol-value id-dep)))
3043 (setcar (symbol-value id-dep) header))
3045 ;; From here the `header' was already present in the
3046 ;; `dependencies' table.
3048 ;; Overrides an existing entry;
3049 ;; just set the header part of the entry.
3050 (setcar (symbol-value id-dep) header))
3052 ;; Renames the existing `header' to a unique Message-ID.
3053 ((not gnus-summary-ignore-duplicates)
3054 ;; An article with this Message-ID has already been seen.
3055 ;; We rename the Message-ID.
3056 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3058 (mail-header-set-id header id))
3060 ;; The last case ignores an existing entry, except it adds any
3061 ;; additional Xrefs (in case the two articles came from different
3063 ;; Also sets `header' to `nil' meaning that the `dependencies'
3064 ;; table was *not* modified.
3066 (mail-header-set-xref
3067 (car (symbol-value id-dep))
3068 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3070 (or (mail-header-xref header) "")))
3074 ;; First check if that we are not creating a References loop.
3075 (setq ref (gnus-parent-id (mail-header-references header)))
3077 (setq ref-dep (intern-soft ref dependencies))
3079 (setq ref-header (car (symbol-value ref-dep))))
3080 (if (string= id ref)
3081 ;; Yuk! This is a reference loop. Make the article be a
3084 (mail-header-set-references (car (symbol-value id-dep)) "none")
3086 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3087 (setq ref (gnus-parent-id (mail-header-references header)))
3088 (setq ref-dep (intern (or ref "none") dependencies))
3089 (if (boundp ref-dep)
3090 (setcdr (symbol-value ref-dep)
3091 (nconc (cdr (symbol-value ref-dep))
3092 (list (symbol-value id-dep))))
3093 (set ref-dep (list nil (symbol-value id-dep)))))
3096 (defun gnus-build-sparse-threads ()
3097 (let ((headers gnus-newsgroup-headers)
3098 (gnus-summary-ignore-duplicates t)
3099 header references generation relations
3100 subject child end new-child date)
3101 ;; First we create an alist of generations/relations, where
3102 ;; generations is how much we trust the relation, and the relation
3104 (gnus-message 7 "Making sparse threads...")
3106 (nnheader-set-temp-buffer " *gnus sparse threads*")
3107 (while (setq header (pop headers))
3108 (when (and (setq references (mail-header-references header))
3109 (not (string= references "")))
3111 (setq child (mail-header-id header)
3112 subject (mail-header-subject header)
3113 date (mail-header-date header)
3115 (while (search-backward ">" nil t)
3116 (setq end (1+ (point)))
3117 (when (search-backward "<" nil t)
3118 (setq new-child (buffer-substring (point) end))
3119 (push (list (incf generation)
3120 child (setq child new-child)
3124 (push (list (1+ generation) child nil subject) relations))
3126 (kill-buffer (current-buffer)))
3127 ;; Sort over trustworthiness.
3130 (when (gnus-dependencies-add-header
3131 (make-full-mail-header
3132 gnus-reffed-article-number
3133 (nth 3 relation) "" (or (nth 4 relation) "")
3135 (or (nth 2 relation) "") 0 0 "")
3136 gnus-newsgroup-dependencies nil)
3137 (push gnus-reffed-article-number gnus-newsgroup-limit)
3138 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3139 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3140 gnus-newsgroup-reads)
3141 (decf gnus-reffed-article-number)))
3142 (sort relations 'car-less-than-car))
3143 (gnus-message 7 "Making sparse threads...done")))
3145 (defun gnus-build-old-threads ()
3146 ;; Look at all the articles that refer back to old articles, and
3147 ;; fetch the headers for the articles that aren't there. This will
3148 ;; build complete threads - if the roots haven't been expired by the
3153 (when (not (car (symbol-value refs)))
3154 (setq heads (cdr (symbol-value refs)))
3156 (if (memq (mail-header-number (caar heads))
3157 gnus-newsgroup-dormant)
3158 (setq heads (cdr heads))
3159 (setq id (symbol-name refs))
3160 (while (and (setq id (gnus-build-get-header id))
3161 (not (car (gnus-id-to-thread id)))))
3162 (setq heads nil)))))
3163 gnus-newsgroup-dependencies)))
3165 ;; This function has to be called with point after the article number
3166 ;; on the beginning of the line.
3167 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3168 (let ((eol (gnus-point-at-eol))
3169 (buffer (current-buffer))
3172 ;; overview: [num subject from date id refs chars lines misc]
3177 (make-full-mail-header
3179 (nnheader-nov-field) ; subject
3180 (nnheader-nov-field) ; from
3181 (nnheader-nov-field) ; date
3182 (nnheader-nov-read-message-id) ; id
3183 (nnheader-nov-field) ; refs
3184 (nnheader-nov-read-integer) ; chars
3185 (nnheader-nov-read-integer) ; lines
3187 (nnheader-nov-field)) ; misc
3188 (nnheader-nov-parse-extra))) ; extra
3190 (when gnus-alter-header-function
3191 (funcall gnus-alter-header-function header))
3192 (gnus-dependencies-add-header header dependencies force-new)))
3194 (defun gnus-build-get-header (id)
3195 ;; Look through the buffer of NOV lines and find the header to
3196 ;; ID. Enter this line into the dependencies hash table, and return
3197 ;; the id of the parent article (if any).
3198 (let ((deps gnus-newsgroup-dependencies)
3202 (set-buffer nntp-server-buffer)
3203 (let ((case-fold-search nil))
3204 (goto-char (point-min))
3205 (while (and (not found)
3206 (search-forward id nil t))
3208 (setq found (looking-at
3209 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3210 (regexp-quote id))))
3211 (or found (beginning-of-line 2)))
3215 (setq header (gnus-nov-parse-line
3216 (read (current-buffer)) deps))
3217 (gnus-parent-id (mail-header-references header))))))
3219 (let ((number (mail-header-number header)))
3220 (push number gnus-newsgroup-limit)
3221 (push header gnus-newsgroup-headers)
3222 (if (memq number gnus-newsgroup-unselected)
3224 (push number gnus-newsgroup-unreads)
3225 (setq gnus-newsgroup-unselected
3226 (delq number gnus-newsgroup-unselected)))
3227 (push number gnus-newsgroup-ancient)))))))
3229 (defun gnus-build-all-threads ()
3230 "Read all the headers."
3231 (let ((gnus-summary-ignore-duplicates t)
3232 (dependencies gnus-newsgroup-dependencies)
3235 (set-buffer nntp-server-buffer)
3236 (let ((case-fold-search nil))
3237 (goto-char (point-min))
3240 (setq article (read (current-buffer))
3241 header (gnus-nov-parse-line
3242 article dependencies)))
3245 (set-buffer gnus-summary-buffer)
3246 (push header gnus-newsgroup-headers)
3247 (if (memq (setq article (mail-header-number header))
3248 gnus-newsgroup-unselected)
3250 (push article gnus-newsgroup-unreads)
3251 (setq gnus-newsgroup-unselected
3252 (delq article gnus-newsgroup-unselected)))
3253 (push article gnus-newsgroup-ancient)))
3254 (forward-line 1)))))))
3256 (defun gnus-summary-update-article-line (article header)
3257 "Update the line for ARTICLE using HEADERS."
3258 (let* ((id (mail-header-id header))
3259 (thread (gnus-id-to-thread id)))
3261 (error "Article in no thread"))
3262 ;; Update the thread.
3263 (setcar thread header)
3264 (gnus-summary-goto-subject article)
3265 (let* ((datal (gnus-data-find-list article))
3267 (length (when (cdr datal)
3268 (- (gnus-data-pos data)
3269 (gnus-data-pos (cadr datal)))))
3270 (buffer-read-only nil)
3271 (level (gnus-summary-thread-level)))
3273 (gnus-summary-insert-line
3274 header level nil (gnus-article-mark article)
3275 (memq article gnus-newsgroup-replied)
3276 (memq article gnus-newsgroup-expirable)
3277 ;; Only insert the Subject string when it's different
3278 ;; from the previous Subject string.
3279 (if (gnus-subject-equal
3281 (mail-header-subject
3284 (gnus-data-find-list
3286 (gnus-data-list t)))))
3287 ;; Error on the side of excessive subjects.
3289 (mail-header-subject header))
3291 (mail-header-subject header))
3292 nil (cdr (assq article gnus-newsgroup-scored))
3293 (memq article gnus-newsgroup-processable))
3295 (gnus-data-update-list
3296 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3298 (defun gnus-summary-update-article (article &optional iheader)
3299 "Update ARTICLE in the summary buffer."
3300 (set-buffer gnus-summary-buffer)
3301 (let* ((header (gnus-summary-article-header article))
3302 (id (mail-header-id header))
3303 (data (gnus-data-find article))
3304 (thread (gnus-id-to-thread id))
3305 (references (mail-header-references header))
3309 (when (and references
3310 (not (equal "" references)))
3313 (buffer-read-only nil)
3319 (delq thread parent)))
3320 (if (gnus-summary-insert-subject id header)
3321 ;; Set the (possibly) new article number in the data structure.
3322 (gnus-data-set-number data (gnus-id-to-article id))
3326 (defun gnus-rebuild-thread (id &optional line)
3327 "Rebuild the thread containing ID.
3328 If LINE, insert the rebuilt thread starting on line LINE."
3329 (let ((buffer-read-only nil)
3330 old-pos current thread data)
3331 (if (not gnus-show-threads)
3332 (setq thread (list (car (gnus-id-to-thread id))))
3333 ;; Get the thread this article is part of.
3334 (setq thread (gnus-remove-thread id)))
3335 (setq old-pos (gnus-point-at-bol))
3336 (setq current (save-excursion
3337 (and (zerop (forward-line -1))
3338 (gnus-summary-article-number))))
3339 ;; If this is a gathered thread, we have to go some re-gathering.
3340 (when (stringp (car thread))
3341 (let ((subject (car thread))
3343 (setq thread (cdr thread))
3345 (unless (memq (setq thr (gnus-id-to-thread
3347 (mail-header-id (caar thread)))))
3350 (setq thread (cdr thread)))
3351 ;; We now have all (unique) roots.
3352 (if (= (length roots) 1)
3353 ;; All the loose roots are now one solid root.
3354 (setq thread (car roots))
3355 (setq thread (cons subject (gnus-sort-threads roots))))))
3357 ;; We then insert this thread into the summary buffer.
3359 (goto-char (point-min))
3360 (forward-line (1- line)))
3361 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3362 (if gnus-show-threads
3363 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3364 (gnus-summary-prepare-unthreaded thread))
3365 (setq data (nreverse gnus-newsgroup-data))
3366 (setq threads gnus-newsgroup-threads))
3367 ;; We splice the new data into the data structure.
3368 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3369 ;;!!! then we want to insert at the beginning of the buffer.
3370 ;;!!! That happens to be true with Gnus now, but that may
3371 ;;!!! change in the future. Perhaps.
3372 (gnus-data-enter-list
3373 (if line nil current) data (- (point) old-pos))
3374 (setq gnus-newsgroup-threads
3375 (nconc threads gnus-newsgroup-threads))
3376 (gnus-data-compute-positions))))
3378 (defun gnus-number-to-header (number)
3379 "Return the header for article NUMBER."
3380 (let ((headers gnus-newsgroup-headers))
3382 (not (= number (mail-header-number (car headers)))))
3387 (defun gnus-parent-headers (in-headers &optional generation)
3388 "Return the headers of the GENERATIONeth parent of HEADERS."
3390 (setq generation 1))
3392 (headers in-headers)
3395 (not (zerop generation))
3396 (setq references (mail-header-references headers)))
3397 (setq headers (if (and references
3398 (setq parent (gnus-parent-id references)))
3399 (car (gnus-id-to-thread parent))
3402 (and (not (eq headers in-headers))
3405 (defun gnus-id-to-thread (id)
3406 "Return the (sub-)thread where ID appears."
3407 (gnus-gethash id gnus-newsgroup-dependencies))
3409 (defun gnus-id-to-article (id)
3410 "Return the article number of ID."
3411 (let ((thread (gnus-id-to-thread id)))
3414 (mail-header-number (car thread)))))
3416 (defun gnus-id-to-header (id)
3417 "Return the article headers of ID."
3418 (car (gnus-id-to-thread id)))
3420 (defun gnus-article-displayed-root-p (article)
3421 "Say whether ARTICLE is a root(ish) article."
3422 (let ((level (gnus-summary-thread-level article))
3423 (refs (mail-header-references (gnus-summary-article-header article)))
3429 ((null (gnus-parent-id refs)) t)
3431 (null (setq particle (gnus-id-to-article
3432 (gnus-parent-id refs))))
3433 (null (gnus-summary-thread-level particle)))))))
3435 (defun gnus-root-id (id)
3436 "Return the id of the root of the thread where ID appears."
3438 (while (and id (setq prev (car (gnus-id-to-thread id))))
3440 id (gnus-parent-id (mail-header-references prev))))
3443 (defun gnus-articles-in-thread (thread)
3444 "Return the list of articles in THREAD."
3445 (cons (mail-header-number (car thread))
3446 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3448 (defun gnus-remove-thread (id &optional dont-remove)
3449 "Remove the thread that has ID in it."
3450 (let (headers thread last-id)
3451 ;; First go up in this thread until we find the root.
3452 (setq last-id (gnus-root-id id)
3453 headers (message-flatten-list (gnus-id-to-thread last-id)))
3454 ;; We have now found the real root of this thread. It might have
3455 ;; been gathered into some loose thread, so we have to search
3456 ;; through the threads to find the thread we wanted.
3457 (let ((threads gnus-newsgroup-threads)
3460 (setq sub (car threads))
3461 (if (stringp (car sub))
3462 ;; This is a gathered thread, so we look at the roots
3463 ;; below it to find whether this article is in this
3466 (setq sub (cdr sub))
3468 (when (member (caar sub) headers)
3469 (setq thread (car threads)
3472 (setq sub (cdr sub))))
3473 ;; It's an ordinary thread, so we check it.
3474 (when (eq (car sub) (car headers))
3477 (setq threads (cdr threads)))
3478 ;; If this article is in no thread, then it's a root.
3481 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3482 (setq thread (gnus-id-to-thread last-id)))
3485 thread ; We return this thread.
3487 (if (stringp (car thread))
3489 ;; If we use dummy roots, then we have to remove the
3490 ;; dummy root as well.
3491 (when (eq gnus-summary-make-false-root 'dummy)
3492 ;; We go to the dummy root by going to
3493 ;; the first sub-"thread", and then one line up.
3494 (gnus-summary-goto-article
3495 (mail-header-number (caadr thread)))
3498 (gnus-data-compute-positions))
3499 (setq thread (cdr thread))
3501 (gnus-remove-thread-1 (car thread))
3502 (setq thread (cdr thread))))
3503 (gnus-summary-show-all-threads)
3504 (gnus-remove-thread-1 thread))))))))
3506 (defun gnus-remove-thread-1 (thread)
3507 "Remove the thread THREAD recursively."
3508 (let ((number (mail-header-number (pop thread)))
3510 (setq thread (reverse thread))
3512 (gnus-remove-thread-1 (pop thread)))
3513 (when (setq d (gnus-data-find number))
3514 (goto-char (gnus-data-pos d))
3517 (- (gnus-point-at-bol)
3519 (1+ (gnus-point-at-eol))
3520 (gnus-delete-line)))))))
3522 (defun gnus-sort-threads (threads)
3524 (if (not gnus-thread-sort-functions)
3526 (gnus-message 8 "Sorting threads...")
3528 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3529 (gnus-message 8 "Sorting threads...done"))))
3531 (defun gnus-sort-articles (articles)
3533 (when gnus-article-sort-functions
3534 (gnus-message 7 "Sorting articles...")
3536 (setq gnus-newsgroup-headers
3537 (sort articles (gnus-make-sort-function
3538 gnus-article-sort-functions)))
3539 (gnus-message 7 "Sorting articles...done"))))
3541 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3542 (defmacro gnus-thread-header (thread)
3543 ;; Return header of first article in THREAD.
3544 ;; Note that THREAD must never, ever be anything else than a variable -
3545 ;; using some other form will lead to serious barfage.
3546 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3547 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3548 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
3551 (defsubst gnus-article-sort-by-number (h1 h2)
3552 "Sort articles by article number."
3553 (< (mail-header-number h1)
3554 (mail-header-number h2)))
3556 (defun gnus-thread-sort-by-number (h1 h2)
3557 "Sort threads by root article number."
3558 (gnus-article-sort-by-number
3559 (gnus-thread-header h1) (gnus-thread-header h2)))
3561 (defsubst gnus-article-sort-by-lines (h1 h2)
3562 "Sort articles by article Lines header."
3563 (< (mail-header-lines h1)
3564 (mail-header-lines h2)))
3566 (defun gnus-thread-sort-by-lines (h1 h2)
3567 "Sort threads by root article Lines header."
3568 (gnus-article-sort-by-lines
3569 (gnus-thread-header h1) (gnus-thread-header h2)))
3571 (defsubst gnus-article-sort-by-chars (h1 h2)
3572 "Sort articles by octet length."
3573 (< (mail-header-chars h1)
3574 (mail-header-chars h2)))
3576 (defun gnus-thread-sort-by-chars (h1 h2)
3577 "Sort threads by root article octet length."
3578 (gnus-article-sort-by-chars
3579 (gnus-thread-header h1) (gnus-thread-header h2)))
3581 (defsubst gnus-article-sort-by-author (h1 h2)
3582 "Sort articles by root author."
3584 (let ((addr (car (mime-read-field 'From h1))))
3585 (or (std11-full-name-string addr)
3586 (std11-address-string addr)
3588 (let ((addr (car (mime-read-field 'From h2))))
3589 (or (std11-full-name-string addr)
3590 (std11-address-string addr)
3594 (defun gnus-thread-sort-by-author (h1 h2)
3595 "Sort threads by root author."
3596 (gnus-article-sort-by-author
3597 (gnus-thread-header h1) (gnus-thread-header h2)))
3599 (defsubst gnus-article-sort-by-subject (h1 h2)
3600 "Sort articles by root subject."
3602 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3603 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3605 (defun gnus-thread-sort-by-subject (h1 h2)
3606 "Sort threads by root subject."
3607 (gnus-article-sort-by-subject
3608 (gnus-thread-header h1) (gnus-thread-header h2)))
3610 (defsubst gnus-article-sort-by-date (h1 h2)
3611 "Sort articles by root article date."
3613 (gnus-date-get-time (mail-header-date h1))
3614 (gnus-date-get-time (mail-header-date h2))))
3616 (defun gnus-thread-sort-by-date (h1 h2)
3617 "Sort threads by root article date."
3618 (gnus-article-sort-by-date
3619 (gnus-thread-header h1) (gnus-thread-header h2)))
3621 (defsubst gnus-article-sort-by-score (h1 h2)
3622 "Sort articles by root article score.
3623 Unscored articles will be counted as having a score of zero."
3624 (> (or (cdr (assq (mail-header-number h1)
3625 gnus-newsgroup-scored))
3626 gnus-summary-default-score 0)
3627 (or (cdr (assq (mail-header-number h2)
3628 gnus-newsgroup-scored))
3629 gnus-summary-default-score 0)))
3631 (defun gnus-thread-sort-by-score (h1 h2)
3632 "Sort threads by root article score."
3633 (gnus-article-sort-by-score
3634 (gnus-thread-header h1) (gnus-thread-header h2)))
3636 (defun gnus-thread-sort-by-total-score (h1 h2)
3637 "Sort threads by the sum of all scores in the thread.
3638 Unscored articles will be counted as having a score of zero."
3639 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3641 (defun gnus-thread-total-score (thread)
3642 ;; This function find the total score of THREAD.
3643 (cond ((null thread)
3646 (if (stringp (car thread))
3647 (apply gnus-thread-score-function 0
3648 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3649 (gnus-thread-total-score-1 thread)))
3651 (gnus-thread-total-score-1 (list thread)))))
3653 (defun gnus-thread-total-score-1 (root)
3654 ;; This function find the total score of the thread below ROOT.
3655 (setq root (car root))
3656 (apply gnus-thread-score-function
3658 (mapcar 'gnus-thread-total-score
3659 (cdr (gnus-id-to-thread (mail-header-id root))))
3660 (when (> (mail-header-number root) 0)
3661 (list (or (cdr (assq (mail-header-number root)
3662 gnus-newsgroup-scored))
3663 gnus-summary-default-score 0))))
3664 (list gnus-summary-default-score)
3667 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3668 (defvar gnus-tmp-prev-subject nil)
3669 (defvar gnus-tmp-false-parent nil)
3670 (defvar gnus-tmp-root-expunged nil)
3671 (defvar gnus-tmp-dummy-line nil)
3673 (defvar gnus-tmp-header)
3674 (defun gnus-extra-header (type &optional header)
3675 "Return the extra header of TYPE."
3676 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
3679 (defun gnus-summary-prepare-threads (threads)
3680 "Prepare summary buffer from THREADS and indentation LEVEL.
3681 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3682 or a straight list of headers."
3683 (gnus-message 7 "Generating summary...")
3685 (setq gnus-newsgroup-threads threads)
3688 (let ((gnus-tmp-level 0)
3689 (default-score (or gnus-summary-default-score 0))
3690 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3691 thread number subject stack state gnus-tmp-gathered beg-match
3692 new-roots gnus-tmp-new-adopts thread-end
3693 gnus-tmp-header gnus-tmp-unread
3694 gnus-tmp-replied gnus-tmp-subject-or-nil
3695 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3696 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3697 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3699 (setq gnus-tmp-prev-subject nil)
3701 (if (vectorp (car threads))
3702 ;; If this is a straight (sic) list of headers, then a
3703 ;; threaded summary display isn't required, so we just create
3704 ;; an unthreaded one.
3705 (gnus-summary-prepare-unthreaded threads)
3707 ;; Do the threaded display.
3709 (while (or threads stack gnus-tmp-new-adopts new-roots)
3711 (if (and (= gnus-tmp-level 0)
3714 (not gnus-tmp-false-parent)
3715 (or gnus-tmp-new-adopts new-roots))
3716 (if gnus-tmp-new-adopts
3717 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3718 thread (list (car gnus-tmp-new-adopts))
3719 gnus-tmp-header (caar thread)
3720 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3722 (setq thread (list (car new-roots))
3723 gnus-tmp-header (caar thread)
3724 new-roots (cdr new-roots))))
3727 ;; If there are some threads, we do them before the
3728 ;; threads on the stack.
3729 (setq thread threads
3730 gnus-tmp-header (caar thread))
3731 ;; There were no current threads, so we pop something off
3733 (setq state (car stack)
3734 gnus-tmp-level (car state)
3737 gnus-tmp-header (caar thread))))
3739 (setq gnus-tmp-false-parent nil)
3740 (setq gnus-tmp-root-expunged nil)
3741 (setq thread-end nil)
3743 (if (stringp gnus-tmp-header)
3744 ;; The header is a dummy root.
3746 ((eq gnus-summary-make-false-root 'adopt)
3747 ;; We let the first article adopt the rest.
3748 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3750 (setq gnus-tmp-gathered
3752 (lambda (h) (mail-header-number (car h)))
3755 (setq thread (cons (list (caar thread)
3758 (setq gnus-tmp-level -1
3759 gnus-tmp-false-parent t))
3760 ((eq gnus-summary-make-false-root 'empty)
3761 ;; We print adopted articles with empty subject fields.
3762 (setq gnus-tmp-gathered
3764 (lambda (h) (mail-header-number (car h)))
3767 (setq gnus-tmp-level -1))
3768 ((eq gnus-summary-make-false-root 'dummy)
3769 ;; We remember that we probably want to output a dummy
3771 (setq gnus-tmp-dummy-line gnus-tmp-header)
3772 (setq gnus-tmp-prev-subject gnus-tmp-header))
3774 ;; We do not make a root for the gathered
3775 ;; sub-threads at all.
3776 (setq gnus-tmp-level -1)))
3778 (setq number (mail-header-number gnus-tmp-header)
3779 subject (mail-header-subject gnus-tmp-header))
3782 ;; If the thread has changed subject, we might want to make
3783 ;; this subthread into a root.
3784 ((and (null gnus-thread-ignore-subject)
3785 (not (zerop gnus-tmp-level))
3786 gnus-tmp-prev-subject
3788 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3789 (setq new-roots (nconc new-roots (list (car thread)))
3791 gnus-tmp-header nil))
3792 ;; If the article lies outside the current limit,
3793 ;; then we do not display it.
3794 ((not (memq number gnus-newsgroup-limit))
3795 (setq gnus-tmp-gathered
3797 (lambda (h) (mail-header-number (car h)))
3800 (setq gnus-tmp-new-adopts (if (cdar thread)
3801 (append gnus-tmp-new-adopts
3803 gnus-tmp-new-adopts)
3805 gnus-tmp-header nil)
3806 (when (zerop gnus-tmp-level)
3807 (setq gnus-tmp-root-expunged t)))
3808 ;; Perhaps this article is to be marked as read?
3809 ((and gnus-summary-mark-below
3810 (< (or (cdr (assq number gnus-newsgroup-scored))
3812 gnus-summary-mark-below)
3813 ;; Don't touch sparse articles.
3814 (not (gnus-summary-article-sparse-p number))
3815 (not (gnus-summary-article-ancient-p number)))
3816 (setq gnus-newsgroup-unreads
3817 (delq number gnus-newsgroup-unreads))
3818 (if gnus-newsgroup-auto-expire
3819 (push number gnus-newsgroup-expirable)
3820 (push (cons number gnus-low-score-mark)
3821 gnus-newsgroup-reads))))
3823 (when gnus-tmp-header
3824 ;; We may have an old dummy line to output before this
3826 (when (and gnus-tmp-dummy-line
3829 (mail-header-subject gnus-tmp-header)))
3830 (gnus-summary-insert-dummy-line
3831 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3832 (setq gnus-tmp-dummy-line nil))
3834 ;; Compute the mark.
3835 (setq gnus-tmp-unread (gnus-article-mark number))
3837 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3838 gnus-tmp-header gnus-tmp-level)
3839 gnus-newsgroup-data)
3841 ;; Actually insert the line.
3843 gnus-tmp-subject-or-nil
3845 ((and gnus-thread-ignore-subject
3846 gnus-tmp-prev-subject
3847 (not (inline (gnus-subject-equal
3848 gnus-tmp-prev-subject subject))))
3850 ((zerop gnus-tmp-level)
3851 (if (and (eq gnus-summary-make-false-root 'empty)
3852 (memq number gnus-tmp-gathered)
3853 gnus-tmp-prev-subject
3854 (inline (gnus-subject-equal
3855 gnus-tmp-prev-subject subject)))
3856 gnus-summary-same-subject
3858 (t gnus-summary-same-subject)))
3859 (if (and (eq gnus-summary-make-false-root 'adopt)
3860 (= gnus-tmp-level 1)
3861 (memq number gnus-tmp-gathered))
3862 (setq gnus-tmp-opening-bracket ?\<
3863 gnus-tmp-closing-bracket ?\>)
3864 (setq gnus-tmp-opening-bracket ?\[
3865 gnus-tmp-closing-bracket ?\]))
3867 gnus-tmp-indentation
3868 (aref gnus-thread-indent-array gnus-tmp-level)
3869 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3870 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3871 gnus-summary-default-score 0)
3873 (if (or (null gnus-summary-default-score)
3874 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3875 gnus-summary-zcore-fuzz))
3877 (if (< gnus-tmp-score gnus-summary-default-score)
3878 gnus-score-below-mark gnus-score-over-mark))
3880 (cond ((memq number gnus-newsgroup-processable)
3882 ((memq number gnus-newsgroup-cached)
3884 ((memq number gnus-newsgroup-replied)
3886 ((memq number gnus-newsgroup-saved)
3888 (t gnus-unread-mark))
3889 gnus-tmp-from (mail-header-from gnus-tmp-header)
3892 ((string-match "<[^>]+> *$" gnus-tmp-from)
3893 (setq beg-match (match-beginning 0))
3894 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3895 (substring gnus-tmp-from (1+ (match-beginning 0))
3896 (1- (match-end 0))))
3897 (substring gnus-tmp-from 0 beg-match)))
3898 ((string-match "(.+)" gnus-tmp-from)
3899 (substring gnus-tmp-from
3900 (1+ (match-beginning 0)) (1- (match-end 0))))
3902 (when (string= gnus-tmp-name "")
3903 (setq gnus-tmp-name gnus-tmp-from))
3904 (unless (numberp gnus-tmp-lines)
3905 (setq gnus-tmp-lines 0))
3906 (gnus-put-text-property
3908 (progn (eval gnus-summary-line-format-spec) (point))
3909 'gnus-number number)
3912 (gnus-run-hooks 'gnus-summary-update-hook)
3915 (setq gnus-tmp-prev-subject subject)))
3917 (when (nth 1 thread)
3918 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3919 (incf gnus-tmp-level)
3920 (setq threads (if thread-end nil (cdar thread)))
3922 (setq gnus-tmp-level 0)))))
3923 (gnus-message 7 "Generating summary...done"))
3925 (defun gnus-summary-prepare-unthreaded (headers)
3926 "Generate an unthreaded summary buffer based on HEADERS."
3927 (let (header number mark)
3932 ;; We may have to root out some bad articles...
3933 (when (memq (setq number (mail-header-number
3934 (setq header (pop headers))))
3935 gnus-newsgroup-limit)
3936 ;; Mark article as read when it has a low score.
3937 (when (and gnus-summary-mark-below
3938 (< (or (cdr (assq number gnus-newsgroup-scored))
3939 gnus-summary-default-score 0)
3940 gnus-summary-mark-below)
3941 (not (gnus-summary-article-ancient-p number)))
3942 (setq gnus-newsgroup-unreads
3943 (delq number gnus-newsgroup-unreads))
3944 (if gnus-newsgroup-auto-expire
3945 (push number gnus-newsgroup-expirable)
3946 (push (cons number gnus-low-score-mark)
3947 gnus-newsgroup-reads)))
3949 (setq mark (gnus-article-mark number))
3950 (push (gnus-data-make number mark (1+ (point)) header 0)
3951 gnus-newsgroup-data)
3952 (gnus-summary-insert-line
3954 mark (memq number gnus-newsgroup-replied)
3955 (memq number gnus-newsgroup-expirable)
3956 (mail-header-subject header) nil
3957 (cdr (assq number gnus-newsgroup-scored))
3958 (memq number gnus-newsgroup-processable))))))
3960 (defun gnus-select-newsgroup (group &optional read-all select-articles)
3961 "Select newsgroup GROUP.
3962 If READ-ALL is non-nil, all articles in the group are selected.
3963 If SELECT-ARTICLES, only select those articles from GROUP."
3964 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3965 ;;!!! Dirty hack; should be removed.
3966 (gnus-summary-ignore-duplicates
3967 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
3969 gnus-summary-ignore-duplicates))
3970 (info (nth 2 entry))
3971 articles fetched-articles cached)
3973 (unless (gnus-check-server
3974 (setq gnus-current-select-method
3975 (gnus-find-method-for-group group)))
3976 (error "Couldn't open server"))
3978 (or (and entry (not (eq (car entry) t))) ; Either it's active...
3979 (gnus-activate-group group) ; Or we can activate it...
3980 (progn ; Or we bug out.
3981 (when (equal major-mode 'gnus-summary-mode)
3982 (kill-buffer (current-buffer)))
3983 (error "Couldn't request group %s: %s"
3984 group (gnus-status-message group))))
3986 (unless (gnus-request-group group t)
3987 (when (equal major-mode 'gnus-summary-mode)
3988 (kill-buffer (current-buffer)))
3989 (error "Couldn't request group %s: %s"
3990 group (gnus-status-message group)))
3992 (setq gnus-newsgroup-name group)
3993 (setq gnus-newsgroup-unselected nil)
3994 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
3995 (gnus-summary-setup-default-charset)
3997 ;; Adjust and set lists of article marks.
3999 (gnus-adjust-marked-articles info))
4001 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4003 (if (gnus-virtual-group-p group)
4004 gnus-newsgroup-cached
4005 (gnus-cache-articles-in-group group)))
4007 (setq gnus-newsgroup-unreads
4008 (gnus-set-difference
4009 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4010 gnus-newsgroup-dormant))
4012 (setq gnus-newsgroup-processable nil)
4014 (gnus-update-read-articles group gnus-newsgroup-unreads)
4016 (if (setq articles select-articles)
4017 (setq gnus-newsgroup-unselected
4018 (gnus-sorted-intersection
4019 gnus-newsgroup-unreads
4020 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4021 (setq articles (gnus-articles-to-read group read-all)))
4025 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4027 ((eq articles 0) nil)
4029 ;; Init the dependencies hash table.
4030 (setq gnus-newsgroup-dependencies
4031 (gnus-make-hashtable (length articles)))
4032 (gnus-set-global-variables)
4033 ;; Retrieve the headers and read them in.
4034 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
4035 (setq gnus-newsgroup-headers
4036 (gnus-retrieve-parsed-headers
4037 articles gnus-newsgroup-name
4038 ;; We might want to fetch old headers, but
4039 ;; not if there is only 1 article.
4040 (and (or (and (not (eq gnus-fetch-old-headers 'some))
4041 (not (numberp gnus-fetch-old-headers)))
4042 (> (length articles) 1))
4043 gnus-fetch-old-headers)))
4044 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
4046 ;; Suppress duplicates?
4047 (when gnus-suppress-duplicates
4048 (gnus-dup-suppress-articles))
4050 ;; Set the initial limit.
4051 (setq gnus-newsgroup-limit (copy-sequence articles))
4052 ;; Remove canceled articles from the list of unread articles.
4053 (setq gnus-newsgroup-unreads
4054 (gnus-set-sorted-intersection
4055 gnus-newsgroup-unreads
4056 (setq fetched-articles
4057 (mapcar (lambda (headers) (mail-header-number headers))
4058 gnus-newsgroup-headers))))
4059 ;; Removed marked articles that do not exist.
4060 (gnus-update-missing-marks
4061 (gnus-sorted-complement fetched-articles articles))
4063 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4065 (setq gnus-newsgroup-cached cached))
4067 ;; We might want to build some more threads first.
4068 (when (and gnus-fetch-old-headers
4069 (eq gnus-headers-retrieved-by 'nov))
4070 (if (eq gnus-fetch-old-headers 'invisible)
4071 (gnus-build-all-threads)
4072 (gnus-build-old-threads)))
4073 ;; Let the Gnus agent mark articles as read.
4075 (gnus-agent-get-undownloaded-list))
4076 ;; Check whether auto-expire is to be done in this group.
4077 (setq gnus-newsgroup-auto-expire
4078 (gnus-group-auto-expirable-p group))
4079 ;; Set up the article buffer now, if necessary.
4080 (unless gnus-single-article-buffer
4081 (gnus-article-setup-buffer))
4082 ;; First and last article in this newsgroup.
4083 (when gnus-newsgroup-headers
4084 (setq gnus-newsgroup-begin
4085 (mail-header-number (car gnus-newsgroup-headers))
4088 (gnus-last-element gnus-newsgroup-headers))))
4089 ;; GROUP is successfully selected.
4090 (or gnus-newsgroup-headers t)))))
4092 (defun gnus-articles-to-read (group &optional read-all)
4093 ;; Find out what articles the user wants to read.
4095 ;; Select all articles if `read-all' is non-nil, or if there
4096 ;; are no unread articles.
4098 (and (zerop (length gnus-newsgroup-marked))
4099 (zerop (length gnus-newsgroup-unreads)))
4100 (eq (gnus-group-find-parameter group 'display)
4102 (gnus-uncompress-range (gnus-active group))
4103 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4104 (copy-sequence gnus-newsgroup-unreads))
4106 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4107 (scored (length scored-list))
4108 (number (length articles))
4109 (marked (+ (length gnus-newsgroup-marked)
4110 (length gnus-newsgroup-dormant)))
4118 ((and (or (<= scored marked) (= scored number))
4119 (natnump gnus-large-newsgroup)
4120 (> number gnus-large-newsgroup))
4121 (let* ((minibuffer-setup-hook (append
4122 minibuffer-setup-hook
4123 '(beginning-of-line)))
4126 "How many articles from %s (max %d): "
4127 (gnus-limit-string gnus-newsgroup-name 35)
4129 (number-to-string gnus-large-newsgroup))))
4130 (if (string-match "^[ \t]*$" input)
4133 ((and (> scored marked) (< scored number)
4134 (> (- scored number) 20))
4137 (format "%s %s (%d scored, %d total): "
4138 "How many articles from"
4139 group scored number))))
4140 (if (string-match "^[ \t]*$" input)
4144 (setq select (if (stringp select) (string-to-number select) select))
4145 (if (or (null select) (zerop select))
4147 (if (and (not (zerop scored)) (<= (abs select) scored))
4149 (setq articles (sort scored-list '<))
4150 (setq number (length articles)))
4151 (setq articles (copy-sequence articles)))
4153 (when (< (abs select) number)
4155 ;; Select the N oldest articles.
4156 (setcdr (nthcdr (1- (abs select)) articles) nil)
4157 ;; Select the N most recent articles.
4158 (setq articles (nthcdr (- number select) articles))))
4159 (setq gnus-newsgroup-unselected
4160 (gnus-sorted-intersection
4161 gnus-newsgroup-unreads
4162 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4165 (defun gnus-killed-articles (killed articles)
4168 (when (inline (gnus-member-of-range (car articles) killed))
4169 (push (car articles) out))
4170 (setq articles (cdr articles)))
4173 (defun gnus-uncompress-marks (marks)
4174 "Uncompress the mark ranges in MARKS."
4175 (let ((uncompressed '(score bookmark))
4178 (if (memq (caar marks) uncompressed)
4179 (push (car marks) out)
4180 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4181 (setq marks (cdr marks)))
4184 (defun gnus-adjust-marked-articles (info)
4185 "Set all article lists and remove all marks that are no longer valid."
4186 (let* ((marked-lists (gnus-info-marks info))
4187 (active (gnus-active (gnus-info-group info)))
4190 (types gnus-article-mark-lists)
4191 (uncompressed '(score bookmark killed))
4192 marks var articles article mark)
4195 (setq marks (pop marked-lists))
4196 (set (setq var (intern (format "gnus-newsgroup-%s"
4197 (car (rassq (setq mark (car marks))
4199 (if (memq (car marks) uncompressed) (cdr marks)
4200 (gnus-uncompress-range (cdr marks))))
4202 (setq articles (symbol-value var))
4204 ;; All articles have to be subsets of the active articles.
4206 ;; Adjust "simple" lists.
4207 ((memq mark '(tick dormant expire reply save))
4209 (when (or (< (setq article (pop articles)) min) (> article max))
4210 (set var (delq article (symbol-value var))))))
4212 ((memq mark uncompressed)
4213 (when (not (listp (cdr (symbol-value var))))
4214 (set var (list (symbol-value var))))
4215 (when (not (listp (cdr articles)))
4216 (setq articles (list articles)))
4218 (when (or (not (consp (setq article (pop articles))))
4219 (< (car article) min)
4220 (> (car article) max))
4221 (set var (delq article (symbol-value var))))))))))
4223 (defun gnus-update-missing-marks (missing)
4224 "Go through the list of MISSING articles and remove them from the mark lists."
4226 (let ((types gnus-article-mark-lists)
4228 ;; Go through all types.
4230 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4231 (when (symbol-value var)
4232 ;; This list has articles. So we delete all missing articles
4236 (set var (delq (pop m) (symbol-value var)))))))))
4238 (defun gnus-update-marks ()
4239 "Enter the various lists of marked articles into the newsgroup info list."
4240 (let ((types gnus-article-mark-lists)
4241 (info (gnus-get-info gnus-newsgroup-name))
4242 (uncompressed '(score bookmark killed))
4243 type list newmarked symbol delta-marks)
4245 ;; Add all marks lists to the list of marks lists.
4246 (while (setq type (pop types))
4247 (setq list (symbol-value
4249 (intern (format "gnus-newsgroup-%s"
4253 ;; Get rid of the entries of the articles that have the
4255 (when (and (eq (cdr type) 'score)
4259 (prev (cons nil list))
4262 (if (or (not (consp (car arts)))
4263 (= (cdar arts) gnus-summary-default-score))
4264 (setcdr prev (cdr arts))
4266 (setq arts (cdr arts)))
4267 (setq list (cdr all)))))
4269 (or (memq (cdr type) uncompressed)
4270 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
4272 (when (gnus-check-backend-function 'request-set-mark
4273 gnus-newsgroup-name)
4274 ;; uncompressed:s are not proper flags (they are cons cells)
4275 ;; cache is a internal gnus flag
4276 (unless (memq (cdr type) (cons 'cache uncompressed))
4277 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4278 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
4279 (add (gnus-remove-from-range (gnus-copy-sequence list) old)))
4281 (push (list add 'add (list (cdr type))) delta-marks))
4283 (push (list del 'del (list (cdr type))) delta-marks)))))
4286 (push (cons (cdr type) list) newmarked)))
4289 (unless (gnus-check-group gnus-newsgroup-name)
4290 (error "Can't open server for %s" gnus-newsgroup-name))
4291 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4293 ;; Enter these new marks into the info of the group.
4295 (setcar (nthcdr 3 info) newmarked)
4296 ;; Add the marks lists to the end of the info.
4298 (setcdr (nthcdr 2 info) (list newmarked))))
4300 ;; Cut off the end of the info if there's nothing else there.
4304 (when (nthcdr (decf i) info)
4305 (setcdr (nthcdr i info) nil)))))))
4307 (defun gnus-set-mode-line (where)
4308 "This function sets the mode line of the article or summary buffers.
4309 If WHERE is `summary', the summary mode line format will be used."
4310 ;; Is this mode line one we keep updated?
4311 (when (and (memq where gnus-updated-mode-lines)
4313 (intern (format "gnus-%s-mode-line-format-spec" where))))
4316 ;; We evaluate this in the summary buffer since these
4317 ;; variables are buffer-local to that buffer.
4318 (set-buffer gnus-summary-buffer)
4319 ;; We bind all these variables that are used in the `eval' form
4321 (let* ((mformat (symbol-value
4323 (format "gnus-%s-mode-line-format-spec" where))))
4324 (gnus-tmp-group-name gnus-newsgroup-name)
4325 (gnus-tmp-article-number (or gnus-current-article 0))
4326 (gnus-tmp-unread gnus-newsgroup-unreads)
4327 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4328 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4329 (gnus-tmp-unread-and-unselected
4330 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4331 (zerop gnus-tmp-unselected))
4333 ((zerop gnus-tmp-unselected)
4334 (format "{%d more}" gnus-tmp-unread-and-unticked))
4335 (t (format "{%d(+%d) more}"
4336 gnus-tmp-unread-and-unticked
4337 gnus-tmp-unselected))))
4339 (if (and gnus-current-headers
4340 (vectorp gnus-current-headers))
4341 (gnus-mode-string-quote
4342 (mail-header-subject gnus-current-headers))
4344 bufname-length max-len
4345 gnus-tmp-header);; passed as argument to any user-format-funcs
4346 (setq mode-string (eval mformat))
4347 (setq bufname-length (if (string-match "%b" mode-string)
4350 (if (eq where 'summary)
4352 (get-buffer gnus-article-buffer))))
4355 (setq max-len (max 4 (if gnus-mode-non-string-length
4357 gnus-mode-non-string-length
4359 (length mode-string))))
4360 ;; We might have to chop a bit of the string off...
4361 (when (> (length mode-string) max-len)
4363 (concat (gnus-truncate-string mode-string (- max-len 3))
4365 ;; Pad the mode string a bit.
4366 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4367 ;; Update the mode line.
4368 (setq mode-line-buffer-identification
4369 (gnus-mode-line-buffer-identification (list mode-string)))
4370 (set-buffer-modified-p t))))
4372 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4373 "Go through the HEADERS list and add all Xrefs to a hash table.
4374 The resulting hash table is returned, or nil if no Xrefs were found."
4375 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4376 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4377 (xref-hashtb (gnus-make-hashtable))
4378 start group entry number xrefs header)
4380 (setq header (pop headers))
4381 (when (and (setq xrefs (mail-header-xref header))
4382 (not (memq (setq number (mail-header-number header))
4385 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4386 (setq start (match-end 0))
4387 (setq group (if prefix
4388 (concat prefix (substring xrefs (match-beginning 1)
4390 (substring xrefs (match-beginning 1) (match-end 1))))
4392 (string-to-int (substring xrefs (match-beginning 2)
4394 (if (setq entry (gnus-gethash group xref-hashtb))
4395 (setcdr entry (cons number (cdr entry)))
4396 (gnus-sethash group (cons number nil) xref-hashtb)))))
4397 (and start xref-hashtb)))
4399 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4400 "Look through all the headers and mark the Xrefs as read."
4401 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4402 name entry info xref-hashtb idlist method nth4)
4404 (set-buffer gnus-group-buffer)
4405 (when (setq xref-hashtb
4406 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4409 (unless (string= from-newsgroup (setq name (symbol-name group)))
4410 (setq idlist (symbol-value group))
4411 ;; Dead groups are not updated.
4413 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4415 (when (stringp (setq nth4 (gnus-info-method info)))
4416 (setq nth4 (gnus-server-to-method nth4))))
4417 ;; Only do the xrefs if the group has the same
4418 ;; select method as the group we have just read.
4419 (or (gnus-methods-equal-p
4420 nth4 (gnus-find-method-for-group from-newsgroup))
4422 (equal nth4 (setq method (gnus-find-method-for-group
4424 (and (equal (car nth4) (car method))
4425 (equal (nth 1 nth4) (nth 1 method))))
4426 gnus-use-cross-reference
4427 (or (not (eq gnus-use-cross-reference t))
4429 ;; Only do cross-references on subscribed
4430 ;; groups, if that is what is wanted.
4431 (<= (gnus-info-level info) gnus-level-subscribed))
4432 (gnus-group-make-articles-read name idlist))))
4435 (defun gnus-compute-read-articles (group articles)
4436 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4437 (info (nth 2 entry))
4438 (active (gnus-active group))
4441 ;; First peel off all invalid article numbers.
4443 (let ((ids articles)
4445 (while (setq id (pop ids))
4446 (when (and first (> id (cdr active)))
4447 ;; We'll end up in this situation in one particular
4448 ;; obscure situation. If you re-scan a group and get
4449 ;; a new article that is cross-posted to a different
4450 ;; group that has not been re-scanned, you might get
4451 ;; crossposted article that has a higher number than
4452 ;; Gnus believes possible. So we re-activate this
4453 ;; group as well. This might mean doing the
4454 ;; crossposting thingy will *increase* the number
4455 ;; of articles in some groups. Tsk, tsk.
4456 (setq active (or (gnus-activate-group group) active)))
4457 (when (or (> id (cdr active))
4458 (< id (car active)))
4459 (setq articles (delq id articles))))))
4460 ;; If the read list is nil, we init it.
4462 (null (gnus-info-read info))
4464 (setq ninfo (cons 1 (1- (car active))))
4465 (setq ninfo (gnus-info-read info)))
4466 ;; Then we add the read articles to the range.
4468 ninfo (setq articles (sort articles '<))))))
4470 (defun gnus-group-make-articles-read (group articles)
4471 "Update the info of GROUP to say that ARTICLES are read."
4473 (entry (gnus-gethash group gnus-newsrc-hashtb))
4474 (info (nth 2 entry))
4475 (active (gnus-active group))
4478 (setq range (gnus-compute-read-articles group articles))
4480 (set-buffer gnus-group-buffer)
4483 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4484 (gnus-info-set-read ',info ',(gnus-info-read info))
4485 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4486 (gnus-group-update-group ,group t))))
4487 ;; Add the read articles to the range.
4488 (gnus-info-set-read info range)
4489 ;; Then we have to re-compute how many unread
4490 ;; articles there are in this group.
4494 (setq num (- (1+ (cdr active)) (car active))))
4495 ((not (listp (cdr range)))
4496 (setq num (- (cdr active) (- (1+ (cdr range))
4500 (if (numberp (car range))
4502 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4503 (setq range (cdr range)))
4504 (setq num (- (cdr active) num))))
4505 ;; Update the number of unread articles.
4507 ;; Update the group buffer.
4508 (gnus-group-update-group group t)))))
4510 (defvar gnus-newsgroup-none-id 0)
4512 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4513 (let ((cur nntp-server-buffer)
4516 (save-excursion (set-buffer gnus-summary-buffer)
4517 gnus-newsgroup-dependencies)))
4519 (mail-parse-charset gnus-newsgroup-charset))
4521 (set-buffer nntp-server-buffer)
4522 ;; Translate all TAB characters into SPACE characters.
4523 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4524 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4525 (gnus-run-hooks 'gnus-parse-headers-hook)
4526 (let ((case-fold-search t)
4527 in-reply-to header p lines chars ctype)
4528 (goto-char (point-min))
4529 ;; Search to the beginning of the next header. Error messages
4530 ;; do not begin with 2 or 3.
4531 (while (re-search-forward "^[23][0-9]+ " nil t)
4534 ;; This implementation of this function, with nine
4535 ;; search-forwards instead of the one re-search-forward and
4536 ;; a case (which basically was the old function) is actually
4537 ;; about twice as fast, even though it looks messier. You
4538 ;; can't have everything, I guess. Speed and elegance
4539 ;; doesn't always go hand in hand.
4542 (make-full-mail-header
4548 (narrow-to-region (point)
4549 (or (and (search-forward "\n.\n" nil t)
4555 (if (search-forward "\nsubject: " nil t)
4556 (buffer-substring (match-end 0) (std11-field-end))
4561 (if (search-forward "\nfrom: " nil t)
4562 (buffer-substring (match-end 0) (std11-field-end))
4567 (if (search-forward "\ndate: " nil t)
4568 (buffer-substring (match-end 0) (std11-field-end))
4573 (setq id (if (re-search-forward
4574 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4575 ;; We do it this way to make sure the Message-ID
4576 ;; is (somewhat) syntactically valid.
4577 (buffer-substring (match-beginning 1)
4579 ;; If there was no message-id, we just fake one
4580 ;; to make subsequent routines simpler.
4581 (nnheader-generate-fake-message-id))))
4585 (if (search-forward "\nreferences: " nil t)
4589 (buffer-substring (match-end 0) (std11-field-end))
4594 (search-backward ">" end t)
4597 (search-backward "<" end t)
4599 ;; Get the references from the in-reply-to header if there
4600 ;; were no references and the in-reply-to header looks
4602 (if (and (search-forward "\nin-reply-to: " nil t)
4604 (buffer-substring (match-end 0)
4606 (string-match "<[^>]+>" in-reply-to))
4608 (setq ref (substring in-reply-to (match-beginning 0)
4610 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4611 (setq ref2 (substring in-reply-to (match-beginning 0)
4613 (when (> (length ref2) (length ref))
4620 (if (search-forward "\nchars: " nil t)
4621 (if (numberp (setq chars (ignore-errors (read cur))))
4627 (if (search-forward "\nlines: " nil t)
4628 (if (numberp (setq lines (ignore-errors (read cur))))
4634 (and (search-forward "\nxref: " nil t)
4635 (buffer-substring (match-end 0) (std11-field-end))))
4637 (when gnus-extra-headers
4638 (let ((extra gnus-extra-headers)
4642 (when (search-forward
4643 (concat "\n" (symbol-name (car extra)) ": ") nil t)
4644 (push (cons (car extra)
4645 (buffer-substring (match-end 0)
4651 (if (and (search-forward "\ncontent-type: " nil t)
4653 (buffer-substring (match-end 0) (std11-field-end))))
4654 (mime-entity-set-content-type-internal
4655 header (mime-parse-Content-Type ctype)))
4656 (when (equal id ref)
4659 (when gnus-alter-header-function
4660 (funcall gnus-alter-header-function header)
4661 (setq id (mail-header-id header)
4662 ref (gnus-parent-id (mail-header-references header))))
4665 (gnus-dependencies-add-header
4666 header dependencies force-new))
4667 (push header headers))
4668 (goto-char (point-max))
4670 (nreverse headers)))))
4672 ;; Goes through the xover lines and returns a list of vectors
4673 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4674 force-new dependencies
4675 group also-fetch-heads)
4676 "Parse the news overview data in the server buffer, and return a
4677 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4678 ;; Get the Xref when the users reads the articles since most/some
4679 ;; NNTP servers do not include Xrefs when using XOVER.
4680 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4681 (let ((mail-parse-charset gnus-newsgroup-charset)
4682 (cur nntp-server-buffer)
4683 (dependencies (or dependencies gnus-newsgroup-dependencies))
4684 number headers header)
4686 (set-buffer nntp-server-buffer)
4687 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4688 ;; Allow the user to mangle the headers before parsing them.
4689 (gnus-run-hooks 'gnus-parse-headers-hook)
4690 (goto-char (point-min))
4693 (while (and sequence (not (eobp)))
4694 (setq number (read cur))
4695 (while (and sequence
4696 (< (car sequence) number))
4697 (setq sequence (cdr sequence)))
4699 (eq number (car sequence))
4701 (setq sequence (cdr sequence))
4702 (setq header (inline
4703 (gnus-nov-parse-line
4704 number dependencies force-new))))
4705 (push header headers))
4708 (gnus-error 4 "Strange nov line (%d)"
4709 (count-lines (point-min) (point)))))
4711 ;; A common bug in inn is that if you have posted an article and
4712 ;; then retrieves the active file, it will answer correctly --
4713 ;; the new article is included. However, a NOV entry for the
4714 ;; article may not have been generated yet, so this may fail.
4715 ;; We work around this problem by retrieving the last few
4716 ;; headers using HEAD.
4717 (if (or (not also-fetch-heads)
4719 ;; We (probably) got all the headers.
4721 (let ((gnus-nov-is-evil t))
4724 (gnus-retrieve-parsed-headers sequence group)
4727 (defun gnus-article-get-xrefs ()
4728 "Fill in the Xref value in `gnus-current-headers', if necessary.
4729 This is meant to be called in `gnus-article-internal-prepare-hook'."
4730 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4731 gnus-current-headers)))
4732 (or (not gnus-use-cross-reference)
4734 (and (mail-header-xref headers)
4735 (not (string= (mail-header-xref headers) "")))
4736 (let ((case-fold-search t)
4739 (nnheader-narrow-to-headers)
4740 (goto-char (point-min))
4741 (when (or (and (eq (downcase (char-after)) ?x)
4742 (looking-at "Xref:"))
4743 (search-forward "\nXref:" nil t))
4744 (goto-char (1+ (match-end 0)))
4745 (setq xref (buffer-substring (point)
4746 (progn (end-of-line) (point))))
4747 (mail-header-set-xref headers xref)))))))
4749 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4750 "Find article ID and insert the summary line for that article.
4751 OLD-HEADER can either be a header or a line number to insert
4752 the subject line on."
4753 (let* ((line (and (numberp old-header) old-header))
4754 (old-header (and (vectorp old-header) old-header))
4755 (header (cond ((and old-header use-old-header)
4758 (gnus-number-to-header id))
4759 (gnus-number-to-header id))
4761 (gnus-read-header id))))
4762 (number (and (numberp id) id))
4765 ;; Rebuild the thread that this article is part of and go to the
4766 ;; article we have fetched.
4767 (when (and (not gnus-show-threads)
4770 (setq d (gnus-data-find (mail-header-number old-header))))
4771 (goto-char (gnus-data-pos d))
4774 (- (gnus-point-at-bol)
4776 (1+ (gnus-point-at-eol))
4777 (gnus-delete-line))))))
4779 (mail-header-set-number header (mail-header-number old-header)))
4780 (setq gnus-newsgroup-sparse
4781 (delq (setq number (mail-header-number header))
4782 gnus-newsgroup-sparse))
4783 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4784 (push number gnus-newsgroup-limit)
4785 (gnus-rebuild-thread (mail-header-id header) line)
4786 (gnus-summary-goto-subject number nil t))
4787 (when (and (numberp number)
4789 ;; We have to update the boundaries even if we can't fetch the
4790 ;; article if ID is a number -- so that the next `P' or `N'
4791 ;; command will fetch the previous (or next) article even
4792 ;; if the one we tried to fetch this time has been canceled.
4793 (when (> number gnus-newsgroup-end)
4794 (setq gnus-newsgroup-end number))
4795 (when (< number gnus-newsgroup-begin)
4796 (setq gnus-newsgroup-begin number))
4797 (setq gnus-newsgroup-unselected
4798 (delq number gnus-newsgroup-unselected)))
4799 ;; Report back a success?
4800 (and header (mail-header-number header))))
4802 ;;; Process/prefix in the summary buffer
4804 (defun gnus-summary-work-articles (n)
4805 "Return a list of articles to be worked upon.
4806 The prefix argument, the list of process marked articles, and the
4807 current article will be taken into consideration."
4809 (set-buffer gnus-summary-buffer)
4812 ;; A numerical prefix has been given.
4813 (setq n (prefix-numeric-value n))
4814 (let ((backward (< n 0))
4815 (n (abs (prefix-numeric-value n)))
4820 (push (setq article (gnus-summary-article-number))
4823 (gnus-summary-find-prev nil article)
4824 (gnus-summary-find-next nil article)))
4826 (nreverse articles)))
4827 ((and (gnus-region-active-p) (mark))
4828 (message "region active")
4829 ;; Work on the region between point and mark.
4830 (let ((max (max (point) (mark)))
4833 (goto-char (min (point) (mark)))
4836 (push (setq article (gnus-summary-article-number)) articles)
4837 (gnus-summary-find-next nil article)
4839 (nreverse articles))))
4840 (gnus-newsgroup-processable
4841 ;; There are process-marked articles present.
4842 ;; Save current state.
4843 (gnus-summary-save-process-mark)
4845 (reverse gnus-newsgroup-processable))
4847 ;; Just return the current article.
4848 (list (gnus-summary-article-number))))))
4850 (defmacro gnus-summary-iterate (arg &rest forms)
4851 "Iterate over the process/prefixed articles and do FORMS.
4852 ARG is the interactive prefix given to the command. FORMS will be
4853 executed with point over the summary line of the articles."
4854 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
4855 `(let ((,articles (gnus-summary-work-articles ,arg)))
4857 (gnus-summary-goto-subject (car ,articles))
4861 (put 'gnus-summary-iterate 'lisp-indent-function 1)
4862 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
4864 (defun gnus-summary-save-process-mark ()
4865 "Push the current set of process marked articles on the stack."
4867 (push (copy-sequence gnus-newsgroup-processable)
4868 gnus-newsgroup-process-stack))
4870 (defun gnus-summary-kill-process-mark ()
4871 "Push the current set of process marked articles on the stack and unmark."
4873 (gnus-summary-save-process-mark)
4874 (gnus-summary-unmark-all-processable))
4876 (defun gnus-summary-yank-process-mark ()
4877 "Pop the last process mark state off the stack and restore it."
4879 (unless gnus-newsgroup-process-stack
4880 (error "Empty mark stack"))
4881 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4883 (defun gnus-summary-process-mark-set (set)
4884 "Make SET into the current process marked articles."
4885 (gnus-summary-unmark-all-processable)
4887 (gnus-summary-set-process-mark (pop set))))
4889 ;;; Searching and stuff
4891 (defun gnus-summary-search-group (&optional backward use-level)
4892 "Search for next unread newsgroup.
4893 If optional argument BACKWARD is non-nil, search backward instead."
4895 (set-buffer gnus-group-buffer)
4896 (when (gnus-group-search-forward
4897 backward nil (if use-level (gnus-group-group-level) nil))
4898 (gnus-group-group-name))))
4900 (defun gnus-summary-best-group (&optional exclude-group)
4901 "Find the name of the best unread group.
4902 If EXCLUDE-GROUP, do not go to this group."
4904 (set-buffer gnus-group-buffer)
4906 (gnus-group-best-unread-group exclude-group))))
4908 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
4909 (if backward (gnus-summary-find-prev)
4910 (let* ((dummy (gnus-summary-article-intangible-p))
4911 (article (or article (gnus-summary-article-number)))
4912 (arts (gnus-data-find-list article))
4914 (when (and (not dummy)
4915 (or (not gnus-summary-check-current)
4917 (not (gnus-data-unread-p (car arts)))))
4918 (setq arts (cdr arts)))
4923 (when (or (and undownloaded
4924 (eq gnus-undownloaded-mark
4925 (gnus-data-mark (car arts))))
4926 (gnus-data-unread-p (car arts)))
4927 (setq result (car arts)
4929 (setq arts (cdr arts)))
4932 (goto-char (gnus-data-pos result))
4933 (gnus-data-number result)))))
4935 (defun gnus-summary-find-prev (&optional unread article)
4936 (let* ((eobp (eobp))
4937 (article (or article (gnus-summary-article-number)))
4938 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
4940 (when (and (not eobp)
4941 (or (not gnus-summary-check-current)
4943 (not (gnus-data-unread-p (car arts)))))
4944 (setq arts (cdr arts)))
4949 (when (gnus-data-unread-p (car arts))
4950 (setq result (car arts)
4952 (setq arts (cdr arts)))
4955 (goto-char (gnus-data-pos result))
4956 (gnus-data-number result))))
4958 (defun gnus-summary-find-subject (subject &optional unread backward article)
4959 (let* ((simp-subject (gnus-simplify-subject-fully subject))
4960 (article (or article (gnus-summary-article-number)))
4961 (articles (gnus-data-list backward))
4962 (arts (gnus-data-find-list article articles))
4964 (when (or (not gnus-summary-check-current)
4966 (not (gnus-data-unread-p (car arts))))
4967 (setq arts (cdr arts)))
4969 (and (or (not unread)
4970 (gnus-data-unread-p (car arts)))
4971 (vectorp (gnus-data-header (car arts)))
4973 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
4974 (setq result (car arts)
4976 (setq arts (cdr arts)))
4978 (goto-char (gnus-data-pos result))
4979 (gnus-data-number result))))
4981 (defun gnus-summary-search-forward (&optional unread subject backward)
4982 "Search forward for an article.
4983 If UNREAD, look for unread articles. If SUBJECT, look for
4984 articles with that subject. If BACKWARD, search backward instead."
4985 (cond (subject (gnus-summary-find-subject subject unread backward))
4986 (backward (gnus-summary-find-prev unread))
4987 (t (gnus-summary-find-next unread))))
4989 (defun gnus-recenter (&optional n)
4990 "Center point in window and redisplay frame.
4991 Also do horizontal recentering."
4993 (when (and gnus-auto-center-summary
4994 (not (eq gnus-auto-center-summary 'vertical)))
4995 (gnus-horizontal-recenter))
4998 (defun gnus-summary-recenter ()
4999 "Center point in the summary window.
5000 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5001 displayed, no centering will be performed."
5002 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5003 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5004 (let* ((top (cond ((< (window-height) 4) 0)
5005 ((< (window-height) 7) 1)
5006 (t (if (numberp gnus-auto-center-summary)
5007 gnus-auto-center-summary
5009 (height (1- (window-height)))
5010 (bottom (save-excursion (goto-char (point-max))
5011 (forward-line (- height))
5013 (window (get-buffer-window (current-buffer))))
5014 ;; The user has to want it.
5015 (when gnus-auto-center-summary
5016 (when (get-buffer-window gnus-article-buffer)
5017 ;; Only do recentering when the article buffer is displayed,
5018 ;; Set the window start to either `bottom', which is the biggest
5019 ;; possible valid number, or the second line from the top,
5020 ;; whichever is the least.
5022 window (min bottom (save-excursion
5023 (forward-line (- top)) (point)))))
5024 ;; Do horizontal recentering while we're at it.
5025 (when (and (get-buffer-window (current-buffer) t)
5026 (not (eq gnus-auto-center-summary 'vertical)))
5027 (let ((selected (selected-window)))
5028 (select-window (get-buffer-window (current-buffer) t))
5029 (gnus-summary-position-point)
5030 (gnus-horizontal-recenter)
5031 (select-window selected))))))
5033 (defun gnus-summary-jump-to-group (newsgroup)
5034 "Move point to NEWSGROUP in group mode buffer."
5035 ;; Keep update point of group mode buffer if visible.
5036 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5037 (save-window-excursion
5038 ;; Take care of tree window mode.
5039 (when (get-buffer-window gnus-group-buffer)
5040 (pop-to-buffer gnus-group-buffer))
5041 (gnus-group-jump-to-group newsgroup))
5043 ;; Take care of tree window mode.
5044 (if (get-buffer-window gnus-group-buffer)
5045 (pop-to-buffer gnus-group-buffer)
5046 (set-buffer gnus-group-buffer))
5047 (gnus-group-jump-to-group newsgroup))))
5049 ;; This function returns a list of article numbers based on the
5050 ;; difference between the ranges of read articles in this group and
5051 ;; the range of active articles.
5052 (defun gnus-list-of-unread-articles (group)
5053 (let* ((read (gnus-info-read (gnus-get-info group)))
5054 (active (or (gnus-active group) (gnus-activate-group group)))
5057 ;; If none are read, then all are unread.
5059 (setq first (car active))
5060 ;; If the range of read articles is a single range, then the
5061 ;; first unread article is the article after the last read
5062 ;; article. Sounds logical, doesn't it?
5063 (if (not (listp (cdr read)))
5064 (setq first (max (car active) (1+ (cdr read))))
5065 ;; `read' is a list of ranges.
5066 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5069 (setq first (car active)))
5072 (while (< first nlast)
5074 (setq first (1+ first))))
5075 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5076 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5077 (setq read (cdr read)))))
5078 ;; And add the last unread articles.
5079 (while (<= first last)
5081 (setq first (1+ first)))
5082 ;; Return the list of unread articles.
5083 (delq 0 (nreverse unread))))
5085 (defun gnus-list-of-read-articles (group)
5086 "Return a list of unread, unticked and non-dormant articles."
5087 (let* ((info (gnus-get-info group))
5088 (marked (gnus-info-marks info))
5089 (active (gnus-active group)))
5091 (gnus-set-difference
5092 (gnus-sorted-complement
5093 (gnus-uncompress-range active)
5094 (gnus-list-of-unread-articles group))
5096 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5097 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5099 ;; Various summary commands
5101 (defun gnus-summary-select-article-buffer ()
5102 "Reconfigure windows to show article buffer."
5104 (if (not (gnus-buffer-live-p gnus-article-buffer))
5105 (error "There is no article buffer for this summary buffer")
5106 (gnus-configure-windows 'article)
5107 (select-window (get-buffer-window gnus-article-buffer))))
5109 (defun gnus-summary-universal-argument (arg)
5110 "Perform any operation on all articles that are process/prefixed."
5112 (let ((articles (gnus-summary-work-articles arg))
5119 (substitute-command-keys
5120 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
5123 (gnus-error 1 "Undefined key")
5126 (gnus-summary-goto-subject (setq article (pop articles)))
5127 (let (gnus-newsgroup-processable)
5128 (command-execute func))
5129 (gnus-summary-remove-process-mark article)))))
5130 (gnus-summary-position-point))
5132 (defun gnus-summary-toggle-truncation (&optional arg)
5133 "Toggle truncation of summary lines.
5134 With arg, turn line truncation on iff arg is positive."
5136 (setq truncate-lines
5137 (if (null arg) (not truncate-lines)
5138 (> (prefix-numeric-value arg) 0)))
5141 (defun gnus-summary-reselect-current-group (&optional all rescan)
5142 "Exit and then reselect the current newsgroup.
5143 The prefix argument ALL means to select all articles."
5145 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5146 (error "Ephemeral groups can't be reselected"))
5147 (let ((current-subject (gnus-summary-article-number))
5148 (group gnus-newsgroup-name))
5149 (setq gnus-newsgroup-begin nil)
5151 ;; We have to adjust the point of group mode buffer because
5152 ;; point was moved to the next unread newsgroup by exiting.
5153 (gnus-summary-jump-to-group group)
5156 (gnus-group-get-new-news-this-group 1)))
5157 (gnus-group-read-group all t)
5158 (gnus-summary-goto-subject current-subject nil t)))
5160 (defun gnus-summary-rescan-group (&optional all)
5161 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5163 (gnus-summary-reselect-current-group all t))
5165 (defun gnus-summary-update-info (&optional non-destructive)
5167 (let ((group gnus-newsgroup-name))
5169 (when gnus-newsgroup-kill-headers
5170 (setq gnus-newsgroup-killed
5171 (gnus-compress-sequence
5173 (gnus-set-sorted-intersection
5174 (gnus-uncompress-range gnus-newsgroup-killed)
5175 (setq gnus-newsgroup-unselected
5176 (sort gnus-newsgroup-unselected '<)))
5177 (setq gnus-newsgroup-unreads
5178 (sort gnus-newsgroup-unreads '<)))
5180 (unless (listp (cdr gnus-newsgroup-killed))
5181 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5182 (let ((headers gnus-newsgroup-headers))
5183 ;; Set the new ranges of read articles.
5185 (set-buffer gnus-group-buffer)
5186 (gnus-undo-force-boundary))
5187 (gnus-update-read-articles
5188 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5189 ;; Set the current article marks.
5190 (let ((gnus-newsgroup-scored
5191 (if (and (not gnus-save-score)
5192 (not non-destructive))
5194 gnus-newsgroup-scored)))
5196 (gnus-update-marks)))
5197 ;; Do the cross-ref thing.
5198 (when gnus-use-cross-reference
5199 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5200 ;; Do not switch windows but change the buffer to work.
5201 (set-buffer gnus-group-buffer)
5202 (unless (gnus-ephemeral-group-p group)
5203 (gnus-group-update-group group)))))))
5205 (defun gnus-summary-save-newsrc (&optional force)
5206 "Save the current number of read/marked articles in the dribble buffer.
5207 The dribble buffer will then be saved.
5208 If FORCE (the prefix), also save the .newsrc file(s)."
5210 (gnus-summary-update-info t)
5212 (gnus-save-newsrc-file)
5213 (gnus-dribble-save)))
5215 (defun gnus-summary-exit (&optional temporary)
5216 "Exit reading current newsgroup, and then return to group selection mode.
5217 gnus-exit-group-hook is called with no arguments if that value is non-nil."
5219 (gnus-set-global-variables)
5220 (gnus-kill-save-kill-buffer)
5221 (gnus-async-halt-prefetch)
5222 (let* ((group gnus-newsgroup-name)
5223 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5226 (buf (current-buffer)))
5228 ;; Do adaptive scoring, and possibly save score files.
5229 (when gnus-newsgroup-adaptive
5230 (gnus-score-adaptive))
5231 (when gnus-use-scoring
5233 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5234 ;; If we have several article buffers, we kill them at exit.
5235 (unless gnus-single-article-buffer
5236 (gnus-kill-buffer gnus-original-article-buffer)
5237 (setq gnus-article-current nil))
5238 (when gnus-use-cache
5239 (gnus-cache-possibly-remove-articles)
5240 (gnus-cache-save-buffers))
5241 (gnus-async-prefetch-remove-group group)
5242 (when gnus-suppress-duplicates
5243 (gnus-dup-enter-articles))
5244 (when gnus-use-trees
5245 (gnus-tree-close group))
5246 ;; Remove entries for this group.
5247 (nnmail-purge-split-history (gnus-group-real-name group))
5248 ;; Make all changes in this group permanent.
5250 (gnus-run-hooks 'gnus-exit-group-hook)
5251 (gnus-summary-update-info))
5252 (gnus-close-group group)
5253 ;; Make sure where we were, and go to next newsgroup.
5254 (set-buffer gnus-group-buffer)
5256 (gnus-group-jump-to-group group))
5257 (gnus-run-hooks 'gnus-summary-exit-hook)
5258 (unless (or quit-config
5259 ;; If this group has disappeared from the summary
5260 ;; buffer, don't skip forwards.
5261 (not (string= group (gnus-group-group-name))))
5262 (gnus-group-next-unread-group 1))
5263 (setq group-point (point))
5266 ;; If we have several article buffers, we kill them at exit.
5267 (unless gnus-single-article-buffer
5268 (gnus-kill-buffer gnus-article-buffer)
5269 (gnus-kill-buffer gnus-original-article-buffer)
5270 (setq gnus-article-current nil))
5272 (if (not gnus-kill-summary-on-exit)
5273 (gnus-deaden-summary)
5274 ;; We set all buffer-local variables to nil. It is unclear why
5275 ;; this is needed, but if we don't, buffer-local variables are
5276 ;; not garbage-collected, it seems. This would the lead to en
5277 ;; ever-growing Emacs.
5278 (gnus-summary-clear-local-variables)
5279 (when (get-buffer gnus-article-buffer)
5280 (bury-buffer gnus-article-buffer))
5281 ;; We clear the global counterparts of the buffer-local
5282 ;; variables as well, just to be on the safe side.
5283 (set-buffer gnus-group-buffer)
5284 (gnus-summary-clear-local-variables)
5285 ;; Return to group mode buffer.
5286 (when (eq mode 'gnus-summary-mode)
5287 (gnus-kill-buffer buf)))
5288 (setq gnus-current-select-method gnus-select-method)
5289 (pop-to-buffer gnus-group-buffer)
5290 (if (not quit-config)
5292 (goto-char group-point)
5293 (gnus-configure-windows 'group 'force))
5294 (gnus-handle-ephemeral-exit quit-config))
5295 ;; Clear the current group name.
5297 (setq gnus-newsgroup-name nil)))))
5299 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5300 (defun gnus-summary-exit-no-update (&optional no-questions)
5301 "Quit reading current newsgroup without updating read article info."
5303 (let* ((group gnus-newsgroup-name)
5304 (quit-config (gnus-group-quit-config group)))
5305 (when (or no-questions
5307 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5308 (gnus-async-halt-prefetch)
5310 (delq 'gnus-summary-expire-articles
5311 (copy-list gnus-summary-prepare-exit-hook)))
5312 ;; If we have several article buffers, we kill them at exit.
5313 (unless gnus-single-article-buffer
5314 (gnus-kill-buffer gnus-article-buffer)
5315 (gnus-kill-buffer gnus-original-article-buffer)
5316 (setq gnus-article-current nil))
5317 (if (not gnus-kill-summary-on-exit)
5318 (gnus-deaden-summary)
5319 (gnus-close-group group)
5320 (gnus-summary-clear-local-variables)
5321 (set-buffer gnus-group-buffer)
5322 (gnus-summary-clear-local-variables)
5323 (when (get-buffer gnus-summary-buffer)
5324 (kill-buffer gnus-summary-buffer)))
5325 (unless gnus-single-article-buffer
5326 (setq gnus-article-current nil))
5327 (when gnus-use-trees
5328 (gnus-tree-close group))
5329 (gnus-async-prefetch-remove-group group)
5330 (when (get-buffer gnus-article-buffer)
5331 (bury-buffer gnus-article-buffer))
5332 ;; Return to the group buffer.
5333 (gnus-configure-windows 'group 'force)
5334 ;; Clear the current group name.
5335 (setq gnus-newsgroup-name nil)
5336 (when (equal (gnus-group-group-name) group)
5337 (gnus-group-next-unread-group 1))
5339 (gnus-handle-ephemeral-exit quit-config)))))
5341 (defun gnus-handle-ephemeral-exit (quit-config)
5342 "Handle movement when leaving an ephemeral group.
5343 The state which existed when entering the ephemeral is reset."
5344 (if (not (buffer-name (car quit-config)))
5345 (gnus-configure-windows 'group 'force)
5346 (set-buffer (car quit-config))
5347 (cond ((eq major-mode 'gnus-summary-mode)
5348 (gnus-set-global-variables))
5349 ((eq major-mode 'gnus-article-mode)
5351 ;; The `gnus-summary-buffer' variable may point
5352 ;; to the old summary buffer when using a single
5354 (unless (gnus-buffer-live-p gnus-summary-buffer)
5355 (set-buffer gnus-group-buffer))
5356 (set-buffer gnus-summary-buffer)
5357 (gnus-set-global-variables))))
5358 (if (or (eq (cdr quit-config) 'article)
5359 (eq (cdr quit-config) 'pick))
5361 ;; The current article may be from the ephemeral group
5362 ;; thus it is best that we reload this article
5363 (gnus-summary-show-article)
5364 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5365 (gnus-configure-windows 'pick 'force)
5366 (gnus-configure-windows (cdr quit-config) 'force)))
5367 (gnus-configure-windows (cdr quit-config) 'force))
5368 (when (eq major-mode 'gnus-summary-mode)
5369 (gnus-summary-next-subject 1 nil t)
5370 (gnus-summary-recenter)
5371 (gnus-summary-position-point))))
5373 (defun gnus-summary-preview-mime-message ()
5374 "MIME decode and play this message."
5376 (let ((gnus-break-pages nil)
5378 (gnus-summary-select-article gnus-show-all-headers t))
5379 (select-window (get-buffer-window gnus-article-buffer)))
5383 (defvar gnus-dead-summary-mode-map nil)
5385 (unless gnus-dead-summary-mode-map
5386 (setq gnus-dead-summary-mode-map (make-keymap))
5387 (suppress-keymap gnus-dead-summary-mode-map)
5388 (substitute-key-definition
5389 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5390 (let ((keys '("\C-d" "\r" "\177" [delete])))
5392 (define-key gnus-dead-summary-mode-map
5393 (pop keys) 'gnus-summary-wake-up-the-dead))))
5395 (defvar gnus-dead-summary-mode nil
5396 "Minor mode for Gnus summary buffers.")
5398 (defun gnus-dead-summary-mode (&optional arg)
5399 "Minor mode for Gnus summary buffers."
5401 (when (eq major-mode 'gnus-summary-mode)
5402 (make-local-variable 'gnus-dead-summary-mode)
5403 (setq gnus-dead-summary-mode
5404 (if (null arg) (not gnus-dead-summary-mode)
5405 (> (prefix-numeric-value arg) 0)))
5406 (when gnus-dead-summary-mode
5407 (gnus-add-minor-mode
5408 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5410 (defun gnus-deaden-summary ()
5411 "Make the current summary buffer into a dead summary buffer."
5412 ;; Kill any previous dead summary buffer.
5413 (when (and gnus-dead-summary
5414 (buffer-name gnus-dead-summary))
5416 (set-buffer gnus-dead-summary)
5417 (when gnus-dead-summary-mode
5418 (kill-buffer (current-buffer)))))
5419 ;; Make this the current dead summary.
5420 (setq gnus-dead-summary (current-buffer))
5421 (gnus-dead-summary-mode 1)
5422 (let ((name (buffer-name)))
5423 (when (string-match "Summary" name)
5425 (concat (substring name 0 (match-beginning 0)) "Dead "
5426 (substring name (match-beginning 0)))
5429 (defun gnus-kill-or-deaden-summary (buffer)
5430 "Kill or deaden the summary BUFFER."
5432 (when (and (buffer-name buffer)
5433 (not gnus-single-article-buffer))
5436 (gnus-kill-buffer gnus-article-buffer)
5437 (gnus-kill-buffer gnus-original-article-buffer)))
5438 (cond (gnus-kill-summary-on-exit
5439 (when (and gnus-use-trees
5440 (gnus-buffer-exists-p buffer))
5443 (gnus-tree-close gnus-newsgroup-name)))
5444 (gnus-kill-buffer buffer))
5445 ((gnus-buffer-exists-p buffer)
5448 (gnus-deaden-summary))))))
5450 (defun gnus-summary-wake-up-the-dead (&rest args)
5451 "Wake up the dead summary buffer."
5453 (gnus-dead-summary-mode -1)
5454 (let ((name (buffer-name)))
5455 (when (string-match "Dead " name)
5457 (concat (substring name 0 (match-beginning 0))
5458 (substring name (match-end 0)))
5460 (gnus-message 3 "This dead summary is now alive again"))
5462 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5463 (defun gnus-summary-fetch-faq (&optional faq-dir)
5464 "Fetch the FAQ for the current group.
5465 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5469 (when current-prefix-arg
5471 "Faq dir: " (and (listp gnus-group-faq-directory)
5472 (mapcar (lambda (file) (list file))
5473 gnus-group-faq-directory))))))
5474 (let (gnus-faq-buffer)
5475 (when (setq gnus-faq-buffer
5476 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5477 (gnus-configure-windows 'summary-faq))))
5479 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5480 (defun gnus-summary-describe-group (&optional force)
5481 "Describe the current newsgroup."
5483 (gnus-group-describe-group force gnus-newsgroup-name))
5485 (defun gnus-summary-describe-briefly ()
5486 "Describe summary mode commands briefly."
5488 (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")))
5490 ;; Walking around group mode buffer from summary mode.
5492 (defun gnus-summary-next-group (&optional no-article target-group backward)
5493 "Exit current newsgroup and then select next unread newsgroup.
5494 If prefix argument NO-ARTICLE is non-nil, no article is selected
5495 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5496 previous group instead."
5498 ;; Stop pre-fetching.
5499 (gnus-async-halt-prefetch)
5500 (let ((current-group gnus-newsgroup-name)
5501 (current-buffer (current-buffer))
5503 ;; First we semi-exit this group to update Xrefs and all variables.
5504 ;; We can't do a real exit, because the window conf must remain
5505 ;; the same in case the user is prompted for info, and we don't
5506 ;; want the window conf to change before that...
5507 (gnus-summary-exit t)
5508 (while (not entered)
5509 ;; Then we find what group we are supposed to enter.
5510 (set-buffer gnus-group-buffer)
5511 (gnus-group-jump-to-group current-group)
5514 (if (eq gnus-keep-same-level 'best)
5515 (gnus-summary-best-group gnus-newsgroup-name)
5516 (gnus-summary-search-group backward gnus-keep-same-level))))
5517 (if (not target-group)
5518 ;; There are no further groups, so we return to the group
5521 (gnus-message 5 "Returning to the group buffer")
5523 (when (gnus-buffer-live-p current-buffer)
5524 (set-buffer current-buffer)
5525 (gnus-summary-exit))
5526 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5527 ;; We try to enter the target group.
5528 (gnus-group-jump-to-group target-group)
5529 (let ((unreads (gnus-group-group-unread)))
5530 (if (and (or (eq t unreads)
5531 (and unreads (not (zerop unreads))))
5532 (gnus-summary-read-group
5533 target-group nil no-article
5534 (and (buffer-name current-buffer) current-buffer)
5537 (setq current-group target-group
5538 target-group nil)))))))
5540 (defun gnus-summary-prev-group (&optional no-article)
5541 "Exit current newsgroup and then select previous unread newsgroup.
5542 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5544 (gnus-summary-next-group no-article nil t))
5546 ;; Walking around summary lines.
5548 (defun gnus-summary-first-subject (&optional unread undownloaded)
5549 "Go to the first unread subject.
5550 If UNREAD is non-nil, go to the first unread article.
5551 Returns the article selected or nil if there are no unread articles."
5556 ((null gnus-newsgroup-data)
5557 (gnus-message 3 "No articles in the group")
5559 ;; Pick the first article.
5561 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5562 (gnus-data-number (car gnus-newsgroup-data)))
5563 ;; No unread articles.
5564 ((null gnus-newsgroup-unreads)
5565 (gnus-message 3 "No more unread articles")
5567 ;; Find the first unread article.
5569 (let ((data gnus-newsgroup-data))
5571 (and (not (and undownloaded
5572 (eq gnus-undownloaded-mark
5573 (gnus-data-mark (car data)))))
5574 (not (gnus-data-unread-p (car data)))))
5575 (setq data (cdr data)))
5577 (goto-char (gnus-data-pos (car data)))
5578 (gnus-data-number (car data))))))
5579 (gnus-summary-position-point)))
5581 (defun gnus-summary-next-subject (n &optional unread dont-display)
5582 "Go to next N'th summary line.
5583 If N is negative, go to the previous N'th subject line.
5584 If UNREAD is non-nil, only unread articles are selected.
5585 The difference between N and the actual number of steps taken is
5588 (let ((backward (< n 0))
5592 (gnus-summary-find-prev unread)
5593 (gnus-summary-find-next unread)))
5594 (gnus-summary-show-thread)
5597 (gnus-message 7 "No more%s articles"
5598 (if unread " unread" "")))
5599 (unless dont-display
5600 (gnus-summary-recenter)
5601 (gnus-summary-position-point))
5604 (defun gnus-summary-next-unread-subject (n)
5605 "Go to next N'th unread summary line."
5607 (gnus-summary-next-subject n t))
5609 (defun gnus-summary-prev-subject (n &optional unread)
5610 "Go to previous N'th summary line.
5611 If optional argument UNREAD is non-nil, only unread article is selected."
5613 (gnus-summary-next-subject (- n) unread))
5615 (defun gnus-summary-prev-unread-subject (n)
5616 "Go to previous N'th unread summary line."
5618 (gnus-summary-next-subject (- n) t))
5620 (defun gnus-summary-goto-subject (article &optional force silent)
5621 "Go the subject line of ARTICLE.
5622 If FORCE, also allow jumping to articles not currently shown."
5623 (interactive "nArticle number: ")
5625 (data (gnus-data-find article)))
5626 ;; We read in the article if we have to.
5629 (gnus-summary-insert-subject
5631 (if (or (numberp force) (vectorp force)) force)
5633 (setq data (gnus-data-find article)))
5638 (gnus-message 3 "Can't find article %d" article))
5640 (goto-char (gnus-data-pos data))
5641 (gnus-summary-position-point)
5644 ;; Walking around summary lines with displaying articles.
5646 (defun gnus-summary-expand-window (&optional arg)
5647 "Make the summary buffer take up the entire Emacs frame.
5648 Given a prefix, will force an `article' buffer configuration."
5651 (gnus-configure-windows 'article 'force)
5652 (gnus-configure-windows 'summary 'force)))
5654 (defun gnus-summary-display-article (article &optional all-header)
5655 "Display ARTICLE in article buffer."
5656 (gnus-set-global-variables)
5660 (if gnus-summary-display-article-function
5661 (funcall gnus-summary-display-article-function article all-header)
5662 (gnus-article-prepare article all-header))
5663 (gnus-run-hooks 'gnus-select-article-hook)
5664 (when (and gnus-current-article
5665 (not (zerop gnus-current-article)))
5666 (gnus-summary-goto-subject gnus-current-article))
5667 (gnus-summary-recenter)
5668 (when (and gnus-use-trees gnus-show-threads)
5669 (gnus-possibly-generate-tree article)
5670 (gnus-highlight-selected-tree article))
5671 ;; Successfully display article.
5672 (gnus-article-set-window-start
5673 (cdr (assq article gnus-newsgroup-bookmarks))))))
5675 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5676 "Select the current article.
5677 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5678 non-nil, the article will be re-fetched even if it already present in
5679 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5681 ;; Make sure we are in the summary buffer to work around bbdb bug.
5682 (unless (eq major-mode 'gnus-summary-mode)
5683 (set-buffer gnus-summary-buffer))
5684 (let ((article (or article (gnus-summary-article-number)))
5685 (all-headers (not (not all-headers))) ;Must be T or NIL.
5686 gnus-summary-display-article-function
5689 (gnus-summary-article-pseudo-p article)
5690 (error "This is a pseudo-article"))
5693 (set-buffer gnus-summary-buffer)
5694 (if (or (and gnus-single-article-buffer
5695 (or (null gnus-current-article)
5696 (null gnus-article-current)
5697 (null (get-buffer gnus-article-buffer))
5698 (not (eq article (cdr gnus-article-current)))
5699 (not (equal (car gnus-article-current)
5700 gnus-newsgroup-name))))
5701 (and (not gnus-single-article-buffer)
5702 (or (null gnus-current-article)
5703 (not (eq gnus-current-article article))))
5705 ;; The requested article is different from the current article.
5707 (gnus-summary-display-article article all-headers)
5709 (when (or all-headers gnus-show-all-headers)
5710 (gnus-article-show-all-headers)))
5711 (when (or all-headers gnus-show-all-headers)
5712 (gnus-article-show-all-headers))
5715 (gnus-article-set-window-start
5716 (cdr (assq article gnus-newsgroup-bookmarks)))))))
5718 (defun gnus-summary-set-current-mark (&optional current-mark)
5719 "Obsolete function."
5722 (defun gnus-summary-next-article (&optional unread subject backward push)
5723 "Select the next article.
5724 If UNREAD, only unread articles are selected.
5725 If SUBJECT, only articles with SUBJECT are selected.
5726 If BACKWARD, the previous article is selected instead of the next."
5729 ;; Is there such an article?
5730 ((and (gnus-summary-search-forward unread subject backward)
5731 (or (gnus-summary-display-article (gnus-summary-article-number))
5732 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5733 (gnus-summary-position-point))
5734 ;; If not, we try the first unread, if that is wanted.
5736 gnus-auto-select-same
5737 (gnus-summary-first-unread-article))
5738 (gnus-summary-position-point)
5739 (gnus-message 6 "Wrapped"))
5740 ;; Try to get next/previous article not displayed in this group.
5741 ((and gnus-auto-extend-newsgroup
5742 (not unread) (not subject))
5743 (gnus-summary-goto-article
5744 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5745 nil (count-lines (point-min) (point))))
5746 ;; Go to next/previous group.
5748 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5749 (gnus-summary-jump-to-group gnus-newsgroup-name))
5750 (let ((cmd last-command-char)
5753 (set-buffer gnus-group-buffer)
5756 (if (eq gnus-keep-same-level 'best)
5757 (gnus-summary-best-group gnus-newsgroup-name)
5758 (gnus-summary-search-group backward gnus-keep-same-level))))
5759 ;; For some reason, the group window gets selected. We change
5761 (select-window (get-buffer-window (current-buffer)))
5762 ;; Select next unread newsgroup automagically.
5764 ((or (not gnus-auto-select-next)
5766 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5767 ((or (eq gnus-auto-select-next 'quietly)
5768 (and (eq gnus-auto-select-next 'slightly-quietly)
5770 (and (eq gnus-auto-select-next 'almost-quietly)
5771 (gnus-summary-last-article-p)))
5773 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5775 (gnus-message 7 "No more%s articles (%s)..."
5776 (if unread " unread" "")
5777 (if group (concat "selecting " group)
5779 (gnus-summary-next-group nil group backward)))
5781 (when (gnus-key-press-event-p last-input-event)
5782 (gnus-summary-walk-group-buffer
5783 gnus-newsgroup-name cmd unread backward point))))))))
5785 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5786 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5787 (?\C-p (gnus-group-prev-unread-group 1))))
5788 (cursor-in-echo-area t)
5789 keve key group ended)
5791 (set-buffer gnus-group-buffer)
5794 (if (eq gnus-keep-same-level 'best)
5795 (gnus-summary-best-group gnus-newsgroup-name)
5796 (gnus-summary-search-group backward gnus-keep-same-level))))
5799 5 "No more%s articles%s" (if unread " unread" "")
5801 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5802 (format " (Type %s for %s [%s])"
5803 (single-key-description cmd) group
5804 (car (gnus-gethash group gnus-newsrc-hashtb)))
5805 (format " (Type %s to exit %s)"
5806 (single-key-description cmd)
5807 gnus-newsgroup-name)))
5808 ;; Confirm auto selection.
5809 (setq key (car (setq keve (gnus-read-event-char))))
5812 ((assq key keystrokes)
5813 (let ((obuf (current-buffer)))
5814 (switch-to-buffer gnus-group-buffer)
5816 (gnus-group-jump-to-group group))
5817 (eval (cadr (assq key keystrokes)))
5818 (setq group (gnus-group-group-name))
5819 (switch-to-buffer obuf))
5823 (gnus-ephemeral-group-p gnus-newsgroup-name))
5825 (gnus-summary-next-group nil group backward)))
5827 (push (cdr keve) unread-command-events))))))
5829 (defun gnus-summary-next-unread-article ()
5830 "Select unread article after current one."
5832 (gnus-summary-next-article
5833 (or (not (eq gnus-summary-goto-unread 'never))
5834 (gnus-summary-last-article-p (gnus-summary-article-number)))
5835 (and gnus-auto-select-same
5836 (gnus-summary-article-subject))))
5838 (defun gnus-summary-prev-article (&optional unread subject)
5839 "Select the article after the current one.
5840 If UNREAD is non-nil, only unread articles are selected."
5842 (gnus-summary-next-article unread subject t))
5844 (defun gnus-summary-prev-unread-article ()
5845 "Select unread article before current one."
5847 (gnus-summary-prev-article
5848 (or (not (eq gnus-summary-goto-unread 'never))
5849 (gnus-summary-first-article-p (gnus-summary-article-number)))
5850 (and gnus-auto-select-same
5851 (gnus-summary-article-subject))))
5853 (defun gnus-summary-next-page (&optional lines circular)
5854 "Show next page of the selected article.
5855 If at the end of the current article, select the next article.
5856 LINES says how many lines should be scrolled up.
5858 If CIRCULAR is non-nil, go to the start of the article instead of
5859 selecting the next article when reaching the end of the current
5862 (setq gnus-summary-buffer (current-buffer))
5863 (gnus-set-global-variables)
5864 (let ((article (gnus-summary-article-number))
5865 (article-window (get-buffer-window gnus-article-buffer t))
5867 ;; If the buffer is empty, we have no article.
5869 (error "No article to select"))
5870 (gnus-configure-windows 'article)
5871 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
5872 (if (and (eq gnus-summary-goto-unread 'never)
5873 (not (gnus-summary-last-article-p article)))
5874 (gnus-summary-next-article)
5875 (gnus-summary-next-unread-article))
5876 (if (or (null gnus-current-article)
5877 (null gnus-article-current)
5878 (/= article (cdr gnus-article-current))
5879 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5880 ;; Selected subject is different from current article's.
5881 (gnus-summary-display-article article)
5882 (when article-window
5883 (gnus-eval-in-buffer-window gnus-article-buffer
5884 (setq endp (gnus-article-next-page lines)))
5887 (gnus-summary-beginning-of-article))
5889 (gnus-message 3 "End of message"))
5891 (if (and (eq gnus-summary-goto-unread 'never)
5892 (not (gnus-summary-last-article-p article)))
5893 (gnus-summary-next-article)
5894 (gnus-summary-next-unread-article))))))))
5895 (gnus-summary-recenter)
5896 (gnus-summary-position-point)))
5898 (defun gnus-summary-prev-page (&optional lines move)
5899 "Show previous page of selected article.
5900 Argument LINES specifies lines to be scrolled down.
5901 If MOVE, move to the previous unread article if point is at
5902 the beginning of the buffer."
5904 (let ((article (gnus-summary-article-number))
5905 (article-window (get-buffer-window gnus-article-buffer t))
5907 (gnus-configure-windows 'article)
5908 (if (or (null gnus-current-article)
5909 (null gnus-article-current)
5910 (/= article (cdr gnus-article-current))
5911 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5912 ;; Selected subject is different from current article's.
5913 (gnus-summary-display-article article)
5914 (gnus-summary-recenter)
5915 (when article-window
5916 (gnus-eval-in-buffer-window gnus-article-buffer
5917 (setq endp (gnus-article-prev-page lines)))
5918 (when (and move endp)
5920 (gnus-message 3 "Beginning of message"))
5922 (if (and (eq gnus-summary-goto-unread 'never)
5923 (not (gnus-summary-first-article-p article)))
5924 (gnus-summary-prev-article)
5925 (gnus-summary-prev-unread-article))))))))
5926 (gnus-summary-position-point))
5928 (defun gnus-summary-prev-page-or-article (&optional lines)
5929 "Show previous page of selected article.
5930 Argument LINES specifies lines to be scrolled down.
5931 If at the beginning of the article, go to the next article."
5933 (gnus-summary-prev-page lines t))
5935 (defun gnus-summary-scroll-up (lines)
5936 "Scroll up (or down) one line current article.
5937 Argument LINES specifies lines to be scrolled up (or down if negative)."
5939 (gnus-configure-windows 'article)
5940 (gnus-summary-show-thread)
5941 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
5942 (gnus-eval-in-buffer-window gnus-article-buffer
5944 (when (gnus-article-next-page lines)
5945 (gnus-message 3 "End of message")))
5947 (gnus-article-prev-page (- lines))))))
5948 (gnus-summary-recenter)
5949 (gnus-summary-position-point))
5951 (defun gnus-summary-scroll-down (lines)
5952 "Scroll down (or up) one line current article.
5953 Argument LINES specifies lines to be scrolled down (or up if negative)."
5955 (gnus-summary-scroll-up (- lines)))
5957 (defun gnus-summary-next-same-subject ()
5958 "Select next article which has the same subject as current one."
5960 (gnus-summary-next-article nil (gnus-summary-article-subject)))
5962 (defun gnus-summary-prev-same-subject ()
5963 "Select previous article which has the same subject as current one."
5965 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
5967 (defun gnus-summary-next-unread-same-subject ()
5968 "Select next unread article which has the same subject as current one."
5970 (gnus-summary-next-article t (gnus-summary-article-subject)))
5972 (defun gnus-summary-prev-unread-same-subject ()
5973 "Select previous unread article which has the same subject as current one."
5975 (gnus-summary-prev-article t (gnus-summary-article-subject)))
5977 (defun gnus-summary-first-unread-article ()
5978 "Select the first unread article.
5979 Return nil if there are no unread articles."
5982 (when (gnus-summary-first-subject t)
5983 (gnus-summary-show-thread)
5984 (gnus-summary-first-subject t)
5985 (gnus-summary-display-article (gnus-summary-article-number)))
5986 (gnus-summary-position-point)))
5988 (defun gnus-summary-first-unread-subject ()
5989 "Place the point on the subject line of the first unread article.
5990 Return nil if there are no unread articles."
5993 (when (gnus-summary-first-subject t)
5994 (gnus-summary-show-thread)
5995 (gnus-summary-first-subject t))
5996 (gnus-summary-position-point)))
5998 (defun gnus-summary-first-article ()
5999 "Select the first article.
6000 Return nil if there are no articles."
6003 (when (gnus-summary-first-subject)
6004 (gnus-summary-show-thread)
6005 (gnus-summary-first-subject)
6006 (gnus-summary-display-article (gnus-summary-article-number)))
6007 (gnus-summary-position-point)))
6009 (defun gnus-summary-best-unread-article ()
6010 "Select the unread article with the highest score."
6012 (let ((best -1000000)
6013 (data gnus-newsgroup-data)
6016 (and (gnus-data-unread-p (car data))
6018 (gnus-summary-article-score (gnus-data-number (car data))))
6021 article (gnus-data-number (car data))))
6022 (setq data (cdr data)))
6025 (gnus-summary-goto-article article)
6026 (error "No unread articles"))
6027 (gnus-summary-position-point))))
6029 (defun gnus-summary-last-subject ()
6030 "Go to the last displayed subject line in the group."
6031 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6033 (gnus-summary-goto-subject article))))
6035 (defun gnus-summary-goto-article (article &optional all-headers force)
6036 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6037 If ALL-HEADERS is non-nil, no header lines are hidden.
6038 If FORCE, go to the article even if it isn't displayed. If FORCE
6039 is a number, it is the line the article is to be displayed on."
6043 "Article number or Message-ID: "
6044 (mapcar (lambda (number) (list (int-to-string number)))
6045 gnus-newsgroup-limit))
6049 (if (and (stringp article)
6050 (string-match "@" article))
6051 (gnus-summary-refer-article article)
6052 (when (stringp article)
6053 (setq article (string-to-number article)))
6054 (if (gnus-summary-goto-subject article force)
6055 (gnus-summary-display-article article all-headers)
6056 (gnus-message 4 "Couldn't go to article %s" article) nil))
6057 (gnus-summary-position-point)))
6059 (defun gnus-summary-goto-last-article ()
6060 "Go to the previously read article."
6063 (when gnus-last-article
6064 (gnus-summary-goto-article gnus-last-article nil t))
6065 (gnus-summary-position-point)))
6067 (defun gnus-summary-pop-article (number)
6068 "Pop one article off the history and go to the previous.
6069 NUMBER articles will be popped off."
6072 (setq gnus-newsgroup-history
6073 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6075 (gnus-summary-goto-article (car to) nil t)
6076 (error "Article history empty")))
6077 (gnus-summary-position-point))
6079 ;; Summary commands and functions for limiting the summary buffer.
6081 (defun gnus-summary-limit-to-articles (n)
6082 "Limit the summary buffer to the next N articles.
6083 If not given a prefix, use the process marked articles instead."
6086 (let ((articles (gnus-summary-work-articles n)))
6087 (setq gnus-newsgroup-processable nil)
6088 (gnus-summary-limit articles))
6089 (gnus-summary-position-point)))
6091 (defun gnus-summary-pop-limit (&optional total)
6092 "Restore the previous limit.
6093 If given a prefix, remove all limits."
6096 (setq gnus-newsgroup-limits
6097 (list (mapcar (lambda (h) (mail-header-number h))
6098 gnus-newsgroup-headers))))
6099 (unless gnus-newsgroup-limits
6100 (error "No limit to pop"))
6102 (gnus-summary-limit nil 'pop)
6103 (gnus-summary-position-point)))
6105 (defun gnus-summary-limit-to-subject (subject &optional header)
6106 "Limit the summary buffer to articles that have subjects that match a regexp."
6107 (interactive "sLimit to subject (regexp): ")
6109 (setq header "subject"))
6110 (when (not (equal "" subject))
6112 (let ((articles (gnus-summary-find-matching
6113 (or header "subject") subject 'all)))
6115 (error "Found no matches for \"%s\"" subject))
6116 (gnus-summary-limit articles))
6117 (gnus-summary-position-point))))
6119 (defun gnus-summary-limit-to-author (from)
6120 "Limit the summary buffer to articles that have authors that match a regexp."
6121 (interactive "sLimit to author (regexp): ")
6122 (gnus-summary-limit-to-subject from "from"))
6124 (defun gnus-summary-limit-to-age (age &optional younger-p)
6125 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6126 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6127 articles that are younger than AGE days."
6128 (interactive "nLimit to articles older than (in days): \nP")
6130 (let ((data gnus-newsgroup-data)
6131 (cutoff (days-to-time age))
6132 articles d date is-younger)
6133 (while (setq d (pop data))
6134 (when (and (vectorp (gnus-data-header d))
6135 (setq date (mail-header-date (gnus-data-header d))))
6136 (setq is-younger (time-less-p
6137 (time-since (date-to-time date))
6142 (push (gnus-data-number d) articles))))
6143 (gnus-summary-limit (nreverse articles)))
6144 (gnus-summary-position-point)))
6146 (defun gnus-summary-limit-to-extra (header regexp)
6147 "Limit the summary buffer to articles that match an 'extra' header."
6151 (gnus-completing-read
6152 (symbol-name (car gnus-extra-headers))
6153 "Score extra header:"
6155 (cons (symbol-name x) x))
6160 (read-string (format "Limit to header %s (regexp): " header)))))
6161 (when (not (equal "" regexp))
6163 (let ((articles (gnus-summary-find-matching
6164 (cons 'extra header) regexp 'all)))
6166 (error "Found no matches for \"%s\"" regexp))
6167 (gnus-summary-limit articles))
6168 (gnus-summary-position-point))))
6170 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6172 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6174 (defun gnus-summary-limit-to-unread (&optional all)
6175 "Limit the summary buffer to articles that are not marked as read.
6176 If ALL is non-nil, limit strictly to unread articles."
6179 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6180 (gnus-summary-limit-to-marks
6181 ;; Concat all the marks that say that an article is read and have
6183 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6184 gnus-killed-mark gnus-kill-file-mark
6185 gnus-low-score-mark gnus-expirable-mark
6186 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6187 gnus-duplicate-mark gnus-souped-mark)
6190 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6191 (make-obsolete 'gnus-summary-delete-marked-with
6192 'gnus-summary-limit-exlude-marks)
6194 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6195 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6196 If REVERSE, limit the summary buffer to articles that are marked
6197 with MARKS. MARKS can either be a string of marks or a list of marks.
6198 Returns how many articles were removed."
6199 (interactive "sMarks: ")
6200 (gnus-summary-limit-to-marks marks t))
6202 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6203 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6204 If REVERSE (the prefix), limit the summary buffer to articles that are
6205 not marked with MARKS. MARKS can either be a string of marks or a
6207 Returns how many articles were removed."
6208 (interactive "sMarks: \nP")
6210 (let ((data gnus-newsgroup-data)
6211 (marks (if (listp marks) marks
6212 (append marks nil))) ; Transform to list.
6215 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6216 (memq (gnus-data-mark (car data)) marks))
6217 (push (gnus-data-number (car data)) articles))
6218 (setq data (cdr data)))
6219 (gnus-summary-limit articles))
6220 (gnus-summary-position-point)))
6222 (defun gnus-summary-limit-to-score (&optional score)
6223 "Limit to articles with score at or above SCORE."
6225 (setq score (if score
6226 (prefix-numeric-value score)
6227 (or gnus-summary-default-score 0)))
6228 (let ((data gnus-newsgroup-data)
6231 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6233 (push (gnus-data-number (car data)) articles))
6234 (setq data (cdr data)))
6236 (gnus-summary-limit articles)
6237 (gnus-summary-position-point))))
6239 (defun gnus-summary-limit-include-thread (id)
6240 "Display all the hidden articles that in the current thread."
6241 (interactive (list (mail-header-id (gnus-summary-article-header))))
6242 (let ((articles (gnus-articles-in-thread
6243 (gnus-id-to-thread (gnus-root-id id)))))
6245 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6246 (gnus-summary-position-point))))
6248 (defun gnus-summary-limit-include-dormant ()
6249 "Display all the hidden articles that are marked as dormant.
6250 Note that this command only works on a subset of the articles currently
6251 fetched for this group."
6253 (unless gnus-newsgroup-dormant
6254 (error "There are no dormant articles in this group"))
6256 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6257 (gnus-summary-position-point)))
6259 (defun gnus-summary-limit-exclude-dormant ()
6260 "Hide all dormant articles."
6263 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6264 (gnus-summary-position-point)))
6266 (defun gnus-summary-limit-exclude-childless-dormant ()
6267 "Hide all dormant articles that have no children."
6269 (let ((data (gnus-data-list t))
6270 articles d children)
6271 ;; Find all articles that are either not dormant or have
6273 (while (setq d (pop data))
6274 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6276 (gnus-article-children (gnus-data-number d)))
6279 (when (memq (car children) articles)
6284 (push (gnus-data-number d) articles)))
6287 (gnus-summary-limit articles)
6288 (gnus-summary-position-point))))
6290 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6291 "Mark all unread excluded articles as read.
6292 If ALL, mark even excluded ticked and dormants as read."
6294 (let ((articles (gnus-sorted-complement
6296 (mapcar (lambda (h) (mail-header-number h))
6297 gnus-newsgroup-headers)
6299 (sort gnus-newsgroup-limit '<)))
6301 (setq gnus-newsgroup-unreads
6302 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6304 (setq gnus-newsgroup-dormant nil
6305 gnus-newsgroup-marked nil
6306 gnus-newsgroup-reads
6308 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6309 gnus-newsgroup-reads))
6310 (while (setq article (pop articles))
6311 (unless (or (memq article gnus-newsgroup-dormant)
6312 (memq article gnus-newsgroup-marked))
6313 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6315 (defun gnus-summary-limit (articles &optional pop)
6317 ;; We pop the previous limit off the stack and use that.
6318 (setq articles (car gnus-newsgroup-limits)
6319 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6320 ;; We use the new limit, so we push the old limit on the stack.
6321 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6323 (setq gnus-newsgroup-limit articles)
6324 (let ((total (length gnus-newsgroup-data))
6325 (data (gnus-data-find-list (gnus-summary-article-number)))
6326 (gnus-summary-mark-below nil) ; Inhibit this.
6328 ;; This will do all the work of generating the new summary buffer
6329 ;; according to the new limit.
6330 (gnus-summary-prepare)
6331 ;; Hide any threads, possibly.
6332 (and gnus-show-threads
6333 gnus-thread-hide-subtree
6334 (gnus-summary-hide-all-threads))
6335 ;; Try to return to the article you were at, or one in the
6338 ;; We try to find some article after the current one.
6340 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6343 (setq data (cdr data))))
6345 ;; If there is no data, that means that we were after the last
6346 ;; article. The same goes when we can't find any articles
6347 ;; after the current one.
6348 (goto-char (point-max))
6349 (gnus-summary-find-prev))
6350 (gnus-set-mode-line 'summary)
6351 ;; We return how many articles were removed from the summary
6352 ;; buffer as a result of the new limit.
6353 (- total (length gnus-newsgroup-data))))
6355 (defsubst gnus-invisible-cut-children (threads)
6358 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6363 (defsubst gnus-cut-thread (thread)
6364 "Go forwards in the thread until we find an article that we want to display."
6365 (when (or (eq gnus-fetch-old-headers 'some)
6366 (eq gnus-fetch-old-headers 'invisible)
6367 (eq gnus-build-sparse-threads 'some)
6368 (eq gnus-build-sparse-threads 'more))
6369 ;; Deal with old-fetched headers and sparse threads.
6373 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6374 (gnus-summary-article-ancient-p
6375 (mail-header-number (car thread))))
6376 (if (or (<= (length (cdr thread)) 1)
6377 (eq gnus-fetch-old-headers 'invisible))
6378 (setq gnus-newsgroup-limit
6379 (delq (mail-header-number (car thread))
6380 gnus-newsgroup-limit)
6381 thread (cadr thread))
6382 (when (gnus-invisible-cut-children (cdr thread))
6383 (let ((th (cdr thread)))
6385 (if (memq (mail-header-number (caar th))
6386 gnus-newsgroup-limit)
6387 (setq thread (car th)
6389 (setq th (cdr th))))))))))
6392 (defun gnus-cut-threads (threads)
6393 "Cut off all uninteresting articles from the beginning of threads."
6394 (when (or (eq gnus-fetch-old-headers 'some)
6395 (eq gnus-fetch-old-headers 'invisible)
6396 (eq gnus-build-sparse-threads 'some)
6397 (eq gnus-build-sparse-threads 'more))
6400 (setcar th (gnus-cut-thread (car th)))
6401 (setq th (cdr th)))))
6402 ;; Remove nixed out threads.
6405 (defun gnus-summary-initial-limit (&optional show-if-empty)
6406 "Figure out what the initial limit is supposed to be on group entry.
6407 This entails weeding out unwanted dormants, low-scored articles,
6408 fetch-old-headers verbiage, and so on."
6409 ;; Most groups have nothing to remove.
6410 (if (or gnus-inhibit-limiting
6411 (and (null gnus-newsgroup-dormant)
6412 (not (eq gnus-fetch-old-headers 'some))
6413 (not (eq gnus-fetch-old-headers 'invisible))
6414 (null gnus-summary-expunge-below)
6415 (not (eq gnus-build-sparse-threads 'some))
6416 (not (eq gnus-build-sparse-threads 'more))
6417 (null gnus-thread-expunge-below)
6418 (not gnus-use-nocem)))
6420 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6421 (setq gnus-newsgroup-limit nil)
6424 (unless (car (symbol-value node))
6425 ;; These threads have no parents -- they are roots.
6426 (let ((nodes (cdr (symbol-value node)))
6429 (if (and gnus-thread-expunge-below
6430 (< (gnus-thread-total-score (car nodes))
6431 gnus-thread-expunge-below))
6432 (gnus-expunge-thread (pop nodes))
6433 (setq thread (pop nodes))
6434 (gnus-summary-limit-children thread))))))
6435 gnus-newsgroup-dependencies)
6436 ;; If this limitation resulted in an empty group, we might
6437 ;; pop the previous limit and use it instead.
6438 (when (and (not gnus-newsgroup-limit)
6440 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6441 gnus-newsgroup-limit))
6443 (defun gnus-summary-limit-children (thread)
6444 "Return 1 if this subthread is visible and 0 if it is not."
6445 ;; First we get the number of visible children to this thread. This
6446 ;; is done by recursing down the thread using this function, so this
6447 ;; will really go down to a leaf article first, before slowly
6448 ;; working its way up towards the root.
6452 (apply '+ (mapcar 'gnus-summary-limit-children
6455 (number (mail-header-number (car thread)))
6458 (not (memq number gnus-newsgroup-marked))
6460 ;; If this article is dormant and has absolutely no visible
6461 ;; children, then this article isn't visible.
6462 (and (memq number gnus-newsgroup-dormant)
6464 ;; If this is "fetch-old-headered" and there is no
6465 ;; visible children, then we don't want this article.
6466 (and (eq gnus-fetch-old-headers 'some)
6467 (gnus-summary-article-ancient-p number)
6469 ;; If this is "fetch-old-headered" and `invisible', then
6470 ;; we don't want this article.
6471 (and (eq gnus-fetch-old-headers 'invisible)
6472 (gnus-summary-article-ancient-p number))
6473 ;; If this is a sparsely inserted article with no children,
6474 ;; we don't want it.
6475 (and (eq gnus-build-sparse-threads 'some)
6476 (gnus-summary-article-sparse-p number)
6478 ;; If we use expunging, and this article is really
6479 ;; low-scored, then we don't want this article.
6480 (when (and gnus-summary-expunge-below
6482 (or (cdr (assq number gnus-newsgroup-scored))
6483 gnus-summary-default-score))
6484 gnus-summary-expunge-below))
6485 ;; We increase the expunge-tally here, but that has
6486 ;; nothing to do with the limits, really.
6487 (incf gnus-newsgroup-expunged-tally)
6488 ;; We also mark as read here, if that's wanted.
6489 (when (and gnus-summary-mark-below
6490 (< score gnus-summary-mark-below))
6491 (setq gnus-newsgroup-unreads
6492 (delq number gnus-newsgroup-unreads))
6493 (if gnus-newsgroup-auto-expire
6494 (push number gnus-newsgroup-expirable)
6495 (push (cons number gnus-low-score-mark)
6496 gnus-newsgroup-reads)))
6498 ;; Check NoCeM things.
6499 (if (and gnus-use-nocem
6500 (gnus-nocem-unwanted-article-p
6501 (mail-header-id (car thread))))
6503 (setq gnus-newsgroup-unreads
6504 (delq number gnus-newsgroup-unreads))
6506 ;; Nope, invisible article.
6508 ;; Ok, this article is to be visible, so we add it to the limit
6510 (push number gnus-newsgroup-limit)
6513 (defun gnus-expunge-thread (thread)
6514 "Mark all articles in THREAD as read."
6515 (let* ((number (mail-header-number (car thread))))
6516 (incf gnus-newsgroup-expunged-tally)
6517 ;; We also mark as read here, if that's wanted.
6518 (setq gnus-newsgroup-unreads
6519 (delq number gnus-newsgroup-unreads))
6520 (if gnus-newsgroup-auto-expire
6521 (push number gnus-newsgroup-expirable)
6522 (push (cons number gnus-low-score-mark)
6523 gnus-newsgroup-reads)))
6524 ;; Go recursively through all subthreads.
6525 (mapcar 'gnus-expunge-thread (cdr thread)))
6527 ;; Summary article oriented commands
6529 (defun gnus-summary-refer-parent-article (n)
6530 "Refer parent article N times.
6531 If N is negative, go to ancestor -N instead.
6532 The difference between N and the number of articles fetched is returned."
6536 (when (not (natnump n))
6541 (setq header (gnus-summary-article-header))
6542 (if (and (eq (mail-header-number header)
6543 (cdr gnus-article-current))
6544 (equal gnus-newsgroup-name
6545 (car gnus-article-current)))
6546 ;; If we try to find the parent of the currently
6547 ;; displayed article, then we take a look at the actual
6548 ;; References header, since this is slightly more
6549 ;; reliable than the References field we got from the
6552 (set-buffer gnus-original-article-buffer)
6553 (nnheader-narrow-to-headers)
6554 (unless (setq ref (message-fetch-field "references"))
6555 (setq ref (message-fetch-field "in-reply-to")))
6558 ;; It's not the current article, so we take a bet on
6559 ;; the value we got from the server.
6560 (mail-header-references header)))
6562 (not (equal ref "")))
6563 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6564 (gnus-message 1 "Couldn't find parent"))
6565 (gnus-message 1 "No references in article %d"
6566 (gnus-summary-article-number))
6569 (gnus-summary-position-point)
6572 (defun gnus-summary-refer-references ()
6573 "Fetch all articles mentioned in the References header.
6574 Return the number of articles fetched."
6576 (let ((ref (mail-header-references (gnus-summary-article-header)))
6577 (current (gnus-summary-article-number))
6581 (error "No References in the current article")
6582 ;; For each Message-ID in the References header...
6583 (while (string-match "<[^>]*>" ref)
6585 ;; ... fetch that article.
6586 (gnus-summary-refer-article
6587 (prog1 (match-string 0 ref)
6588 (setq ref (substring ref (match-end 0))))))
6589 (gnus-summary-goto-subject current)
6590 (gnus-summary-position-point)
6593 (defun gnus-summary-refer-thread (&optional limit)
6594 "Fetch all articles in the current thread.
6595 If LIMIT (the numerical prefix), fetch that many old headers instead
6596 of what's specified by the `gnus-refer-thread-limit' variable."
6598 (let ((id (mail-header-id (gnus-summary-article-header)))
6599 (limit (if limit (prefix-numeric-value limit)
6600 gnus-refer-thread-limit)))
6601 ;; We want to fetch LIMIT *old* headers, but we also have to
6602 ;; re-fetch all the headers in the current buffer, because many of
6603 ;; them may be undisplayed. So we adjust LIMIT.
6604 (when (numberp limit)
6605 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6606 (unless (eq gnus-fetch-old-headers 'invisible)
6607 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6608 ;; Retrieve the headers and read them in.
6609 (if (eq (gnus-retrieve-headers
6610 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6612 (gnus-build-all-threads)
6613 (error "Can't fetch thread from backends that don't support NOV"))
6614 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6615 (gnus-summary-limit-include-thread id)))
6617 (defun gnus-summary-refer-article (message-id &optional arg)
6618 "Fetch an article specified by MESSAGE-ID.
6619 If ARG (the prefix), fetch the article using `gnus-refer-article-method'
6620 or `gnus-select-method', no matter what backend the article comes from."
6621 (interactive "sMessage-ID: \nP")
6622 (when (and (stringp message-id)
6623 (not (zerop (length message-id))))
6624 ;; Construct the correct Message-ID if necessary.
6625 ;; Suggested by tale@pawl.rpi.edu.
6626 (unless (string-match "^<" message-id)
6627 (setq message-id (concat "<" message-id)))
6628 (unless (string-match ">$" message-id)
6629 (setq message-id (concat message-id ">")))
6630 (let* ((header (gnus-id-to-header message-id))
6632 (gnus-summary-article-sparse-p
6633 (mail-header-number header))
6634 (memq (mail-header-number header)
6635 gnus-newsgroup-limit))))
6637 ;; If the article is present in the buffer we just go to it.
6639 (or (not (gnus-summary-article-sparse-p
6640 (mail-header-number header)))
6643 (gnus-summary-goto-article
6644 (mail-header-number header) nil t)
6646 (gnus-summary-update-article (mail-header-number header)))))
6648 ;; We fetch the article
6649 (let ((gnus-override-method
6650 (cond ((gnus-news-group-p gnus-newsgroup-name)
6651 gnus-refer-article-method)
6653 (or gnus-refer-article-method gnus-select-method))
6656 ;; Start the special refer-article method, if necessary.
6657 (when (and gnus-refer-article-method
6658 (gnus-news-group-p gnus-newsgroup-name))
6659 (gnus-check-server gnus-refer-article-method))
6660 ;; Fetch the header, and display the article.
6661 (if (setq number (gnus-summary-insert-subject message-id))
6662 (gnus-summary-select-article nil nil nil number)
6663 (gnus-message 3 "Couldn't fetch article %s" message-id))))))))
6665 (defun gnus-summary-edit-parameters ()
6666 "Edit the group parameters of the current group."
6668 (gnus-group-edit-group gnus-newsgroup-name 'params))
6670 (defun gnus-summary-customize-parameters ()
6671 "Customize the group parameters of the current group."
6673 (gnus-group-customize gnus-newsgroup-name))
6675 (defun gnus-summary-enter-digest-group (&optional force)
6676 "Enter an nndoc group based on the current article.
6677 If FORCE, force a digest interpretation. If not, try
6678 to guess what the document format is."
6680 (let ((conf gnus-current-window-configuration))
6682 (gnus-summary-select-article))
6683 (setq gnus-current-window-configuration conf)
6684 (let* ((name (format "%s-%d"
6685 (gnus-group-prefixed-name
6686 gnus-newsgroup-name (list 'nndoc ""))
6688 (set-buffer gnus-summary-buffer)
6689 gnus-current-article)))
6690 (ogroup gnus-newsgroup-name)
6691 (params (append (gnus-info-params (gnus-get-info ogroup))
6692 (list (cons 'to-group ogroup))
6693 (list (cons 'save-article-group ogroup))))
6694 (case-fold-search t)
6695 (buf (current-buffer))
6698 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6699 (insert-buffer-substring gnus-original-article-buffer)
6700 ;; Remove lines that may lead nndoc to misinterpret the
6703 (goto-char (point-min))
6704 (or (search-forward "\n\n" nil t) (point)))
6705 (goto-char (point-min))
6706 (delete-matching-lines "^\\(Path\\):\\|^From ")
6709 (if (gnus-group-read-ephemeral-group
6710 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6712 ,(if force 'digest 'guess))) t)
6713 ;; Make all postings to this group go to the parent group.
6714 (nconc (gnus-info-params (gnus-get-info name))
6716 ;; Couldn't select this doc group.
6717 (switch-to-buffer buf)
6718 (gnus-set-global-variables)
6719 (gnus-configure-windows 'summary)
6720 (gnus-message 3 "Article couldn't be entered?"))
6721 (kill-buffer dig)))))
6723 (defun gnus-summary-read-document (n)
6724 "Open a new group based on the current article(s).
6725 This will allow you to read digests and other similar
6726 documents as newsgroups.
6727 Obeys the standard process/prefix convention."
6729 (let* ((articles (gnus-summary-work-articles n))
6730 (ogroup gnus-newsgroup-name)
6731 (params (append (gnus-info-params (gnus-get-info ogroup))
6732 (list (cons 'to-group ogroup))))
6733 article group egroup groups vgroup)
6734 (while (setq article (pop articles))
6735 (setq group (format "%s-%d" gnus-newsgroup-name article))
6736 (gnus-summary-remove-process-mark article)
6737 (when (gnus-summary-display-article article)
6740 (insert-buffer-substring gnus-original-article-buffer)
6741 ;; Remove some headers that may lead nndoc to make
6743 (message-narrow-to-head)
6744 (goto-char (point-min))
6745 (delete-matching-lines "^\\(Path\\):\\|^From ")
6748 (gnus-group-read-ephemeral-group
6749 group `(nndoc ,group (nndoc-address ,(current-buffer))
6750 (nndoc-article-type guess))
6753 ;; Make all postings to this group go to the parent group.
6754 (nconc (gnus-info-params (gnus-get-info egroup))
6756 (push egroup groups))
6757 ;; Couldn't select this doc group.
6758 (gnus-error 3 "Article couldn't be entered"))))))
6759 ;; Now we have selected all the documents.
6762 (error "None of the articles could be interpreted as documents"))
6763 ((gnus-group-read-ephemeral-group
6764 (setq vgroup (format
6765 "nnvirtual:%s-%s" gnus-newsgroup-name
6766 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6767 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6769 (cons (current-buffer) 'summary)))
6771 (error "Couldn't select virtual nndoc group")))))
6773 (defun gnus-summary-isearch-article (&optional regexp-p)
6774 "Do incremental search forward on the current article.
6775 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6777 (gnus-summary-select-article)
6778 (gnus-configure-windows 'article)
6779 (gnus-eval-in-buffer-window gnus-article-buffer
6782 (isearch-forward regexp-p))))
6784 (defun gnus-summary-search-article-forward (regexp &optional backward)
6785 "Search for an article containing REGEXP forward.
6786 If BACKWARD, search backward instead."
6789 (format "Search article %s (regexp%s): "
6790 (if current-prefix-arg "backward" "forward")
6791 (if gnus-last-search-regexp
6792 (concat ", default " gnus-last-search-regexp)
6794 current-prefix-arg))
6795 (if (string-equal regexp "")
6796 (setq regexp (or gnus-last-search-regexp ""))
6797 (setq gnus-last-search-regexp regexp))
6798 (if (gnus-summary-search-article regexp backward)
6799 (gnus-summary-show-thread)
6800 (error "Search failed: \"%s\"" regexp)))
6802 (defun gnus-summary-search-article-backward (regexp)
6803 "Search for an article containing REGEXP backward."
6806 (format "Search article backward (regexp%s): "
6807 (if gnus-last-search-regexp
6808 (concat ", default " gnus-last-search-regexp)
6810 (gnus-summary-search-article-forward regexp 'backward))
6812 (defun gnus-summary-search-article (regexp &optional backward)
6813 "Search for an article containing REGEXP.
6814 Optional argument BACKWARD means do search for backward.
6815 `gnus-select-article-hook' is not called during the search."
6816 ;; We have to require this here to make sure that the following
6817 ;; dynamic binding isn't shadowed by autoloading.
6818 (require 'gnus-async)
6820 (let ((gnus-select-article-hook nil) ;Disable hook.
6821 (gnus-article-display-hook nil)
6822 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6823 (gnus-use-article-prefetch nil)
6824 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
6825 (gnus-use-trees nil) ;Inhibit updating tree buffer.
6826 (sum (current-buffer))
6829 (gnus-save-hidden-threads
6830 (gnus-summary-select-article)
6831 (set-buffer gnus-article-buffer)
6835 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
6837 (re-search-backward regexp nil t)
6838 (re-search-forward regexp nil t))
6839 ;; We found the regexp.
6844 (get-buffer-window (current-buffer))
6848 (setq point (point)))
6849 ;; We didn't find it, so we go to the next article.
6852 (while (eq found 'not)
6853 (if (not (if backward (gnus-summary-find-prev)
6854 (gnus-summary-find-next)))
6855 ;; No more articles.
6857 ;; Select the next article and adjust point.
6858 (unless (gnus-summary-article-sparse-p
6859 (gnus-summary-article-number))
6861 (gnus-summary-select-article)
6862 (set-buffer gnus-article-buffer)
6864 (goto-char (if backward (point-max) (point-min))))))))
6865 (gnus-message 7 ""))
6866 ;; Return whether we found the regexp.
6867 (when (eq found 'found)
6869 (gnus-summary-show-thread)
6870 (gnus-summary-goto-subject gnus-current-article)
6871 (gnus-summary-position-point)
6874 (defun gnus-summary-find-matching (header regexp &optional backward unread
6876 "Return a list of all articles that match REGEXP on HEADER.
6877 The search stars on the current article and goes forwards unless
6878 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
6879 If UNREAD is non-nil, only unread articles will
6880 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
6881 in the comparisons."
6882 (let ((data (if (eq backward 'all) gnus-newsgroup-data
6883 (gnus-data-find-list
6884 (gnus-summary-article-number) (gnus-data-list backward))))
6885 (case-fold-search (not not-case-fold))
6888 (if (eq (car header) 'extra)
6891 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
6893 (error "%s is an invalid header" header))
6894 (unless (fboundp (intern (concat "mail-header-" header)))
6895 (error "%s is not a valid header" header))
6896 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
6899 (and (or (not unread) ; We want all articles...
6900 (gnus-data-unread-p d)) ; Or just unreads.
6901 (vectorp (gnus-data-header d)) ; It's not a pseudo.
6902 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
6903 (push (gnus-data-number d) articles)) ; Success!
6904 (setq data (cdr data)))
6905 (nreverse articles)))
6907 (defun gnus-summary-execute-command (header regexp command &optional backward)
6908 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
6909 If HEADER is an empty string (or nil), the match is done on the entire
6910 article. If BACKWARD (the prefix) is non-nil, search backward instead."
6912 (list (let ((completion-ignore-case t))
6915 (mapcar (lambda (string) (list string))
6916 '("Number" "Subject" "From" "Lines" "Date"
6917 "Message-ID" "Xref" "References" "Body"))
6918 nil 'require-match))
6919 (read-string "Regexp: ")
6920 (read-key-sequence "Command: ")
6921 current-prefix-arg))
6922 (when (equal header "Body")
6924 ;; Hidden thread subtrees must be searched as well.
6925 (gnus-summary-show-all-threads)
6926 ;; We don't want to change current point nor window configuration.
6928 (save-window-excursion
6929 (gnus-message 6 "Executing %s..." (key-description command))
6930 ;; We'd like to execute COMMAND interactively so as to give arguments.
6931 (gnus-execute header regexp
6932 `(call-interactively ',(key-binding command))
6934 (gnus-message 6 "Executing %s...done" (key-description command)))))
6936 (defun gnus-summary-beginning-of-article ()
6937 "Scroll the article back to the beginning."
6939 (gnus-summary-select-article)
6940 (gnus-configure-windows 'article)
6941 (gnus-eval-in-buffer-window gnus-article-buffer
6943 (goto-char (point-min))
6944 (when gnus-page-broken
6945 (gnus-narrow-to-page))))
6947 (defun gnus-summary-end-of-article ()
6948 "Scroll to the end of the article."
6950 (gnus-summary-select-article)
6951 (gnus-configure-windows 'article)
6952 (gnus-eval-in-buffer-window gnus-article-buffer
6954 (goto-char (point-max))
6956 (when gnus-page-broken
6957 (gnus-narrow-to-page))))
6959 (defun gnus-summary-print-article (&optional filename n)
6960 "Generate and print a PostScript image of the N next (mail) articles.
6962 If N is negative, print the N previous articles. If N is nil and articles
6963 have been marked with the process mark, print these instead.
6965 If the optional first argument FILENAME is nil, send the image to the
6966 printer. If FILENAME is a string, save the PostScript image in a file with
6967 that name. If FILENAME is a number, prompt the user for the name of the file
6969 (interactive (list (ps-print-preprint current-prefix-arg)
6970 current-prefix-arg))
6971 (dolist (article (gnus-summary-work-articles n))
6972 (gnus-summary-select-article nil nil 'pseudo article)
6973 (gnus-eval-in-buffer-window gnus-article-buffer
6974 (let ((buffer (generate-new-buffer " *print*")))
6977 (copy-to-buffer buffer (point-min) (point-max))
6979 (gnus-article-delete-invisible-text)
6980 (let ((ps-left-header
6983 (mail-header-subject gnus-current-headers) ")")
6985 (mail-header-from gnus-current-headers) ")")))
6988 "/pagenumberstring load"
6990 (mail-header-date gnus-current-headers) ")"))))
6991 (gnus-run-hooks 'gnus-ps-print-hook)
6993 (ps-print-buffer-with-faces filename))))
6994 (kill-buffer buffer))))))
6996 (defun gnus-summary-show-article (&optional arg)
6997 "Force re-fetching of the current article.
6998 If ARG (the prefix) is non-nil, show the raw article without any
6999 article massaging functions being run."
7002 ;; Select the article the normal way.
7003 (gnus-summary-select-article nil 'force)
7004 ;; We have to require this here to make sure that the following
7005 ;; dynamic binding isn't shadowed by autoloading.
7006 (require 'gnus-async)
7008 ;; Bind the article treatment functions to nil.
7009 (let ((gnus-have-all-headers t)
7010 gnus-article-display-hook
7011 gnus-article-prepare-hook
7012 gnus-article-decode-hook
7016 (gnus-summary-select-article nil 'force)))
7017 (gnus-summary-goto-subject gnus-current-article)
7018 (gnus-summary-position-point))
7020 (defun gnus-summary-verbose-headers (&optional arg)
7021 "Toggle permanent full header display.
7022 If ARG is a positive number, turn header display on.
7023 If ARG is a negative number, turn header display off."
7025 (setq gnus-show-all-headers
7026 (cond ((or (not (numberp arg))
7028 (not gnus-show-all-headers))
7031 (gnus-summary-show-article))
7033 (defun gnus-summary-toggle-header (&optional arg)
7034 "Show the headers if they are hidden, or hide them if they are shown.
7035 If ARG is a positive number, show the entire header.
7036 If ARG is a negative number, hide the unwanted header lines."
7039 (set-buffer gnus-article-buffer)
7041 (let* ((buffer-read-only nil)
7042 (inhibit-point-motion-hooks t)
7045 (article-narrow-to-head)
7046 (setq hidden (gnus-article-hidden-text-p 'headers)))
7047 (goto-char (point-min))
7048 (when (search-forward "\n\n" nil t)
7049 (delete-region (point-min) (1- (point))))
7050 (goto-char (point-min))
7052 (set-buffer gnus-original-article-buffer)
7053 (goto-char (point-min))
7054 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
7055 (insert-buffer-substring gnus-original-article-buffer 1 e)
7057 (narrow-to-region (point-min) (point))
7058 (article-decode-encoded-words)
7060 (and (numberp arg) (< arg 0)))
7061 (let ((gnus-treat-hide-headers nil)
7062 (gnus-treat-hide-boring-headers nil))
7063 (gnus-treat-article 'head))
7064 (gnus-treat-article 'head)))))))
7066 (defun gnus-summary-show-all-headers ()
7067 "Make all header lines visible."
7069 (gnus-article-show-all-headers))
7071 (defun gnus-summary-toggle-mime (&optional arg)
7072 "Toggle MIME processing.
7073 If ARG is a positive number, turn MIME processing on."
7075 (setq gnus-show-mime
7077 (not gnus-show-mime)
7078 (> (prefix-numeric-value arg) 0)))
7079 (gnus-summary-select-article t 'force))
7081 (defun gnus-summary-caesar-message (&optional arg)
7082 "Caesar rotate the current article by 13.
7083 The numerical prefix specifies how many places to rotate each letter
7086 (gnus-summary-select-article)
7087 (let ((mail-header-separator ""))
7088 (gnus-eval-in-buffer-window gnus-article-buffer
7091 (let ((start (window-start))
7093 (message-caesar-buffer-body arg)
7094 (set-window-start (get-buffer-window (current-buffer)) start))))))
7096 (defun gnus-summary-stop-page-breaking ()
7097 "Stop page breaking in the current article."
7099 (gnus-summary-select-article)
7100 (gnus-eval-in-buffer-window gnus-article-buffer
7102 (when (gnus-visual-p 'page-marker)
7103 (let ((buffer-read-only nil))
7104 (gnus-remove-text-with-property 'gnus-prev)
7105 (gnus-remove-text-with-property 'gnus-next))
7106 (setq gnus-page-broken nil))))
7108 (defun gnus-summary-move-article (&optional n to-newsgroup
7109 select-method action)
7110 "Move the current article to a different newsgroup.
7111 If N is a positive number, move the N next articles.
7112 If N is a negative number, move the N previous articles.
7113 If N is nil and any articles have been marked with the process mark,
7114 move those articles instead.
7115 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7116 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7117 re-spool using this method.
7119 For this function to work, both the current newsgroup and the
7120 newsgroup that you want to move to have to support the `request-move'
7121 and `request-accept' functions."
7124 (setq action 'move))
7125 ;; Disable marking as read.
7126 (let (gnus-mark-article-hook)
7127 (save-window-excursion
7128 (gnus-summary-select-article)))
7129 ;; Check whether the source group supports the required functions.
7130 (cond ((and (eq action 'move)
7131 (not (gnus-check-backend-function
7132 'request-move-article gnus-newsgroup-name)))
7133 (error "The current group does not support article moving"))
7134 ((and (eq action 'crosspost)
7135 (not (gnus-check-backend-function
7136 'request-replace-article gnus-newsgroup-name)))
7137 (error "The current group does not support article editing")))
7138 (let ((articles (gnus-summary-work-articles n))
7139 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
7140 (names '((move "Move" "Moving")
7141 (copy "Copy" "Copying")
7142 (crosspost "Crosspost" "Crossposting")))
7143 (copy-buf (save-excursion
7144 (nnheader-set-temp-buffer " *copy article*")))
7145 (default-marks gnus-article-mark-lists)
7146 (no-expire-marks (delete '(expirable . expire)
7147 (copy-sequence gnus-article-mark-lists)))
7148 art-group to-method new-xref article to-groups)
7149 (unless (assq action names)
7150 (error "Unknown action %s" action))
7151 ;; Read the newsgroup name.
7152 (when (and (not to-newsgroup)
7153 (not select-method))
7155 (gnus-read-move-group-name
7156 (cadr (assq action names))
7157 (symbol-value (intern (format "gnus-current-%s-group" action)))
7159 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
7160 (setq to-method (or select-method
7161 (gnus-group-name-to-method to-newsgroup)))
7162 ;; Check the method we are to move this article to...
7163 (unless (gnus-check-backend-function
7164 'request-accept-article (car to-method))
7165 (error "%s does not support article copying" (car to-method)))
7166 (unless (gnus-check-server to-method)
7167 (error "Can't open server %s" (car to-method)))
7168 (gnus-message 6 "%s to %s: %s..."
7169 (caddr (assq action names))
7170 (or (car select-method) to-newsgroup) articles)
7172 (setq article (pop articles))
7176 ;; Move the article.
7178 ;; Remove this article from future suppression.
7179 (gnus-dup-unsuppress-article article)
7180 (gnus-request-move-article
7181 article ; Article to move
7182 gnus-newsgroup-name ; From newsgroup
7183 (nth 1 (gnus-find-method-for-group
7184 gnus-newsgroup-name)) ; Server
7185 (list 'gnus-request-accept-article
7186 to-newsgroup (list 'quote select-method)
7187 (not articles) t) ; Accept form
7188 (not articles))) ; Only save nov last time
7189 ;; Copy the article.
7192 (set-buffer copy-buf)
7193 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
7194 (gnus-request-accept-article
7195 to-newsgroup select-method (not articles) t))))
7196 ;; Crosspost the article.
7197 ((eq action 'crosspost)
7198 (let ((xref (message-tokenize-header
7199 (mail-header-xref (gnus-summary-article-header article))
7201 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
7204 (setq xref (list (system-name))))
7207 (mapconcat 'identity
7208 (delete "Xref:" (delete new-xref xref))
7212 (set-buffer copy-buf)
7213 ;; First put the article in the destination group.
7214 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7215 (when (consp (setq art-group
7216 (gnus-request-accept-article
7217 to-newsgroup select-method (not articles))))
7218 (setq new-xref (concat new-xref " " (car art-group)
7219 ":" (cdr art-group)))
7220 ;; Now we have the new Xrefs header, so we insert
7221 ;; it and replace the new article.
7222 (nnheader-replace-header "Xref" new-xref)
7223 (gnus-request-replace-article
7224 (cdr art-group) to-newsgroup (current-buffer))
7228 (gnus-message 1 "Couldn't %s article %s"
7229 (cadr (assq action names)) article))
7230 ((and (eq art-group 'junk)
7232 (gnus-summary-mark-article article gnus-canceled-mark)
7233 (gnus-message 4 "Deleted article %s" article))
7235 (let* ((pto-group (gnus-group-prefixed-name
7236 (car art-group) to-method))
7238 (gnus-gethash pto-group gnus-newsrc-hashtb))
7239 (info (nth 2 entry))
7240 (to-group (gnus-info-group info)))
7241 ;; Update the group that has been moved to.
7243 (memq action '(move copy)))
7244 (unless (member to-group to-groups)
7245 (push to-group to-groups))
7247 (unless (memq article gnus-newsgroup-unreads)
7249 info (gnus-add-to-range (gnus-info-read info)
7250 (list (cdr art-group)))))
7252 ;; Copy any marks over to the new group.
7253 (let ((marks (if (gnus-group-auto-expirable-p to-group)
7256 (to-article (cdr art-group)))
7258 ;; See whether the article is to be put in the cache.
7259 (when gnus-use-cache
7260 (gnus-cache-possibly-enter-article
7262 (memq article gnus-newsgroup-marked)
7263 (memq article gnus-newsgroup-dormant)
7264 (memq article gnus-newsgroup-unreads)))
7266 (when (and (equal to-group gnus-newsgroup-name)
7267 (not (memq article gnus-newsgroup-unreads)))
7268 ;; Mark this article as read in this group.
7269 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7270 (setcdr (gnus-active to-group) to-article)
7271 (setcdr gnus-newsgroup-active to-article))
7274 (when (memq article (symbol-value
7275 (intern (format "gnus-newsgroup-%s"
7277 ;; If the other group is the same as this group,
7278 ;; then we have to add the mark to the list.
7279 (when (equal to-group gnus-newsgroup-name)
7280 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7283 (intern (format "gnus-newsgroup-%s"
7285 ;; Copy the marks to other group.
7286 (gnus-add-marked-articles
7287 to-group (cdar marks) (list to-article) info))
7288 (setq marks (cdr marks)))
7291 (concat "(gnus-group-set-info '"
7292 (gnus-prin1-to-string (gnus-get-info to-group))
7295 ;; Update the Xref header in this article to point to
7296 ;; the new crossposted article we have just created.
7297 (when (eq action 'crosspost)
7299 (set-buffer copy-buf)
7300 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7301 (nnheader-replace-header "Xref" new-xref)
7302 (gnus-request-replace-article
7303 article gnus-newsgroup-name (current-buffer)))))
7305 ;;;!!!Why is this necessary?
7306 (set-buffer gnus-summary-buffer)
7308 (gnus-summary-goto-subject article)
7309 (when (eq action 'move)
7310 (gnus-summary-mark-article article gnus-canceled-mark))))
7311 (gnus-summary-remove-process-mark article))
7312 ;; Re-activate all groups that have been moved to.
7315 (set-buffer gnus-group-buffer)
7316 (when (gnus-group-goto-group (car to-groups) t)
7317 (gnus-group-get-new-news-this-group 1 t))
7320 (gnus-kill-buffer copy-buf)
7321 (gnus-summary-position-point)
7322 (gnus-set-mode-line 'summary)))
7324 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7325 "Move the current article to a different newsgroup.
7326 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7327 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7328 re-spool using this method."
7330 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7332 (defun gnus-summary-crosspost-article (&optional n)
7333 "Crosspost the current article to some other group."
7335 (gnus-summary-move-article n nil nil 'crosspost))
7337 (defcustom gnus-summary-respool-default-method nil
7338 "Default method for respooling an article.
7339 If nil, use to the current newsgroup method."
7340 :type '(choice (gnus-select-method :value (nnml ""))
7342 :group 'gnus-summary-mail)
7344 (defun gnus-summary-respool-article (&optional n method)
7345 "Respool the current article.
7346 The article will be squeezed through the mail spooling process again,
7347 which means that it will be put in some mail newsgroup or other
7348 depending on `nnmail-split-methods'.
7349 If N is a positive number, respool the N next articles.
7350 If N is a negative number, respool the N previous articles.
7351 If N is nil and any articles have been marked with the process mark,
7352 respool those articles instead.
7354 Respooling can be done both from mail groups and \"real\" newsgroups.
7355 In the former case, the articles in question will be moved from the
7356 current group into whatever groups they are destined to. In the
7357 latter case, they will be copied into the relevant groups."
7359 (list current-prefix-arg
7360 (let* ((methods (gnus-methods-using 'respool))
7362 (symbol-name (or gnus-summary-respool-default-method
7363 (car (gnus-find-method-for-group
7364 gnus-newsgroup-name)))))
7366 (gnus-completing-read
7367 methname "What backend do you want to use when respooling?"
7368 methods nil t nil 'gnus-mail-method-history))
7371 ((zerop (length (setq ms (gnus-servers-using-backend
7373 (list (intern method) ""))
7377 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7378 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7381 (error "No method given for respooling"))
7382 (if (assoc (symbol-name
7383 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7384 (gnus-methods-using 'respool))
7385 (gnus-summary-move-article n nil method)
7386 (gnus-summary-copy-article n nil method)))
7388 (defun gnus-summary-import-article (file)
7389 "Import an arbitrary file into a mail newsgroup."
7390 (interactive "fImport file: ")
7391 (let ((group gnus-newsgroup-name)
7392 (now (current-time))
7394 (unless (gnus-check-backend-function 'request-accept-article group)
7395 (error "%s does not support article importing" group))
7396 (or (file-readable-p file)
7397 (not (file-regular-p file))
7398 (error "Can't read %s" file))
7400 (set-buffer (gnus-get-buffer-create " *import file*"))
7402 (nnheader-insert-file-contents file)
7403 (goto-char (point-min))
7404 (unless (nnheader-article-p)
7405 ;; This doesn't look like an article, so we fudge some headers.
7406 (setq atts (file-attributes file)
7407 lines (count-lines (point-min) (point-max)))
7408 (insert "From: " (read-string "From: ") "\n"
7409 "Subject: " (read-string "Subject: ") "\n"
7410 "Date: " (message-make-date (nth 5 atts))
7412 "Message-ID: " (message-make-message-id) "\n"
7413 "Lines: " (int-to-string lines) "\n"
7414 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7415 (gnus-request-accept-article group nil t)
7416 (kill-buffer (current-buffer)))))
7418 (defun gnus-summary-article-posted-p ()
7419 "Say whether the current (mail) article is available from `gnus-select-method' as well.
7420 This will be the case if the article has both been mailed and posted."
7422 (let ((id (mail-header-references (gnus-summary-article-header)))
7423 (gnus-override-method
7424 (or gnus-refer-article-method gnus-select-method)))
7425 (if (gnus-request-head id "")
7426 (gnus-message 2 "The current message was found on %s"
7427 gnus-override-method)
7428 (gnus-message 2 "The current message couldn't be found on %s"
7429 gnus-override-method)
7432 (defun gnus-summary-expire-articles (&optional now)
7433 "Expire all articles that are marked as expirable in the current group."
7435 (when (gnus-check-backend-function
7436 'request-expire-articles gnus-newsgroup-name)
7437 ;; This backend supports expiry.
7438 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7439 (expirable (if total
7441 ;; We need to update the info for
7442 ;; this group for `gnus-list-of-read-articles'
7443 ;; to give us the right answer.
7444 (gnus-run-hooks 'gnus-exit-group-hook)
7445 (gnus-summary-update-info)
7446 (gnus-list-of-read-articles gnus-newsgroup-name))
7447 (setq gnus-newsgroup-expirable
7448 (sort gnus-newsgroup-expirable '<))))
7449 (expiry-wait (if now 'immediate
7450 (gnus-group-find-parameter
7451 gnus-newsgroup-name 'expiry-wait)))
7454 ;; There are expirable articles in this group, so we run them
7455 ;; through the expiry process.
7456 (gnus-message 6 "Expiring articles...")
7457 (unless (gnus-check-group gnus-newsgroup-name)
7458 (error "Can't open server for %s" gnus-newsgroup-name))
7459 ;; The list of articles that weren't expired is returned.
7462 (let ((nnmail-expiry-wait-function nil)
7463 (nnmail-expiry-wait expiry-wait))
7464 (setq es (gnus-request-expire-articles
7465 expirable gnus-newsgroup-name)))
7466 (setq es (gnus-request-expire-articles
7467 expirable gnus-newsgroup-name))))
7469 (setq gnus-newsgroup-expirable es))
7470 ;; We go through the old list of expirable, and mark all
7471 ;; really expired articles as nonexistent.
7472 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7473 (let ((gnus-use-cache nil))
7475 (unless (memq (car expirable) es)
7476 (when (gnus-data-find (car expirable))
7477 (gnus-summary-mark-article
7478 (car expirable) gnus-canceled-mark)))
7479 (setq expirable (cdr expirable)))))
7480 (gnus-message 6 "Expiring articles...done")))))
7482 (defun gnus-summary-expire-articles-now ()
7483 "Expunge all expirable articles in the current group.
7484 This means that *all* articles that are marked as expirable will be
7485 deleted forever, right now."
7487 (or gnus-expert-user
7489 "Are you really, really, really sure you want to delete all these messages? ")
7491 (gnus-summary-expire-articles t))
7493 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7494 (defun gnus-summary-delete-article (&optional n)
7495 "Delete the N next (mail) articles.
7496 This command actually deletes articles. This is not a marking
7497 command. The article will disappear forever from your life, never to
7499 If N is negative, delete backwards.
7500 If N is nil and articles have been marked with the process mark,
7501 delete these instead."
7503 (unless (gnus-check-backend-function 'request-expire-articles
7504 gnus-newsgroup-name)
7505 (error "The current newsgroup does not support article deletion"))
7506 ;; Compute the list of articles to delete.
7507 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
7509 (if (and gnus-novice-user
7510 (not (gnus-yes-or-no-p
7511 (format "Do you really want to delete %s forever? "
7512 (if (> (length articles) 1)
7513 (format "these %s articles" (length articles))
7516 ;; Delete the articles.
7517 (setq not-deleted (gnus-request-expire-articles
7518 articles gnus-newsgroup-name 'force))
7520 (gnus-summary-remove-process-mark (car articles))
7521 ;; The backend might not have been able to delete the article
7523 (unless (memq (car articles) not-deleted)
7524 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7525 (setq articles (cdr articles)))
7527 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7528 (gnus-summary-position-point)
7529 (gnus-set-mode-line 'summary)
7532 (defun gnus-summary-edit-article (&optional force)
7533 "Edit the current article.
7534 This will have permanent effect only in mail groups.
7535 If FORCE is non-nil, allow editing of articles even in read-only
7538 (let ((mail-parse-charset gnus-newsgroup-charset))
7540 (set-buffer gnus-summary-buffer)
7541 (gnus-set-global-variables)
7542 (when (and (not force)
7543 (gnus-group-read-only-p))
7544 (error "The current newsgroup does not support article editing"))
7545 (gnus-summary-show-article t)
7546 (gnus-article-edit-article
7548 `(lambda (no-highlight)
7549 (let ((mail-parse-charset ',gnus-newsgroup-charset))
7550 (gnus-summary-edit-article-done
7551 ,(or (mail-header-references gnus-current-headers) "")
7552 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
7554 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7556 (defun gnus-summary-edit-article-done (&optional references read-only buffer
7558 "Make edits to the current article permanent."
7560 ;; Replace the article.
7561 (let ((buf (current-buffer)))
7563 (insert-buffer-substring buf)
7564 (if (and (not read-only)
7565 (not (gnus-request-replace-article
7566 (cdr gnus-article-current) (car gnus-article-current)
7567 (current-buffer) t)))
7568 (error "Couldn't replace article")
7569 ;; Update the summary buffer.
7571 (equal (message-tokenize-header references " ")
7572 (message-tokenize-header
7573 (or (message-fetch-field "references") "") " ")))
7574 ;; We only have to update this line.
7577 (message-narrow-to-head)
7578 (let ((head (buffer-string))
7581 (insert (format "211 %d Article retrieved.\n"
7582 (cdr gnus-article-current)))
7585 (let ((nntp-server-buffer (current-buffer)))
7586 (setq header (car (gnus-get-newsgroup-headers
7588 (set-buffer gnus-summary-buffer)
7589 gnus-newsgroup-dependencies)
7592 (set-buffer gnus-summary-buffer)
7593 (gnus-data-set-header
7594 (gnus-data-find (cdr gnus-article-current))
7596 (gnus-summary-update-article-line
7597 (cdr gnus-article-current) header))))))
7599 (set-buffer (or buffer gnus-summary-buffer))
7600 (gnus-summary-update-article (cdr gnus-article-current)))
7601 ;; Prettify the article buffer again.
7602 (unless no-highlight
7604 (set-buffer gnus-article-buffer)
7605 ;;;!!! Fix this -- article should be rehighlighted.
7606 ;;;(gnus-run-hooks 'gnus-article-display-hook)
7607 (set-buffer gnus-original-article-buffer)
7608 (gnus-request-article
7609 (cdr gnus-article-current)
7610 (car gnus-article-current) (current-buffer))))
7611 ;; Prettify the summary buffer line.
7612 (when (gnus-visual-p 'summary-highlight 'highlight)
7613 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
7615 (defun gnus-summary-edit-wash (key)
7616 "Perform editing command KEY in the article buffer."
7620 (message "%s" (concat (this-command-keys) "- "))
7623 (gnus-summary-edit-article)
7624 (execute-kbd-macro (concat (this-command-keys) key))
7625 (gnus-article-edit-done))
7629 (defun gnus-summary-respool-query (&optional silent trace)
7630 "Query where the respool algorithm would put this article."
7632 (let (gnus-mark-article-hook)
7633 (gnus-summary-select-article)
7635 (set-buffer gnus-original-article-buffer)
7637 (message-narrow-to-head)
7638 (let ((groups (nnmail-article-group 'identity trace)))
7641 (message "This message would go to %s"
7642 (mapconcat 'car groups ", "))
7643 (message "This message would go to no groups"))
7646 (defun gnus-summary-respool-trace ()
7647 "Trace where the respool algorithm would put this article.
7648 Display a buffer showing all fancy splitting patterns which matched."
7650 (gnus-summary-respool-query nil t))
7652 ;; Summary marking commands.
7654 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
7655 "Mark articles which has the same subject as read, and then select the next.
7656 If UNMARK is positive, remove any kind of mark.
7657 If UNMARK is negative, tick articles."
7660 (setq unmark (prefix-numeric-value unmark)))
7662 (gnus-summary-mark-same-subject
7663 (gnus-summary-article-subject) unmark)))
7664 ;; Select next unread article. If auto-select-same mode, should
7665 ;; select the first unread article.
7666 (gnus-summary-next-article t (and gnus-auto-select-same
7667 (gnus-summary-article-subject)))
7668 (gnus-message 7 "%d article%s marked as %s"
7669 count (if (= count 1) " is" "s are")
7670 (if unmark "unread" "read"))))
7672 (defun gnus-summary-kill-same-subject (&optional unmark)
7673 "Mark articles which has the same subject as read.
7674 If UNMARK is positive, remove any kind of mark.
7675 If UNMARK is negative, tick articles."
7678 (setq unmark (prefix-numeric-value unmark)))
7680 (gnus-summary-mark-same-subject
7681 (gnus-summary-article-subject) unmark)))
7682 ;; If marked as read, go to next unread subject.
7684 ;; Go to next unread subject.
7685 (gnus-summary-next-subject 1 t))
7686 (gnus-message 7 "%d articles are marked as %s"
7687 count (if unmark "unread" "read"))))
7689 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7690 "Mark articles with same SUBJECT as read, and return marked number.
7691 If optional argument UNMARK is positive, remove any kinds of marks.
7692 If optional argument UNMARK is negative, mark articles as unread instead."
7696 ((null unmark) ; Mark as read.
7699 (gnus-summary-mark-article-as-read gnus-killed-mark)
7700 (gnus-summary-show-thread) t)
7701 (gnus-summary-find-subject subject))
7702 (setq count (1+ count))))
7703 ((> unmark 0) ; Tick.
7706 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
7707 (gnus-summary-show-thread) t)
7708 (gnus-summary-find-subject subject))
7709 (setq count (1+ count))))
7710 (t ; Mark as unread.
7713 (gnus-summary-mark-article-as-unread gnus-unread-mark)
7714 (gnus-summary-show-thread) t)
7715 (gnus-summary-find-subject subject))
7716 (setq count (1+ count)))))
7717 (gnus-set-mode-line 'summary)
7718 ;; Return the number of marked articles.
7721 (defun gnus-summary-mark-as-processable (n &optional unmark)
7722 "Set the process mark on the next N articles.
7723 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7724 the process mark instead. The difference between N and the actual
7725 number of articles marked is returned."
7727 (let ((backward (< n 0))
7732 (gnus-summary-remove-process-mark
7733 (gnus-summary-article-number))
7734 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7735 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7738 (gnus-message 7 "No more articles"))
7739 (gnus-summary-recenter)
7740 (gnus-summary-position-point)
7743 (defun gnus-summary-unmark-as-processable (n)
7744 "Remove the process mark from the next N articles.
7745 If N is negative, unmark backward instead. The difference between N and
7746 the actual number of articles unmarked is returned."
7748 (gnus-summary-mark-as-processable n t))
7750 (defun gnus-summary-unmark-all-processable ()
7751 "Remove the process mark from all articles."
7754 (while gnus-newsgroup-processable
7755 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7756 (gnus-summary-position-point))
7758 (defun gnus-summary-mark-as-expirable (n)
7759 "Mark N articles forward as expirable.
7760 If N is negative, mark backward instead. The difference between N and
7761 the actual number of articles marked is returned."
7763 (gnus-summary-mark-forward n gnus-expirable-mark))
7765 (defun gnus-summary-mark-article-as-replied (article)
7766 "Mark ARTICLE replied and update the summary line."
7767 (push article gnus-newsgroup-replied)
7768 (let ((buffer-read-only nil))
7769 (when (gnus-summary-goto-subject article nil t)
7770 (gnus-summary-update-secondary-mark article))))
7772 (defun gnus-summary-set-bookmark (article)
7773 "Set a bookmark in current article."
7774 (interactive (list (gnus-summary-article-number)))
7775 (when (or (not (get-buffer gnus-article-buffer))
7776 (not gnus-current-article)
7777 (not gnus-article-current)
7778 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7779 (error "No current article selected"))
7780 ;; Remove old bookmark, if one exists.
7781 (let ((old (assq article gnus-newsgroup-bookmarks)))
7783 (setq gnus-newsgroup-bookmarks
7784 (delq old gnus-newsgroup-bookmarks))))
7785 ;; Set the new bookmark, which is on the form
7786 ;; (article-number . line-number-in-body).
7790 (set-buffer gnus-article-buffer)
7794 (goto-char (point-min))
7795 (search-forward "\n\n" nil t)
7798 gnus-newsgroup-bookmarks)
7799 (gnus-message 6 "A bookmark has been added to the current article."))
7801 (defun gnus-summary-remove-bookmark (article)
7802 "Remove the bookmark from the current article."
7803 (interactive (list (gnus-summary-article-number)))
7804 ;; Remove old bookmark, if one exists.
7805 (let ((old (assq article gnus-newsgroup-bookmarks)))
7808 (setq gnus-newsgroup-bookmarks
7809 (delq old gnus-newsgroup-bookmarks))
7810 (gnus-message 6 "Removed bookmark."))
7811 (gnus-message 6 "No bookmark in current article."))))
7813 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7814 (defun gnus-summary-mark-as-dormant (n)
7815 "Mark N articles forward as dormant.
7816 If N is negative, mark backward instead. The difference between N and
7817 the actual number of articles marked is returned."
7819 (gnus-summary-mark-forward n gnus-dormant-mark))
7821 (defun gnus-summary-set-process-mark (article)
7822 "Set the process mark on ARTICLE and update the summary line."
7823 (setq gnus-newsgroup-processable
7825 (delq article gnus-newsgroup-processable)))
7826 (when (gnus-summary-goto-subject article)
7827 (gnus-summary-show-thread)
7828 (gnus-summary-goto-subject article)
7829 (gnus-summary-update-secondary-mark article)))
7831 (defun gnus-summary-remove-process-mark (article)
7832 "Remove the process mark from ARTICLE and update the summary line."
7833 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7834 (when (gnus-summary-goto-subject article)
7835 (gnus-summary-show-thread)
7836 (gnus-summary-goto-subject article)
7837 (gnus-summary-update-secondary-mark article)))
7839 (defun gnus-summary-set-saved-mark (article)
7840 "Set the process mark on ARTICLE and update the summary line."
7841 (push article gnus-newsgroup-saved)
7842 (when (gnus-summary-goto-subject article)
7843 (gnus-summary-update-secondary-mark article)))
7845 (defun gnus-summary-mark-forward (n &optional mark no-expire)
7846 "Mark N articles as read forwards.
7847 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
7848 The difference between N and the actual number of articles marked is
7851 (gnus-summary-show-thread)
7852 (let ((backward (< n 0))
7853 (gnus-summary-goto-unread
7854 (and gnus-summary-goto-unread
7855 (not (eq gnus-summary-goto-unread 'never))
7856 (not (memq mark (list gnus-unread-mark
7857 gnus-ticked-mark gnus-dormant-mark)))))
7859 (mark (or mark gnus-del-mark)))
7861 (gnus-summary-mark-article nil mark no-expire)
7862 (zerop (gnus-summary-next-subject
7864 (and gnus-summary-goto-unread
7865 (not (eq gnus-summary-goto-unread 'never)))
7869 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
7870 (gnus-summary-recenter)
7871 (gnus-summary-position-point)
7872 (gnus-set-mode-line 'summary)
7875 (defun gnus-summary-mark-article-as-read (mark)
7876 "Mark the current article quickly as read with MARK."
7877 (let ((article (gnus-summary-article-number)))
7878 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7879 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7880 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7881 (push (cons article mark) gnus-newsgroup-reads)
7882 ;; Possibly remove from cache, if that is used.
7883 (when gnus-use-cache
7884 (gnus-cache-enter-remove-article article))
7885 ;; Allow the backend to change the mark.
7886 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7887 ;; Check for auto-expiry.
7888 (when (and gnus-newsgroup-auto-expire
7889 (memq mark gnus-auto-expirable-marks))
7890 (setq mark gnus-expirable-mark)
7891 ;; Let the backend know about the mark change.
7892 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7893 (push article gnus-newsgroup-expirable))
7894 ;; Set the mark in the buffer.
7895 (gnus-summary-update-mark mark 'unread)
7898 (defun gnus-summary-mark-article-as-unread (mark)
7899 "Mark the current article quickly as unread with MARK."
7900 (let* ((article (gnus-summary-article-number))
7901 (old-mark (gnus-summary-article-mark article)))
7902 ;; Allow the backend to change the mark.
7903 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7904 (if (eq mark old-mark)
7908 (gnus-error 1 "Can't mark negative article numbers")
7910 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7911 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7912 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
7913 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
7914 (cond ((= mark gnus-ticked-mark)
7915 (push article gnus-newsgroup-marked))
7916 ((= mark gnus-dormant-mark)
7917 (push article gnus-newsgroup-dormant))
7919 (push article gnus-newsgroup-unreads)))
7920 (gnus-pull article gnus-newsgroup-reads)
7922 ;; See whether the article is to be put in the cache.
7924 (vectorp (gnus-summary-article-header article))
7926 (gnus-cache-possibly-enter-article
7927 gnus-newsgroup-name article
7928 (= mark gnus-ticked-mark)
7929 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7932 (gnus-summary-update-mark mark 'unread)
7935 (defun gnus-summary-mark-article (&optional article mark no-expire)
7936 "Mark ARTICLE with MARK. MARK can be any character.
7937 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
7938 `??' (dormant) and `?E' (expirable).
7939 If MARK is nil, then the default character `?r' is used.
7940 If ARTICLE is nil, then the article on the current line will be
7942 ;; The mark might be a string.
7943 (when (stringp mark)
7944 (setq mark (aref mark 0)))
7945 ;; If no mark is given, then we check auto-expiring.
7947 (setq mark gnus-del-mark))
7948 (when (and (not no-expire)
7949 gnus-newsgroup-auto-expire
7950 (memq mark gnus-auto-expirable-marks))
7951 (setq mark gnus-expirable-mark))
7952 (let ((article (or article (gnus-summary-article-number)))
7953 (old-mark (gnus-summary-article-mark article)))
7954 ;; Allow the backend to change the mark.
7955 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7956 (if (eq mark old-mark)
7959 (error "No article on current line"))
7960 (if (not (if (or (= mark gnus-unread-mark)
7961 (= mark gnus-ticked-mark)
7962 (= mark gnus-dormant-mark))
7963 (gnus-mark-article-as-unread article mark)
7964 (gnus-mark-article-as-read article mark)))
7966 ;; See whether the article is to be put in the cache.
7968 (not (= mark gnus-canceled-mark))
7969 (vectorp (gnus-summary-article-header article))
7971 (gnus-cache-possibly-enter-article
7972 gnus-newsgroup-name article
7973 (= mark gnus-ticked-mark)
7974 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7976 (when (gnus-summary-goto-subject article nil t)
7977 (let ((buffer-read-only nil))
7978 (gnus-summary-show-thread)
7980 (gnus-summary-update-mark mark 'unread)
7983 (defun gnus-summary-update-secondary-mark (article)
7984 "Update the secondary (read, process, cache) mark."
7985 (gnus-summary-update-mark
7986 (cond ((memq article gnus-newsgroup-processable)
7988 ((memq article gnus-newsgroup-cached)
7990 ((memq article gnus-newsgroup-replied)
7992 ((memq article gnus-newsgroup-saved)
7994 (t gnus-unread-mark))
7996 (when (gnus-visual-p 'summary-highlight 'highlight)
7997 (gnus-run-hooks 'gnus-summary-update-hook))
8000 (defun gnus-summary-update-mark (mark type)
8001 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
8002 (buffer-read-only nil))
8003 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
8005 (when (looking-at "\r")
8007 (when (<= (+ forward (point)) (point-max))
8008 ;; Go to the right position on the line.
8009 (goto-char (+ forward (point)))
8010 ;; Replace the old mark with the new mark.
8011 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
8012 ;; Optionally update the marks by some user rule.
8013 (when (eq type 'unread)
8015 (gnus-data-find (gnus-summary-article-number)) mark)
8016 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
8018 (defun gnus-mark-article-as-read (article &optional mark)
8019 "Enter ARTICLE in the pertinent lists and remove it from others."
8020 ;; Make the article expirable.
8021 (let ((mark (or mark gnus-del-mark)))
8022 (if (= mark gnus-expirable-mark)
8023 (push article gnus-newsgroup-expirable)
8024 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
8025 ;; Remove from unread and marked lists.
8026 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8027 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8028 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8029 (push (cons article mark) gnus-newsgroup-reads)
8030 ;; Possibly remove from cache, if that is used.
8031 (when gnus-use-cache
8032 (gnus-cache-enter-remove-article article))
8035 (defun gnus-mark-article-as-unread (article &optional mark)
8036 "Enter ARTICLE in the pertinent lists and remove it from others."
8037 (let ((mark (or mark gnus-ticked-mark)))
8040 (gnus-error 1 "Can't mark negative article numbers")
8042 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
8043 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
8044 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
8045 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8047 ;; Unsuppress duplicates?
8048 (when gnus-suppress-duplicates
8049 (gnus-dup-unsuppress-article article))
8051 (cond ((= mark gnus-ticked-mark)
8052 (push article gnus-newsgroup-marked))
8053 ((= mark gnus-dormant-mark)
8054 (push article gnus-newsgroup-dormant))
8056 (push article gnus-newsgroup-unreads)))
8057 (gnus-pull article gnus-newsgroup-reads)
8060 (defalias 'gnus-summary-mark-as-unread-forward
8061 'gnus-summary-tick-article-forward)
8062 (make-obsolete 'gnus-summary-mark-as-unread-forward
8063 'gnus-summary-tick-article-forward)
8064 (defun gnus-summary-tick-article-forward (n)
8065 "Tick N articles forwards.
8066 If N is negative, tick backwards instead.
8067 The difference between N and the number of articles ticked is returned."
8069 (gnus-summary-mark-forward n gnus-ticked-mark))
8071 (defalias 'gnus-summary-mark-as-unread-backward
8072 'gnus-summary-tick-article-backward)
8073 (make-obsolete 'gnus-summary-mark-as-unread-backward
8074 'gnus-summary-tick-article-backward)
8075 (defun gnus-summary-tick-article-backward (n)
8076 "Tick N articles backwards.
8077 The difference between N and the number of articles ticked is returned."
8079 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
8081 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8082 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8083 (defun gnus-summary-tick-article (&optional article clear-mark)
8084 "Mark current article as unread.
8085 Optional 1st argument ARTICLE specifies article number to be marked as unread.
8086 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
8088 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
8091 (defun gnus-summary-mark-as-read-forward (n)
8092 "Mark N articles as read forwards.
8093 If N is negative, mark backwards instead.
8094 The difference between N and the actual number of articles marked is
8097 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
8099 (defun gnus-summary-mark-as-read-backward (n)
8100 "Mark the N articles as read backwards.
8101 The difference between N and the actual number of articles marked is
8104 (gnus-summary-mark-forward
8105 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
8107 (defun gnus-summary-mark-as-read (&optional article mark)
8108 "Mark current article as read.
8109 ARTICLE specifies the article to be marked as read.
8110 MARK specifies a string to be inserted at the beginning of the line."
8111 (gnus-summary-mark-article article mark))
8113 (defun gnus-summary-clear-mark-forward (n)
8114 "Clear marks from N articles forward.
8115 If N is negative, clear backward instead.
8116 The difference between N and the number of marks cleared is returned."
8118 (gnus-summary-mark-forward n gnus-unread-mark))
8120 (defun gnus-summary-clear-mark-backward (n)
8121 "Clear marks from N articles backward.
8122 The difference between N and the number of marks cleared is returned."
8124 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8126 (defun gnus-summary-mark-unread-as-read ()
8127 "Intended to be used by `gnus-summary-mark-article-hook'."
8128 (when (memq gnus-current-article gnus-newsgroup-unreads)
8129 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
8131 (defun gnus-summary-mark-read-and-unread-as-read ()
8132 "Intended to be used by `gnus-summary-mark-article-hook'."
8133 (let ((mark (gnus-summary-article-mark)))
8134 (when (or (gnus-unread-mark-p mark)
8135 (gnus-read-mark-p mark))
8136 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
8138 (defun gnus-summary-mark-region-as-read (point mark all)
8139 "Mark all unread articles between point and mark as read.
8140 If given a prefix, mark all articles between point and mark as read,
8141 even ticked and dormant ones."
8142 (interactive "r\nP")
8151 (memq (setq article (gnus-summary-article-number))
8152 gnus-newsgroup-unreads))
8153 (gnus-summary-mark-article article gnus-del-mark))
8155 (gnus-summary-find-next))))))
8157 (defun gnus-summary-mark-below (score mark)
8158 "Mark articles with score less than SCORE with MARK."
8159 (interactive "P\ncMark: ")
8160 (setq score (if score
8161 (prefix-numeric-value score)
8162 (or gnus-summary-default-score 0)))
8164 (set-buffer gnus-summary-buffer)
8165 (goto-char (point-min))
8168 (and (< (gnus-summary-article-score) score)
8169 (gnus-summary-mark-article nil mark))
8170 (gnus-summary-find-next)))))
8172 (defun gnus-summary-kill-below (&optional score)
8173 "Mark articles with score below SCORE as read."
8175 (gnus-summary-mark-below score gnus-killed-mark))
8177 (defun gnus-summary-clear-above (&optional score)
8178 "Clear all marks from articles with score above SCORE."
8180 (gnus-summary-mark-above score gnus-unread-mark))
8182 (defun gnus-summary-tick-above (&optional score)
8183 "Tick all articles with score above SCORE."
8185 (gnus-summary-mark-above score gnus-ticked-mark))
8187 (defun gnus-summary-mark-above (score mark)
8188 "Mark articles with score over SCORE with MARK."
8189 (interactive "P\ncMark: ")
8190 (setq score (if score
8191 (prefix-numeric-value score)
8192 (or gnus-summary-default-score 0)))
8194 (set-buffer gnus-summary-buffer)
8195 (goto-char (point-min))
8197 (when (> (gnus-summary-article-score) score)
8198 (gnus-summary-mark-article nil mark))
8200 (gnus-summary-find-next)))))
8202 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8203 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
8204 (defun gnus-summary-limit-include-expunged (&optional no-error)
8205 "Display all the hidden articles that were expunged for low scores."
8207 (let ((buffer-read-only nil))
8208 (let ((scored gnus-newsgroup-scored)
8211 (unless (gnus-summary-goto-subject (caar scored))
8212 (and (setq h (gnus-summary-article-header (caar scored)))
8213 (< (cdar scored) gnus-summary-expunge-below)
8215 (setq scored (cdr scored)))
8217 (when (not no-error)
8218 (error "No expunged articles hidden"))
8219 (goto-char (point-min))
8220 (gnus-summary-prepare-unthreaded (nreverse headers))
8221 (goto-char (point-min))
8222 (gnus-summary-position-point)
8225 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
8226 "Mark all unread articles in this newsgroup as read.
8227 If prefix argument ALL is non-nil, ticked and dormant articles will
8228 also be marked as read.
8229 If QUIETLY is non-nil, no questions will be asked.
8230 If TO-HERE is non-nil, it should be a point in the buffer. All
8231 articles before this point will be marked as read.
8232 Note that this function will only catch up the unread article
8233 in the current summary buffer limitation.
8234 The number of articles marked as read is returned."
8239 (not gnus-interactive-catchup) ;Without confirmation?
8243 "Mark absolutely all articles as read? "
8244 "Mark all unread articles as read? ")))
8246 (not gnus-newsgroup-adaptive)
8247 (not gnus-newsgroup-auto-expire)
8248 (not gnus-suppress-duplicates)
8249 (or (not gnus-use-cache)
8250 (eq gnus-use-cache 'passive)))
8253 (setq gnus-newsgroup-marked nil
8254 gnus-newsgroup-dormant nil))
8255 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8256 ;; We actually mark all articles as canceled, which we
8257 ;; have to do when using auto-expiry or adaptive scoring.
8258 (gnus-summary-show-all-threads)
8259 (when (gnus-summary-first-subject (not all) t)
8261 (if to-here (< (point) to-here) t)
8262 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8263 (gnus-summary-find-next (not all) nil nil t))))
8264 (gnus-set-mode-line 'summary))
8266 (gnus-summary-position-point)))
8268 (defun gnus-summary-catchup-to-here (&optional all)
8269 "Mark all unticked articles before the current one as read.
8270 If ALL is non-nil, also mark ticked and dormant articles as read."
8273 (gnus-save-hidden-threads
8274 (let ((beg (point)))
8275 ;; We check that there are unread articles.
8276 (when (or all (gnus-summary-find-prev))
8277 (gnus-summary-catchup all t beg)))))
8278 (gnus-summary-position-point))
8280 (defun gnus-summary-catchup-all (&optional quietly)
8281 "Mark all articles in this newsgroup as read."
8283 (gnus-summary-catchup t quietly))
8285 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8286 "Mark all articles not marked as unread in this newsgroup as read, then exit.
8287 If prefix argument ALL is non-nil, all articles are marked as read."
8289 (when (gnus-summary-catchup all quietly nil 'fast)
8290 ;; Select next newsgroup or exit.
8291 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
8292 (eq gnus-auto-select-next 'quietly))
8293 (gnus-summary-next-group nil)
8294 (gnus-summary-exit))))
8296 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8297 "Mark all articles in this newsgroup as read, and then exit."
8299 (gnus-summary-catchup-and-exit t quietly))
8301 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
8302 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8303 "Mark all articles in this group as read and select the next group.
8304 If given a prefix, mark all articles, unread as well as ticked, as
8308 (gnus-summary-catchup all))
8309 (gnus-summary-next-article t nil nil t))
8311 ;; Thread-based commands.
8313 (defun gnus-summary-articles-in-thread (&optional article)
8314 "Return a list of all articles in the current thread.
8315 If ARTICLE is non-nil, return all articles in the thread that starts
8317 (let* ((article (or article (gnus-summary-article-number)))
8318 (data (gnus-data-find-list article))
8319 (top-level (gnus-data-level (car data)))
8321 (cond ((null gnus-thread-operation-ignore-subject)
8322 (gnus-simplify-subject-re
8323 (mail-header-subject (gnus-data-header (car data)))))
8324 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8325 (gnus-simplify-subject-fuzzy
8326 (mail-header-subject (gnus-data-header (car data)))))
8328 (end-point (save-excursion
8329 (if (gnus-summary-go-to-next-thread)
8330 (point) (point-max))))
8333 (< (gnus-data-pos (car data)) end-point))
8334 (when (or (not top-subject)
8335 (string= top-subject
8336 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8337 (gnus-simplify-subject-fuzzy
8338 (mail-header-subject
8339 (gnus-data-header (car data))))
8340 (gnus-simplify-subject-re
8341 (mail-header-subject
8342 (gnus-data-header (car data)))))))
8343 (push (gnus-data-number (car data)) articles))
8344 (unless (and (setq data (cdr data))
8345 (> (gnus-data-level (car data)) top-level))
8347 ;; Return the list of articles.
8348 (nreverse articles)))
8350 (defun gnus-summary-rethread-current ()
8351 "Rethread the thread the current article is part of."
8353 (let* ((gnus-show-threads t)
8354 (article (gnus-summary-article-number))
8355 (id (mail-header-id (gnus-summary-article-header)))
8356 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8358 (error "No article on the current line"))
8359 (gnus-rebuild-thread id)
8360 (gnus-summary-goto-subject article)))
8362 (defun gnus-summary-reparent-thread ()
8363 "Make the current article child of the marked (or previous) article.
8365 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8366 is non-nil or the Subject: of both articles are the same."
8368 (unless (not (gnus-group-read-only-p))
8369 (error "The current newsgroup does not support article editing"))
8370 (unless (<= (length gnus-newsgroup-processable) 1)
8371 (error "No more than one article may be marked"))
8372 (save-window-excursion
8373 (let ((gnus-article-buffer " *reparent*")
8374 (current-article (gnus-summary-article-number))
8375 ;; First grab the marked article, otherwise one line up.
8376 (parent-article (if (not (null gnus-newsgroup-processable))
8377 (car gnus-newsgroup-processable)
8379 (if (eq (forward-line -1) 0)
8380 (gnus-summary-article-number)
8381 (error "Beginning of summary buffer"))))))
8382 (unless (not (eq current-article parent-article))
8383 (error "An article may not be self-referential"))
8384 (let ((message-id (mail-header-id
8385 (gnus-summary-article-header parent-article))))
8386 (unless (and message-id (not (equal message-id "")))
8387 (error "No message-id in desired parent"))
8388 (gnus-with-article current-article
8389 (goto-char (point-min))
8390 (if (re-search-forward "^References: " nil t)
8392 (re-search-forward "^[^ \t]" nil t)
8395 (insert " " message-id))
8396 (insert "References: " message-id "\n")))
8397 (set-buffer gnus-summary-buffer)
8398 (gnus-summary-unmark-all-processable)
8399 (gnus-summary-update-article current-article)
8400 (gnus-summary-rethread-current)
8401 (gnus-message 3 "Article %d is now the child of article %d"
8402 current-article parent-article)))))
8404 (defun gnus-summary-toggle-threads (&optional arg)
8405 "Toggle showing conversation threads.
8406 If ARG is positive number, turn showing conversation threads on."
8408 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8409 (setq gnus-show-threads
8410 (if (null arg) (not gnus-show-threads)
8411 (> (prefix-numeric-value arg) 0)))
8412 (gnus-summary-prepare)
8413 (gnus-summary-goto-subject current)
8414 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8415 (gnus-summary-position-point)))
8417 (defun gnus-summary-show-all-threads ()
8421 (let ((buffer-read-only nil))
8422 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8423 (gnus-summary-position-point))
8425 (defun gnus-summary-show-thread ()
8426 "Show thread subtrees.
8427 Returns nil if no thread was there to be shown."
8429 (let ((buffer-read-only nil)
8431 ;; first goto end then to beg, to have point at beg after let
8432 (end (progn (end-of-line) (point)))
8433 (beg (progn (beginning-of-line) (point))))
8435 ;; Any hidden lines here?
8436 (search-forward "\r" end t)
8437 (subst-char-in-region beg end ?\^M ?\n t)
8439 (gnus-summary-position-point))))
8441 (defun gnus-summary-hide-all-threads ()
8442 "Hide all thread subtrees."
8445 (goto-char (point-min))
8446 (gnus-summary-hide-thread)
8447 (while (zerop (gnus-summary-next-thread 1 t))
8448 (gnus-summary-hide-thread)))
8449 (gnus-summary-position-point))
8451 (defun gnus-summary-hide-thread ()
8452 "Hide thread subtrees.
8453 Returns nil if no threads were there to be hidden."
8455 (let ((buffer-read-only nil)
8457 (article (gnus-summary-article-number)))
8459 ;; Go forward until either the buffer ends or the subthread
8461 (when (and (not (eobp))
8462 (or (zerop (gnus-summary-next-thread 1 t))
8463 (goto-char (point-max))))
8465 (if (and (> (point) start)
8466 (search-backward "\n" start t))
8468 (subst-char-in-region start (point) ?\n ?\^M)
8469 (gnus-summary-goto-subject article))
8472 ;;(gnus-summary-position-point)
8475 (defun gnus-summary-go-to-next-thread (&optional previous)
8476 "Go to the same level (or less) next thread.
8477 If PREVIOUS is non-nil, go to previous thread instead.
8478 Return the article number moved to, or nil if moving was impossible."
8479 (let ((level (gnus-summary-thread-level))
8480 (way (if previous -1 1))
8483 (while (and (not (eobp))
8484 (< level (gnus-summary-thread-level)))
8492 (gnus-summary-article-number)
8495 (defun gnus-summary-next-thread (n &optional silent)
8496 "Go to the same level next N'th thread.
8497 If N is negative, search backward instead.
8498 Returns the difference between N and the number of skips actually
8501 If SILENT, don't output messages."
8503 (let ((backward (< n 0))
8506 (gnus-summary-go-to-next-thread backward))
8509 (gnus-summary-position-point))
8510 (when (and (not silent) (/= 0 n))
8511 (gnus-message 7 "No more threads"))
8514 (defun gnus-summary-prev-thread (n)
8515 "Go to the same level previous N'th thread.
8516 Returns the difference between N and the number of skips actually
8519 (gnus-summary-next-thread (- n)))
8521 (defun gnus-summary-go-down-thread ()
8522 "Go down one level in the current thread."
8523 (let ((children (gnus-summary-article-children)))
8525 (gnus-summary-goto-subject (car children)))))
8527 (defun gnus-summary-go-up-thread ()
8528 "Go up one level in the current thread."
8529 (let ((parent (gnus-summary-article-parent)))
8531 (gnus-summary-goto-subject parent))))
8533 (defun gnus-summary-down-thread (n)
8534 "Go down thread N steps.
8535 If N is negative, go up instead.
8536 Returns the difference between N and how many steps down that were
8542 (if up (gnus-summary-go-up-thread)
8543 (gnus-summary-go-down-thread)))
8545 (gnus-summary-position-point)
8547 (gnus-message 7 "Can't go further"))
8550 (defun gnus-summary-up-thread (n)
8551 "Go up thread N steps.
8552 If N is negative, go up instead.
8553 Returns the difference between N and how many steps down that were
8556 (gnus-summary-down-thread (- n)))
8558 (defun gnus-summary-top-thread ()
8559 "Go to the top of the thread."
8561 (while (gnus-summary-go-up-thread))
8562 (gnus-summary-article-number))
8564 (defun gnus-summary-kill-thread (&optional unmark)
8565 "Mark articles under current thread as read.
8566 If the prefix argument is positive, remove any kinds of marks.
8567 If the prefix argument is negative, tick articles instead."
8570 (setq unmark (prefix-numeric-value unmark)))
8571 (let ((articles (gnus-summary-articles-in-thread)))
8573 ;; Expand the thread.
8574 (gnus-summary-show-thread)
8575 ;; Mark all the articles.
8577 (gnus-summary-goto-subject (car articles))
8578 (cond ((null unmark)
8579 (gnus-summary-mark-article-as-read gnus-killed-mark))
8581 (gnus-summary-mark-article-as-unread gnus-unread-mark))
8583 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
8584 (setq articles (cdr articles))))
8585 ;; Hide killed subtrees.
8587 gnus-thread-hide-killed
8588 (gnus-summary-hide-thread))
8589 ;; If marked as read, go to next unread subject.
8591 ;; Go to next unread subject.
8592 (gnus-summary-next-subject 1 t)))
8593 (gnus-set-mode-line 'summary))
8595 ;; Summary sorting commands
8597 (defun gnus-summary-sort-by-number (&optional reverse)
8598 "Sort the summary buffer by article number.
8599 Argument REVERSE means reverse order."
8601 (gnus-summary-sort 'number reverse))
8603 (defun gnus-summary-sort-by-author (&optional reverse)
8604 "Sort the summary buffer by author name alphabetically.
8605 If case-fold-search is non-nil, case of letters is ignored.
8606 Argument REVERSE means reverse order."
8608 (gnus-summary-sort 'author reverse))
8610 (defun gnus-summary-sort-by-subject (&optional reverse)
8611 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8612 If case-fold-search is non-nil, case of letters is ignored.
8613 Argument REVERSE means reverse order."
8615 (gnus-summary-sort 'subject reverse))
8617 (defun gnus-summary-sort-by-date (&optional reverse)
8618 "Sort the summary buffer by date.
8619 Argument REVERSE means reverse order."
8621 (gnus-summary-sort 'date reverse))
8623 (defun gnus-summary-sort-by-score (&optional reverse)
8624 "Sort the summary buffer by score.
8625 Argument REVERSE means reverse order."
8627 (gnus-summary-sort 'score reverse))
8629 (defun gnus-summary-sort-by-lines (&optional reverse)
8630 "Sort the summary buffer by the number of lines.
8631 Argument REVERSE means reverse order."
8633 (gnus-summary-sort 'lines reverse))
8635 (defun gnus-summary-sort-by-chars (&optional reverse)
8636 "Sort the summary buffer by article length.
8637 Argument REVERSE means reverse order."
8639 (gnus-summary-sort 'chars reverse))
8641 (defun gnus-summary-sort (predicate reverse)
8642 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
8643 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
8644 (article (intern (format "gnus-article-sort-by-%s" predicate)))
8645 (gnus-thread-sort-functions
8650 (gnus-article-sort-functions
8656 (gnus-summary-prepare-hook nil))
8657 ;; We do the sorting by regenerating the threads.
8658 (gnus-summary-prepare)
8659 ;; Hide subthreads if needed.
8660 (when (and gnus-show-threads gnus-thread-hide-subtree)
8661 (gnus-summary-hide-all-threads))))
8663 ;; Summary saving commands.
8665 (defun gnus-summary-save-article (&optional n not-saved)
8666 "Save the current article using the default saver function.
8667 If N is a positive number, save the N next articles.
8668 If N is a negative number, save the N previous articles.
8669 If N is nil and any articles have been marked with the process mark,
8670 save those articles instead.
8671 The variable `gnus-default-article-saver' specifies the saver function."
8673 (let* ((articles (gnus-summary-work-articles n))
8674 (save-buffer (save-excursion
8675 (nnheader-set-temp-buffer " *Gnus Save*")))
8676 (num (length articles))
8678 (dolist (article articles)
8679 (setq header (gnus-summary-article-header article))
8680 (if (not (vectorp header))
8681 ;; This is a pseudo-article.
8682 (if (assq 'name header)
8683 (gnus-copy-file (cdr (assq 'name header)))
8684 (gnus-message 1 "Article %d is unsaveable" article))
8685 ;; This is a real article.
8686 (save-window-excursion
8687 (gnus-summary-select-article t nil nil article))
8689 (set-buffer save-buffer)
8691 (insert-buffer-substring gnus-original-article-buffer))
8692 (setq file (gnus-article-save save-buffer file num))
8693 (gnus-summary-remove-process-mark article)
8695 (gnus-summary-set-saved-mark article))))
8696 (gnus-kill-buffer save-buffer)
8697 (gnus-summary-position-point)
8698 (gnus-set-mode-line 'summary)
8701 (defun gnus-summary-pipe-output (&optional arg)
8702 "Pipe the current article to a subprocess.
8703 If N is a positive number, pipe the N next articles.
8704 If N is a negative number, pipe the N previous articles.
8705 If N is nil and any articles have been marked with the process mark,
8706 pipe those articles instead."
8708 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8709 (gnus-summary-save-article arg t))
8710 (gnus-configure-windows 'pipe))
8712 (defun gnus-summary-save-article-mail (&optional arg)
8713 "Append the current article to an mail file.
8714 If N is a positive number, save the N next articles.
8715 If N is a negative number, save the N previous articles.
8716 If N is nil and any articles have been marked with the process mark,
8717 save those articles instead."
8719 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8720 (gnus-summary-save-article arg)))
8722 (defun gnus-summary-save-article-rmail (&optional arg)
8723 "Append the current article to an rmail file.
8724 If N is a positive number, save the N next articles.
8725 If N is a negative number, save the N previous articles.
8726 If N is nil and any articles have been marked with the process mark,
8727 save those articles instead."
8729 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
8730 (gnus-summary-save-article arg)))
8732 (defun gnus-summary-save-article-file (&optional arg)
8733 "Append the current article to a file.
8734 If N is a positive number, save the N next articles.
8735 If N is a negative number, save the N previous articles.
8736 If N is nil and any articles have been marked with the process mark,
8737 save those articles instead."
8739 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8740 (gnus-summary-save-article arg)))
8742 (defun gnus-summary-write-article-file (&optional arg)
8743 "Write the current article to a file, deleting the previous file.
8744 If N is a positive number, save the N next articles.
8745 If N is a negative number, save the N previous articles.
8746 If N is nil and any articles have been marked with the process mark,
8747 save those articles instead."
8749 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
8750 (gnus-summary-save-article arg)))
8752 (defun gnus-summary-save-article-body-file (&optional arg)
8753 "Append the current article body to a file.
8754 If N is a positive number, save the N next articles.
8755 If N is a negative number, save the N previous articles.
8756 If N is nil and any articles have been marked with the process mark,
8757 save those articles instead."
8759 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
8760 (gnus-summary-save-article arg)))
8762 (defun gnus-summary-pipe-message (program)
8763 "Pipe the current article through PROGRAM."
8764 (interactive "sProgram: ")
8765 (gnus-summary-select-article)
8766 (let ((mail-header-separator ""))
8767 (gnus-eval-in-buffer-window gnus-article-buffer
8770 (let ((start (window-start))
8772 (message-pipe-buffer-body program)
8773 (set-window-start (get-buffer-window (current-buffer)) start))))))
8775 (defun gnus-get-split-value (methods)
8776 "Return a value based on the split METHODS."
8777 (let (split-name method result match)
8780 (set-buffer gnus-original-article-buffer)
8782 (nnheader-narrow-to-headers)
8784 (goto-char (point-min))
8785 (setq method (pop methods))
8786 (setq match (car method))
8789 ;; Regular expression.
8791 (re-search-forward match nil t)))
8792 ((gnus-functionp match)
8796 (setq result (funcall match gnus-newsgroup-name))))
8801 (setq result (eval match)))))
8802 (setq split-name (append (cdr method) split-name))
8803 (cond ((stringp result)
8804 (push (expand-file-name
8805 result gnus-article-save-directory)
8808 (setq split-name (append result split-name)))))))))
8809 (nreverse split-name)))
8811 (defun gnus-valid-move-group-p (group)
8814 (symbol-value group)
8815 (gnus-get-function (gnus-find-method-for-group
8816 (symbol-name group)) 'request-accept-article t)))
8818 (defun gnus-read-move-group-name (prompt default articles prefix)
8819 "Read a group name."
8820 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
8821 (minibuffer-confirm-incomplete nil) ; XEmacs
8825 (if (> (length articles) 1)
8826 (format "these %d articles" (length articles))
8831 (gnus-completing-read default prom
8833 'gnus-valid-move-group-p
8835 'gnus-group-history))
8836 ((= 1 (length split-name))
8837 (gnus-completing-read (car split-name) prom
8839 'gnus-valid-move-group-p
8841 'gnus-group-history))
8843 (gnus-completing-read nil prom
8844 (mapcar (lambda (el) (list el))
8845 (nreverse split-name))
8847 'gnus-group-history)))))
8849 (if (or (string= to-newsgroup "")
8850 (string= to-newsgroup prefix))
8851 (setq to-newsgroup default))
8852 (unless to-newsgroup
8853 (error "No group name entered"))
8854 (or (gnus-active to-newsgroup)
8855 (gnus-activate-group to-newsgroup)
8856 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
8858 (or (and (gnus-request-create-group
8859 to-newsgroup (gnus-group-name-to-method to-newsgroup))
8860 (gnus-activate-group to-newsgroup nil nil
8861 (gnus-group-name-to-method
8863 (error "Couldn't create group %s" to-newsgroup)))
8864 (error "No such group: %s" to-newsgroup)))
8867 (defun gnus-summary-save-parts (type dir n reverse)
8868 "Save parts matching TYPE to DIR.
8869 If REVERSE, save parts that do not match TYPE."
8871 (list (read-string "Save parts of type: " "image/.*")
8872 (read-file-name "Save to directory: " t nil t)
8873 current-prefix-arg))
8874 (gnus-summary-iterate n
8875 (let ((gnus-display-mime-function nil)
8876 (gnus-inhibit-treatment t))
8877 (gnus-summary-select-article))
8879 (set-buffer gnus-article-buffer)
8880 (let ((handles (or (mm-dissect-buffer) (mm-uu-dissect))))
8882 (gnus-summary-save-parts-1 type dir handles reverse))))))
8884 (defun gnus-summary-save-parts-1 (type dir handle reverse)
8885 (if (stringp (car handle))
8886 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
8889 (not (string-match type (car (mm-handle-type handle))))
8890 (string-match type (car (mm-handle-type handle))))
8891 (let ((file (expand-file-name
8892 (file-name-nondirectory
8894 (mail-content-type-get
8895 (mm-handle-disposition handle) 'filename)
8896 (concat gnus-newsgroup-name "." gnus-current-article)))
8898 (unless (file-exists-p file)
8899 (mm-save-part-to-file handle file))))))
8901 ;; Summary extract commands
8903 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
8904 (let ((buffer-read-only nil)
8905 (article (gnus-summary-article-number))
8907 (unless (gnus-summary-goto-subject article)
8908 (error "No such article: %d" article))
8909 (gnus-summary-position-point)
8910 ;; If all commands are to be bunched up on one line, we collect
8912 (unless gnus-view-pseudos-separately
8913 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
8916 (setq action (cdr (assq 'action (car ps))))
8917 (setq files (list (cdr (assq 'name (car ps)))))
8918 (while (and ps (cdr ps)
8919 (string= (or action "1")
8920 (or (cdr (assq 'action (cadr ps))) "2")))
8921 (push (cdr (assq 'name (cadr ps))) files)
8922 (setcdr ps (cddr ps)))
8924 (when (not (string-match "%s" action))
8927 (when (assq 'execute (car ps))
8928 (setcdr (assq 'execute (car ps))
8929 (funcall (if (string-match "%s" action)
8936 (gnus-quote-arg-for-sh-or-csh f)))
8938 (setq ps (cdr ps)))))
8939 (if (and gnus-view-pseudos (not not-view))
8941 (when (assq 'execute (car pslist))
8942 (gnus-execute-command (cdr (assq 'execute (car pslist)))
8943 (eq gnus-view-pseudos 'not-confirm)))
8944 (setq pslist (cdr pslist)))
8947 (setq after-article (or (cdr (assq 'article (car pslist)))
8948 (gnus-summary-article-number)))
8949 (gnus-summary-goto-subject after-article)
8952 (insert " " (file-name-nondirectory
8953 (cdr (assq 'name (car pslist))))
8954 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
8956 (forward-line -1) ; back to `b'
8957 (gnus-add-text-properties
8958 b (1- e) (list 'gnus-number gnus-reffed-article-number
8959 gnus-mouse-face-prop gnus-mouse-face))
8961 after-article gnus-reffed-article-number
8962 gnus-unread-mark b (car pslist) 0 (- e b))
8963 (push gnus-reffed-article-number gnus-newsgroup-unreads)
8964 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
8965 (setq pslist (cdr pslist)))))))
8967 (defun gnus-pseudos< (p1 p2)
8968 (let ((c1 (cdr (assq 'action p1)))
8969 (c2 (cdr (assq 'action p2))))
8970 (and c1 c2 (string< c1 c2))))
8972 (defun gnus-request-pseudo-article (props)
8973 (cond ((assq 'execute props)
8974 (gnus-execute-command (cdr (assq 'execute props)))))
8975 (let ((gnus-current-article (gnus-summary-article-number)))
8976 (gnus-run-hooks 'gnus-mark-article-hook)))
8978 (defun gnus-execute-command (command &optional automatic)
8980 (gnus-article-setup-buffer)
8981 (set-buffer gnus-article-buffer)
8982 (setq buffer-read-only nil)
8983 (let ((command (if automatic command
8984 (read-string "Command: " (cons command 0)))))
8986 (insert "$ " command "\n\n")
8987 (if gnus-view-pseudo-asynchronously
8988 (start-process "gnus-execute" (current-buffer) shell-file-name
8989 shell-command-switch command)
8990 (call-process shell-file-name nil t nil
8991 shell-command-switch command)))))
8993 ;; Summary kill commands.
8995 (defun gnus-summary-edit-global-kill (article)
8996 "Edit the \"global\" kill file."
8997 (interactive (list (gnus-summary-article-number)))
8998 (gnus-group-edit-global-kill article))
9000 (defun gnus-summary-edit-local-kill ()
9001 "Edit a local kill file applied to the current newsgroup."
9003 (setq gnus-current-headers (gnus-summary-article-header))
9004 (gnus-group-edit-local-kill
9005 (gnus-summary-article-number) gnus-newsgroup-name))
9009 (defun gnus-read-header (id &optional header)
9010 "Read the headers of article ID and enter them into the Gnus system."
9011 (let ((group gnus-newsgroup-name)
9012 (gnus-override-method
9013 (and (gnus-news-group-p gnus-newsgroup-name)
9014 gnus-refer-article-method))
9016 ;; First we check to see whether the header in question is already
9019 ;; This is a Message-ID.
9020 (setq header (or header (gnus-id-to-header id)))
9021 ;; This is an article number.
9022 (setq header (or header (gnus-summary-article-header id))))
9024 (not (gnus-summary-article-sparse-p (mail-header-number header))))
9025 ;; We have found the header.
9027 ;; If this is a sparse article, we have to nix out its
9028 ;; previous entry in the thread hashtb.
9030 (gnus-summary-article-sparse-p (mail-header-number header)))
9031 (let* ((parent (gnus-parent-id (mail-header-references header)))
9032 (thread (and parent (gnus-id-to-thread parent))))
9034 (delq (assq header thread) thread))))
9035 ;; We have to really fetch the header to this article.
9037 (set-buffer nntp-server-buffer)
9038 (when (setq where (gnus-request-head id group))
9039 (nnheader-fold-continuation-lines)
9040 (goto-char (point-max))
9042 (goto-char (point-min))
9046 ((cdr where) (cdr where))
9047 (header (mail-header-number header))
9048 (t gnus-reffed-article-number))
9050 (insert " Article retrieved.\n"))
9052 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
9053 () ; Malformed head.
9054 (unless (gnus-summary-article-sparse-p (mail-header-number header))
9055 (when (and (stringp id)
9056 (not (string= (gnus-group-real-name group)
9058 ;; If we fetched by Message-ID and the article came
9059 ;; from a different group, we fudge some bogus article
9060 ;; numbers for this article.
9061 (mail-header-set-number header gnus-reffed-article-number))
9063 (set-buffer gnus-summary-buffer)
9064 (decf gnus-reffed-article-number)
9065 (gnus-remove-header (mail-header-number header))
9066 (push header gnus-newsgroup-headers)
9067 (setq gnus-current-headers header)
9068 (push (mail-header-number header) gnus-newsgroup-limit)))
9071 (defun gnus-remove-header (number)
9072 "Remove header NUMBER from `gnus-newsgroup-headers'."
9073 (if (and gnus-newsgroup-headers
9074 (= number (mail-header-number (car gnus-newsgroup-headers))))
9075 (pop gnus-newsgroup-headers)
9076 (let ((headers gnus-newsgroup-headers))
9077 (while (and (cdr headers)
9078 (not (= number (mail-header-number (cadr headers)))))
9081 (setcdr headers (cddr headers))))))
9084 ;;; summary highlights
9087 (defun gnus-highlight-selected-summary ()
9088 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
9089 ;; Highlight selected article in summary buffer
9090 (when gnus-summary-selected-face
9092 (let* ((beg (progn (beginning-of-line) (point)))
9093 (end (progn (end-of-line) (point)))
9094 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
9095 (from (if (get-text-property beg gnus-mouse-face-prop)
9097 (or (next-single-property-change
9098 beg gnus-mouse-face-prop nil end)
9103 (or (next-single-property-change
9104 from gnus-mouse-face-prop nil end)
9106 ;; If no mouse-face prop on line we will have to = from = end,
9107 ;; so we highlight the entire line instead.
9108 (when (= (+ to 2) from)
9111 (if gnus-newsgroup-selected-overlay
9112 ;; Move old overlay.
9114 gnus-newsgroup-selected-overlay from to (current-buffer))
9115 ;; Create new overlay.
9117 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
9118 'face gnus-summary-selected-face))))))
9120 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
9121 (defun gnus-summary-highlight-line ()
9122 "Highlight current line according to `gnus-summary-highlight'."
9123 (let* ((list gnus-summary-highlight)
9125 (end (progn (end-of-line) (point)))
9126 ;; now find out where the line starts and leave point there.
9127 (beg (progn (beginning-of-line) (point)))
9128 (article (gnus-summary-article-number))
9129 (score (or (cdr (assq (or article gnus-current-article)
9130 gnus-newsgroup-scored))
9131 gnus-summary-default-score 0))
9132 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
9133 (inhibit-read-only t))
9134 ;; Eval the cars of the lists until we find a match.
9135 (let ((default gnus-summary-default-score))
9137 (not (eval (caar list))))
9138 (setq list (cdr list))))
9139 (let ((face (cdar list)))
9140 (unless (eq face (get-text-property beg 'face))
9141 (gnus-put-text-property-excluding-characters-with-faces
9143 (setq face (if (boundp face) (symbol-value face) face)))
9144 (when gnus-summary-highlight-line-function
9145 (funcall gnus-summary-highlight-line-function article face))))
9148 (defun gnus-update-read-articles (group unread &optional compute)
9149 "Update the list of read articles in GROUP."
9150 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
9151 (entry (gnus-gethash group gnus-newsrc-hashtb))
9152 (info (nth 2 entry))
9154 (unread (sort (copy-sequence unread) '<))
9156 (if (or (not info) (not active))
9157 ;; There is no info on this group if it was, in fact,
9158 ;; killed. Gnus stores no information on killed groups, so
9159 ;; there's nothing to be done.
9160 ;; One could store the information somewhere temporarily,
9161 ;; perhaps... Hmmm...
9163 ;; Remove any negative articles numbers.
9164 (while (and unread (< (car unread) 0))
9165 (setq unread (cdr unread)))
9166 ;; Remove any expired article numbers
9167 (while (and unread (< (car unread) (car active)))
9168 (setq unread (cdr unread)))
9169 ;; Compute the ranges of read articles by looking at the list of
9172 (when (/= (car unread) prev)
9173 (push (if (= prev (1- (car unread))) prev
9174 (cons prev (1- (car unread))))
9176 (setq prev (1+ (car unread)))
9177 (setq unread (cdr unread)))
9178 (when (<= prev (cdr active))
9179 (push (cons prev (cdr active)) read))
9180 (setq read (if (> (length read) 1) (nreverse read) read))
9184 (set-buffer gnus-group-buffer)
9187 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
9188 (gnus-info-set-read ',info ',(gnus-info-read info))
9189 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
9190 (gnus-group-update-group ,group t))))
9191 ;; Propagate the read marks to the backend.
9192 (if (gnus-check-backend-function 'request-set-mark group)
9193 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
9194 (add (gnus-remove-from-range read (gnus-info-read info))))
9196 (unless (gnus-check-group group)
9197 (error "Can't open server for %s" group))
9198 (gnus-request-set-mark
9199 group (delq nil (list (if add (list add 'add '(read)))
9200 (if del (list del 'del '(read)))))))))
9201 ;; Enter this list into the group info.
9202 (gnus-info-set-read info read)
9203 ;; Set the number of unread articles in gnus-newsrc-hashtb.
9204 (gnus-get-unread-articles-in-group info (gnus-active group))
9207 (defun gnus-offer-save-summaries ()
9208 "Offer to save all active summary buffers."
9210 (let ((buflist (buffer-list))
9212 ;; Go through all buffers and find all summaries.
9214 (and (setq bufname (buffer-name (car buflist)))
9215 (string-match "Summary" bufname)
9217 (set-buffer bufname)
9218 ;; We check that this is, indeed, a summary buffer.
9219 (and (eq major-mode 'gnus-summary-mode)
9220 ;; Also make sure this isn't bogus.
9221 gnus-newsgroup-prepared
9222 ;; Also make sure that this isn't a dead summary buffer.
9223 (not gnus-dead-summary-mode)))
9224 (push bufname buffers))
9225 (setq buflist (cdr buflist)))
9226 ;; Go through all these summary buffers and offer to save them.
9229 "Update summary buffer %s? "
9231 (switch-to-buffer buf)
9232 (gnus-summary-exit))
9236 ;;; @ for mime-partial
9239 (defun gnus-request-partial-message ()
9241 (let ((number (gnus-summary-article-number))
9242 (group gnus-newsgroup-name)
9243 (mother gnus-article-buffer))
9244 (set-buffer (get-buffer-create " *Partial Article*"))
9246 (setq mime-preview-buffer mother)
9247 (gnus-request-article-this-buffer number group)
9251 (autoload 'mime-combine-message/partial-pieces-automatically
9253 "Internal method to combine message/partial messages automatically.")
9256 'action '((type . message)(subtype . partial)
9257 (major-mode . gnus-original-article-mode)
9258 (method . mime-combine-message/partial-pieces-automatically)
9259 (summary-buffer-exp . gnus-summary-buffer)
9260 (request-partial-message-method . gnus-request-partial-message)
9264 ;;; @ for message/rfc822
9267 (defun gnus-mime-extract-message/rfc822 (entity situation)
9268 (let (group article num cwin swin cur)
9269 (with-current-buffer (mime-entity-buffer entity)
9271 (narrow-to-region (mime-entity-body-start entity)
9272 (mime-entity-body-end entity))
9273 (setq group (or (cdr (assq 'group situation))
9274 (completing-read "Group: "
9277 (gnus-read-active-file-p)
9278 gnus-newsgroup-name))
9279 article (gnus-request-accept-article group)
9282 (when (and (consp article)
9283 (numberp (setq article (cdr article))))
9284 (setq num (1+ (or (cdr (assq 'number situation)) 0))
9285 cwin (get-buffer-window (current-buffer) t)
9287 (save-window-excursion
9288 (if (setq swin (get-buffer-window gnus-summary-buffer t))
9289 (select-window swin)
9290 (set-buffer gnus-summary-buffer)
9292 (setq cur gnus-current-article)
9294 (let (gnus-show-threads)
9295 (gnus-summary-goto-subject article t)
9297 (gnus-summary-clear-mark-forward 1)
9298 (gnus-summary-goto-subject cur)
9300 (when (and cwin (window-frame cwin))
9301 (select-frame (window-frame cwin))
9303 (when (boundp 'mime-acting-situation-to-override)
9304 (set-alist 'mime-acting-situation-to-override
9307 (set-alist 'mime-acting-situation-to-override
9310 (save-current-buffer
9311 (set-buffer gnus-group-buffer)
9312 (gnus-activate-group ,group)
9314 (gnus-summary-goto-article ,cur
9315 gnus-show-all-headers)
9317 (set-alist 'mime-acting-situation-to-override
9323 'action '((type . message)(subtype . rfc822)
9324 (major-mode . gnus-original-article-mode)
9325 (method . gnus-mime-extract-message/rfc822)
9330 'action '((type . message)(subtype . news)
9331 (major-mode . gnus-original-article-mode)
9332 (method . gnus-mime-extract-message/rfc822)
9336 (defun gnus-mime-extract-multipart (entity situation)
9337 (let ((children (mime-entity-children entity))
9338 mime-acting-situation-to-override
9341 (mime-play-entity (car children)
9342 (cons (assq 'mode situation)
9343 mime-acting-situation-to-override))
9344 (setq children (cdr children)))
9345 (if (setq f (cdr (assq 'after-method
9346 mime-acting-situation-to-override)))
9351 'action '((type . multipart)
9352 (method . gnus-mime-extract-multipart)
9361 (defun gnus-summary-setup-default-charset ()
9362 "Setup newsgroup default charset."
9363 (let ((name (and gnus-newsgroup-name
9364 (gnus-group-real-name gnus-newsgroup-name))))
9365 (setq gnus-newsgroup-charset
9366 (or (and gnus-newsgroup-name
9367 (or (gnus-group-find-parameter gnus-newsgroup-name
9369 (let ((alist gnus-group-charset-alist)
9371 (while (setq elem (pop alist))
9373 (string-match (car elem) name))
9375 charset (cadr elem))))
9377 gnus-default-charset))))
9383 (defun gnus-summary-display-buttonized (&optional show-all-parts)
9384 "Display the current article buffer fully MIME-buttonized.
9385 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
9386 treated as multipart/mixed."
9389 (let ((gnus-unbuttonized-mime-types nil)
9390 (gnus-mime-display-multipart-as-mixed show-all-parts))
9391 (gnus-summary-show-article)))
9393 (defun gnus-summary-repair-multipart (article)
9394 "Add a Content-Type header to a multipart article without one."
9395 (interactive (list (gnus-summary-article-number)))
9396 (gnus-with-article article
9397 (message-narrow-to-head)
9398 (goto-char (point-max))
9400 (when (search-forward "\n--" nil t)
9401 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
9402 (message-narrow-to-head)
9403 (message-remove-header "Mime-Version")
9404 (message-remove-header "Content-Type")
9405 (goto-char (point-max))
9406 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
9408 (insert "Mime-Version: 1.0\n")
9410 (let (gnus-mark-article-hook)
9411 (gnus-summary-select-article t t nil article)))
9413 (defun gnus-summary-toggle-display-buttonized ()
9414 "Toggle the buttonizing of the article buffer."
9417 (if (setq gnus-inhibit-mime-unbuttonizing
9418 (not gnus-inhibit-mime-unbuttonizing))
9419 (let ((gnus-unbuttonized-mime-types nil))
9420 (gnus-summary-show-article))
9421 (gnus-summary-show-article)))
9427 (defmacro gnus-with-article (article &rest forms)
9428 "Select ARTICLE and perform FORMS in the original article buffer.
9429 Then replace the article with the result."
9431 ;; We don't want the article to be marked as read.
9432 (let (gnus-mark-article-hook)
9433 (gnus-summary-select-article t t nil ,article))
9434 (set-buffer gnus-original-article-buffer)
9436 (if (not (gnus-check-backend-function
9437 'request-replace-article (car gnus-article-current)))
9438 (gnus-message 5 "Read-only group; not replacing")
9439 (unless (gnus-request-replace-article
9440 ,article (car gnus-article-current)
9442 (error "Couldn't replace article")))
9443 ;; The cache and backlog have to be flushed somewhat.
9444 (when gnus-keep-backlog
9445 (gnus-backlog-remove-article
9446 (car gnus-article-current) (cdr gnus-article-current)))
9447 (when gnus-use-cache
9448 (gnus-cache-update-article
9449 (car gnus-article-current) (cdr gnus-article-current)))))
9451 (put 'gnus-with-article 'lisp-indent-function 1)
9452 (put 'gnus-with-article 'edebug-form-spec '(form body))
9455 ;;; Generic summary marking commands
9458 (defvar gnus-summary-marking-alist
9459 '((read gnus-del-mark "d")
9460 (unread gnus-unread-mark "u")
9461 (ticked gnus-ticked-mark "!")
9462 (dormant gnus-dormant-mark "?")
9463 (expirable gnus-expirable-mark "e"))
9464 "An alist of names/marks/keystrokes.")
9466 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
9467 (defvar gnus-summary-mark-map)
9469 (defun gnus-summary-make-all-marking-commands ()
9470 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
9471 (dolist (elem gnus-summary-marking-alist)
9472 (apply 'gnus-summary-make-marking-command elem)))
9474 (defun gnus-summary-make-marking-command (name mark keystroke)
9475 (let ((map (make-sparse-keymap)))
9476 (define-key gnus-summary-generic-mark-map keystroke map)
9477 (dolist (lway `((next "next" next nil "n")
9478 (next-unread "next unread" next t "N")
9479 (prev "previous" prev nil "p")
9480 (prev-unread "previous unread" prev t "P")
9481 (nomove "" nil nil ,keystroke)))
9482 (let ((func (gnus-summary-make-marking-command-1
9483 mark (car lway) lway name)))
9484 (setq func (eval func))
9485 (define-key map (nth 4 lway) func)))))
9487 (defun gnus-summary-make-marking-command-1 (mark way lway name)
9489 (format "gnus-summary-put-mark-as-%s%s"
9490 name (if (eq way 'nomove)
9492 (concat "-" (symbol-name way)))))
9495 "Mark the current article as %s%s.
9496 If N, the prefix, then repeat N times.
9497 If N is negative, move in reverse order.
9498 The difference between N and the actual number of articles marked is
9502 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
9504 (defun gnus-summary-generic-mark (n mark move unread)
9505 "Mark N articles with MARK."
9506 (unless (eq major-mode 'gnus-summary-mode)
9507 (error "This command can only be used in the summary buffer"))
9508 (gnus-summary-show-thread)
9512 ((eq move 'prev) -1)
9518 nummove (* -1 nummove))))
9520 (gnus-summary-mark-article nil mark)
9521 (zerop (gnus-summary-next-subject nummove unread t)))
9524 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9525 (gnus-summary-recenter)
9526 (gnus-summary-position-point)
9527 (gnus-set-mode-line 'summary)
9530 (gnus-summary-make-all-marking-commands)
9536 (run-hooks 'gnus-sum-load-hook)
9538 ;;; gnus-sum.el ends here